Tons of fixes!!

This commit is contained in:
travja 2012-08-29 17:58:39 -06:00
parent 3d90d9afce
commit 641ba0b3d1
50 changed files with 661 additions and 453 deletions

Binary file not shown.

Binary file not shown.

View File

@ -12,8 +12,8 @@ config:
# If left blank all worlds will be allowed.
# ie:
# worlds:
# - world
# - world_nether
# - world
# - world_nether
worlds:
# Message to display when the games start

28
spawns.yml Normal file
View File

@ -0,0 +1,28 @@
# This file stores all of the spawns!
Spawn_coords: 100,100,100,world
# If /ha setspawn has been run
Spawns_set: 'false'
Tribute_one_spawn: 100,100,100
Tribute_two_spawn: 100,100,100
Tribute_three_spawn: 100,100,100
Tribute_four_spawn: 100,100,100
Tribute_five_spawn: 100,100,100
Tribute_six_spawn: 100,100,100
Tribute_seven_spawn: 100,100,100
Tribute_eight_spawn: 100,100,100
Tribute_nine_spawn: 100,100,100
Tribute_ten_spawn: 100,100,100
Tribute_eleven_spawn: 100,100,100
Tribute_twelve_spawn: 100,100,100
Tribute_thirteen_spawn: 100,100,100
Tribute_fourteen_spawn: 100,100,100
Tribute_fifteen_spawn: 100,100,100
Tribute_sixteen_spawn: 100,100,100
Tribute_seventeen_spawn: 100,100,100
Tribute_eighteen_spawn: 100,100,100
Tribute_nineteen_spawn: 100,100,100
Tribute_twenty_spawn: 100,100,100
Tribute_twentyone_spawn: 100,100,100
Tribute_twentytwo_spawn: 100,100,100
Tribute_twentythree_spawn: 100,100,100
Tribute_twentyfour_spawn: 100,100,100

View File

