diff --git a/src/me/travja/HungerArena/BlockStorage.java b/src/me/travja/HungerArena/BlockStorage.java index 1d2f14c..1ce0492 100644 --- a/src/me/travja/HungerArena/BlockStorage.java +++ b/src/me/travja/HungerArena/BlockStorage.java @@ -25,41 +25,80 @@ public class BlockStorage implements Listener { public BlockStorage(Main m) { this.plugin = m; } - @EventHandler(priority=EventPriority.MONITOR) - public void BlockBreak(BlockBreakEvent event) { + @EventHandler(priority = EventPriority.MONITOR) + public void BlockBreak(BlockBreakEvent event){ Block b = event.getBlock(); Player p = event.getPlayer(); String pname = p.getName(); - boolean protall = false; - if (plugin.config.getString("Protected_Arena_Allways").equalsIgnoreCase("True")) { /* Jeppa Fix/Add */ - protall = true; - } - if ((plugin.getArena(p) != null) || (protall)) { /* Bug1a */ - //int a = this.plugin.getArena(p).intValue(); - int a = 1; //Jeppa: define a default (may be needed if protall is true) - if (plugin.getArena(p) != null) a = plugin.getArena(p); - if ((!event.isCancelled()) && (((plugin.Playing.get(a)).contains(pname)) || (protall))) /* Bug1a */ - { - if (plugin.config.getString("Protected_Arena").equalsIgnoreCase("True")) { - event.setCancelled(true); /* Jeppa fix Bug1 */ - p.sendMessage(ChatColor.RED + "You can't break blocks while playing!"); - } else if ((((plugin.canjoin.get(a))) || (protall)) && ((plugin.config.getStringList("worlds").isEmpty()) || ((!plugin.config.getStringList("worlds").isEmpty()) && (plugin.config.getStringList("worlds").contains(p.getWorld().getName()))))) { /* Klammer fehlte! */ - if (((plugin.management.getIntegerList("blocks.whitelist").isEmpty()) || ((!plugin.management.getIntegerList("blocks.whitelist").isEmpty()) && (!plugin.management.getIntegerList("blocks.whitelist").contains(Integer.valueOf(b.getTypeId()))))) ^ (plugin.management.getBoolean("blocks.useWhitelistAsBlacklist"))) { - 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(); + 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(); + } + } + } } } } diff --git a/src/me/travja/HungerArena/CommandBlock.java b/src/me/travja/HungerArena/CommandBlock.java index e3626e0..fdb28de 100644 --- a/src/me/travja/HungerArena/CommandBlock.java +++ b/src/me/travja/HungerArena/CommandBlock.java @@ -20,19 +20,14 @@ public class CommandBlock implements Listener { String pname = p.getName(); int i = 0; int x = 0; - boolean found = false; 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")){ - if(cmd.toLowerCase().startsWith(whitelist.toLowerCase())){ // Jeppa: check for ALL whitelist commands - found = true; - i = plugin.management.getStringList("commands.whitelist").size()-1; - } i = i+1; if(i== plugin.management.getStringList("commands.whitelist").size()){ - if(!found && !cmd.toLowerCase().startsWith("/ha")){ //Jeppa: must be && ;) + 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")){ @@ -75,13 +70,9 @@ public class CommandBlock implements Listener { if(!p.hasPermission("HungerArena.UseCommands")){ if(!plugin.management.getStringList("commands.whitelist").isEmpty()){ for(String whitelist: plugin.management.getStringList("commands.whitelist")){ - if(cmd.toLowerCase().startsWith(whitelist.toLowerCase())){ - found = true; - i = plugin.management.getStringList("commands.whitelist").size()-1; - } i = i+1; - if(i== plugin.management.getStringList("commands.whitelist").size()){ // Abbruch bei max. Anzahl - if(!found && !cmd.toLowerCase().startsWith("/ha")){ // with the two invertet forms it must be && ;) + 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")){ @@ -118,7 +109,6 @@ public class CommandBlock implements Listener { p.sendMessage("You have perms for all commands except this one!"); } } -//commands while not playing... }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)) diff --git a/src/me/travja/HungerArena/HaCommands.java b/src/me/travja/HungerArena/HaCommands.java index 1eb3567..40d1b51 100644 --- a/src/me/travja/HungerArena/HaCommands.java +++ b/src/me/travja/HungerArena/HaCommands.java @@ -14,7 +14,6 @@ import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.entity.Player; -import org.bukkit.event.HandlerList; //Jeppa : add for eventremoval... import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; @@ -508,11 +507,11 @@ public class HaCommands implements CommandExecutor { } } }else if(args[0].equalsIgnoreCase("Ready")){ - // p.sendMessage("debug: Arena: " + String.valueOf(plugin.getArena(p))); // Jeppa: das ist debug! + p.sendMessage(String.valueOf(plugin.getArena(p))); if(plugin.getArena(p)!= null){ a = plugin.getArena(p); - // for(String s:plugin.Playing.get(a)) // Jeppa: das ist debug! - // p.sendMessage("Debug: Player:"+a+" : " + s); // Jeppa: das ist debug! + 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!"); @@ -734,38 +733,18 @@ public class HaCommands implements CommandExecutor { }else{ p.sendMessage(ChatColor.RED + "You don't have permission!"); } - }else if(args[0].equalsIgnoreCase("Restart")){ //Jeppa: fixed reopen , merged routines, added respawn + }else if(args[0].equalsIgnoreCase("Restart")){ int b = 0; if(p.hasPermission("HungerArena.Restart")){ - // Jeppa: merged the two routines and fixed reopen bug... - i = 1; // default first arena - int e = plugin.open.size(); // default amount number of arenas if(args.length>= 2){ - i = Integer.parseInt(args[1]); // replace i with commandvalue - if(i > e) i=e; // dirty fix for wrong args in command... - if(i < 1) i=1; // dirty fix for wrong args in command... - e = i; // loop i to i ;) - } - for(a = i; a <= e; a++){ - //Jeppa: Routine dazu: erweitert um Teleport der Player!!!!! - if(plugin.Playing.get(a).size() > 0){ // Jeppa: fix - for(b = 0; b < plugin.Playing.get(a).size(); b++){ - String s = plugin.Playing.get(a).get(b); - Player tributes = plugin.getServer().getPlayerExact(s); - clearInv(tributes); - tributes.teleport(tributes.getWorld().getSpawnLocation()); - } - } - // ^^ - if(plugin.Watching.get(a).size() > 0){ // Jeppa: fix - 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); - } + 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(); @@ -831,6 +810,71 @@ public class HaCommands implements CommandExecutor { 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!"); @@ -838,16 +882,8 @@ public class HaCommands implements CommandExecutor { /////////////////////////////////// Toggle ////////////////////////////////////////////////// }else if(args[0].equalsIgnoreCase("close")){ if(p.hasPermission("HungerArena.toggle")){ - // Jeppa: merged the two routines and fixed reopen bug... - i = 1; // default first arena - int e = plugin.open.size(); // default amount number of arenas if(args.length>= 2){ - i = Integer.parseInt(args[1]); // replace i with commandvalue - if(i > e) i=e; // dirty fix for wrong args in command... - if(i < 1) i=1; // dirty fix for wrong args in command... - e = i; // loop i to i ;) - } - for(a = i; a <= e; a++){ + a = Integer.parseInt(args[1]); if(plugin.open.get(a)){ plugin.open.put(a, false); if(plugin.Playing.get(a)!= null){ @@ -881,6 +917,42 @@ public class HaCommands implements CommandExecutor { }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!"); @@ -900,10 +972,10 @@ public class HaCommands implements CommandExecutor { if(!plugin.open.get(i)){ plugin.open.put(i, true); p.sendMessage(ChatColor.GOLD + "Arena " + i + " Open!"); - // i = i+1; // Jeppa: ??? + i = i+1; }else{ p.sendMessage(ChatColor.RED + "Arena " + i + " already open, type /ha close to close them!"); - // i = i+1; + i = i+1; } } } @@ -917,8 +989,7 @@ public class HaCommands implements CommandExecutor { plugin.Reward.clear(); plugin.Cost.clear(); plugin.Fee.clear(); - HandlerList.unregisterAll(plugin); //Jeppa: Close all running Listeners before reopening them! - plugin.onEnable(); //Jeppa: with this in here all Listeners get re-registered again each "reload"! so f.e the Block-break will result in multiple lines in Data.yml ... + plugin.onEnable(); p.sendMessage(ChatColor.AQUA + "HungerArena Reloaded!"); System.out.println(ChatColor.GREEN + pname + " reloaded HungerArena!"); }else{ @@ -1177,28 +1248,10 @@ public class HaCommands implements CommandExecutor { sender.sendMessage(ChatColor.GREEN + "All chests refilled!"); } } - }else if(args[0].equalsIgnoreCase("Restart")){ //Jeppa: merged , fixed + }else if(args[0].equalsIgnoreCase("Restart")){ int b = 0; - // Jeppa: merged the two routines and fixed reopen bug... - i = 1; // default first arena - int e = plugin.open.size(); // default amount number of arenas if(args.length>= 2){ - i = Integer.parseInt(args[1]); // replace i with commandvalue - if(i > e) i=e; // dirty fix for wrong args in command... - if(i < 1) i=1; // dirty fix for wrong args in command... - e = i; // loop i to i ;) - } - for(a = i; a <= e; a++){ - //Jeppa: Routine dazu: erweitert um Teleport der Player!!!!! - if(!plugin.Playing.get(a).isEmpty()){ - for(b = 0; b < plugin.Playing.get(a).size(); b++){ - String s = plugin.Playing.get(a).get(b); - Player tributes = plugin.getServer().getPlayerExact(s); - clearInv(tributes); - tributes.teleport(tributes.getWorld().getSpawnLocation()); - } - } - // ^^ + 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); @@ -1273,19 +1326,74 @@ public class HaCommands implements CommandExecutor { 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")){ - // Jeppa: merged the two routines and fixed reopen bug... - i = 1; // default first arena - int e = plugin.open.size(); // default amount number of arenas if(args.length>= 2){ - i = Integer.parseInt(args[1]); // replace i with commandvalue - if(i > e) i=e; // dirty fix for wrong args in command... - if(i < 1) i=1; // dirty fix for wrong args in command... - e = i; // loop i to i ;) - } - for(a = i; a <= e; a++){ + a = Integer.parseInt(args[1]); if(plugin.open.get(a)){ plugin.open.put(a, false); if(plugin.Playing.get(a)!= null){ @@ -1319,8 +1427,44 @@ public class HaCommands implements CommandExecutor { }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")){ // Jeppa: i / a fixed ;) + }else if(args[0].equalsIgnoreCase("open")){ if(args.length>= 2){ a = Integer.parseInt(args[1]); if(!plugin.open.get(a)){ @@ -1333,9 +1477,9 @@ public class HaCommands implements CommandExecutor { for(i = 1; i <= plugin.open.size(); i++){ if(!plugin.open.get(i)){ plugin.open.put(i, true); - sender.sendMessage(ChatColor.GOLD + "Arena " + i + " Open!"); + sender.sendMessage(ChatColor.GOLD + "Arena " + a + " Open!"); }else{ - sender.sendMessage(ChatColor.RED + "Arena " + i + " already open, type /ha close to close them!"); + sender.sendMessage(ChatColor.RED + "Arena " + a + " already open, type /ha close to close them!"); } } } @@ -1345,7 +1489,6 @@ public class HaCommands implements CommandExecutor { plugin.Reward.clear(); plugin.Cost.clear(); plugin.Fee.clear(); - HandlerList.unregisterAll(plugin); //Jeppa: Close all running Listeners before reopening them! plugin.onEnable(); sender.sendMessage(ChatColor.AQUA + "HungerArena Reloaded!"); }else if(args[0].equalsIgnoreCase("WarpAll")){ diff --git a/src/me/travja/HungerArena/Main.java b/src/me/travja/HungerArena/Main.java index c5be8f0..cb144ba 100644 --- a/src/me/travja/HungerArena/Main.java +++ b/src/me/travja/HungerArena/Main.java @@ -114,7 +114,7 @@ public class Main extends JavaPlugin{ getCommand("Sponsor").setExecutor(SponsorCommands); getCommand("Startpoint").setExecutor(SpawnsCommand); i = 1; - //TODO THIS CRAP /* Jeppa: Wasn't this already done ??? */ + //TODO THIS CRAP if(spawns.getConfigurationSection("Spawns")!= null){ Map temp = spawns.getConfigurationSection("Spawns").getValues(false); for(Entry entry: temp.entrySet()){ @@ -315,7 +315,6 @@ public class Main extends JavaPlugin{ double spawny = Double.parseDouble(Spawncoords[1]); double spawnz = Double.parseDouble(Spawncoords[2]); Location Spawn = new Location(spawnw, spawnx, spawny, spawnz); - final String a2 = String.valueOf(a); // Jeppa Test if(Playing.get(a).size()== 1 && canjoin.get(a)== true){ //Announce winner for(i = 0; i < Playing.get(a).size(); i++){ @@ -369,7 +368,8 @@ public class Main extends JavaPlugin{ if(config.getString("Auto_Restart").equalsIgnoreCase("True")){ Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){ public void run(){ - Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha restart " + a2); + Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha restart"); + } }, 220L); } @@ -379,12 +379,7 @@ public class Main extends JavaPlugin{ String begin = config.getString("Start_Message"); begin = begin.replaceAll("(&([a-f0-9]))", "\u00A7$2"); final String msg = begin; - /* Jeppa add : */ - if(config.getInt("Countdown_Timer") != 0) { - i = config.getInt("Countdown_Timer") ; - } else { - i = 10; - } + i = 10; if(config.getString("Countdown").equalsIgnoreCase("true")){ start = getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){ public void run(){