Many bug fixes and more configuration
This commit is contained in:
		@@ -24,12 +24,12 @@ public class ChatListener implements Listener {
 | 
			
		||||
				List<Entity> near = p.getNearbyEntities(radius, radius, radius);
 | 
			
		||||
				event.setCancelled(true);
 | 
			
		||||
				if(!(near.size()== 0)){
 | 
			
		||||
				for(Entity e:near){
 | 
			
		||||
					if(e instanceof Player){
 | 
			
		||||
						p.sendMessage(msg);
 | 
			
		||||
						((Player) e).sendMessage(msg);
 | 
			
		||||
					p.sendMessage(msg);
 | 
			
		||||
					for(Entity e:near){
 | 
			
		||||
						if(e instanceof Player){
 | 
			
		||||
							((Player) e).sendMessage(msg);
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
				}else if(near.size()== 0){
 | 
			
		||||
					p.sendMessage(msg);
 | 
			
		||||
					p.sendMessage(ChatColor.YELLOW + "No one near!");
 | 
			
		||||
@@ -42,6 +42,7 @@ public class ChatListener implements Listener {
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			}else{
 | 
			
		||||
				event.setCancelled(true);
 | 
			
		||||
				plugin.getServer().broadcastMessage(msg);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
@@ -16,7 +16,7 @@ public class CommandBlock implements Listener {
 | 
			
		||||
	public void CatchCommand(PlayerCommandPreprocessEvent event){
 | 
			
		||||
		String cmd = event.getMessage();
 | 
			
		||||
		Player p = event.getPlayer();
 | 
			
		||||
		if(!cmd.contains("/ha") && plugin.Playing.contains(p)){
 | 
			
		||||
		if(!cmd.contains("/ha") && plugin.Playing.contains(p) && plugin.canjoin== true){
 | 
			
		||||
			event.setCancelled(true);
 | 
			
		||||
			p.sendMessage(ChatColor.RED + "You are only allowed to use /ha commands!");
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,6 @@
 | 
			
		||||
package me.Travja.HungerArena;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.ChatColor;
 | 
			
		||||
import org.bukkit.Effect;
 | 
			
		||||
import org.bukkit.Location;
 | 
			
		||||
import org.bukkit.Material;
 | 
			
		||||
import org.bukkit.Server;
 | 
			
		||||
@@ -24,7 +23,7 @@ public class DeathListener implements Listener{
 | 
			
		||||
		Player p = event.getPlayer();
 | 
			
		||||
		if(plugin.Dead.contains(p)){
 | 
			
		||||
			String[] Spawncoords = plugin.config.getString("Spawn_coords").split(",");
 | 
			
		||||
			World spawnw = p.getWorld();
 | 
			
		||||
			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]);
 | 
			
		||||
@@ -37,9 +36,20 @@ public class DeathListener implements Listener{
 | 
			
		||||
		Player p = event.getEntity();
 | 
			
		||||
		Server s = p.getServer();
 | 
			
		||||
		String pname = p.getName();
 | 
			
		||||
		String[] Spawncoords = plugin.config.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.Playing.contains(p)){
 | 
			
		||||
			if(plugin.config.getString("Cannon_Death").equalsIgnoreCase("True")){
 | 
			
		||||
				p.getWorld().playEffect(p.getLocation(), Effect.ZOMBIE_CHEW_WOODEN_DOOR, 0, 300);
 | 
			
		||||
				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);
 | 
			
		||||
			}
 | 
			
		||||
			plugin.Dead.add(p);
 | 
			
		||||
			plugin.Playing.remove(p);
 | 
			
		||||
@@ -56,21 +66,23 @@ public class DeathListener implements Listener{
 | 
			
		||||
							String winnername = winner.getName();
 | 
			
		||||
							s.broadcastMessage(ChatColor.GREEN + winnername + " 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();
 | 
			
		||||
						for(Player spectator:plugin.Watching){
 | 
			
		||||
							spectator.setAllowFlight(false);
 | 
			
		||||
							spectator.teleport(Spawn);
 | 
			
		||||
							for(Player online:plugin.getServer().getOnlinePlayers()){
 | 
			
		||||
								online.showPlayer(spectator);
 | 
			
		||||
							}
 | 
			
		||||
						}
 | 
			
		||||
						if(plugin.config.getString("Auto_Restart").equalsIgnoreCase("True")){
 | 
			
		||||
							plugin.Dead.clear();
 | 
			
		||||
							plugin.Playing.clear();
 | 
			
		||||
							plugin.Quit.clear();
 | 
			
		||||
							plugin.Watching.clear();
 | 
			
		||||
							plugin.Frozen.clear();
 | 
			
		||||
@@ -90,21 +102,23 @@ public class DeathListener implements Listener{
 | 
			
		||||
							String winnername = winner.getName();
 | 
			
		||||
							s.broadcastMessage(ChatColor.GREEN + winnername + " 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();
 | 
			
		||||
						for(Player spectator:plugin.Watching){
 | 
			
		||||
							spectator.setAllowFlight(false);
 | 
			
		||||
							spectator.teleport(Spawn);
 | 
			
		||||
							for(Player online:plugin.getServer().getOnlinePlayers()){
 | 
			
		||||
								online.showPlayer(spectator);
 | 
			
		||||
							}
 | 
			
		||||
						}
 | 
			
		||||
						if(plugin.config.getString("Auto_Restart").equalsIgnoreCase("True")){
 | 
			
		||||
							plugin.Dead.clear();
 | 
			
		||||
							plugin.Playing.clear();
 | 
			
		||||
							plugin.Quit.clear();
 | 
			
		||||
							plugin.Watching.clear();
 | 
			
		||||
							plugin.Frozen.clear();
 | 
			
		||||
@@ -121,21 +135,23 @@ public class DeathListener implements Listener{
 | 
			
		||||
						String winnername = winner.getName();
 | 
			
		||||
						s.broadcastMessage(ChatColor.GREEN + winnername + " 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();
 | 
			
		||||
					for(Player spectator:plugin.Watching){
 | 
			
		||||
						spectator.setAllowFlight(false);
 | 
			
		||||
						spectator.teleport(Spawn);
 | 
			
		||||
						for(Player online:plugin.getServer().getOnlinePlayers()){
 | 
			
		||||
							online.showPlayer(spectator);
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
					if(plugin.config.getString("Auto_Restart").equalsIgnoreCase("True")){
 | 
			
		||||
						plugin.Dead.clear();
 | 
			
		||||
						plugin.Playing.clear();
 | 
			
		||||
						plugin.Quit.clear();
 | 
			
		||||
						plugin.Watching.clear();
 | 
			
		||||
						plugin.Frozen.clear();
 | 
			
		||||
 
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -1,11 +1,13 @@
 | 
			
		||||
package me.Travja.HungerArena;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.ChatColor;
 | 
			
		||||
import org.bukkit.Material;
 | 
			
		||||
import org.bukkit.block.Block;
 | 
			
		||||
import org.bukkit.entity.Player;
 | 
			
		||||
import org.bukkit.event.EventHandler;
 | 
			
		||||
import org.bukkit.event.Listener;
 | 
			
		||||
import org.bukkit.event.block.Action;
 | 
			
		||||
import org.bukkit.event.block.SignChangeEvent;
 | 
			
		||||
import org.bukkit.event.player.PlayerInteractEvent;
 | 
			
		||||
 | 
			
		||||
public class Signs implements Listener {
 | 
			
		||||
@@ -21,21 +23,25 @@ public class Signs implements Listener {
 | 
			
		||||
			if(b.getType()== Material.SIGN || b.getType()==Material.SIGN_POST || b.getType()==Material.WALL_SIGN){
 | 
			
		||||
				org.bukkit.block.Sign sign = (org.bukkit.block.Sign) b.getState();
 | 
			
		||||
				String[] lines = sign.getLines();
 | 
			
		||||
				if(lines[0].equalsIgnoreCase("[HungerArena]")){
 | 
			
		||||
					if(lines[1].equalsIgnoreCase("Join")){
 | 
			
		||||
						p.performCommand("ha join");
 | 
			
		||||
					}
 | 
			
		||||
					if(lines[1].equalsIgnoreCase("Confirm")){
 | 
			
		||||
						p.performCommand("ha confirm");
 | 
			
		||||
					}
 | 
			
		||||
					if(lines[1].equalsIgnoreCase("Leave")){
 | 
			
		||||
						p.performCommand("ha leave");
 | 
			
		||||
				if(lines[0].equalsIgnoreCase(ChatColor.BLUE + "[HungerArena]")){
 | 
			
		||||
					if(lines[1].isEmpty()){
 | 
			
		||||
						p.performCommand("ha");
 | 
			
		||||
					}else{
 | 
			
		||||
						p.performCommand("ha " + lines[1]);
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
				if(lines[0].equalsIgnoreCase("[Sponsor]")){
 | 
			
		||||
					p.performCommand("sponsor" + " " + lines[1] + " " + lines[2] + " " + lines[3]);
 | 
			
		||||
				if(lines[0].equalsIgnoreCase(ChatColor.BLUE + "[Sponsor]")){
 | 
			
		||||
					p.performCommand("sponsor " + lines[1] + " " + lines[2] + " " + lines[3]);
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	@EventHandler
 | 
			
		||||
	public void Create(SignChangeEvent event){
 | 
			
		||||
		String[] lines = event.getLines();
 | 
			
		||||
		String top = lines[0];
 | 
			
		||||
		if(top.equalsIgnoreCase("[HungerArena]") || top.equalsIgnoreCase("[Sponsor]")){
 | 
			
		||||
			event.setLine(0, ChatColor.BLUE + top);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -19,45 +19,49 @@ public class SponsorCommands implements CommandExecutor {
 | 
			
		||||
		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.config.getInt("Sponsor_Cost.ID"), plugin.config.getInt("Sponsor_Cost.Amount")*Amount)){
 | 
			
		||||
							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);
 | 
			
		||||
								}
 | 
			
		||||
							}
 | 
			
		||||
			if(p.hasPermission("HungerArena.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{
 | 
			
		||||
							p.sendMessage(ChatColor.RED + "You don't have the necessary items to sponsor!");
 | 
			
		||||
							int ID = Integer.parseInt(args[1]);
 | 
			
		||||
							int Amount = Integer.parseInt(args[2]);
 | 
			
		||||
							ItemStack sponsoritem = new ItemStack(ID, Amount);
 | 
			
		||||
							if(p.getInventory().contains(plugin.config.getInt("Sponsor_Cost.ID"), plugin.config.getInt("Sponsor_Cost.Amount")*Amount)){
 | 
			
		||||
								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!");
 | 
			
		||||
				}
 | 
			
		||||
			}else{
 | 
			
		||||
				p.sendMessage(ChatColor.RED + "You are playing, you can't sponsor yourself!");
 | 
			
		||||
				p.sendMessage(ChatColor.RED + "You don't have permission!");
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		return false;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user