@ -27,7 +27,7 @@ public class BlockStorage implements Listener {
public BlockStorage(Main m) {
this.plugin = m;
}
@EventHandler
/*@EventHandler
public void creeperExplosion(EntityExplodeEvent event){
if(plugin.canjoin== true){
for(Block b:event.blockList()){
@ -116,7 +116,7 @@ public class BlockStorage implements Listener {
if(l.getBlock().getRelative(BlockFace.DOWN).getType()!= Material.AIR || l.getBlock().getRelative(BlockFace.DOWN).getType()!= Material.WATER || l.getBlock().getRelative(BlockFace.DOWN).getType()!= Material.LAVA){
event.getPlayer().sendMessage(ChatColor.GREEN + "Block will land at " + x + ", " + newy + ", " + z + " and replaced " + replaced);
}
/*Location location = b.getLocation();
Location location = b.getLocation();
if (location.getBlock().getRelative(BlockFace.DOWN).getType() == Material.AIR) {
int i = 0;
for (i = location.getBlockY(); i > -1; i --) {
@ -131,7 +131,7 @@ public class BlockStorage implements Listener {
plugin.config.set("Blocks_Destroyed", blocks);
plugin.saveConfig();
}
}*/
}
}
}
}
@ -259,7 +259,7 @@ public class BlockStorage implements Listener {
}
}
}
/*@EventHandler
@EventHandler
public void onChange(BlockPhysicsEvent event){
Block block = event.getBlock();
Material changed = event.getChangedType();

View File

@ -18,7 +18,7 @@ public class CommandBlock implements Listener {
Player p = event.getPlayer();
String pname = p.getName();
if(!cmd.contains("/ha") && plugin.Playing.contains(pname) && plugin.canjoin== true){
if(!p.hasPermission("HungerArena.UseCommands")){
if(!cmd.contains("/login") || !p.hasPermission("HungerArena.UseCommands")){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are only allowed to use /ha commands!");
}

View File

@ -20,7 +20,7 @@ public class DeathListener implements Listener{
Player p = event.getPlayer();
String pname = p.getName();
if(plugin.Dead.contains(pname)){
String[] Spawncoords = plugin.config.getString("Spawn_coords").split(",");
String[] Spawncoords = plugin.spawns.getString("Spawn_coords").split(",");
World spawnw = plugin.getServer().getWorld(Spawncoords[3]);
double spawnx = Double.parseDouble(Spawncoords[0]);
double spawny = Double.parseDouble(Spawncoords[1]);
@ -36,21 +36,22 @@ public class DeathListener implements Listener{
String pname = p.getName();
int players = plugin.Playing.size()-1;
String leftmsg = ChatColor.BLUE + "There are now " + players + " tributes left!";
String[] Spawncoords = plugin.config.getString("Spawn_coords").split(",");
String[] Spawncoords = plugin.spawns.getString("Spawn_coords").split(",");
World spawnw = plugin.getServer().getWorld(Spawncoords[3]);
double spawnx = Double.parseDouble(Spawncoords[0]);
double spawny = Double.parseDouble(Spawncoords[1]);
double spawnz = Double.parseDouble(Spawncoords[2]);
Location Spawn = new Location(spawnw, spawnx, spawny, spawnz);
if(plugin.config.getString("Cannon_Death").equalsIgnoreCase("True")){
double y = p.getLocation().getY();
double newy = y+200;
double x = p.getLocation().getX();
double z = p.getLocation().getZ();
Location strike = new Location(p.getWorld(), x, newy, z);
p.getWorld().strikeLightning(strike);
}
if(plugin.Frozen.contains(pname) && plugin.Playing.contains(pname)){
if(plugin.config.getString("Cannon_Death").equalsIgnoreCase("True")){
double y = p.getLocation().getY();
double newy = y+200;
double x = p.getLocation().getX();
double z = p.getLocation().getZ();
Location strike = new Location(p.getWorld(), x, newy, z);
p.getWorld().strikeLightning(strike);
}
event.setDeathMessage("");
p.getServer().broadcastMessage(pname + ChatColor.LIGHT_PURPLE + " Stepped off their pedestal too early!");
plugin.Frozen.remove(pname);
@ -59,34 +60,39 @@ public class DeathListener implements Listener{
s.broadcastMessage(leftmsg);
if(plugin.Playing.size()== 1 && plugin.canjoin== false){
//Announce winner
String winnername = plugin.Playing.get(i++);
Player winner = plugin.getServer().getPlayerExact(winnername);
String winnername2 = winner.getName();
plugin.getServer().broadcastMessage(ChatColor.GREEN + winnername2 + " is the victor of this Hunger Games!");
winner.getInventory().clear();
winner.teleport(Spawn);
winner.getInventory().setBoots(null);
winner.getInventory().setChestplate(null);
winner.getInventory().setHelmet(null);
winner.getInventory().setLeggings(null);
winner.getInventory().addItem(plugin.Reward);
plugin.Playing.clear();
//Show spectators
if(!plugin.Watching.isEmpty()){
String s1 = plugin.Watching.get(i++);
Player spectator = plugin.getServer().getPlayerExact(s1);
spectator.setAllowFlight(false);
spectator.teleport(Spawn);
for(Player online:plugin.getServer().getOnlinePlayers()){
online.showPlayer(spectator);
}
for(i = 0; i < plugin.Playing.size(); i++){
String winnername = plugin.Playing.get(i++);
Player winner = plugin.getServer().getPlayerExact(winnername);
String winnername2 = winner.getName();
plugin.getServer().broadcastMessage(ChatColor.GREEN + winnername2 + " is the victor of this Hunger Games!");
winner.getInventory().clear();
winner.teleport(Spawn);
winner.getInventory().setBoots(null);
winner.getInventory().setChestplate(null);
winner.getInventory().setHelmet(null);
winner.getInventory().setLeggings(null);
winner.getInventory().addItem(plugin.Reward);
plugin.Playing.clear();
}
//Show spectators
for(String sname: plugin.Watching){
Player spectator = plugin.getServer().getPlayerExact(sname);
spectator.setAllowFlight(false);
spectator.teleport(spectator.getWorld().getSpawnLocation());
for(Player online:plugin.getServer().getOnlinePlayers()){
online.showPlayer(spectator);
}
}
if(plugin.config.getString("Auto_Restart").equalsIgnoreCase("True")){
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha restart");
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
public void run(){
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha restart");
}
}, 220L);
}
}
}
if(plugin.Playing.contains(pname)){
}else if(plugin.Playing.contains(pname)){
if(plugin.config.getString("Cannon_Death").equalsIgnoreCase("True")){
double y = p.getLocation().getY();
double newy = y+200;
@ -106,26 +112,30 @@ public class DeathListener implements Listener{
s.broadcastMessage(leftmsg);
if(plugin.Playing.size()== 1 && plugin.canjoin== true){
//Announce winner
String winnername = plugin.Playing.get(i++);
Player winner = plugin.getServer().getPlayerExact(winnername);
String winnername2 = winner.getName();
plugin.getServer().broadcastMessage(ChatColor.GREEN + winnername2 + " is the victor of this Hunger Games!");
winner.getInventory().clear();
winner.teleport(Spawn);
winner.getInventory().setBoots(null);
winner.getInventory().setChestplate(null);
winner.getInventory().setHelmet(null);
winner.getInventory().setLeggings(null);
winner.getInventory().addItem(plugin.Reward);
for(i = 0; i < plugin.Playing.size(); i++){
String winnername = plugin.Playing.get(i++);
Player winner = plugin.getServer().getPlayerExact(winnername);
String winnername2 = winner.getName();
plugin.getServer().broadcastMessage(ChatColor.GREEN + winnername2 + " is the victor of this Hunger Games!");
winner.getInventory().clear();
winner.teleport(Spawn);
winner.getInventory().setBoots(null);
winner.getInventory().setChestplate(null);
winner.getInventory().setHelmet(null);
winner.getInventory().setLeggings(null);
winner.getInventory().addItem(plugin.Reward);
}
plugin.Playing.clear();
//Show spectators
if(!plugin.Watching.isEmpty()){
String s1 = plugin.Watching.get(i++);
Player spectator = plugin.getServer().getPlayerExact(s1);
spectator.setAllowFlight(false);
spectator.teleport(Spawn);
for(Player online:plugin.getServer().getOnlinePlayers()){
online.showPlayer(spectator);
for(i = 0; i < plugin.Watching.size(); i++){
String s1 = plugin.Watching.get(i++);
Player spectator = plugin.getServer().getPlayerExact(s1);
spectator.setAllowFlight(false);
spectator.teleport(Spawn);
for(Player online:plugin.getServer().getOnlinePlayers()){
online.showPlayer(spectator);
}
}
}
if(plugin.config.getString("Auto_Restart").equalsIgnoreCase("True")){
@ -142,26 +152,30 @@ public class DeathListener implements Listener{
s.broadcastMessage(leftmsg);
if(plugin.Playing.size()== 1 && plugin.canjoin== true){
//Announce winner
String winnername = plugin.Playing.get(i++);
Player winner = plugin.getServer().getPlayerExact(winnername);
String winnername2 = winner.getName();
plugin.getServer().broadcastMessage(ChatColor.GREEN + winnername2 + " is the victor of this Hunger Games!");
winner.getInventory().clear();
winner.teleport(Spawn);
winner.getInventory().setBoots(null);
winner.getInventory().setChestplate(null);
winner.getInventory().setHelmet(null);
winner.getInventory().setLeggings(null);
winner.getInventory().addItem(plugin.Reward);
for(i = 0; i < plugin.Playing.size(); i++){
String winnername = plugin.Playing.get(i++);
Player winner = plugin.getServer().getPlayerExact(winnername);
String winnername2 = winner.getName();
plugin.getServer().broadcastMessage(ChatColor.GREEN + winnername2 + " is the victor of this Hunger Games!");
winner.getInventory().clear();
winner.teleport(Spawn);
winner.getInventory().setBoots(null);
winner.getInventory().setChestplate(null);
winner.getInventory().setHelmet(null);
winner.getInventory().setLeggings(null);
winner.getInventory().addItem(plugin.Reward);
}
plugin.Playing.clear();
//Show spectators
if(plugin.Watching.size() != 0){
String s1 = plugin.Watching.get(i++);
Player spectator = plugin.getServer().getPlayerExact(s1);
spectator.setAllowFlight(false);
spectator.teleport(Spawn);
for(Player online:plugin.getServer().getOnlinePlayers()){
online.showPlayer(spectator);
for(i = 0; i < plugin.Watching.size(); i++){
String s1 = plugin.Watching.get(i++);
Player spectator = plugin.getServer().getPlayerExact(s1);
spectator.setAllowFlight(false);
spectator.teleport(Spawn);
for(Player online:plugin.getServer().getOnlinePlayers()){
online.showPlayer(spectator);
}
}
}
if(plugin.config.getString("Auto_Restart").equalsIgnoreCase("True")){
@ -175,30 +189,34 @@ public class DeathListener implements Listener{
s.broadcastMessage(leftmsg);
if(plugin.Playing.size()== 1 && plugin.canjoin== true){
//Announce winner
String winnername = plugin.Playing.get(i++);
Player winner = plugin.getServer().getPlayerExact(winnername);
String winnername2 = winner.getName();
plugin.getServer().broadcastMessage(ChatColor.GREEN + winnername2 + " is the victor of this Hunger Games!");
winner.getInventory().clear();
winner.teleport(Spawn);
winner.getInventory().setBoots(null);
winner.getInventory().setChestplate(null);
winner.getInventory().setHelmet(null);
winner.getInventory().setLeggings(null);
winner.getInventory().addItem(plugin.Reward);
for(i = 0; i < plugin.Playing.size(); i++){
String winnername = plugin.Playing.get(i++);
Player winner = plugin.getServer().getPlayerExact(winnername);
String winnername2 = winner.getName();
plugin.getServer().broadcastMessage(ChatColor.GREEN + winnername2 + " is the victor of this Hunger Games!");
winner.getInventory().clear();
winner.teleport(Spawn);
winner.getInventory().setBoots(null);
winner.getInventory().setChestplate(null);
winner.getInventory().setHelmet(null);
winner.getInventory().setLeggings(null);
winner.getInventory().addItem(plugin.Reward);
}
// Create the event here
PlayerWinGamesEvent winevent = new PlayerWinGamesEvent(winner);
//PlayerWinGamesEvent winevent = new PlayerWinGamesEvent(winner);
// Call the event
Bukkit.getServer().getPluginManager().callEvent(winevent);
//Bukkit.getServer().getPluginManager().callEvent(winevent);
plugin.Playing.clear();
//Show spectators
if(!plugin.Watching.isEmpty()){
String s1 = plugin.Watching.get(i++);
Player spectator = plugin.getServer().getPlayerExact(s1);
spectator.setAllowFlight(false);
spectator.teleport(Spawn);
for(Player online:plugin.getServer().getOnlinePlayers()){
online.showPlayer(spectator);
for(i = 0; i < plugin.Watching.size(); i++){
String s1 = plugin.Watching.get(i++);
Player spectator = plugin.getServer().getPlayerExact(s1);
spectator.setAllowFlight(false);
spectator.teleport(Spawn);
for(Player online:plugin.getServer().getOnlinePlayers()){
online.showPlayer(spectator);
}
}
}
if(plugin.config.getString("Auto_Restart").equalsIgnoreCase("True")){

View File

@ -22,7 +22,7 @@ public class FreezeListener implements Listener {
String one = plugin.Playing.get(0);
if(pname==one){
Player tone = plugin.getServer().getPlayerExact(one);
String[] onecoords = plugin.config.getString("Tribute_one_spawn").split(",");
String[] onecoords = plugin.spawns.getString("Tribute_one_spawn").split(",");
double x = Double.parseDouble(onecoords[0]);
double y = Double.parseDouble(onecoords[1]);
double z = Double.parseDouble(onecoords[2]);
@ -41,7 +41,7 @@ public class FreezeListener implements Listener {
String two = plugin.Playing.get(1);
if(pname==two){
Player ttwo = plugin.getServer().getPlayerExact(two);
String[] twocoords = plugin.config.getString("Tribute_two_spawn").split(",");
String[] twocoords = plugin.spawns.getString("Tribute_two_spawn").split(",");
double twox = Double.parseDouble(twocoords[0]);
double twoy = Double.parseDouble(twocoords[1]);
double twoz = Double.parseDouble(twocoords[2]);
@ -60,7 +60,7 @@ public class FreezeListener implements Listener {
String three = plugin.Playing.get(2);
if(pname==three){
Player tthree = plugin.getServer().getPlayerExact(three);
String[] threecoords = plugin.config.getString("Tribute_three_spawn").split(",");
String[] threecoords = plugin.spawns.getString("Tribute_three_spawn").split(",");
double threex = Double.parseDouble(threecoords[0]);
double threey = Double.parseDouble(threecoords[1]);
double threez = Double.parseDouble(threecoords[2]);
@ -79,7 +79,7 @@ public class FreezeListener implements Listener {
String four = plugin.Playing.get(3);
if(pname==four){
Player tfour = plugin.getServer().getPlayerExact(four);
String[] fourcoords = plugin.config.getString("Tribute_four_spawn").split(",");
String[] fourcoords = plugin.spawns.getString("Tribute_four_spawn").split(",");
double fourx = Double.parseDouble(fourcoords[0]);
double foury = Double.parseDouble(fourcoords[1]);
double fourz = Double.parseDouble(fourcoords[2]);
@ -98,7 +98,7 @@ public class FreezeListener implements Listener {
String five = plugin.Playing.get(4);
if(pname==five){
Player tfive = plugin.getServer().getPlayerExact(five);
String[] fivecoords = plugin.config.getString("Tribute_five_spawn").split(",");
String[] fivecoords = plugin.spawns.getString("Tribute_five_spawn").split(",");
double fivex = Double.parseDouble(fivecoords[0]);
double fivey = Double.parseDouble(fivecoords[1]);
double fivez = Double.parseDouble(fivecoords[2]);
@ -117,7 +117,7 @@ public class FreezeListener implements Listener {
String six = plugin.Playing.get(5);
if(pname==six){
Player tsix = plugin.getServer().getPlayerExact(six);
String[] sixcoords = plugin.config.getString("Tribute_six_spawn").split(",");
String[] sixcoords = plugin.spawns.getString("Tribute_six_spawn").split(",");
double sixx = Double.parseDouble(sixcoords[0]);
double sixy = Double.parseDouble(sixcoords[1]);
double sixz = Double.parseDouble(sixcoords[2]);
@ -136,7 +136,7 @@ public class FreezeListener implements Listener {
String seven = plugin.Playing.get(6);
if(pname==seven){
Player tseven = plugin.getServer().getPlayerExact(seven);
String[] sevencoords = plugin.config.getString("Tribute_seven_spawn").split(",");
String[] sevencoords = plugin.spawns.getString("Tribute_seven_spawn").split(",");
double sevenx = Double.parseDouble(sevencoords[0]);
double seveny = Double.parseDouble(sevencoords[1]);
double sevenz = Double.parseDouble(sevencoords[2]);
@ -155,7 +155,7 @@ public class FreezeListener implements Listener {
String eight = plugin.Playing.get(7);
if(pname==eight){
Player teight = plugin.getServer().getPlayerExact(eight);
String[] eightcoords = plugin.config.getString("Tribute_eight_spawn").split(",");
String[] eightcoords = plugin.spawns.getString("Tribute_eight_spawn").split(",");
double eightx = Double.parseDouble(eightcoords[0]);
double eighty = Double.parseDouble(eightcoords[1]);
double eightz = Double.parseDouble(eightcoords[2]);
@ -174,7 +174,7 @@ public class FreezeListener implements Listener {
String nine = plugin.Playing.get(8);
if(pname==nine){
Player tnine = plugin.getServer().getPlayerExact(nine);
String[] ninecoords = plugin.config.getString("Tribute_nine_spawn").split(",");
String[] ninecoords = plugin.spawns.getString("Tribute_nine_spawn").split(",");
double ninex = Double.parseDouble(ninecoords[0]);
double niney = Double.parseDouble(ninecoords[1]);
double ninez = Double.parseDouble(ninecoords[2]);
@ -193,7 +193,7 @@ public class FreezeListener implements Listener {
String ten = plugin.Playing.get(9);
if(pname==ten){
Player tten = plugin.getServer().getPlayerExact(ten);
String[] tencoords = plugin.config.getString("Tribute_ten_spawn").split(",");
String[] tencoords = plugin.spawns.getString("Tribute_ten_spawn").split(",");
double tenx = Double.parseDouble(tencoords[0]);
double teny = Double.parseDouble(tencoords[1]);
double tenz = Double.parseDouble(tencoords[2]);
@ -212,7 +212,7 @@ public class FreezeListener implements Listener {
String eleven = plugin.Playing.get(10);
if(pname==eleven){
Player televen = plugin.getServer().getPlayerExact(eleven);
String[] elevencoords = plugin.config.getString("Tribute_eleven_spawn").split(",");
String[] elevencoords = plugin.spawns.getString("Tribute_eleven_spawn").split(",");
double elevenx = Double.parseDouble(elevencoords[0]);
double eleveny = Double.parseDouble(elevencoords[1]);
double elevenz = Double.parseDouble(elevencoords[2]);
@ -231,7 +231,7 @@ public class FreezeListener implements Listener {
String twelve = plugin.Playing.get(11);
if(pname==twelve){
Player ttwelve = plugin.getServer().getPlayerExact(twelve);
String[] twelvecoords = plugin.config.getString("Tribute_twelve_spawn").split(",");
String[] twelvecoords = plugin.spawns.getString("Tribute_twelve_spawn").split(",");
double twelvex = Double.parseDouble(twelvecoords[0]);
double twelvey = Double.parseDouble(twelvecoords[1]);
double twelvez = Double.parseDouble(twelvecoords[2]);
@ -250,7 +250,7 @@ public class FreezeListener implements Listener {
String thirteen = plugin.Playing.get(12);
if(pname==thirteen){
Player tthirteen = plugin.getServer().getPlayerExact(thirteen);
String[] thirteencoords = plugin.config.getString("Tribute_thirteen_spawn").split(",");
String[] thirteencoords = plugin.spawns.getString("Tribute_thirteen_spawn").split(",");
double thirteenx = Double.parseDouble(thirteencoords[0]);
double thirteeny = Double.parseDouble(thirteencoords[1]);
double thirteenz = Double.parseDouble(thirteencoords[2]);
@ -269,7 +269,7 @@ public class FreezeListener implements Listener {
String fourteen = plugin.Playing.get(13);
if(pname==fourteen){
Player tfourteen = plugin.getServer().getPlayerExact(fourteen);
String[] fourteencoords = plugin.config.getString("Tribute_fourteen_spawn").split(",");
String[] fourteencoords = plugin.spawns.getString("Tribute_fourteen_spawn").split(",");
double fourteenx = Double.parseDouble(fourteencoords[0]);
double fourteeny = Double.parseDouble(fourteencoords[1]);
double fourteenz = Double.parseDouble(fourteencoords[2]);
@ -288,7 +288,7 @@ public class FreezeListener implements Listener {
String fifteen = plugin.Playing.get(14);
if(pname==fifteen){
Player tfifteen = plugin.getServer().getPlayerExact(fifteen);
String[] fifteencoords = plugin.config.getString("Tribute_fifteen_spawn").split(",");
String[] fifteencoords = plugin.spawns.getString("Tribute_fifteen_spawn").split(",");
double fifteenx = Double.parseDouble(fifteencoords[0]);
double fifteeny = Double.parseDouble(fifteencoords[1]);
double fifteenz = Double.parseDouble(fifteencoords[2]);
@ -307,7 +307,7 @@ public class FreezeListener implements Listener {
String sixteen = plugin.Playing.get(15);
if(pname==sixteen){
Player tsixteen = plugin.getServer().getPlayerExact(sixteen);
String[] sixteencoords = plugin.config.getString("Tribute_sixteen_spawn").split(",");
String[] sixteencoords = plugin.spawns.getString("Tribute_sixteen_spawn").split(",");
double sixteenx = Double.parseDouble(sixteencoords[0]);
double sixteeny = Double.parseDouble(sixteencoords[1]);
double sixteenz = Double.parseDouble(sixteencoords[2]);
@ -326,7 +326,7 @@ public class FreezeListener implements Listener {
String seventeen = plugin.Playing.get(16);
if(pname==seventeen){
Player tseventeen = plugin.getServer().getPlayerExact(seventeen);
String[] seventeencoords = plugin.config.getString("Tribute_seventeen_spawn").split(",");
String[] seventeencoords = plugin.spawns.getString("Tribute_seventeen_spawn").split(",");
double seventeenx = Double.parseDouble(seventeencoords[0]);
double seventeeny = Double.parseDouble(seventeencoords[1]);
double seventeenz = Double.parseDouble(seventeencoords[2]);
@ -345,7 +345,7 @@ public class FreezeListener implements Listener {
String eighteen = plugin.Playing.get(17);
if(pname==eighteen){
Player teighteen = plugin.getServer().getPlayerExact(eighteen);
String[] eighteencoords = plugin.config.getString("Tribute_eighteen_spawn").split(",");
String[] eighteencoords = plugin.spawns.getString("Tribute_eighteen_spawn").split(",");
double eighteenx = Double.parseDouble(eighteencoords[0]);
double eighteeny = Double.parseDouble(eighteencoords[1]);
double eighteenz = Double.parseDouble(eighteencoords[2]);
@ -364,7 +364,7 @@ public class FreezeListener implements Listener {
String nineteen = plugin.Playing.get(18);
if(pname==nineteen){
Player tnineteen = plugin.getServer().getPlayerExact(nineteen);
String[] nineteencoords = plugin.config.getString("Tribute_nineteen_spawn").split(",");
String[] nineteencoords = plugin.spawns.getString("Tribute_nineteen_spawn").split(",");
double nineteenx = Double.parseDouble(nineteencoords[0]);
double nineteeny = Double.parseDouble(nineteencoords[1]);
double nineteenz = Double.parseDouble(nineteencoords[2]);
@ -383,7 +383,7 @@ public class FreezeListener implements Listener {
String twenty = plugin.Playing.get(19);
if(pname==twenty){
Player ttwenty = plugin.getServer().getPlayerExact(twenty);
String[] twentycoords = plugin.config.getString("Tribute_twenty_spawn").split(",");
String[] twentycoords = plugin.spawns.getString("Tribute_twenty_spawn").split(",");
double twentyx = Double.parseDouble(twentycoords[0]);
double twentyy = Double.parseDouble(twentycoords[1]);
double twentyz = Double.parseDouble(twentycoords[2]);
@ -402,7 +402,7 @@ public class FreezeListener implements Listener {
String twentyone = plugin.Playing.get(20);
if(pname==twentyone){
Player ttwentyone = plugin.getServer().getPlayerExact(twentyone);
String[] twentyonecoords = plugin.config.getString("Tribute_twentyone_spawn").split(",");
String[] twentyonecoords = plugin.spawns.getString("Tribute_twentyone_spawn").split(",");
double twentyonex = Double.parseDouble(twentyonecoords[0]);
double twentyoney = Double.parseDouble(twentyonecoords[1]);
double twentyonez = Double.parseDouble(twentyonecoords[2]);
@ -421,7 +421,7 @@ public class FreezeListener implements Listener {
String twentytwo = plugin.Playing.get(21);
if(pname==twentytwo){
Player ttwentytwo = plugin.getServer().getPlayerExact(twentytwo);
String[] twentytwocoords = plugin.config.getString("Tribute_twentytwo_spawn").split(",");
String[] twentytwocoords = plugin.spawns.getString("Tribute_twentytwo_spawn").split(",");
double twentytwox = Double.parseDouble(twentytwocoords[0]);
double twentytwoy = Double.parseDouble(twentytwocoords[1]);
double twentytwoz = Double.parseDouble(twentytwocoords[2]);
@ -440,7 +440,7 @@ public class FreezeListener implements Listener {
String twentythree = plugin.Playing.get(22);
if(pname==twentythree){
Player ttwentythree = plugin.getServer().getPlayerExact(twentythree);
String[] twentythreecoords = plugin.config.getString("Tribute_twentythree_spawn").split(",");
String[] twentythreecoords = plugin.spawns.getString("Tribute_twentythree_spawn").split(",");
double twentythreex = Double.parseDouble(twentythreecoords[0]);
double twentythreey = Double.parseDouble(twentythreecoords[1]);
double twentythreez = Double.parseDouble(twentythreecoords[2]);
@ -459,7 +459,7 @@ public class FreezeListener implements Listener {
String twentyfour = plugin.Playing.get(23);
if(pname==twentyfour){
Player ttwentyfour = plugin.getServer().getPlayerExact(twentyfour);
String[] twentyfourcoords = plugin.config.getString("Tribute_twentyfour_spawn").split(",");
String[] twentyfourcoords = plugin.spawns.getString("Tribute_twentyfour_spawn").split(",");
double twentyfourx = Double.parseDouble(twentyfourcoords[0]);
double twentyfoury = Double.parseDouble(twentyfourcoords[1]);
double twentyfourz = Double.parseDouble(twentyfourcoords[2]);
@ -479,7 +479,7 @@ public class FreezeListener implements Listener {
String one = plugin.Playing.get(0);
if(pname==one){
Player tone = plugin.getServer().getPlayerExact(one);
String[] onecoords = plugin.config.getString("Tribute_one_spawn").split(",");
String[] onecoords = plugin.spawns.getString("Tribute_one_spawn").split(",");
double x = Double.parseDouble(onecoords[0]);
double y = Double.parseDouble(onecoords[1]);
double z = Double.parseDouble(onecoords[2]);
@ -494,7 +494,7 @@ public class FreezeListener implements Listener {
String two = plugin.Playing.get(1);
if(pname==two){
Player ttwo = plugin.getServer().getPlayerExact(two);
String[] twocoords = plugin.config.getString("Tribute_two_spawn").split(",");
String[] twocoords = plugin.spawns.getString("Tribute_two_spawn").split(",");
double twox = Double.parseDouble(twocoords[0]);
double twoy = Double.parseDouble(twocoords[1]);
double twoz = Double.parseDouble(twocoords[2]);
@ -509,7 +509,7 @@ public class FreezeListener implements Listener {
String three = plugin.Playing.get(2);
if(pname==three){
Player tthree = plugin.getServer().getPlayerExact(three);
String[] threecoords = plugin.config.getString("Tribute_three_spawn").split(",");
String[] threecoords = plugin.spawns.getString("Tribute_three_spawn").split(",");
double threex = Double.parseDouble(threecoords[0]);
double threey = Double.parseDouble(threecoords[1]);
double threez = Double.parseDouble(threecoords[2]);
@ -524,7 +524,7 @@ public class FreezeListener implements Listener {
String four = plugin.Playing.get(3);
if(pname==four){
Player tfour = plugin.getServer().getPlayerExact(four);
String[] fourcoords = plugin.config.getString("Tribute_four_spawn").split(",");
String[] fourcoords = plugin.spawns.getString("Tribute_four_spawn").split(",");
double fourx = Double.parseDouble(fourcoords[0]);
double foury = Double.parseDouble(fourcoords[1]);
double fourz = Double.parseDouble(fourcoords[2]);
@ -539,7 +539,7 @@ public class FreezeListener implements Listener {
String five = plugin.Playing.get(4);
if(pname==five){
Player tfive = plugin.getServer().getPlayerExact(five);
String[] fivecoords = plugin.config.getString("Tribute_five_spawn").split(",");
String[] fivecoords = plugin.spawns.getString("Tribute_five_spawn").split(",");
double fivex = Double.parseDouble(fivecoords[0]);
double fivey = Double.parseDouble(fivecoords[1]);
double fivez = Double.parseDouble(fivecoords[2]);
@ -554,7 +554,7 @@ public class FreezeListener implements Listener {
String six = plugin.Playing.get(5);
if(pname==six){
Player tsix = plugin.getServer().getPlayerExact(six);
String[] sixcoords = plugin.config.getString("Tribute_six_spawn").split(",");
String[] sixcoords = plugin.spawns.getString("Tribute_six_spawn").split(",");
double sixx = Double.parseDouble(sixcoords[0]);
double sixy = Double.parseDouble(sixcoords[1]);
double sixz = Double.parseDouble(sixcoords[2]);
@ -569,7 +569,7 @@ public class FreezeListener implements Listener {
String seven = plugin.Playing.get(6);
if(pname==seven){
Player tseven = plugin.getServer().getPlayerExact(seven);
String[] sevencoords = plugin.config.getString("Tribute_seven_spawn").split(",");
String[] sevencoords = plugin.spawns.getString("Tribute_seven_spawn").split(",");
double sevenx = Double.parseDouble(sevencoords[0]);
double seveny = Double.parseDouble(sevencoords[1]);
double sevenz = Double.parseDouble(sevencoords[2]);
@ -584,7 +584,7 @@ public class FreezeListener implements Listener {
String eight = plugin.Playing.get(7);
if(pname==eight){
Player teight = plugin.getServer().getPlayerExact(eight);
String[] eightcoords = plugin.config.getString("Tribute_eight_spawn").split(",");
String[] eightcoords = plugin.spawns.getString("Tribute_eight_spawn").split(",");
double eightx = Double.parseDouble(eightcoords[0]);
double eighty = Double.parseDouble(eightcoords[1]);
double eightz = Double.parseDouble(eightcoords[2]);
@ -599,7 +599,7 @@ public class FreezeListener implements Listener {
String nine = plugin.Playing.get(8);
if(pname==nine){
Player tnine = plugin.getServer().getPlayerExact(nine);
String[] ninecoords = plugin.config.getString("Tribute_nine_spawn").split(",");
String[] ninecoords = plugin.spawns.getString("Tribute_nine_spawn").split(",");
double ninex = Double.parseDouble(ninecoords[0]);
double niney = Double.parseDouble(ninecoords[1]);
double ninez = Double.parseDouble(ninecoords[2]);
@ -614,7 +614,7 @@ public class FreezeListener implements Listener {
String ten = plugin.Playing.get(9);
if(pname==ten){
Player tten = plugin.getServer().getPlayerExact(ten);
String[] tencoords = plugin.config.getString("Tribute_ten_spawn").split(",");
String[] tencoords = plugin.spawns.getString("Tribute_ten_spawn").split(",");
double tenx = Double.parseDouble(tencoords[0]);
double teny = Double.parseDouble(tencoords[1]);
double tenz = Double.parseDouble(tencoords[2]);
@ -629,7 +629,7 @@ public class FreezeListener implements Listener {
String eleven = plugin.Playing.get(10);
if(pname==eleven){
Player televen = plugin.getServer().getPlayerExact(eleven);
String[] elevencoords = plugin.config.getString("Tribute_eleven_spawn").split(",");
String[] elevencoords = plugin.spawns.getString("Tribute_eleven_spawn").split(",");
double elevenx = Double.parseDouble(elevencoords[0]);
double eleveny = Double.parseDouble(elevencoords[1]);
double elevenz = Double.parseDouble(elevencoords[2]);
@ -644,7 +644,7 @@ public class FreezeListener implements Listener {
String twelve = plugin.Playing.get(11);
if(pname==twelve){
Player ttwelve = plugin.getServer().getPlayerExact(twelve);
String[] twelvecoords = plugin.config.getString("Tribute_twelve_spawn").split(",");
String[] twelvecoords = plugin.spawns.getString("Tribute_twelve_spawn").split(",");
double twelvex = Double.parseDouble(twelvecoords[0]);
double twelvey = Double.parseDouble(twelvecoords[1]);
double twelvez = Double.parseDouble(twelvecoords[2]);
@ -659,7 +659,7 @@ public class FreezeListener implements Listener {
String thirteen = plugin.Playing.get(12);
if(pname==thirteen){
Player tthirteen = plugin.getServer().getPlayerExact(thirteen);
String[] thirteencoords = plugin.config.getString("Tribute_thirteen_spawn").split(",");
String[] thirteencoords = plugin.spawns.getString("Tribute_thirteen_spawn").split(",");
double thirteenx = Double.parseDouble(thirteencoords[0]);
double thirteeny = Double.parseDouble(thirteencoords[1]);
double thirteenz = Double.parseDouble(thirteencoords[2]);
@ -674,7 +674,7 @@ public class FreezeListener implements Listener {
String fourteen = plugin.Playing.get(13);
if(pname==fourteen){
Player tfourteen = plugin.getServer().getPlayerExact(fourteen);
String[] fourteencoords = plugin.config.getString("Tribute_fourteen_spawn").split(",");
String[] fourteencoords = plugin.spawns.getString("Tribute_fourteen_spawn").split(",");
double fourteenx = Double.parseDouble(fourteencoords[0]);
double fourteeny = Double.parseDouble(fourteencoords[1]);
double fourteenz = Double.parseDouble(fourteencoords[2]);
@ -689,7 +689,7 @@ public class FreezeListener implements Listener {
String fifteen = plugin.Playing.get(14);
if(pname==fifteen){
Player tfifteen = plugin.getServer().getPlayerExact(fifteen);
String[] fifteencoords = plugin.config.getString("Tribute_fifteen_spawn").split(",");
String[] fifteencoords = plugin.spawns.getString("Tribute_fifteen_spawn").split(",");
double fifteenx = Double.parseDouble(fifteencoords[0]);
double fifteeny = Double.parseDouble(fifteencoords[1]);
double fifteenz = Double.parseDouble(fifteencoords[2]);
@ -704,7 +704,7 @@ public class FreezeListener implements Listener {
String sixteen = plugin.Playing.get(15);
if(pname==sixteen){
Player tsixteen = plugin.getServer().getPlayerExact(sixteen);
String[] sixteencoords = plugin.config.getString("Tribute_sixteen_spawn").split(",");
String[] sixteencoords = plugin.spawns.getString("Tribute_sixteen_spawn").split(",");
double sixteenx = Double.parseDouble(sixteencoords[0]);
double sixteeny = Double.parseDouble(sixteencoords[1]);
double sixteenz = Double.parseDouble(sixteencoords[2]);
@ -719,7 +719,7 @@ public class FreezeListener implements Listener {
String seventeen = plugin.Playing.get(16);
if(pname==seventeen){
Player tseventeen = plugin.getServer().getPlayerExact(seventeen);
String[] seventeencoords = plugin.config.getString("Tribute_seventeen_spawn").split(",");
String[] seventeencoords = plugin.spawns.getString("Tribute_seventeen_spawn").split(",");
double seventeenx = Double.parseDouble(seventeencoords[0]);
double seventeeny = Double.parseDouble(seventeencoords[1]);
double seventeenz = Double.parseDouble(seventeencoords[2]);
@ -734,7 +734,7 @@ public class FreezeListener implements Listener {
String eighteen = plugin.Playing.get(17);
if(pname==eighteen){
Player teighteen = plugin.getServer().getPlayerExact(eighteen);
String[] eighteencoords = plugin.config.getString("Tribute_eighteen_spawn").split(",");
String[] eighteencoords = plugin.spawns.getString("Tribute_eighteen_spawn").split(",");
double eighteenx = Double.parseDouble(eighteencoords[0]);
double eighteeny = Double.parseDouble(eighteencoords[1]);
double eighteenz = Double.parseDouble(eighteencoords[2]);
@ -749,7 +749,7 @@ public class FreezeListener implements Listener {
String nineteen = plugin.Playing.get(18);
if(pname==nineteen){
Player tnineteen = plugin.getServer().getPlayerExact(nineteen);
String[] nineteencoords = plugin.config.getString("Tribute_nineteen_spawn").split(",");
String[] nineteencoords = plugin.spawns.getString("Tribute_nineteen_spawn").split(",");
double nineteenx = Double.parseDouble(nineteencoords[0]);
double nineteeny = Double.parseDouble(nineteencoords[1]);
double nineteenz = Double.parseDouble(nineteencoords[2]);
@ -764,7 +764,7 @@ public class FreezeListener implements Listener {
String twenty = plugin.Playing.get(19);
if(pname==twenty){
Player ttwenty = plugin.getServer().getPlayerExact(twenty);
String[] twentycoords = plugin.config.getString("Tribute_twenty_spawn").split(",");
String[] twentycoords = plugin.spawns.getString("Tribute_twenty_spawn").split(",");
double twentyx = Double.parseDouble(twentycoords[0]);
double twentyy = Double.parseDouble(twentycoords[1]);
double twentyz = Double.parseDouble(twentycoords[2]);
@ -779,7 +779,7 @@ public class FreezeListener implements Listener {
String twentyone = plugin.Playing.get(20);
if(pname==twentyone){
Player ttwentyone = plugin.getServer().getPlayerExact(twentyone);
String[] twentyonecoords = plugin.config.getString("Tribute_twentyone_spawn").split(",");
String[] twentyonecoords = plugin.spawns.getString("Tribute_twentyone_spawn").split(",");
double twentyonex = Double.parseDouble(twentyonecoords[0]);
double twentyoney = Double.parseDouble(twentyonecoords[1]);
double twentyonez = Double.parseDouble(twentyonecoords[2]);
@ -794,7 +794,7 @@ public class FreezeListener implements Listener {
String twentytwo = plugin.Playing.get(21);
if(pname==twentytwo){
Player ttwentytwo = plugin.getServer().getPlayerExact(twentytwo);
String[] twentytwocoords = plugin.config.getString("Tribute_twentytwo_spawn").split(",");
String[] twentytwocoords = plugin.spawns.getString("Tribute_twentytwo_spawn").split(",");
double twentytwox = Double.parseDouble(twentytwocoords[0]);
double twentytwoy = Double.parseDouble(twentytwocoords[1]);
double twentytwoz = Double.parseDouble(twentytwocoords[2]);
@ -809,7 +809,7 @@ public class FreezeListener implements Listener {
String twentythree = plugin.Playing.get(22);
if(pname==twentythree){
Player ttwentythree = plugin.getServer().getPlayerExact(twentythree);
String[] twentythreecoords = plugin.config.getString("Tribute_twentythree_spawn").split(",");
String[] twentythreecoords = plugin.spawns.getString("Tribute_twentythree_spawn").split(",");
double twentythreex = Double.parseDouble(twentythreecoords[0]);
double twentythreey = Double.parseDouble(twentythreecoords[1]);
double twentythreez = Double.parseDouble(twentythreecoords[2]);
@ -824,7 +824,7 @@ public class FreezeListener implements Listener {
String twentyfour = plugin.Playing.get(23);
if(pname==twentyfour){
Player ttwentyfour = plugin.getServer().getPlayerExact(twentyfour);
String[] twentyfourcoords = plugin.config.getString("Tribute_twentyfour_spawn").split(",");
String[] twentyfourcoords = plugin.spawns.getString("Tribute_twentyfour_spawn").split(",");
double twentyfourx = Double.parseDouble(twentyfourcoords[0]);
double twentyfoury = Double.parseDouble(twentyfourcoords[1]);
double twentyfourz = Double.parseDouble(twentyfourcoords[2]);

View File

@ -20,10 +20,10 @@ public class HaCommands implements CommandExecutor {
this.plugin = m;
}
int i = 0;
@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "deprecation" })
@Override
public boolean onCommand(final CommandSender sender, Command cmd, String commandLabel, String[] args){
String[] Spawncoords = plugin.config.getString("Spawn_coords").split(",");
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]);
@ -62,6 +62,7 @@ public class HaCommands implements CommandExecutor {
sender.sendMessage(c + "/ha rlist - See who's ready!");
sender.sendMessage(c + "/startpoint [1,2,3,4,etc] - Sets the starting points of tributes!");
sender.sendMessage(ChatColor.GREEN + "----------------------");
//////////////////////////////////////// LISTING ///////////////////////////////////////////////
}else if(args[0].equalsIgnoreCase("List")){
if(p.hasPermission("HungerArena.GameMaker")){
sender.sendMessage(ChatColor.AQUA + "-----People Playing-----");
@ -92,19 +93,21 @@ public class HaCommands implements CommandExecutor {
}else{
p.sendMessage(ChatColor.RED + "You don't have permission!");
}
////////////////////////////////////////////////////////////////////////////////////////////////
}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.config.set("Spawn_coords", x + "," + y + "," + z + "," + w);
plugin.config.set("Spawns_set", "true");
plugin.saveConfig();
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!");
}
///////////////////////////////////// JOINING/LEAVING ////////////////////////////////////////////////////
}else if(args[0].equalsIgnoreCase("Join")){
if(p.hasPermission("HungerArena.Join")){
if(plugin.Playing.contains(pname)){
@ -115,7 +118,9 @@ public class HaCommands implements CommandExecutor {
p.sendMessage(ChatColor.RED + "There are already 24 Tributes!");
}else if(plugin.canjoin== true){
p.sendMessage(ChatColor.RED + "The game is in progress!");
}else if(plugin.config.getString("Spawns_set").equalsIgnoreCase("false")){
}else if(!plugin.open){
p.sendMessage(ChatColor.RED + "The 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.contains(pname)){
p.sendMessage(ChatColor.RED + "You need to do /ha confirm");
@ -129,9 +134,10 @@ public class HaCommands implements CommandExecutor {
p.getInventory().setChestplate(null);
p.getInventory().setHelmet(null);
p.getInventory().setLeggings(null);
p.updateInventory();
plugin.getServer().broadcastMessage(ChatColor.AQUA + pname + " has Joined the Game!");
if(plugin.Playing.size()== 24){
p.performCommand("ha warpall");
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha warpall");
}
}
}else{
@ -147,6 +153,7 @@ public class HaCommands implements CommandExecutor {
p.getInventory().setChestplate(null);
p.getInventory().setHelmet(null);
p.getInventory().setLeggings(null);
p.updateInventory();
plugin.getServer().broadcastMessage(ChatColor.AQUA + pname + " has Joined the Game!");
if(plugin.Playing.size()== 24){
p.performCommand("ha warpall");
@ -200,32 +207,37 @@ public class HaCommands implements CommandExecutor {
}
if(plugin.Playing.size()== 1){
//Announce the Winner
String winnername = plugin.Playing.get(i++);
Player winner = plugin.getServer().getPlayerExact(winnername);
String winnername2 = winner.getName();
plugin.getServer().broadcastMessage(ChatColor.GREEN + winnername2 + " is the victor of this Hunger Games!");
winner.getInventory().clear();
winner.teleport(Spawn);
winner.getInventory().setBoots(null);
winner.getInventory().setChestplate(null);
winner.getInventory().setHelmet(null);
winner.getInventory().setLeggings(null);
winner.getInventory().addItem(plugin.Reward);
Bukkit.getServer().getPluginManager().callEvent(new PlayerWinGamesEvent(winner));
for(i = 0; i < plugin.Playing.size(); i++){
String winnername = plugin.Playing.get(i++);
Player winner = plugin.getServer().getPlayerExact(winnername);
String winnername2 = winner.getName();
plugin.getServer().broadcastMessage(ChatColor.GREEN + winnername2 + " is the victor of this Hunger Games!");
winner.getInventory().clear();
winner.teleport(Spawn);
winner.getInventory().setBoots(null);
winner.getInventory().setChestplate(null);
winner.getInventory().setHelmet(null);
winner.getInventory().setLeggings(null);
winner.getInventory().addItem(plugin.Reward);
Bukkit.getServer().getPluginManager().callEvent(new PlayerWinGamesEvent(winner));
}
plugin.Playing.clear();
//Show spectators
String s = plugin.Watching.get(i++);
Player spectator = plugin.getServer().getPlayerExact(s);
spectator.setAllowFlight(false);
spectator.teleport(Spawn);
for(Player online:plugin.getServer().getOnlinePlayers()){
online.showPlayer(spectator);
for(i = 0; i < plugin.Watching.size(); i++){
String s = plugin.Watching.get(i++);
Player spectator = plugin.getServer().getPlayerExact(s);
spectator.setAllowFlight(false);
spectator.teleport(Spawn);
for(Player online:plugin.getServer().getOnlinePlayers()){
online.showPlayer(spectator);
}
}
if(plugin.config.getString("Auto_Restart").equalsIgnoreCase("True")){
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha restart");
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}else if(args[0].equalsIgnoreCase("Watch")){
if(sender.hasPermission("HungerArena.Watch")){
if(!plugin.Watching.contains(pname) && !plugin.Playing.contains(pname) && plugin.canjoin== true){
@ -268,26 +280,30 @@ public class HaCommands implements CommandExecutor {
target.getInventory().setLeggings(null);
plugin.Quit.add(target.getName());
if(plugin.Playing.size()== 1 && plugin.canjoin== true){
String winnername = plugin.Playing.get(i++);
Player winner = plugin.getServer().getPlayerExact(winnername);
String winnername2 = winner.getName();
plugin.getServer().broadcastMessage(ChatColor.GREEN + winnername2 + " is the victor of this Hunger Games!");
winner.getInventory().clear();
winner.teleport(Spawn);
winner.getInventory().setBoots(null);
winner.getInventory().setChestplate(null);
winner.getInventory().setHelmet(null);
winner.getInventory().setLeggings(null);
winner.getInventory().addItem(plugin.Reward);
Bukkit.getServer().getPluginManager().callEvent(new PlayerWinGamesEvent(winner));
for(i = 0; i < plugin.Playing.size(); i++){
String winnername = plugin.Playing.get(i++);
Player winner = plugin.getServer().getPlayerExact(winnername);
String winnername2 = winner.getName();
plugin.getServer().broadcastMessage(ChatColor.GREEN + winnername2 + " is the victor of this Hunger Games!");
winner.getInventory().clear();
winner.teleport(Spawn);
winner.getInventory().setBoots(null);
winner.getInventory().setChestplate(null);
winner.getInventory().setHelmet(null);
winner.getInventory().setLeggings(null);
winner.getInventory().addItem(plugin.Reward);
Bukkit.getServer().getPluginManager().callEvent(new PlayerWinGamesEvent(winner));
}
plugin.Playing.clear();
if(!plugin.Watching.isEmpty()){
String s = plugin.Watching.get(i++);
Player spectator = plugin.getServer().getPlayerExact(s);
spectator.setAllowFlight(false);
spectator.teleport(Spawn);
for(Player online:plugin.getServer().getOnlinePlayers()){
online.showPlayer(spectator);
for(i = 0; i < plugin.Watching.size(); i++){
String s = plugin.Watching.get(i++);
Player spectator = plugin.getServer().getPlayerExact(s);
spectator.setAllowFlight(false);
spectator.teleport(Spawn);
for(Player online:plugin.getServer().getOnlinePlayers()){
online.showPlayer(spectator);
}
}
}
if(plugin.config.getString("Auto_Restart").equalsIgnoreCase("True")){
@ -337,12 +353,14 @@ public class HaCommands implements CommandExecutor {
}else if(args[0].equalsIgnoreCase("Restart")){
if(p.hasPermission("HungerArena.Restart")){
if(!plugin.Watching.isEmpty()){
String s = plugin.Watching.get(i++);
Player spectator = plugin.getServer().getPlayerExact(s);
spectator.setAllowFlight(false);
spectator.teleport(Spawn);
for(Player online:plugin.getServer().getOnlinePlayers()){
online.showPlayer(spectator);
for(i = 0; i < plugin.Watching.size(); i++){
String s = plugin.Watching.get(i++);
Player spectator = plugin.getServer().getPlayerExact(s);
spectator.setAllowFlight(false);
spectator.teleport(Spawn);
for(Player online:plugin.getServer().getOnlinePlayers()){
online.showPlayer(spectator);
}
}
}
plugin.Dead.clear();
@ -359,20 +377,70 @@ public class HaCommands implements CommandExecutor {
}else{
p.sendMessage(ChatColor.RED + "You don't have permission!");
}
/////////////////////////////////// Toggle //////////////////////////////////////////////////
}else if(args[0].equalsIgnoreCase("close")){
if(p.hasPermission("HungerArena.toggle")){
if(plugin.open){
plugin.open = false;
for(String players: plugin.Playing){
Player tributes = plugin.getServer().getPlayerExact(players);
tributes.teleport(tributes.getWorld().getSpawnLocation());
tributes.getInventory().clear();
tributes.getInventory().setBoots(null);
tributes.getInventory().setChestplate(null);
tributes.getInventory().setHelmet(null);
tributes.getInventory().setLeggings(null);
}
for(String sname: plugin.Watching){
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();
p.performCommand("ha refill");
p.sendMessage(ChatColor.GOLD + "Games Closed!");
}else{
p.sendMessage(ChatColor.RED + "Games alredy close, 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(!plugin.open){
plugin.open = true;
p.sendMessage(ChatColor.GOLD + "Games Opened!!");
}else{
p.sendMessage(ChatColor.RED + "Games already open, type /ha close to close them!");
}
}else{
p.sendMessage(ChatColor.RED + "No Perms!");
}
////////////////////////////////////////////////////////////////////////////////////////////
}else if(args[0].equalsIgnoreCase("Reload")){
plugin.reloadConfig();
p.sendMessage(ChatColor.AQUA + "HungerArena Reloaded!");
}else if(args[0].equalsIgnoreCase("WarpAll")){
if(p.hasPermission("HungerArena.Warpall")){
if(plugin.config.getString("Spawns_set").equalsIgnoreCase("false")){
if(plugin.spawns.getString("Spawns_set").equalsIgnoreCase("false")){
sender.sendMessage(ChatColor.RED + "/ha setspawn hasn't been run!");
}else{
if(plugin.Playing.size()== 1){
sender.sendMessage(ChatColor.RED + "There are not enough players!");
}
if(plugin.Playing.size()>= 2){
plugin.config.getString("Tribute_one_spawn");
String[] onecoords = plugin.config.getString("Tribute_one_spawn").split(",");
plugin.spawns.getString("Tribute_one_spawn");
String[] onecoords = plugin.spawns.getString("Tribute_one_spawn").split(",");
Player Tribute_one = plugin.getServer().getPlayerExact(plugin.Playing.get(0));
double x = Double.parseDouble(onecoords[0]);
double y = Double.parseDouble(onecoords[1]);
@ -383,8 +451,8 @@ public class HaCommands implements CommandExecutor {
Tribute_one.teleport(oneloc);
plugin.Frozen.add(Tribute_one.getName());
Tribute_one.setFoodLevel(20);
plugin.config.getString("Tribute_two_spawn");
String[] twocoords = plugin.config.getString("Tribute_two_spawn").split(",");
plugin.spawns.getString("Tribute_two_spawn");
String[] twocoords = plugin.spawns.getString("Tribute_two_spawn").split(",");
Player Tribute_two = plugin.getServer().getPlayerExact(plugin.Playing.get(1));
double twox = Double.parseDouble(twocoords[0]);
double twoy = Double.parseDouble(twocoords[1]);
@ -410,8 +478,8 @@ public class HaCommands implements CommandExecutor {
}, 20L);
}
if(plugin.Playing.size()>= 3){
plugin.config.getString("Tribute_three_spawn");
String[] coords = plugin.config.getString("Tribute_three_spawn").split(",");
plugin.spawns.getString("Tribute_three_spawn");
String[] coords = plugin.spawns.getString("Tribute_three_spawn").split(",");
Player Tribute_three = plugin.getServer().getPlayerExact(plugin.Playing.get(2));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -424,8 +492,8 @@ public class HaCommands implements CommandExecutor {
Tribute_three.setFoodLevel(20);
}
if(plugin.Playing.size()>= 4){
plugin.config.getString("Tribute_four_spawn");
String[] coords = plugin.config.getString("Tribute_four_spawn").split(",");
plugin.spawns.getString("Tribute_four_spawn");
String[] coords = plugin.spawns.getString("Tribute_four_spawn").split(",");
Player Tribute_four = plugin.getServer().getPlayerExact(plugin.Playing.get(3));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -438,8 +506,8 @@ public class HaCommands implements CommandExecutor {
Tribute_four.setFoodLevel(20);
}
if(plugin.Playing.size()>= 5){
plugin.config.getString("Tribute_five_spawn");
String[] coords = plugin.config.getString("Tribute_five_spawn").split(",");
plugin.spawns.getString("Tribute_five_spawn");
String[] coords = plugin.spawns.getString("Tribute_five_spawn").split(",");
Player Tribute_five = plugin.getServer().getPlayerExact(plugin.Playing.get(4));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -452,8 +520,8 @@ public class HaCommands implements CommandExecutor {
Tribute_five.setFoodLevel(20);
}
if(plugin.Playing.size()>= 6){
plugin.config.getString("Tribute_six_spawn");
String[] coords = plugin.config.getString("Tribute_six_spawn").split(",");
plugin.spawns.getString("Tribute_six_spawn");
String[] coords = plugin.spawns.getString("Tribute_six_spawn").split(",");
Player Tribute_six = plugin.getServer().getPlayerExact(plugin.Playing.get(5));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -466,8 +534,8 @@ public class HaCommands implements CommandExecutor {
Tribute_six.setFoodLevel(20);
}
if(plugin.Playing.size()>= 7){
plugin.config.getString("Tribute_seven_spawn");
String[] coords = plugin.config.getString("Tribute_seven_spawn").split(",");
plugin.spawns.getString("Tribute_seven_spawn");
String[] coords = plugin.spawns.getString("Tribute_seven_spawn").split(",");
Player Tribute_seven = plugin.getServer().getPlayerExact(plugin.Playing.get(6));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -480,8 +548,8 @@ public class HaCommands implements CommandExecutor {
Tribute_seven.setFoodLevel(20);
}
if(plugin.Playing.size()>= 8){
plugin.config.getString("Tribute_eight_spawn");
String[] coords = plugin.config.getString("Tribute_eight_spawn").split(",");
plugin.spawns.getString("Tribute_eight_spawn");
String[] coords = plugin.spawns.getString("Tribute_eight_spawn").split(",");
Player Tribute_eight = plugin.getServer().getPlayerExact(plugin.Playing.get(7));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -494,8 +562,8 @@ public class HaCommands implements CommandExecutor {
Tribute_eight.setFoodLevel(20);
}
if(plugin.Playing.size()>= 9){
plugin.config.getString("Tribute_nine_spawn");
String[] coords = plugin.config.getString("Tribute_nine_spawn").split(",");
plugin.spawns.getString("Tribute_nine_spawn");
String[] coords = plugin.spawns.getString("Tribute_nine_spawn").split(",");
Player Tribute_nine = plugin.getServer().getPlayerExact(plugin.Playing.get(8));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -508,8 +576,8 @@ public class HaCommands implements CommandExecutor {
Tribute_nine.setFoodLevel(20);
}
if(plugin.Playing.size()>= 10){
plugin.config.getString("Tribute_ten_spawn");
String[] coords = plugin.config.getString("Tribute_ten_spawn").split(",");
plugin.spawns.getString("Tribute_ten_spawn");
String[] coords = plugin.spawns.getString("Tribute_ten_spawn").split(",");
Player Tribute_ten = plugin.getServer().getPlayerExact(plugin.Playing.get(9));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -522,8 +590,8 @@ public class HaCommands implements CommandExecutor {
Tribute_ten.setFoodLevel(20);
}
if(plugin.Playing.size()>= 11){
plugin.config.getString("Tribute_eleven_spawn");
String[] coords = plugin.config.getString("Tribute_eleven_spawn").split(",");
plugin.spawns.getString("Tribute_eleven_spawn");
String[] coords = plugin.spawns.getString("Tribute_eleven_spawn").split(",");
Player Tribute_eleven = plugin.getServer().getPlayerExact(plugin.Playing.get(10));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -536,8 +604,8 @@ public class HaCommands implements CommandExecutor {
Tribute_eleven.setFoodLevel(20);
}
if(plugin.Playing.size()>= 12){
plugin.config.getString("Tribute_twelve_spawn");
String[] coords = plugin.config.getString("Tribute_twelve_spawn").split(",");
plugin.spawns.getString("Tribute_twelve_spawn");
String[] coords = plugin.spawns.getString("Tribute_twelve_spawn").split(",");
Player Tribute_twelve = plugin.getServer().getPlayerExact(plugin.Playing.get(11));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -550,8 +618,8 @@ public class HaCommands implements CommandExecutor {
Tribute_twelve.setFoodLevel(20);
}
if(plugin.Playing.size()>= 13){
plugin.config.getString("Tribute_thirteen_spawn");
String[] coords = plugin.config.getString("Tribute_thirteen_spawn").split(",");
plugin.spawns.getString("Tribute_thirteen_spawn");
String[] coords = plugin.spawns.getString("Tribute_thirteen_spawn").split(",");
Player Tribute_thirteen = plugin.getServer().getPlayerExact(plugin.Playing.get(12));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -564,8 +632,8 @@ public class HaCommands implements CommandExecutor {
Tribute_thirteen.setFoodLevel(20);
}
if(plugin.Playing.size()>= 14){
plugin.config.getString("Tribute_fourteen_spawn");
String[] coords = plugin.config.getString("Tribute_fourteen_spawn").split(",");
plugin.spawns.getString("Tribute_fourteen_spawn");
String[] coords = plugin.spawns.getString("Tribute_fourteen_spawn").split(",");
Player Tribute_fourteen = plugin.getServer().getPlayerExact(plugin.Playing.get(13));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -578,8 +646,8 @@ public class HaCommands implements CommandExecutor {
Tribute_fourteen.setFoodLevel(20);
}
if(plugin.Playing.size()>= 15){
plugin.config.getString("Tribute_fifteen_spawn");
String[] coords = plugin.config.getString("Tribute_fifteen_spawn").split(",");
plugin.spawns.getString("Tribute_fifteen_spawn");
String[] coords = plugin.spawns.getString("Tribute_fifteen_spawn").split(",");
Player Tribute_fifteen = plugin.getServer().getPlayerExact(plugin.Playing.get(14));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -592,8 +660,8 @@ public class HaCommands implements CommandExecutor {
Tribute_fifteen.setFoodLevel(20);
}
if(plugin.Playing.size()>= 16){
plugin.config.getString("Tribute_sixteen_spawn");
String[] coords = plugin.config.getString("Tribute_sixteen_spawn").split(",");
plugin.spawns.getString("Tribute_sixteen_spawn");
String[] coords = plugin.spawns.getString("Tribute_sixteen_spawn").split(",");
Player Tribute_sixteen = plugin.getServer().getPlayerExact(plugin.Playing.get(15));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -606,8 +674,8 @@ public class HaCommands implements CommandExecutor {
Tribute_sixteen.setFoodLevel(20);
}
if(plugin.Playing.size()>= 17){
plugin.config.getString("Tribute_seventeen_spawn");
String[] coords = plugin.config.getString("Tribute_seventeen_spawn").split(",");
plugin.spawns.getString("Tribute_seventeen_spawn");
String[] coords = plugin.spawns.getString("Tribute_seventeen_spawn").split(",");
Player Tribute_seventeen = plugin.getServer().getPlayerExact(plugin.Playing.get(16));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -620,8 +688,8 @@ public class HaCommands implements CommandExecutor {
Tribute_seventeen.setFoodLevel(20);
}
if(plugin.Playing.size()>= 18){
plugin.config.getString("Tribute_eighteen_spawn");
String[] coords = plugin.config.getString("Tribute_eighteen_spawn").split(",");
plugin.spawns.getString("Tribute_eighteen_spawn");
String[] coords = plugin.spawns.getString("Tribute_eighteen_spawn").split(",");
Player Tribute_eighteen = plugin.getServer().getPlayerExact(plugin.Playing.get(17));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -634,8 +702,8 @@ public class HaCommands implements CommandExecutor {
Tribute_eighteen.setFoodLevel(20);
}
if(plugin.Playing.size()>= 19){
plugin.config.getString("Tribute_nineteen_spawn");
String[] coords = plugin.config.getString("Tribute_nineteen_spawn").split(",");
plugin.spawns.getString("Tribute_nineteen_spawn");
String[] coords = plugin.spawns.getString("Tribute_nineteen_spawn").split(",");
Player Tribute_nineteen = plugin.getServer().getPlayerExact(plugin.Playing.get(18));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -648,8 +716,8 @@ public class HaCommands implements CommandExecutor {
Tribute_nineteen.setFoodLevel(20);
}
if(plugin.Playing.size()>= 20){
plugin.config.getString("Tribute_twenty_spawn");
String[] coords = plugin.config.getString("Tribute_twenty_spawn").split(",");
plugin.spawns.getString("Tribute_twenty_spawn");
String[] coords = plugin.spawns.getString("Tribute_twenty_spawn").split(",");
Player Tribute_twenty = plugin.getServer().getPlayerExact(plugin.Playing.get(19));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -662,8 +730,8 @@ public class HaCommands implements CommandExecutor {
Tribute_twenty.setFoodLevel(20);
}
if(plugin.Playing.size()>= 21){
plugin.config.getString("Tribute_twentyone_spawn");
String[] coords = plugin.config.getString("Tribute_twentyone_spawn").split(",");
plugin.spawns.getString("Tribute_twentyone_spawn");
String[] coords = plugin.spawns.getString("Tribute_twentyone_spawn").split(",");
Player Tribute_twentyone = plugin.getServer().getPlayerExact(plugin.Playing.get(20));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -676,8 +744,8 @@ public class HaCommands implements CommandExecutor {
Tribute_twentyone.setFoodLevel(20);
}
if(plugin.Playing.size()>= 22){
plugin.config.getString("Tribute_twentytwo_spawn");
String[] coords = plugin.config.getString("Tribute_twentytwo_spawn").split(",");
plugin.spawns.getString("Tribute_twentytwo_spawn");
String[] coords = plugin.spawns.getString("Tribute_twentytwo_spawn").split(",");
Player Tribute_twentytwo = plugin.getServer().getPlayerExact(plugin.Playing.get(21));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -690,8 +758,8 @@ public class HaCommands implements CommandExecutor {
Tribute_twentytwo.setFoodLevel(20);
}
if(plugin.Playing.size()>= 23){
plugin.config.getString("Tribute_twentythree_spawn");
String[] coords = plugin.config.getString("Tribute_twentythree_spawn").split(",");
plugin.spawns.getString("Tribute_twentythree_spawn");
String[] coords = plugin.spawns.getString("Tribute_twentythree_spawn").split(",");
Player Tribute_twentythree = plugin.getServer().getPlayerExact(plugin.Playing.get(22));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -704,8 +772,8 @@ public class HaCommands implements CommandExecutor {
Tribute_twentythree.setFoodLevel(20);
}
if(plugin.Playing.size()>= 24){
plugin.config.getString("Tribute_twentyfour_spawn");
String[] coords = plugin.config.getString("Tribute_twentyfour_spawn").split(",");
plugin.spawns.getString("Tribute_twentyfour_spawn");
String[] coords = plugin.spawns.getString("Tribute_twentyfour_spawn").split(",");
Player Tribute_twentyfour = plugin.getServer().getPlayerExact(plugin.Playing.get(23));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -861,27 +929,31 @@ public class HaCommands implements CommandExecutor {
plugin.Quit.add(target.getName());
if(plugin.Playing.size()== 1 && plugin.canjoin== true){
//Announce winner
String winnername = plugin.Playing.get(i++);
Player winner = plugin.getServer().getPlayerExact(winnername);
String winnername2 = winner.getName();
plugin.getServer().broadcastMessage(ChatColor.GREEN + winnername2 + " is the victor of this Hunger Games!");
winner.getInventory().clear();
winner.teleport(Spawn);
winner.getInventory().setBoots(null);
winner.getInventory().setChestplate(null);
winner.getInventory().setHelmet(null);
winner.getInventory().setLeggings(null);
winner.getInventory().addItem(plugin.Reward);
Bukkit.getServer().getPluginManager().callEvent(new PlayerWinGamesEvent(winner));
for(i = 0; i < plugin.Playing.size(); i++){
String winnername = plugin.Playing.get(i++);
Player winner = plugin.getServer().getPlayerExact(winnername);
String winnername2 = winner.getName();
plugin.getServer().broadcastMessage(ChatColor.GREEN + winnername2 + " is the victor of this Hunger Games!");
winner.getInventory().clear();
winner.teleport(Spawn);
winner.getInventory().setBoots(null);
winner.getInventory().setChestplate(null);
winner.getInventory().setHelmet(null);
winner.getInventory().setLeggings(null);
winner.getInventory().addItem(plugin.Reward);
Bukkit.getServer().getPluginManager().callEvent(new PlayerWinGamesEvent(winner));
}
plugin.Playing.clear();
//Make spectators visible
if(!plugin.Watching.isEmpty()){
String s = plugin.Watching.get(i++);
Player spectator = plugin.getServer().getPlayerExact(s);
spectator.setAllowFlight(false);
spectator.teleport(Spawn);
for(Player online:plugin.getServer().getOnlinePlayers()){
online.showPlayer(spectator);
for(i = 0; i < plugin.Watching.size(); i++){
String s = plugin.Watching.get(i++);
Player spectator = plugin.getServer().getPlayerExact(s);
spectator.setAllowFlight(false);
spectator.teleport(Spawn);
for(Player online:plugin.getServer().getOnlinePlayers()){
online.showPlayer(spectator);
}
}
}
if(plugin.config.getString("Auto_Restart").equalsIgnoreCase("True")){
@ -923,12 +995,14 @@ public class HaCommands implements CommandExecutor {
}
}else if(args[0].equalsIgnoreCase("Restart")){
if(!plugin.Watching.isEmpty()){
String s = plugin.Watching.get(i++);
Player spectator = plugin.getServer().getPlayerExact(s);
spectator.setAllowFlight(false);
spectator.teleport(Spawn);
for(Player online:plugin.getServer().getOnlinePlayers()){
online.showPlayer(spectator);
for(i = 0; i < plugin.Watching.size(); i++){
String s = plugin.Watching.get(i++);
Player spectator = plugin.getServer().getPlayerExact(s);
spectator.setAllowFlight(false);
spectator.teleport(Spawn);
for(Player online:plugin.getServer().getOnlinePlayers()){
online.showPlayer(spectator);
}
}
}
plugin.Dead.clear();
@ -942,19 +1016,61 @@ public class HaCommands implements CommandExecutor {
plugin.canjoin = false;
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha refill");
sender.sendMessage(ChatColor.AQUA + "The games have been reset!");
/////////////////////////////////// Toggle //////////////////////////////////////////////////
}else if(args[0].equalsIgnoreCase("close")){
if(plugin.open){
plugin.open = false;
for(String players: plugin.Playing){
Player tributes = plugin.getServer().getPlayerExact(players);
tributes.teleport(tributes.getWorld().getSpawnLocation());
tributes.getInventory().clear();
tributes.getInventory().setBoots(null);
tributes.getInventory().setChestplate(null);
tributes.getInventory().setHelmet(null);
tributes.getInventory().setLeggings(null);
}
for(String sname: plugin.Watching){
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();
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha refill");
sender.sendMessage(ChatColor.GOLD + "Games Closed!");
}else{
sender.sendMessage(ChatColor.RED + "Games alredy close, type /ha open to re-open them!");
}
}else if(args[0].equalsIgnoreCase("open")){
if(!plugin.open){
plugin.open = true;
sender.sendMessage(ChatColor.GOLD + "Games Opened!!");
}else{
sender.sendMessage(ChatColor.RED + "Games already open, type /ha close to close them!");
}
////////////////////////////////////////////////////////////////////////////////////////////
}else if(args[0].equalsIgnoreCase("Reload")){
plugin.reloadConfig();
sender.sendMessage(ChatColor.AQUA + "HungerArena Reloaded!");
}else if(args[0].equalsIgnoreCase("WarpAll")){
if(plugin.config.getString("Spawns_set").equalsIgnoreCase("false")){
if(plugin.spawns.getString("Spawns_set").equalsIgnoreCase("false")){
sender.sendMessage(ChatColor.RED + "/ha setspawn hasn't been run!");
}else{
if(plugin.Playing.size()== 1){
sender.sendMessage(ChatColor.RED + "There are not enough players!");
}
if(plugin.Playing.size()>= 2){
plugin.config.getString("Tribute_one_spawn");
String[] onecoords = plugin.config.getString("Tribute_one_spawn").split(",");
plugin.spawns.getString("Tribute_one_spawn");
String[] onecoords = plugin.spawns.getString("Tribute_one_spawn").split(",");
Player Tribute_one = plugin.getServer().getPlayerExact(plugin.Playing.get(0));
double x = Double.parseDouble(onecoords[0]);
double y = Double.parseDouble(onecoords[1]);
@ -965,8 +1081,8 @@ public class HaCommands implements CommandExecutor {
Tribute_one.teleport(oneloc);
plugin.Frozen.add(Tribute_one.getName());
Tribute_one.setFoodLevel(20);
plugin.config.getString("Tribute_two_spawn");
String[] twocoords = plugin.config.getString("Tribute_two_spawn").split(",");
plugin.spawns.getString("Tribute_two_spawn");
String[] twocoords = plugin.spawns.getString("Tribute_two_spawn").split(",");
Player Tribute_two = plugin.getServer().getPlayerExact(plugin.Playing.get(1));
double twox = Double.parseDouble(twocoords[0]);
double twoy = Double.parseDouble(twocoords[1]);
@ -992,8 +1108,8 @@ public class HaCommands implements CommandExecutor {
}, 20L);
}
if(plugin.Playing.size()>= 3){
plugin.config.getString("Tribute_three_spawn");
String[] coords = plugin.config.getString("Tribute_three_spawn").split(",");
plugin.spawns.getString("Tribute_three_spawn");
String[] coords = plugin.spawns.getString("Tribute_three_spawn").split(",");
Player Tribute_three = plugin.getServer().getPlayerExact(plugin.Playing.get(2));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -1006,8 +1122,8 @@ public class HaCommands implements CommandExecutor {
Tribute_three.setFoodLevel(20);
}
if(plugin.Playing.size()>= 4){
plugin.config.getString("Tribute_four_spawn");
String[] coords = plugin.config.getString("Tribute_four_spawn").split(",");
plugin.spawns.getString("Tribute_four_spawn");
String[] coords = plugin.spawns.getString("Tribute_four_spawn").split(",");
Player Tribute_four = plugin.getServer().getPlayerExact(plugin.Playing.get(3));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -1020,8 +1136,8 @@ public class HaCommands implements CommandExecutor {
Tribute_four.setFoodLevel(20);
}
if(plugin.Playing.size()>= 5){
plugin.config.getString("Tribute_five_spawn");
String[] coords = plugin.config.getString("Tribute_five_spawn").split(",");
plugin.spawns.getString("Tribute_five_spawn");
String[] coords = plugin.spawns.getString("Tribute_five_spawn").split(",");
Player Tribute_five = plugin.getServer().getPlayerExact(plugin.Playing.get(4));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -1034,8 +1150,8 @@ public class HaCommands implements CommandExecutor {
Tribute_five.setFoodLevel(20);
}
if(plugin.Playing.size()>= 6){
plugin.config.getString("Tribute_six_spawn");
String[] coords = plugin.config.getString("Tribute_six_spawn").split(",");
plugin.spawns.getString("Tribute_six_spawn");
String[] coords = plugin.spawns.getString("Tribute_six_spawn").split(",");
Player Tribute_six = plugin.getServer().getPlayerExact(plugin.Playing.get(5));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -1048,8 +1164,8 @@ public class HaCommands implements CommandExecutor {
Tribute_six.setFoodLevel(20);
}
if(plugin.Playing.size()>= 7){
plugin.config.getString("Tribute_seven_spawn");
String[] coords = plugin.config.getString("Tribute_seven_spawn").split(",");
plugin.spawns.getString("Tribute_seven_spawn");
String[] coords = plugin.spawns.getString("Tribute_seven_spawn").split(",");
Player Tribute_seven = plugin.getServer().getPlayerExact(plugin.Playing.get(6));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -1062,8 +1178,8 @@ public class HaCommands implements CommandExecutor {
Tribute_seven.setFoodLevel(20);
}
if(plugin.Playing.size()>= 8){
plugin.config.getString("Tribute_eight_spawn");
String[] coords = plugin.config.getString("Tribute_eight_spawn").split(",");
plugin.spawns.getString("Tribute_eight_spawn");
String[] coords = plugin.spawns.getString("Tribute_eight_spawn").split(",");
Player Tribute_eight = plugin.getServer().getPlayerExact(plugin.Playing.get(7));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -1076,8 +1192,8 @@ public class HaCommands implements CommandExecutor {
Tribute_eight.setFoodLevel(20);
}
if(plugin.Playing.size()>= 9){
plugin.config.getString("Tribute_nine_spawn");
String[] coords = plugin.config.getString("Tribute_nine_spawn").split(",");
plugin.spawns.getString("Tribute_nine_spawn");
String[] coords = plugin.spawns.getString("Tribute_nine_spawn").split(",");
Player Tribute_nine = plugin.getServer().getPlayerExact(plugin.Playing.get(8));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -1090,8 +1206,8 @@ public class HaCommands implements CommandExecutor {
Tribute_nine.setFoodLevel(20);
}
if(plugin.Playing.size()>= 10){
plugin.config.getString("Tribute_ten_spawn");
String[] coords = plugin.config.getString("Tribute_ten_spawn").split(",");
plugin.spawns.getString("Tribute_ten_spawn");
String[] coords = plugin.spawns.getString("Tribute_ten_spawn").split(",");
Player Tribute_ten = plugin.getServer().getPlayerExact(plugin.Playing.get(9));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -1104,8 +1220,8 @@ public class HaCommands implements CommandExecutor {
Tribute_ten.setFoodLevel(20);
}
if(plugin.Playing.size()>= 11){
plugin.config.getString("Tribute_eleven_spawn");
String[] coords = plugin.config.getString("Tribute_eleven_spawn").split(",");
plugin.spawns.getString("Tribute_eleven_spawn");
String[] coords = plugin.spawns.getString("Tribute_eleven_spawn").split(",");
Player Tribute_eleven = plugin.getServer().getPlayerExact(plugin.Playing.get(10));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -1118,8 +1234,8 @@ public class HaCommands implements CommandExecutor {
Tribute_eleven.setFoodLevel(20);
}
if(plugin.Playing.size()>= 12){
plugin.config.getString("Tribute_twelve_spawn");
String[] coords = plugin.config.getString("Tribute_twelve_spawn").split(",");
plugin.spawns.getString("Tribute_twelve_spawn");
String[] coords = plugin.spawns.getString("Tribute_twelve_spawn").split(",");
Player Tribute_twelve = plugin.getServer().getPlayerExact(plugin.Playing.get(11));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -1132,8 +1248,8 @@ public class HaCommands implements CommandExecutor {
Tribute_twelve.setFoodLevel(20);
}
if(plugin.Playing.size()>= 13){
plugin.config.getString("Tribute_thirteen_spawn");
String[] coords = plugin.config.getString("Tribute_thirteen_spawn").split(",");
plugin.spawns.getString("Tribute_thirteen_spawn");
String[] coords = plugin.spawns.getString("Tribute_thirteen_spawn").split(",");
Player Tribute_thirteen = plugin.getServer().getPlayerExact(plugin.Playing.get(12));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -1146,8 +1262,8 @@ public class HaCommands implements CommandExecutor {
Tribute_thirteen.setFoodLevel(20);
}
if(plugin.Playing.size()>= 14){
plugin.config.getString("Tribute_fourteen_spawn");
String[] coords = plugin.config.getString("Tribute_fourteen_spawn").split(",");
plugin.spawns.getString("Tribute_fourteen_spawn");
String[] coords = plugin.spawns.getString("Tribute_fourteen_spawn").split(",");
Player Tribute_fourteen = plugin.getServer().getPlayerExact(plugin.Playing.get(13));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -1160,8 +1276,8 @@ public class HaCommands implements CommandExecutor {
Tribute_fourteen.setFoodLevel(20);
}
if(plugin.Playing.size()>= 15){
plugin.config.getString("Tribute_fifteen_spawn");
String[] coords = plugin.config.getString("Tribute_fifteen_spawn").split(",");
plugin.spawns.getString("Tribute_fifteen_spawn");
String[] coords = plugin.spawns.getString("Tribute_fifteen_spawn").split(",");
Player Tribute_fifteen = plugin.getServer().getPlayerExact(plugin.Playing.get(14));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -1174,8 +1290,8 @@ public class HaCommands implements CommandExecutor {
Tribute_fifteen.setFoodLevel(20);
}
if(plugin.Playing.size()>= 16){
plugin.config.getString("Tribute_sixteen_spawn");
String[] coords = plugin.config.getString("Tribute_sixteen_spawn").split(",");
plugin.spawns.getString("Tribute_sixteen_spawn");
String[] coords = plugin.spawns.getString("Tribute_sixteen_spawn").split(",");
Player Tribute_sixteen = plugin.getServer().getPlayerExact(plugin.Playing.get(15));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -1188,8 +1304,8 @@ public class HaCommands implements CommandExecutor {
Tribute_sixteen.setFoodLevel(20);
}
if(plugin.Playing.size()>= 17){
plugin.config.getString("Tribute_seventeen_spawn");
String[] coords = plugin.config.getString("Tribute_seventeen_spawn").split(",");
plugin.spawns.getString("Tribute_seventeen_spawn");
String[] coords = plugin.spawns.getString("Tribute_seventeen_spawn").split(",");
Player Tribute_seventeen = plugin.getServer().getPlayerExact(plugin.Playing.get(16));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -1202,8 +1318,8 @@ public class HaCommands implements CommandExecutor {
Tribute_seventeen.setFoodLevel(20);
}
if(plugin.Playing.size()>= 18){
plugin.config.getString("Tribute_eighteen_spawn");
String[] coords = plugin.config.getString("Tribute_eighteen_spawn").split(",");
plugin.spawns.getString("Tribute_eighteen_spawn");
String[] coords = plugin.spawns.getString("Tribute_eighteen_spawn").split(",");
Player Tribute_eighteen = plugin.getServer().getPlayerExact(plugin.Playing.get(17));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -1216,8 +1332,8 @@ public class HaCommands implements CommandExecutor {
Tribute_eighteen.setFoodLevel(20);
}
if(plugin.Playing.size()>= 19){
plugin.config.getString("Tribute_nineteen_spawn");
String[] coords = plugin.config.getString("Tribute_nineteen_spawn").split(",");
plugin.spawns.getString("Tribute_nineteen_spawn");
String[] coords = plugin.spawns.getString("Tribute_nineteen_spawn").split(",");
Player Tribute_nineteen = plugin.getServer().getPlayerExact(plugin.Playing.get(18));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -1230,8 +1346,8 @@ public class HaCommands implements CommandExecutor {
Tribute_nineteen.setFoodLevel(20);
}
if(plugin.Playing.size()>= 20){
plugin.config.getString("Tribute_twenty_spawn");
String[] coords = plugin.config.getString("Tribute_twenty_spawn").split(",");
plugin.spawns.getString("Tribute_twenty_spawn");
String[] coords = plugin.spawns.getString("Tribute_twenty_spawn").split(",");
Player Tribute_twenty = plugin.getServer().getPlayerExact(plugin.Playing.get(19));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -1244,8 +1360,8 @@ public class HaCommands implements CommandExecutor {
Tribute_twenty.setFoodLevel(20);
}
if(plugin.Playing.size()>= 21){
plugin.config.getString("Tribute_twentyone_spawn");
String[] coords = plugin.config.getString("Tribute_twentyone_spawn").split(",");
plugin.spawns.getString("Tribute_twentyone_spawn");
String[] coords = plugin.spawns.getString("Tribute_twentyone_spawn").split(",");
Player Tribute_twentyone = plugin.getServer().getPlayerExact(plugin.Playing.get(20));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -1258,8 +1374,8 @@ public class HaCommands implements CommandExecutor {
Tribute_twentyone.setFoodLevel(20);
}
if(plugin.Playing.size()>= 22){
plugin.config.getString("Tribute_twentytwo_spawn");
String[] coords = plugin.config.getString("Tribute_twentytwo_spawn").split(",");
plugin.spawns.getString("Tribute_twentytwo_spawn");
String[] coords = plugin.spawns.getString("Tribute_twentytwo_spawn").split(",");
Player Tribute_twentytwo = plugin.getServer().getPlayerExact(plugin.Playing.get(21));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -1272,8 +1388,8 @@ public class HaCommands implements CommandExecutor {
Tribute_twentytwo.setFoodLevel(20);
}
if(plugin.Playing.size()>= 23){
plugin.config.getString("Tribute_twentythree_spawn");
String[] coords = plugin.config.getString("Tribute_twentythree_spawn").split(",");
plugin.spawns.getString("Tribute_twentythree_spawn");
String[] coords = plugin.spawns.getString("Tribute_twentythree_spawn").split(",");
Player Tribute_twentythree = plugin.getServer().getPlayerExact(plugin.Playing.get(22));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
@ -1286,8 +1402,8 @@ public class HaCommands implements CommandExecutor {
Tribute_twentythree.setFoodLevel(20);
}
if(plugin.Playing.size()>= 24){
plugin.config.getString("Tribute_twentyfour_spawn");
String[] coords = plugin.config.getString("Tribute_twentyfour_spawn").split(",");
plugin.spawns.getString("Tribute_twentyfour_spawn");
String[] coords = plugin.spawns.getString("Tribute_twentyfour_spawn").split(",");
Player Tribute_twentyfour = plugin.getServer().getPlayerExact(plugin.Playing.get(23));
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);

View File

@ -13,27 +13,29 @@ import org.bukkit.event.player.PlayerQuitEvent;
public class JoinAndQuitListener implements Listener {
public Main plugin;
public JoinAndQuitListener(Main m) {
this.plugin = m;
this.plugin = m;
}
int i = 0;
@EventHandler
public void onJoin(PlayerJoinEvent evt) {
Player p = evt.getPlayer();
for (String s : plugin.Watching) {
Player spectator = Bukkit.getServer().getPlayerExact(s);
p.hidePlayer(spectator);
}
}
@EventHandler
public void onJoin(PlayerJoinEvent evt) {
Player p = evt.getPlayer();
for (String s : plugin.Watching) {
Player spectator = Bukkit.getServer().getPlayerExact(s);
p.hidePlayer(spectator);
}
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event){
final Player p = event.getPlayer();
String pname = p.getName();
if(!plugin.Watching.isEmpty()){
String s = plugin.Watching.get(i++);
Player spectator = plugin.getServer().getPlayerExact(s);
p.hidePlayer(spectator);
for(i = 0; i < plugin.Watching.size(); i++){
String s = plugin.Watching.get(i++);
Player spectator = plugin.getServer().getPlayerExact(s);
p.hidePlayer(spectator);
}
}
if(plugin.Out.contains(pname)){
plugin.Playing.add(pname);
@ -45,7 +47,7 @@ public class JoinAndQuitListener implements Listener {
plugin.Out.remove(pname);
}
if(plugin.Quit.contains(pname) || plugin.Dead.contains(pname)){
String[] Spawncoords = plugin.config.getString("Spawn_coords").split(",");
String[] Spawncoords = plugin.spawns.getString("Spawn_coords").split(",");
String w = Spawncoords[3];
World spawnw = plugin.getServer().getWorld(w);
double spawnx = Double.parseDouble(Spawncoords[0]);
@ -60,29 +62,29 @@ public class JoinAndQuitListener implements Listener {
}, 40L);
}
}
@EventHandler
public void onQuit(PlayerQuitEvent evt) {
Player p = evt.getPlayer();
String pname = p.getName();
if (plugin.Frozen.contains(pname)) {
plugin.Frozen.remove(pname);
String[] Spawncoords = plugin.config.getString("Spawn_coords").split(",");
String w = Spawncoords[3];
World spawnw = plugin.getServer().getWorld(w);
double spawnx = Double.parseDouble(Spawncoords[0]);
double spawny = Double.parseDouble(Spawncoords[1]);
double spawnz = Double.parseDouble(Spawncoords[2]);
Location Spawn = new Location(spawnw, spawnx, spawny, spawnz);
p.teleport(Spawn);
}
}
@EventHandler
public void onQuit(PlayerQuitEvent evt) {
Player p = evt.getPlayer();
String pname = p.getName();
if (plugin.Frozen.contains(pname)) {
plugin.Frozen.remove(pname);
String[] Spawncoords = plugin.spawns.getString("Spawn_coords").split(",");
String w = Spawncoords[3];
World spawnw = plugin.getServer().getWorld(w);
double spawnx = Double.parseDouble(Spawncoords[0]);
double spawny = Double.parseDouble(Spawncoords[1]);
double spawnz = Double.parseDouble(Spawncoords[2]);
Location Spawn = new Location(spawnw, spawnx, spawny, spawnz);
p.teleport(Spawn);
}
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event){
final Player p = event.getPlayer();
final String pname = p.getName();
String[] Spawncoords = plugin.config.getString("Spawn_coords").split(",");
String[] Spawncoords = plugin.spawns.getString("Spawn_coords").split(",");
String w = Spawncoords[3];
World spawnw = plugin.getServer().getWorld(w);
double spawnx = Double.parseDouble(Spawncoords[0]);
@ -92,46 +94,50 @@ public class JoinAndQuitListener implements Listener {
if(plugin.Playing.contains(pname)){
plugin.Out.add(pname);
plugin.Playing.remove(pname);
}
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
public void run(){
if(plugin.Out.contains(pname)){
if(plugin.canjoin== true){
plugin.Quit.add(pname);
plugin.Out.remove(pname);
if(plugin.Playing.size()== 1){
//Announce Winner
String winnername = plugin.Playing.get(i++);
Player winner = plugin.getServer().getPlayerExact(winnername);
String winnername2 = winner.getName();
p.getServer().broadcastMessage(ChatColor.GREEN + winnername2 + " is the victor of this Hunger Games!");
winner.getInventory().clear();
winner.getInventory().setBoots(null);
winner.getInventory().setChestplate(null);
winner.getInventory().setHelmet(null);
winner.getInventory().setLeggings(null);
winner.getInventory().addItem(plugin.Reward);
PlayerWinGamesEvent evt = new PlayerWinGamesEvent(winner);
Bukkit.getServer().getPluginManager().callEvent(evt);
//Make spectators visible
if(!plugin.Watching.isEmpty()){
String s = plugin.Watching.get(i++);
Player spectator = plugin.getServer().getPlayerExact(s);
spectator.setAllowFlight(false);
spectator.teleport(Spawn);
for(Player online:plugin.getServer().getOnlinePlayers()){
online.showPlayer(spectator);
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
public void run(){
if(plugin.Out.contains(pname)){
if(plugin.canjoin== true){
plugin.Quit.add(pname);
plugin.Out.remove(pname);
if(plugin.Playing.size()== 1){
//Announce Winner
for(i = 0; i < plugin.Playing.size(); i++){
String winnername = plugin.Playing.get(i++);
Player winner = plugin.getServer().getPlayerExact(winnername);
String winnername2 = winner.getName();
p.getServer().broadcastMessage(ChatColor.GREEN + winnername2 + " is the victor of this Hunger Games!");
winner.getInventory().clear();
winner.getInventory().setBoots(null);
winner.getInventory().setChestplate(null);
winner.getInventory().setHelmet(null);
winner.getInventory().setLeggings(null);
winner.getInventory().addItem(plugin.Reward);
PlayerWinGamesEvent evt = new PlayerWinGamesEvent(winner);
Bukkit.getServer().getPluginManager().callEvent(evt);
}
//Make spectators visible
if(!plugin.Watching.isEmpty()){
for(i = 0; i < plugin.Playing.size(); i++){
String s = plugin.Watching.get(i++);
Player spectator = plugin.getServer().getPlayerExact(s);
spectator.setAllowFlight(false);
spectator.teleport(Spawn);
for(Player online:plugin.getServer().getOnlinePlayers()){
online.showPlayer(spectator);
}
}
}
if(plugin.config.getString("Auto_Restart").equalsIgnoreCase("True")){
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha restart");
}
}
if(plugin.config.getString("Auto_Restart").equalsIgnoreCase("True")){
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha restart");
}
}
}else{
plugin.Quit.add(pname);
}
}else{
plugin.Quit.add(pname);
}
}
}, 1200L);
}, 1200L);
}
}
}

View File

@ -1,13 +1,18 @@
package me.Travja.HungerArena;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandExecutor;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.RegisteredServiceProvider;
@ -44,7 +49,10 @@ public class Main extends JavaPlugin{
public boolean canjoin;
public boolean exists;
public boolean restricted;
public boolean open = true;
public FileConfiguration config;
public FileConfiguration spawns = null;
public File spawnsFile = null;
public ItemStack Reward;
public ItemStack Cost;
public boolean vault = false;
@ -53,6 +61,9 @@ public class Main extends JavaPlugin{
config = this.getConfig();
config.options().copyDefaults(true);
this.saveDefaultConfig();
this.getSpawns();
spawns.options().copyDefaults(true);
this.saveSpawns();
log.info("[HungerArena] enabled v" + getDescription().getVersion());
getServer().getPluginManager().registerEvents(DeathListener, this);
getServer().getPluginManager().registerEvents(SpectatorListener, this);
@ -116,4 +127,33 @@ public class Main extends JavaPlugin{
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);
}
}
}

View File

@ -19,7 +19,7 @@ public class SpawnsCommand implements CommandExecutor {
if(cmd.getName().equalsIgnoreCase("StartPoint")){
if(p.hasPermission("HungerArena.StartPoint")){
if(!plugin.restricted || (plugin.restricted && plugin.worlds.contains(p.getWorld().getName()))){
if(plugin.restricted && !plugin.worlds.contains(p.getWorld().toString())){
if(plugin.restricted && !plugin.worlds.contains(p.getWorld().getName())){
p.sendMessage(ChatColor.GOLD + "We ran the command, however, this isn't a world you defined in the config...");
p.sendMessage(ChatColor.GOLD + "If this is the right world, please disregard this message.");
}
@ -29,8 +29,8 @@ public class SpawnsCommand implements CommandExecutor {
double y = ploc.getY();
double z = ploc.getZ();
String w = ploc.getWorld().getName();
plugin.config.set("Tribute_one_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
plugin.spawns.set("Tribute_one_spawn", x + "," + y + "," + z + "," + w);
plugin.saveSpawns();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute one!");
}
if(args[0].equalsIgnoreCase("2")){
@ -38,8 +38,8 @@ public class SpawnsCommand implements CommandExecutor {
double y = ploc.getY();
double z = ploc.getZ();
String w = ploc.getWorld().getName();
plugin.config.set("Tribute_two_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
plugin.spawns.set("Tribute_two_spawn", x + "," + y + "," + z + "," + w);
plugin.saveSpawns();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute two!");
}
if(args[0].equalsIgnoreCase("3")){
@ -47,8 +47,8 @@ public class SpawnsCommand implements CommandExecutor {
double y = ploc.getY();
double z = ploc.getZ();
String w = ploc.getWorld().getName();
plugin.config.set("Tribute_three_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
plugin.spawns.set("Tribute_three_spawn", x + "," + y + "," + z + "," + w);
plugin.saveSpawns();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute three!");
}
if(args[0].equalsIgnoreCase("4")){
@ -56,8 +56,8 @@ public class SpawnsCommand implements CommandExecutor {
double y = ploc.getY();
double z = ploc.getZ();
String w = ploc.getWorld().getName();
plugin.config.set("Tribute_four_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
plugin.spawns.set("Tribute_four_spawn", x + "," + y + "," + z + "," + w);
plugin.saveSpawns();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute four!");
}
if(args[0].equalsIgnoreCase("5")){
@ -65,8 +65,8 @@ public class SpawnsCommand implements CommandExecutor {
double y = ploc.getY();
double z = ploc.getZ();
String w = ploc.getWorld().getName();
plugin.config.set("Tribute_five_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
plugin.spawns.set("Tribute_five_spawn", x + "," + y + "," + z + "," + w);
plugin.saveSpawns();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute five!");
}
if(args[0].equalsIgnoreCase("6")){
@ -74,8 +74,8 @@ public class SpawnsCommand implements CommandExecutor {
double y = ploc.getY();
double z = ploc.getZ();
String w = ploc.getWorld().getName();
plugin.config.set("Tribute_six_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
plugin.spawns.set("Tribute_six_spawn", x + "," + y + "," + z + "," + w);
plugin.saveSpawns();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute six!");
}
if(args[0].equalsIgnoreCase("7")){
@ -83,8 +83,8 @@ public class SpawnsCommand implements CommandExecutor {
double y = ploc.getY();
double z = ploc.getZ();
String w = ploc.getWorld().getName();
plugin.config.set("Tribute_seven_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
plugin.spawns.set("Tribute_seven_spawn", x + "," + y + "," + z + "," + w);
plugin.saveSpawns();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute seven!");
}
if(args[0].equalsIgnoreCase("8")){
@ -92,8 +92,8 @@ public class SpawnsCommand implements CommandExecutor {
double y = ploc.getY();
double z = ploc.getZ();
String w = ploc.getWorld().getName();
plugin.config.set("Tribute_eight_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
plugin.spawns.set("Tribute_eight_spawn", x + "," + y + "," + z + "," + w);
plugin.saveSpawns();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute eight!");
}
if(args[0].equalsIgnoreCase("9")){
@ -101,8 +101,8 @@ public class SpawnsCommand implements CommandExecutor {
double y = ploc.getY();
double z = ploc.getZ();
String w = ploc.getWorld().getName();
plugin.config.set("Tribute_nine_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
plugin.spawns.set("Tribute_nine_spawn", x + "," + y + "," + z + "," + w);
plugin.saveSpawns();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute nine!");
}
if(args[0].equalsIgnoreCase("10")){
@ -110,8 +110,8 @@ public class SpawnsCommand implements CommandExecutor {
double y = ploc.getY();
double z = ploc.getZ();
String w = ploc.getWorld().getName();
plugin.config.set("Tribute_ten_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
plugin.spawns.set("Tribute_ten_spawn", x + "," + y + "," + z + "," + w);
plugin.saveSpawns();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute ten!");
}
if(args[0].equalsIgnoreCase("11")){
@ -119,8 +119,8 @@ public class SpawnsCommand implements CommandExecutor {
double y = ploc.getY();
double z = ploc.getZ();
String w = ploc.getWorld().getName();
plugin.config.set("Tribute_eleven_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
plugin.spawns.set("Tribute_eleven_spawn", x + "," + y + "," + z + "," + w);
plugin.saveSpawns();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute eleven!");
}
if(args[0].equalsIgnoreCase("12")){
@ -128,8 +128,8 @@ public class SpawnsCommand implements CommandExecutor {
double y = ploc.getY();
double z = ploc.getZ();
String w = ploc.getWorld().getName();
plugin.config.set("Tribute_twelve_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
plugin.spawns.set("Tribute_twelve_spawn", x + "," + y + "," + z + "," + w);
plugin.saveSpawns();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute twelve!");
}
if(args[0].equalsIgnoreCase("13")){
@ -137,8 +137,8 @@ public class SpawnsCommand implements CommandExecutor {
double y = ploc.getY();
double z = ploc.getZ();
String w = ploc.getWorld().getName();
plugin.config.set("Tribute_thirteen_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
plugin.spawns.set("Tribute_thirteen_spawn", x + "," + y + "," + z + "," + w);
plugin.saveSpawns();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute thirteen!");
}
if(args[0].equalsIgnoreCase("14")){
@ -146,8 +146,8 @@ public class SpawnsCommand implements CommandExecutor {
double y = ploc.getY();
double z = ploc.getZ();
String w = ploc.getWorld().getName();
plugin.config.set("Tribute_fourteen_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
plugin.spawns.set("Tribute_fourteen_spawn", x + "," + y + "," + z + "," + w);
plugin.saveSpawns();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute fourteen!");
}
if(args[0].equalsIgnoreCase("15")){
@ -155,8 +155,8 @@ public class SpawnsCommand implements CommandExecutor {
double y = ploc.getY();
double z = ploc.getZ();
String w = ploc.getWorld().getName();
plugin.config.set("Tribute_fifteen_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
plugin.spawns.set("Tribute_fifteen_spawn", x + "," + y + "," + z + "," + w);
plugin.saveSpawns();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute fifteen!");
}
if(args[0].equalsIgnoreCase("16")){
@ -164,8 +164,8 @@ public class SpawnsCommand implements CommandExecutor {
double y = ploc.getY();
double z = ploc.getZ();
String w = ploc.getWorld().getName();
plugin.config.set("Tribute_sixteen_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
plugin.spawns.set("Tribute_sixteen_spawn", x + "," + y + "," + z + "," + w);
plugin.saveSpawns();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute sixteen!");
}
if(args[0].equalsIgnoreCase("17")){
@ -173,8 +173,8 @@ public class SpawnsCommand implements CommandExecutor {
double y = ploc.getY();
double z = ploc.getZ();
String w = ploc.getWorld().getName();
plugin.config.set("Tribute_seventeen_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
plugin.spawns.set("Tribute_seventeen_spawn", x + "," + y + "," + z + "," + w);
plugin.saveSpawns();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute seventeen!");
}
if(args[0].equalsIgnoreCase("18")){
@ -182,8 +182,8 @@ public class SpawnsCommand implements CommandExecutor {
double y = ploc.getY();
double z = ploc.getZ();
String w = ploc.getWorld().getName();
plugin.config.set("Tribute_eighteen_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
plugin.spawns.set("Tribute_eighteen_spawn", x + "," + y + "," + z + "," + w);
plugin.saveSpawns();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute eighteen!");
}
if(args[0].equalsIgnoreCase("19")){
@ -191,8 +191,8 @@ public class SpawnsCommand implements CommandExecutor {
double y = ploc.getY();
double z = ploc.getZ();
String w = ploc.getWorld().getName();
plugin.config.set("Tribute_nineteen_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
plugin.spawns.set("Tribute_nineteen_spawn", x + "," + y + "," + z + "," + w);
plugin.saveSpawns();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute nineteen!");
}
if(args[0].equalsIgnoreCase("20")){
@ -200,8 +200,8 @@ public class SpawnsCommand implements CommandExecutor {
double y = ploc.getY();
double z = ploc.getZ();
String w = ploc.getWorld().getName();
plugin.config.set("Tribute_twenty_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
plugin.spawns.set("Tribute_twenty_spawn", x + "," + y + "," + z + "," + w);
plugin.saveSpawns();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute twenty!");
}
if(args[0].equalsIgnoreCase("21")){
@ -209,8 +209,8 @@ public class SpawnsCommand implements CommandExecutor {
double y = ploc.getY();
double z = ploc.getZ();
String w = ploc.getWorld().getName();
plugin.config.set("Tribute_twentyone_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
plugin.spawns.set("Tribute_twentyone_spawn", x + "," + y + "," + z + "," + w);
plugin.saveSpawns();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute twentyone!");
}
if(args[0].equalsIgnoreCase("22")){
@ -218,8 +218,8 @@ public class SpawnsCommand implements CommandExecutor {
double y = ploc.getY();
double z = ploc.getZ();
String w = ploc.getWorld().getName();
plugin.config.set("Tribute_twentytwo_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
plugin.spawns.set("Tribute_twentytwo_spawn", x + "," + y + "," + z + "," + w);
plugin.saveSpawns();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute twentytwo!");
}
if(args[0].equalsIgnoreCase("23")){
@ -227,8 +227,8 @@ public class SpawnsCommand implements CommandExecutor {
double y = ploc.getY();
double z = ploc.getZ();
String w = ploc.getWorld().getName();
plugin.config.set("Tribute_twentythree_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
plugin.spawns.set("Tribute_twentythree_spawn", x + "," + y + "," + z + "," + w);
plugin.saveSpawns();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute twentythree!");
}
if(args[0].equalsIgnoreCase("24")){
@ -236,8 +236,8 @@ public class SpawnsCommand implements CommandExecutor {
double y = ploc.getY();
double z = ploc.getZ();
String w = ploc.getWorld().getName();
plugin.config.set("Tribute_twentyfour_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
plugin.spawns.set("Tribute_twentyfour_spawn", x + "," + y + "," + z + "," + w);
plugin.saveSpawns();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute twentyfour!");
}
}

View File

@ -37,8 +37,8 @@ public class SpectatorListener implements Listener {
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
@EventHandler
@EventHandler
public void SpectatorInteractEntity(PlayerInteractEntityEvent event){
Player p = event.getPlayer();
String pname = p.getName();
@ -87,8 +87,8 @@ public class SpectatorListener implements Listener {
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
@EventHandler
@EventHandler
public void SpectatorBlockPlace(BlockPlaceEvent event){
Player p = event.getPlayer();
String pname = p.getName();
@ -97,35 +97,35 @@ public class SpectatorListener implements Listener {
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
@EventHandler
@EventHandler
public void SpectatorQuit(PlayerQuitEvent event){
Player p = event.getPlayer();
String pname = p.getName();
if(plugin.Watching.contains(pname)){
plugin.Watching.remove(pname);
String[] Spawncoords = plugin.config.getString("Spawn_coords").split(",");
String w = Spawncoords[3];
World spawnw = plugin.getServer().getWorld(w);
double spawnx = Double.parseDouble(Spawncoords[0]);
double spawny = Double.parseDouble(Spawncoords[1]);
double spawnz = Double.parseDouble(Spawncoords[2]);
final Location Spawn = new Location(spawnw, spawnx, spawny, spawnz);
p.teleport(Spawn);
plugin.Watching.remove(pname);
String[] Spawncoords = plugin.spawns.getString("Spawn_coords").split(",");
String w = Spawncoords[3];
World spawnw = plugin.getServer().getWorld(w);
double spawnx = Double.parseDouble(Spawncoords[0]);
double spawny = Double.parseDouble(Spawncoords[1]);
double spawnz = Double.parseDouble(Spawncoords[2]);
final Location Spawn = new Location(spawnw, spawnx, spawny, spawnz);
p.teleport(Spawn);
}
}
@EventHandler
public void MobNerf(EntityTargetEvent event){
Entity target = event.getTarget();
Entity e = event.getEntity();
if (e instanceof Player) {
return;
}
Entity e = event.getEntity();
if (e instanceof Player) {
return;
}
if(target instanceof Player){
String targetName = ((Player) target).getName();
if(plugin.Watching.contains(targetName)){
event.setTarget(null);
event.setTarget(null);
}
}
}