Fixed chests and made more classes!

This commit is contained in:
Travis Eggett 2012-05-28 18:16:16 -06:00
parent 14bb7ddf38
commit 47cb43efc2
35 changed files with 889 additions and 443 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -23,7 +23,14 @@ public class ChatListener implements Listener {
double radius = plugin.config.getDouble("ChatClose_Radius"); double radius = plugin.config.getDouble("ChatClose_Radius");
List<Entity> near = p.getNearbyEntities(radius, radius, radius); List<Entity> near = p.getNearbyEntities(radius, radius, radius);
event.setCancelled(true); event.setCancelled(true);
if(near.size()== 0){ if(!(near.size()== 0)){
for(Entity e:near){
if(e instanceof Player){
p.sendMessage(msg);
((Player) e).sendMessage(msg);
}
}
}else if(near.size()== 0){
p.sendMessage(msg); p.sendMessage(msg);
p.sendMessage(ChatColor.YELLOW + "No one near!"); p.sendMessage(ChatColor.YELLOW + "No one near!");
}else if(!(near.size()== 0)){ }else if(!(near.size()== 0)){
@ -33,12 +40,6 @@ public class ChatListener implements Listener {
p.sendMessage(ChatColor.YELLOW + "No one near!"); p.sendMessage(ChatColor.YELLOW + "No one near!");
} }
} }
}else{
for(Entity e:near){
if(e instanceof Player){
((Player) e).sendMessage(msg);
}
}
} }
}else{ }else{
plugin.getServer().broadcastMessage(msg); plugin.getServer().broadcastMessage(msg);

View File

@ -2,6 +2,7 @@ package me.Travja.HungerArena;
import java.util.List; import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.Chest; import org.bukkit.block.Chest;
@ -21,8 +22,6 @@ public class Chests implements Listener {
public void ChestSaves(PlayerInteractEvent event){ public void ChestSaves(PlayerInteractEvent event){
Block block = event.getClickedBlock(); Block block = event.getClickedBlock();
Player p = event.getPlayer(); Player p = event.getPlayer();
//currently crashes the server when refilling....
//Kinda glitchy through all here...
if(p.getItemInHand().getType()== Material.BLAZE_ROD && event.getAction() == Action.LEFT_CLICK_BLOCK){ if(p.getItemInHand().getType()== Material.BLAZE_ROD && event.getAction() == Action.LEFT_CLICK_BLOCK){
if(block.getState() instanceof Chest){ if(block.getState() instanceof Chest){
ItemStack[] itemsinchest = ((Chest) block.getState()).getInventory().getContents(); ItemStack[] itemsinchest = ((Chest) block.getState()).getInventory().getContents();
@ -48,6 +47,7 @@ public class Chests implements Listener {
plugin.getConfig().set("StorageXYZ", list2); plugin.getConfig().set("StorageXYZ", list2);
plugin.getConfig().options().copyDefaults(true); plugin.getConfig().options().copyDefaults(true);
plugin.saveConfig(); plugin.saveConfig();
p.sendMessage(ChatColor.GREEN + "Chest Stored!");
} }
} }
} }

View File

@ -0,0 +1,24 @@
package me.Travja.HungerArena;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
public class CommandBlock implements Listener {
public Main plugin;
public CommandBlock(Main m) {
this.plugin = m;
}
@EventHandler(priority = EventPriority.HIGHEST)
public void CatchCommand(PlayerCommandPreprocessEvent event){
String cmd = event.getMessage();
Player p = event.getPlayer();
if(!cmd.contains("/ha") && plugin.Playing.contains(p)){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are only allowed to use /ha commands!");
}
}
}

View File

@ -64,6 +64,9 @@ public class DeathListener implements Listener{
} }
for(Player spectator:plugin.Watching){ for(Player spectator:plugin.Watching){
spectator.setAllowFlight(false); spectator.setAllowFlight(false);
for(Player online:plugin.getServer().getOnlinePlayers()){
online.showPlayer(spectator);
}
} }
if(plugin.config.getString("Auto_Restart").equalsIgnoreCase("True")){ if(plugin.config.getString("Auto_Restart").equalsIgnoreCase("True")){
plugin.Dead.clear(); plugin.Dead.clear();
@ -95,6 +98,9 @@ public class DeathListener implements Listener{
} }
for(Player spectator:plugin.Watching){ for(Player spectator:plugin.Watching){
spectator.setAllowFlight(false); spectator.setAllowFlight(false);
for(Player online:plugin.getServer().getOnlinePlayers()){
online.showPlayer(spectator);
}
} }
if(plugin.config.getString("Auto_Restart").equalsIgnoreCase("True")){ if(plugin.config.getString("Auto_Restart").equalsIgnoreCase("True")){
plugin.Dead.clear(); plugin.Dead.clear();
@ -123,6 +129,9 @@ public class DeathListener implements Listener{
} }
for(Player spectator:plugin.Watching){ for(Player spectator:plugin.Watching){
spectator.setAllowFlight(false); spectator.setAllowFlight(false);
for(Player online:plugin.getServer().getOnlinePlayers()){
online.showPlayer(spectator);
}
} }
if(plugin.config.getString("Auto_Restart").equalsIgnoreCase("True")){ if(plugin.config.getString("Auto_Restart").equalsIgnoreCase("True")){
plugin.Dead.clear(); plugin.Dead.clear();
@ -135,9 +144,5 @@ public class DeathListener implements Listener{
} }
} }
} }
if(plugin.Watching.contains(p)){
for(Player online:plugin.getServer().getOnlinePlayers())
online.showPlayer(p);
}
} }
} }

View File

