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);
if(plugin.Playing.get(a).contains(p.getName()) && plugin.canjoin.get(a)){
if(!plugin.restricted || (plugin.restricted && plugin.worlds.contains(p.getWorld().getName()))){
if(block.getState() instanceof Chest){
ItemStack[] itemsinchest = ((Chest) block.getState()).getInventory().getContents();
int blockx = block.getX();
int blocky = block.getY();
int blockz = block.getZ();
String blockw = block.getWorld().getName().toString();
if(!plugin.getConfig().contains("Storage." + blockx + "," + blocky + "," + blockz + ".Location.X")){
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.X", blockx);
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Y", blocky);
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Z",blockz);
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.W", blockw);
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".ItemsInStorage", itemsinchest);
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Arena", a);
}
List<String> list2 = plugin.getConfig().getStringList("StorageXYZ");
if(!list2.contains(blockx + "," + blocky + "," + blockz)){
list2.add(blockx + "," + blocky + "," + blockz);
plugin.getConfig().set("StorageXYZ", list2);
plugin.getConfig().options().copyDefaults(true);
plugin.saveConfig();
p.sendMessage(ChatColor.GREEN + "Thank you for finding this undiscovered chest, it has been stored!!");
if(block!= null){
if(block.getState() instanceof Chest){
ItemStack[] itemsinchest = ((Chest) block.getState()).getInventory().getContents();
int blockx = block.getX();
int blocky = block.getY();
int blockz = block.getZ();
String blockw = block.getWorld().getName().toString();
if(!plugin.getConfig().contains("Storage." + blockx + "," + blocky + "," + blockz + ".Location.X")){
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.X", blockx);
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Y", blocky);
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Z",blockz);
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.W", blockw);
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".ItemsInStorage", itemsinchest);
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Arena", a);
}
List<String> list2 = plugin.getConfig().getStringList("StorageXYZ");
if(!list2.contains(blockx + "," + blocky + "," + blockz)){
list2.add(blockx + "," + blocky + "," + blockz);
plugin.getConfig().set("StorageXYZ", list2);
plugin.getConfig().options().copyDefaults(true);
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();
String pname = p.getName();
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++){
if(plugin.Frozen.get(i).contains(pname)){
if(plugin.getArena(p)!= null){
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")){
double y = p.getLocation().getY();
double newy = y+200;
@ -83,6 +85,8 @@ public class DeathListener implements Listener{
}
}else if(plugin.getArena(p)!= null){
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")){
double y = p.getLocation().getY();
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)){
for(String playernames: plugin.Playing.get(a)){
Player players = plugin.getServer().getPlayerExact(playernames);
if(p.hasPermission("HungerArena.List")){
sender.sendMessage(ChatColor.GREEN + playernames);
}else{
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 + "-------------------");
}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{
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.List")){
sender.sendMessage(ChatColor.GREEN + playernames);
}else{
sender.sendMessage(ChatColor.GREEN + playernames + " Life: " + players.getHealth() + "/20");
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{
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{
p.sendMessage(ChatColor.RED + "You don't have permission!");
@ -146,7 +163,7 @@ public class HaCommands implements CommandExecutor {
}else{
p.sendMessage(ChatColor.GRAY + "No one is ready!");
}
p.sendMessage(ChatColor.AQUA + "---------------------");
p.sendMessage(ChatColor.AQUA + "-------------------");
}catch(Exception e){
p.sendMessage(ChatColor.RED + "Argument not an integer!");
}
@ -159,7 +176,7 @@ public class HaCommands implements CommandExecutor {
}else{
p.sendMessage(ChatColor.GRAY + "No one is ready!");
}
p.sendMessage(ChatColor.AQUA + "---------------------");
p.sendMessage(ChatColor.AQUA + "-------------------");
}
}else{
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)){
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")){
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!");
@ -643,13 +663,7 @@ public class HaCommands implements CommandExecutor {
a = Integer.parseInt(args[1]);
int list056;
list056 = 0;
int limit = 0;
for(String chests: plugin.config.getStringList("StorageXYZ")){
String[] chest = chests.split(",");
if(Integer.parseInt(chest[3])== a){
limit = limit+1;
}
}
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");
@ -659,26 +673,30 @@ public class HaCommands implements CommandExecutor {
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();
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<ItemStack>) o).toArray(new ItemStack[0]);
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<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{
int list056;
@ -794,13 +812,15 @@ public class HaCommands implements CommandExecutor {
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(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);
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);
}
}
}
}
@ -866,17 +886,21 @@ public class HaCommands implements CommandExecutor {
a = Integer.parseInt(args[1]);
if(plugin.open.get(a)){
plugin.open.put(a, false);
for(String players: plugin.Playing.get(a)){
Player tributes = plugin.getServer().getPlayerExact(players);
clearInv(tributes);
tributes.teleport(tributes.getWorld().getSpawnLocation());
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());
}
}
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);
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();
@ -897,17 +921,21 @@ public class HaCommands implements CommandExecutor {
for(i = 1; i <= plugin.open.size(); i++){
if(plugin.open.get(i)){
plugin.open.put(i, false);
for(String players: plugin.Playing.get(i)){
Player tributes = plugin.getServer().getPlayerExact(players);
clearInv(tributes);
tributes.teleport(tributes.getWorld().getSpawnLocation());
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());
}
}
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);
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();
@ -943,9 +971,11 @@ public class HaCommands implements CommandExecutor {
for(i = 1; i <= plugin.open.size(); i++){
if(!plugin.open.get(i)){
plugin.open.put(i, true);
p.sendMessage(ChatColor.GOLD + "Arena " + a + " Open!");
p.sendMessage(ChatColor.GOLD + "Arena " + i + " Open!");
i = i+1;
}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")){
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{
p.sendMessage(ChatColor.RED + "You don't have permission!");
}
@ -1141,13 +1181,7 @@ public class HaCommands implements CommandExecutor {
a = Integer.parseInt(args[1]);
int list056;
list056 = 0;
int limit = 0;
for(String chests: plugin.config.getStringList("StorageXYZ")){
String[] chest = chests.split(",");
if(Integer.parseInt(chest[3])== a){
limit = limit+1;
}
}
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");
@ -1157,22 +1191,26 @@ public class HaCommands implements CommandExecutor {
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();
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<ItemStack>) o).toArray(new ItemStack[0]);
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<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){
@ -1354,15 +1392,18 @@ public class HaCommands implements CommandExecutor {
}
/////////////////////////////////// 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(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());
@ -1371,30 +1412,34 @@ public class HaCommands implements CommandExecutor {
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{
for(i = 1; i <= plugin.open.size(); i++){
if(plugin.open.get(i)){
plugin.open.put(i, false);
for(String players: plugin.Playing.get(a)){
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());
}
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);
spectators.teleport(spectators.getWorld().getSpawnLocation());
spectators.setAllowFlight(false);
@ -1402,97 +1447,107 @@ public class HaCommands implements CommandExecutor {
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")){
if(args.length>= 2){
a = Integer.parseInt(args[1]);
if(!plugin.open.get(a)){
plugin.open.put(a, true);
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{
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!");
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)); //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;
}
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(){
sender.sendMessage(ChatColor.AQUA + "All Tributes warped!");
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha start " + a);
}
}, 20L);
}
}else{
sender.sendMessage(ChatColor.RED + "Too few arguments, specify an arena");
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")){
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{
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.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;
@ -314,10 +315,10 @@ 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);
if(Playing.size()== 1 && canjoin.get(a)== true){
if(Playing.get(a).size()== 1 && canjoin.get(a)== true){
//Announce winner
for(i = 1; i < Playing.get(a).size(); i++){
String winnername = Playing.get(a).get(i++);
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!");
@ -332,7 +333,16 @@ public class Main extends JavaPlugin{
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);
@ -343,7 +353,7 @@ public class Main extends JavaPlugin{
}
econ.depositPlayer(winner.getName(), config.getDouble("rewardEco.reward"));
}
Playing.clear();
Playing.get(a).clear();
getServer().getScheduler().cancelTask(deathtime);
}
//Show spectators
@ -402,7 +412,8 @@ public class Main extends JavaPlugin{
i = i-1;
canjoin.put(a, true);
if(i== -1){
Frozen.get(a).clear();
if(Frozen.get(a)!= null)
Frozen.get(a).clear();
if(config.getBoolean("broadcastAll")){
getServer().broadcastMessage(msg);
}else{
@ -477,13 +488,10 @@ public class Main extends JavaPlugin{
}
}
public Integer getArena(Player p){
int x = 0;
for(x = 1; x < Playing.size(); x++){
if(Playing.get(x)!= null){
if(Playing.get(x).contains(p.getName())){
return x;
}
}
for (int x: Playing.keySet()) {
if (Playing.get(x).contains(p.getName())){
return x;
}
}
return null;
}