3/15 - Most recent Dev

This commit is contained in:
travja 2013-03-15 23:07:55 -06:00
parent 444ec3ea01
commit 482e3e8e55
16 changed files with 289 additions and 220 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -53,27 +53,29 @@ public class Chests implements Listener {
int a = plugin.getArena(p); int a = plugin.getArena(p);
if(plugin.Playing.get(a).contains(p.getName()) && plugin.canjoin.get(a)){ if(plugin.Playing.get(a).contains(p.getName()) && plugin.canjoin.get(a)){
if(!plugin.restricted || (plugin.restricted && plugin.worlds.contains(p.getWorld().getName()))){ if(!plugin.restricted || (plugin.restricted && plugin.worlds.contains(p.getWorld().getName()))){
if(block.getState() instanceof Chest){ if(block!= null){
ItemStack[] itemsinchest = ((Chest) block.getState()).getInventory().getContents(); if(block.getState() instanceof Chest){
int blockx = block.getX(); ItemStack[] itemsinchest = ((Chest) block.getState()).getInventory().getContents();
int blocky = block.getY(); int blockx = block.getX();
int blockz = block.getZ(); int blocky = block.getY();
String blockw = block.getWorld().getName().toString(); int blockz = block.getZ();
if(!plugin.getConfig().contains("Storage." + blockx + "," + blocky + "," + blockz + ".Location.X")){ String blockw = block.getWorld().getName().toString();
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.X", blockx); if(!plugin.getConfig().contains("Storage." + blockx + "," + blocky + "," + blockz + ".Location.X")){
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Y", blocky); plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.X", blockx);
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Z",blockz); plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Y", blocky);
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.W", blockw); plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Z",blockz);
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".ItemsInStorage", itemsinchest); plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.W", blockw);
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Arena", a); plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".ItemsInStorage", itemsinchest);
} plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Arena", a);
List<String> list2 = plugin.getConfig().getStringList("StorageXYZ"); }
if(!list2.contains(blockx + "," + blocky + "," + blockz)){ List<String> list2 = plugin.getConfig().getStringList("StorageXYZ");
list2.add(blockx + "," + blocky + "," + blockz); if(!list2.contains(blockx + "," + blocky + "," + blockz)){
plugin.getConfig().set("StorageXYZ", list2); list2.add(blockx + "," + blocky + "," + blockz);
plugin.getConfig().options().copyDefaults(true); plugin.getConfig().set("StorageXYZ", list2);
plugin.saveConfig(); plugin.getConfig().options().copyDefaults(true);
p.sendMessage(ChatColor.GREEN + "Thank you for finding this undiscovered chest, it has been stored!!"); plugin.saveConfig();
p.sendMessage(ChatColor.GREEN + "Thank you for finding this undiscovered chest, it has been stored!!");
}
} }
} }
} }

View File