@ -1,7 +1,5 @@
package me.Travja.HungerArena; package me.Travja.HungerArena;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List; import java.util.List;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -13,7 +11,7 @@ import org.bukkit.block.Chest;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -22,38 +20,53 @@ public class HaCommands implements CommandExecutor {
public HaCommands(Main m) { public HaCommands(Main m) {
this.plugin = m; this.plugin = m;
} }
public FileConfiguration config = plugin.config;
public ArrayList<Player> Playing = plugin.Playing;
public ArrayList<Player> Ready = plugin.Ready;
public ArrayList<Player> Dead = plugin.Dead;
public ArrayList<Player> Quit = plugin.Quit;
public ArrayList<Player> Out = plugin.Out;
public ArrayList<Player> Watching = plugin.Watching;
public ArrayList<Player> NeedConfirm = plugin.NeedConfirm;
public HashSet<Player> Frozen = plugin.Frozen;
public boolean canjoin = plugin.canjoin;
public boolean exists = plugin.exists;
public ItemStack Reward = plugin.Reward;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){ public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
Player p = (Player) sender; Player p = (Player) sender;
String pname = p.getName(); String pname = p.getName();
ChatColor c = ChatColor.AQUA;
if(cmd.getName().equalsIgnoreCase("Ha")){ if(cmd.getName().equalsIgnoreCase("Ha")){
if(config.getString("Spawns_set").equalsIgnoreCase("false")){
p.sendMessage(ChatColor.RED + "/ha setspawn hasn't been run!");
}
if(args.length== 0){ if(args.length== 0){
p.sendMessage(ChatColor.GREEN + "[HungerArena] by " + ChatColor.AQUA + "travja!"); sender.sendMessage(ChatColor.GREEN + "[HungerArena] by " + ChatColor.AQUA + "travja!");
return false;
}
if(args[0].equalsIgnoreCase("Help")){
sender.sendMessage(ChatColor.GREEN + "----HungerArena Help----");
sender.sendMessage(c + "/ha - Displays author message!");
sender.sendMessage(c + "/ha help - Displays this screen!");
sender.sendMessage(c + "/ha join - Makes you join the game!");
sender.sendMessage(c + "/ha leave - Makes you leave the game!");
sender.sendMessage(c + "/ha watch - Lets you watch the tributes!");
sender.sendMessage(c + "/sponsor [Player] [ItemID] [Amount] - Lets you sponsor someone!");
sender.sendMessage(c + "/ha setspawn - Sets the spawn for dead tributes!");
sender.sendMessage(c + "/ha kick [Player] - Kicks a player from the arena!");
sender.sendMessage(c + "/ha restart - Makes it so dead tributes can join again!");
sender.sendMessage(c + "/ha warpall - Warps all tribute into position!");
sender.sendMessage(c + "/ha reload - Reloads the config!");
sender.sendMessage(c + "/ha start - Unfreezes tributes allowing them to fight!");
sender.sendMessage(c + "/ha list - Shows a list of players in the game and their health!");
sender.sendMessage(c + "/startpoint [1,2,3,4,etc] - Sets the starting points of tributes!");
sender.sendMessage(ChatColor.GREEN + "----------------------");
return false; return false;
} }
if(args[0].equalsIgnoreCase("List")){ if(args[0].equalsIgnoreCase("List")){
if(sender instanceof ConsoleCommandSender){
sender.sendMessage(ChatColor.AQUA + "-----People Playing-----");
for(Player players:plugin.Playing){
sender.sendMessage(ChatColor.GREEN + players.getDisplayName() + " Life: " + players.getHealth() + "/20");
}
if(plugin.Playing.size()== 0){
sender.sendMessage(ChatColor.GRAY + "No one is playing!");
}
sender.sendMessage(ChatColor.AQUA + "----------------------");
}
if(p.hasPermission("HungerArena.GameMaker")){ if(p.hasPermission("HungerArena.GameMaker")){
p.sendMessage(ChatColor.AQUA + "-----People Playing-----"); p.sendMessage(ChatColor.AQUA + "-----People Playing-----");
for(Player players:Playing){ for(Player players:plugin.Playing){
p.sendMessage(ChatColor.GREEN + players.getDisplayName() + " Life: " + players.getHealth() + "/20"); p.sendMessage(ChatColor.GREEN + players.getDisplayName() + " Life: " + players.getHealth() + "/20");
} }
if(Playing.size()== 0){ if(plugin.Playing.size()== 0){
p.sendMessage(ChatColor.GRAY + "No one is playing!"); p.sendMessage(ChatColor.GRAY + "No one is playing!");
} }
p.sendMessage(ChatColor.AQUA + "----------------------"); p.sendMessage(ChatColor.AQUA + "----------------------");
@ -67,15 +80,15 @@ public class HaCommands implements CommandExecutor {
double y = p.getLocation().getY(); double y = p.getLocation().getY();
double z = p.getLocation().getZ(); double z = p.getLocation().getZ();
String w = p.getWorld().getName(); String w = p.getWorld().getName();
config.set("Spawn_coords", x + "," + y + "," + z + "," + w); plugin.config.set("Spawn_coords", x + "," + y + "," + z + "," + w);
plugin.config.set("Spawns_set", "true");
plugin.saveConfig(); plugin.saveConfig();
config.set("Spawns_set", "true");
p.sendMessage(ChatColor.AQUA + "You have set the spawn for dead tributes!"); p.sendMessage(ChatColor.AQUA + "You have set the spawn for dead tributes!");
}else{ }else{
p.sendMessage(ChatColor.RED + "You don't have permission!"); p.sendMessage(ChatColor.RED + "You don't have permission!");
} }
} }
String[] Spawncoords = config.getString("Spawn_coords").split(","); String[] Spawncoords = plugin.config.getString("Spawn_coords").split(",");
double spawnx = Double.parseDouble(Spawncoords[0]); double spawnx = Double.parseDouble(Spawncoords[0]);
double spawny = Double.parseDouble(Spawncoords[1]); double spawny = Double.parseDouble(Spawncoords[1]);
double spawnz = Double.parseDouble(Spawncoords[2]); double spawnz = Double.parseDouble(Spawncoords[2]);
@ -84,16 +97,18 @@ public class HaCommands implements CommandExecutor {
Location Spawn = new Location(spawnw, spawnx, spawny, spawnz); Location Spawn = new Location(spawnw, spawnx, spawny, spawnz);
if(args[0].equalsIgnoreCase("Join")){ if(args[0].equalsIgnoreCase("Join")){
if(p.hasPermission("HungerArena.Join")){ if(p.hasPermission("HungerArena.Join")){
if(Playing.contains(p)){ if(plugin.Playing.contains(p)){
p.sendMessage(ChatColor.RED + "You are already playing!"); p.sendMessage(ChatColor.RED + "You are already playing!");
}else if(Dead.contains(p) || Quit.contains(p)){ }else if(plugin.Dead.contains(p) || plugin.Quit.contains(p)){
p.sendMessage(ChatColor.RED + "You DIED/QUIT! You can't join again!"); p.sendMessage(ChatColor.RED + "You DIED/QUIT! You can't join again!");
}else if(Playing.size()== 24){ }else if(plugin.Playing.size()== 24){
p.sendMessage(ChatColor.RED + "There are already 24 Tributes!"); p.sendMessage(ChatColor.RED + "There are already 24 Tributes!");
}else if(canjoin== true){ }else if(plugin.canjoin== true){
p.sendMessage(ChatColor.RED + "The game is in progress!"); p.sendMessage(ChatColor.RED + "The game is in progress!");
}else if(plugin.config.getString("Spawns_set").equalsIgnoreCase("false")){
p.sendMessage(ChatColor.RED + "/ha setspawn hasn't been run!");
}else{ }else{
NeedConfirm.add(p); plugin.NeedConfirm.add(p);
p.sendMessage(ChatColor.GOLD + "You're inventory will be cleared! Type /ha confirm to procede"); p.sendMessage(ChatColor.GOLD + "You're inventory will be cleared! Type /ha confirm to procede");
} }
}else{ }else{
@ -101,37 +116,37 @@ public class HaCommands implements CommandExecutor {
} }
} }
if(args[0].equalsIgnoreCase("Confirm")){ if(args[0].equalsIgnoreCase("Confirm")){
if(NeedConfirm.contains(p)){ if(plugin.NeedConfirm.contains(p)){
Playing.add(p); plugin.Playing.add(p);
NeedConfirm.remove(p); plugin.NeedConfirm.remove(p);
p.getInventory().clear(); p.getInventory().clear();
p.getInventory().setBoots(null); p.getInventory().setBoots(null);
p.getInventory().setChestplate(null); p.getInventory().setChestplate(null);
p.getInventory().setHelmet(null); p.getInventory().setHelmet(null);
p.getInventory().setLeggings(null); p.getInventory().setLeggings(null);
plugin.getServer().broadcastMessage(ChatColor.AQUA + pname + " has Joined the Game!"); plugin.getServer().broadcastMessage(ChatColor.AQUA + pname + " has Joined the Game!");
if(Playing.size()== 24){ if(plugin.Playing.size()== 24){
p.performCommand("ha warpall"); p.performCommand("ha warpall");
} }
} }
} }
if(args[0].equalsIgnoreCase("Ready")){ if(args[0].equalsIgnoreCase("Ready")){
if(Playing.contains(p)){ if(plugin.Playing.contains(p)){
Ready.add(p); plugin.Ready.add(p);
p.sendMessage(ChatColor.AQUA + "You have marked yourself as READY!"); p.sendMessage(ChatColor.AQUA + "You have marked yourself as READY!");
if(Playing.size()== Ready.size()){ if(plugin.Playing.size()== plugin.Ready.size()){
p.performCommand("Ha Warpall"); p.performCommand("Ha Warpall");
} }
}else if(!Playing.contains(p)){ }else if(!plugin.Playing.contains(p)){
p.sendMessage(ChatColor.RED + "You aren't playing!"); p.sendMessage(ChatColor.RED + "You aren't playing!");
} }
} }
if(args[0].equalsIgnoreCase("Leave")){ if(args[0].equalsIgnoreCase("Leave")){
if(!Playing.contains(p)){ if(!plugin.Playing.contains(p)){
p.sendMessage(ChatColor.RED + "You aren't playing!"); p.sendMessage(ChatColor.RED + "You aren't playing!");
}else{ }else{
Playing.remove(p); plugin.Playing.remove(p);
Quit.add(p); plugin.Quit.add(p);
p.sendMessage(ChatColor.AQUA + "You have left the game!"); p.sendMessage(ChatColor.AQUA + "You have left the game!");
p.getServer().broadcastMessage(ChatColor.RED + pname + " Quit!"); p.getServer().broadcastMessage(ChatColor.RED + pname + " Quit!");
p.getInventory().clear(); p.getInventory().clear();
@ -140,39 +155,39 @@ public class HaCommands implements CommandExecutor {
p.getInventory().setHelmet(null); p.getInventory().setHelmet(null);
p.getInventory().setLeggings(null); p.getInventory().setLeggings(null);
p.teleport(Spawn); p.teleport(Spawn);
if(Frozen.contains(p)){ if(plugin.Frozen.contains(p)){
Frozen.remove(p); plugin.Frozen.remove(p);
} }
if(Playing.size()== 1 && canjoin== true){ if(plugin.Playing.size()== 1 && plugin.canjoin== true){
for(Player winner:Playing){ for(Player winner:plugin.Playing){
String winnername = winner.getName(); String winnername = winner.getName();
p.getServer().broadcastMessage(ChatColor.GREEN + winnername + " is the victor of this Hunger Games!"); p.getServer().broadcastMessage(ChatColor.GREEN + winnername + " is the victor of this Hunger Games!");
winner.getInventory().clear(); winner.getInventory().clear();
winner.getInventory().addItem(Reward); winner.getInventory().addItem(plugin.Reward);
} }
for(Player spectator:Watching){ for(Player spectator:plugin.Watching){
spectator.setAllowFlight(false); spectator.setAllowFlight(false);
} }
canjoin= false; plugin.canjoin= false;
Watching.clear(); plugin.Watching.clear();
} }
} }
} }
if(args[0].equalsIgnoreCase("Watch")){ if(args[0].equalsIgnoreCase("Watch")){
if(p.hasPermission("HungerArena.Watch")){ if(p.hasPermission("HungerArena.Watch")){
if(!Watching.contains(p) && !Playing.contains(p) && canjoin== true){ if(!plugin.Watching.contains(p) && !plugin.Playing.contains(p) && plugin.canjoin== true){
Watching.add(p); plugin.Watching.add(p);
for(Player online:plugin.getServer().getOnlinePlayers()){ for(Player online:plugin.getServer().getOnlinePlayers()){
online.hidePlayer(p); online.hidePlayer(p);
} }
p.setAllowFlight(true); p.setAllowFlight(true);
p.sendMessage(ChatColor.AQUA + "You can now spectate!"); p.sendMessage(ChatColor.AQUA + "You can now spectate!");
}else if(canjoin == false){ }else if(plugin.canjoin == false){
p.sendMessage(ChatColor.RED + "The game isn't in progress!"); p.sendMessage(ChatColor.RED + "The game isn't in progress!");
}else if(Playing.contains(p)){ }else if(plugin.Playing.contains(p)){
p.sendMessage(ChatColor.RED + "You can't watch while you're playing!"); p.sendMessage(ChatColor.RED + "You can't watch while you're playing!");
}else if(Watching.contains(p)){ }else if(plugin.Watching.contains(p)){
Watching.remove(p); plugin.Watching.remove(p);
for(Player online:plugin.getServer().getOnlinePlayers()){ for(Player online:plugin.getServer().getOnlinePlayers()){
online.showPlayer(p); online.showPlayer(p);
} }
@ -187,9 +202,9 @@ public class HaCommands implements CommandExecutor {
if(args[0].equalsIgnoreCase("Kick")){ if(args[0].equalsIgnoreCase("Kick")){
Player target = plugin.getServer().getPlayer(args[1]); Player target = plugin.getServer().getPlayer(args[1]);
if(p.hasPermission("HungerArena.Kick")){ if(p.hasPermission("HungerArena.Kick")){
if(Playing.contains(target)){ if(plugin.Playing.contains(target)){
if(p.isOnline()){ if(p.isOnline()){
Playing.remove(target); plugin.Playing.remove(target);
plugin.getServer().broadcastMessage(ChatColor.RED + target.getName() + " was kicked from the game!"); plugin.getServer().broadcastMessage(ChatColor.RED + target.getName() + " was kicked from the game!");
target.teleport(Spawn); target.teleport(Spawn);
target.getInventory().clear(); target.getInventory().clear();
@ -197,22 +212,22 @@ public class HaCommands implements CommandExecutor {
target.getInventory().setChestplate(null); target.getInventory().setChestplate(null);
target.getInventory().setHelmet(null); target.getInventory().setHelmet(null);
target.getInventory().setLeggings(null); target.getInventory().setLeggings(null);
Quit.add(target); plugin.Quit.add(target);
if(Playing.size()== 1 && canjoin== true){ if(plugin.Playing.size()== 1 && plugin.canjoin== true){
for(Player winner:Playing){ for(Player winner:plugin.Playing){
String winnername = winner.getName(); String winnername = winner.getName();
p.getServer().broadcastMessage(ChatColor.GREEN + winnername + " is the victor of this Hunger Games!"); p.getServer().broadcastMessage(ChatColor.GREEN + winnername + " is the victor of this Hunger Games!");
winner.getInventory().clear(); winner.getInventory().clear();
winner.getInventory().addItem(Reward); winner.getInventory().addItem(plugin.Reward);
} }
for(Player spectator:Watching){ for(Player spectator:plugin.Watching){
spectator.setAllowFlight(false); spectator.setAllowFlight(false);
} }
canjoin= false; plugin.canjoin= false;
Watching.clear(); plugin.Watching.clear();
}else{ }else{
Playing.remove(target); plugin.Playing.remove(target);
Quit.add(target); plugin.Quit.add(target);
} }
} }
}else{ }else{
@ -225,8 +240,7 @@ public class HaCommands implements CommandExecutor {
if(args[0].equalsIgnoreCase("Refill")){ if(args[0].equalsIgnoreCase("Refill")){
int list056; int list056;
list056 = 0; list056 = 0;
int limit; int limit = plugin.getConfig().getStringList("StorageXYZ").size();
limit = plugin.getConfig().getStringList("StorageXYZ").size();
while(limit > list056){ while(limit > list056){
String xyz2 = plugin.getConfig().getStringList("StorageXYZ").get(list056); String xyz2 = plugin.getConfig().getStringList("StorageXYZ").get(list056);
int chestx = plugin.getConfig().getInt("Storage." + xyz2 + ".Location.X"); int chestx = plugin.getConfig().getInt("Storage." + xyz2 + ".Location.X");
@ -234,9 +248,9 @@ public class HaCommands implements CommandExecutor {
int chestz = plugin.getConfig().getInt("Storage." + xyz2 + ".Location.Z"); int chestz = plugin.getConfig().getInt("Storage." + xyz2 + ".Location.Z");
String chestw = plugin.getConfig().getString("Storage." + xyz2 + ".Location.W"); String chestw = plugin.getConfig().getString("Storage." + xyz2 + ".Location.W");
Block blockatlocation = Bukkit.getWorld(chestw).getBlockAt(chestx, chesty, chestz); Block blockatlocation = Bukkit.getWorld(chestw).getBlockAt(chestx, chesty, chestz);
exists = false; plugin.exists = false;
if(blockatlocation.getState() instanceof Chest){ if(blockatlocation.getState() instanceof Chest){
exists = true; plugin.exists = true;
Chest chest = (Chest) blockatlocation.getState(); Chest chest = (Chest) blockatlocation.getState();
chest.getInventory().clear(); chest.getInventory().clear();
ItemStack[] itemsinchest = null; ItemStack[] itemsinchest = null;
@ -245,28 +259,29 @@ public class HaCommands implements CommandExecutor {
itemsinchest = (ItemStack[]) o; itemsinchest = (ItemStack[]) o;
}else if(o instanceof List){ }else if(o instanceof List){
itemsinchest = (ItemStack[]) ((List<ItemStack>) o).toArray(new ItemStack[0]); itemsinchest = (ItemStack[]) ((List<ItemStack>) o).toArray(new ItemStack[0]);
}else{
try{
throw new Exception();
}catch (Exception e) {
e.printStackTrace();
} }
list056 = list056+1;
chest.getInventory().setContents(itemsinchest); chest.getInventory().setContents(itemsinchest);
} }
} }
if(limit== list056){
p.sendMessage(ChatColor.GREEN + "All chests refilled!");
} }
} }
if(args[0].equalsIgnoreCase("Restart")){ if(args[0].equalsIgnoreCase("Restart")){
if(p.hasPermission("HungerArena.Restart")){ if(p.hasPermission("HungerArena.Restart")){
for(Player spectator:Watching){ for(Player spectator:plugin.Watching){
spectator.setAllowFlight(false); spectator.setAllowFlight(false);
for(Player online:plugin.getServer().getOnlinePlayers()){
online.showPlayer(spectator);
} }
Dead.clear(); }
Playing.clear(); plugin.Dead.clear();
Quit.clear(); plugin.Playing.clear();
Watching.clear(); plugin.Quit.clear();
Frozen.clear(); plugin.Watching.clear();
canjoin = false; plugin.Frozen.clear();
plugin.canjoin = false;
p.sendMessage(ChatColor.AQUA + "The games have been reset!"); p.sendMessage(ChatColor.AQUA + "The games have been reset!");
}else{ }else{
p.sendMessage(ChatColor.RED + "You don't have permission!"); p.sendMessage(ChatColor.RED + "You don't have permission!");
@ -278,13 +293,16 @@ public class HaCommands implements CommandExecutor {
} }
if(args[0].equalsIgnoreCase("WarpAll")){ if(args[0].equalsIgnoreCase("WarpAll")){
if(p.hasPermission("HungerArena.Warpall")){ if(p.hasPermission("HungerArena.Warpall")){
if(Playing.size()== 1){ if(plugin.config.getString("Spawns_set").equalsIgnoreCase("false")){
p.sendMessage(ChatColor.RED + "/ha setspawn hasn't been run!");
}else{
if(plugin.Playing.size()== 1){
p.sendMessage(ChatColor.RED + "There are not enough players!"); p.sendMessage(ChatColor.RED + "There are not enough players!");
} }
if(Playing.size()>= 2){ if(plugin.Playing.size()>= 2){
config.getString("Tribute_one_spawn"); plugin.config.getString("Tribute_one_spawn");
String[] onecoords = config.getString("Tribute_one_spawn").split(","); String[] onecoords = plugin.config.getString("Tribute_one_spawn").split(",");
Player Tribute_one = Playing.get(0); Player Tribute_one = plugin.Playing.get(0);
double x = Double.parseDouble(onecoords[0]); double x = Double.parseDouble(onecoords[0]);
double y = Double.parseDouble(onecoords[1]); double y = Double.parseDouble(onecoords[1]);
double z = Double.parseDouble(onecoords[2]); double z = Double.parseDouble(onecoords[2]);
@ -292,11 +310,11 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world); World w = plugin.getServer().getWorld(world);
Location oneloc = new Location(w, x, y, z); Location oneloc = new Location(w, x, y, z);
Tribute_one.teleport(oneloc); Tribute_one.teleport(oneloc);
Frozen.add(Tribute_one); plugin.Frozen.add(Tribute_one);
Tribute_one.setFoodLevel(20); Tribute_one.setFoodLevel(20);
config.getString("Tribute_two_spawn"); plugin.config.getString("Tribute_two_spawn");
String[] twocoords = config.getString("Tribute_two_spawn").split(","); String[] twocoords = plugin.config.getString("Tribute_two_spawn").split(",");
Player Tribute_two = Playing.get(1); Player Tribute_two = plugin.Playing.get(1);
double twox = Double.parseDouble(twocoords[0]); double twox = Double.parseDouble(twocoords[0]);
double twoy = Double.parseDouble(twocoords[1]); double twoy = Double.parseDouble(twocoords[1]);
double twoz = Double.parseDouble(twocoords[2]); double twoz = Double.parseDouble(twocoords[2]);
@ -304,14 +322,14 @@ public class HaCommands implements CommandExecutor {
World twow = plugin.getServer().getWorld(twoworld); World twow = plugin.getServer().getWorld(twoworld);
Location twoloc = new Location(twow, twox, twoy, twoz); Location twoloc = new Location(twow, twox, twoy, twoz);
Tribute_two.teleport(twoloc); Tribute_two.teleport(twoloc);
Frozen.add(Tribute_two); plugin.Frozen.add(Tribute_two);
Tribute_two.setFoodLevel(20); Tribute_two.setFoodLevel(20);
p.getWorld().setTime(0); p.getWorld().setTime(0);
} }
if(Playing.size()>= 3){ if(plugin.Playing.size()>= 3){
config.getString("Tribute_three_spawn"); plugin.config.getString("Tribute_three_spawn");
String[] coords = config.getString("Tribute_three_spawn").split(","); String[] coords = plugin.config.getString("Tribute_three_spawn").split(",");
Player Tribute_three = Playing.get(2); Player Tribute_three = plugin.Playing.get(2);
double x = Double.parseDouble(coords[0]); double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]); double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]); double z = Double.parseDouble(coords[2]);
@ -319,13 +337,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world); World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z); Location loc = new Location(w, x, y, z);
Tribute_three.teleport(loc); Tribute_three.teleport(loc);
Frozen.add(Tribute_three); plugin.Frozen.add(Tribute_three);
Tribute_three.setFoodLevel(20); Tribute_three.setFoodLevel(20);
} }
if(Playing.size()>= 4){ if(plugin.Playing.size()>= 4){
config.getString("Tribute_four_spawn"); plugin.config.getString("Tribute_four_spawn");
String[] coords = config.getString("Tribute_four_spawn").split(","); String[] coords = plugin.config.getString("Tribute_four_spawn").split(",");
Player Tribute_four = Playing.get(3); Player Tribute_four = plugin.Playing.get(3);
double x = Double.parseDouble(coords[0]); double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]); double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]); double z = Double.parseDouble(coords[2]);
@ -333,13 +351,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world); World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z); Location loc = new Location(w, x, y, z);
Tribute_four.teleport(loc); Tribute_four.teleport(loc);
Frozen.add(Tribute_four); plugin.Frozen.add(Tribute_four);
Tribute_four.setFoodLevel(20); Tribute_four.setFoodLevel(20);
} }
if(Playing.size()>= 5){ if(plugin.Playing.size()>= 5){
config.getString("Tribute_five_spawn"); plugin.config.getString("Tribute_five_spawn");
String[] coords = config.getString("Tribute_five_spawn").split(","); String[] coords = plugin.config.getString("Tribute_five_spawn").split(",");
Player Tribute_five = Playing.get(4); Player Tribute_five = plugin.Playing.get(4);
double x = Double.parseDouble(coords[0]); double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]); double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]); double z = Double.parseDouble(coords[2]);
@ -347,13 +365,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world); World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z); Location loc = new Location(w, x, y, z);
Tribute_five.teleport(loc); Tribute_five.teleport(loc);
Frozen.add(Tribute_five); plugin.Frozen.add(Tribute_five);
Tribute_five.setFoodLevel(20); Tribute_five.setFoodLevel(20);
} }
if(Playing.size()>= 6){ if(plugin.Playing.size()>= 6){
config.getString("Tribute_six_spawn"); plugin.config.getString("Tribute_six_spawn");
String[] coords = config.getString("Tribute_six_spawn").split(","); String[] coords = plugin.config.getString("Tribute_six_spawn").split(",");
Player Tribute_six = Playing.get(5); Player Tribute_six = plugin.Playing.get(5);
double x = Double.parseDouble(coords[0]); double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]); double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]); double z = Double.parseDouble(coords[2]);
@ -361,13 +379,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world); World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z); Location loc = new Location(w, x, y, z);
Tribute_six.teleport(loc); Tribute_six.teleport(loc);
Frozen.add(Tribute_six); plugin.Frozen.add(Tribute_six);
Tribute_six.setFoodLevel(20); Tribute_six.setFoodLevel(20);
} }
if(Playing.size()>= 7){ if(plugin.Playing.size()>= 7){
config.getString("Tribute_seven_spawn"); plugin.config.getString("Tribute_seven_spawn");
String[] coords = config.getString("Tribute_seven_spawn").split(","); String[] coords = plugin.config.getString("Tribute_seven_spawn").split(",");
Player Tribute_seven = Playing.get(6); Player Tribute_seven = plugin.Playing.get(6);
double x = Double.parseDouble(coords[0]); double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]); double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]); double z = Double.parseDouble(coords[2]);
@ -375,13 +393,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world); World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z); Location loc = new Location(w, x, y, z);
Tribute_seven.teleport(loc); Tribute_seven.teleport(loc);
Frozen.add(Tribute_seven); plugin.Frozen.add(Tribute_seven);
Tribute_seven.setFoodLevel(20); Tribute_seven.setFoodLevel(20);
} }
if(Playing.size()>= 8){ if(plugin.Playing.size()>= 8){
config.getString("Tribute_eight_spawn"); plugin.config.getString("Tribute_eight_spawn");
String[] coords = config.getString("Tribute_eight_spawn").split(","); String[] coords = plugin.config.getString("Tribute_eight_spawn").split(",");
Player Tribute_eight = Playing.get(7); Player Tribute_eight = plugin.Playing.get(7);
double x = Double.parseDouble(coords[0]); double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]); double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]); double z = Double.parseDouble(coords[2]);
@ -389,13 +407,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world); World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z); Location loc = new Location(w, x, y, z);
Tribute_eight.teleport(loc); Tribute_eight.teleport(loc);
Frozen.add(Tribute_eight); plugin.Frozen.add(Tribute_eight);
Tribute_eight.setFoodLevel(20); Tribute_eight.setFoodLevel(20);
} }
if(Playing.size()>= 9){ if(plugin.Playing.size()>= 9){
config.getString("Tribute_nine_spawn"); plugin.config.getString("Tribute_nine_spawn");
String[] coords = config.getString("Tribute_nine_spawn").split(","); String[] coords = plugin.config.getString("Tribute_nine_spawn").split(",");
Player Tribute_nine = Playing.get(8); Player Tribute_nine = plugin.Playing.get(8);
double x = Double.parseDouble(coords[0]); double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]); double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]); double z = Double.parseDouble(coords[2]);
@ -403,13 +421,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world); World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z); Location loc = new Location(w, x, y, z);
Tribute_nine.teleport(loc); Tribute_nine.teleport(loc);
Frozen.add(Tribute_nine); plugin.Frozen.add(Tribute_nine);
Tribute_nine.setFoodLevel(20); Tribute_nine.setFoodLevel(20);
} }
if(Playing.size()>= 10){ if(plugin.Playing.size()>= 10){
config.getString("Tribute_ten_spawn"); plugin.config.getString("Tribute_ten_spawn");
String[] coords = config.getString("Tribute_ten_spawn").split(","); String[] coords = plugin.config.getString("Tribute_ten_spawn").split(",");
Player Tribute_ten = Playing.get(9); Player Tribute_ten = plugin.Playing.get(9);
double x = Double.parseDouble(coords[0]); double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]); double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]); double z = Double.parseDouble(coords[2]);
@ -417,13 +435,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world); World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z); Location loc = new Location(w, x, y, z);
Tribute_ten.teleport(loc); Tribute_ten.teleport(loc);
Frozen.add(Tribute_ten); plugin.Frozen.add(Tribute_ten);
Tribute_ten.setFoodLevel(20); Tribute_ten.setFoodLevel(20);
} }
if(Playing.size()>= 11){ if(plugin.Playing.size()>= 11){
config.getString("Tribute_eleven_spawn"); plugin.config.getString("Tribute_eleven_spawn");
String[] coords = config.getString("Tribute_eleven_spawn").split(","); String[] coords = plugin.config.getString("Tribute_eleven_spawn").split(",");
Player Tribute_eleven = Playing.get(10); Player Tribute_eleven = plugin.Playing.get(10);
double x = Double.parseDouble(coords[0]); double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]); double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]); double z = Double.parseDouble(coords[2]);
@ -431,13 +449,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world); World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z); Location loc = new Location(w, x, y, z);
Tribute_eleven.teleport(loc); Tribute_eleven.teleport(loc);
Frozen.add(Tribute_eleven); plugin.Frozen.add(Tribute_eleven);
Tribute_eleven.setFoodLevel(20); Tribute_eleven.setFoodLevel(20);
} }
if(Playing.size()>= 12){ if(plugin.Playing.size()>= 12){
config.getString("Tribute_twelve_spawn"); plugin.config.getString("Tribute_twelve_spawn");
String[] coords = config.getString("Tribute_twelve_spawn").split(","); String[] coords = plugin.config.getString("Tribute_twelve_spawn").split(",");
Player Tribute_twelve = Playing.get(11); Player Tribute_twelve = plugin.Playing.get(11);
double x = Double.parseDouble(coords[0]); double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]); double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]); double z = Double.parseDouble(coords[2]);
@ -445,13 +463,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world); World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z); Location loc = new Location(w, x, y, z);
Tribute_twelve.teleport(loc); Tribute_twelve.teleport(loc);
Frozen.add(Tribute_twelve); plugin.Frozen.add(Tribute_twelve);
Tribute_twelve.setFoodLevel(20); Tribute_twelve.setFoodLevel(20);
} }
if(Playing.size()>= 13){ if(plugin.Playing.size()>= 13){
config.getString("Tribute_thirteen_spawn"); plugin.config.getString("Tribute_thirteen_spawn");
String[] coords = config.getString("Tribute_thirteen_spawn").split(","); String[] coords = plugin.config.getString("Tribute_thirteen_spawn").split(",");
Player Tribute_thirteen = Playing.get(12); Player Tribute_thirteen = plugin.Playing.get(12);
double x = Double.parseDouble(coords[0]); double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]); double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]); double z = Double.parseDouble(coords[2]);
@ -459,13 +477,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world); World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z); Location loc = new Location(w, x, y, z);
Tribute_thirteen.teleport(loc); Tribute_thirteen.teleport(loc);
Frozen.add(Tribute_thirteen); plugin.Frozen.add(Tribute_thirteen);
Tribute_thirteen.setFoodLevel(20); Tribute_thirteen.setFoodLevel(20);
} }
if(Playing.size()>= 14){ if(plugin.Playing.size()>= 14){
config.getString("Tribute_fourteen_spawn"); plugin.config.getString("Tribute_fourteen_spawn");
String[] coords = config.getString("Tribute_fourteen_spawn").split(","); String[] coords = plugin.config.getString("Tribute_fourteen_spawn").split(",");
Player Tribute_fourteen = Playing.get(13); Player Tribute_fourteen = plugin.Playing.get(13);
double x = Double.parseDouble(coords[0]); double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]); double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]); double z = Double.parseDouble(coords[2]);
@ -473,13 +491,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world); World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z); Location loc = new Location(w, x, y, z);
Tribute_fourteen.teleport(loc); Tribute_fourteen.teleport(loc);
Frozen.add(Tribute_fourteen); plugin.Frozen.add(Tribute_fourteen);
Tribute_fourteen.setFoodLevel(20); Tribute_fourteen.setFoodLevel(20);
} }
if(Playing.size()>= 15){ if(plugin.Playing.size()>= 15){
config.getString("Tribute_fifteen_spawn"); plugin.config.getString("Tribute_fifteen_spawn");
String[] coords = config.getString("Tribute_fifteen_spawn").split(","); String[] coords = plugin.config.getString("Tribute_fifteen_spawn").split(",");
Player Tribute_fifteen = Playing.get(14); Player Tribute_fifteen = plugin.Playing.get(14);
double x = Double.parseDouble(coords[0]); double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]); double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]); double z = Double.parseDouble(coords[2]);
@ -487,13 +505,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world); World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z); Location loc = new Location(w, x, y, z);
Tribute_fifteen.teleport(loc); Tribute_fifteen.teleport(loc);
Frozen.add(Tribute_fifteen); plugin.Frozen.add(Tribute_fifteen);
Tribute_fifteen.setFoodLevel(20); Tribute_fifteen.setFoodLevel(20);
} }
if(Playing.size()>= 16){ if(plugin.Playing.size()>= 16){
config.getString("Tribute_sixteen_spawn"); plugin.config.getString("Tribute_sixteen_spawn");
String[] coords = config.getString("Tribute_sixteen_spawn").split(","); String[] coords = plugin.config.getString("Tribute_sixteen_spawn").split(",");
Player Tribute_sixteen = Playing.get(15); Player Tribute_sixteen = plugin.Playing.get(15);
double x = Double.parseDouble(coords[0]); double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]); double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]); double z = Double.parseDouble(coords[2]);
@ -501,13 +519,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world); World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z); Location loc = new Location(w, x, y, z);
Tribute_sixteen.teleport(loc); Tribute_sixteen.teleport(loc);
Frozen.add(Tribute_sixteen); plugin.Frozen.add(Tribute_sixteen);
Tribute_sixteen.setFoodLevel(20); Tribute_sixteen.setFoodLevel(20);
} }
if(Playing.size()>= 17){ if(plugin.Playing.size()>= 17){
config.getString("Tribute_seventeen_spawn"); plugin.config.getString("Tribute_seventeen_spawn");
String[] coords = config.getString("Tribute_seventeen_spawn").split(","); String[] coords = plugin.config.getString("Tribute_seventeen_spawn").split(",");
Player Tribute_seventeen = Playing.get(16); Player Tribute_seventeen = plugin.Playing.get(16);
double x = Double.parseDouble(coords[0]); double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]); double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]); double z = Double.parseDouble(coords[2]);
@ -515,13 +533,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world); World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z); Location loc = new Location(w, x, y, z);
Tribute_seventeen.teleport(loc); Tribute_seventeen.teleport(loc);
Frozen.add(Tribute_seventeen); plugin.Frozen.add(Tribute_seventeen);
Tribute_seventeen.setFoodLevel(20); Tribute_seventeen.setFoodLevel(20);
} }
if(Playing.size()>= 18){ if(plugin.Playing.size()>= 18){
config.getString("Tribute_eighteen_spawn"); plugin.config.getString("Tribute_eighteen_spawn");
String[] coords = config.getString("Tribute_eighteen_spawn").split(","); String[] coords = plugin.config.getString("Tribute_eighteen_spawn").split(",");
Player Tribute_eighteen = Playing.get(17); Player Tribute_eighteen = plugin.Playing.get(17);
double x = Double.parseDouble(coords[0]); double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]); double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]); double z = Double.parseDouble(coords[2]);
@ -529,13 +547,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world); World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z); Location loc = new Location(w, x, y, z);
Tribute_eighteen.teleport(loc); Tribute_eighteen.teleport(loc);
Frozen.add(Tribute_eighteen); plugin.Frozen.add(Tribute_eighteen);
Tribute_eighteen.setFoodLevel(20); Tribute_eighteen.setFoodLevel(20);
} }
if(Playing.size()>= 19){ if(plugin.Playing.size()>= 19){
config.getString("Tribute_nineteen_spawn"); plugin.config.getString("Tribute_nineteen_spawn");
String[] coords = config.getString("Tribute_nineteen_spawn").split(","); String[] coords = plugin.config.getString("Tribute_nineteen_spawn").split(",");
Player Tribute_nineteen = Playing.get(18); Player Tribute_nineteen = plugin.Playing.get(18);
double x = Double.parseDouble(coords[0]); double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]); double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]); double z = Double.parseDouble(coords[2]);
@ -543,13 +561,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world); World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z); Location loc = new Location(w, x, y, z);
Tribute_nineteen.teleport(loc); Tribute_nineteen.teleport(loc);
Frozen.add(Tribute_nineteen); plugin.Frozen.add(Tribute_nineteen);
Tribute_nineteen.setFoodLevel(20); Tribute_nineteen.setFoodLevel(20);
} }
if(Playing.size()>= 20){ if(plugin.Playing.size()>= 20){
config.getString("Tribute_twenty_spawn"); plugin.config.getString("Tribute_twenty_spawn");
String[] coords = config.getString("Tribute_twenty_spawn").split(","); String[] coords = plugin.config.getString("Tribute_twenty_spawn").split(",");
Player Tribute_twenty = Playing.get(19); Player Tribute_twenty = plugin.Playing.get(19);
double x = Double.parseDouble(coords[0]); double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]); double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]); double z = Double.parseDouble(coords[2]);
@ -557,13 +575,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world); World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z); Location loc = new Location(w, x, y, z);
Tribute_twenty.teleport(loc); Tribute_twenty.teleport(loc);
Frozen.add(Tribute_twenty); plugin.Frozen.add(Tribute_twenty);
Tribute_twenty.setFoodLevel(20); Tribute_twenty.setFoodLevel(20);
} }
if(Playing.size()>= 21){ if(plugin.Playing.size()>= 21){
config.getString("Tribute_twentyone_spawn"); plugin.config.getString("Tribute_twentyone_spawn");
String[] coords = config.getString("Tribute_twentyone_spawn").split(","); String[] coords = plugin.config.getString("Tribute_twentyone_spawn").split(",");
Player Tribute_twentyone = Playing.get(20); Player Tribute_twentyone = plugin.Playing.get(20);
double x = Double.parseDouble(coords[0]); double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]); double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]); double z = Double.parseDouble(coords[2]);
@ -571,13 +589,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world); World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z); Location loc = new Location(w, x, y, z);
Tribute_twentyone.teleport(loc); Tribute_twentyone.teleport(loc);
Frozen.add(Tribute_twentyone); plugin.Frozen.add(Tribute_twentyone);
Tribute_twentyone.setFoodLevel(20); Tribute_twentyone.setFoodLevel(20);
} }
if(Playing.size()>= 22){ if(plugin.Playing.size()>= 22){
config.getString("Tribute_twentytwo_spawn"); plugin.config.getString("Tribute_twentytwo_spawn");
String[] coords = config.getString("Tribute_twentytwo_spawn").split(","); String[] coords = plugin.config.getString("Tribute_twentytwo_spawn").split(",");
Player Tribute_twentytwo = Playing.get(21); Player Tribute_twentytwo = plugin.Playing.get(21);
double x = Double.parseDouble(coords[0]); double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]); double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]); double z = Double.parseDouble(coords[2]);
@ -585,13 +603,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world); World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z); Location loc = new Location(w, x, y, z);
Tribute_twentytwo.teleport(loc); Tribute_twentytwo.teleport(loc);
Frozen.add(Tribute_twentytwo); plugin.Frozen.add(Tribute_twentytwo);
Tribute_twentytwo.setFoodLevel(20); Tribute_twentytwo.setFoodLevel(20);
} }
if(Playing.size()>= 23){ if(plugin.Playing.size()>= 23){
config.getString("Tribute_twentythree_spawn"); plugin.config.getString("Tribute_twentythree_spawn");
String[] coords = config.getString("Tribute_twentythree_spawn").split(","); String[] coords = plugin.config.getString("Tribute_twentythree_spawn").split(",");
Player Tribute_twentythree = Playing.get(22); Player Tribute_twentythree = plugin.Playing.get(22);
double x = Double.parseDouble(coords[0]); double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]); double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]); double z = Double.parseDouble(coords[2]);
@ -599,13 +617,13 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world); World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z); Location loc = new Location(w, x, y, z);
Tribute_twentythree.teleport(loc); Tribute_twentythree.teleport(loc);
Frozen.add(Tribute_twentythree); plugin.Frozen.add(Tribute_twentythree);
Tribute_twentythree.setFoodLevel(20); Tribute_twentythree.setFoodLevel(20);
} }
if(Playing.size()>= 24){ if(plugin.Playing.size()>= 24){
config.getString("Tribute_twentyfour_spawn"); plugin.config.getString("Tribute_twentyfour_spawn");
String[] coords = config.getString("Tribute_twentyfour_spawn").split(","); String[] coords = plugin.config.getString("Tribute_twentyfour_spawn").split(",");
Player Tribute_twentyfour = Playing.get(23); Player Tribute_twentyfour = plugin.Playing.get(23);
double x = Double.parseDouble(coords[0]); double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]); double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]); double z = Double.parseDouble(coords[2]);
@ -613,14 +631,86 @@ public class HaCommands implements CommandExecutor {
World w = plugin.getServer().getWorld(world); World w = plugin.getServer().getWorld(world);
Location loc = new Location(w, x, y, z); Location loc = new Location(w, x, y, z);
Tribute_twentyfour.teleport(loc); Tribute_twentyfour.teleport(loc);
Frozen.add(Tribute_twentyfour); plugin.Frozen.add(Tribute_twentyfour);
Tribute_twentyfour.setFoodLevel(20); Tribute_twentyfour.setFoodLevel(20);
} }
} }
} }
} }
}
if(args[0].equalsIgnoreCase("Start")){
String begin = plugin.config.getString("Start_Message");
begin = begin.replaceAll("(&([a-f0-9]))", "\u00A7$2");
final String msg = begin;
if(p.hasPermission("HungerArena.Start")){
if(plugin.config.getString("Countdown").equalsIgnoreCase("true")){
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
public void run(){
plugin.getServer().broadcastMessage("10");
}
}, 20L);
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
public void run(){
plugin.getServer().broadcastMessage("9");
}
}, 40L);
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
public void run(){
plugin.getServer().broadcastMessage("8");
}
}, 60L);
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
public void run(){
plugin.getServer().broadcastMessage("7");
}
}, 80L);
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
public void run(){
plugin.getServer().broadcastMessage("6");
}
}, 100L);
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
public void run(){
plugin.getServer().broadcastMessage("5");
}
}, 120L);
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
public void run(){
plugin.getServer().broadcastMessage("4");
}
}, 140L);
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
public void run(){
plugin.getServer().broadcastMessage("3");
}
}, 160L);
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
public void run(){
plugin.getServer().broadcastMessage("2");
}
}, 180L);
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
public void run(){
plugin.getServer().broadcastMessage("1");
}
}, 200L);
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
public void run(){
plugin.Frozen.clear();
plugin.getServer().broadcastMessage(msg);
plugin.canjoin = true;
}
}, 220L);
}else{
plugin.Frozen.clear();
p.getServer().broadcastMessage(ChatColor.AQUA + "Let the Games Begin!!");
plugin.canjoin = true;
}
}else{
p.sendMessage(ChatColor.RED + "You don't have permission!");
}
}
return false; return false;
} }
} }

