From 4696c01a3577b9e7d33c1fcdae4e6e50ad6e4809 Mon Sep 17 00:00:00 2001 From: Jeppa Date: Wed, 20 Mar 2013 17:51:59 +0100 Subject: [PATCH] Bugfixes ! merged routines, fixed "Protect_Always", added possibility for full Protection when noone is playing... Fixed autorestart, added configurable countdown. reload command : fixed multiple listeners restart command : fixed reopen, merged routines, added respawn close command: fixed for multiple arenas and merged routines. open command: small textfix fix for whitelisted commands (can be used now...) --- src/me/travja/hungerarena/BlockStorage.java | 402 ----- src/me/travja/hungerarena/CommandBlock.java | 149 -- src/me/travja/hungerarena/HaCommands.java | 1558 ------------------- src/me/travja/hungerarena/Main.java | 511 ------ 4 files changed, 2620 deletions(-) delete mode 100644 src/me/travja/hungerarena/BlockStorage.java delete mode 100644 src/me/travja/hungerarena/CommandBlock.java delete mode 100644 src/me/travja/hungerarena/HaCommands.java delete mode 100644 src/me/travja/hungerarena/Main.java diff --git a/src/me/travja/hungerarena/BlockStorage.java b/src/me/travja/hungerarena/BlockStorage.java deleted file mode 100644 index 1ce0492..0000000 --- a/src/me/travja/hungerarena/BlockStorage.java +++ /dev/null @@ -1,402 +0,0 @@ -package me.Travja.HungerArena; - -import java.util.List; - -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -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.BlockPlaceEvent; -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(priority = EventPriority.MONITOR) - public void BlockBreak(BlockBreakEvent event){ - Block b = event.getBlock(); - Player p = event.getPlayer(); - String pname = p.getName(); - if(plugin.getArena(p)!= null){ - int a = plugin.getArena(p); - if(!event.isCancelled()){ - if(plugin.Playing.get(a).contains(pname)){ - if(plugin.config.getString("Protected_Arena").equalsIgnoreCase("True")){ - p.sendMessage(ChatColor.RED + "You can't break blocks while playing!"); - } - if(plugin.canjoin.get(a)){ - if(plugin.config.getStringList("worlds").isEmpty() || (!plugin.config.getStringList("worlds").isEmpty() && plugin.config.getStringList("worlds").contains(p.getWorld().getName()))){ - if(!plugin.management.getBoolean("blocks.useWhitelistAsBlacklist")){ - if(!plugin.management.getIntegerList("blocks.whitelist").isEmpty()){ - if(!plugin.management.getIntegerList("blocks.whitelist").contains(b.getTypeId())){ - event.setCancelled(true); - p.sendMessage(ChatColor.RED + "That is an illegal block!"); - }else if(plugin.management.getIntegerList("blocks.whitelist").contains(b.getTypeId())){ - String w = b.getWorld().getName(); - int x = b.getX(); - int y = b.getY(); - int z = b.getZ(); - int d = b.getTypeId(); - byte m = b.getData(); - String coords = w + "," + x + "," + y + "," + z + "," + d + "," + m + "," + a; - List blocks = plugin.data.getStringList("Blocks_Destroyed"); - if(!plugin.data.getStringList("Blocks_Placed").contains(w + "," + x + "," + y + "," + z + "," + a)){ - blocks.add(coords); - plugin.data.set("Blocks_Destroyed", blocks); - plugin.saveData(); - } - } - }else{ - event.setCancelled(true); - p.sendMessage(ChatColor.RED + "That is an illegal block!"); - } - }else{ - if(!plugin.management.getIntegerList("blocks.whitelist").isEmpty()){ - if(!plugin.management.getIntegerList("blocks.whitelist").contains(b.getTypeId())){ - String w = b.getWorld().getName(); - int x = b.getX(); - int y = b.getY(); - int z = b.getZ(); - int d = b.getTypeId(); - byte m = b.getData(); - String coords = w + "," + x + "," + y + "," + z + "," + d + "," + m + "," + a; - List blocks = plugin.data.getStringList("Blocks_Destroyed"); - if(!plugin.data.getStringList("Blocks_Placed").contains(w + "," + x + "," + y + "," + z + "," + a)){ - blocks.add(coords); - plugin.data.set("Blocks_Destroyed", blocks); - plugin.saveData(); - } - }else if(plugin.management.getIntegerList("blocks.whitelist").contains(b.getTypeId())){ - event.setCancelled(true); - p.sendMessage(ChatColor.RED + "That is an illegal block"); - } - }else{ - String w = b.getWorld().getName(); - int x = b.getX(); - int y = b.getY(); - int z = b.getZ(); - int d = b.getTypeId(); - byte m = b.getData(); - String coords = w + "," + x + "," + y + "," + z + "," + d + "," + m + "," + a; - List blocks = plugin.data.getStringList("Blocks_Destroyed"); - if(!plugin.data.getStringList("Blocks_Placed").contains(w + "," + x + "," + y + "," + z + "," + a)){ - blocks.add(coords); - plugin.data.set("Blocks_Destroyed", blocks); - plugin.saveData(); - } - } - } - } - } - } - } - } - } - @EventHandler(priority = EventPriority.MONITOR) - public void Explosion(EntityExplodeEvent event){ - List blocksd = event.blockList(); - Entity e = event.getEntity(); - int i = 0; - if(!event.isCancelled()){ - for(i = 1; i <= plugin.canjoin.size(); i++){ - if(plugin.canjoin.get(i)){ - i = plugin.canjoin.size()+1; - if(plugin.config.getStringList("worlds").isEmpty() || (!plugin.config.getStringList("worlds").isEmpty() && plugin.config.getStringList("worlds").contains(event.getEntity().getWorld().getName()))){ - if(e.getType()== EntityType.PRIMED_TNT){ - if(!plugin.data.getStringList("Blocks_Placed").contains(e.getLocation().getWorld() + "," + e.getLocation().getX() + "," + e.getLocation().getY() + "," + e.getLocation().getZ()) /*|| !plugin.data.getStringList("Blocks_Destroyed").contains(e.getLocation().getWorld() + "," + e.getLocation().getX() + "," + e.getLocation().getY() + "," + e.getLocation().getZ())*/){ - List blocks = plugin.data.getStringList("Blocks_Destroyed"); - blocks.add(e.getLocation().getWorld().getName() + "," + e.getLocation().getX() + "," + e.getLocation().getY() + "," + e.getLocation().getZ() + ",46" + ",0"); - plugin.data.set("Blocks_Destroyed", blocks); - plugin.saveData(); - } - } - for(Block b:blocksd){ - String w = event.getEntity().getWorld().getName(); - int x = b.getX(); - int y = b.getY(); - int z = b.getZ(); - int d = b.getTypeId(); - byte m = b.getData(); - String coords = w + "," + x + "," + y + "," + z + "," + d + "," + m + "," + i; - List blocks = plugin.data.getStringList("Blocks_Destroyed"); - if(!plugin.data.getStringList("Blocks_Placed").contains(w + "," + x + "," + y + "," + z + "," + i) || !plugin.data.getStringList("Blocks_Destroyed").contains(w + "," + x + "," + y + "," + z + "," + i)){ - blocks.add(coords); - plugin.data.set("Blocks_Destroyed", blocks); - plugin.saveData(); - } - } - } - } - } - } - } - @EventHandler(priority = EventPriority.MONITOR) - public void burningBlocks(BlockBurnEvent event){ - Block b = event.getBlock(); - int i = 0; - if(!event.isCancelled()){ - for(i = 1; i <= plugin.canjoin.size(); i++){ - if(plugin.canjoin.get(i)){ - i = plugin.canjoin.size()+1; - if(plugin.config.getStringList("worlds").isEmpty() || (!plugin.config.getStringList("worlds").isEmpty() && plugin.config.getStringList("worlds").contains(b.getWorld().getName()))){ - String w = b.getWorld().getName(); - int x = b.getX(); - int y = b.getY(); - int z = b.getZ(); - int d = b.getTypeId(); - byte m = b.getData(); - String coords = w + "," + x + "," + y + "," + z + "," + d + "," + m + "," + i; - List blocks = plugin.data.getStringList("Blocks_Destroyed"); - if(!plugin.data.getStringList("Blocks_Placed").contains(w + "," + x + "," + y + "," + z + "," + i)){ - blocks.add(coords); - plugin.data.set("Blocks_Destroyed", blocks); - plugin.saveData(); - } - } - } - } - } - } - @EventHandler(priority = EventPriority.MONITOR) - public void blockPlace(BlockPlaceEvent event){ - Block b = event.getBlock(); - Player p = event.getPlayer(); - if(plugin.getArena(p)!= null){ - int a = plugin.getArena(p); - if(!event.isCancelled()){ - if(plugin.Playing.get(a).contains(p.getName())){ - if(plugin.canjoin.get(a)){ - if(plugin.config.getStringList("worlds").isEmpty() || (!plugin.config.getStringList("worlds").isEmpty() && plugin.config.getStringList("worlds").contains(b.getWorld().getName()))){ - if((b.getType()== Material.SAND || b.getType()== Material.GRAVEL) && (b.getRelative(BlockFace.DOWN).getType()== Material.AIR || b.getRelative(BlockFace.DOWN).getType()== Material.WATER || b.getRelative(BlockFace.DOWN).getType()== Material.LAVA)){ - int n = b.getY() -1; - while(b.getWorld().getBlockAt(b.getX(), n, b.getZ()).getType()== Material.AIR || b.getWorld().getBlockAt(b.getX(), n, b.getZ()).getType()== Material.WATER || b.getWorld().getBlockAt(b.getX(), n, b.getZ()).getType()== Material.LAVA){ - n = n -1; - event.getPlayer().sendMessage(b.getWorld().getBlockAt(b.getX(), n, b.getZ()).getType().toString().toLowerCase()); - if(b.getWorld().getBlockAt(b.getX(), n, b.getZ()).getType()!= Material.AIR || b.getWorld().getBlockAt(b.getX(), n, b.getZ()).getType()!= Material.WATER || b.getWorld().getBlockAt(b.getX(), n, b.getZ()).getType()!= Material.LAVA){ - int l = n +1; - Block br = b.getWorld().getBlockAt(b.getX(), l, b.getZ()); - String w = br.getWorld().getName(); - int x = br.getX(); - int y = br.getY(); - int z = br.getZ(); - String coords = w + "," + x + "," + y + "," + z + "," + a; - p.sendMessage(ChatColor.GREEN + "Sand/Gravel will land at " + coords); - List blocks = plugin.data.getStringList("Blocks_Placed"); - blocks.add(coords); - plugin.data.set("Blocks_Placed", blocks); - plugin.saveData(); - } - } - }else{ - if(b.getType()!= Material.SAND || b.getType()!= Material.GRAVEL){ - String w = b.getWorld().getName(); - int x = b.getX(); - int y = b.getY(); - int z = b.getZ(); - String coords = w + "," + x + "," + y + "," + z + "," + a; - List blocks = plugin.data.getStringList("Blocks_Placed"); - blocks.add(coords); - plugin.data.set("Blocks_Placed", blocks); - plugin.saveData(); - } - } - } - } - } - } - } - } - @EventHandler(priority = EventPriority.MONITOR) - public void bucketEmpty(PlayerBucketEmptyEvent event){ - if(plugin.getArena(event.getPlayer())!= null){ - int a = plugin.getArena(event.getPlayer()); - if(!event.isCancelled()){ - if(plugin.canjoin.get(a)){ - if(plugin.Playing.get(a).contains(event.getPlayer().getName())){ - if(plugin.config.getStringList("worlds").isEmpty() || (!plugin.config.getStringList("worlds").isEmpty() && plugin.config.getStringList("worlds").contains(event.getPlayer().getWorld().getName()))){ - Block b = event.getBlockClicked().getRelative(event.getBlockFace()); - String w = b.getWorld().getName(); - int x = b.getX(); - int y = b.getY(); - int z = b.getZ(); - String coords = w + "," + x + "," + y + "," + z + "," + a; - List blocks = plugin.data.getStringList("Blocks_Placed"); - blocks.add(coords); - plugin.data.set("Blocks_Placed", blocks); - plugin.saveData(); - } - } - } - } - } - } - @EventHandler(priority = EventPriority.MONITOR) - public void bucketFill(PlayerBucketFillEvent event){ - if(plugin.getArena(event.getPlayer())!= null){ - int a = plugin.getArena(event.getPlayer()); - if(!event.isCancelled()){ - if(plugin.canjoin.get(a)){ - if(plugin.Playing.get(a).contains(event.getPlayer().getName())){ - if(plugin.config.getStringList("worlds").isEmpty() || (!plugin.config.getStringList("worlds").isEmpty() && plugin.config.getStringList("worlds").contains(event.getPlayer().getWorld().getName()))){ - Block b = event.getBlockClicked().getRelative(event.getBlockFace()); - String w = b.getWorld().getName(); - int x = b.getX(); - int y = b.getY(); - int z = b.getZ(); - int d = b.getTypeId(); - byte m = b.getData(); - String coords = w + "," + x + "," + y + "," + z + "," + d + "," + m + "," + a; - List blocks = plugin.data.getStringList("Blocks_Destroyed"); - if(!plugin.data.getStringList("Blocks_Placed").contains(w + "," + x + "," + y + "," + z + "," + a)){ - blocks.add(coords); - plugin.data.set("Blocks_Destroyed", blocks); - plugin.saveData(); - } - } - } - } - } - } - } - @EventHandler(priority = EventPriority.MONITOR) - public void blockMelt(BlockFadeEvent event){ - int i = 0; - if(!event.isCancelled()){ - for(i = 1; i <= plugin.canjoin.size(); i++){ - if(plugin.canjoin.get(i)){ - if(plugin.config.getStringList("worlds").isEmpty() || (!plugin.config.getStringList("worlds").isEmpty() && plugin.config.getStringList("worlds").contains(event.getBlock().getWorld().getName()))){ - i = plugin.canjoin.size()+1; - 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(); - byte m = b.getData(); - String coords = w + "," + x + "," + y + "," + z + "," + d + "," + m + "," + i; - List blocks = plugin.data.getStringList("Blocks_Destroyed"); - if(!plugin.data.getStringList("Blocks_Placed").contains(w + "," + x + "," + y + "," + z + "," + i)){ - blocks.add(coords); - plugin.data.set("Blocks_Destroyed", blocks); - plugin.saveData(); - } - } - } - } - } - } - /*@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.data.getStringList("Blocks_Placed"); - blocks.add(coords); - plugin.data.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.data.getStringList("Blocks_Placed"); - blocks.add(coords); - plugin.data.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.data.getStringList("Blocks_Destroyed"); - blocks.add(coords); - plugin.data.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.data.getStringList("Blocks_Placed"); - blocks.add(coords); - plugin.data.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.data.getStringList("Blocks_Placed"); - blocks.add(coords); - plugin.data.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.data.getStringList("Blocks_Placed"); - blocks.add(coords); - plugin.data.set("Blocks_Destroyed", blocks); - plugin.saveConfig(); - } - } - }*/ -} \ No newline at end of file diff --git a/src/me/travja/hungerarena/CommandBlock.java b/src/me/travja/hungerarena/CommandBlock.java deleted file mode 100644 index fdb28de..0000000 --- a/src/me/travja/hungerarena/CommandBlock.java +++ /dev/null @@ -1,149 +0,0 @@ -package me.Travja.HungerArena; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; - -public class CommandBlock implements Listener { - public Main plugin; - public CommandBlock(Main m) { - this.plugin = m; - } - @EventHandler(priority = EventPriority.MONITOR) - public void CatchCommand(PlayerCommandPreprocessEvent event){ - String cmd = event.getMessage(); - Player p = event.getPlayer(); - String pname = p.getName(); - int i = 0; - int x = 0; - for(x = 1; x < plugin.Watching.size(); x++){ - if(plugin.Watching.get(x).contains(p.getName())){ - if(!p.hasPermission("HungerArena.UseCommands")){ - if(!plugin.management.getStringList("commands.whitelist").isEmpty()){ - for(String whitelist: plugin.management.getStringList("commands.whitelist")){ - i = i+1; - if(i== plugin.management.getStringList("commands.whitelist").size()){ - if(!cmd.toLowerCase().startsWith(whitelist.toLowerCase()) || !cmd.toLowerCase().startsWith("/ha")){ - event.setCancelled(true); - p.sendMessage(ChatColor.RED + "You are only allowed to perform the following commands:"); - for(String whitelistfull: plugin.management.getStringList("commands.whitelist")){ - p.sendMessage(ChatColor.AQUA + whitelistfull); - } - p.sendMessage(ChatColor.AQUA + "/ha"); - p.sendMessage(ChatColor.AQUA + "/ha close"); - p.sendMessage(ChatColor.AQUA + "/ha help"); - p.sendMessage(ChatColor.AQUA + "/ha join"); - p.sendMessage(ChatColor.AQUA + "/ha kick [Player]"); - p.sendMessage(ChatColor.AQUA + "/ha leave"); - p.sendMessage(ChatColor.AQUA + "/ha list"); - p.sendMessage(ChatColor.AQUA + "/ha open"); - p.sendMessage(ChatColor.AQUA + "/ha ready"); - p.sendMessage(ChatColor.AQUA + "/ha refill"); - p.sendMessage(ChatColor.AQUA + "/ha reload"); - p.sendMessage(ChatColor.AQUA + "/ha restart"); - p.sendMessage(ChatColor.AQUA + "/ha rlist"); - p.sendMessage(ChatColor.AQUA + "/ha setspawn"); - p.sendMessage(ChatColor.AQUA + "/ha start"); - p.sendMessage(ChatColor.AQUA + "/ha tp"); - p.sendMessage(ChatColor.AQUA + "/ha watch"); - p.sendMessage(ChatColor.AQUA + "/ha warpall"); - } - } - } - }else if(!cmd.toLowerCase().startsWith("/ha")){ - event.setCancelled(true); - p.sendMessage(ChatColor.RED + "You are only allowed to perform /ha commands!"); - } - }else if(!cmd.toLowerCase().startsWith("/ha")){ - if(cmd.toLowerCase().startsWith("/spawn")){ - event.setCancelled(true); - p.sendMessage("You have perms for all commands except this one!"); - } - } - } - } - if(plugin.getArena(p)!= null){ - if(!p.hasPermission("HungerArena.UseCommands")){ - if(!plugin.management.getStringList("commands.whitelist").isEmpty()){ - for(String whitelist: plugin.management.getStringList("commands.whitelist")){ - i = i+1; - if(i== plugin.management.getStringList("commands.whitelist").size()){ - if(!cmd.toLowerCase().startsWith(whitelist.toLowerCase()) || !cmd.toLowerCase().startsWith("/ha")){ - event.setCancelled(true); - p.sendMessage(ChatColor.RED + "You are only allowed to perform the following commands:"); - for(String whitelistfull: plugin.management.getStringList("commands.whitelist")){ - p.sendMessage(ChatColor.AQUA + whitelistfull); - } - p.sendMessage(ChatColor.AQUA + "/ha"); - p.sendMessage(ChatColor.AQUA + "/ha close"); - p.sendMessage(ChatColor.AQUA + "/ha help"); - p.sendMessage(ChatColor.AQUA + "/ha join"); - p.sendMessage(ChatColor.AQUA + "/ha kick [Player]"); - p.sendMessage(ChatColor.AQUA + "/ha leave"); - p.sendMessage(ChatColor.AQUA + "/ha list"); - p.sendMessage(ChatColor.AQUA + "/ha open"); - p.sendMessage(ChatColor.AQUA + "/ha ready"); - p.sendMessage(ChatColor.AQUA + "/ha refill"); - p.sendMessage(ChatColor.AQUA + "/ha reload"); - p.sendMessage(ChatColor.AQUA + "/ha restart"); - p.sendMessage(ChatColor.AQUA + "/ha rlist"); - p.sendMessage(ChatColor.AQUA + "/ha setspawn"); - p.sendMessage(ChatColor.AQUA + "/ha start"); - p.sendMessage(ChatColor.AQUA + "/ha tp"); - p.sendMessage(ChatColor.AQUA + "/ha watch"); - p.sendMessage(ChatColor.AQUA + "/ha warpall"); - } - } - } - }else if(!cmd.toLowerCase().startsWith("/ha")){ - event.setCancelled(true); - p.sendMessage(ChatColor.RED + "You are only allowed to perform /ha commands!"); - } - }else if(!cmd.toLowerCase().startsWith("/ha")){ - if(cmd.toLowerCase().startsWith("/spawn")){ - event.setCancelled(true); - p.sendMessage("You have perms for all commands except this one!"); - } - } - }else if(cmd.toLowerCase().equals("/back")){ - for(i = 1; i < plugin.Dead.size(); i++){ - if(plugin.Dead.get(i).contains(pname) && plugin.canjoin.get(i)) - plugin.Tele.add(p); - } - }else if(cmd.startsWith("/tp") || cmd.startsWith("/tpa") || cmd.startsWith("/tpo")){ - String[] args = cmd.split(" "); - Player arg1 = null; - Player arg2 = null; - if(args.length == 2){ - if(Bukkit.getPlayer(args[0]) != null && Bukkit.getPlayer(args[1]) != null){ - arg1 = Bukkit.getPlayer(args[0]); - arg2 = Bukkit.getPlayer(args[1]); - if(plugin.isSpectating(p)){ - event.setCancelled(true); - p.sendMessage(ChatColor.RED + "Invalid command for spectating, using /ha tp " + arg2); - p.performCommand("/ha tp " + arg2); - }else if(plugin.getArena(arg1)!= null || plugin.getArena(arg2)!= null){ - event.setCancelled(true); - p.sendMessage(ChatColor.RED + "You can't teleport to other tributes!"); - } - } - }else if(args.length == 1){ - if(Bukkit.getPlayer(args[0]) != null){ - arg1 = Bukkit.getPlayer(args[0]); - if(plugin.isSpectating(p)){ - event.setCancelled(true); - p.sendMessage(ChatColor.RED + "Invalid command for spectating, using /ha tp " + arg1); - p.performCommand("/ha tp " + arg1); - }else if(plugin.getArena(arg1)!= null || plugin.getArena(p)!= null){ - event.setCancelled(true); - p.sendMessage(ChatColor.RED + "You can't teleport to other tributes!"); - } - } - } - } - } -} diff --git a/src/me/travja/hungerarena/HaCommands.java b/src/me/travja/hungerarena/HaCommands.java deleted file mode 100644 index 40d1b51..0000000 --- a/src/me/travja/hungerarena/HaCommands.java +++ /dev/null @@ -1,1558 +0,0 @@ -package me.Travja.HungerArena; - -import java.util.ArrayList; -import java.util.List; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Location; -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.command.ConsoleCommandSender; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; - -public class HaCommands implements CommandExecutor { - public Main plugin; - public HaCommands(Main m) { - this.plugin = m; - } - int i = 0; - int a = 1; - @SuppressWarnings("deprecation") - private void clearInv(Player p){ - p.getInventory().clear(); - p.getInventory().setBoots(null); - p.getInventory().setChestplate(null); - p.getInventory().setHelmet(null); - p.getInventory().setLeggings(null); - p.updateInventory(); - } - @SuppressWarnings({ "unchecked" }) - @Override - public boolean onCommand(final CommandSender sender, Command cmd, String commandLabel, String[] args){ - String[] Spawncoords = plugin.spawns.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 = plugin.getServer().getWorld(spawnworld); - Location Spawn = new Location(spawnw, spawnx, spawny, spawnz); - if(sender instanceof Player){ - final Player p = (Player) sender; - final String pname = p.getName(); - ChatColor c = ChatColor.AQUA; - if(cmd.getName().equalsIgnoreCase("Ha")){ - if(args.length== 0){ - p.sendMessage(ChatColor.GREEN + "[HungerArena] by " + ChatColor.AQUA + "travja! Version: " + plugin.getDescription().getVersion()); - return false; - }else 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(); - plugin.spawns.set("Spawn_coords", x + "," + y + "," + z + "," + w); - plugin.spawns.set("Spawns_set", "true"); - plugin.saveSpawns(); - p.sendMessage(ChatColor.AQUA + "You have set the spawn for dead tributes!"); - }else{ - p.sendMessage(ChatColor.RED + "You don't have permission!"); - } - }else if(args[0].equalsIgnoreCase("Help")){ - p.sendMessage(ChatColor.GREEN + "----HungerArena Help----"); - sender.sendMessage(c + "/ha - Displays author message!"); - sender.sendMessage(c + "/sponsor [Player] [ItemID] [Amount] - Lets you sponsor someone!"); - sender.sendMessage(c + "/startpoint [1,2,3,4,etc] [1,2,3,4,etc] - Sets the starting points of tributes in a specific arena!"); - sender.sendMessage(c + "/ha close (1,2,3,4,etc) - Prevents anyone from joining that arena! Numbers are optional"); - sender.sendMessage(c + "/ha help - Displays this screen!"); - sender.sendMessage(c + "/ha join [1,2,3,4,etc] - Makes you join the game!"); - sender.sendMessage(c + "/ha kick [Player] - Kicks a player from the arena!"); - sender.sendMessage(c + "/ha leave - Makes you leave the game!"); - sender.sendMessage(c + "/ha list (1,2,3,4,etc) - Shows a list of players in the game and their health! Numbers are optional."); - sender.sendMessage(c + "/ha open (1,2,3,4,etc) - Opens the game allowing people to join! Numbers are optional"); - sender.sendMessage(c + "/ha ready - Votes for the game to start!"); - sender.sendMessage(c + "/ha refill (1,2,3,4,etc) - Refills all chests! Numbers are optional"); - sender.sendMessage(c + "/ha reload - Reloads the config!"); - sender.sendMessage(c + "/ha restart (1,2,3,4,etc) - Restarts the game! Numbers are optional"); - sender.sendMessage(c + "/ha rlist (1,2,3,4,etc) - See who's ready! Numbers are optional"); - sender.sendMessage(c + "/ha setspawn - Sets the spawn for dead tributes!"); - sender.sendMessage(c + "/ha tp [player] - Teleports you to a tribute!"); - sender.sendMessage(c + "/ha start [1,2,3,4,etc] - Unfreezes tributes allowing them to fight!"); - sender.sendMessage(c + "/ha watch [1,2,3,4,etc] - Lets you watch the tributes!"); - sender.sendMessage(c + "/ha warpall [1,2,3,4,etc] - Warps all tribute into position!"); - sender.sendMessage(ChatColor.GREEN + "----------------------"); - }else if(plugin.restricted && !plugin.worlds.contains(p.getWorld().getName())){ - p.sendMessage(ChatColor.RED + "That can't be run in this world!"); - }else if((plugin.restricted && plugin.worlds.contains(p.getWorld().getName())) || !plugin.restricted){ - //////////////////////////////////////// LISTING /////////////////////////////////////////////// - if(args[0].equalsIgnoreCase("List")){ - if(p.hasPermission("HungerArena.GameMaker") || plugin.Watching.get(a).contains(pname) || p.hasPermission("HungerArena.List")){ - if(args.length>= 2){ - try{ - a = Integer.parseInt(args[1]); - sender.sendMessage(ChatColor.AQUA + "----- Arena " + a + " -----"); - if(!plugin.Playing.get(a).isEmpty() && plugin.Playing.containsKey(a)){ - for(String playernames: plugin.Playing.get(a)){ - Player players = plugin.getServer().getPlayerExact(playernames); - if(p.hasPermission("HungerArena.GameMaker")){ - sender.sendMessage(ChatColor.GREEN + playernames + " Life: " + players.getHealth() + "/20"); - }else if(p.hasPermission("HungerArena.List")){ - sender.sendMessage(ChatColor.GREEN + playernames); - } - } - }else{ - p.sendMessage(ChatColor.GRAY + "No one is playing!"); - } - p.sendMessage(ChatColor.AQUA + "-------------------"); - }catch(Exception e){ - p.sendMessage(ChatColor.RED + "Argument not an integer or is an invalid arena!"); - } - }else{ - if(plugin.getArena(p)== null){ - p.sendMessage(ChatColor.AQUA + "----- Arena 1 -----"); - if(!plugin.Playing.get(1).isEmpty() && plugin.Playing.containsKey(1)){ - for(String playernames: plugin.Playing.get(1)){ - Player players = plugin.getServer().getPlayerExact(playernames); - if(p.hasPermission("HungerArena.GameMaker")){ - sender.sendMessage(ChatColor.GREEN + playernames + " Life: " + players.getHealth() + "/20"); - }else if(p.hasPermission("HungerArena.List")){ - sender.sendMessage(ChatColor.GREEN + playernames); - } - } - }else{ - p.sendMessage(ChatColor.GRAY + "No one is playing!"); - } - }else{ - a = plugin.getArena(p); - sender.sendMessage(ChatColor.AQUA + "----- Arena " + a + " -----"); - if(!plugin.Playing.get(a).isEmpty() && plugin.Playing.containsKey(a)){ - for(String playernames: plugin.Playing.get(a)){ - Player players = plugin.getServer().getPlayerExact(playernames); - if(p.hasPermission("HungerArena.GameMaker")){ - sender.sendMessage(ChatColor.GREEN + playernames + " Life: " + players.getHealth() + "/20"); - }else if(p.hasPermission("HungerArena.List")){ - sender.sendMessage(ChatColor.GREEN + playernames); - } - } - }else{ - p.sendMessage(ChatColor.GRAY + "No one is playing!"); - } - } - p.sendMessage(ChatColor.AQUA + "-------------------"); - } - }else{ - p.sendMessage(ChatColor.RED + "You don't have permission!"); - } - }else if(args[0].equalsIgnoreCase("rList")){ - if(p.hasPermission("HungerArena.GameMaker")){ - if(args.length>= 2){ - try{ - a = Integer.parseInt(args[1]); - sender.sendMessage(ChatColor.AQUA + "----- Arena " + a + " -----"); - if(!plugin.Ready.get(a).isEmpty() && plugin.Ready.containsKey(a)){ - for(String playernames: plugin.Ready.get(a)){ - sender.sendMessage(ChatColor.GREEN + playernames); - } - }else{ - p.sendMessage(ChatColor.GRAY + "No one is ready!"); - } - p.sendMessage(ChatColor.AQUA + "-------------------"); - }catch(Exception e){ - p.sendMessage(ChatColor.RED + "Argument not an integer!"); - } - }else{ - p.sendMessage(ChatColor.AQUA + "----- Arena 1 -----"); - if(!plugin.Ready.get(1).isEmpty() && plugin.Ready.containsKey(1)){ - for(String playernames: plugin.Ready.get(1)){ - sender.sendMessage(ChatColor.GREEN + playernames); - } - }else{ - p.sendMessage(ChatColor.GRAY + "No one is ready!"); - } - p.sendMessage(ChatColor.AQUA + "-------------------"); - } - }else{ - p.sendMessage(ChatColor.RED + "You don't have permission!"); - } - //////////////////////////////////////////////////////////////////////////////////////////////// - ///////////////////////////////////// JOINING/LEAVING ////////////////////////////////////////// - }else if(args[0].equalsIgnoreCase("Join")){ - if(p.hasPermission("HungerArena.Join")){ - boolean needconfirm = false; - for(i= 1; i< plugin.NeedConfirm.size(); i++){ - if(plugin.NeedConfirm.get(i).contains(pname)){ - needconfirm = true; - p.sendMessage(ChatColor.GOLD + "You need to run /ha confirm"); - } - } - if(!needconfirm){ - try{ - a = Integer.parseInt(args[1]); - }catch(Exception e){ - i = 1; - while(i <= plugin.Playing.size()){ - if(plugin.Playing.get(i).size()< plugin.maxPlayers.get(i)){ - a = i; - i = plugin.Playing.size()+1; - } - if(plugin.Playing.size()== i){ - p.sendMessage(ChatColor.RED + "All games are full!"); - } - i++; - } - } - if(plugin.Playing.get(a)!= null){ - if(plugin.Playing.get(a).contains(pname)){ - p.sendMessage(ChatColor.RED + "You are already playing!"); - }else if(plugin.Dead.get(a).contains(pname) || plugin.Quit.get(a).contains(pname)){ - p.sendMessage(ChatColor.RED + "You DIED/QUIT! You can't join again!"); - }else if(plugin.Playing.get(a).size()== plugin.maxPlayers.get(a)){ - p.sendMessage(ChatColor.RED + "There are already " + plugin.maxPlayers.get(a) + " Tributes in that Arena!"); - }else if(plugin.canjoin.get(a)== true){ - p.sendMessage(ChatColor.RED + "That game is in progress!"); - }else if(!plugin.open.get(a)){ - p.sendMessage(ChatColor.RED + "That game is closed!"); - }else if(plugin.spawns.getString("Spawns_set").equalsIgnoreCase("false")){ - p.sendMessage(ChatColor.RED + "/ha setspawn hasn't been run!"); - }else if(plugin.NeedConfirm.get(a).contains(pname)){ - p.sendMessage(ChatColor.RED + "You need to do /ha confirm"); - }else if(plugin.getArena(p)!= null){ - p.sendMessage(ChatColor.RED + "You are already in an arena!"); - }else if(plugin.config.getString("Need_Confirm").equalsIgnoreCase("true")){ - if(plugin.config.getBoolean("EntryFee.enabled") && plugin.config.getBoolean("EntryFee.eco")){ - if(!(plugin.econ.getBalance(pname) < plugin.config.getDouble("EntryFee.cost"))){ - i = 0; - for(ItemStack fee: plugin.Fee){ - int total = plugin.Fee.size(); - if(p.getInventory().contains(fee)){ - i = i+1; - if(total == i){ - plugin.NeedConfirm.get(a).add(pname); - p.sendMessage(ChatColor.GOLD + "You're inventory will be cleared! Type /ha confirm to procede"); - } - } - } - if(plugin.Fee.size() > i){ - p.sendMessage(ChatColor.RED + "You are missing some items and can't join the games..."); - } - }else{ - p.sendMessage(ChatColor.RED + "You don't have enough money to join!"); - } - }else if(plugin.config.getBoolean("EntryFee.enabled") && !plugin.config.getBoolean("EntryFee.eco")){ - i = 0; - for(ItemStack fee: plugin.Fee){ - int total = plugin.Fee.size(); - if(p.getInventory().contains(fee)){ - i = i+1; - if(total == i){ - plugin.NeedConfirm.get(a).add(pname); - p.sendMessage(ChatColor.GOLD + "You're inventory will be cleared! Type /ha confirm to procede"); - } - } - } - if(plugin.Fee.size() > i){ - p.sendMessage(ChatColor.RED + "You are missing some items and can't join the games..."); - } - }else if(!plugin.config.getBoolean("EntryFee.enabled") && plugin.config.getBoolean("EntryFee.eco")){ - if(!(plugin.econ.getBalance(pname) < plugin.config.getDouble("EntryFee.cost"))){ - plugin.NeedConfirm.get(a).add(pname); - p.sendMessage(ChatColor.GOLD + "You're inventory will be cleared! Type /ha confirm to procede"); - }else{ - p.sendMessage(ChatColor.RED + "You don't have enough money to join!"); - } - }else{ - plugin.NeedConfirm.get(a).add(pname); - p.sendMessage(ChatColor.GOLD + "You're inventory will be cleared! Type /ha confirm to procede"); - } - }else if(plugin.config.getString("Need_Confirm").equalsIgnoreCase("false")){ - if(plugin.config.getBoolean("EntryFee.enabled") && plugin.config.getBoolean("EntryFee.eco")){ - if(!(plugin.econ.getBalance(pname) < plugin.config.getDouble("EntryFee.cost"))){ - i = 0; - for(ItemStack fee: plugin.Fee){ - int total = plugin.Fee.size(); - if(p.getInventory().contains(fee)){ - i = i+1; - if(total == i){ - plugin.econ.withdrawPlayer(pname, plugin.config.getDouble("EntryFee.cost")); - p.sendMessage(ChatColor.GOLD + "[HungerArena] " + ChatColor.GREEN + "$" + plugin.config.getDouble("EntryFee.cost") + " has been taken from your account!"); - for(ItemStack fees: plugin.Fee){ - p.sendMessage(ChatColor.GOLD + "[HungerArena] " + ChatColor.GREEN + fees + " was paid to join the games."); - } - plugin.Playing.get(a).add(pname); - plugin.NeedConfirm.get(a).remove(pname); - p.sendMessage(ChatColor.GREEN + "Do /ha ready to vote to start the games!"); - clearInv(p); - if(plugin.config.getBoolean("broadcastAll")){ - plugin.getServer().broadcastMessage(ChatColor.AQUA + pname + " has Joined Arena " + a + "!"); - }else{ - for(String gn: plugin.Playing.get(a)){ - Player g = plugin.getServer().getPlayer(gn); - g.sendMessage(ChatColor.AQUA + pname + " has Joined the Game!"); - } - } - if(plugin.Playing.get(a).size()== plugin.maxPlayers.get(a)){ - plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), "ha warpall " + a); - } - } - } - } - if(plugin.Fee.size() > i){ - p.sendMessage(ChatColor.RED + "You are missing some items and can't join the games..."); - } - }else{ - p.sendMessage(ChatColor.RED + "You don't have enough money to join!"); - } - }else if(plugin.config.getBoolean("EntryFee.enabled") && !plugin.config.getBoolean("EntryFee.eco")){ - i = 0; - for(ItemStack fee: plugin.Fee){ - int total = plugin.Fee.size(); - if(p.getInventory().contains(fee)){ - i = i+1; - if(total == i){ - for(ItemStack fees: plugin.Fee){ - p.sendMessage(ChatColor.GOLD + "[HungerArena] " + ChatColor.GREEN + fees + " was paid to join the games."); - } - plugin.Playing.get(a).add(pname); - plugin.NeedConfirm.get(a).remove(pname); - p.sendMessage(ChatColor.GREEN + "Do /ha ready to vote to start the games!"); - clearInv(p); - if(plugin.config.getBoolean("broadcastAll")){ - plugin.getServer().broadcastMessage(ChatColor.AQUA + pname + " has Joined Arena " + a + "!"); - }else{ - for(String gn: plugin.Playing.get(a)){ - Player g = plugin.getServer().getPlayer(gn); - g.sendMessage(ChatColor.AQUA + pname + " has Joined the Game!"); - } - } - if(plugin.Playing.get(a).size()== plugin.maxPlayers.get(a)){ - plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), "ha warpall " + a); - } - } - } - } - if(plugin.Fee.size() > i){ - p.sendMessage(ChatColor.RED + "You are missing some items and can't join the games..."); - } - }else if(!plugin.config.getBoolean("EntryFee.enabled") && plugin.config.getBoolean("EntryFee.eco")){ - if(!(plugin.econ.getBalance(pname) < plugin.config.getDouble("EntryFee.cost"))){ - plugin.econ.withdrawPlayer(pname, plugin.config.getDouble("EntryFee.cost")); - p.sendMessage(ChatColor.GOLD + "[HungerArena] " + ChatColor.GREEN + "$" + plugin.config.getDouble("EntryFee.cost") + " has been taken from your account!"); - plugin.Playing.get(a).add(pname); - plugin.NeedConfirm.get(a).remove(pname); - p.sendMessage(ChatColor.GREEN + "Do /ha ready to vote to start the games!"); - clearInv(p); - if(plugin.config.getBoolean("broadcastAll")){ - plugin.getServer().broadcastMessage(ChatColor.AQUA + pname + " has Joined Arena " + a + "!"); - }else{ - for(String gn: plugin.Playing.get(a)){ - Player g = plugin.getServer().getPlayer(gn); - g.sendMessage(ChatColor.AQUA + pname + " has Joined the Game!"); - } - } - if(plugin.Playing.get(a).size()== plugin.maxPlayers.get(a)){ - plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), "ha warpall " + a); - } - }else{ - p.sendMessage(ChatColor.RED + "You don't have enough money to join!"); - } - }else{ - plugin.Playing.get(a).add(pname); - plugin.NeedConfirm.get(a).remove(pname); - p.sendMessage(ChatColor.GREEN + "Do /ha ready to vote to start the games!"); - clearInv(p); - if(plugin.config.getBoolean("broadcastAll")){ - plugin.getServer().broadcastMessage(ChatColor.AQUA + pname + " has Joined Arena " + a + "!"); - }else{ - for(String gn: plugin.Playing.get(a)){ - Player g = plugin.getServer().getPlayer(gn); - g.sendMessage(ChatColor.AQUA + pname + " has Joined the Game!"); - } - } - if(plugin.Playing.get(a).size()== plugin.maxPlayers.get(a)){ - plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), "ha warpall " + a); - } - } - } - }else{ - p.sendMessage(ChatColor.RED + "That arena doesn't exist!"); - } - } - }else{ - p.sendMessage(ChatColor.RED + "You don't have permission!"); - } - //////////////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////// CONFIRMATION /////////////////////////////////////////////// - }else if(args[0].equalsIgnoreCase("Confirm")){ - int v = 0; - for(v = 1; v < plugin.NeedConfirm.size(); v++){ - if(plugin.NeedConfirm.get(v).contains(pname)){ - v = plugin.NeedConfirm.size()+1; - if(plugin.config.getBoolean("EntryFee.enabled") && plugin.config.getBoolean("EntryFee.eco")){ - if(!(plugin.econ.getBalance(pname) < plugin.config.getDouble("EntryFee.cost"))){ - i = 0; - for(ItemStack fee: plugin.Fee){ - int total = plugin.Fee.size(); - if(p.getInventory().contains(fee)){ - i = i+1; - if(total == i){ - plugin.econ.withdrawPlayer(pname, plugin.config.getDouble("EntryFee.cost")); - p.sendMessage(ChatColor.GOLD + "[HungerArena] " + ChatColor.GREEN + "$" + plugin.config.getDouble("EntryFee.cost") + " has been taken from your account!"); - for(ItemStack fees: plugin.Fee){ - p.sendMessage(ChatColor.GOLD + "[HungerArena] " + ChatColor.GREEN + fees + " was paid to join the games."); - } - plugin.Playing.get(a).add(pname); - plugin.NeedConfirm.get(a).remove(pname); - p.sendMessage(ChatColor.GREEN + "Do /ha ready to vote to start the games!"); - clearInv(p); - if(plugin.config.getBoolean("broadcastAll")){ - plugin.getServer().broadcastMessage(ChatColor.AQUA + pname + " has Joined Arena " + a + "!"); - }else{ - for(String gn: plugin.Playing.get(a)){ - Player g = plugin.getServer().getPlayer(gn); - g.sendMessage(ChatColor.AQUA + pname + " has Joined the Game!"); - } - } - if(plugin.Playing.get(a).size()== plugin.maxPlayers.get(a)){ - plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), "ha warpall " + a); - } - } - } - } - if(plugin.Fee.size() > i){ - p.sendMessage(ChatColor.RED + "You are missing some items and can't join the games..."); - } - }else{ - p.sendMessage(ChatColor.RED + "You don't have enough money to join!"); - } - }else if(plugin.config.getBoolean("EntryFee.enabled") && !plugin.config.getBoolean("EntryFee.eco")){ - i = 0; - for(ItemStack fee: plugin.Fee){ - int total = plugin.Fee.size(); - if(p.getInventory().contains(fee)){ - i = i+1; - if(total == i){ - for(ItemStack fees: plugin.Fee){ - p.sendMessage(ChatColor.GOLD + "[HungerArena] " + ChatColor.GREEN + fees + " was paid to join the games."); - } - plugin.Playing.get(a).add(pname); - plugin.NeedConfirm.get(a).remove(pname); - p.sendMessage(ChatColor.GREEN + "Do /ha ready to vote to start the games!"); - clearInv(p); - if(plugin.config.getBoolean("broadcastAll")){ - plugin.getServer().broadcastMessage(ChatColor.AQUA + pname + " has Joined Arena " + a + "!"); - }else{ - for(String gn: plugin.Playing.get(a)){ - Player g = plugin.getServer().getPlayer(gn); - g.sendMessage(ChatColor.AQUA + pname + " has Joined the Game!"); - } - } - if(plugin.Playing.get(a).size()== plugin.maxPlayers.get(a)){ - plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), "ha warpall " + a); - } - } - } - } - if(plugin.Fee.size() > i){ - p.sendMessage(ChatColor.RED + "You are missing some items and can't join the games..."); - } - }else if(!plugin.config.getBoolean("EntryFee.enabled") && plugin.config.getBoolean("EntryFee.eco")){ - if(!(plugin.econ.getBalance(pname) < plugin.config.getDouble("EntryFee.cost"))){ - plugin.econ.withdrawPlayer(pname, plugin.config.getDouble("EntryFee.cost")); - p.sendMessage(ChatColor.GOLD + "[HungerArena] " + ChatColor.GREEN + "$" + plugin.config.getDouble("EntryFee.cost") + " has been taken from your account!"); - plugin.Playing.get(a).add(pname); - plugin.NeedConfirm.get(a).remove(pname); - p.sendMessage(ChatColor.GREEN + "Do /ha ready to vote to start the games!"); - clearInv(p); - if(plugin.config.getBoolean("broadcastAll")){ - plugin.getServer().broadcastMessage(ChatColor.AQUA + pname + " has Joined Arena " + a + "!"); - }else{ - for(String gn: plugin.Playing.get(a)){ - Player g = plugin.getServer().getPlayer(gn); - g.sendMessage(ChatColor.AQUA + pname + " has Joined the Game!"); - } - } - if(plugin.Playing.get(a).size()== plugin.maxPlayers.get(a)){ - plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), "ha warpall " + a); - } - }else{ - p.sendMessage(ChatColor.RED + "You don't have enough money to join!"); - } - }else{ - plugin.Playing.get(a).add(pname); - plugin.NeedConfirm.get(a).remove(pname); - p.sendMessage(ChatColor.GREEN + "Do /ha ready to vote to start the games!"); - clearInv(p); - if(plugin.config.getBoolean("broadcastAll")){ - plugin.getServer().broadcastMessage(ChatColor.AQUA + pname + " has Joined Arena " + a + "!"); - }else{ - for(String gn: plugin.Playing.get(a)){ - Player g = plugin.getServer().getPlayer(gn); - g.sendMessage(ChatColor.AQUA + pname + " has Joined the Game!"); - } - } - if(plugin.Playing.get(a).size()== plugin.maxPlayers.get(a)){ - plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), "ha warpall " + a); - } - } - } - if(v== plugin.NeedConfirm.size()){ - p.sendMessage(ChatColor.RED + "You haven't joined any games!"); - } - } - }else if(args[0].equalsIgnoreCase("Ready")){ - p.sendMessage(String.valueOf(plugin.getArena(p))); - if(plugin.getArena(p)!= null){ - a = plugin.getArena(p); - for(String s:plugin.Playing.get(a)) - p.sendMessage(s); - if(plugin.Playing.get(a).contains(pname)){ - if(plugin.Ready.get(a).contains(pname)){ - p.sendMessage(ChatColor.RED + "You're already ready!"); - }else if(plugin.Playing.get(a).size()== 1){ - p.sendMessage(ChatColor.RED + "You can't be ready when no one else is playing!"); - }else{ - plugin.Ready.get(a).add(pname); - p.sendMessage(ChatColor.AQUA + "You have marked yourself as READY!"); - if(plugin.Playing.get(a).size()-4== plugin.Ready.get(a).size() || plugin.Playing.get(a).size()==plugin.Ready.get(a).size()){ - Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha warpall " + a); - } - } - } - }else{ - p.sendMessage(ChatColor.RED + "You aren't playing in any games!"); - } - }else if(args[0].equalsIgnoreCase("Leave")){ - if(plugin.getArena(p)!= null){ - a = plugin.getArena(p); - if(plugin.canjoin.get(a)== true){ - plugin.Playing.get(a).remove(pname); - p.sendMessage(ChatColor.AQUA + "You have left the game!"); - if(plugin.config.getBoolean("broadcastAll")){ - p.getServer().broadcastMessage(ChatColor.RED + pname + " Left Arena " + a + "!"); - }else{ - for(String gn: plugin.Playing.get(a)){ - Player g = plugin.getServer().getPlayer(gn); - g.sendMessage(ChatColor.RED + pname + " Quit!"); - } - } - clearInv(p); - p.teleport(Spawn); - if(plugin.Frozen.get(a).contains(pname)){ - plugin.Frozen.get(a).remove(pname); - } - plugin.winner(a); - }else{ - plugin.Playing.get(a).remove(pname); - p.sendMessage(ChatColor.AQUA + "You have left the game!"); - if(plugin.config.getBoolean("broadcastAll")){ - p.getServer().broadcastMessage(ChatColor.RED + pname + " Left Arena " + a + "!"); - }else{ - for(String gn: plugin.Playing.get(a)){ - Player g = plugin.getServer().getPlayer(gn); - g.sendMessage(ChatColor.RED + pname + " Quit!"); - } - } - clearInv(p); - p.teleport(Spawn); - if(plugin.config.getBoolean("EntryFee.enabled") && plugin.config.getBoolean("EntryFee.eco")){ - plugin.econ.depositPlayer(pname, plugin.config.getDouble("EntryFee.cost")); - p.sendMessage(ChatColor.GOLD + "[HungerArena] " + ChatColor.GREEN + "$" + plugin.config.getDouble("EntryFee.cost") + " has been added to your account!"); - for(ItemStack fees: plugin.Fee){ - p.sendMessage(ChatColor.GOLD + "[HungerArena] " + ChatColor.GREEN + fees + " was refunded because you left the games."); - } - }else if(plugin.config.getBoolean("EntryFee.enabled") && !plugin.config.getBoolean("EntryFee.eco")){ - for(ItemStack fees: plugin.Fee){ - p.sendMessage(ChatColor.GOLD + "[HungerArena] " + ChatColor.GREEN + fees + " was refunded because you left the games."); - } - }else if(!plugin.config.getBoolean("EntryFee.enabled") && plugin.config.getBoolean("EntryFee.eco")){ - plugin.econ.depositPlayer(pname, plugin.config.getDouble("EntryFee.cost")); - p.sendMessage(ChatColor.GOLD + "[HungerArena] " + ChatColor.GREEN + "$" + plugin.config.getDouble("EntryFee.cost") + " has added to your account!"); - } - } - }else{ - p.sendMessage(ChatColor.RED + "You aren't in any games!"); - } - //////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////// SPECTATOR RELATED ////////////////////////////////// - }else if(args[0].equalsIgnoreCase("Watch")){ - if(sender.hasPermission("HungerArena.Watch")){ - if(args.length>= 2){ - a = Integer.parseInt(args[1]); - if(!plugin.Watching.get(a).contains(pname) && plugin.getArena(p)== null && plugin.canjoin.get(a)== true){ - plugin.Watching.get(a).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.get(a)== false){ - p.sendMessage(ChatColor.RED + "That game isn't in progress!"); - }else if(plugin.Playing.get(a).contains(pname)){ - p.sendMessage(ChatColor.RED + "You can't watch while you're playing!"); - }else if(plugin.Watching.get(a).contains(pname)){ - plugin.Watching.get(a).remove(pname); - for(Player online:plugin.getServer().getOnlinePlayers()){ - online.showPlayer(p); - } - p.teleport(Spawn); - p.setAllowFlight(false); - p.sendMessage(ChatColor.AQUA + "You are not spectating any more"); - } - }else{ - p.sendMessage(ChatColor.RED + "Too few arguments!"); - } - }else{ - p.sendMessage(ChatColor.RED + "You don't have permission!"); - } - }else if(args[0].equalsIgnoreCase("tp")){ - int b = 0; - for(i = 1; i <= plugin.Watching.size(); i++){ - if(plugin.Watching.get(a).contains(pname)){ - if(plugin.getArena(Bukkit.getServer().getPlayer(args[1])) != null){ - Player target = Bukkit.getServer().getPlayer(args[1]); - p.teleport(target); - p.sendMessage(ChatColor.AQUA + "You've been teleported to " + target.getName()); - }else{ - p.sendMessage(ChatColor.RED + "That person isn't in game!"); - } - }else{ - b = b+1; - if(b== plugin.Watching.size()){ - p.sendMessage(ChatColor.RED + "You have to be spectating first!"); - } - } - } - ///////////////////////////////////////////////////////////////////////////////// - }else if(args[0].equalsIgnoreCase("Kick")){ - if (args.length != 2) { - return false; - } - Player target = Bukkit.getServer().getPlayer(args[1]); - if(sender.hasPermission("HungerArena.Kick")){ - if(plugin.getArena(target) != null){ - a = plugin.getArena(target); - plugin.Playing.get(a).remove(target.getName()); - if(plugin.config.getBoolean("broadcastAll")){ - p.getServer().broadcastMessage(ChatColor.RED + target.getName() + " was kicked from arena " + a + "!"); - }else{ - for(String gn: plugin.Playing.get(a)){ - Player g = plugin.getServer().getPlayer(gn); - g.sendMessage(ChatColor.RED + target.getName() + " was kicked from the game!"); - } - } - clearInv(target); - target.teleport(Spawn); - plugin.Quit.get(a).add(target.getName()); - plugin.winner(a); - }else{ - sender.sendMessage(ChatColor.RED + "That player isn't in the game!"); - } - }else{ - sender.sendMessage(ChatColor.RED + "You don't have permission!"); - } - }else if(args[0].equalsIgnoreCase("Refill")){ - if(p.hasPermission("HungerArena.Refill")){ - if(args.length>= 2){ - a = Integer.parseInt(args[1]); - 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"); - int chesta = plugin.getConfig().getInt("Storage." + xyz2 + ".Arena"); - String chestw = plugin.getConfig().getString("Storage." + xyz2 + ".Location.W"); - Block blockatlocation = Bukkit.getWorld(chestw).getBlockAt(chestx, chesty, chestz); - plugin.exists = false; - if(chesta== a){ - if(blockatlocation.getState() instanceof Chest){ - plugin.exists = true; - Chest chest = (Chest) blockatlocation.getState(); - if(chesta== a){ - 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); - chest.update(); - } - } - }else{ - list056 = list056+1; - } - if(limit== list056){ - sender.sendMessage(ChatColor.GREEN + "All for arena " + a + " refilled!"); - } - } - }else{ - 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); - chest.update(); - } - } - 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")){ - int b = 0; - if(p.hasPermission("HungerArena.Restart")){ - if(args.length>= 2){ - a = Integer.parseInt(args[1]); - for(b = 0; b < plugin.Watching.get(a).size(); b++){ - String s = plugin.Watching.get(a).get(b); - Player spectator = plugin.getServer().getPlayerExact(s); - spectator.setAllowFlight(false); - spectator.teleport(Spawn); - for(Player online:plugin.getServer().getOnlinePlayers()){ - online.showPlayer(spectator); - } - } - plugin.Dead.get(a).clear(); - plugin.Quit.get(a).clear(); - plugin.Watching.get(a).clear(); - plugin.Frozen.get(a).clear(); - plugin.Ready.get(a).clear(); - plugin.NeedConfirm.get(a).clear(); - plugin.Out.get(a).clear(); - plugin.Playing.get(a).clear(); - plugin.inArena.get(a).clear(); - plugin.canjoin.put(a, false); - plugin.open.put(a, true); - List blocksbroken = plugin.data.getStringList("Blocks_Destroyed"); - List blocksplaced = plugin.data.getStringList("Blocks_Placed"); - ArrayList toremove = new ArrayList(); - ArrayList toremove2 = new ArrayList(); - for(String blocks:blocksplaced){ - String[] coords = blocks.split(","); - World w = plugin.getServer().getWorld(coords[0]); - double x = Double.parseDouble(coords[1]); - double y = Double.parseDouble(coords[2]); - double z = Double.parseDouble(coords[3]); - int arena = Integer.parseInt(coords[4]); - int d = 0; - byte m = 0; - Location blockl = new Location(w, x, y, z); - Block block = w.getBlockAt(blockl); - if(arena== a){ - block.setTypeIdAndData(d, m, true); - block.getState().update(); - toremove.add(blocks); - } - } - for(String blocks:blocksbroken){ - String[] coords = blocks.split(","); - World w = plugin.getServer().getWorld(coords[0]); - double x = Double.parseDouble(coords[1]); - double y = Double.parseDouble(coords[2]); - double z = Double.parseDouble(coords[3]); - int d = Integer.parseInt(coords[4]); - byte m = Byte.parseByte(coords[5]); - int arena = Integer.parseInt(coords[6]); - Location blockl = new Location(w, x, y, z); - Block block = w.getBlockAt(blockl); - if(arena== a){ - block.setTypeIdAndData(d, m, true); - block.getState().update(); - toremove2.add(blocks); - } - } - for(String blocks: toremove){ - blocksplaced.remove(blocks); - } - for(String blocks: toremove2){ - blocksbroken.remove(blocks); - } - toremove.clear(); - toremove2.clear(); - plugin.data.set("Blocks_Destroyed", blocksbroken); - plugin.data.set("Blocks_Placed", blocksplaced); - plugin.data.options().copyDefaults(); - plugin.saveData(); - p.performCommand("ha refill " + a); - p.sendMessage(ChatColor.AQUA + "Arena " + a + " has been reset!"); - }else{ - for(i = 1; i <= plugin.Watching.size(); i++){ - for(b = 0; b <= plugin.Watching.get(i).size(); b++){ - if(plugin.Watching.get(i).get(b)!= null){ - String s = plugin.Watching.get(i).get(b); - Player spectator = plugin.getServer().getPlayerExact(s); - spectator.setAllowFlight(false); - spectator.teleport(Spawn); - for(Player online:plugin.getServer().getOnlinePlayers()){ - online.showPlayer(spectator); - } - } - } - } - plugin.Dead.clear(); - plugin.Quit.clear(); - plugin.Watching.clear(); - plugin.Frozen.clear(); - plugin.Ready.clear(); - plugin.NeedConfirm.clear(); - plugin.Out.clear(); - plugin.Playing.clear(); - plugin.inArena.clear(); - for(i = 1; i <= plugin.canjoin.size(); i++){ - plugin.canjoin.put(i, false); - } - for(i = 1; i <= plugin.open.size(); i++){ - plugin.open.put(i, true); - } - List blocksbroken = plugin.data.getStringList("Blocks_Destroyed"); - List blocksplaced = plugin.data.getStringList("Blocks_Placed"); - for(String blocks:blocksplaced){ - String[] coords = blocks.split(","); - World w = plugin.getServer().getWorld(coords[0]); - double x = Double.parseDouble(coords[1]); - double y = Double.parseDouble(coords[2]); - double z = Double.parseDouble(coords[3]); - int d = 0; - byte m = 0; - Location blockl = new Location(w, x, y, z); - Block block = w.getBlockAt(blockl); - block.setTypeIdAndData(d, m, true); - block.getState().update(); - } - for(String blocks:blocksbroken){ - String[] coords = blocks.split(","); - World w = plugin.getServer().getWorld(coords[0]); - double x = Double.parseDouble(coords[1]); - double y = Double.parseDouble(coords[2]); - double z = Double.parseDouble(coords[3]); - int d = Integer.parseInt(coords[4]); - byte m = Byte.parseByte(coords[5]); - Location blockl = new Location(w, x, y, z); - Block block = w.getBlockAt(blockl); - block.setTypeIdAndData(d, m, true); - block.getState().update(); - } - blocksplaced.clear(); - blocksbroken.clear(); - plugin.data.set("Blocks_Destroyed", blocksbroken); - plugin.data.set("Blocks_Placed", blocksplaced); - plugin.data.options().copyDefaults(); - plugin.saveData(); - p.performCommand("ha refill"); - p.sendMessage(ChatColor.AQUA + "All games have been reset!"); - } - }else{ - p.sendMessage(ChatColor.RED + "You don't have permission!"); - } - /////////////////////////////////// Toggle ////////////////////////////////////////////////// - }else if(args[0].equalsIgnoreCase("close")){ - if(p.hasPermission("HungerArena.toggle")){ - if(args.length>= 2){ - a = Integer.parseInt(args[1]); - if(plugin.open.get(a)){ - plugin.open.put(a, false); - if(plugin.Playing.get(a)!= null){ - for(String players: plugin.Playing.get(a)){ - Player tributes = plugin.getServer().getPlayerExact(players); - clearInv(tributes); - tributes.teleport(tributes.getWorld().getSpawnLocation()); - } - } - if(plugin.Watching.get(a)!= null){ - for(String sname: plugin.Watching.get(a)){ - Player spectators = plugin.getServer().getPlayerExact(sname); - spectators.teleport(spectators.getWorld().getSpawnLocation()); - spectators.setAllowFlight(false); - for(Player online:plugin.getServer().getOnlinePlayers()){ - online.showPlayer(spectators); - } - } - } - plugin.Dead.get(a).clear(); - plugin.Quit.get(a).clear(); - plugin.Watching.get(a).clear(); - plugin.Frozen.get(a).clear(); - plugin.Ready.get(a).clear(); - plugin.NeedConfirm.get(a).clear(); - plugin.Out.get(a).clear(); - plugin.Playing.get(a).clear(); - plugin.inArena.get(a).clear(); - p.performCommand("ha refill " + a); - p.sendMessage(ChatColor.GOLD + "Arena " + a + " Closed!"); - }else{ - p.sendMessage(ChatColor.RED + "Arena " + a + " already closed, type /ha open to re-open them!"); - } - }else{ - for(i = 1; i <= plugin.open.size(); i++){ - if(plugin.open.get(i)){ - plugin.open.put(i, false); - if(plugin.Playing.get(i)!= null){ - for(String players: plugin.Playing.get(i)){ - Player tributes = plugin.getServer().getPlayerExact(players); - clearInv(tributes); - tributes.teleport(tributes.getWorld().getSpawnLocation()); - } - } - if(plugin.Watching.get(i)!= null){ - for(String sname: plugin.Watching.get(i)){ - Player spectators = plugin.getServer().getPlayerExact(sname); - spectators.teleport(spectators.getWorld().getSpawnLocation()); - spectators.setAllowFlight(false); - for(Player online:plugin.getServer().getOnlinePlayers()){ - online.showPlayer(spectators); - } - } - } - plugin.Dead.clear(); - plugin.Quit.clear(); - plugin.Watching.clear(); - plugin.Frozen.clear(); - plugin.Ready.clear(); - plugin.NeedConfirm.clear(); - plugin.Out.clear(); - plugin.Playing.clear(); - plugin.inArena.clear(); - p.performCommand("ha refill"); - p.sendMessage(ChatColor.GOLD + "Arena " + i + " Closed!"); - }else{ - p.sendMessage(ChatColor.RED + "Arena " + i + " already closed, type /ha open to re-open them!"); - } - } - } - }else{ - p.sendMessage(ChatColor.RED + "No Perms!"); - } - }else if(args[0].equalsIgnoreCase("open")){ - if(p.hasPermission("HungerArena.toggle")){ - if(args.length>= 2){ - a = Integer.parseInt(args[1]); - if(!plugin.open.get(a)){ - plugin.open.put(a, true); - p.sendMessage(ChatColor.GOLD + "Arena " + a + " Open!"); - }else{ - p.sendMessage(ChatColor.RED + "Arena " + a + " already open, type /ha close to close them!"); - } - }else{ - for(i = 1; i <= plugin.open.size(); i++){ - if(!plugin.open.get(i)){ - plugin.open.put(i, true); - p.sendMessage(ChatColor.GOLD + "Arena " + i + " Open!"); - i = i+1; - }else{ - p.sendMessage(ChatColor.RED + "Arena " + i + " already open, type /ha close to close them!"); - i = i+1; - } - } - } - }else{ - p.sendMessage(ChatColor.RED + "No Perms!"); - } - //////////////////////////////////////////////////////////////////////////////////////////// - }else if(args[0].equalsIgnoreCase("Reload")){ - if(p.hasPermission("HungerArena.Reload")){ - plugin.location.clear(); - plugin.Reward.clear(); - plugin.Cost.clear(); - plugin.Fee.clear(); - plugin.onEnable(); - p.sendMessage(ChatColor.AQUA + "HungerArena Reloaded!"); - System.out.println(ChatColor.GREEN + pname + " reloaded HungerArena!"); - }else{ - p.sendMessage(ChatColor.RED + "You don't have permission"); - } - }else if(args[0].equalsIgnoreCase("WarpAll")){ - if(p.hasPermission("HungerArena.Warpall")){ - if(plugin.spawns.getString("Spawns_set").equalsIgnoreCase("false")){ - sender.sendMessage(ChatColor.RED + "/ha setspawn hasn't been run!"); - }else{ - if(args.length>= 2){ - a = Integer.parseInt(args[1]); - if(plugin.Playing.get(a).size()== 1){ - sender.sendMessage(ChatColor.RED + "There are not enough players!"); - }else{ - if(plugin.config.getString("Auto_Start").equalsIgnoreCase("true")){ - plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){ - public void run(){ - Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha start " + a); - } - }, 20L); - } - i = 1; - for(String playing:plugin.Playing.get(a)){ - Player tribute = plugin.getServer().getPlayerExact(playing); - tribute.teleport(plugin.location.get(a).get(i)); - tribute.setHealth(20); - tribute.setFoodLevel(20); - tribute.setSaturation(20); - tribute.setLevel(0); - clearInv(tribute); - for(PotionEffect pe: tribute.getActivePotionEffects()){ - PotionEffectType potion = pe.getType(); - tribute.removePotionEffect(potion); - } - if(tribute.getAllowFlight()){ - tribute.setAllowFlight(false); - } - plugin.Frozen.get(a).add(tribute.getName()); - i = i+1; - } - plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){ - public void run(){ - p.sendMessage(ChatColor.AQUA + "All Tributes warped!"); - } - }, 20L); - } - }else{ - p.sendMessage(ChatColor.RED + "Too few arguments, specify an arena"); - } - } - } - }else if(args[0].equalsIgnoreCase("Start")){ - if(p.hasPermission("HungerArena.Start")){ - if(args.length!= 2){ - p.sendMessage(ChatColor.RED + "You need an arena!"); - }else{ - a = Integer.parseInt(args[1]); - if(plugin.canjoin.get(a)== true) - p.sendMessage(ChatColor.RED + "Game already in progress!"); - else if(plugin.Playing.get(a).isEmpty()) - p.sendMessage(ChatColor.RED + "No one is in that game!"); - else - plugin.startGames(a); - } - }else{ - p.sendMessage(ChatColor.RED + "You don't have permission!"); - } - }else{ - p.sendMessage(ChatColor.RED + "Unknown command, type /ha help for a list of commands"); - } - } - } - }else if(sender instanceof ConsoleCommandSender){ - if(cmd.getName().equalsIgnoreCase("Ha")){ - if(args.length== 0){ - sender.sendMessage(ChatColor.GREEN + "[HungerArena] by " + ChatColor.AQUA + "travja! Version: " + plugin.getDescription().getVersion()); - return false; - } - if(args[0].equalsIgnoreCase("Help")){ - ChatColor c = ChatColor.AQUA; - sender.sendMessage(ChatColor.GREEN + "----HungerArena Help----"); - sender.sendMessage(c + "/ha - Displays author message!"); - sender.sendMessage(c + "/sponsor [Player] [ItemID] [Amount] - Lets you sponsor someone!"); - sender.sendMessage(c + "/startpoint [1,2,3,4,etc] [1,2,3,4,etc] - Sets the starting points of tributes in a specific arena!"); - sender.sendMessage(c + "/ha close (1,2,3,4,etc) - Prevents anyone from joining that arena! Numbers are optional"); - sender.sendMessage(c + "/ha help - Displays this screen!"); - sender.sendMessage(c + "/ha join [1,2,3,4,etc] - Makes you join the game!"); - sender.sendMessage(c + "/ha kick [Player] - Kicks a player from the arena!"); - sender.sendMessage(c + "/ha leave - Makes you leave the game!"); - sender.sendMessage(c + "/ha list (1,2,3,4,etc) - Shows a list of players in the game and their health! Numbers are optional."); - sender.sendMessage(c + "/ha open (1,2,3,4,etc) - Opens the game allowing people to join! Numbers are optional"); - sender.sendMessage(c + "/ha ready - Votes for the game to start!"); - sender.sendMessage(c + "/ha refill (1,2,3,4,etc) - Refills all chests! Numbers are optional"); - sender.sendMessage(c + "/ha reload - Reloads the config!"); - sender.sendMessage(c + "/ha restart (1,2,3,4,etc) - Restarts the game! Numbers are optional"); - sender.sendMessage(c + "/ha rlist (1,2,3,4,etc) - See who's ready! Numbers are optional"); - sender.sendMessage(c + "/ha setspawn - Sets the spawn for dead tributes!"); - sender.sendMessage(c + "/ha tp [player] - Teleports you to a tribute!"); - sender.sendMessage(c + "/ha start [1,2,3,4,etc] - Unfreezes tributes allowing them to fight!"); - sender.sendMessage(c + "/ha watch [1,2,3,4,etc] - Lets you watch the tributes!"); - sender.sendMessage(c + "/ha warpall [1,2,3,4,etc] - Warps all tribute into position!"); - sender.sendMessage(ChatColor.GREEN + "----------------------"); - return false; - }else if(args[0].equalsIgnoreCase("List")){ - if(args.length>= 2){ - try{ - a = Integer.parseInt(args[1]); - sender.sendMessage(ChatColor.AQUA + "----- Arena " + a + " -----"); - if(!plugin.Playing.get(a).isEmpty() && plugin.Playing.containsKey(a)){ - for(String playernames: plugin.Playing.get(a)){ - Player players = plugin.getServer().getPlayerExact(playernames); - sender.sendMessage(ChatColor.GREEN + playernames + " Life: " + players.getHealth() + "/20"); - } - }else{ - sender.sendMessage(ChatColor.GRAY + "No one is playing!"); - } - sender.sendMessage(ChatColor.AQUA + "---------------------"); - }catch(Exception e){ - sender.sendMessage(ChatColor.RED + "Argument not an integer!"); - } - }else{ - sender.sendMessage(ChatColor.AQUA + "----- Arena 1 -----"); - if(!plugin.Playing.get(1).isEmpty() && plugin.Playing.containsKey(1)){ - for(String playernames: plugin.Playing.get(1)){ - Player players = plugin.getServer().getPlayerExact(playernames); - sender.sendMessage(ChatColor.GREEN + playernames + " Life: " + players.getHealth() + "/20"); - } - }else{ - sender.sendMessage(ChatColor.GRAY + "No one is playing!"); - } - sender.sendMessage(ChatColor.AQUA + "---------------------"); - } - }else if(args[0].equalsIgnoreCase("rList")){ - if(args.length>= 2){ - try{ - a = Integer.parseInt(args[1]); - sender.sendMessage(ChatColor.AQUA + "----- Arena " + a + " -----"); - if(!plugin.Ready.get(a).isEmpty() && plugin.Ready.containsKey(a)){ - for(String playernames: plugin.Ready.get(a)){ - sender.sendMessage(ChatColor.GREEN + playernames); - } - }else{ - sender.sendMessage(ChatColor.GRAY + "No one is ready!"); - } - sender.sendMessage(ChatColor.AQUA + "---------------------"); - }catch(Exception e){ - sender.sendMessage(ChatColor.RED + "Argument not an integer!"); - } - }else{ - sender.sendMessage(ChatColor.AQUA + "----- Arena 1 -----"); - if(!plugin.Ready.get(1).isEmpty() && plugin.Ready.containsKey(1)){ - for(String playernames: plugin.Ready.get(1)){ - sender.sendMessage(ChatColor.GREEN + playernames); - } - }else{ - sender.sendMessage(ChatColor.GRAY + "No one is ready!"); - } - sender.sendMessage(ChatColor.AQUA + "---------------------"); - } - }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")){ - if(args.length>= 2){ - Player target = Bukkit.getPlayer(args[1]); - if(plugin.getArena(target) != null){ - a = plugin.getArena(target); - plugin.Playing.get(a).remove(target.getName()); - if(plugin.config.getBoolean("broadcastAll")){ - sender.getServer().broadcastMessage(ChatColor.RED + target.getName() + " was kicked from arena " + a + "!"); - }else{ - for(String gn: plugin.Playing.get(a)){ - Player g = plugin.getServer().getPlayer(gn); - g.sendMessage(ChatColor.RED + target.getName() + " was kicked from the game!"); - } - } - clearInv(target); - target.teleport(Spawn); - plugin.Quit.get(a).add(target.getName()); - plugin.winner(a); - }else{ - sender.sendMessage(ChatColor.RED + "That player isn't in the game!"); - } - }else{ - sender.sendMessage(ChatColor.RED + "Too few arguments"); - } - }else if(args[0].equalsIgnoreCase("Refill")){ - if(args.length>= 2){ - a = Integer.parseInt(args[1]); - 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"); - int chesta = plugin.getConfig().getInt("Storage." + xyz2 + ".Arena"); - String chestw = plugin.getConfig().getString("Storage." + xyz2 + ".Location.W"); - Block blockatlocation = Bukkit.getWorld(chestw).getBlockAt(chestx, chesty, chestz); - plugin.exists = false; - if(chesta== a){ - if(blockatlocation.getState() instanceof Chest){ - plugin.exists = true; - Chest chest = (Chest) blockatlocation.getState(); - if(chesta== a){ - 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); - chest.update(); - } - } - }else{ - list056 = list056+1; - } - } - if(limit== list056){ - sender.sendMessage(ChatColor.GREEN + "All for arena " + a + " refilled!"); - } - }else{ - 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); - chest.update(); - } - } - if(limit== list056){ - sender.sendMessage(ChatColor.GREEN + "All chests refilled!"); - } - } - }else if(args[0].equalsIgnoreCase("Restart")){ - int b = 0; - if(args.length>= 2){ - a = Integer.parseInt(args[1]); - if(!plugin.Watching.get(a).isEmpty()){ - for(b = 0; b < plugin.Watching.get(a).size(); b++){ - String s = plugin.Watching.get(a).get(b); - Player spectator = plugin.getServer().getPlayerExact(s); - spectator.setAllowFlight(false); - spectator.teleport(Spawn); - for(Player online:plugin.getServer().getOnlinePlayers()){ - online.showPlayer(spectator); - } - } - } - plugin.Dead.get(a).clear(); - plugin.Quit.get(a).clear(); - plugin.Watching.get(a).clear(); - plugin.Frozen.get(a).clear(); - plugin.Ready.get(a).clear(); - plugin.NeedConfirm.get(a).clear(); - plugin.Out.get(a).clear(); - plugin.Playing.get(a).clear(); - plugin.inArena.get(a).clear(); - plugin.canjoin.put(a, false); - plugin.open.put(a, true); - List blocksbroken = plugin.data.getStringList("Blocks_Destroyed"); - List blocksplaced = plugin.data.getStringList("Blocks_Placed"); - ArrayList toremove = new ArrayList(); - ArrayList toremove2 = new ArrayList(); - for(String blocks:blocksplaced){ - String[] coords = blocks.split(","); - World w = plugin.getServer().getWorld(coords[0]); - double x = Double.parseDouble(coords[1]); - double y = Double.parseDouble(coords[2]); - double z = Double.parseDouble(coords[3]); - int arena = Integer.parseInt(coords[4]); - int d = 0; - byte m = 0; - Location blockl = new Location(w, x, y, z); - Block block = w.getBlockAt(blockl); - if(arena== a){ - block.setTypeIdAndData(d, m, true); - block.getState().update(); - toremove.add(blocks); - } - } - for(String blocks:blocksbroken){ - String[] coords = blocks.split(","); - World w = plugin.getServer().getWorld(coords[0]); - double x = Double.parseDouble(coords[1]); - double y = Double.parseDouble(coords[2]); - double z = Double.parseDouble(coords[3]); - int d = Integer.parseInt(coords[4]); - byte m = Byte.parseByte(coords[5]); - int arena = Integer.parseInt(coords[6]); - Location blockl = new Location(w, x, y, z); - Block block = w.getBlockAt(blockl); - if(arena== a){ - block.setTypeIdAndData(d, m, true); - block.getState().update(); - toremove2.add(blocks); - } - } - for(String blocks: toremove){ - blocksplaced.remove(blocks); - } - for(String blocks: toremove2){ - blocksbroken.remove(blocks); - } - toremove.clear(); - toremove2.clear(); - plugin.data.set("Blocks_Destroyed", blocksbroken); - plugin.data.set("Blocks_Placed", blocksplaced); - plugin.data.options().copyDefaults(); - plugin.saveData(); - plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), "ha refill " + a); - sender.sendMessage(ChatColor.AQUA + "Arena " + a + " has been reset!"); - }else{ - for(i = 1; i <= plugin.Watching.size(); i++){ - for(b = 0; b < plugin.Watching.get(b).size(); b++){ - String s = plugin.Watching.get(i).get(b); - Player spectator = plugin.getServer().getPlayerExact(s); - spectator.setAllowFlight(false); - spectator.teleport(Spawn); - for(Player online:plugin.getServer().getOnlinePlayers()){ - online.showPlayer(spectator); - } - } - } - plugin.Dead.clear(); - plugin.Quit.clear(); - plugin.Watching.clear(); - plugin.Frozen.clear(); - plugin.Ready.clear(); - plugin.NeedConfirm.clear(); - plugin.Out.clear(); - plugin.Playing.clear(); - plugin.inArena.clear(); - for(i = 1; i <= plugin.canjoin.size(); i++){ - plugin.canjoin.put(i, false); - } - for(i = 1; i <= plugin.open.size(); i++){ - plugin.open.put(i, true); - } - List blocksbroken = plugin.data.getStringList("Blocks_Destroyed"); - List blocksplaced = plugin.data.getStringList("Blocks_Placed"); - for(String blocks:blocksplaced){ - String[] coords = blocks.split(","); - World w = plugin.getServer().getWorld(coords[0]); - double x = Double.parseDouble(coords[1]); - double y = Double.parseDouble(coords[2]); - double z = Double.parseDouble(coords[3]); - int d = 0; - byte m = 0; - Location blockl = new Location(w, x, y, z); - Block block = w.getBlockAt(blockl); - block.setTypeIdAndData(d, m, true); - block.getState().update(); - } - for(String blocks:blocksbroken){ - String[] coords = blocks.split(","); - World w = plugin.getServer().getWorld(coords[0]); - double x = Double.parseDouble(coords[1]); - double y = Double.parseDouble(coords[2]); - double z = Double.parseDouble(coords[3]); - int d = Integer.parseInt(coords[4]); - byte m = Byte.parseByte(coords[5]); - Location blockl = new Location(w, x, y, z); - Block block = w.getBlockAt(blockl); - block.setTypeIdAndData(d, m, true); - block.getState().update(); - } - blocksplaced.clear(); - blocksbroken.clear(); - plugin.data.set("Blocks_Destroyed", blocksbroken); - plugin.data.set("Blocks_Placed", blocksplaced); - plugin.data.options().copyDefaults(); - plugin.saveData(); - plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), "ha refill"); - sender.sendMessage(ChatColor.AQUA + "All games have been reset!"); - } - /////////////////////////////////// Toggle ////////////////////////////////////////////////// - }else if(args[0].equalsIgnoreCase("close")){ - if(args.length>= 2){ - a = Integer.parseInt(args[1]); - if(plugin.open.get(a)){ - plugin.open.put(a, false); - if(plugin.Playing.get(a)!= null){ - for(String players: plugin.Playing.get(a)){ - Player tributes = plugin.getServer().getPlayerExact(players); - clearInv(tributes); - tributes.teleport(tributes.getWorld().getSpawnLocation()); - } - } - if(plugin.Watching.get(a)!= null){ - for(String sname: plugin.Watching.get(a)){ - Player spectators = plugin.getServer().getPlayerExact(sname); - spectators.teleport(spectators.getWorld().getSpawnLocation()); - spectators.setAllowFlight(false); - for(Player online:plugin.getServer().getOnlinePlayers()){ - online.showPlayer(spectators); - } - } - } - plugin.Dead.get(a).clear(); - plugin.Quit.get(a).clear(); - plugin.Watching.get(a).clear(); - plugin.Frozen.get(a).clear(); - plugin.Ready.get(a).clear(); - plugin.NeedConfirm.get(a).clear(); - plugin.Out.get(a).clear(); - plugin.Playing.get(a).clear(); - plugin.inArena.get(a).clear(); - Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha refill " + a); - sender.sendMessage(ChatColor.GOLD + "Arena " + a + " Closed!"); - }else{ - sender.sendMessage(ChatColor.RED + "Arena " + a + " already closed, type /ha open to re-open them!"); - } - }else{ - for(i = 1; i <= plugin.open.size(); i++){ - if(plugin.open.get(i)){ - plugin.open.put(i, false); - if(plugin.Playing.get(i)!= null){ - for(String players: plugin.Playing.get(i)){ - Player tributes = plugin.getServer().getPlayerExact(players); - clearInv(tributes); - tributes.teleport(tributes.getWorld().getSpawnLocation()); - } - } - if(plugin.Watching.get(i)!= null){ - for(String sname: plugin.Watching.get(i)){ - Player spectators = plugin.getServer().getPlayerExact(sname); - spectators.teleport(spectators.getWorld().getSpawnLocation()); - spectators.setAllowFlight(false); - for(Player online:plugin.getServer().getOnlinePlayers()){ - online.showPlayer(spectators); - } - } - } - plugin.Dead.clear(); - plugin.Quit.clear(); - plugin.Watching.clear(); - plugin.Frozen.clear(); - plugin.Ready.clear(); - plugin.NeedConfirm.clear(); - plugin.Out.clear(); - plugin.Playing.clear(); - plugin.inArena.clear(); - Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha refill"); - sender.sendMessage(ChatColor.GOLD + "Arena " + i + " Closed!"); - }else{ - sender.sendMessage(ChatColor.RED + "Arena " + i + " already closed, type /ha open to re-open them!"); - } - } - } - }else if(args[0].equalsIgnoreCase("open")){ - if(args.length>= 2){ - a = Integer.parseInt(args[1]); - if(!plugin.open.get(a)){ - plugin.open.put(a, true); - sender.sendMessage(ChatColor.GOLD + "Arena " + a + " Open!"); - }else{ - sender.sendMessage(ChatColor.RED + "Arena " + a + " already open, type /ha close to close them!"); - } - }else{ - for(i = 1; i <= plugin.open.size(); i++){ - if(!plugin.open.get(i)){ - plugin.open.put(i, true); - sender.sendMessage(ChatColor.GOLD + "Arena " + a + " Open!"); - }else{ - sender.sendMessage(ChatColor.RED + "Arena " + a + " already open, type /ha close to close them!"); - } - } - } - //////////////////////////////////////////////////////////////////////////////////////////// - }else if(args[0].equalsIgnoreCase("Reload")){ - plugin.location.clear(); - plugin.Reward.clear(); - plugin.Cost.clear(); - plugin.Fee.clear(); - plugin.onEnable(); - sender.sendMessage(ChatColor.AQUA + "HungerArena Reloaded!"); - }else if(args[0].equalsIgnoreCase("WarpAll")){ - if(plugin.spawns.getString("Spawns_set").equalsIgnoreCase("false")){ - sender.sendMessage(ChatColor.RED + "/ha setspawn hasn't been run!"); - }else{ - if(args.length>= 2){ - a = Integer.parseInt(args[1]); - if(plugin.Playing.get(a).size()== 1){ - sender.sendMessage(ChatColor.RED + "There are not enough players!"); - }else{ - if(plugin.config.getString("Auto_Start").equalsIgnoreCase("true")){ - plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){ - public void run(){ - Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha start " + a); - } - }, 20L); - } - i = 1; - for(String playing: plugin.Playing.get(a)){ - Player tribute = plugin.getServer().getPlayerExact(playing); - tribute.teleport(plugin.location.get(a).get(i)); - tribute.setHealth(20); - tribute.setFoodLevel(20); - tribute.setSaturation(20); - tribute.setLevel(0); - clearInv(tribute); - for(PotionEffect pe: tribute.getActivePotionEffects()){ - PotionEffectType potion = pe.getType(); - tribute.removePotionEffect(potion); - } - if(tribute.getAllowFlight()){ - tribute.setAllowFlight(false); - } - plugin.Frozen.get(a).add(tribute.getName()); - i = i+1; - } - plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){ - public void run(){ - sender.sendMessage(ChatColor.AQUA + "All Tributes warped!"); - } - }, 20L); - } - }else{ - sender.sendMessage(ChatColor.RED + "Too few arguments, specify an arena"); - } - } - }else if(args[0].equalsIgnoreCase("Start")){ - if(args.length!= 2){ - sender.sendMessage(ChatColor.RED + "You need an arena!"); - }else{ - a = Integer.parseInt(args[1]); - if(plugin.canjoin.get(a)== true) - sender.sendMessage(ChatColor.RED + "Game already in progress!"); - else if(plugin.Playing.get(a).isEmpty()) - sender.sendMessage(ChatColor.RED + "No one is in that game!"); - else - plugin.startGames(a); - } - }else{ - sender.sendMessage(ChatColor.RED + "Unknown command, type /ha help to see all commands!"); - } - } - } - return false; - } -} diff --git a/src/me/travja/hungerarena/Main.java b/src/me/travja/hungerarena/Main.java deleted file mode 100644 index cb144ba..0000000 --- a/src/me/travja/hungerarena/Main.java +++ /dev/null @@ -1,511 +0,0 @@ -package me.Travja.HungerArena; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.logging.Level; -import java.util.logging.Logger; - -import net.milkbowl.vault.economy.Economy; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.WorldCreator; -import org.bukkit.command.CommandExecutor; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.entity.Player; -import org.bukkit.event.Listener; -import org.bukkit.inventory.ItemStack; -import org.bukkit.plugin.RegisteredServiceProvider; -import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; - -public class Main extends JavaPlugin{ - static Logger log; - public HashMap> Playing = new HashMap>(); - public HashMap> Ready = new HashMap>(); - public HashMap> Dead = new HashMap>(); - public HashMap> Quit = new HashMap>(); - public HashMap> Out = new HashMap>(); - public HashMap> Watching = new HashMap>(); - public HashMap> NeedConfirm = new HashMap>(); - public HashMap> location = new HashMap>(); - public ArrayList Tele = new ArrayList(); - public HashMap> inArena = new HashMap>(); - public HashMap> Frozen = new HashMap>(); - public HashMap> arena = new HashMap>(); - public HashMap canjoin = new HashMap(); - public HashMap maxPlayers = new HashMap(); - public HashMap open = new HashMap(); - public List worlds; - public Listener DeathListener = new DeathListener(this); - public Listener SpectatorListener = new SpectatorListener(this); - public Listener FreezeListener = new FreezeListener(this); - public Listener JoinAndQuitListener = new JoinAndQuitListener(this); - public Listener ChatListener = new ChatListener(this); - public Listener Chests = new Chests(this); - public Listener PvP = new PvP(this); - public Listener CommandBlock = new CommandBlock(this); - public Listener Damage = new DmgListener(this); - public Listener Teleport = new TeleportListener(this); - public Listener Signs = new Signs(this); - public Listener BlockStorage = new BlockStorage(this); - public Listener WinGames = new WinGamesListener(this); - public CommandExecutor HaCommands = new HaCommands(this); - public CommandExecutor SponsorCommands = new SponsorCommands(this); - public CommandExecutor SpawnsCommand = new SpawnsCommand(this); - public boolean exists; - public boolean restricted; - public FileConfiguration config; - public FileConfiguration spawns = null; - public File spawnsFile = null; - public FileConfiguration data = null; - public File dataFile = null; - public File managementFile = null; - public FileConfiguration management = null; - public ArrayList Reward = new ArrayList(); - public ArrayList Cost = new ArrayList(); - public ArrayList Fee = new ArrayList(); - public boolean vault = false; - public boolean eco = false; - public Economy econ = null; - int i = 0; - int v = 0; - int start = 0; - int deathtime = 0; - int timetodeath = 0; - int a = 0; - public void onEnable(){ - log = this.getLogger(); - config = this.getConfig(); - config.options().copyDefaults(true); - this.saveDefaultConfig(); - spawns = this.getSpawns(); - spawns.options().copyDefaults(true); - this.saveSpawns(); - data = this.getData(); - data.options().copyDefaults(true); - this.saveData(); - management = this.getManagement(); - management.options().copyDefaults(true); - this.saveManagement(); - getServer().getPluginManager().registerEvents(DeathListener, this); - getServer().getPluginManager().registerEvents(SpectatorListener, this); - getServer().getPluginManager().registerEvents(FreezeListener, this); - getServer().getPluginManager().registerEvents(JoinAndQuitListener, this); - getServer().getPluginManager().registerEvents(ChatListener, this); - getServer().getPluginManager().registerEvents(Chests, this); - getServer().getPluginManager().registerEvents(PvP, this); - getServer().getPluginManager().registerEvents(CommandBlock, this); - getServer().getPluginManager().registerEvents(Signs, this); - getServer().getPluginManager().registerEvents(BlockStorage, this); - getServer().getPluginManager().registerEvents(WinGames, this); - getServer().getPluginManager().registerEvents(Damage, this); - getCommand("Ha").setExecutor(HaCommands); - getCommand("Sponsor").setExecutor(SponsorCommands); - getCommand("Startpoint").setExecutor(SpawnsCommand); - i = 1; - //TODO THIS CRAP - if(spawns.getConfigurationSection("Spawns")!= null){ - Map temp = spawns.getConfigurationSection("Spawns").getValues(false); - for(Entry entry: temp.entrySet()){ - if(spawns.getConfigurationSection("Spawns." + entry.getKey())!= null){ - Map temp2 = spawns.getConfigurationSection("Spawns." + entry.getKey()).getValues(false); - for(Map.Entry e: temp2.entrySet()){ - if(spawns.get("Spawns." + entry.getKey() + "." + e.getKey())!= null){ - String[] coords = ((String) spawns.get("Spawns." + entry.getKey() + "." + e.getKey())).split(","); - Integer a = Integer.parseInt(entry.getKey()); - Integer s = Integer.parseInt(e.getKey()); - if(location.get(a)== null) - location.put(a, new HashMap()); - log.info("Added spawn number " + s + " in arena " + a + "!"); - location.get(a).put(s, new Location(getServer().getWorld(coords[0]), Double.parseDouble(coords[1]), Double.parseDouble(coords[2]), Double.parseDouble(coords[3]))); - } - } - } - } - } - for(i = 1; i <= location.size(); i++){ - log.info("Loaded " + location.get(i).size() + " tribute spawns for arena " + i + "!"); - Playing.put(i, new ArrayList()); - Ready.put(i, new ArrayList()); - Dead.put(i, new ArrayList()); - Quit.put(i, new ArrayList()); - Out.put(i, new ArrayList()); - Watching.put(i, new ArrayList()); - NeedConfirm.put(i, new ArrayList()); - inArena.put(i, new ArrayList()); - Frozen.put(i, new ArrayList()); - arena.put(i, new ArrayList()); - canjoin.put(i, false); - if(location.get(i).size()== config.getInt("maxPlayers")){ - maxPlayers.put(i, location.get(i).size()); - }else if(location.size()< config.getInt("maxPlayers")){ - maxPlayers.put(i, location.get(i).size()); - }else if(location.size()> config.getInt("maxPlayers")){ - maxPlayers.put(i, config.getInt("maxPlayers")); - } - log.info("Max players is for arena " + i + " is " + maxPlayers.get(i)); - open.put(i, true); - } - if (setupEconomy()) { - log.info("Found Vault! Hooking in for economy!"); - } - if (config.getDouble("config.version") != 1.3) { - config.set("config.version", 1.3); - config.set("rewardEco.enabled", false); - config.set("rewardEco.reward", 100); - } - if (config.getBoolean("rewardEco.enabled", true) || config.getBoolean("sponsorEco.enabled", true) || config.getBoolean("EntryFee.eco", true)) { - if (vault == true) { - log.info("Economy hook deployed."); - eco = true; - }else{ - log.info("You want economy support... yet you either don't have Vault or don't have an economy plugin. Sorry, can't give you it."); - } - } - if (!eco) { - if (vault == true) { - log.info("We see that you have Vault on your server. To set economy support to true, enable it in the config."); - } - } - try{ - for(String rewards: config.getStringList("Reward")){ - String[] rinfo = rewards.split(","); - Reward.add(new ItemStack(Integer.parseInt(rinfo[0]), Integer.parseInt(rinfo[1]))); - } - for(String scost: config.getStringList("Sponsor_Cost")){ - String[] sinfo = scost.split(","); - Cost.add(new ItemStack(Integer.parseInt(sinfo[0]), Integer.parseInt(sinfo[1]))); - } - if(config.getBoolean("EntryFee.enabled")){ - for(String fee: config.getStringList("EntryFee.fee")){ - String[] finfo = fee.split(","); - Fee.add(new ItemStack(Integer.parseInt(finfo[0]), Integer.parseInt(finfo[1]))); - } - } - }catch(Exception e){ - log.warning("Could not add a reward/sponsor/entry cost! One of the rewards/costs is not a number!"); - } - worlds = config.getStringList("worlds"); - if(worlds.isEmpty()){ - restricted = false; - }else if(!worlds.isEmpty()){ - restricted = true; - } - log.info("Enabled v" + getDescription().getVersion()); - } - - public void onDisable(){ - log.info("Disabled v" + getDescription().getVersion()); - } - - public boolean setupEconomy() { - if (getServer().getPluginManager().getPlugin("Vault") == null) { - return false; - } - RegisteredServiceProvider rsp = getServer().getServicesManager().getRegistration(Economy.class); - if (rsp == null) { - return false; - } - econ = rsp.getProvider(); - vault = true; - return econ != null; - } - public void reloadSpawns() { - if (spawnsFile == null) { - spawnsFile = new File(getDataFolder(), "spawns.yml"); - } - spawns = YamlConfiguration.loadConfiguration(spawnsFile); - - // Look for defaults in the jar - InputStream defConfigStream = this.getResource("spawns.yml"); - if (defConfigStream != null) { - YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream); - spawns.setDefaults(defConfig); - } - } - public FileConfiguration getSpawns() { - if (spawns == null) { - this.reloadSpawns(); - } - return spawns; - } - public void saveSpawns() { - if (spawns == null || spawnsFile == null) { - return; - } - try { - getSpawns().save(spawnsFile); - } catch (IOException ex) { - this.getLogger().log(Level.SEVERE, "Could not save config to " + spawnsFile, ex); - } - } - public void reloadData() { - if (dataFile == null) { - dataFile = new File(getDataFolder(), "Data.yml"); - } - data = YamlConfiguration.loadConfiguration(dataFile); - - // Look for defaults in the jar - InputStream defConfigStream = this.getResource("Data.yml"); - if (defConfigStream != null) { - YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream); - data.setDefaults(defConfig); - } - } - public FileConfiguration getData() { - if (data == null) { - this.reloadData(); - } - return data; - } - public void saveData() { - if (data == null || dataFile == null) { - return; - } - try { - getData().save(dataFile); - } catch (IOException ex) { - this.getLogger().log(Level.SEVERE, "Could not save config to " + dataFile, ex); - } - } - public void reloadManagement() { - if (managementFile == null) { - managementFile = new File(getDataFolder(), "commandAndBlockManagement.yml"); - } - management = YamlConfiguration.loadConfiguration(managementFile); - - // Look for defaults in the jar - InputStream defConfigStream = this.getResource("commandAndBlockManagement.yml"); - if (defConfigStream != null) { - YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream); - management.setDefaults(defConfig); - } - } - public FileConfiguration getManagement() { - if (management == null) { - this.reloadManagement(); - } - return management; - } - public void saveManagement() { - if (management == null || managementFile == null) { - return; - } - try { - getManagement().save(managementFile); - } catch (IOException ex) { - this.getLogger().log(Level.SEVERE, "Could not save config to " + managementFile, ex); - } - } - public void winner(Integer a){ - String[] Spawncoords = spawns.getString("Spawn_coords").split(","); - World spawnw = 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(Playing.get(a).size()== 1 && canjoin.get(a)== true){ - //Announce winner - for(i = 0; i < Playing.get(a).size(); i++){ - String winnername = Playing.get(a).get(i); - Player winner = getServer().getPlayerExact(winnername); - String winnername2 = winner.getName(); - 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.setLevel(0); - for(PotionEffect pe: winner.getActivePotionEffects()){ - PotionEffectType potion = pe.getType(); - winner.removePotionEffect(potion); - } - Tele.add(winner); - final World w = winner.getWorld(); - winner.teleport(Spawn); - if(config.getBoolean("reloadWorld")){ - getServer().unloadWorld(w, false); - getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){ - public void run(){ - getServer().createWorld(new WorldCreator(w.getName())); - } - },200L); - } - if(!config.getBoolean("rewardEco.enabled")){ - for(ItemStack Rewards: Reward){ - winner.getInventory().addItem(Rewards); - } - }else{ - for(ItemStack Rewards: Reward){ - winner.getInventory().addItem(Rewards); - } - econ.depositPlayer(winner.getName(), config.getDouble("rewardEco.reward")); - } - Playing.get(a).clear(); - getServer().getScheduler().cancelTask(deathtime); - } - //Show spectators - for(String s1: Watching.get(a)){ - Player spectator = getServer().getPlayerExact(s1); - spectator.setAllowFlight(false); - spectator.teleport(Spawn); - for(Player online:getServer().getOnlinePlayers()){ - online.showPlayer(spectator); - } - } - if(config.getString("Auto_Restart").equalsIgnoreCase("True")){ - Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){ - public void run(){ - Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha restart"); - - } - }, 220L); - } - } - } - public void startGames(final Integer a){ - String begin = config.getString("Start_Message"); - begin = begin.replaceAll("(&([a-f0-9]))", "\u00A7$2"); - final String msg = begin; - i = 10; - if(config.getString("Countdown").equalsIgnoreCase("true")){ - start = getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){ - public void run(){ - if(i > 0){ - if(worlds.isEmpty()){ - if(config.getBoolean("broadcastAll")){ - getServer().broadcastMessage(String.valueOf(i)); - }else{ - for(String gn: Playing.get(a)){ - Player g = getServer().getPlayer(gn); - g.sendMessage(String.valueOf(i)); - } - } - }else{ - for(String world: worlds){ - World w = getServer().getWorld(world); - if(config.getBoolean("broadcastAll")){ - for(Player wp: w.getPlayers()){ - wp.sendMessage(String.valueOf(i)); - } - }else{ - for(String gn: Playing.get(a)){ - Player g = getServer().getPlayer(gn); - g.sendMessage(String.valueOf(i)); - } - } - } - } - } - i = i-1; - canjoin.put(a, true); - if(i== -1){ - if(Frozen.get(a)!= null) - Frozen.get(a).clear(); - if(config.getBoolean("broadcastAll")){ - getServer().broadcastMessage(msg); - }else{ - for(String gn: Playing.get(a)){ - Player g = getServer().getPlayer(gn); - g.sendMessage(msg); - } - } - getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha Refill " + a); - getServer().getScheduler().cancelTask(start); - if(config.getInt("DeathMatch")!= 0){ - int death = config.getInt("DeathMatch"); - timetodeath = death; - deathtime = getServer().getScheduler().scheduleSyncRepeatingTask(Bukkit.getPluginManager().getPlugin("HungerArena"), new Runnable(){ - public void run(){ - timetodeath = timetodeath-1; - if(config.getBoolean("broadcastAll")){ - for(Player wp: location.get(a).get(0).getWorld().getPlayers()){ - if(timetodeath!= 0){ - wp.sendMessage(ChatColor.RED + String.valueOf(timetodeath) + " mins till the death match!"); - } - } - }else{ - for(String gn: Playing.get(a)){ - Player g = getServer().getPlayer(gn); - g.sendMessage(ChatColor.RED + String.valueOf(timetodeath) + " mins till the death match!"); - } - } - if(timetodeath== 0){ - for(String playing: Playing.get(a)){ - Player tribute = getServer().getPlayerExact(playing); - tribute.teleport(location.get(a).get(i)); - i = i+1; - for(PotionEffect pe: tribute.getActivePotionEffects()){ - PotionEffectType potion = pe.getType(); - tribute.removePotionEffect(potion); - } - if(tribute.getAllowFlight()){ - tribute.setAllowFlight(false); - } - } - if(config.getBoolean("broadcastAll")){ - for(Player wp: location.get(a).get(0).getWorld().getPlayers()){ - wp.sendMessage(ChatColor.RED + "The final battle has begun! " + Playing.size() + " tributes will be facing off!"); - } - }else{ - for(String gn: Playing.get(a)){ - Player g = getServer().getPlayer(gn); - g.sendMessage(ChatColor.RED + "The final battle has begun! " + Playing.size() + " tributes will be facing off!"); - } - } - getServer().getScheduler().cancelTask(deathtime); - } - } - }, 1200L, 1200L); - } - } - } - }, 20L, 20L); - }else{ - Frozen.get(a).clear(); - if(config.getBoolean("broadcastAll")){ - getServer().broadcastMessage(msg); - }else{ - for(String gn: Playing.get(a)){ - Player g = getServer().getPlayer(gn); - g.sendMessage(msg); - } - } - canjoin.put(a, true); - getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha Refill " + a); - } - } - public Integer getArena(Player p){ - for (int x: Playing.keySet()) { - if (Playing.get(x).contains(p.getName())){ - return x; - } - } - return null; - } - public boolean isSpectating(Player p){ - int x = 0; - if(!Watching.isEmpty()){ - for(x= 1; x <= Watching.size(); x++){ - if(Watching.get(x).contains(p.getName())){ - x = Watching.size()+1; - return true; - }else if(Watching.size()== x) - return false; - } - } - return false; - } -}