@ -46,11 +46,13 @@ public class DeathListener implements Listener{
Server s = p.getServer(); Server s = p.getServer();
String pname = p.getName(); String pname = p.getName();
int players = plugin.Playing.size()-1; int players = plugin.Playing.size()-1;
String leftmsg = ChatColor.BLUE + "There are now " + players + " tributes left!"; String leftmsg = null;
for(i = 1; i < plugin.Frozen.size(); i++){ for(i = 1; i < plugin.Frozen.size(); i++){
if(plugin.Frozen.get(i).contains(pname)){ if(plugin.Frozen.get(i).contains(pname)){
if(plugin.getArena(p)!= null){ if(plugin.getArena(p)!= null){
a = plugin.getArena(p); a = plugin.getArena(p);
players = plugin.Playing.get(a).size()-1;
leftmsg = ChatColor.BLUE + "There are now " + players + " tributes left!";
if(plugin.config.getString("Cannon_Death").equalsIgnoreCase("True")){ if(plugin.config.getString("Cannon_Death").equalsIgnoreCase("True")){
double y = p.getLocation().getY(); double y = p.getLocation().getY();
double newy = y+200; double newy = y+200;
@ -83,6 +85,8 @@ public class DeathListener implements Listener{
} }
}else if(plugin.getArena(p)!= null){ }else if(plugin.getArena(p)!= null){
a = plugin.getArena(p); a = plugin.getArena(p);
players = plugin.Playing.get(a).size()-1;
leftmsg = ChatColor.BLUE + "There are now " + players + " tributes left!";
if(plugin.config.getString("Cannon_Death").equalsIgnoreCase("True")){ if(plugin.config.getString("Cannon_Death").equalsIgnoreCase("True")){
double y = p.getLocation().getY(); double y = p.getLocation().getY();
double newy = y+200; double newy = y+200;

View File

@ -101,34 +101,51 @@ public class HaCommands implements CommandExecutor {
if(!plugin.Playing.get(a).isEmpty() && plugin.Playing.containsKey(a)){ if(!plugin.Playing.get(a).isEmpty() && plugin.Playing.containsKey(a)){
for(String playernames: plugin.Playing.get(a)){ for(String playernames: plugin.Playing.get(a)){
Player players = plugin.getServer().getPlayerExact(playernames); Player players = plugin.getServer().getPlayerExact(playernames);
if(p.hasPermission("HungerArena.List")){ if(p.hasPermission("HungerArena.GameMaker")){
sender.sendMessage(ChatColor.GREEN + playernames);
}else{
sender.sendMessage(ChatColor.GREEN + playernames + " Life: " + players.getHealth() + "/20"); sender.sendMessage(ChatColor.GREEN + playernames + " Life: " + players.getHealth() + "/20");
}else if(p.hasPermission("HungerArena.List")){
sender.sendMessage(ChatColor.GREEN + playernames);
} }
} }
}else{ }else{
p.sendMessage(ChatColor.GRAY + "No one is playing!"); p.sendMessage(ChatColor.GRAY + "No one is playing!");
} }
p.sendMessage(ChatColor.AQUA + "---------------------"); p.sendMessage(ChatColor.AQUA + "-------------------");
}catch(Exception e){ }catch(Exception e){
p.sendMessage(ChatColor.RED + "Argument not an integer!"); p.sendMessage(ChatColor.RED + "Argument not an integer or is an invalid arena!");
} }
}else{ }else{
p.sendMessage(ChatColor.AQUA + "----- Arena 1 -----"); if(plugin.getArena(p)== null){
if(!plugin.Playing.get(1).isEmpty() && plugin.Playing.containsKey(1)){ p.sendMessage(ChatColor.AQUA + "----- Arena 1 -----");
for(String playernames: plugin.Playing.get(1)){ if(!plugin.Playing.get(1).isEmpty() && plugin.Playing.containsKey(1)){
Player players = plugin.getServer().getPlayerExact(playernames); for(String playernames: plugin.Playing.get(1)){
if(p.hasPermission("HungerArena.List")){ Player players = plugin.getServer().getPlayerExact(playernames);
sender.sendMessage(ChatColor.GREEN + playernames); if(p.hasPermission("HungerArena.GameMaker")){
}else{ sender.sendMessage(ChatColor.GREEN + playernames + " Life: " + players.getHealth() + "/20");
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{ }else{
p.sendMessage(ChatColor.GRAY + "No one is playing!"); 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 + "---------------------"); p.sendMessage(ChatColor.AQUA + "-------------------");
} }
}else{ }else{
p.sendMessage(ChatColor.RED + "You don't have permission!"); p.sendMessage(ChatColor.RED + "You don't have permission!");
@ -146,7 +163,7 @@ public class HaCommands implements CommandExecutor {
}else{ }else{
p.sendMessage(ChatColor.GRAY + "No one is ready!"); p.sendMessage(ChatColor.GRAY + "No one is ready!");
} }
p.sendMessage(ChatColor.AQUA + "---------------------"); p.sendMessage(ChatColor.AQUA + "-------------------");
}catch(Exception e){ }catch(Exception e){
p.sendMessage(ChatColor.RED + "Argument not an integer!"); p.sendMessage(ChatColor.RED + "Argument not an integer!");
} }
@ -159,7 +176,7 @@ public class HaCommands implements CommandExecutor {
}else{ }else{
p.sendMessage(ChatColor.GRAY + "No one is ready!"); p.sendMessage(ChatColor.GRAY + "No one is ready!");
} }
p.sendMessage(ChatColor.AQUA + "---------------------"); p.sendMessage(ChatColor.AQUA + "-------------------");
} }
}else{ }else{
p.sendMessage(ChatColor.RED + "You don't have permission!"); p.sendMessage(ChatColor.RED + "You don't have permission!");
@ -359,7 +376,7 @@ public class HaCommands implements CommandExecutor {
} }
} }
if(plugin.Playing.get(a).size()== plugin.maxPlayers.get(a)){ if(plugin.Playing.get(a).size()== plugin.maxPlayers.get(a)){
plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), "ha warpall " + String.valueOf(a)); plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), "ha warpall " + a);
} }
} }
} }
@ -490,8 +507,11 @@ public class HaCommands implements CommandExecutor {
} }
} }
}else if(args[0].equalsIgnoreCase("Ready")){ }else if(args[0].equalsIgnoreCase("Ready")){
p.sendMessage(String.valueOf(plugin.getArena(p)));
if(plugin.getArena(p)!= null){ if(plugin.getArena(p)!= null){
a = plugin.getArena(p); a = plugin.getArena(p);
for(String s:plugin.Playing.get(a))
p.sendMessage(s);
if(plugin.Playing.get(a).contains(pname)){ if(plugin.Playing.get(a).contains(pname)){
if(plugin.Ready.get(a).contains(pname)){ if(plugin.Ready.get(a).contains(pname)){
p.sendMessage(ChatColor.RED + "You're already ready!"); p.sendMessage(ChatColor.RED + "You're already ready!");
@ -643,13 +663,7 @@ public class HaCommands implements CommandExecutor {
a = Integer.parseInt(args[1]); a = Integer.parseInt(args[1]);
int list056; int list056;
list056 = 0; list056 = 0;
int limit = 0; int limit = plugin.config.getStringList("StorageXYZ").size();
for(String chests: plugin.config.getStringList("StorageXYZ")){
String[] chest = chests.split(",");
if(Integer.parseInt(chest[3])== a){
limit = limit+1;
}
}
while(limit > list056){ while(limit > list056){
String xyz2 = plugin.getConfig().getStringList("StorageXYZ").get(list056); String xyz2 = plugin.getConfig().getStringList("StorageXYZ").get(list056);
int chestx = plugin.getConfig().getInt("Storage." + xyz2 + ".Location.X"); int chestx = plugin.getConfig().getInt("Storage." + xyz2 + ".Location.X");
@ -659,26 +673,30 @@ public class HaCommands implements CommandExecutor {
String chestw = plugin.getConfig().getString("Storage." + xyz2 + ".Location.W"); String chestw = plugin.getConfig().getString("Storage." + xyz2 + ".Location.W");
Block blockatlocation = Bukkit.getWorld(chestw).getBlockAt(chestx, chesty, chestz); Block blockatlocation = Bukkit.getWorld(chestw).getBlockAt(chestx, chesty, chestz);
plugin.exists = false; plugin.exists = false;
if(blockatlocation.getState() instanceof Chest){ if(chesta== a){
plugin.exists = true; if(blockatlocation.getState() instanceof Chest){
Chest chest = (Chest) blockatlocation.getState(); plugin.exists = true;
if(chesta== a){ Chest chest = (Chest) blockatlocation.getState();
chest.getInventory().clear(); if(chesta== a){
ItemStack[] itemsinchest = null; chest.getInventory().clear();
Object o = plugin.getConfig().get("Storage." + xyz2 + ".ItemsInStorage"); ItemStack[] itemsinchest = null;
if(o instanceof ItemStack[]){ Object o = plugin.getConfig().get("Storage." + xyz2 + ".ItemsInStorage");
itemsinchest = (ItemStack[]) o; if(o instanceof ItemStack[]){
}else if(o instanceof List){ itemsinchest = (ItemStack[]) o;
itemsinchest = (ItemStack[]) ((List<ItemStack>) o).toArray(new ItemStack[0]); }else if(o instanceof List){
itemsinchest = (ItemStack[]) ((List<ItemStack>) o).toArray(new ItemStack[0]);
}
list056 = list056+1;
chest.getInventory().setContents(itemsinchest);
chest.update();
} }
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!");
} }
}
if(limit== list056){
sender.sendMessage(ChatColor.GREEN + "All for arena " + a + " refilled!");
} }
}else{ }else{
int list056; int list056;
@ -794,13 +812,15 @@ public class HaCommands implements CommandExecutor {
p.sendMessage(ChatColor.AQUA + "Arena " + a + " has been reset!"); p.sendMessage(ChatColor.AQUA + "Arena " + a + " has been reset!");
}else{ }else{
for(i = 1; i <= plugin.Watching.size(); i++){ for(i = 1; i <= plugin.Watching.size(); i++){
for(b = 0; b < plugin.Watching.get(b).size(); b++){ for(b = 0; b <= plugin.Watching.get(i).size(); b++){
String s = plugin.Watching.get(i).get(b); if(plugin.Watching.get(i).get(b)!= null){
Player spectator = plugin.getServer().getPlayerExact(s); String s = plugin.Watching.get(i).get(b);
spectator.setAllowFlight(false); Player spectator = plugin.getServer().getPlayerExact(s);
spectator.teleport(Spawn); spectator.setAllowFlight(false);
for(Player online:plugin.getServer().getOnlinePlayers()){ spectator.teleport(Spawn);
online.showPlayer(spectator); for(Player online:plugin.getServer().getOnlinePlayers()){
online.showPlayer(spectator);
}
} }
} }
} }
@ -866,17 +886,21 @@ public class HaCommands implements CommandExecutor {
a = Integer.parseInt(args[1]); a = Integer.parseInt(args[1]);
if(plugin.open.get(a)){ if(plugin.open.get(a)){
plugin.open.put(a, false); plugin.open.put(a, false);
for(String players: plugin.Playing.get(a)){ if(plugin.Playing.get(a)!= null){
Player tributes = plugin.getServer().getPlayerExact(players); for(String players: plugin.Playing.get(a)){
clearInv(tributes); Player tributes = plugin.getServer().getPlayerExact(players);
tributes.teleport(tributes.getWorld().getSpawnLocation()); clearInv(tributes);
tributes.teleport(tributes.getWorld().getSpawnLocation());
}
} }
for(String sname: plugin.Watching.get(a)){ if(plugin.Watching.get(a)!= null){
Player spectators = plugin.getServer().getPlayerExact(sname); for(String sname: plugin.Watching.get(a)){
spectators.teleport(spectators.getWorld().getSpawnLocation()); Player spectators = plugin.getServer().getPlayerExact(sname);
spectators.setAllowFlight(false); spectators.teleport(spectators.getWorld().getSpawnLocation());
for(Player online:plugin.getServer().getOnlinePlayers()){ spectators.setAllowFlight(false);
online.showPlayer(spectators); for(Player online:plugin.getServer().getOnlinePlayers()){
online.showPlayer(spectators);
}
} }
} }
plugin.Dead.get(a).clear(); plugin.Dead.get(a).clear();
@ -897,17 +921,21 @@ public class HaCommands implements CommandExecutor {
for(i = 1; i <= plugin.open.size(); i++){ for(i = 1; i <= plugin.open.size(); i++){
if(plugin.open.get(i)){ if(plugin.open.get(i)){
plugin.open.put(i, false); plugin.open.put(i, false);
for(String players: plugin.Playing.get(i)){ if(plugin.Playing.get(i)!= null){
Player tributes = plugin.getServer().getPlayerExact(players); for(String players: plugin.Playing.get(i)){
clearInv(tributes); Player tributes = plugin.getServer().getPlayerExact(players);
tributes.teleport(tributes.getWorld().getSpawnLocation()); clearInv(tributes);
tributes.teleport(tributes.getWorld().getSpawnLocation());
}
} }
for(String sname: plugin.Watching.get(i)){ if(plugin.Watching.get(i)!= null){
Player spectators = plugin.getServer().getPlayerExact(sname); for(String sname: plugin.Watching.get(i)){
spectators.teleport(spectators.getWorld().getSpawnLocation()); Player spectators = plugin.getServer().getPlayerExact(sname);
spectators.setAllowFlight(false); spectators.teleport(spectators.getWorld().getSpawnLocation());
for(Player online:plugin.getServer().getOnlinePlayers()){ spectators.setAllowFlight(false);
online.showPlayer(spectators); for(Player online:plugin.getServer().getOnlinePlayers()){
online.showPlayer(spectators);
}
} }
} }
plugin.Dead.clear(); plugin.Dead.clear();
@ -943,9 +971,11 @@ public class HaCommands implements CommandExecutor {
for(i = 1; i <= plugin.open.size(); i++){ for(i = 1; i <= plugin.open.size(); i++){
if(!plugin.open.get(i)){ if(!plugin.open.get(i)){
plugin.open.put(i, true); plugin.open.put(i, true);
p.sendMessage(ChatColor.GOLD + "Arena " + a + " Open!"); p.sendMessage(ChatColor.GOLD + "Arena " + i + " Open!");
i = i+1;
}else{ }else{
p.sendMessage(ChatColor.RED + "Arena " + a + " already open, type /ha close to close them!"); p.sendMessage(ChatColor.RED + "Arena " + i + " already open, type /ha close to close them!");
i = i+1;
} }
} }
} }
@ -1014,7 +1044,17 @@ public class HaCommands implements CommandExecutor {
} }
}else if(args[0].equalsIgnoreCase("Start")){ }else if(args[0].equalsIgnoreCase("Start")){
if(p.hasPermission("HungerArena.Start")){ if(p.hasPermission("HungerArena.Start")){
plugin.startGames(a); 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{ }else{
p.sendMessage(ChatColor.RED + "You don't have permission!"); p.sendMessage(ChatColor.RED + "You don't have permission!");
} }
@ -1141,13 +1181,7 @@ public class HaCommands implements CommandExecutor {
a = Integer.parseInt(args[1]); a = Integer.parseInt(args[1]);
int list056; int list056;
list056 = 0; list056 = 0;
int limit = 0; int limit = plugin.config.getStringList("StorageXYZ").size();
for(String chests: plugin.config.getStringList("StorageXYZ")){
String[] chest = chests.split(",");
if(Integer.parseInt(chest[3])== a){
limit = limit+1;
}
}
while(limit > list056){ while(limit > list056){
String xyz2 = plugin.getConfig().getStringList("StorageXYZ").get(list056); String xyz2 = plugin.getConfig().getStringList("StorageXYZ").get(list056);
int chestx = plugin.getConfig().getInt("Storage." + xyz2 + ".Location.X"); int chestx = plugin.getConfig().getInt("Storage." + xyz2 + ".Location.X");
@ -1157,22 +1191,26 @@ public class HaCommands implements CommandExecutor {
String chestw = plugin.getConfig().getString("Storage." + xyz2 + ".Location.W"); String chestw = plugin.getConfig().getString("Storage." + xyz2 + ".Location.W");
Block blockatlocation = Bukkit.getWorld(chestw).getBlockAt(chestx, chesty, chestz); Block blockatlocation = Bukkit.getWorld(chestw).getBlockAt(chestx, chesty, chestz);
plugin.exists = false; plugin.exists = false;
if(blockatlocation.getState() instanceof Chest){ if(chesta== a){
plugin.exists = true; if(blockatlocation.getState() instanceof Chest){
Chest chest = (Chest) blockatlocation.getState(); plugin.exists = true;
if(chesta== a){ Chest chest = (Chest) blockatlocation.getState();
chest.getInventory().clear(); if(chesta== a){
ItemStack[] itemsinchest = null; chest.getInventory().clear();
Object o = plugin.getConfig().get("Storage." + xyz2 + ".ItemsInStorage"); ItemStack[] itemsinchest = null;
if(o instanceof ItemStack[]){ Object o = plugin.getConfig().get("Storage." + xyz2 + ".ItemsInStorage");
itemsinchest = (ItemStack[]) o; if(o instanceof ItemStack[]){
}else if(o instanceof List){ itemsinchest = (ItemStack[]) o;
itemsinchest = (ItemStack[]) ((List<ItemStack>) o).toArray(new ItemStack[0]); }else if(o instanceof List){
itemsinchest = (ItemStack[]) ((List<ItemStack>) o).toArray(new ItemStack[0]);
}
list056 = list056+1;
chest.getInventory().setContents(itemsinchest);
chest.update();
} }
list056 = list056+1;
chest.getInventory().setContents(itemsinchest);
chest.update();
} }
}else{
list056 = list056+1;
} }
} }
if(limit== list056){ if(limit== list056){
@ -1354,15 +1392,18 @@ public class HaCommands implements CommandExecutor {
} }
/////////////////////////////////// Toggle ////////////////////////////////////////////////// /////////////////////////////////// Toggle //////////////////////////////////////////////////
}else if(args[0].equalsIgnoreCase("close")){ }else if(args[0].equalsIgnoreCase("close")){
if(args.length>= 2){ if(args.length>= 2){
a = Integer.parseInt(args[1]); a = Integer.parseInt(args[1]);
if(plugin.open.get(a)){ if(plugin.open.get(a)){
plugin.open.put(a, false); plugin.open.put(a, false);
if(plugin.Playing.get(a)!= null){
for(String players: plugin.Playing.get(a)){ for(String players: plugin.Playing.get(a)){
Player tributes = plugin.getServer().getPlayerExact(players); Player tributes = plugin.getServer().getPlayerExact(players);
clearInv(tributes); clearInv(tributes);
tributes.teleport(tributes.getWorld().getSpawnLocation()); tributes.teleport(tributes.getWorld().getSpawnLocation());
} }
}
if(plugin.Watching.get(a)!= null){
for(String sname: plugin.Watching.get(a)){ for(String sname: plugin.Watching.get(a)){
Player spectators = plugin.getServer().getPlayerExact(sname); Player spectators = plugin.getServer().getPlayerExact(sname);
spectators.teleport(spectators.getWorld().getSpawnLocation()); spectators.teleport(spectators.getWorld().getSpawnLocation());
@ -1371,30 +1412,34 @@ public class HaCommands implements CommandExecutor {
online.showPlayer(spectators); 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();
plugin.getServer().dispatchCommand(plugin.getServer().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!");
} }
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{ }else{
for(i = 1; i <= plugin.open.size(); i++){ sender.sendMessage(ChatColor.RED + "Arena " + a + " already closed, type /ha open to re-open them!");
if(plugin.open.get(i)){ }
plugin.open.put(i, false); }else{
for(String players: plugin.Playing.get(a)){ 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); Player tributes = plugin.getServer().getPlayerExact(players);
clearInv(tributes); clearInv(tributes);
tributes.teleport(tributes.getWorld().getSpawnLocation()); tributes.teleport(tributes.getWorld().getSpawnLocation());
} }
for(String sname: plugin.Watching.get(a)){ }
if(plugin.Watching.get(i)!= null){
for(String sname: plugin.Watching.get(i)){
Player spectators = plugin.getServer().getPlayerExact(sname); Player spectators = plugin.getServer().getPlayerExact(sname);
spectators.teleport(spectators.getWorld().getSpawnLocation()); spectators.teleport(spectators.getWorld().getSpawnLocation());
spectators.setAllowFlight(false); spectators.setAllowFlight(false);
@ -1402,97 +1447,107 @@ public class HaCommands implements CommandExecutor {
online.showPlayer(spectators); 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();
plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), "ha refill");
sender.sendMessage(ChatColor.GOLD + "Arena " + a + " Closed!");
}else{
sender.sendMessage(ChatColor.RED + "Arena " + a + " already closed, type /ha open to re-open them!");
} }
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")){ }else if(args[0].equalsIgnoreCase("open")){
if(args.length>= 2){ if(args.length>= 2){
a = Integer.parseInt(args[1]); a = Integer.parseInt(args[1]);
if(!plugin.open.get(a)){ if(!plugin.open.get(a)){
plugin.open.put(a, true); 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!"); sender.sendMessage(ChatColor.GOLD + "Arena " + a + " Open!");
}else{ }else{
sender.sendMessage(ChatColor.RED + "Arena " + a + " already open, type /ha close to close them!"); 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")){ }else if(args[0].equalsIgnoreCase("Reload")){
plugin.location.clear(); plugin.location.clear();
plugin.Reward.clear(); plugin.Reward.clear();
plugin.Cost.clear(); plugin.Cost.clear();
plugin.Fee.clear(); plugin.Fee.clear();
plugin.onEnable(); plugin.onEnable();
sender.sendMessage(ChatColor.AQUA + "HungerArena Reloaded!"); sender.sendMessage(ChatColor.AQUA + "HungerArena Reloaded!");
}else if(args[0].equalsIgnoreCase("WarpAll")){ }else if(args[0].equalsIgnoreCase("WarpAll")){
if(plugin.spawns.getString("Spawns_set").equalsIgnoreCase("false")){ if(plugin.spawns.getString("Spawns_set").equalsIgnoreCase("false")){
sender.sendMessage(ChatColor.RED + "/ha setspawn hasn't been run!"); sender.sendMessage(ChatColor.RED + "/ha setspawn hasn't been run!");
}else{ }else{
if(args.length>= 2){ if(args.length>= 2){
a = Integer.parseInt(args[1]); a = Integer.parseInt(args[1]);
if(plugin.Playing.get(a).size()== 1){ if(plugin.Playing.get(a).size()== 1){
sender.sendMessage(ChatColor.RED + "There are not enough players!"); sender.sendMessage(ChatColor.RED + "There are not enough players!");
}else{ }else{
if(plugin.config.getString("Auto_Start").equalsIgnoreCase("true")){ 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)); //TODO BUG?
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(){ plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
public void run(){ public void run(){
sender.sendMessage(ChatColor.AQUA + "All Tributes warped!"); Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha start " + a);
} }
}, 20L); }, 20L);
} }
}else{ i = 1;
sender.sendMessage(ChatColor.RED + "Too few arguments, specify an arena"); 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")){ }else if(args[0].equalsIgnoreCase("Start")){
plugin.startGames(a); 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{ }else{
sender.sendMessage(ChatColor.RED + "Unknown command, type /ha help to see all commands!"); sender.sendMessage(ChatColor.RED + "Unknown command, type /ha help to see all commands!");
} }

View File

@ -17,6 +17,7 @@ import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
@ -314,10 +315,10 @@ public class Main extends JavaPlugin{
double spawny = Double.parseDouble(Spawncoords[1]); double spawny = Double.parseDouble(Spawncoords[1]);
double spawnz = Double.parseDouble(Spawncoords[2]); double spawnz = Double.parseDouble(Spawncoords[2]);
Location Spawn = new Location(spawnw, spawnx, spawny, spawnz); Location Spawn = new Location(spawnw, spawnx, spawny, spawnz);
if(Playing.size()== 1 && canjoin.get(a)== true){ if(Playing.get(a).size()== 1 && canjoin.get(a)== true){
//Announce winner //Announce winner
for(i = 1; i < Playing.get(a).size(); i++){ for(i = 0; i < Playing.get(a).size(); i++){
String winnername = Playing.get(a).get(i++); String winnername = Playing.get(a).get(i);
Player winner = getServer().getPlayerExact(winnername); Player winner = getServer().getPlayerExact(winnername);
String winnername2 = winner.getName(); String winnername2 = winner.getName();
getServer().broadcastMessage(ChatColor.GREEN + winnername2 + " is the victor of this Hunger Games!"); getServer().broadcastMessage(ChatColor.GREEN + winnername2 + " is the victor of this Hunger Games!");
@ -332,7 +333,16 @@ public class Main extends JavaPlugin{
winner.removePotionEffect(potion); winner.removePotionEffect(potion);
} }
Tele.add(winner); Tele.add(winner);
final World w = winner.getWorld();
winner.teleport(Spawn); 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")){ if(!config.getBoolean("rewardEco.enabled")){
for(ItemStack Rewards: Reward){ for(ItemStack Rewards: Reward){
winner.getInventory().addItem(Rewards); winner.getInventory().addItem(Rewards);
@ -343,7 +353,7 @@ public class Main extends JavaPlugin{
} }
econ.depositPlayer(winner.getName(), config.getDouble("rewardEco.reward")); econ.depositPlayer(winner.getName(), config.getDouble("rewardEco.reward"));
} }
Playing.clear(); Playing.get(a).clear();
getServer().getScheduler().cancelTask(deathtime); getServer().getScheduler().cancelTask(deathtime);
} }
//Show spectators //Show spectators
@ -402,7 +412,8 @@ public class Main extends JavaPlugin{
i = i-1; i = i-1;
canjoin.put(a, true); canjoin.put(a, true);
if(i== -1){ if(i== -1){
Frozen.get(a).clear(); if(Frozen.get(a)!= null)
Frozen.get(a).clear();
if(config.getBoolean("broadcastAll")){ if(config.getBoolean("broadcastAll")){
getServer().broadcastMessage(msg); getServer().broadcastMessage(msg);
}else{ }else{
@ -477,13 +488,10 @@ public class Main extends JavaPlugin{
} }
} }
public Integer getArena(Player p){ public Integer getArena(Player p){
int x = 0; for (int x: Playing.keySet()) {
for(x = 1; x < Playing.size(); x++){ if (Playing.get(x).contains(p.getName())){
if(Playing.get(x)!= null){ return x;
if(Playing.get(x).contains(p.getName())){ }
return x;
}
}
} }
return null; return null;
} }