View File

@ -18,6 +18,9 @@ public class JoinAndQuitListener implements Listener {
public void onPlayerJoin(PlayerJoinEvent event){ public void onPlayerJoin(PlayerJoinEvent event){
Player p = event.getPlayer(); Player p = event.getPlayer();
final Player player = event.getPlayer(); final Player player = event.getPlayer();
for(Player spectator:plugin.Watching){
p.hidePlayer(spectator);
}
if(plugin.Out.contains(p)){ if(plugin.Out.contains(p)){
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){ plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
public void run(){ public void run(){

View File

@ -56,7 +56,10 @@ public class Main extends JavaPlugin{
public Listener Chests = new Chests(this); public Listener Chests = new Chests(this);
public Listener PvP = new PvP(this); public Listener PvP = new PvP(this);
public Listener Blocks = new Blocks(this); public Listener Blocks = new Blocks(this);
public Listener CommandBlock = new CommandBlock(this);
public CommandExecutor HaCommands = new HaCommands(this); public CommandExecutor HaCommands = new HaCommands(this);
public CommandExecutor SponsorCommands = new SponsorCommands(this);
public CommandExecutor SpawnsCommand = new SpawnsCommand(this);
public boolean canjoin; public boolean canjoin;
public boolean exists; public boolean exists;
public FileConfiguration config; public FileConfiguration config;
@ -76,7 +79,10 @@ public class Main extends JavaPlugin{
getServer().getPluginManager().registerEvents(Chests, this); getServer().getPluginManager().registerEvents(Chests, this);
getServer().getPluginManager().registerEvents(PvP, this); getServer().getPluginManager().registerEvents(PvP, this);
getServer().getPluginManager().registerEvents(Blocks, this); getServer().getPluginManager().registerEvents(Blocks, this);
getServer().getPluginManager().registerEvents(CommandBlock, this);
getCommand("Ha").setExecutor(HaCommands); getCommand("Ha").setExecutor(HaCommands);
getCommand("Sponsor").setExecutor(SponsorCommands);
getCommand("Startpoint").setExecutor(SpawnsCommand);
Reward = new ItemStack(config.getInt("Reward.ID"), config.getInt("Reward.Amount")); Reward = new ItemStack(config.getInt("Reward.ID"), config.getInt("Reward.Amount"));
Cost = new ItemStack(config.getInt("Sponsor_Cost.ID"), config.getInt("Sponsor_Cost.Amount")); Cost = new ItemStack(config.getInt("Sponsor_Cost.ID"), config.getInt("Sponsor_Cost.Amount"));
} }
@ -84,12 +90,10 @@ public class Main extends JavaPlugin{
log = this.getLogger(); log = this.getLogger();
log.info("HungerArena has been Disabled"); log.info("HungerArena has been Disabled");
} }
@SuppressWarnings("unchecked") /*public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
Player p = (Player) sender; Player p = (Player) sender;
String pname = p.getName(); String pname = p.getName();
/*if(cmd.getName().equalsIgnoreCase("Sponsor")){ if(cmd.getName().equalsIgnoreCase("Sponsor")){
Player target = Bukkit.getPlayer(args[0]);
if(!Playing.contains(p)){ if(!Playing.contains(p)){
if(args.length== 0){ if(args.length== 0){
p.sendMessage(ChatColor.RED + "You didn't specify a tribute!"); p.sendMessage(ChatColor.RED + "You didn't specify a tribute!");
@ -102,12 +106,12 @@ public class Main extends JavaPlugin{
p.sendMessage(ChatColor.RED + "You didn't specify an amount!"); p.sendMessage(ChatColor.RED + "You didn't specify an amount!");
} }
if(args.length== 3){ if(args.length== 3){
Player target = Bukkit.getPlayer(args[0]);
if(args[1].equalsIgnoreCase("57") || args[1].equalsIgnoreCase("7")){ if(args[1].equalsIgnoreCase("57") || args[1].equalsIgnoreCase("7")){
p.sendMessage(ChatColor.RED + "You can't sponsor that item!"); p.sendMessage(ChatColor.RED + "You can't sponsor that item!");
}else{ }else{
int ID = Integer.parseInt(args[1]); int ID = Integer.parseInt(args[1]);
int Amount = Integer.parseInt(args[2]); int Amount = Integer.parseInt(args[2]);
Cost = new ItemStack(config.getInt("Sponsor_Cost.ID"), config.getInt("Sponsor_Cost.Amount")*Amount);
ItemStack sponsoritem = new ItemStack(ID, Amount); ItemStack sponsoritem = new ItemStack(ID, Amount);
if(p.getInventory().contains(Cost)){ if(p.getInventory().contains(Cost)){
if(!Playing.contains(target)){ if(!Playing.contains(target)){
@ -782,7 +786,7 @@ public class Main extends JavaPlugin{
p.sendMessage(ChatColor.RED + "You don't have permission!"); p.sendMessage(ChatColor.RED + "You don't have permission!");
} }
} }
}*/ }
if(cmd.getName().equalsIgnoreCase("StartPoint")){ if(cmd.getName().equalsIgnoreCase("StartPoint")){
if(p.hasPermission("HungerArena.StartPoint")){ if(p.hasPermission("HungerArena.StartPoint")){
if(args[0].equalsIgnoreCase("1")){ if(args[0].equalsIgnoreCase("1")){
@ -1008,7 +1012,7 @@ public class Main extends JavaPlugin{
return true; return true;
} }
} }
/*class DeadListener implements Listener{ class DeadListener implements Listener{
public Main plugin; public Main plugin;
public DeadListener(Main m){ public DeadListener(Main m){
this.plugin = m; this.plugin = m;
@ -1363,5 +1367,5 @@ public class Main extends JavaPlugin{
plugin.saveConfig(); plugin.saveConfig();
} }
} }
} }*/
}*/ }

View File

@ -0,0 +1,243 @@
package me.Travja.HungerArena;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class SpawnsCommand implements CommandExecutor {
public Main plugin;
public SpawnsCommand(Main m) {
this.plugin = m;
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
Player p = (Player) sender;
if(cmd.getName().equalsIgnoreCase("StartPoint")){
if(p.hasPermission("HungerArena.StartPoint")){
if(args[0].equalsIgnoreCase("1")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_one_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute one!");
}
if(args[0].equalsIgnoreCase("2")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_two_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute two!");
}
if(args[0].equalsIgnoreCase("3")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_three_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute three!");
}
if(args[0].equalsIgnoreCase("4")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_four_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute four!");
}
if(args[0].equalsIgnoreCase("5")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_five_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute five!");
}
if(args[0].equalsIgnoreCase("6")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_six_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute six!");
}
if(args[0].equalsIgnoreCase("7")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_seven_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute seven!");
}
if(args[0].equalsIgnoreCase("8")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_eight_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute eight!");
}
if(args[0].equalsIgnoreCase("9")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_nine_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute nine!");
}
if(args[0].equalsIgnoreCase("10")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_ten_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute ten!");
}
if(args[0].equalsIgnoreCase("11")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_eleven_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute eleven!");
}
if(args[0].equalsIgnoreCase("12")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_twelve_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute twelve!");
}
if(args[0].equalsIgnoreCase("13")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_thirteen_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute thirteen!");
}
if(args[0].equalsIgnoreCase("14")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_fourteen_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute fourteen!");
}
if(args[0].equalsIgnoreCase("15")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_fifteen_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute fifteen!");
}
if(args[0].equalsIgnoreCase("16")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_sixteen_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute sixteen!");
}
if(args[0].equalsIgnoreCase("17")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_seventeen_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute seventeen!");
}
if(args[0].equalsIgnoreCase("18")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_eighteen_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute eighteen!");
}
if(args[0].equalsIgnoreCase("19")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_nineteen_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute nineteen!");
}
if(args[0].equalsIgnoreCase("20")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_twenty_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute twenty!");
}
if(args[0].equalsIgnoreCase("21")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_twentyone_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute twentyone!");
}
if(args[0].equalsIgnoreCase("22")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_twentytwo_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute twentytwo!");
}
if(args[0].equalsIgnoreCase("23")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_twentythree_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute twentythree!");
}
if(args[0].equalsIgnoreCase("24")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_twentyfour_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute twentyfour!");
}
}else{
p.sendMessage(ChatColor.RED + "You don't have permission!");
}
}
return false;
}
}

View File

@ -10,6 +10,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
@ -112,4 +113,13 @@ public class SpectatorListener implements Listener {
System.out.println(p.getName() + " quit while spectating!"); System.out.println(p.getName() + " quit while spectating!");
} }
} }
@EventHandler
public void MobNerf(EntityTargetEvent event){
Entity target = event.getTarget();
if(target instanceof Player){
if(plugin.Watching.contains(target)){
event.setCancelled(true);
}
}
}
} }

View File

@ -0,0 +1,66 @@
package me.Travja.HungerArena;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class SponsorCommands implements CommandExecutor {
public Main plugin;
public SponsorCommands(Main m) {
this.plugin = m;
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
Player p = (Player) sender;
String pname = p.getName();
if(cmd.getName().equalsIgnoreCase("Sponsor")){
if(!plugin.Playing.contains(p)){
if(args.length== 0){
p.sendMessage(ChatColor.RED + "You didn't specify a tribute!");
return false;
}
if(args.length== 1){
p.sendMessage(ChatColor.RED + "You didn't specify an item!");
}
if(args.length== 2){
p.sendMessage(ChatColor.RED + "You didn't specify an amount!");
}
if(args.length== 3){
Player target = Bukkit.getPlayer(args[0]);
if(args[1].equalsIgnoreCase("57") || args[1].equalsIgnoreCase("7")){
p.sendMessage(ChatColor.RED + "You can't sponsor that item!");
}else{
int ID = Integer.parseInt(args[1]);
int Amount = Integer.parseInt(args[2]);
ItemStack sponsoritem = new ItemStack(ID, Amount);
if(p.getInventory().contains(plugin.Cost)){
if(!plugin.Playing.contains(target)){
p.sendMessage(ChatColor.RED + "That person isn't playing!");
}else{
if(args[0].equalsIgnoreCase(pname)){
p.sendMessage(ChatColor.RED + "You can't sponsor yourself!");
}else{
target.sendMessage(ChatColor.AQUA + "You have been Sponsored!");
target.getInventory().addItem(sponsoritem);
p.sendMessage("You have sponsored " + target.getName() + "!");
p.getInventory().removeItem(plugin.Cost);
}
}
}else{
p.sendMessage(ChatColor.RED + "You don't have the necessary items to sponsor!");
}
}
}
}else{
p.sendMessage(ChatColor.RED + "You are playing, you can't sponsor yourself!");
}
}
return false;
}
}