diff --git a/.classpath b/.classpath
index 5edfce4..add9899 100644
--- a/.classpath
+++ b/.classpath
@@ -3,6 +3,6 @@
-
+
diff --git a/bin/me/Travja/HungerArena/BlockStorage.class b/bin/me/Travja/HungerArena/BlockStorage.class
new file mode 100644
index 0000000..9b80152
Binary files /dev/null and b/bin/me/Travja/HungerArena/BlockStorage.class differ
diff --git a/bin/me/Travja/HungerArena/Chests.class b/bin/me/Travja/HungerArena/Chests.class
index 623d346..0711b47 100644
Binary files a/bin/me/Travja/HungerArena/Chests.class and b/bin/me/Travja/HungerArena/Chests.class differ
diff --git a/bin/me/Travja/HungerArena/CommandBlock.class b/bin/me/Travja/HungerArena/CommandBlock.class
index d8963f9..717f261 100644
Binary files a/bin/me/Travja/HungerArena/CommandBlock.class and b/bin/me/Travja/HungerArena/CommandBlock.class differ
diff --git a/bin/me/Travja/HungerArena/DeathListener.class b/bin/me/Travja/HungerArena/DeathListener.class
index 35eccfe..39875f2 100644
Binary files a/bin/me/Travja/HungerArena/DeathListener.class and b/bin/me/Travja/HungerArena/DeathListener.class differ
diff --git a/bin/me/Travja/HungerArena/HaCommands$10.class b/bin/me/Travja/HungerArena/HaCommands$10.class
index 9348a22..dc858a2 100644
Binary files a/bin/me/Travja/HungerArena/HaCommands$10.class and b/bin/me/Travja/HungerArena/HaCommands$10.class differ
diff --git a/bin/me/Travja/HungerArena/HaCommands$11.class b/bin/me/Travja/HungerArena/HaCommands$11.class
index 9d7725a..1e4ae17 100644
Binary files a/bin/me/Travja/HungerArena/HaCommands$11.class and b/bin/me/Travja/HungerArena/HaCommands$11.class differ
diff --git a/bin/me/Travja/HungerArena/HaCommands$12.class b/bin/me/Travja/HungerArena/HaCommands$12.class
index 0ebeece..ddc0b55 100644
Binary files a/bin/me/Travja/HungerArena/HaCommands$12.class and b/bin/me/Travja/HungerArena/HaCommands$12.class differ
diff --git a/bin/me/Travja/HungerArena/HaCommands$13.class b/bin/me/Travja/HungerArena/HaCommands$13.class
index 06d297a..e234539 100644
Binary files a/bin/me/Travja/HungerArena/HaCommands$13.class and b/bin/me/Travja/HungerArena/HaCommands$13.class differ
diff --git a/bin/me/Travja/HungerArena/HaCommands$14.class b/bin/me/Travja/HungerArena/HaCommands$14.class
index c5cb35e..1301b53 100644
Binary files a/bin/me/Travja/HungerArena/HaCommands$14.class and b/bin/me/Travja/HungerArena/HaCommands$14.class differ
diff --git a/bin/me/Travja/HungerArena/HaCommands$15.class b/bin/me/Travja/HungerArena/HaCommands$15.class
index e19baa9..e55a5fc 100644
Binary files a/bin/me/Travja/HungerArena/HaCommands$15.class and b/bin/me/Travja/HungerArena/HaCommands$15.class differ
diff --git a/bin/me/Travja/HungerArena/HaCommands$16.class b/bin/me/Travja/HungerArena/HaCommands$16.class
index 1cc08d0..7229692 100644
Binary files a/bin/me/Travja/HungerArena/HaCommands$16.class and b/bin/me/Travja/HungerArena/HaCommands$16.class differ
diff --git a/bin/me/Travja/HungerArena/HaCommands$17.class b/bin/me/Travja/HungerArena/HaCommands$17.class
index bd34681..c3f436b 100644
Binary files a/bin/me/Travja/HungerArena/HaCommands$17.class and b/bin/me/Travja/HungerArena/HaCommands$17.class differ
diff --git a/bin/me/Travja/HungerArena/HaCommands$18.class b/bin/me/Travja/HungerArena/HaCommands$18.class
index 46fb3ad..f7e2f9e 100644
Binary files a/bin/me/Travja/HungerArena/HaCommands$18.class and b/bin/me/Travja/HungerArena/HaCommands$18.class differ
diff --git a/bin/me/Travja/HungerArena/HaCommands$19.class b/bin/me/Travja/HungerArena/HaCommands$19.class
index c44b694..6d9a04f 100644
Binary files a/bin/me/Travja/HungerArena/HaCommands$19.class and b/bin/me/Travja/HungerArena/HaCommands$19.class differ
diff --git a/bin/me/Travja/HungerArena/HaCommands$2.class b/bin/me/Travja/HungerArena/HaCommands$2.class
index 62104bc..dcb2d6d 100644
Binary files a/bin/me/Travja/HungerArena/HaCommands$2.class and b/bin/me/Travja/HungerArena/HaCommands$2.class differ
diff --git a/bin/me/Travja/HungerArena/HaCommands$20.class b/bin/me/Travja/HungerArena/HaCommands$20.class
index 222612b..17bba19 100644
Binary files a/bin/me/Travja/HungerArena/HaCommands$20.class and b/bin/me/Travja/HungerArena/HaCommands$20.class differ
diff --git a/bin/me/Travja/HungerArena/HaCommands$21.class b/bin/me/Travja/HungerArena/HaCommands$21.class
index bb7d045..4671e28 100644
Binary files a/bin/me/Travja/HungerArena/HaCommands$21.class and b/bin/me/Travja/HungerArena/HaCommands$21.class differ
diff --git a/bin/me/Travja/HungerArena/HaCommands$22.class b/bin/me/Travja/HungerArena/HaCommands$22.class
index f257183..6659060 100644
Binary files a/bin/me/Travja/HungerArena/HaCommands$22.class and b/bin/me/Travja/HungerArena/HaCommands$22.class differ
diff --git a/bin/me/Travja/HungerArena/HaCommands$23.class b/bin/me/Travja/HungerArena/HaCommands$23.class
index a552661..12922aa 100644
Binary files a/bin/me/Travja/HungerArena/HaCommands$23.class and b/bin/me/Travja/HungerArena/HaCommands$23.class differ
diff --git a/bin/me/Travja/HungerArena/HaCommands$24.class b/bin/me/Travja/HungerArena/HaCommands$24.class
index 101d452..5fa3938 100644
Binary files a/bin/me/Travja/HungerArena/HaCommands$24.class and b/bin/me/Travja/HungerArena/HaCommands$24.class differ
diff --git a/bin/me/Travja/HungerArena/HaCommands$25.class b/bin/me/Travja/HungerArena/HaCommands$25.class
new file mode 100644
index 0000000..eb9bd52
Binary files /dev/null and b/bin/me/Travja/HungerArena/HaCommands$25.class differ
diff --git a/bin/me/Travja/HungerArena/HaCommands$26.class b/bin/me/Travja/HungerArena/HaCommands$26.class
new file mode 100644
index 0000000..51d78a2
Binary files /dev/null and b/bin/me/Travja/HungerArena/HaCommands$26.class differ
diff --git a/bin/me/Travja/HungerArena/HaCommands$3.class b/bin/me/Travja/HungerArena/HaCommands$3.class
index 64f4918..e38bed1 100644
Binary files a/bin/me/Travja/HungerArena/HaCommands$3.class and b/bin/me/Travja/HungerArena/HaCommands$3.class differ
diff --git a/bin/me/Travja/HungerArena/HaCommands$4.class b/bin/me/Travja/HungerArena/HaCommands$4.class
index f6c3ff9..05eb795 100644
Binary files a/bin/me/Travja/HungerArena/HaCommands$4.class and b/bin/me/Travja/HungerArena/HaCommands$4.class differ
diff --git a/bin/me/Travja/HungerArena/HaCommands$5.class b/bin/me/Travja/HungerArena/HaCommands$5.class
index 1521c95..fa14c4f 100644
Binary files a/bin/me/Travja/HungerArena/HaCommands$5.class and b/bin/me/Travja/HungerArena/HaCommands$5.class differ
diff --git a/bin/me/Travja/HungerArena/HaCommands$6.class b/bin/me/Travja/HungerArena/HaCommands$6.class
index ac95474..62e1c20 100644
Binary files a/bin/me/Travja/HungerArena/HaCommands$6.class and b/bin/me/Travja/HungerArena/HaCommands$6.class differ
diff --git a/bin/me/Travja/HungerArena/HaCommands$7.class b/bin/me/Travja/HungerArena/HaCommands$7.class
index 7e4874b..7108739 100644
Binary files a/bin/me/Travja/HungerArena/HaCommands$7.class and b/bin/me/Travja/HungerArena/HaCommands$7.class differ
diff --git a/bin/me/Travja/HungerArena/HaCommands$8.class b/bin/me/Travja/HungerArena/HaCommands$8.class
index 76d7b3b..a251c03 100644
Binary files a/bin/me/Travja/HungerArena/HaCommands$8.class and b/bin/me/Travja/HungerArena/HaCommands$8.class differ
diff --git a/bin/me/Travja/HungerArena/HaCommands$9.class b/bin/me/Travja/HungerArena/HaCommands$9.class
index 8f99b94..d62f57d 100644
Binary files a/bin/me/Travja/HungerArena/HaCommands$9.class and b/bin/me/Travja/HungerArena/HaCommands$9.class differ
diff --git a/bin/me/Travja/HungerArena/HaCommands.class b/bin/me/Travja/HungerArena/HaCommands.class
index 7e5c3d3..8121eee 100644
Binary files a/bin/me/Travja/HungerArena/HaCommands.class and b/bin/me/Travja/HungerArena/HaCommands.class differ
diff --git a/bin/me/Travja/HungerArena/JoinAndQuitListener$1.class b/bin/me/Travja/HungerArena/JoinAndQuitListener$1.class
index fba4f9b..6606691 100644
Binary files a/bin/me/Travja/HungerArena/JoinAndQuitListener$1.class and b/bin/me/Travja/HungerArena/JoinAndQuitListener$1.class differ
diff --git a/bin/me/Travja/HungerArena/JoinAndQuitListener$2.class b/bin/me/Travja/HungerArena/JoinAndQuitListener$2.class
index fb7335d..011d9ff 100644
Binary files a/bin/me/Travja/HungerArena/JoinAndQuitListener$2.class and b/bin/me/Travja/HungerArena/JoinAndQuitListener$2.class differ
diff --git a/bin/me/Travja/HungerArena/JoinAndQuitListener$3.class b/bin/me/Travja/HungerArena/JoinAndQuitListener$3.class
index 0ba3cff..156cc74 100644
Binary files a/bin/me/Travja/HungerArena/JoinAndQuitListener$3.class and b/bin/me/Travja/HungerArena/JoinAndQuitListener$3.class differ
diff --git a/bin/me/Travja/HungerArena/JoinAndQuitListener.class b/bin/me/Travja/HungerArena/JoinAndQuitListener.class
index f21cdce..508b0c8 100644
Binary files a/bin/me/Travja/HungerArena/JoinAndQuitListener.class and b/bin/me/Travja/HungerArena/JoinAndQuitListener.class differ
diff --git a/bin/me/Travja/HungerArena/Main.class b/bin/me/Travja/HungerArena/Main.class
index 40cc134..a8f907b 100644
Binary files a/bin/me/Travja/HungerArena/Main.class and b/bin/me/Travja/HungerArena/Main.class differ
diff --git a/bin/me/Travja/HungerArena/SpectatorListener$1.class b/bin/me/Travja/HungerArena/SpectatorListener$1.class
index 9f19b3e..de8703a 100644
Binary files a/bin/me/Travja/HungerArena/SpectatorListener$1.class and b/bin/me/Travja/HungerArena/SpectatorListener$1.class differ
diff --git a/bin/me/Travja/HungerArena/SpectatorListener.class b/bin/me/Travja/HungerArena/SpectatorListener.class
index d4e58c8..e168b89 100644
Binary files a/bin/me/Travja/HungerArena/SpectatorListener.class and b/bin/me/Travja/HungerArena/SpectatorListener.class differ
diff --git a/config.yml b/config.yml
index facbf97..b7bbabf 100644
--- a/config.yml
+++ b/config.yml
@@ -19,7 +19,7 @@ Sponsor_Cost:
Amount: 1
# Whether or not the countdown will start upon warping.
Countdown: 'true'
-Spawn_coords: 100,100,100
+Spawn_coords: 100,100,100,world
# If players will only talk to close players of the whole server
ChatClose: 'true'
# How close the players have to be to talk to them
@@ -55,4 +55,5 @@ Tribute_twentytwo_spawn: 100,100,100
Tribute_twentythree_spawn: 100,100,100
Tribute_twentyfour_spawn: 100,100,100
# If /ha setspawn has been run
-Spawn_set: 'false'
\ No newline at end of file
+Spawn_set: 'false'
+Blocks_Destroyed:
\ No newline at end of file
diff --git a/src/me/Travja/HungerArena/BlockStorage.java b/src/me/Travja/HungerArena/BlockStorage.java
new file mode 100644
index 0000000..ff6b675
--- /dev/null
+++ b/src/me/Travja/HungerArena/BlockStorage.java
@@ -0,0 +1,289 @@
+package me.Travja.HungerArena;
+
+import java.util.List;
+
+import org.bukkit.Location;
+import org.bukkit.Material;
+import org.bukkit.block.Block;
+import org.bukkit.block.BlockFace;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.block.BlockBreakEvent;
+import org.bukkit.event.block.BlockBurnEvent;
+import org.bukkit.event.block.BlockFadeEvent;
+import org.bukkit.event.block.BlockFormEvent;
+import org.bukkit.event.block.BlockGrowEvent;
+import org.bukkit.event.block.BlockPhysicsEvent;
+import org.bukkit.event.block.BlockPistonExtendEvent;
+import org.bukkit.event.block.BlockPlaceEvent;
+import org.bukkit.event.block.LeavesDecayEvent;
+import org.bukkit.event.entity.EntityExplodeEvent;
+import org.bukkit.event.player.PlayerBucketEmptyEvent;
+import org.bukkit.event.player.PlayerBucketFillEvent;
+
+public class BlockStorage implements Listener {
+ public Main plugin;
+ public BlockStorage(Main m) {
+ this.plugin = m;
+ }
+ /*@EventHandler
+ public void creeperExplosion(EntityExplodeEvent event){
+ if(plugin.canjoin== true){
+ for(Block b:event.blockList()){
+ String w = b.getWorld().getName();
+ int x = b.getX();
+ int y = b.getY();
+ int z = b.getZ();
+ int d = b.getTypeId();
+ String coords = w + "," + x + "," + y + "," + z + "," + d;
+ System.out.println("Explode: " + coords);
+ List blocks = plugin.config.getStringList("Blocks_Destroyed");
+ blocks.add(coords);
+ plugin.config.set("Blocks_Destroyed", blocks);
+ plugin.saveConfig();
+ }
+ }
+ }
+ @EventHandler
+ public void burningBlocks(BlockBurnEvent event){
+ if(plugin.canjoin== true){
+ Block b = event.getBlock();
+ String w = b.getWorld().getName();
+ int x = b.getX();
+ int y = b.getY();
+ int z = b.getZ();
+ int d = b.getTypeId();
+ String coords = w + "," + x + "," + y + "," + z + "," + d;
+ System.out.println("Burn: " + coords);
+ List blocks = plugin.config.getStringList("Blocks_Destroyed");
+ blocks.add(coords);
+ plugin.config.set("Blocks_Destroyed", blocks);
+ plugin.saveConfig();
+ }
+ }
+ @EventHandler
+ public void leafDecay(LeavesDecayEvent event){
+ if(plugin.canjoin== true){
+ Block b = event.getBlock();
+ String w = b.getWorld().getName();
+ int x = b.getX();
+ int y = b.getY();
+ int z = b.getZ();
+ int d = b.getTypeId();
+ String coords = w + "," + x + "," + y + "," + z + "," + d;
+ System.out.println("Decay: " + coords);
+ List blocks = plugin.config.getStringList("Blocks_Destroyed");
+ blocks.add(coords);
+ plugin.config.set("Blocks_Destroyed", blocks);
+ plugin.saveConfig();
+ }
+ }
+ @EventHandler
+ public void blockPlace(BlockPlaceEvent event){
+ if(plugin.canjoin== true){
+ Block b = event.getBlock();
+ String w = b.getWorld().getName();
+ int x = b.getX();
+ int y = b.getY();
+ int z = b.getZ();
+ int d = b.getTypeId();
+ String coords = w + "," + x + "," + y + "," + z + "," + d;
+ if(!(d== 51) && !(d==12){
+ System.out.println("Place: " + coords);
+ List blocks = plugin.config.getStringList("Blocks_Placed");
+ blocks.add(coords);
+ plugin.config.set("Blocks_Placed", blocks);
+ plugin.saveConfig();
+ }
+ Location location = b.getLocation();
+ if (b.getType() == Material.SAND || b.getType() == Material.GRAVEL) {
+ if (location.getBlock().getRelative(BlockFace.DOWN).getType() == Material.AIR) {
+ int i = 0;
+ for (i = location.getBlockY(); i > -1; i --) {
+ location = new Location(location.getWorld(), location.getBlockX(), i, location.getBlockZ());
+ if (location.getBlock().getType() != Material.AIR && location.getBlock().getType() != Material.WATER && location.getBlock().getType() != Material.LAVA) {
+ break;
+ }
+ event.getPlayer().sendMessage("Block will land at: " + location);
+ System.out.println("Sand Place: " + coords);
+ List blocks = plugin.config.getStringList("Blocks_Destroyed");
+ blocks.add(coords);
+ plugin.config.set("Blocks_Destroyed", blocks);
+ plugin.saveConfig();
+ }
+ }
+ }
+ }
+ }
+ @EventHandler
+ public void bucketEmpty(PlayerBucketEmptyEvent event){
+ if(plugin.canjoin== true){
+ Block clicked = event.getBlockClicked();
+ BlockFace face = event.getBlockFace();
+ Block b = clicked.getRelative(face);
+ String w = b.getWorld().getName();
+ int x = b.getX();
+ int y = b.getY();
+ int z = b.getZ();
+ int d = b.getTypeId();
+ String coords = w + "," + x + "," + y + "," + z + "," + d;
+ System.out.println("Bucket Empty: " + coords);
+ List blocks = plugin.config.getStringList("Blocks_Placed");
+ blocks.add(coords);
+ plugin.config.set("Blocks_Destroyed", blocks);
+ plugin.saveConfig();
+ }
+ }
+ @EventHandler
+ public void bucketFill(PlayerBucketFillEvent event){
+ if(plugin.canjoin== true){
+ Block b = event.getBlockClicked();
+ String w = b.getWorld().getName();
+ int x = b.getX();
+ int y = b.getY();
+ int z = b.getZ();
+ int d = b.getTypeId();
+ String coords = w + "," + x + "," + y + "," + z + "," + d;
+ System.out.println("Bucket Fill: " + coords);
+ List blocks = plugin.config.getStringList("Blocks_Destroyed");
+ blocks.add(coords);
+ plugin.config.set("Blocks_Destroyed", blocks);
+ plugin.saveConfig();
+ }
+ }
+ @EventHandler
+ public void blockBreak(BlockBreakEvent event){
+ if(plugin.canjoin== true){
+ Block b = event.getBlock();
+ String w = b.getWorld().getName();
+ int x = b.getX();
+ int y = b.getY();
+ int z = b.getZ();
+ int d = b.getTypeId();
+ String coords = w + "," + x + "," + y + "," + z + "," + d;
+ System.out.println("Break: " + coords);
+ List blocks = plugin.config.getStringList("Blocks_Destroyed");
+ blocks.add(coords);
+ plugin.config.set("Blocks_Destroyed", blocks);
+ plugin.saveConfig();
+ }
+ }
+ @EventHandler
+ public void blockMelt(BlockFadeEvent event){
+ if(plugin.canjoin== true){
+ Block b = event.getBlock();
+ String w = b.getWorld().getName();
+ int x = b.getX();
+ int y = b.getY();
+ int z = b.getZ();
+ int d = b.getTypeId();
+ String coords = w + "," + x + "," + y + "," + z + "," + d;
+ System.out.println("Fade: " + coords);
+ List blocks = plugin.config.getStringList("Blocks_Destroyed");
+ blocks.add(coords);
+ plugin.config.set("Blocks_Destroyed", blocks);
+ plugin.saveConfig();
+ }
+ }
+ @EventHandler
+ public void blockGrow(BlockGrowEvent event){
+ if(plugin.canjoin== true){
+ Block b = event.getBlock();
+ String w = b.getWorld().getName();
+ int x = b.getX();
+ int y = b.getY();
+ int z = b.getZ();
+ int d = b.getTypeId();
+ String coords = w + "," + x + "," + y + "," + z + "," + d;
+ System.out.println("Grow: " + coords);
+ List blocks = plugin.config.getStringList("Blocks_Placed");
+ blocks.add(coords);
+ plugin.config.set("Blocks_Destroyed", blocks);
+ plugin.saveConfig();
+ }
+ }
+ @EventHandler
+ public void blockForm(BlockFormEvent event){
+ if(plugin.canjoin== true){
+ Block b = event.getBlock();
+ String w = b.getWorld().getName();
+ int x = b.getX();
+ int y = b.getY();
+ int z = b.getZ();
+ int d = b.getTypeId();
+ String coords = w + "," + x + "," + y + "," + z + "," + d;
+ System.out.println("Snowfall: " + coords);
+ List blocks = plugin.config.getStringList("Blocks_Placed");
+ blocks.add(coords);
+ plugin.config.set("Blocks_Destroyed", blocks);
+ plugin.saveConfig();
+ }
+ }
+ @EventHandler
+ public void pistonPush(BlockPistonExtendEvent event){
+ if(plugin.canjoin== true){
+ for(Block b:event.getBlocks()){
+ String w = b.getWorld().getName();
+ int x = b.getX();
+ int y = b.getY();
+ int z = b.getZ();
+ int d = b.getTypeId();
+ String coords = w + "," + x + "," + y + "," + z + "," + d;
+ System.out.println("Piston: " + coords);
+ List blocks = plugin.config.getStringList("Blocks_Destroyed");
+ blocks.add(coords);
+ plugin.config.set("Blocks_Destroyed", blocks);
+ plugin.saveConfig();
+ }
+ }
+ }
+ @EventHandler
+ public void onChange(BlockPhysicsEvent event){
+ Block block = event.getBlock();
+ Material changed = event.getChangedType();
+ if (block.getType() == Material.LAVA){
+ if (changed == Material.LAVA){
+ Block b = event.getBlock();
+ String w = b.getWorld().getName();
+ int x = b.getX();
+ int y = b.getY();
+ int z = b.getZ();
+ int d = b.getTypeId();
+ String coords = w + "," + x + "," + y + "," + z + "," + d;
+ System.out.println("Lava Change: " + coords);
+ List blocks = plugin.config.getStringList("Blocks_Placed");
+ blocks.add(coords);
+ plugin.config.set("Blocks_Destroyed", blocks);
+ plugin.saveConfig();
+ }else if(changed == Material.WATER){
+ Block b = event.getBlock();
+ String w = b.getWorld().getName();
+ int x = b.getX();
+ int y = b.getY();
+ int z = b.getZ();
+ int d = b.getTypeId();
+ String coords = w + "," + x + "," + y + "," + z + "," + d;
+ System.out.println("Water Change: " + coords);
+ List blocks = plugin.config.getStringList("Blocks_Placed");
+ blocks.add(coords);
+ plugin.config.set("Blocks_Destroyed", blocks);
+ plugin.saveConfig();
+ }
+ }else if (block.getType() == Material.SAND || block.getType() == Material.GRAVEL) {
+ if (changed == Material.AIR) {
+ Block b = event.getBlock();
+ String w = b.getWorld().getName();
+ int x = b.getX();
+ int y = b.getY();
+ int z = b.getZ();
+ int d = b.getTypeId();
+ String coords = w + "," + x + "," + y + "," + z + "," + d;
+ System.out.println("Sand/Gravel Fall: " + coords);
+ List blocks = plugin.config.getStringList("Blocks_Placed");
+ blocks.add(coords);
+ plugin.config.set("Blocks_Destroyed", blocks);
+ plugin.saveConfig();
+ }
+ }
+ }*/
+}
\ No newline at end of file
diff --git a/src/me/Travja/HungerArena/Chests.java b/src/me/Travja/HungerArena/Chests.java
index 7b1fabf..5a971b9 100644
--- a/src/me/Travja/HungerArena/Chests.java
+++ b/src/me/Travja/HungerArena/Chests.java
@@ -3,6 +3,7 @@ package me.Travja.HungerArena;
import java.util.List;
import org.bukkit.ChatColor;
+import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Chest;
@@ -10,6 +11,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
+import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
@@ -24,30 +26,55 @@ public class Chests implements Listener {
Player p = event.getPlayer();
if(p.getItemInHand().getType()== Material.BLAZE_ROD && event.getAction() == Action.LEFT_CLICK_BLOCK){
if(block.getState() instanceof Chest){
- ItemStack[] itemsinchest = ((Chest) block.getState()).getInventory().getContents();
- int blockx = block.getX();
- int blocky = block.getY();
- int blockz = block.getZ();
- String blockw = block.getWorld().getName().toString();
- if(!plugin.getConfig().contains("Storage." + blockx + "," + blocky + "," + blockz + ".Location.X")){
- plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.X", blockx);
- plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Y", blocky);
- plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Z",blockz);
- plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.W", blockw);
- plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".ItemsInStorage", itemsinchest);
+ if(p.hasPermission("HungerArena.Chest.Store")){
+ ItemStack[] itemsinchest = ((Chest) block.getState()).getInventory().getContents();
+ int blockx = block.getX();
+ int blocky = block.getY();
+ int blockz = block.getZ();
+ String blockw = block.getWorld().getName().toString();
+ if(!plugin.getConfig().contains("Storage." + blockx + "," + blocky + "," + blockz + ".Location.X")){
+ plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.X", blockx);
+ plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Y", blocky);
+ plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Z",blockz);
+ plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.W", blockw);
+ plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".ItemsInStorage", itemsinchest);
+ }else{
+ plugin.getConfig().set("Storage." + blockx + "," + blocky+ "," + blockz + ".Location.X",blockx);
+ plugin.getConfig().set("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Y", blocky);
+ plugin.getConfig().set("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Z", blockz);
+ plugin.getConfig().set("Storage." + blockx + "," + blocky + "," + blockz + ".Location.W", blockw);
+ plugin.getConfig().set("Storage." + blockx + "," + blocky + "," + blockz + ".ItemsInStorage", itemsinchest);
+ }
+ List list2 = plugin.getConfig().getStringList("StorageXYZ");
+ list2.add(blockx + "," + blocky + "," + blockz);
+ plugin.getConfig().set("StorageXYZ", list2);
+ plugin.getConfig().options().copyDefaults(true);
+ plugin.saveConfig();
+ p.sendMessage(ChatColor.GREEN + "Chest Stored!");
}else{
- plugin.getConfig().set("Storage." + blockx + "," + blocky+ "," + blockz + ".Location.X",blockx);
- plugin.getConfig().set("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Y", blocky);
- plugin.getConfig().set("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Z", blockz);
- plugin.getConfig().set("Storage." + blockx + "," + blocky + "," + blockz + ".Location.W", blockw);
- plugin.getConfig().set("Storage." + blockx + "," + blocky + "," + blockz + ".ItemsInStorage", itemsinchest);
+ p.sendMessage(ChatColor.RED + "You don't have permission to store chests!");
+ }
+ }
+ }
+ }
+ @EventHandler
+ public void onBlockBreak(BlockBreakEvent event) {
+ Player p = event.getPlayer();
+ Block block = event.getBlock();
+ Location blocklocation = event.getBlock().getLocation();
+ if (block.getState() instanceof Chest) {
+ int blockx = blocklocation.getBlockX();
+ int blocky = blocklocation.getBlockY();
+ int blockz = blocklocation.getBlockZ();
+ if (plugin.getConfig().getStringList("StorageXYZ").contains(blockx + "," + blocky + "," + blockz)) {
+ if(p.hasPermission("HungerArena.Chest.Break")){
+ List list2 = plugin.getConfig().getStringList("StorageXYZ");
+ list2.remove(blockx + "," + blocky + "," + blockz);
+ plugin.getConfig().set("StorageXYZ", list2);
+ plugin.getConfig().options().copyDefaults(true);
+ plugin.saveConfig();
+ p.sendMessage("Chest Removed!");
}
- List list2 = plugin.getConfig().getStringList("StorageXYZ");
- list2.add(blockx + "," + blocky + "," + blockz);
- plugin.getConfig().set("StorageXYZ", list2);
- plugin.getConfig().options().copyDefaults(true);
- plugin.saveConfig();
- p.sendMessage(ChatColor.GREEN + "Chest Stored!");
}
}
}
diff --git a/src/me/Travja/HungerArena/CommandBlock.java b/src/me/Travja/HungerArena/CommandBlock.java
index 857a975..198e3c0 100644
--- a/src/me/Travja/HungerArena/CommandBlock.java
+++ b/src/me/Travja/HungerArena/CommandBlock.java
@@ -17,8 +17,10 @@ public class CommandBlock implements Listener {
String cmd = event.getMessage();
Player p = event.getPlayer();
if(!cmd.contains("/ha") && plugin.Playing.contains(p) && plugin.canjoin== true){
- event.setCancelled(true);
- p.sendMessage(ChatColor.RED + "You are only allowed to use /ha commands!");
+ if(!p.hasPermission("HungerArena.UseCommands")){
+ event.setCancelled(true);
+ p.sendMessage(ChatColor.RED + "You are only allowed to use /ha commands!");
+ }
}
}
}
diff --git a/src/me/Travja/HungerArena/DeathListener.java b/src/me/Travja/HungerArena/DeathListener.java
index f4a4e63..a063e4b 100644
--- a/src/me/Travja/HungerArena/DeathListener.java
+++ b/src/me/Travja/HungerArena/DeathListener.java
@@ -19,10 +19,12 @@ public class DeathListener implements Listener{
this.plugin = m;
}
public FileConfiguration config;
+ int i = 0;
@EventHandler
public void onPlayerRespawn(PlayerRespawnEvent event){
Player p = event.getPlayer();
- if(plugin.Dead.contains(p)){
+ String pname = p.getDisplayName();
+ if(plugin.Dead.contains(pname)){
String[] Spawncoords = plugin.config.getString("Spawn_coords").split(",");
World spawnw = plugin.getServer().getWorld(Spawncoords[3]);
double spawnx = Double.parseDouble(Spawncoords[0]);
@@ -36,14 +38,14 @@ public class DeathListener implements Listener{
public void onPlayerDeath(PlayerDeathEvent event){
Player p = event.getEntity();
Server s = p.getServer();
- String pname = p.getName();
+ String pname = p.getDisplayName();
String[] Spawncoords = plugin.config.getString("Spawn_coords").split(",");
World spawnw = plugin.getServer().getWorld(Spawncoords[3]);
double spawnx = Double.parseDouble(Spawncoords[0]);
double spawny = Double.parseDouble(Spawncoords[1]);
double spawnz = Double.parseDouble(Spawncoords[2]);
Location Spawn = new Location(spawnw, spawnx, spawny, spawnz);
- if(plugin.Playing.contains(p)){
+ if(plugin.Playing.contains(pname)){
if(plugin.config.getString("Cannon_Death").equalsIgnoreCase("True")){
double y = p.getLocation().getY();
double newy = y+200;
@@ -52,8 +54,8 @@ public class DeathListener implements Listener{
Location strike = new Location(p.getWorld(), x, newy, z);
p.getWorld().strikeLightning(strike);
}
- plugin.Dead.add(p);
- plugin.Playing.remove(p);
+ plugin.Dead.add(pname);
+ plugin.Playing.remove(pname);
String leftmsg = ChatColor.BLUE + "There are now " + plugin.Playing.size() + " tributes left!";
if(p.getKiller() instanceof Player){
if(p.getKiller().getItemInHand().getType().getId()== 0){
@@ -63,19 +65,23 @@ public class DeathListener implements Listener{
s.broadcastMessage(ChatColor.LIGHT_PURPLE + "**BOOM** Tribute " + pname + " was killed by tribute " + killername + " with their FIST!");
s.broadcastMessage(leftmsg);
if(plugin.Playing.size()== 1 && plugin.canjoin== true){
- for(Player winner:plugin.Playing){
- String winnername = winner.getName();
- plugin.getServer().broadcastMessage(ChatColor.GREEN + winnername + " is the victor of this Hunger Games!");
- winner.getInventory().clear();
- winner.teleport(Spawn);
- winner.getInventory().setBoots(null);
- winner.getInventory().setChestplate(null);
- winner.getInventory().setHelmet(null);
- winner.getInventory().setLeggings(null);
- winner.getInventory().addItem(plugin.Reward);
- }
+ //Announce winner
+ String winnername = plugin.Playing.get(i++);
+ Player winner = plugin.getServer().getPlayerExact(winnername);
+ String winnername2 = winner.getName();
+ plugin.getServer().broadcastMessage(ChatColor.GREEN + winnername2 + " is the victor of this Hunger Games!");
+ winner.getInventory().clear();
+ winner.teleport(Spawn);
+ winner.getInventory().setBoots(null);
+ winner.getInventory().setChestplate(null);
+ winner.getInventory().setHelmet(null);
+ winner.getInventory().setLeggings(null);
+ winner.getInventory().addItem(plugin.Reward);
plugin.Playing.clear();
- for(Player spectator:plugin.Watching){
+ //Show spectators
+ if(!plugin.Watching.isEmpty()){
+ String s1 = plugin.Watching.get(i++);
+ Player spectator = plugin.getServer().getPlayerExact(s1);
spectator.setAllowFlight(false);
spectator.teleport(Spawn);
for(Player online:plugin.getServer().getOnlinePlayers()){
@@ -95,19 +101,23 @@ public class DeathListener implements Listener{
s.broadcastMessage(msg);
s.broadcastMessage(leftmsg);
if(plugin.Playing.size()== 1 && plugin.canjoin== true){
- for(Player winner:plugin.Playing){
- String winnername = winner.getName();
- plugin.getServer().broadcastMessage(ChatColor.GREEN + winnername + " is the victor of this Hunger Games!");
- winner.getInventory().clear();
- winner.teleport(Spawn);
- winner.getInventory().setBoots(null);
- winner.getInventory().setChestplate(null);
- winner.getInventory().setHelmet(null);
- winner.getInventory().setLeggings(null);
- winner.getInventory().addItem(plugin.Reward);
- }
+ //Announce winner
+ String winnername = plugin.Playing.get(i++);
+ Player winner = plugin.getServer().getPlayerExact(winnername);
+ String winnername2 = winner.getName();
+ plugin.getServer().broadcastMessage(ChatColor.GREEN + winnername2 + " is the victor of this Hunger Games!");
+ winner.getInventory().clear();
+ winner.teleport(Spawn);
+ winner.getInventory().setBoots(null);
+ winner.getInventory().setChestplate(null);
+ winner.getInventory().setHelmet(null);
+ winner.getInventory().setLeggings(null);
+ winner.getInventory().addItem(plugin.Reward);
plugin.Playing.clear();
- for(Player spectator:plugin.Watching){
+ //Show spectators
+ if(!plugin.Watching.isEmpty()){
+ String s1 = plugin.Watching.get(i++);
+ Player spectator = plugin.getServer().getPlayerExact(s1);
spectator.setAllowFlight(false);
spectator.teleport(Spawn);
for(Player online:plugin.getServer().getOnlinePlayers()){
@@ -124,19 +134,23 @@ public class DeathListener implements Listener{
s.broadcastMessage(ChatColor.LIGHT_PURPLE + pname + " died of natural causes!");
s.broadcastMessage(leftmsg);
if(plugin.Playing.size()== 1 && plugin.canjoin== true){
- for(Player winner:plugin.Playing){
- String winnername = winner.getName();
- plugin.getServer().broadcastMessage(ChatColor.GREEN + winnername + " is the victor of this Hunger Games!");
- winner.getInventory().clear();
- winner.teleport(Spawn);
- winner.getInventory().setBoots(null);
- winner.getInventory().setChestplate(null);
- winner.getInventory().setHelmet(null);
- winner.getInventory().setLeggings(null);
- winner.getInventory().addItem(plugin.Reward);
- }
+ //Announce winner
+ String winnername = plugin.Playing.get(i++);
+ Player winner = plugin.getServer().getPlayerExact(winnername);
+ String winnername2 = winner.getName();
+ plugin.getServer().broadcastMessage(ChatColor.GREEN + winnername2 + " is the victor of this Hunger Games!");
+ winner.getInventory().clear();
+ winner.teleport(Spawn);
+ winner.getInventory().setBoots(null);
+ winner.getInventory().setChestplate(null);
+ winner.getInventory().setHelmet(null);
+ winner.getInventory().setLeggings(null);
+ winner.getInventory().addItem(plugin.Reward);
plugin.Playing.clear();
- for(Player spectator:plugin.Watching){
+ //Show spectators
+ if(!plugin.Watching.isEmpty()){
+ String s1 = plugin.Watching.get(i++);
+ Player spectator = plugin.getServer().getPlayerExact(s1);
spectator.setAllowFlight(false);
spectator.teleport(Spawn);
for(Player online:plugin.getServer().getOnlinePlayers()){
diff --git a/src/me/Travja/HungerArena/HaCommands.java b/src/me/Travja/HungerArena/HaCommands.java
index 15b1f02..d091dee 100644
--- a/src/me/Travja/HungerArena/HaCommands.java
+++ b/src/me/Travja/HungerArena/HaCommands.java
@@ -20,9 +20,10 @@ public class HaCommands implements CommandExecutor {
public HaCommands(Main m) {
this.plugin = m;
}
+ int i = 0;
@SuppressWarnings("unchecked")
@Override
- public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
+ public boolean onCommand(final CommandSender sender, Command cmd, String commandLabel, String[] args){
String[] Spawncoords = plugin.config.getString("Spawn_coords").split(",");
double spawnx = Double.parseDouble(Spawncoords[0]);
double spawny = Double.parseDouble(Spawncoords[1]);
@@ -31,8 +32,8 @@ public class HaCommands implements CommandExecutor {
World spawnw = plugin.getServer().getWorld(spawnworld);
Location Spawn = new Location(spawnw, spawnx, spawny, spawnz);
if(sender instanceof Player){
- Player p = (Player) sender;
- String pname = p.getName();
+ final Player p = (Player) sender;
+ final String pname = p.getDisplayName();
ChatColor c = ChatColor.AQUA;
if(cmd.getName().equalsIgnoreCase("Ha")){
if(args.length== 0){
@@ -52,6 +53,7 @@ public class HaCommands implements CommandExecutor {
sender.sendMessage(c + "/ha restart - Makes it so dead tributes can join again!");
sender.sendMessage(c + "/ha warpall - Warps all tribute into position!");
sender.sendMessage(c + "/ha reload - Reloads the config!");
+ sender.sendMessage(c + "/ha refill - Refills all chests!");
sender.sendMessage(c + "/ha start - Unfreezes tributes allowing them to fight!");
sender.sendMessage(c + "/ha list - Shows a list of players in the game and their health!");
sender.sendMessage(c + "/ha rlist - See who's ready!");
@@ -61,10 +63,11 @@ public class HaCommands implements CommandExecutor {
}else if(args[0].equalsIgnoreCase("List")){
if(p.hasPermission("HungerArena.GameMaker") || sender instanceof ConsoleCommandSender){
sender.sendMessage(ChatColor.AQUA + "-----People Playing-----");
- for(Player players:plugin.Playing){
+ if(!(plugin.Playing.size()== 0)){
+ String playernames = plugin.Playing.get(i++);
+ Player players = plugin.getServer().getPlayerExact(playernames);
sender.sendMessage(ChatColor.GREEN + players.getDisplayName() + " Life: " + players.getHealth() + "/20");
- }
- if(plugin.Playing.size()== 0){
+ }else if(plugin.Playing.size()== 0){
sender.sendMessage(ChatColor.GRAY + "No one is playing!");
}
sender.sendMessage(ChatColor.AQUA + "----------------------");
@@ -74,10 +77,11 @@ public class HaCommands implements CommandExecutor {
}else if(args[0].equalsIgnoreCase("rList")){
if(p.hasPermission("HungerArena.GameMaker") || sender instanceof ConsoleCommandSender){
sender.sendMessage(ChatColor.AQUA + "-----People Ready-----");
- for(Player ready:plugin.Ready){
+ if(!(plugin.Ready.size()== 0)){
+ String readyname = plugin.Ready.get(i++);
+ Player ready = plugin.getServer().getPlayerExact(readyname);
sender.sendMessage(ChatColor.GREEN + ready.getDisplayName() + " Life: " + ready.getHealth() + "/20");
- }
- if(plugin.Playing.size()== 0){
+ }else if(plugin.Playing.size()== 0){
sender.sendMessage(ChatColor.GRAY + "No one is ready!");
}
sender.sendMessage(ChatColor.AQUA + "---------------------");
@@ -85,9 +89,7 @@ public class HaCommands implements CommandExecutor {
sender.sendMessage(ChatColor.RED + "You don't have permission!");
}
}else if(args[0].equalsIgnoreCase("SetSpawn")){
- if(sender instanceof ConsoleCommandSender){
- sender.sendMessage(ChatColor.RED + "That can only be run by a player!");
- }else if(p.hasPermission("HungerArena.SetSpawn")){
+ if(p.hasPermission("HungerArena.SetSpawn")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
@@ -100,12 +102,10 @@ public class HaCommands implements CommandExecutor {
p.sendMessage(ChatColor.RED + "You don't have permission!");
}
}else if(args[0].equalsIgnoreCase("Join")){
- if(sender instanceof ConsoleCommandSender){
- sender.sendMessage(ChatColor.RED + "That can only be run by a player!");
- }else if(p.hasPermission("HungerArena.Join")){
- if(plugin.Playing.contains(p)){
+ if(p.hasPermission("HungerArena.Join")){
+ if(plugin.Playing.contains(pname)){
p.sendMessage(ChatColor.RED + "You are already playing!");
- }else if(plugin.Dead.contains(p) || plugin.Quit.contains(p)){
+ }else if(plugin.Dead.contains(pname) || plugin.Quit.contains(pname)){
p.sendMessage(ChatColor.RED + "You DIED/QUIT! You can't join again!");
}else if(plugin.Playing.size()== 24){
p.sendMessage(ChatColor.RED + "There are already 24 Tributes!");
@@ -113,13 +113,13 @@ public class HaCommands implements CommandExecutor {
p.sendMessage(ChatColor.RED + "The game is in progress!");
}else if(plugin.config.getString("Spawns_set").equalsIgnoreCase("false")){
p.sendMessage(ChatColor.RED + "/ha setspawn hasn't been run!");
- }else if(plugin.NeedConfirm.contains(p)){
+ }else if(plugin.NeedConfirm.contains(pname)){
p.sendMessage(ChatColor.RED + "You need to do /ha confirm");
}else if(plugin.config.getString("Need_Confirm").equalsIgnoreCase("true")){
- plugin.NeedConfirm.add(p);
+ plugin.NeedConfirm.add(pname);
p.sendMessage(ChatColor.GOLD + "You're inventory will be cleared! Type /ha confirm to procede");
}else{
- plugin.Playing.add(p);
+ plugin.Playing.add(pname);
p.getInventory().clear();
p.getInventory().setBoots(null);
p.getInventory().setChestplate(null);
@@ -134,11 +134,9 @@ public class HaCommands implements CommandExecutor {
p.sendMessage(ChatColor.RED + "You don't have permission!");
}
}else if(args[0].equalsIgnoreCase("Confirm")){
- if(sender instanceof ConsoleCommandSender){
- sender.sendMessage(ChatColor.RED + "That can only be run by a player!");
- }else if(plugin.NeedConfirm.contains(p)){
- plugin.Playing.add(p);
- plugin.NeedConfirm.remove(p);
+ if(plugin.NeedConfirm.contains(pname)){
+ plugin.Playing.add(pname);
+ plugin.NeedConfirm.remove(pname);
p.sendMessage(ChatColor.GREEN + "Do /ha ready to vote to start the games!");
p.getInventory().clear();
p.getInventory().setBoots(null);
@@ -151,41 +149,40 @@ public class HaCommands implements CommandExecutor {
}
}
}else if(args[0].equalsIgnoreCase("Ready")){
- if(sender instanceof ConsoleCommandSender){
- sender.sendMessage(ChatColor.RED + "That can only be run by a player!");
- }else if(plugin.Playing.contains(p)){
- if(plugin.Ready.contains(p)){
+ if(plugin.Playing.contains(pname)){
+ if(plugin.Ready.contains(pname)){
p.sendMessage(ChatColor.RED + "You're already ready!");
}else if(plugin.Playing.size()== 1){
p.sendMessage(ChatColor.RED + "You can't be ready when no one else is playing!");
}else{
- plugin.Ready.add(p);
+ plugin.Ready.add(pname);
p.sendMessage(ChatColor.AQUA + "You have marked yourself as READY!");
- if(plugin.Playing.size()== plugin.Ready.size()){
+ if(plugin.Playing.size()-4== plugin.Ready.size()){
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha warpall");
}
}
- }else if(!plugin.Playing.contains(p)){
+ }else if(!plugin.Playing.contains(pname)){
p.sendMessage(ChatColor.RED + "You aren't playing!");
}
}else if(args[0].equalsIgnoreCase("Leave")){
- if(!plugin.Playing.contains(p)){
+ if(!plugin.Playing.contains(pname)){
p.sendMessage(ChatColor.RED + "You aren't playing!");
}else if(plugin.canjoin== false){
- plugin.Playing.remove(p);
+ plugin.Playing.remove(pname);
p.sendMessage(ChatColor.AQUA + "You have left the game!");
p.getServer().broadcastMessage(ChatColor.RED + pname + " Quit!");
p.getInventory().clear();
+ p.teleport(Spawn);
p.getInventory().setBoots(null);
p.getInventory().setChestplate(null);
p.getInventory().setHelmet(null);
p.getInventory().setLeggings(null);
- if(plugin.Frozen.contains(p)){
- plugin.Frozen.remove(p);
+ if(plugin.Frozen.contains(pname)){
+ plugin.Frozen.remove(pname);
}
}else{
- plugin.Playing.remove(p);
- plugin.Quit.add(p);
+ plugin.Playing.remove(pname);
+ plugin.Quit.add(pname);
p.sendMessage(ChatColor.AQUA + "You have left the game!");
p.getServer().broadcastMessage(ChatColor.RED + pname + " Quit!");
p.getInventory().clear();
@@ -194,28 +191,30 @@ public class HaCommands implements CommandExecutor {
p.getInventory().setHelmet(null);
p.getInventory().setLeggings(null);
p.teleport(Spawn);
- if(plugin.Frozen.contains(p)){
- plugin.Frozen.remove(p);
+ if(plugin.Frozen.contains(pname)){
+ plugin.Frozen.remove(pname);
}
if(plugin.Playing.size()== 1){
- for(Player winner:plugin.Playing){
- String winnername = winner.getName();
- plugin.getServer().broadcastMessage(ChatColor.GREEN + winnername + " is the victor of this Hunger Games!");
- winner.getInventory().clear();
- winner.teleport(Spawn);
- winner.getInventory().setBoots(null);
- winner.getInventory().setChestplate(null);
- winner.getInventory().setHelmet(null);
- winner.getInventory().setLeggings(null);
- winner.getInventory().addItem(plugin.Reward);
- }
+ //Announce the Winner
+ String winnername = plugin.Playing.get(i++);
+ Player winner = plugin.getServer().getPlayerExact(winnername);
+ String winnername2 = winner.getName();
+ plugin.getServer().broadcastMessage(ChatColor.GREEN + winnername2 + " is the victor of this Hunger Games!");
+ winner.getInventory().clear();
+ winner.teleport(Spawn);
+ winner.getInventory().setBoots(null);
+ winner.getInventory().setChestplate(null);
+ winner.getInventory().setHelmet(null);
+ winner.getInventory().setLeggings(null);
+ winner.getInventory().addItem(plugin.Reward);
plugin.Playing.clear();
- for(Player spectator:plugin.Watching){
- spectator.setAllowFlight(false);
- spectator.teleport(Spawn);
- for(Player online:plugin.getServer().getOnlinePlayers()){
- online.showPlayer(spectator);
- }
+ //Show spectators
+ String s = plugin.Watching.get(i++);
+ Player spectator = plugin.getServer().getPlayerExact(s);
+ spectator.setAllowFlight(false);
+ spectator.teleport(Spawn);
+ for(Player online:plugin.getServer().getOnlinePlayers()){
+ online.showPlayer(spectator);
}
if(plugin.config.getString("Auto_Restart").equalsIgnoreCase("True")){
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha restart");
@@ -223,72 +222,67 @@ public class HaCommands implements CommandExecutor {
}
}
}else if(args[0].equalsIgnoreCase("Watch")){
- if(sender instanceof ConsoleCommandSender){
- sender.sendMessage(ChatColor.RED + "That can only be run by a player!");
- }else if(sender.hasPermission("HungerArena.Watch")){
- if(!plugin.Watching.contains(p) && !plugin.Playing.contains(p) && plugin.canjoin== true){
- plugin.Watching.add(p);
+ if(sender.hasPermission("HungerArena.Watch")){
+ if(!plugin.Watching.contains(pname) && !plugin.Playing.contains(pname) && plugin.canjoin== true){
+ plugin.Watching.add(pname);
for(Player online:plugin.getServer().getOnlinePlayers()){
online.hidePlayer(p);
}
p.setAllowFlight(true);
p.sendMessage(ChatColor.AQUA + "You can now spectate!");
- }else if(plugin.canjoin == false){
+ }else if(plugin.canjoin== false){
p.sendMessage(ChatColor.RED + "The game isn't in progress!");
- }else if(plugin.Playing.contains(p)){
+ }else if(plugin.Playing.contains(pname)){
p.sendMessage(ChatColor.RED + "You can't watch while you're playing!");
- }else if(plugin.Watching.contains(p)){
- plugin.Watching.remove(p);
+ }else if(plugin.Watching.contains(pname)){
+ plugin.Watching.remove(pname);
for(Player online:plugin.getServer().getOnlinePlayers()){
online.showPlayer(p);
}
p.teleport(Spawn);
p.setAllowFlight(false);
- sender.sendMessage(ChatColor.AQUA + "You are not spectating anymore");
+ p.sendMessage(ChatColor.AQUA + "You are not spectating anymore");
}
}else{
- sender.sendMessage(ChatColor.RED + "You don't have permission!");
+ p.sendMessage(ChatColor.RED + "You don't have permission!");
}
}else if(args[0].equalsIgnoreCase("Kick")){
Player target = plugin.getServer().getPlayer(args[1]);
- if(sender.hasPermission("HungerArena.Kick") || sender instanceof ConsoleCommandSender){
- if(plugin.Playing.contains(target)){
- if(p.isOnline()){
- plugin.Playing.remove(target);
- plugin.getServer().broadcastMessage(ChatColor.RED + target.getName() + " was kicked from the game!");
- target.teleport(Spawn);
- target.getInventory().clear();
- target.getInventory().setBoots(null);
- target.getInventory().setChestplate(null);
- target.getInventory().setHelmet(null);
- target.getInventory().setLeggings(null);
- plugin.Quit.add(target);
- if(plugin.Playing.size()== 1 && plugin.canjoin== true){
- for(Player winner:plugin.Playing){
- String winnername = winner.getName();
- plugin.getServer().broadcastMessage(ChatColor.GREEN + winnername + " is the victor of this Hunger Games!");
- winner.getInventory().clear();
- winner.teleport(Spawn);
- winner.getInventory().setBoots(null);
- winner.getInventory().setChestplate(null);
- winner.getInventory().setHelmet(null);
- winner.getInventory().setLeggings(null);
- winner.getInventory().addItem(plugin.Reward);
+ if(sender.hasPermission("HungerArena.Kick")){
+ if(plugin.Playing.contains(target.getDisplayName())){
+ plugin.Playing.remove(target.getDisplayName());
+ plugin.getServer().broadcastMessage(ChatColor.RED + target.getName() + " was kicked from the game!");
+ target.teleport(Spawn);
+ target.getInventory().clear();
+ target.getInventory().setBoots(null);
+ target.getInventory().setChestplate(null);
+ target.getInventory().setHelmet(null);
+ target.getInventory().setLeggings(null);
+ plugin.Quit.add(target.getDisplayName());
+ if(plugin.Playing.size()== 1 && plugin.canjoin== true){
+ String winnername = plugin.Playing.get(i++);
+ Player winner = plugin.getServer().getPlayerExact(winnername);
+ String winnername2 = winner.getName();
+ plugin.getServer().broadcastMessage(ChatColor.GREEN + winnername2 + " is the victor of this Hunger Games!");
+ winner.getInventory().clear();
+ winner.teleport(Spawn);
+ winner.getInventory().setBoots(null);
+ winner.getInventory().setChestplate(null);
+ winner.getInventory().setHelmet(null);
+ winner.getInventory().setLeggings(null);
+ winner.getInventory().addItem(plugin.Reward);
+ plugin.Playing.clear();
+ if(!plugin.Watching.isEmpty()){
+ String s = plugin.Watching.get(i++);
+ Player spectator = plugin.getServer().getPlayerExact(s);
+ spectator.setAllowFlight(false);
+ spectator.teleport(Spawn);
+ for(Player online:plugin.getServer().getOnlinePlayers()){
+ online.showPlayer(spectator);
}
- plugin.Playing.clear();
- for(Player spectator:plugin.Watching){
- spectator.setAllowFlight(false);
- spectator.teleport(Spawn);
- for(Player online:plugin.getServer().getOnlinePlayers()){
- online.showPlayer(spectator);
- }
- }
- if(plugin.config.getString("Auto_Restart").equalsIgnoreCase("True")){
- Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha restart");
- }
- }else{
- plugin.Playing.remove(target);
- plugin.Quit.add(target);
+ }
+ if(plugin.config.getString("Auto_Restart").equalsIgnoreCase("True")){
+ Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha restart");
}
}
}else{
@@ -298,38 +292,44 @@ public class HaCommands implements CommandExecutor {
sender.sendMessage(ChatColor.RED + "You don't have permission!");
}
}else if(args[0].equalsIgnoreCase("Refill")){
- int list056;
- list056 = 0;
- int limit = plugin.getConfig().getStringList("StorageXYZ").size();
- while(limit > list056){
- String xyz2 = plugin.getConfig().getStringList("StorageXYZ").get(list056);
- int chestx = plugin.getConfig().getInt("Storage." + xyz2 + ".Location.X");
- int chesty = plugin.getConfig().getInt("Storage." + xyz2 + ".Location.Y");
- int chestz = plugin.getConfig().getInt("Storage." + xyz2 + ".Location.Z");
- String chestw = plugin.getConfig().getString("Storage." + xyz2 + ".Location.W");
- Block blockatlocation = Bukkit.getWorld(chestw).getBlockAt(chestx, chesty, chestz);
- plugin.exists = false;
- if(blockatlocation.getState() instanceof Chest){
- plugin.exists = true;
- Chest chest = (Chest) blockatlocation.getState();
- chest.getInventory().clear();
- ItemStack[] itemsinchest = null;
- Object o = plugin.getConfig().get("Storage." + xyz2 + ".ItemsInStorage");
- if(o instanceof ItemStack[]){
- itemsinchest = (ItemStack[]) o;
- }else if(o instanceof List){
- itemsinchest = (ItemStack[]) ((List) o).toArray(new ItemStack[0]);
+ if(p.hasPermission("HungerArena.Refill")){
+ int list056;
+ list056 = 0;
+ int limit = plugin.config.getStringList("StorageXYZ").size();
+ while(limit > list056){
+ String xyz2 = plugin.getConfig().getStringList("StorageXYZ").get(list056);
+ int chestx = plugin.getConfig().getInt("Storage." + xyz2 + ".Location.X");
+ int chesty = plugin.getConfig().getInt("Storage." + xyz2 + ".Location.Y");
+ int chestz = plugin.getConfig().getInt("Storage." + xyz2 + ".Location.Z");
+ String chestw = plugin.getConfig().getString("Storage." + xyz2 + ".Location.W");
+ Block blockatlocation = Bukkit.getWorld(chestw).getBlockAt(chestx, chesty, chestz);
+ plugin.exists = false;
+ if(blockatlocation.getState() instanceof Chest){
+ plugin.exists = true;
+ Chest chest = (Chest) blockatlocation.getState();
+ chest.getInventory().clear();
+ ItemStack[] itemsinchest = null;
+ Object o = plugin.getConfig().get("Storage." + xyz2 + ".ItemsInStorage");
+ if(o instanceof ItemStack[]){
+ itemsinchest = (ItemStack[]) o;
+ }else if(o instanceof List){
+ itemsinchest = (ItemStack[]) ((List) o).toArray(new ItemStack[0]);
+ }
+ list056 = list056+1;
+ chest.getInventory().setContents(itemsinchest);
}
- list056 = list056+1;
- chest.getInventory().setContents(itemsinchest);
}
- }
- if(limit== list056){
- sender.sendMessage(ChatColor.GREEN + "All chests refilled!");
+ if(limit== list056){
+ sender.sendMessage(ChatColor.GREEN + "All chests refilled!");
+ }
+ }else{
+ p.sendMessage(ChatColor.RED + "You don't have permission!");
}
}else if(args[0].equalsIgnoreCase("Restart")){
- if(sender.hasPermission("HungerArena.Restart") || sender instanceof ConsoleCommandSender){
- for(Player spectator:plugin.Watching){
+ if(p.hasPermission("HungerArena.Restart")){
+ if(!plugin.Watching.isEmpty()){
+ String s = plugin.Watching.get(i++);
+ Player spectator = plugin.getServer().getPlayerExact(s);
spectator.setAllowFlight(false);
spectator.teleport(Spawn);
for(Player online:plugin.getServer().getOnlinePlayers()){
@@ -345,16 +345,16 @@ public class HaCommands implements CommandExecutor {
plugin.Out.clear();
plugin.Playing.clear();
plugin.canjoin = false;
- Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha refill");
- sender.sendMessage(ChatColor.AQUA + "The games have been reset!");
+ p.performCommand("ha refill");
+ p.sendMessage(ChatColor.AQUA + "The games have been reset!");
}else{
- sender.sendMessage(ChatColor.RED + "You don't have permission!");
+ p.sendMessage(ChatColor.RED + "You don't have permission!");
}
}else if(args[0].equalsIgnoreCase("Reload")){
plugin.reloadConfig();
- sender.sendMessage(ChatColor.AQUA + "HungerArena Reloaded!");
+ p.sendMessage(ChatColor.AQUA + "HungerArena Reloaded!");
}else if(args[0].equalsIgnoreCase("WarpAll")){
- if(sender.hasPermission("HungerArena.Warpall") || sender instanceof ConsoleCommandSender){
+ if(p.hasPermission("HungerArena.Warpall")){
if(plugin.config.getString("Spawns_set").equalsIgnoreCase("false")){
sender.sendMessage(ChatColor.RED + "/ha setspawn hasn't been run!");
}else{
@@ -364,7 +364,7 @@ public class HaCommands implements CommandExecutor {
if(plugin.Playing.size()>= 2){
plugin.config.getString("Tribute_one_spawn");
String[] onecoords = plugin.config.getString("Tribute_one_spawn").split(",");
- Player Tribute_one = plugin.Playing.get(0);
+ Player Tribute_one = plugin.getServer().getPlayerExact(plugin.Playing.get(0));
double x = Double.parseDouble(onecoords[0]);
double y = Double.parseDouble(onecoords[1]);
double z = Double.parseDouble(onecoords[2]);
@@ -372,11 +372,11 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location oneloc = new Location(w, x, y, z);
Tribute_one.teleport(oneloc);
- plugin.Frozen.add(Tribute_one);
+ plugin.Frozen.add(Tribute_one.getDisplayName());
Tribute_one.setFoodLevel(20);
plugin.config.getString("Tribute_two_spawn");
String[] twocoords = plugin.config.getString("Tribute_two_spawn").split(",");
- Player Tribute_two = plugin.Playing.get(1);
+ Player Tribute_two = plugin.getServer().getPlayerExact(plugin.Playing.get(1));
double twox = Double.parseDouble(twocoords[0]);
double twoy = Double.parseDouble(twocoords[1]);
double twoz = Double.parseDouble(twocoords[2]);
@@ -384,7 +384,7 @@ public class HaCommands implements CommandExecutor {
World twow = plugin.getServer().getWorld(twoworld);
Location twoloc = new Location(twow, twox, twoy, twoz);
Tribute_two.teleport(twoloc);
- plugin.Frozen.add(Tribute_two);
+ plugin.Frozen.add(Tribute_two.getDisplayName());
Tribute_two.setFoodLevel(20);
p.getWorld().setTime(0);
if(plugin.config.getString("Auto_Start").equalsIgnoreCase("true")){
@@ -394,11 +394,16 @@ public class HaCommands implements CommandExecutor {
}
}, 20L);
}
+ plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
+ public void run(){
+ p.sendMessage(ChatColor.AQUA + "All Tributes warped!");
+ }
+ }, 20L);
}
if(plugin.Playing.size()>= 3){
plugin.config.getString("Tribute_three_spawn");
String[] coords = plugin.config.getString("Tribute_three_spawn").split(",");
- Player Tribute_three = plugin.Playing.get(2);
+ Player Tribute_three = plugin.getServer().getPlayerExact(plugin.Playing.get(2));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -406,13 +411,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_three.teleport(loc);
- plugin.Frozen.add(Tribute_three);
+ plugin.Frozen.add(Tribute_three.getDisplayName());
Tribute_three.setFoodLevel(20);
}
if(plugin.Playing.size()>= 4){
plugin.config.getString("Tribute_four_spawn");
String[] coords = plugin.config.getString("Tribute_four_spawn").split(",");
- Player Tribute_four = plugin.Playing.get(3);
+ Player Tribute_four = plugin.getServer().getPlayerExact(plugin.Playing.get(3));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -420,13 +425,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_four.teleport(loc);
- plugin.Frozen.add(Tribute_four);
+ plugin.Frozen.add(Tribute_four.getDisplayName());
Tribute_four.setFoodLevel(20);
}
if(plugin.Playing.size()>= 5){
plugin.config.getString("Tribute_five_spawn");
String[] coords = plugin.config.getString("Tribute_five_spawn").split(",");
- Player Tribute_five = plugin.Playing.get(4);
+ Player Tribute_five = plugin.getServer().getPlayerExact(plugin.Playing.get(4));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -434,13 +439,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_five.teleport(loc);
- plugin.Frozen.add(Tribute_five);
+ plugin.Frozen.add(Tribute_five.getDisplayName());
Tribute_five.setFoodLevel(20);
}
if(plugin.Playing.size()>= 6){
plugin.config.getString("Tribute_six_spawn");
String[] coords = plugin.config.getString("Tribute_six_spawn").split(",");
- Player Tribute_six = plugin.Playing.get(5);
+ Player Tribute_six = plugin.getServer().getPlayerExact(plugin.Playing.get(5));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -448,13 +453,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_six.teleport(loc);
- plugin.Frozen.add(Tribute_six);
+ plugin.Frozen.add(Tribute_six.getDisplayName());
Tribute_six.setFoodLevel(20);
}
if(plugin.Playing.size()>= 7){
plugin.config.getString("Tribute_seven_spawn");
String[] coords = plugin.config.getString("Tribute_seven_spawn").split(",");
- Player Tribute_seven = plugin.Playing.get(6);
+ Player Tribute_seven = plugin.getServer().getPlayerExact(plugin.Playing.get(6));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -462,13 +467,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_seven.teleport(loc);
- plugin.Frozen.add(Tribute_seven);
+ plugin.Frozen.add(Tribute_seven.getDisplayName());
Tribute_seven.setFoodLevel(20);
}
if(plugin.Playing.size()>= 8){
plugin.config.getString("Tribute_eight_spawn");
String[] coords = plugin.config.getString("Tribute_eight_spawn").split(",");
- Player Tribute_eight = plugin.Playing.get(7);
+ Player Tribute_eight = plugin.getServer().getPlayerExact(plugin.Playing.get(7));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -476,13 +481,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_eight.teleport(loc);
- plugin.Frozen.add(Tribute_eight);
+ plugin.Frozen.add(Tribute_eight.getDisplayName());
Tribute_eight.setFoodLevel(20);
}
if(plugin.Playing.size()>= 9){
plugin.config.getString("Tribute_nine_spawn");
String[] coords = plugin.config.getString("Tribute_nine_spawn").split(",");
- Player Tribute_nine = plugin.Playing.get(8);
+ Player Tribute_nine = plugin.getServer().getPlayerExact(plugin.Playing.get(8));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -490,13 +495,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_nine.teleport(loc);
- plugin.Frozen.add(Tribute_nine);
+ plugin.Frozen.add(Tribute_nine.getDisplayName());
Tribute_nine.setFoodLevel(20);
}
if(plugin.Playing.size()>= 10){
plugin.config.getString("Tribute_ten_spawn");
String[] coords = plugin.config.getString("Tribute_ten_spawn").split(",");
- Player Tribute_ten = plugin.Playing.get(9);
+ Player Tribute_ten = plugin.getServer().getPlayerExact(plugin.Playing.get(9));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -504,13 +509,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_ten.teleport(loc);
- plugin.Frozen.add(Tribute_ten);
+ plugin.Frozen.add(Tribute_ten.getDisplayName());
Tribute_ten.setFoodLevel(20);
}
if(plugin.Playing.size()>= 11){
plugin.config.getString("Tribute_eleven_spawn");
String[] coords = plugin.config.getString("Tribute_eleven_spawn").split(",");
- Player Tribute_eleven = plugin.Playing.get(10);
+ Player Tribute_eleven = plugin.getServer().getPlayerExact(plugin.Playing.get(10));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -518,13 +523,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_eleven.teleport(loc);
- plugin.Frozen.add(Tribute_eleven);
+ plugin.Frozen.add(Tribute_eleven.getDisplayName());
Tribute_eleven.setFoodLevel(20);
}
if(plugin.Playing.size()>= 12){
plugin.config.getString("Tribute_twelve_spawn");
String[] coords = plugin.config.getString("Tribute_twelve_spawn").split(",");
- Player Tribute_twelve = plugin.Playing.get(11);
+ Player Tribute_twelve = plugin.getServer().getPlayerExact(plugin.Playing.get(11));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -532,13 +537,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_twelve.teleport(loc);
- plugin.Frozen.add(Tribute_twelve);
+ plugin.Frozen.add(Tribute_twelve.getDisplayName());
Tribute_twelve.setFoodLevel(20);
}
if(plugin.Playing.size()>= 13){
plugin.config.getString("Tribute_thirteen_spawn");
String[] coords = plugin.config.getString("Tribute_thirteen_spawn").split(",");
- Player Tribute_thirteen = plugin.Playing.get(12);
+ Player Tribute_thirteen = plugin.getServer().getPlayerExact(plugin.Playing.get(12));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -546,13 +551,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_thirteen.teleport(loc);
- plugin.Frozen.add(Tribute_thirteen);
+ plugin.Frozen.add(Tribute_thirteen.getDisplayName());
Tribute_thirteen.setFoodLevel(20);
}
if(plugin.Playing.size()>= 14){
plugin.config.getString("Tribute_fourteen_spawn");
String[] coords = plugin.config.getString("Tribute_fourteen_spawn").split(",");
- Player Tribute_fourteen = plugin.Playing.get(13);
+ Player Tribute_fourteen = plugin.getServer().getPlayerExact(plugin.Playing.get(13));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -560,13 +565,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_fourteen.teleport(loc);
- plugin.Frozen.add(Tribute_fourteen);
+ plugin.Frozen.add(Tribute_fourteen.getDisplayName());
Tribute_fourteen.setFoodLevel(20);
}
if(plugin.Playing.size()>= 15){
plugin.config.getString("Tribute_fifteen_spawn");
String[] coords = plugin.config.getString("Tribute_fifteen_spawn").split(",");
- Player Tribute_fifteen = plugin.Playing.get(14);
+ Player Tribute_fifteen = plugin.getServer().getPlayerExact(plugin.Playing.get(14));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -574,13 +579,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_fifteen.teleport(loc);
- plugin.Frozen.add(Tribute_fifteen);
+ plugin.Frozen.add(Tribute_fifteen.getDisplayName());
Tribute_fifteen.setFoodLevel(20);
}
if(plugin.Playing.size()>= 16){
plugin.config.getString("Tribute_sixteen_spawn");
String[] coords = plugin.config.getString("Tribute_sixteen_spawn").split(",");
- Player Tribute_sixteen = plugin.Playing.get(15);
+ Player Tribute_sixteen = plugin.getServer().getPlayerExact(plugin.Playing.get(15));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -588,13 +593,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_sixteen.teleport(loc);
- plugin.Frozen.add(Tribute_sixteen);
+ plugin.Frozen.add(Tribute_sixteen.getDisplayName());
Tribute_sixteen.setFoodLevel(20);
}
if(plugin.Playing.size()>= 17){
plugin.config.getString("Tribute_seventeen_spawn");
String[] coords = plugin.config.getString("Tribute_seventeen_spawn").split(",");
- Player Tribute_seventeen = plugin.Playing.get(16);
+ Player Tribute_seventeen = plugin.getServer().getPlayerExact(plugin.Playing.get(16));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -602,13 +607,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_seventeen.teleport(loc);
- plugin.Frozen.add(Tribute_seventeen);
+ plugin.Frozen.add(Tribute_seventeen.getDisplayName());
Tribute_seventeen.setFoodLevel(20);
}
if(plugin.Playing.size()>= 18){
plugin.config.getString("Tribute_eighteen_spawn");
String[] coords = plugin.config.getString("Tribute_eighteen_spawn").split(",");
- Player Tribute_eighteen = plugin.Playing.get(17);
+ Player Tribute_eighteen = plugin.getServer().getPlayerExact(plugin.Playing.get(17));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -616,13 +621,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_eighteen.teleport(loc);
- plugin.Frozen.add(Tribute_eighteen);
+ plugin.Frozen.add(Tribute_eighteen.getDisplayName());
Tribute_eighteen.setFoodLevel(20);
}
if(plugin.Playing.size()>= 19){
plugin.config.getString("Tribute_nineteen_spawn");
String[] coords = plugin.config.getString("Tribute_nineteen_spawn").split(",");
- Player Tribute_nineteen = plugin.Playing.get(18);
+ Player Tribute_nineteen = plugin.getServer().getPlayerExact(plugin.Playing.get(18));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -630,13 +635,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_nineteen.teleport(loc);
- plugin.Frozen.add(Tribute_nineteen);
+ plugin.Frozen.add(Tribute_nineteen.getDisplayName());
Tribute_nineteen.setFoodLevel(20);
}
if(plugin.Playing.size()>= 20){
plugin.config.getString("Tribute_twenty_spawn");
String[] coords = plugin.config.getString("Tribute_twenty_spawn").split(",");
- Player Tribute_twenty = plugin.Playing.get(19);
+ Player Tribute_twenty = plugin.getServer().getPlayerExact(plugin.Playing.get(19));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -644,13 +649,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_twenty.teleport(loc);
- plugin.Frozen.add(Tribute_twenty);
+ plugin.Frozen.add(Tribute_twenty.getDisplayName());
Tribute_twenty.setFoodLevel(20);
}
if(plugin.Playing.size()>= 21){
plugin.config.getString("Tribute_twentyone_spawn");
String[] coords = plugin.config.getString("Tribute_twentyone_spawn").split(",");
- Player Tribute_twentyone = plugin.Playing.get(20);
+ Player Tribute_twentyone = plugin.getServer().getPlayerExact(plugin.Playing.get(20));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -658,13 +663,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_twentyone.teleport(loc);
- plugin.Frozen.add(Tribute_twentyone);
+ plugin.Frozen.add(Tribute_twentyone.getDisplayName());
Tribute_twentyone.setFoodLevel(20);
}
if(plugin.Playing.size()>= 22){
plugin.config.getString("Tribute_twentytwo_spawn");
String[] coords = plugin.config.getString("Tribute_twentytwo_spawn").split(",");
- Player Tribute_twentytwo = plugin.Playing.get(21);
+ Player Tribute_twentytwo = plugin.getServer().getPlayerExact(plugin.Playing.get(21));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -672,13 +677,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_twentytwo.teleport(loc);
- plugin.Frozen.add(Tribute_twentytwo);
+ plugin.Frozen.add(Tribute_twentytwo.getDisplayName());
Tribute_twentytwo.setFoodLevel(20);
}
if(plugin.Playing.size()>= 23){
plugin.config.getString("Tribute_twentythree_spawn");
String[] coords = plugin.config.getString("Tribute_twentythree_spawn").split(",");
- Player Tribute_twentythree = plugin.Playing.get(22);
+ Player Tribute_twentythree = plugin.getServer().getPlayerExact(plugin.Playing.get(22));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -686,13 +691,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_twentythree.teleport(loc);
- plugin.Frozen.add(Tribute_twentythree);
+ plugin.Frozen.add(Tribute_twentythree.getDisplayName());
Tribute_twentythree.setFoodLevel(20);
}
if(plugin.Playing.size()>= 24){
plugin.config.getString("Tribute_twentyfour_spawn");
String[] coords = plugin.config.getString("Tribute_twentyfour_spawn").split(",");
- Player Tribute_twentyfour = plugin.Playing.get(23);
+ Player Tribute_twentyfour = plugin.getServer().getPlayerExact(plugin.Playing.get(23));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -700,7 +705,7 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_twentyfour.teleport(loc);
- plugin.Frozen.add(Tribute_twentyfour);
+ plugin.Frozen.add(Tribute_twentyfour.getDisplayName());
Tribute_twentyfour.setFoodLevel(20);
}
}
@@ -800,6 +805,7 @@ public class HaCommands implements CommandExecutor {
sender.sendMessage(c + "/ha restart - Makes it so dead tributes can join again!");
sender.sendMessage(c + "/ha warpall - Warps all tribute into position!");
sender.sendMessage(c + "/ha reload - Reloads the config!");
+ sender.sendMessage(c + "/ha refill - Refills all chests!");
sender.sendMessage(c + "/ha start - Unfreezes tributes allowing them to fight!");
sender.sendMessage(c + "/ha list - Shows a list of players in the game and their health!");
sender.sendMessage(c + "/ha rlist - See who's ready!");
@@ -808,76 +814,54 @@ public class HaCommands implements CommandExecutor {
return false;
}else if(args[0].equalsIgnoreCase("List")){
sender.sendMessage(ChatColor.AQUA + "-----People Playing-----");
- for(Player players:plugin.Playing){
+ if(!(plugin.Playing.size()== 0)){
+ String playernames = plugin.Playing.get(i++);
+ Player players = plugin.getServer().getPlayerExact(playernames);
sender.sendMessage(ChatColor.GREEN + players.getDisplayName() + " Life: " + players.getHealth() + "/20");
- }
- if(plugin.Playing.size()== 0){
+ }else if(plugin.Playing.size()== 0){
sender.sendMessage(ChatColor.GRAY + "No one is playing!");
}
sender.sendMessage(ChatColor.AQUA + "----------------------");
- }else if(args[0].equalsIgnoreCase("SetSpawn")){
- if(sender instanceof ConsoleCommandSender){
- sender.sendMessage(ChatColor.RED + "That can only be run by a player!");
- }
- }else if(args[0].equalsIgnoreCase("Join")){
- if(sender instanceof ConsoleCommandSender){
- sender.sendMessage(ChatColor.RED + "That can only be run by a player!");
- }
- }else if(args[0].equalsIgnoreCase("Confirm")){
- if(sender instanceof ConsoleCommandSender){
- sender.sendMessage(ChatColor.RED + "That can only be run by a player!");
- }
- }else if(args[0].equalsIgnoreCase("Ready")){
- if(sender instanceof ConsoleCommandSender){
- sender.sendMessage(ChatColor.RED + "That can only be run by a player!");
- }
- }else if(args[0].equalsIgnoreCase("Leave")){
- if(sender instanceof ConsoleCommandSender){
- sender.sendMessage(ChatColor.RED + "That can only be run by a player!");
- }
- }else if(args[0].equalsIgnoreCase("Watch")){
- if(sender instanceof ConsoleCommandSender){
- sender.sendMessage(ChatColor.RED + "That can only be run by a player!");
- }
+ }else if(args[0].equalsIgnoreCase("SetSpawn") || args[0].equalsIgnoreCase("Join") || args[0].equalsIgnoreCase("Confirm") || args[0].equalsIgnoreCase("Ready") || args[0].equalsIgnoreCase("Leave") || args[0].equalsIgnoreCase("Watch")){
+ sender.sendMessage(ChatColor.RED + "That can only be run by a player!");
}else if(args[0].equalsIgnoreCase("Kick")){
Player target = plugin.getServer().getPlayer(args[1]);
if(plugin.Playing.contains(target)){
- if(target.isOnline()){
- plugin.Playing.remove(target);
- plugin.getServer().broadcastMessage(ChatColor.RED + target.getName() + " was kicked from the game!");
- target.teleport(Spawn);
- target.getInventory().clear();
- target.getInventory().setBoots(null);
- target.getInventory().setChestplate(null);
- target.getInventory().setHelmet(null);
- target.getInventory().setLeggings(null);
- plugin.Quit.add(target);
- if(plugin.Playing.size()== 1 && plugin.canjoin== true){
- for(Player winner:plugin.Playing){
- String winnername = winner.getName();
- plugin.getServer().broadcastMessage(ChatColor.GREEN + winnername + " is the victor of this Hunger Games!");
- winner.getInventory().clear();
- winner.teleport(Spawn);
- winner.getInventory().setBoots(null);
- winner.getInventory().setChestplate(null);
- winner.getInventory().setHelmet(null);
- winner.getInventory().setLeggings(null);
- winner.getInventory().addItem(plugin.Reward);
+ plugin.Playing.remove(target.getDisplayName());
+ plugin.getServer().broadcastMessage(ChatColor.RED + target.getName() + " was kicked from the game!");
+ target.teleport(Spawn);
+ target.getInventory().clear();
+ target.getInventory().setBoots(null);
+ target.getInventory().setChestplate(null);
+ target.getInventory().setHelmet(null);
+ target.getInventory().setLeggings(null);
+ plugin.Quit.add(target.getDisplayName());
+ if(plugin.Playing.size()== 1 && plugin.canjoin== true){
+ //Announce winner
+ String winnername = plugin.Playing.get(i++);
+ Player winner = plugin.getServer().getPlayerExact(winnername);
+ String winnername2 = winner.getName();
+ plugin.getServer().broadcastMessage(ChatColor.GREEN + winnername2 + " is the victor of this Hunger Games!");
+ winner.getInventory().clear();
+ winner.teleport(Spawn);
+ winner.getInventory().setBoots(null);
+ winner.getInventory().setChestplate(null);
+ winner.getInventory().setHelmet(null);
+ winner.getInventory().setLeggings(null);
+ winner.getInventory().addItem(plugin.Reward);
+ plugin.Playing.clear();
+ //Make spectators visible
+ if(!plugin.Watching.isEmpty()){
+ String s = plugin.Watching.get(i++);
+ Player spectator = plugin.getServer().getPlayerExact(s);
+ spectator.setAllowFlight(false);
+ spectator.teleport(Spawn);
+ for(Player online:plugin.getServer().getOnlinePlayers()){
+ online.showPlayer(spectator);
}
- plugin.Playing.clear();
- for(Player spectator:plugin.Watching){
- spectator.setAllowFlight(false);
- spectator.teleport(Spawn);
- for(Player online:plugin.getServer().getOnlinePlayers()){
- online.showPlayer(spectator);
- }
- }
- if(plugin.config.getString("Auto_Restart").equalsIgnoreCase("True")){
- Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha restart");
- }
- }else{
- plugin.Playing.remove(target);
- plugin.Quit.add(target);
+ }
+ if(plugin.config.getString("Auto_Restart").equalsIgnoreCase("True")){
+ Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha restart");
}
}
}else{
@@ -914,13 +898,9 @@ public class HaCommands implements CommandExecutor {
sender.sendMessage(ChatColor.GREEN + "All chests refilled!");
}
}else if(args[0].equalsIgnoreCase("Restart")){
- for(Player spectator:plugin.Watching){
- spectator.setAllowFlight(false);
- for(Player online:plugin.getServer().getOnlinePlayers()){
- online.showPlayer(spectator);
- }
- }
- for(Player spectator:plugin.Watching){
+ if(!plugin.Watching.isEmpty()){
+ String s = plugin.Watching.get(i++);
+ Player spectator = plugin.getServer().getPlayerExact(s);
spectator.setAllowFlight(false);
spectator.teleport(Spawn);
for(Player online:plugin.getServer().getOnlinePlayers()){
@@ -951,7 +931,7 @@ public class HaCommands implements CommandExecutor {
if(plugin.Playing.size()>= 2){
plugin.config.getString("Tribute_one_spawn");
String[] onecoords = plugin.config.getString("Tribute_one_spawn").split(",");
- Player Tribute_one = plugin.Playing.get(0);
+ Player Tribute_one = plugin.getServer().getPlayerExact(plugin.Playing.get(0));
double x = Double.parseDouble(onecoords[0]);
double y = Double.parseDouble(onecoords[1]);
double z = Double.parseDouble(onecoords[2]);
@@ -959,11 +939,11 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location oneloc = new Location(w, x, y, z);
Tribute_one.teleport(oneloc);
- plugin.Frozen.add(Tribute_one);
+ plugin.Frozen.add(Tribute_one.getDisplayName());
Tribute_one.setFoodLevel(20);
plugin.config.getString("Tribute_two_spawn");
String[] twocoords = plugin.config.getString("Tribute_two_spawn").split(",");
- Player Tribute_two = plugin.Playing.get(1);
+ Player Tribute_two = plugin.getServer().getPlayerExact(plugin.Playing.get(1));
double twox = Double.parseDouble(twocoords[0]);
double twoy = Double.parseDouble(twocoords[1]);
double twoz = Double.parseDouble(twocoords[2]);
@@ -971,7 +951,7 @@ public class HaCommands implements CommandExecutor {
World twow = plugin.getServer().getWorld(twoworld);
Location twoloc = new Location(twow, twox, twoy, twoz);
Tribute_two.teleport(twoloc);
- plugin.Frozen.add(Tribute_two);
+ plugin.Frozen.add(Tribute_two.getDisplayName());
Tribute_two.setFoodLevel(20);
Tribute_one.getWorld().setTime(0);
if(plugin.config.getString("Auto_Start").equalsIgnoreCase("true")){
@@ -981,11 +961,16 @@ public class HaCommands implements CommandExecutor {
}
}, 20L);
}
+ plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
+ public void run(){
+ sender.sendMessage(ChatColor.AQUA + "All Tributes warped!");
+ }
+ }, 20L);
}
if(plugin.Playing.size()>= 3){
plugin.config.getString("Tribute_three_spawn");
String[] coords = plugin.config.getString("Tribute_three_spawn").split(",");
- Player Tribute_three = plugin.Playing.get(2);
+ Player Tribute_three = plugin.getServer().getPlayerExact(plugin.Playing.get(2));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -993,13 +978,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_three.teleport(loc);
- plugin.Frozen.add(Tribute_three);
+ plugin.Frozen.add(Tribute_three.getDisplayName());
Tribute_three.setFoodLevel(20);
}
if(plugin.Playing.size()>= 4){
plugin.config.getString("Tribute_four_spawn");
String[] coords = plugin.config.getString("Tribute_four_spawn").split(",");
- Player Tribute_four = plugin.Playing.get(3);
+ Player Tribute_four = plugin.getServer().getPlayerExact(plugin.Playing.get(3));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -1007,13 +992,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_four.teleport(loc);
- plugin.Frozen.add(Tribute_four);
+ plugin.Frozen.add(Tribute_four.getDisplayName());
Tribute_four.setFoodLevel(20);
}
if(plugin.Playing.size()>= 5){
plugin.config.getString("Tribute_five_spawn");
String[] coords = plugin.config.getString("Tribute_five_spawn").split(",");
- Player Tribute_five = plugin.Playing.get(4);
+ Player Tribute_five = plugin.getServer().getPlayerExact(plugin.Playing.get(4));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -1021,13 +1006,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_five.teleport(loc);
- plugin.Frozen.add(Tribute_five);
+ plugin.Frozen.add(Tribute_five.getDisplayName());
Tribute_five.setFoodLevel(20);
}
if(plugin.Playing.size()>= 6){
plugin.config.getString("Tribute_six_spawn");
String[] coords = plugin.config.getString("Tribute_six_spawn").split(",");
- Player Tribute_six = plugin.Playing.get(5);
+ Player Tribute_six = plugin.getServer().getPlayerExact(plugin.Playing.get(5));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -1035,13 +1020,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_six.teleport(loc);
- plugin.Frozen.add(Tribute_six);
+ plugin.Frozen.add(Tribute_six.getDisplayName());
Tribute_six.setFoodLevel(20);
}
if(plugin.Playing.size()>= 7){
plugin.config.getString("Tribute_seven_spawn");
String[] coords = plugin.config.getString("Tribute_seven_spawn").split(",");
- Player Tribute_seven = plugin.Playing.get(6);
+ Player Tribute_seven = plugin.getServer().getPlayerExact(plugin.Playing.get(6));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -1049,13 +1034,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_seven.teleport(loc);
- plugin.Frozen.add(Tribute_seven);
+ plugin.Frozen.add(Tribute_seven.getDisplayName());
Tribute_seven.setFoodLevel(20);
}
if(plugin.Playing.size()>= 8){
plugin.config.getString("Tribute_eight_spawn");
String[] coords = plugin.config.getString("Tribute_eight_spawn").split(",");
- Player Tribute_eight = plugin.Playing.get(7);
+ Player Tribute_eight = plugin.getServer().getPlayerExact(plugin.Playing.get(7));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -1063,13 +1048,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_eight.teleport(loc);
- plugin.Frozen.add(Tribute_eight);
+ plugin.Frozen.add(Tribute_eight.getDisplayName());
Tribute_eight.setFoodLevel(20);
}
if(plugin.Playing.size()>= 9){
plugin.config.getString("Tribute_nine_spawn");
String[] coords = plugin.config.getString("Tribute_nine_spawn").split(",");
- Player Tribute_nine = plugin.Playing.get(8);
+ Player Tribute_nine = plugin.getServer().getPlayerExact(plugin.Playing.get(8));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -1077,13 +1062,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_nine.teleport(loc);
- plugin.Frozen.add(Tribute_nine);
+ plugin.Frozen.add(Tribute_nine.getDisplayName());
Tribute_nine.setFoodLevel(20);
}
if(plugin.Playing.size()>= 10){
plugin.config.getString("Tribute_ten_spawn");
String[] coords = plugin.config.getString("Tribute_ten_spawn").split(",");
- Player Tribute_ten = plugin.Playing.get(9);
+ Player Tribute_ten = plugin.getServer().getPlayerExact(plugin.Playing.get(9));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -1091,13 +1076,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_ten.teleport(loc);
- plugin.Frozen.add(Tribute_ten);
+ plugin.Frozen.add(Tribute_ten.getDisplayName());
Tribute_ten.setFoodLevel(20);
}
if(plugin.Playing.size()>= 11){
plugin.config.getString("Tribute_eleven_spawn");
String[] coords = plugin.config.getString("Tribute_eleven_spawn").split(",");
- Player Tribute_eleven = plugin.Playing.get(10);
+ Player Tribute_eleven = plugin.getServer().getPlayerExact(plugin.Playing.get(10));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -1105,13 +1090,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_eleven.teleport(loc);
- plugin.Frozen.add(Tribute_eleven);
+ plugin.Frozen.add(Tribute_eleven.getDisplayName());
Tribute_eleven.setFoodLevel(20);
}
if(plugin.Playing.size()>= 12){
plugin.config.getString("Tribute_twelve_spawn");
String[] coords = plugin.config.getString("Tribute_twelve_spawn").split(",");
- Player Tribute_twelve = plugin.Playing.get(11);
+ Player Tribute_twelve = plugin.getServer().getPlayerExact(plugin.Playing.get(11));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -1119,13 +1104,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_twelve.teleport(loc);
- plugin.Frozen.add(Tribute_twelve);
+ plugin.Frozen.add(Tribute_twelve.getDisplayName());
Tribute_twelve.setFoodLevel(20);
}
if(plugin.Playing.size()>= 13){
plugin.config.getString("Tribute_thirteen_spawn");
String[] coords = plugin.config.getString("Tribute_thirteen_spawn").split(",");
- Player Tribute_thirteen = plugin.Playing.get(12);
+ Player Tribute_thirteen = plugin.getServer().getPlayerExact(plugin.Playing.get(12));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -1133,13 +1118,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_thirteen.teleport(loc);
- plugin.Frozen.add(Tribute_thirteen);
+ plugin.Frozen.add(Tribute_thirteen.getDisplayName());
Tribute_thirteen.setFoodLevel(20);
}
if(plugin.Playing.size()>= 14){
plugin.config.getString("Tribute_fourteen_spawn");
String[] coords = plugin.config.getString("Tribute_fourteen_spawn").split(",");
- Player Tribute_fourteen = plugin.Playing.get(13);
+ Player Tribute_fourteen = plugin.getServer().getPlayerExact(plugin.Playing.get(13));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -1147,13 +1132,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_fourteen.teleport(loc);
- plugin.Frozen.add(Tribute_fourteen);
+ plugin.Frozen.add(Tribute_fourteen.getDisplayName());
Tribute_fourteen.setFoodLevel(20);
}
if(plugin.Playing.size()>= 15){
plugin.config.getString("Tribute_fifteen_spawn");
String[] coords = plugin.config.getString("Tribute_fifteen_spawn").split(",");
- Player Tribute_fifteen = plugin.Playing.get(14);
+ Player Tribute_fifteen = plugin.getServer().getPlayerExact(plugin.Playing.get(14));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -1161,13 +1146,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_fifteen.teleport(loc);
- plugin.Frozen.add(Tribute_fifteen);
+ plugin.Frozen.add(Tribute_fifteen.getDisplayName());
Tribute_fifteen.setFoodLevel(20);
}
if(plugin.Playing.size()>= 16){
plugin.config.getString("Tribute_sixteen_spawn");
String[] coords = plugin.config.getString("Tribute_sixteen_spawn").split(",");
- Player Tribute_sixteen = plugin.Playing.get(15);
+ Player Tribute_sixteen = plugin.getServer().getPlayerExact(plugin.Playing.get(15));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -1175,13 +1160,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_sixteen.teleport(loc);
- plugin.Frozen.add(Tribute_sixteen);
+ plugin.Frozen.add(Tribute_sixteen.getDisplayName());
Tribute_sixteen.setFoodLevel(20);
}
if(plugin.Playing.size()>= 17){
plugin.config.getString("Tribute_seventeen_spawn");
String[] coords = plugin.config.getString("Tribute_seventeen_spawn").split(",");
- Player Tribute_seventeen = plugin.Playing.get(16);
+ Player Tribute_seventeen = plugin.getServer().getPlayerExact(plugin.Playing.get(16));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -1189,13 +1174,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_seventeen.teleport(loc);
- plugin.Frozen.add(Tribute_seventeen);
+ plugin.Frozen.add(Tribute_seventeen.getDisplayName());
Tribute_seventeen.setFoodLevel(20);
}
if(plugin.Playing.size()>= 18){
plugin.config.getString("Tribute_eighteen_spawn");
String[] coords = plugin.config.getString("Tribute_eighteen_spawn").split(",");
- Player Tribute_eighteen = plugin.Playing.get(17);
+ Player Tribute_eighteen = plugin.getServer().getPlayerExact(plugin.Playing.get(17));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -1203,13 +1188,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_eighteen.teleport(loc);
- plugin.Frozen.add(Tribute_eighteen);
+ plugin.Frozen.add(Tribute_eighteen.getDisplayName());
Tribute_eighteen.setFoodLevel(20);
}
if(plugin.Playing.size()>= 19){
plugin.config.getString("Tribute_nineteen_spawn");
String[] coords = plugin.config.getString("Tribute_nineteen_spawn").split(",");
- Player Tribute_nineteen = plugin.Playing.get(18);
+ Player Tribute_nineteen = plugin.getServer().getPlayerExact(plugin.Playing.get(18));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -1217,13 +1202,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_nineteen.teleport(loc);
- plugin.Frozen.add(Tribute_nineteen);
+ plugin.Frozen.add(Tribute_nineteen.getDisplayName());
Tribute_nineteen.setFoodLevel(20);
}
if(plugin.Playing.size()>= 20){
plugin.config.getString("Tribute_twenty_spawn");
String[] coords = plugin.config.getString("Tribute_twenty_spawn").split(",");
- Player Tribute_twenty = plugin.Playing.get(19);
+ Player Tribute_twenty = plugin.getServer().getPlayerExact(plugin.Playing.get(19));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -1231,13 +1216,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_twenty.teleport(loc);
- plugin.Frozen.add(Tribute_twenty);
+ plugin.Frozen.add(Tribute_twenty.getDisplayName());
Tribute_twenty.setFoodLevel(20);
}
if(plugin.Playing.size()>= 21){
plugin.config.getString("Tribute_twentyone_spawn");
String[] coords = plugin.config.getString("Tribute_twentyone_spawn").split(",");
- Player Tribute_twentyone = plugin.Playing.get(20);
+ Player Tribute_twentyone = plugin.getServer().getPlayerExact(plugin.Playing.get(20));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -1245,13 +1230,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_twentyone.teleport(loc);
- plugin.Frozen.add(Tribute_twentyone);
+ plugin.Frozen.add(Tribute_twentyone.getDisplayName());
Tribute_twentyone.setFoodLevel(20);
}
if(plugin.Playing.size()>= 22){
plugin.config.getString("Tribute_twentytwo_spawn");
String[] coords = plugin.config.getString("Tribute_twentytwo_spawn").split(",");
- Player Tribute_twentytwo = plugin.Playing.get(21);
+ Player Tribute_twentytwo = plugin.getServer().getPlayerExact(plugin.Playing.get(21));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -1259,13 +1244,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_twentytwo.teleport(loc);
- plugin.Frozen.add(Tribute_twentytwo);
+ plugin.Frozen.add(Tribute_twentytwo.getDisplayName());
Tribute_twentytwo.setFoodLevel(20);
}
if(plugin.Playing.size()>= 23){
plugin.config.getString("Tribute_twentythree_spawn");
String[] coords = plugin.config.getString("Tribute_twentythree_spawn").split(",");
- Player Tribute_twentythree = plugin.Playing.get(22);
+ Player Tribute_twentythree = plugin.getServer().getPlayerExact(plugin.Playing.get(22));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -1273,13 +1258,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_twentythree.teleport(loc);
- plugin.Frozen.add(Tribute_twentythree);
+ plugin.Frozen.add(Tribute_twentythree.getDisplayName());
Tribute_twentythree.setFoodLevel(20);
}
if(plugin.Playing.size()>= 24){
plugin.config.getString("Tribute_twentyfour_spawn");
String[] coords = plugin.config.getString("Tribute_twentyfour_spawn").split(",");
- Player Tribute_twentyfour = plugin.Playing.get(23);
+ Player Tribute_twentyfour = plugin.getServer().getPlayerExact(plugin.Playing.get(23));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
@@ -1287,7 +1272,7 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
Tribute_twentyfour.teleport(loc);
- plugin.Frozen.add(Tribute_twentyfour);
+ plugin.Frozen.add(Tribute_twentyfour.getDisplayName());
Tribute_twentyfour.setFoodLevel(20);
}
}
diff --git a/src/me/Travja/HungerArena/JoinAndQuitListener.java b/src/me/Travja/HungerArena/JoinAndQuitListener.java
index 4479883..533ca31 100644
--- a/src/me/Travja/HungerArena/JoinAndQuitListener.java
+++ b/src/me/Travja/HungerArena/JoinAndQuitListener.java
@@ -1,5 +1,6 @@
package me.Travja.HungerArena;
+import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
@@ -14,22 +15,26 @@ public class JoinAndQuitListener implements Listener {
public JoinAndQuitListener(Main m) {
this.plugin = m;
}
+ int i = 0;
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event){
- Player p = event.getPlayer();
- final Player player = event.getPlayer();
- for(Player spectator:plugin.Watching){
+ final Player p = event.getPlayer();
+ String pname = p.getDisplayName();
+ if(!plugin.Watching.isEmpty()){
+ String s = plugin.Watching.get(i++);
+ Player spectator = plugin.getServer().getPlayerExact(s);
p.hidePlayer(spectator);
}
- if(plugin.Out.contains(p)){
+ if(plugin.Out.contains(pname)){
+ plugin.Playing.add(pname);
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
public void run(){
- player.sendMessage(ChatColor.AQUA + "You have saved yourself from being ejected from the arena!");
+ p.sendMessage(ChatColor.AQUA + "You have saved yourself from being ejected from the arena!");
}
}, 40L);
plugin.Out.remove(p);
}
- if(plugin.Quit.contains(p) || plugin.Dead.contains(p)){
+ if(plugin.Quit.contains(pname) || plugin.Dead.contains(pname)){
String[] Spawncoords = plugin.config.getString("Spawn_coords").split(",");
String w = Spawncoords[3];
World spawnw = plugin.getServer().getWorld(w);
@@ -39,8 +44,8 @@ public class JoinAndQuitListener implements Listener {
final Location Spawn = new Location(spawnw, spawnx, spawny, spawnz);
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
public void run(){
- player.teleport(Spawn);
- player.sendMessage(ChatColor.RED + "You have been teleported to spawn because you quit/forfieted!");
+ p.teleport(Spawn);
+ p.sendMessage(ChatColor.RED + "You have been teleported to spawn because you quit/forfieted!");
}
}, 40L);
}
@@ -48,6 +53,7 @@ public class JoinAndQuitListener implements Listener {
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event){
final Player p = event.getPlayer();
+ final String pname = p.getDisplayName();
String[] Spawncoords = plugin.config.getString("Spawn_coords").split(",");
String w = Spawncoords[3];
World spawnw = plugin.getServer().getWorld(w);
@@ -55,45 +61,46 @@ public class JoinAndQuitListener implements Listener {
double spawny = Double.parseDouble(Spawncoords[1]);
double spawnz = Double.parseDouble(Spawncoords[2]);
final Location Spawn = new Location(spawnw, spawnx, spawny, spawnz);
- if(plugin.Playing.contains(p)){
- plugin.Out.add(p);
+ if(plugin.Playing.contains(pname)){
+ plugin.Out.add(pname);
+ plugin.Playing.remove(pname);
}
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
public void run(){
- if(plugin.Playing.contains(p) && plugin.Out.contains(p)){
+ if(plugin.Out.contains(pname)){
if(plugin.canjoin== true){
- plugin.Playing.remove(p);
- plugin.Quit.add(p);
- plugin.Out.remove(p);
+ plugin.Quit.add(pname);
+ plugin.Out.remove(pname);
if(plugin.Playing.size()== 1){
- for(Player winner:plugin.Playing){
- String winnername = winner.getName();
- p.getServer().broadcastMessage(ChatColor.GREEN + winnername + " is the victor of this Hunger Games!");
- winner.getInventory().clear();
- winner.getInventory().setBoots(null);
- winner.getInventory().setChestplate(null);
- winner.getInventory().setHelmet(null);
- winner.getInventory().setLeggings(null);
- winner.getInventory().addItem(plugin.Reward);
- }
- for(Player spectator:plugin.Watching){
+ //Announce Winner
+ String winnername = plugin.Playing.get(i++);
+ Player winner = plugin.getServer().getPlayerExact(winnername);
+ String winnername2 = winner.getName();
+ p.getServer().broadcastMessage(ChatColor.GREEN + winnername2 + " is the victor of this Hunger Games!");
+ winner.getInventory().clear();
+ winner.getInventory().setBoots(null);
+ winner.getInventory().setChestplate(null);
+ winner.getInventory().setHelmet(null);
+ winner.getInventory().setLeggings(null);
+ winner.getInventory().addItem(plugin.Reward);
+ //Make spectators visible
+ if(!plugin.Watching.isEmpty()){
+ String s = plugin.Watching.get(i++);
+ Player spectator = plugin.getServer().getPlayerExact(s);
spectator.setAllowFlight(false);
spectator.teleport(Spawn);
+ for(Player online:plugin.getServer().getOnlinePlayers()){
+ online.showPlayer(spectator);
+ }
}
if(plugin.config.getString("Auto_Restart").equalsIgnoreCase("True")){
- plugin.Dead.clear();
- plugin.Playing.clear();
- plugin.Quit.clear();
- plugin.Watching.clear();
- plugin.Frozen.clear();
- plugin.canjoin = false;
+ Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha restart");
}
}
- }else if(plugin.canjoin== false){
- plugin.Playing.remove(p);
- plugin.Quit.add(p);
- plugin.Out.remove(p);
}
+ }else{
+ plugin.Quit.add(pname);
+ plugin.Out.remove(pname);
}
}
}, 1200L);
diff --git a/src/me/Travja/HungerArena/Main.java b/src/me/Travja/HungerArena/Main.java
index b739753..6259c62 100644
--- a/src/me/Travja/HungerArena/Main.java
+++ b/src/me/Travja/HungerArena/Main.java
@@ -2,52 +2,24 @@ package me.Travja.HungerArena;
import java.util.ArrayList;
import java.util.HashSet;
-import java.util.List;
import java.util.logging.Logger;
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-import org.bukkit.Effect;
-import org.bukkit.Location;
-import org.bukkit.Material;
-import org.bukkit.Server;
-import org.bukkit.World;
-import org.bukkit.block.Block;
-import org.bukkit.block.Chest;
-import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
-import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
-import org.bukkit.entity.Entity;
-import org.bukkit.entity.Player;
-import org.bukkit.entity.Projectile;
-import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
-import org.bukkit.event.block.Action;
-import org.bukkit.event.block.BlockBreakEvent;
-import org.bukkit.event.entity.EntityDamageByEntityEvent;
-import org.bukkit.event.entity.PlayerDeathEvent;
-import org.bukkit.event.player.PlayerChatEvent;
-import org.bukkit.event.player.PlayerDropItemEvent;
-import org.bukkit.event.player.PlayerInteractEvent;
-import org.bukkit.event.player.PlayerJoinEvent;
-import org.bukkit.event.player.PlayerMoveEvent;
-import org.bukkit.event.player.PlayerPickupItemEvent;
-import org.bukkit.event.player.PlayerQuitEvent;
-import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin{
Logger log;
- public ArrayList Playing = new ArrayList();
- public ArrayList Ready = new ArrayList();
- public ArrayList Dead = new ArrayList();
- public ArrayList Quit = new ArrayList();
- public ArrayList Out = new ArrayList();
- public ArrayList Watching = new ArrayList();
- public ArrayList NeedConfirm = new ArrayList();
- public HashSet Frozen = new HashSet();
+ public ArrayList Playing = new ArrayList();
+ public ArrayList Ready = new ArrayList();
+ public ArrayList Dead = new ArrayList();
+ public ArrayList Quit = new ArrayList();
+ public ArrayList Out = new ArrayList();
+ public ArrayList Watching = new ArrayList();
+ public ArrayList NeedConfirm = new ArrayList();
+ public HashSet Frozen = new HashSet();
public Listener DeathListener = new DeathListener(this);
public Listener SpectatorListener = new SpectatorListener(this);
public Listener FreezeListener = new FreezeListener(this);
@@ -58,6 +30,7 @@ public class Main extends JavaPlugin{
public Listener Blocks = new Blocks(this);
public Listener CommandBlock = new CommandBlock(this);
public Listener Signs = new Signs(this);
+ public Listener BlockStorage = new BlockStorage(this);
public CommandExecutor HaCommands = new HaCommands(this);
public CommandExecutor SponsorCommands = new SponsorCommands(this);
public CommandExecutor SpawnsCommand = new SpawnsCommand(this);
@@ -82,6 +55,7 @@ public class Main extends JavaPlugin{
getServer().getPluginManager().registerEvents(Blocks, this);
getServer().getPluginManager().registerEvents(CommandBlock, this);
getServer().getPluginManager().registerEvents(Signs, this);
+ getServer().getPluginManager().registerEvents(BlockStorage, this);
getCommand("Ha").setExecutor(HaCommands);
getCommand("Sponsor").setExecutor(SponsorCommands);
getCommand("Startpoint").setExecutor(SpawnsCommand);
@@ -92,1282 +66,4 @@ public class Main extends JavaPlugin{
log = this.getLogger();
log.info("HungerArena has been Disabled");
}
- /*public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
- Player p = (Player) sender;
- String pname = p.getName();
- if(cmd.getName().equalsIgnoreCase("Sponsor")){
- if(!Playing.contains(p)){
- if(args.length== 0){
- p.sendMessage(ChatColor.RED + "You didn't specify a tribute!");
- return false;
- }
- if(args.length== 1){
- p.sendMessage(ChatColor.RED + "You didn't specify an item!");
- }
- if(args.length== 2){
- p.sendMessage(ChatColor.RED + "You didn't specify an amount!");
- }
- if(args.length== 3){
- Player target = Bukkit.getPlayer(args[0]);
- if(args[1].equalsIgnoreCase("57") || args[1].equalsIgnoreCase("7")){
- p.sendMessage(ChatColor.RED + "You can't sponsor that item!");
- }else{
- int ID = Integer.parseInt(args[1]);
- int Amount = Integer.parseInt(args[2]);
- ItemStack sponsoritem = new ItemStack(ID, Amount);
- if(p.getInventory().contains(Cost)){
- if(!Playing.contains(target)){
- p.sendMessage(ChatColor.RED + "That person isn't playing!");
- }else{
- if(args[0].equalsIgnoreCase(pname)){
- p.sendMessage(ChatColor.RED + "You can't sponsor yourself!");
- }else{
- target.sendMessage(ChatColor.AQUA + "You have been Sponsored!");
- target.getInventory().addItem(sponsoritem);
- p.sendMessage("You have sponsored " + target.getName() + "!");
- p.getInventory().removeItem(Cost);
- }
- }
- }else{
- p.sendMessage(ChatColor.RED + "You don't have the necessary items to sponsor!");
- }
- }
- }
- }else{
- p.sendMessage(ChatColor.RED + "You are playing, you can't sponsor yourself!");
- }
- }
- if(cmd.getName().equalsIgnoreCase("Ha")){
- if(config.getString("Spawns_set").equalsIgnoreCase("false")){
- p.sendMessage(ChatColor.RED + "/ha setspawn hasn't been run!");
- }
- if(args.length== 0){
- p.sendMessage(ChatColor.GREEN + "[HungerArena] by " + ChatColor.AQUA + "travja!");
- return false;
- }
- if(args[0].equalsIgnoreCase("List")){
- if(p.hasPermission("HungerArena.GameMaker")){
- p.sendMessage(ChatColor.AQUA + "-----People Playing-----");
- for(Player players:Playing){
- p.sendMessage(ChatColor.GREEN + players.getDisplayName() + " Life: " + players.getHealth() + "/20");
- }
- if(Playing.size()== 0){
- p.sendMessage(ChatColor.GRAY + "No one is playing!");
- }
- p.sendMessage(ChatColor.AQUA + "----------------------");
- }else{
- p.sendMessage(ChatColor.RED + "You don't have permission!");
- }
- }
- if(args[0].equalsIgnoreCase("SetSpawn")){
- if(p.hasPermission("HungerArena.SetSpawn")){
- double x = p.getLocation().getX();
- double y = p.getLocation().getY();
- double z = p.getLocation().getZ();
- String w = p.getWorld().getName();
- config.set("Spawn_coords", x + "," + y + "," + z + "," + w);
- saveConfig();
- config.set("Spawns_set", "true");
- p.sendMessage(ChatColor.AQUA + "You have set the spawn for dead tributes!");
- }else{
- p.sendMessage(ChatColor.RED + "You don't have permission!");
- }
- }
- String[] Spawncoords = config.getString("Spawn_coords").split(",");
- double spawnx = Double.parseDouble(Spawncoords[0]);
- double spawny = Double.parseDouble(Spawncoords[1]);
- double spawnz = Double.parseDouble(Spawncoords[2]);
- String spawnworld = Spawncoords[3];
- World spawnw = getServer().getWorld(spawnworld);
- Location Spawn = new Location(spawnw, spawnx, spawny, spawnz);
- if(args[0].equalsIgnoreCase("Join")){
- if(p.hasPermission("HungerArena.Join")){
- if(Playing.contains(p)){
- p.sendMessage(ChatColor.RED + "You are already playing!");
- }else if(Dead.contains(p) || Quit.contains(p)){
- p.sendMessage(ChatColor.RED + "You DIED/QUIT! You can't join again!");
- }else if(Playing.size()== 24){
- p.sendMessage(ChatColor.RED + "There are already 24 Tributes!");
- }else if(canjoin== true){
- p.sendMessage(ChatColor.RED + "The game is in progress!");
- }else{
- NeedConfirm.add(p);
- p.sendMessage(ChatColor.GOLD + "You're inventory will be cleared! Type /ha confirm to procede");
- }
- }else{
- p.sendMessage(ChatColor.RED + "You don't have permission!");
- }
- }
- if(args[0].equalsIgnoreCase("Confirm")){
- if(NeedConfirm.contains(p)){
- Playing.add(p);
- NeedConfirm.remove(p);
- p.getInventory().clear();
- p.getInventory().setBoots(null);
- p.getInventory().setChestplate(null);
- p.getInventory().setHelmet(null);
- p.getInventory().setLeggings(null);
- getServer().broadcastMessage(ChatColor.AQUA + pname + " has Joined the Game!");
- if(Playing.size()== 24){
- p.performCommand("ha warpall");
- }
- }
- }
- if(args[0].equalsIgnoreCase("Ready")){
- if(Playing.contains(p)){
- Ready.add(p);
- p.sendMessage(ChatColor.AQUA + "You have marked yourself as READY!");
- if(Playing.size()== Ready.size()){
- p.performCommand("Ha Warpall");
- }
- }else if(!Playing.contains(p)){
- p.sendMessage(ChatColor.RED + "You aren't playing!");
- }
- }
- if(args[0].equalsIgnoreCase("Leave")){
- if(!Playing.contains(p)){
- p.sendMessage(ChatColor.RED + "You aren't playing!");
- }else{
- Playing.remove(p);
- Quit.add(p);
- p.sendMessage(ChatColor.AQUA + "You have left the game!");
- p.getServer().broadcastMessage(ChatColor.RED + pname + " Quit!");
- p.getInventory().clear();
- p.getInventory().setBoots(null);
- p.getInventory().setChestplate(null);
- p.getInventory().setHelmet(null);
- p.getInventory().setLeggings(null);
- p.teleport(Spawn);
- if(Frozen.contains(p)){
- Frozen.remove(p);
- }
- if(Playing.size()== 1 && canjoin== true){
- for(Player winner:Playing){
- String winnername = winner.getName();
- p.getServer().broadcastMessage(ChatColor.GREEN + winnername + " is the victor of this Hunger Games!");
- winner.getInventory().clear();
- winner.getInventory().addItem(Reward);
- }
- for(Player spectator:Watching){
- spectator.setAllowFlight(false);
- }
- canjoin= false;
- Watching.clear();
- }
- }
- }
- if(args[0].equalsIgnoreCase("Watch")){
- if(p.hasPermission("HungerArena.Watch")){
- if(!Watching.contains(p) && !Playing.contains(p) && canjoin== true){
- Watching.add(p);
- for(Player online:getServer().getOnlinePlayers()){
- online.hidePlayer(p);
- }
- p.setAllowFlight(true);
- p.sendMessage(ChatColor.AQUA + "You can now spectate!");
- }else if(canjoin == false){
- p.sendMessage(ChatColor.RED + "The game isn't in progress!");
- }else if(Playing.contains(p)){
- p.sendMessage(ChatColor.RED + "You can't watch while you're playing!");
- }else if(Watching.contains(p)){
- Watching.remove(p);
- for(Player online:getServer().getOnlinePlayers()){
- online.showPlayer(p);
- }
- p.teleport(Spawn);
- p.setAllowFlight(false);
- p.sendMessage(ChatColor.AQUA + "You are not spectating anymore");
- }
- }else{
- p.sendMessage(ChatColor.RED + "You don't have permission!");
- }
- }
- if(args[0].equalsIgnoreCase("Kick")){
- Player target = getServer().getPlayer(args[1]);
- if(p.hasPermission("HungerArena.Kick")){
- if(Playing.contains(target)){
- if(p.isOnline()){
- Playing.remove(target);
- getServer().broadcastMessage(ChatColor.RED + target.getName() + " was kicked from the game!");
- target.teleport(Spawn);
- target.getInventory().clear();
- target.getInventory().setBoots(null);
- target.getInventory().setChestplate(null);
- target.getInventory().setHelmet(null);
- target.getInventory().setLeggings(null);
- Quit.add(target);
- if(Playing.size()== 1 && canjoin== true){
- for(Player winner:Playing){
- String winnername = winner.getName();
- p.getServer().broadcastMessage(ChatColor.GREEN + winnername + " is the victor of this Hunger Games!");
- winner.getInventory().clear();
- winner.getInventory().addItem(Reward);
- }
- for(Player spectator:Watching){
- spectator.setAllowFlight(false);
- }
- canjoin= false;
- Watching.clear();
- }else{
- Playing.remove(target);
- Quit.add(target);
- }
- }
- }else{
- p.sendMessage(ChatColor.RED + "That player isn't in the game!");
- }
- }else{
- p.sendMessage(ChatColor.RED + "You don't have permission!");
- }
- }
- if(args[0].equalsIgnoreCase("Refill")){
- int list056;
- list056 = 0;
- int limit;
- limit = getConfig().getStringList("StorageXYZ").size();
- while(limit > list056){
- String xyz2 = getConfig().getStringList("StorageXYZ").get(list056);
- int chestx = getConfig().getInt("Storage." + xyz2 + ".Location.X");
- int chesty = getConfig().getInt("Storage." + xyz2 + ".Location.Y");
- int chestz = getConfig().getInt("Storage." + xyz2 + ".Location.Z");
- String chestw = getConfig().getString("Storage." + xyz2 + ".Location.W");
- Block blockatlocation = Bukkit.getWorld(chestw).getBlockAt(chestx, chesty, chestz);
- exists = false;
- if(blockatlocation.getState() instanceof Chest){
- exists = true;
- Chest chest = (Chest) blockatlocation.getState();
- chest.getInventory().clear();
- ItemStack[] itemsinchest = null;
- Object o = getConfig().get("Storage." + xyz2 + ".ItemsInStorage");
- if(o instanceof ItemStack[]){
- itemsinchest = (ItemStack[]) o;
- }else if(o instanceof List){
- itemsinchest = (ItemStack[]) ((List) o).toArray(new ItemStack[0]);
- }else{
- try{
- throw new Exception();
- }catch (Exception e) {
- e.printStackTrace();
- }
- chest.getInventory().setContents(itemsinchest);
- }
- }
- }
- }
- if(args[0].equalsIgnoreCase("Restart")){
- if(p.hasPermission("HungerArena.Restart")){
- for(Player spectator:Watching){
- spectator.setAllowFlight(false);
- }
- Dead.clear();
- Playing.clear();
- Quit.clear();
- Watching.clear();
- Frozen.clear();
- canjoin = false;
- p.sendMessage(ChatColor.AQUA + "The games have been reset!");
- }else{
- p.sendMessage(ChatColor.RED + "You don't have permission!");
- }
- }
- if(args[0].equalsIgnoreCase("Reload")){
- reloadConfig();
- p.sendMessage(ChatColor.AQUA + "HungerArena Reloaded!");
- }
- if(args[0].equalsIgnoreCase("WarpAll")){
- if(p.hasPermission("HungerArena.Warpall")){
- if(Playing.size()== 1){
- p.sendMessage(ChatColor.RED + "There are not enough players!");
- }
- if(Playing.size()>= 2){
- config.getString("Tribute_one_spawn");
- String[] onecoords = config.getString("Tribute_one_spawn").split(",");
- Player Tribute_one = Playing.get(0);
- double x = Double.parseDouble(onecoords[0]);
- double y = Double.parseDouble(onecoords[1]);
- double z = Double.parseDouble(onecoords[2]);
- String world = onecoords[3];
- World w = getServer().getWorld(world);
- Location oneloc = new Location(w, x, y, z);
- Tribute_one.teleport(oneloc);
- Frozen.add(Tribute_one);
- Tribute_one.setFoodLevel(20);
- config.getString("Tribute_two_spawn");
- String[] twocoords = config.getString("Tribute_two_spawn").split(",");
- Player Tribute_two = Playing.get(1);
- double twox = Double.parseDouble(twocoords[0]);
- double twoy = Double.parseDouble(twocoords[1]);
- double twoz = Double.parseDouble(twocoords[2]);
- String twoworld = twocoords[3];
- World twow = getServer().getWorld(twoworld);
- Location twoloc = new Location(twow, twox, twoy, twoz);
- Tribute_two.teleport(twoloc);
- Frozen.add(Tribute_two);
- Tribute_two.setFoodLevel(20);
- p.getWorld().setTime(0);
- }
- if(Playing.size()>= 3){
- config.getString("Tribute_three_spawn");
- String[] coords = config.getString("Tribute_three_spawn").split(",");
- Player Tribute_three = Playing.get(2);
- double x = Double.parseDouble(coords[0]);
- double y = Double.parseDouble(coords[1]);
- double z = Double.parseDouble(coords[2]);
- String world = coords[3];
- World w = getServer().getWorld(world);
- Location loc = new Location(w, x, y, z);
- Tribute_three.teleport(loc);
- Frozen.add(Tribute_three);
- Tribute_three.setFoodLevel(20);
- }
- if(Playing.size()>= 4){
- config.getString("Tribute_four_spawn");
- String[] coords = config.getString("Tribute_four_spawn").split(",");
- Player Tribute_four = Playing.get(3);
- double x = Double.parseDouble(coords[0]);
- double y = Double.parseDouble(coords[1]);
- double z = Double.parseDouble(coords[2]);
- String world = coords[3];
- World w = getServer().getWorld(world);
- Location loc = new Location(w, x, y, z);
- Tribute_four.teleport(loc);
- Frozen.add(Tribute_four);
- Tribute_four.setFoodLevel(20);
- }
- if(Playing.size()>= 5){
- config.getString("Tribute_five_spawn");
- String[] coords = config.getString("Tribute_five_spawn").split(",");
- Player Tribute_five = Playing.get(4);
- double x = Double.parseDouble(coords[0]);
- double y = Double.parseDouble(coords[1]);
- double z = Double.parseDouble(coords[2]);
- String world = coords[3];
- World w = getServer().getWorld(world);
- Location loc = new Location(w, x, y, z);
- Tribute_five.teleport(loc);
- Frozen.add(Tribute_five);
- Tribute_five.setFoodLevel(20);
- }
- if(Playing.size()>= 6){
- config.getString("Tribute_six_spawn");
- String[] coords = config.getString("Tribute_six_spawn").split(",");
- Player Tribute_six = Playing.get(5);
- double x = Double.parseDouble(coords[0]);
- double y = Double.parseDouble(coords[1]);
- double z = Double.parseDouble(coords[2]);
- String world = coords[3];
- World w = getServer().getWorld(world);
- Location loc = new Location(w, x, y, z);
- Tribute_six.teleport(loc);
- Frozen.add(Tribute_six);
- Tribute_six.setFoodLevel(20);
- }
- if(Playing.size()>= 7){
- config.getString("Tribute_seven_spawn");
- String[] coords = config.getString("Tribute_seven_spawn").split(",");
- Player Tribute_seven = Playing.get(6);
- double x = Double.parseDouble(coords[0]);
- double y = Double.parseDouble(coords[1]);
- double z = Double.parseDouble(coords[2]);
- String world = coords[3];
- World w = getServer().getWorld(world);
- Location loc = new Location(w, x, y, z);
- Tribute_seven.teleport(loc);
- Frozen.add(Tribute_seven);
- Tribute_seven.setFoodLevel(20);
- }
- if(Playing.size()>= 8){
- config.getString("Tribute_eight_spawn");
- String[] coords = config.getString("Tribute_eight_spawn").split(",");
- Player Tribute_eight = Playing.get(7);
- double x = Double.parseDouble(coords[0]);
- double y = Double.parseDouble(coords[1]);
- double z = Double.parseDouble(coords[2]);
- String world = coords[3];
- World w = getServer().getWorld(world);
- Location loc = new Location(w, x, y, z);
- Tribute_eight.teleport(loc);
- Frozen.add(Tribute_eight);
- Tribute_eight.setFoodLevel(20);
- }
- if(Playing.size()>= 9){
- config.getString("Tribute_nine_spawn");
- String[] coords = config.getString("Tribute_nine_spawn").split(",");
- Player Tribute_nine = Playing.get(8);
- double x = Double.parseDouble(coords[0]);
- double y = Double.parseDouble(coords[1]);
- double z = Double.parseDouble(coords[2]);
- String world = coords[3];
- World w = getServer().getWorld(world);
- Location loc = new Location(w, x, y, z);
- Tribute_nine.teleport(loc);
- Frozen.add(Tribute_nine);
- Tribute_nine.setFoodLevel(20);
- }
- if(Playing.size()>= 10){
- config.getString("Tribute_ten_spawn");
- String[] coords = config.getString("Tribute_ten_spawn").split(",");
- Player Tribute_ten = Playing.get(9);
- double x = Double.parseDouble(coords[0]);
- double y = Double.parseDouble(coords[1]);
- double z = Double.parseDouble(coords[2]);
- String world = coords[3];
- World w = getServer().getWorld(world);
- Location loc = new Location(w, x, y, z);
- Tribute_ten.teleport(loc);
- Frozen.add(Tribute_ten);
- Tribute_ten.setFoodLevel(20);
- }
- if(Playing.size()>= 11){
- config.getString("Tribute_eleven_spawn");
- String[] coords = config.getString("Tribute_eleven_spawn").split(",");
- Player Tribute_eleven = Playing.get(10);
- double x = Double.parseDouble(coords[0]);
- double y = Double.parseDouble(coords[1]);
- double z = Double.parseDouble(coords[2]);
- String world = coords[3];
- World w = getServer().getWorld(world);
- Location loc = new Location(w, x, y, z);
- Tribute_eleven.teleport(loc);
- Frozen.add(Tribute_eleven);
- Tribute_eleven.setFoodLevel(20);
- }
- if(Playing.size()>= 12){
- config.getString("Tribute_twelve_spawn");
- String[] coords = config.getString("Tribute_twelve_spawn").split(",");
- Player Tribute_twelve = Playing.get(11);
- double x = Double.parseDouble(coords[0]);
- double y = Double.parseDouble(coords[1]);
- double z = Double.parseDouble(coords[2]);
- String world = coords[3];
- World w = getServer().getWorld(world);
- Location loc = new Location(w, x, y, z);
- Tribute_twelve.teleport(loc);
- Frozen.add(Tribute_twelve);
- Tribute_twelve.setFoodLevel(20);
- }
- if(Playing.size()>= 13){
- config.getString("Tribute_thirteen_spawn");
- String[] coords = config.getString("Tribute_thirteen_spawn").split(",");
- Player Tribute_thirteen = Playing.get(12);
- double x = Double.parseDouble(coords[0]);
- double y = Double.parseDouble(coords[1]);
- double z = Double.parseDouble(coords[2]);
- String world = coords[3];
- World w = getServer().getWorld(world);
- Location loc = new Location(w, x, y, z);
- Tribute_thirteen.teleport(loc);
- Frozen.add(Tribute_thirteen);
- Tribute_thirteen.setFoodLevel(20);
- }
- if(Playing.size()>= 14){
- config.getString("Tribute_fourteen_spawn");
- String[] coords = config.getString("Tribute_fourteen_spawn").split(",");
- Player Tribute_fourteen = Playing.get(13);
- double x = Double.parseDouble(coords[0]);
- double y = Double.parseDouble(coords[1]);
- double z = Double.parseDouble(coords[2]);
- String world = coords[3];
- World w = getServer().getWorld(world);
- Location loc = new Location(w, x, y, z);
- Tribute_fourteen.teleport(loc);
- Frozen.add(Tribute_fourteen);
- Tribute_fourteen.setFoodLevel(20);
- }
- if(Playing.size()>= 15){
- config.getString("Tribute_fifteen_spawn");
- String[] coords = config.getString("Tribute_fifteen_spawn").split(",");
- Player Tribute_fifteen = Playing.get(14);
- double x = Double.parseDouble(coords[0]);
- double y = Double.parseDouble(coords[1]);
- double z = Double.parseDouble(coords[2]);
- String world = coords[3];
- World w = getServer().getWorld(world);
- Location loc = new Location(w, x, y, z);
- Tribute_fifteen.teleport(loc);
- Frozen.add(Tribute_fifteen);
- Tribute_fifteen.setFoodLevel(20);
- }
- if(Playing.size()>= 16){
- config.getString("Tribute_sixteen_spawn");
- String[] coords = config.getString("Tribute_sixteen_spawn").split(",");
- Player Tribute_sixteen = Playing.get(15);
- double x = Double.parseDouble(coords[0]);
- double y = Double.parseDouble(coords[1]);
- double z = Double.parseDouble(coords[2]);
- String world = coords[3];
- World w = getServer().getWorld(world);
- Location loc = new Location(w, x, y, z);
- Tribute_sixteen.teleport(loc);
- Frozen.add(Tribute_sixteen);
- Tribute_sixteen.setFoodLevel(20);
- }
- if(Playing.size()>= 17){
- config.getString("Tribute_seventeen_spawn");
- String[] coords = config.getString("Tribute_seventeen_spawn").split(",");
- Player Tribute_seventeen = Playing.get(16);
- double x = Double.parseDouble(coords[0]);
- double y = Double.parseDouble(coords[1]);
- double z = Double.parseDouble(coords[2]);
- String world = coords[3];
- World w = getServer().getWorld(world);
- Location loc = new Location(w, x, y, z);
- Tribute_seventeen.teleport(loc);
- Frozen.add(Tribute_seventeen);
- Tribute_seventeen.setFoodLevel(20);
- }
- if(Playing.size()>= 18){
- config.getString("Tribute_eighteen_spawn");
- String[] coords = config.getString("Tribute_eighteen_spawn").split(",");
- Player Tribute_eighteen = Playing.get(17);
- double x = Double.parseDouble(coords[0]);
- double y = Double.parseDouble(coords[1]);
- double z = Double.parseDouble(coords[2]);
- String world = coords[3];
- World w = getServer().getWorld(world);
- Location loc = new Location(w, x, y, z);
- Tribute_eighteen.teleport(loc);
- Frozen.add(Tribute_eighteen);
- Tribute_eighteen.setFoodLevel(20);
- }
- if(Playing.size()>= 19){
- config.getString("Tribute_nineteen_spawn");
- String[] coords = config.getString("Tribute_nineteen_spawn").split(",");
- Player Tribute_nineteen = Playing.get(18);
- double x = Double.parseDouble(coords[0]);
- double y = Double.parseDouble(coords[1]);
- double z = Double.parseDouble(coords[2]);
- String world = coords[3];
- World w = getServer().getWorld(world);
- Location loc = new Location(w, x, y, z);
- Tribute_nineteen.teleport(loc);
- Frozen.add(Tribute_nineteen);
- Tribute_nineteen.setFoodLevel(20);
- }
- if(Playing.size()>= 20){
- config.getString("Tribute_twenty_spawn");
- String[] coords = config.getString("Tribute_twenty_spawn").split(",");
- Player Tribute_twenty = Playing.get(19);
- double x = Double.parseDouble(coords[0]);
- double y = Double.parseDouble(coords[1]);
- double z = Double.parseDouble(coords[2]);
- String world = coords[3];
- World w = getServer().getWorld(world);
- Location loc = new Location(w, x, y, z);
- Tribute_twenty.teleport(loc);
- Frozen.add(Tribute_twenty);
- Tribute_twenty.setFoodLevel(20);
- }
- if(Playing.size()>= 21){
- config.getString("Tribute_twentyone_spawn");
- String[] coords = config.getString("Tribute_twentyone_spawn").split(",");
- Player Tribute_twentyone = Playing.get(20);
- double x = Double.parseDouble(coords[0]);
- double y = Double.parseDouble(coords[1]);
- double z = Double.parseDouble(coords[2]);
- String world = coords[3];
- World w = getServer().getWorld(world);
- Location loc = new Location(w, x, y, z);
- Tribute_twentyone.teleport(loc);
- Frozen.add(Tribute_twentyone);
- Tribute_twentyone.setFoodLevel(20);
- }
- if(Playing.size()>= 22){
- config.getString("Tribute_twentytwo_spawn");
- String[] coords = config.getString("Tribute_twentytwo_spawn").split(",");
- Player Tribute_twentytwo = Playing.get(21);
- double x = Double.parseDouble(coords[0]);
- double y = Double.parseDouble(coords[1]);
- double z = Double.parseDouble(coords[2]);
- String world = coords[3];
- World w = getServer().getWorld(world);
- Location loc = new Location(w, x, y, z);
- Tribute_twentytwo.teleport(loc);
- Frozen.add(Tribute_twentytwo);
- Tribute_twentytwo.setFoodLevel(20);
- }
- if(Playing.size()>= 23){
- config.getString("Tribute_twentythree_spawn");
- String[] coords = config.getString("Tribute_twentythree_spawn").split(",");
- Player Tribute_twentythree = Playing.get(22);
- double x = Double.parseDouble(coords[0]);
- double y = Double.parseDouble(coords[1]);
- double z = Double.parseDouble(coords[2]);
- String world = coords[3];
- World w = getServer().getWorld(world);
- Location loc = new Location(w, x, y, z);
- Tribute_twentythree.teleport(loc);
- Frozen.add(Tribute_twentythree);
- Tribute_twentythree.setFoodLevel(20);
- }
- if(Playing.size()>= 24){
- config.getString("Tribute_twentyfour_spawn");
- String[] coords = config.getString("Tribute_twentyfour_spawn").split(",");
- Player Tribute_twentyfour = Playing.get(23);
- double x = Double.parseDouble(coords[0]);
- double y = Double.parseDouble(coords[1]);
- double z = Double.parseDouble(coords[2]);
- String world = coords[3];
- World w = getServer().getWorld(world);
- Location loc = new Location(w, x, y, z);
- Tribute_twentyfour.teleport(loc);
- Frozen.add(Tribute_twentyfour);
- Tribute_twentyfour.setFoodLevel(20);
- }
- }
- }
- if(args[0].equalsIgnoreCase("Start")){
- String begin = config.getString("Start_Message");
- begin = begin.replaceAll("(&([a-f0-9]))", "\u00A7$2");
- final String msg = begin;
- if(p.hasPermission("HungerArena.Start")){
- if(config.getString("Countdown").equalsIgnoreCase("true")){
- getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
- public void run(){
- getServer().broadcastMessage("10");
- }
- }, 20L);
- getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
- public void run(){
- getServer().broadcastMessage("9");
- }
- }, 40L);
- getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
- public void run(){
- getServer().broadcastMessage("8");
- }
- }, 60L);
- getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
- public void run(){
- getServer().broadcastMessage("7");
- }
- }, 80L);
- getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
- public void run(){
- getServer().broadcastMessage("6");
- }
- }, 100L);
- getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
- public void run(){
- getServer().broadcastMessage("5");
- }
- }, 120L);
- getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
- public void run(){
- getServer().broadcastMessage("4");
- }
- }, 140L);
- getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
- public void run(){
- getServer().broadcastMessage("3");
- }
- }, 160L);
- getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
- public void run(){
- getServer().broadcastMessage("2");
- }
- }, 180L);
- getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
- public void run(){
- getServer().broadcastMessage("1");
- }
- }, 200L);
- getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
- public void run(){
- Frozen.clear();
- getServer().broadcastMessage(msg);
- canjoin = true;
- }
- }, 220L);
- }else{
- Frozen.clear();
- p.getServer().broadcastMessage(ChatColor.AQUA + "Let the Games Begin!!");
- canjoin = true;
- }
- }else{
- p.sendMessage(ChatColor.RED + "You don't have permission!");
- }
- }
- }
- if(cmd.getName().equalsIgnoreCase("StartPoint")){
- if(p.hasPermission("HungerArena.StartPoint")){
- if(args[0].equalsIgnoreCase("1")){
- double x = p.getLocation().getX();
- double y = p.getLocation().getY();
- double z = p.getLocation().getZ();
- String w = p.getWorld().getName();
- config.set("Tribute_one_spawn", x + "," + y + "," + z + "," + w);
- saveConfig();
- p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute one!");
- }
- if(args[0].equalsIgnoreCase("2")){
- double x = p.getLocation().getX();
- double y = p.getLocation().getY();
- double z = p.getLocation().getZ();
- String w = p.getWorld().getName();
- config.set("Tribute_two_spawn", x + "," + y + "," + z + "," + w);
- saveConfig();
- p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute two!");
- }
- if(args[0].equalsIgnoreCase("3")){
- double x = p.getLocation().getX();
- double y = p.getLocation().getY();
- double z = p.getLocation().getZ();
- String w = p.getWorld().getName();
- config.set("Tribute_three_spawn", x + "," + y + "," + z + "," + w);
- saveConfig();
- p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute three!");
- }
- if(args[0].equalsIgnoreCase("4")){
- double x = p.getLocation().getX();
- double y = p.getLocation().getY();
- double z = p.getLocation().getZ();
- String w = p.getWorld().getName();
- config.set("Tribute_four_spawn", x + "," + y + "," + z + "," + w);
- saveConfig();
- p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute four!");
- }
- if(args[0].equalsIgnoreCase("5")){
- double x = p.getLocation().getX();
- double y = p.getLocation().getY();
- double z = p.getLocation().getZ();
- String w = p.getWorld().getName();
- config.set("Tribute_five_spawn", x + "," + y + "," + z + "," + w);
- saveConfig();
- p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute five!");
- }
- if(args[0].equalsIgnoreCase("6")){
- double x = p.getLocation().getX();
- double y = p.getLocation().getY();
- double z = p.getLocation().getZ();
- String w = p.getWorld().getName();
- config.set("Tribute_six_spawn", x + "," + y + "," + z + "," + w);
- saveConfig();
- p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute six!");
- }
- if(args[0].equalsIgnoreCase("7")){
- double x = p.getLocation().getX();
- double y = p.getLocation().getY();
- double z = p.getLocation().getZ();
- String w = p.getWorld().getName();
- config.set("Tribute_seven_spawn", x + "," + y + "," + z + "," + w);
- saveConfig();
- p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute seven!");
- }
- if(args[0].equalsIgnoreCase("8")){
- double x = p.getLocation().getX();
- double y = p.getLocation().getY();
- double z = p.getLocation().getZ();
- String w = p.getWorld().getName();
- config.set("Tribute_eight_spawn", x + "," + y + "," + z + "," + w);
- saveConfig();
- p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute eight!");
- }
- if(args[0].equalsIgnoreCase("9")){
- double x = p.getLocation().getX();
- double y = p.getLocation().getY();
- double z = p.getLocation().getZ();
- String w = p.getWorld().getName();
- config.set("Tribute_nine_spawn", x + "," + y + "," + z + "," + w);
- saveConfig();
- p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute nine!");
- }
- if(args[0].equalsIgnoreCase("10")){
- double x = p.getLocation().getX();
- double y = p.getLocation().getY();
- double z = p.getLocation().getZ();
- String w = p.getWorld().getName();
- config.set("Tribute_ten_spawn", x + "," + y + "," + z + "," + w);
- saveConfig();
- p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute ten!");
- }
- if(args[0].equalsIgnoreCase("11")){
- double x = p.getLocation().getX();
- double y = p.getLocation().getY();
- double z = p.getLocation().getZ();
- String w = p.getWorld().getName();
- config.set("Tribute_eleven_spawn", x + "," + y + "," + z + "," + w);
- saveConfig();
- p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute eleven!");
- }
- if(args[0].equalsIgnoreCase("12")){
- double x = p.getLocation().getX();
- double y = p.getLocation().getY();
- double z = p.getLocation().getZ();
- String w = p.getWorld().getName();
- config.set("Tribute_twelve_spawn", x + "," + y + "," + z + "," + w);
- saveConfig();
- p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute twelve!");
- }
- if(args[0].equalsIgnoreCase("13")){
- double x = p.getLocation().getX();
- double y = p.getLocation().getY();
- double z = p.getLocation().getZ();
- String w = p.getWorld().getName();
- config.set("Tribute_thirteen_spawn", x + "," + y + "," + z + "," + w);
- saveConfig();
- p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute thirteen!");
- }
- if(args[0].equalsIgnoreCase("14")){
- double x = p.getLocation().getX();
- double y = p.getLocation().getY();
- double z = p.getLocation().getZ();
- String w = p.getWorld().getName();
- config.set("Tribute_fourteen_spawn", x + "," + y + "," + z + "," + w);
- saveConfig();
- p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute fourteen!");
- }
- if(args[0].equalsIgnoreCase("15")){
- double x = p.getLocation().getX();
- double y = p.getLocation().getY();
- double z = p.getLocation().getZ();
- String w = p.getWorld().getName();
- config.set("Tribute_fifteen_spawn", x + "," + y + "," + z + "," + w);
- saveConfig();
- p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute fifteen!");
- }
- if(args[0].equalsIgnoreCase("16")){
- double x = p.getLocation().getX();
- double y = p.getLocation().getY();
- double z = p.getLocation().getZ();
- String w = p.getWorld().getName();
- config.set("Tribute_sixteen_spawn", x + "," + y + "," + z + "," + w);
- saveConfig();
- p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute sixteen!");
- }
- if(args[0].equalsIgnoreCase("17")){
- double x = p.getLocation().getX();
- double y = p.getLocation().getY();
- double z = p.getLocation().getZ();
- String w = p.getWorld().getName();
- config.set("Tribute_seventeen_spawn", x + "," + y + "," + z + "," + w);
- saveConfig();
- p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute seventeen!");
- }
- if(args[0].equalsIgnoreCase("18")){
- double x = p.getLocation().getX();
- double y = p.getLocation().getY();
- double z = p.getLocation().getZ();
- String w = p.getWorld().getName();
- config.set("Tribute_eighteen_spawn", x + "," + y + "," + z + "," + w);
- saveConfig();
- p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute eighteen!");
- }
- if(args[0].equalsIgnoreCase("19")){
- double x = p.getLocation().getX();
- double y = p.getLocation().getY();
- double z = p.getLocation().getZ();
- String w = p.getWorld().getName();
- config.set("Tribute_nineteen_spawn", x + "," + y + "," + z + "," + w);
- saveConfig();
- p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute nineteen!");
- }
- if(args[0].equalsIgnoreCase("20")){
- double x = p.getLocation().getX();
- double y = p.getLocation().getY();
- double z = p.getLocation().getZ();
- String w = p.getWorld().getName();
- config.set("Tribute_twenty_spawn", x + "," + y + "," + z + "," + w);
- saveConfig();
- p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute twenty!");
- }
- if(args[0].equalsIgnoreCase("21")){
- double x = p.getLocation().getX();
- double y = p.getLocation().getY();
- double z = p.getLocation().getZ();
- String w = p.getWorld().getName();
- config.set("Tribute_twentyone_spawn", x + "," + y + "," + z + "," + w);
- saveConfig();
- p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute twentyone!");
- }
- if(args[0].equalsIgnoreCase("22")){
- double x = p.getLocation().getX();
- double y = p.getLocation().getY();
- double z = p.getLocation().getZ();
- String w = p.getWorld().getName();
- config.set("Tribute_twentytwo_spawn", x + "," + y + "," + z + "," + w);
- saveConfig();
- p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute twentytwo!");
- }
- if(args[0].equalsIgnoreCase("23")){
- double x = p.getLocation().getX();
- double y = p.getLocation().getY();
- double z = p.getLocation().getZ();
- String w = p.getWorld().getName();
- config.set("Tribute_twentythree_spawn", x + "," + y + "," + z + "," + w);
- saveConfig();
- p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute twentythree!");
- }
- if(args[0].equalsIgnoreCase("24")){
- double x = p.getLocation().getX();
- double y = p.getLocation().getY();
- double z = p.getLocation().getZ();
- String w = p.getWorld().getName();
- config.set("Tribute_twentyfour_spawn", x + "," + y + "," + z + "," + w);
- saveConfig();
- p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute twentyfour!");
- }
- }else{
- p.sendMessage(ChatColor.RED + "You don't have permission!");
- }
- }
- return true;
- }
-}
-class DeadListener implements Listener{
- public Main plugin;
- public DeadListener(Main m){
- this.plugin = m;
- }
- @EventHandler
- public void onPlayerMove(PlayerMoveEvent event){
- Player p = event.getPlayer();
- if(plugin.Frozen.contains(p) && plugin.config.getString("Frozen_Teleport").equalsIgnoreCase("True")){
- event.setCancelled(true);
- }
- }
- @EventHandler
- public void onPlayerRespawn(PlayerRespawnEvent event){
- Player p = event.getPlayer();
- if(plugin.Dead.contains(p)){
- String[] Spawncoords = plugin.config.getString("Spawn_coords").split(",");
- World spawnw = p.getWorld();
- double spawnx = Double.parseDouble(Spawncoords[0]);
- double spawny = Double.parseDouble(Spawncoords[1]);
- double spawnz = Double.parseDouble(Spawncoords[2]);
- Location Spawn = new Location(spawnw, spawnx, spawny, spawnz);
- event.setRespawnLocation(Spawn);
- }
- }
- @EventHandler
- public void onPlayerDeath(PlayerDeathEvent event){
- Player p = event.getEntity();
- Server s = p.getServer();
- String pname = p.getName();
- if(plugin.Playing.contains(p)){
- if(plugin.config.getString("Cannon_Death").equalsIgnoreCase("True")){
- p.getWorld().playEffect(p.getLocation(), Effect.ZOMBIE_CHEW_WOODEN_DOOR, 0, 300);
- }
- plugin.Dead.add(p);
- plugin.Playing.remove(p);
- String leftmsg = ChatColor.BLUE + "There are now " + plugin.Playing.size() + " tributes left!";
- if(p.getKiller() instanceof Player){
- if(p.getKiller().getItemInHand().getType().getId()== 0){
- Player killer = p.getKiller();
- String killername = killer.getName();
- event.setDeathMessage("");
- s.broadcastMessage(ChatColor.LIGHT_PURPLE + "**BOOM** Tribute " + pname + " was killed by tribute " + killername + " with their FIST!");
- s.broadcastMessage(leftmsg);
- if(plugin.Playing.size()== 1){
- for(Player winner:plugin.Playing){
- String winnername = winner.getName();
- s.broadcastMessage(ChatColor.GREEN + winnername + " is the victor of this Hunger Games!");
- winner.getInventory().clear();
- winner.getInventory().setBoots(null);
- winner.getInventory().setChestplate(null);
- winner.getInventory().setHelmet(null);
- winner.getInventory().setLeggings(null);
- winner.getInventory().addItem(plugin.Reward);
- }
- for(Player spectator:plugin.Watching){
- spectator.setAllowFlight(false);
- }
- if(plugin.config.getString("Auto_Restart").equalsIgnoreCase("True")){
- plugin.Dead.clear();
- plugin.Playing.clear();
- plugin.Quit.clear();
- plugin.Watching.clear();
- plugin.Frozen.clear();
- plugin.canjoin = false;
- }
- }
- }else{
- Player killer = p.getKiller();
- String killername = killer.getName();
- Material weapon = killer.getItemInHand().getType();
- String msg = ChatColor.LIGHT_PURPLE + "**BOOM** Tribute " + pname + " was killed by tribute " + killername + " with a(n) " + weapon;
- event.setDeathMessage("");
- s.broadcastMessage(msg);
- s.broadcastMessage(leftmsg);
- if(plugin.Playing.size()== 1){
- for(Player winner:plugin.Playing){
- String winnername = winner.getName();
- s.broadcastMessage(ChatColor.GREEN + winnername + " is the victor of this Hunger Games!");
- winner.getInventory().clear();
- winner.getInventory().setBoots(null);
- winner.getInventory().setChestplate(null);
- winner.getInventory().setHelmet(null);
- winner.getInventory().setLeggings(null);
- winner.getInventory().addItem(plugin.Reward);
- }
- for(Player spectator:plugin.Watching){
- spectator.setAllowFlight(false);
- }
- if(plugin.config.getString("Auto_Restart").equalsIgnoreCase("True")){
- plugin.Dead.clear();
- plugin.Playing.clear();
- plugin.Quit.clear();
- plugin.Watching.clear();
- plugin.Frozen.clear();
- plugin.canjoin = false;
- }
- }
- }
- }else{
- event.setDeathMessage("");
- s.broadcastMessage(ChatColor.LIGHT_PURPLE + pname + " died of natural causes!");
- s.broadcastMessage(leftmsg);
- if(plugin.Playing.size()== 1){
- for(Player winner:plugin.Playing){
- String winnername = winner.getName();
- s.broadcastMessage(ChatColor.GREEN + winnername + " is the victor of this Hunger Games!");
- winner.getInventory().clear();
- winner.getInventory().setBoots(null);
- winner.getInventory().setChestplate(null);
- winner.getInventory().setHelmet(null);
- winner.getInventory().setLeggings(null);
- winner.getInventory().addItem(plugin.Reward);
- }
- for(Player spectator:plugin.Watching){
- spectator.setAllowFlight(false);
- }
- if(plugin.config.getString("Auto_Restart").equalsIgnoreCase("True")){
- plugin.Dead.clear();
- plugin.Playing.clear();
- plugin.Quit.clear();
- plugin.Watching.clear();
- plugin.Frozen.clear();
- plugin.canjoin = false;
- }
- }
- }
- }
- if(plugin.Watching.contains(p)){
- for(Player online:plugin.getServer().getOnlinePlayers())
- online.showPlayer(p);
- }
- }
- @EventHandler
- public void onPlayerJoin(PlayerJoinEvent event){
- Player p = event.getPlayer();
- final Player player = event.getPlayer();
- if(plugin.Watching.contains(p)){
- p.setAllowFlight(true);
- p.setFlying(true);
- for(Player everyone:plugin.getServer().getOnlinePlayers()){
- everyone.hidePlayer(p);
- }
- }
- if(plugin.Out.contains(p)){
- plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
- public void run(){
- player.sendMessage(ChatColor.AQUA + "You have saved yourself from being ejected from the arena!");
- }
- }, 40L);
- plugin.Out.remove(p);
- }
- if(plugin.Quit.contains(p) || plugin.Dead.contains(p)){
- String[] Spawncoords = plugin.config.getString("Spawn_coords").split(",");
- String w = Spawncoords[3];
- World spawnw = plugin.getServer().getWorld(w);
- double spawnx = Double.parseDouble(Spawncoords[0]);
- double spawny = Double.parseDouble(Spawncoords[1]);
- double spawnz = Double.parseDouble(Spawncoords[2]);
- final Location Spawn = new Location(spawnw, spawnx, spawny, spawnz);
- plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
- public void run(){
- player.teleport(Spawn);
- player.sendMessage(ChatColor.RED + "You have been teleported to spawn because you quit/forfieted!");
- }
- }, 40L);
- }
- }
- @EventHandler
- public void onPlayerQuit(PlayerQuitEvent event){
- final Player p = event.getPlayer();
- String[] Spawncoords = plugin.config.getString("Spawn_coords").split(",");
- String w = Spawncoords[3];
- World spawnw = plugin.getServer().getWorld(w);
- double spawnx = Double.parseDouble(Spawncoords[0]);
- double spawny = Double.parseDouble(Spawncoords[1]);
- double spawnz = Double.parseDouble(Spawncoords[2]);
- final Location Spawn = new Location(spawnw, spawnx, spawny, spawnz);
- if(plugin.Playing.contains(p)){
- if(plugin.Playing.size()== 1){
-
- }
- plugin.Out.add(p);
- }
- if(plugin.Watching.contains(p)){
- System.out.println(p.getName() + " testing");
- }
- plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
- public void run(){
- if(plugin.Playing.contains(p) && plugin.Out.contains(p)){
- if(plugin.canjoin== true){
- plugin.Playing.remove(p);
- plugin.Quit.add(p);
- plugin.Out.remove(p);
- if(plugin.Playing.size()== 1){
- for(Player winner:plugin.Playing){
- String winnername = winner.getName();
- p.getServer().broadcastMessage(ChatColor.GREEN + winnername + " is the victor of this Hunger Games!");
- winner.getInventory().clear();
- winner.getInventory().setBoots(null);
- winner.getInventory().setChestplate(null);
- winner.getInventory().setHelmet(null);
- winner.getInventory().setLeggings(null);
- winner.getInventory().addItem(plugin.Reward);
- }
- for(Player spectator:plugin.Watching){
- spectator.setAllowFlight(false);
- spectator.teleport(Spawn);
- }
- if(plugin.config.getString("Auto_Restart").equalsIgnoreCase("True")){
- plugin.Dead.clear();
- plugin.Playing.clear();
- plugin.Quit.clear();
- plugin.Watching.clear();
- plugin.Frozen.clear();
- plugin.canjoin = false;
- }
- }
- }else if(plugin.canjoin== false){
- plugin.Playing.remove(p);
- plugin.Quit.add(p);
- plugin.Out.remove(p);
- }
- }
- }
- }, 1200L);
- }
- @EventHandler
- public void BreakBlock(BlockBreakEvent event){
- Player p = event.getPlayer();
- if(plugin.Playing.contains(p)){
- if(plugin.config.getString("Protected_Arena").equalsIgnoreCase("True")){
- event.setCancelled(true);
- p.sendMessage(ChatColor.RED + "You can't break blocks when you're playing!");
- }
- }
- if(plugin.Watching.contains(p)){
- event.setCancelled(true);
- p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
- }
- }
- @EventHandler
- public void TributeChat(PlayerChatEvent event){
- Player p = event.getPlayer();
- if(plugin.Playing.contains(p)){
- String msg = "<" + ChatColor.RED + "[Tribute] " + ChatColor.WHITE + p.getName() + ">" + " " + event.getMessage();
- if(plugin.config.getString("ChatClose").equalsIgnoreCase("True")){
- double radius = plugin.config.getDouble("ChatClose_Radius");
- List near = p.getNearbyEntities(radius, radius, radius);
- event.setCancelled(true);
- if(near.size()== 0){
- p.sendMessage(msg);
- p.sendMessage(ChatColor.YELLOW + "No one near!");
- }else if(!(near.size()== 0)){
- for(Entity en:near){
- if(!(en instanceof Player)){
- p.sendMessage(msg);
- p.sendMessage(ChatColor.YELLOW + "No one near!");
- }
- }
- }else{
- for(Entity e:near){
- if(e instanceof Player){
- ((Player) e).sendMessage(msg);
- }
- }
- }
- }else{
- plugin.getServer().broadcastMessage(msg);
- }
- }
- }
- @EventHandler
- public void PvP(EntityDamageByEntityEvent event){
- Entity p = event.getEntity();
- Entity offense = event.getDamager();
- if(p instanceof Player){
- if(plugin.Playing.contains(p) && plugin.canjoin== false){
- event.setCancelled(true);
- }
- }
- if(offense instanceof Player){
- Player Attacker = (Player) event.getDamager();
- if(plugin.Watching.contains(Attacker)){
- event.setCancelled(true);
- Attacker.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
- }
- }else if(event.getDamager() instanceof Projectile){
- Projectile arrow = (Projectile) offense;
- if(arrow.getShooter() instanceof Player){
- Player BowMan = (Player) arrow.getShooter();
- if(plugin.Watching.contains(BowMan)){
- event.setCancelled(true);
- BowMan.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
- }
- }
- }
- }
- @EventHandler
- public void SpectatorDrops(PlayerDropItemEvent event){
- Player p = event.getPlayer();
- if(plugin.Watching.contains(p)){
- event.setCancelled(true);
- p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
- }
- }
- @EventHandler
- public void SpectatorInteractions(PlayerInteractEvent event){
- Player p = event.getPlayer();
- if(plugin.Watching.contains(p)){
- event.setCancelled(true);
- p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
- }
- }
- @EventHandler
- public void SpectatorItems(PlayerPickupItemEvent event){
- Player p = event.getPlayer();
- if(plugin.Watching.contains(p)){
- event.setCancelled(true);
- p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
- }
- }
- @EventHandler
- public void ChestSaves(PlayerInteractEvent event){
- Block block = event.getClickedBlock();
- Player p = event.getPlayer();
- //currently crashes the server when refilling....
- //Kinda glitchy through all here...
- if(p.getItemInHand().getType()== Material.BLAZE_ROD && event.getAction() == Action.LEFT_CLICK_BLOCK){
- if(block.getState() instanceof Chest){
- ItemStack[] itemsinchest = ((Chest) block.getState()).getInventory().getContents();
- int blockx = block.getX();
- int blocky = block.getY();
- int blockz = block.getZ();
- String blockw = block.getWorld().getName().toString();
- if(!plugin.getConfig().contains("Storage." + blockx + "," + blocky + "," + blockz + ".Location.X")){
- plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.X", blockx);
- plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Y", blocky);
- plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Z",blockz);
- plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.W", blockw);
- plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".ItemsInStorage", itemsinchest);
- }else{
- plugin.getConfig().set("Storage." + blockx + "," + blocky+ "," + blockz + ".Location.X",blockx);
- plugin.getConfig().set("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Y", blocky);
- plugin.getConfig().set("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Z", blockz);
- plugin.getConfig().set("Storage." + blockx + "," + blocky + "," + blockz + ".Location.W", blockw);
- plugin.getConfig().set("Storage." + blockx + "," + blocky + "," + blockz + ".ItemsInStorage", itemsinchest);
- }
- List list2 = plugin.getConfig().getStringList("StorageXYZ");
- list2.add(blockx + "," + blocky + "," + blockz);
- plugin.getConfig().set("StorageXYZ", list2);
- plugin.getConfig().options().copyDefaults(true);
- plugin.saveConfig();
- }
- }
- }*/
}
diff --git a/src/me/Travja/HungerArena/SpectatorListener.java b/src/me/Travja/HungerArena/SpectatorListener.java
index 679b30e..3d2dc7f 100644
--- a/src/me/Travja/HungerArena/SpectatorListener.java
+++ b/src/me/Travja/HungerArena/SpectatorListener.java
@@ -15,7 +15,6 @@ import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
-import org.bukkit.event.player.PlayerQuitEvent;
public class SpectatorListener implements Listener {
public Main plugin;
@@ -87,7 +86,6 @@ public class SpectatorListener implements Listener {
double spawny = Double.parseDouble(Spawncoords[1]);
double spawnz = Double.parseDouble(Spawncoords[2]);
final Location Spawn = new Location(spawnw, spawnx, spawny, spawnz);
- plugin.Watching.remove(p);
for(Player everyone:plugin.getServer().getOnlinePlayers()){
everyone.showPlayer(p);
}
@@ -97,6 +95,7 @@ public class SpectatorListener implements Listener {
player.sendMessage(ChatColor.RED + "You have been teleported to spawn because the game is over!");
}
}, 40L);
+ plugin.Watching.remove(p);
}else{
p.setAllowFlight(true);
p.setFlying(true);
@@ -107,13 +106,6 @@ public class SpectatorListener implements Listener {
}
}
@EventHandler
- public void SpectatorQuit(PlayerQuitEvent event){
- Player p = event.getPlayer();
- if(plugin.Watching.contains(p)){
- System.out.println(p.getName() + " quit while spectating!");
- }
- }
- @EventHandler
public void MobNerf(EntityTargetEvent event){
Entity target = event.getTarget();
if(target instanceof Player){