Try to merge my commit, past the conflicts
This commit is contained in:
parent
7c82d7879a
commit
59d8dc791c
4 changed files with 82 additions and 13 deletions
|
@ -4,3 +4,7 @@
|
||||||
commands:
|
commands:
|
||||||
hardcore:
|
hardcore:
|
||||||
description: Command that teleports you to hardcore world
|
description: Command that teleports you to hardcore world
|
||||||
|
HelloWorld:
|
||||||
|
description: Command that says Hello World!
|
||||||
|
debugRTP:
|
||||||
|
description: Command that randomly teleports someone inside the hardcore world
|
|
@ -3,9 +3,14 @@ package alisolarflare;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class RandomTP{
|
import iie.HelloWorldPlugin;
|
||||||
|
|
||||||
|
public class RandomTP implements CommandExecutor{
|
||||||
|
|
||||||
private int conflictX;
|
private int conflictX;
|
||||||
private int conflictZ;
|
private int conflictZ;
|
||||||
|
@ -14,6 +19,12 @@ public class RandomTP{
|
||||||
private boolean southUsed;
|
private boolean southUsed;
|
||||||
private boolean eastUsed;
|
private boolean eastUsed;
|
||||||
private boolean westUsed;
|
private boolean westUsed;
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private HelloWorldPlugin helloWorldPlugin;
|
||||||
|
public RandomTP(HelloWorldPlugin helloWorldPlugin) {
|
||||||
|
this.helloWorldPlugin = helloWorldPlugin;
|
||||||
|
}
|
||||||
|
|
||||||
//every 4 players who use it will be teleported near each other.
|
//every 4 players who use it will be teleported near each other.
|
||||||
//ex. iie > 1200, ali -> 1210, byz -> 1190, charles -> 1195, wind -> 300, zan -> 310, etc
|
//ex. iie > 1200, ali -> 1210, byz -> 1190, charles -> 1195, wind -> 300, zan -> 310, etc
|
||||||
public void conflictRtp(Player player, World world, Location minLocation, Location maxLocation){
|
public void conflictRtp(Player player, World world, Location minLocation, Location maxLocation){
|
||||||
|
@ -120,7 +131,11 @@ public class RandomTP{
|
||||||
|
|
||||||
//Randomly teleports a player, into the hardcore world
|
//Randomly teleports a player, into the hardcore world
|
||||||
public void rtp(Player player, World world, Location minLocation, Location maxLocation){
|
public void rtp(Player player, World world, Location minLocation, Location maxLocation){
|
||||||
|
player.sendMessage("TELEPORT INITIATED");
|
||||||
|
player.sendMessage("minLocation: " + minLocation.toString());
|
||||||
|
player.sendMessage("maxLocation: " + maxLocation.toString());
|
||||||
|
player.sendMessage("world : " + world.toString());
|
||||||
|
player.sendMessage("player : " + player.toString());
|
||||||
|
|
||||||
//INIT - xDifference, xAverage
|
//INIT - xDifference, xAverage
|
||||||
int xdifference = minLocation.getBlockX() - maxLocation.getBlockX();
|
int xdifference = minLocation.getBlockX() - maxLocation.getBlockX();
|
||||||
|
@ -129,17 +144,18 @@ public class RandomTP{
|
||||||
//INIT - zDifference, zAverage
|
//INIT - zDifference, zAverage
|
||||||
int zdifference = minLocation.getBlockX() - maxLocation.getBlockY();
|
int zdifference = minLocation.getBlockX() - maxLocation.getBlockY();
|
||||||
int zAverage = (int) Math.floor(minLocation.getBlockZ() + maxLocation.getBlockZ());
|
int zAverage = (int) Math.floor(minLocation.getBlockZ() + maxLocation.getBlockZ());
|
||||||
|
player.sendMessage("Averages : " + xAverage + "|" + zAverage);
|
||||||
//TELEPORTS - Tries 20 times to find a location
|
//TELEPORTS - Tries 20 times to find a location
|
||||||
for(int i = 0; i < 20; i ++){
|
for(int i = 0; i < 20; i ++){
|
||||||
|
|
||||||
//INIT - attemptedX, attemptedZ
|
//INIT - attemptedX, attemptedZ
|
||||||
int attemptedX = (int) Math.floor((Math.random()-0.5)*xdifference) + xAverage;
|
int attemptedX = (int) Math.floor((Math.random()-0.5)*xdifference) + xAverage;
|
||||||
int attemptedZ = (int) Math.floor((Math.random()-0.5)*zdifference) + zAverage;
|
int attemptedZ = (int) Math.floor((Math.random()-0.5)*zdifference) + zAverage;
|
||||||
|
player.sendMessage("TAKE " + i + " : " + attemptedX + ", "+ attemptedZ);
|
||||||
//CHECKS - if ground is safe
|
//CHECKS - if ground is safe
|
||||||
boolean groundisSafe = world.getHighestBlockAt(attemptedX, attemptedZ).getType() != Material.WATER;
|
boolean groundisSafe = world.getHighestBlockAt(attemptedX, attemptedZ).getType() != Material.WATER;
|
||||||
if (groundisSafe){
|
if (groundisSafe){
|
||||||
|
player.sendMessage("SAFE GROUND, TELEPORTING");
|
||||||
player.teleport(world.getHighestBlockAt(attemptedX, attemptedZ).getLocation());
|
player.teleport(world.getHighestBlockAt(attemptedX, attemptedZ).getLocation());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -147,4 +163,21 @@ public class RandomTP{
|
||||||
//player.teleport(arg0)
|
//player.teleport(arg0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if(!(sender instanceof Player)){
|
||||||
|
sender.sendMessage("You must be a Player to use this command!");
|
||||||
|
sender.sendMessage(sender.toString());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Player player = (Player) sender;
|
||||||
|
if(player.getWorld().getName() != "hardcore"){
|
||||||
|
sender.sendMessage("You must be in the hardcore world to use this command!");
|
||||||
|
sender.sendMessage("Current World: " + player.getWorld().getName());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
rtp(player, player.getWorld(), new Location(player.getWorld(), 644, 65, -944), new Location(player.getWorld(), 1700, 65, 464));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
26
src/alisolarflare/listeners/CompassLobby.java
Normal file
26
src/alisolarflare/listeners/CompassLobby.java
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
package alisolarflare.listeners;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
|
||||||
|
public class CompassLobby implements Listener{
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerJoin(PlayerJoinEvent event){
|
||||||
|
openGUI(event.getPlayer());
|
||||||
|
}
|
||||||
|
public void openGUI(Player p){
|
||||||
|
//format: null, size of inventory (must be divisible by 9), "GUI name"
|
||||||
|
Inventory inv = Bukkit.createInventory(null, 9, "GUI Name");
|
||||||
|
inv.setItem(0, new ItemStack(Material.GRASS));
|
||||||
|
inv.setItem(1, new ItemStack(Material.IRON_SWORD));
|
||||||
|
inv.setItem(8, new ItemStack(Material.BARRIER));
|
||||||
|
p.openInventory(inv);
|
||||||
|
}
|
||||||
|
}
|
|
@ -14,21 +14,27 @@ import org.bukkit.event.inventory.CraftItemEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class ConflictCompassCraftingListener implements Listener{
|
public class ConflictCompassCraftingListener implements Listener{
|
||||||
|
public static void main(String[] args){
|
||||||
|
String nulltest = null;
|
||||||
|
if(nulltest == null){
|
||||||
|
System.out.println("NUUUUULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public boolean onConflictCompassCraft(CraftItemEvent event){
|
public boolean onConflictCompassCraft(CraftItemEvent event){
|
||||||
//SANITATION - HARDCORE
|
//SANITATION - HARDCORE
|
||||||
if(event.getWhoClicked().getWorld().getName() != "hardcore"){
|
if(event.getWhoClicked().getWorld().getName() != "hardcore")
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
//INIT - targetItem
|
//INIT - targetItem
|
||||||
ItemStack targetItem = event.getRecipe().getResult();
|
ItemStack targetItem = event.getRecipe().getResult();
|
||||||
|
|
||||||
//SANITATION - NOT COMPASS
|
//SANITATION - NOT COMPASS
|
||||||
if(targetItem.getType() != Material.COMPASS){
|
if(targetItem.getType() != Material.COMPASS)
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
//GIVE - chainmail chestplate
|
//GIVE - chainmail chestplate
|
||||||
|
@ -60,9 +66,9 @@ public class ConflictCompassCraftingListener implements Listener{
|
||||||
nearestPlayer = player;
|
nearestPlayer = player;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(nearestPlayer == null){
|
if(nearestPlayer == null)
|
||||||
return "METAL";
|
return "METAL";
|
||||||
}
|
|
||||||
return nearestPlayer.toString();
|
return nearestPlayer.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue