From d060bd118a8b7a884783d4bd214c8b1eaa9ae39c Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Sun, 4 Sep 2016 21:29:59 -0400 Subject: [PATCH] Revert "Finalized the RandomTP" This reverts commit fb43e3c8d718e3e5b36715b02b885b79232bd977. --- plugin.yml | 4 +- src/alisolarflare/RandomTP.java | 45 +++---------------- src/alisolarflare/listeners/CompassLobby.java | 26 ----------- .../ConflictCompassCraftingListener.java | 18 +++----- 4 files changed, 13 insertions(+), 80 deletions(-) delete mode 100644 src/alisolarflare/listeners/CompassLobby.java diff --git a/plugin.yml b/plugin.yml index cd81552..13eb73d 100644 --- a/plugin.yml +++ b/plugin.yml @@ -3,6 +3,4 @@ name: HelloWorldPlugin commands: HelloWorld: - description: Command that says Hello World! - debugRTP: - description: Command that randomly teleports someone inside the hardcore world \ No newline at end of file + description: Command that says Hello World! \ No newline at end of file diff --git a/src/alisolarflare/RandomTP.java b/src/alisolarflare/RandomTP.java index 78b2094..f9c1016 100644 --- a/src/alisolarflare/RandomTP.java +++ b/src/alisolarflare/RandomTP.java @@ -3,15 +3,10 @@ package alisolarflare; import org.bukkit.Location; import org.bukkit.Material; 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 iie.HelloWorldPlugin; - -public class RandomTP implements CommandExecutor{ +public class RandomTP{ private int conflictX; private int conflictZ; @@ -20,12 +15,6 @@ public class RandomTP implements CommandExecutor{ private boolean southUsed; private boolean eastUsed; 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. //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){ @@ -132,31 +121,26 @@ public class RandomTP implements CommandExecutor{ //Randomly teleports a player, into the hardcore world 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 int xdifference = minLocation.getBlockX() - maxLocation.getBlockX(); int xAverage = (int) Math.floor(minLocation.getBlockX() + maxLocation.getBlockX() / 2); - + //INIT - zDifference, zAverage int zdifference = minLocation.getBlockX() - maxLocation.getBlockY(); int zAverage = (int) Math.floor(minLocation.getBlockZ() + maxLocation.getBlockZ()); - player.sendMessage("Averages : " + xAverage + "|" + zAverage); + //TELEPORTS - Tries 20 times to find a location for(int i = 0; i < 20; i ++){ - + //INIT - attemptedX, attemptedZ int attemptedX = (int) Math.floor((Math.random()-0.5)*xdifference) + xAverage; int attemptedZ = (int) Math.floor((Math.random()-0.5)*zdifference) + zAverage; - player.sendMessage("TAKE " + i + " : " + attemptedX + ", "+ attemptedZ); + //CHECKS - if ground is safe boolean groundisSafe = world.getHighestBlockAt(attemptedX, attemptedZ).getType() != Material.WATER; if (groundisSafe){ - player.sendMessage("SAFE GROUND, TELEPORTING"); player.teleport(world.getHighestBlockAt(attemptedX, attemptedZ).getLocation()); return; } @@ -164,21 +148,4 @@ public class RandomTP implements CommandExecutor{ //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; - } } diff --git a/src/alisolarflare/listeners/CompassLobby.java b/src/alisolarflare/listeners/CompassLobby.java deleted file mode 100644 index a07f676..0000000 --- a/src/alisolarflare/listeners/CompassLobby.java +++ /dev/null @@ -1,26 +0,0 @@ -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); - } -} diff --git a/src/alisolarflare/listeners/ConflictCompassCraftingListener.java b/src/alisolarflare/listeners/ConflictCompassCraftingListener.java index ab26daf..ee2c355 100644 --- a/src/alisolarflare/listeners/ConflictCompassCraftingListener.java +++ b/src/alisolarflare/listeners/ConflictCompassCraftingListener.java @@ -14,27 +14,21 @@ import org.bukkit.event.inventory.CraftItemEvent; import org.bukkit.inventory.ItemStack; public class ConflictCompassCraftingListener implements Listener{ - public static void main(String[] args){ - String nulltest = null; - if(nulltest == null){ - System.out.println("NUUUUULL"); - } - } @EventHandler public boolean onConflictCompassCraft(CraftItemEvent event){ //SANITATION - HARDCORE - if(event.getWhoClicked().getWorld().getName() != "hardcore") + if(event.getWhoClicked().getWorld().getName() != "hardcore"){ return false; - + } //INIT - targetItem ItemStack targetItem = event.getRecipe().getResult(); //SANITATION - NOT COMPASS - if(targetItem.getType() != Material.COMPASS) + if(targetItem.getType() != Material.COMPASS){ return false; - + } event.setCancelled(true); //GIVE - chainmail chestplate @@ -66,9 +60,9 @@ public class ConflictCompassCraftingListener implements Listener{ nearestPlayer = player; } } - if(nearestPlayer == null) + if(nearestPlayer == null){ return "METAL"; - + } return nearestPlayer.toString(); } }