Add new seeker/hider protection configuration options.

To use these new protection features, these options must be
manually added to the arenas.yml file and restart the server.

These settings should be fairly self-explanatory:

arena1:
  ==: BlockHuntArena
  seekersCanHurtSeekers: false
  hidersCanHurtSeekers: false
  hidersCanHurtHiders: false
  seekersTakeFallDamage: false
  hidersTakeFallDamage: false
This commit is contained in:
addstar 2015-05-16 19:53:38 +10:00
parent b353589963
commit 1e38bd6b29
7 changed files with 182 additions and 98 deletions

View File

@ -28,7 +28,11 @@ public class Arena implements ConfigurationSerializable {
public int gameTime; public int gameTime;
public int timeUntilHidersSword; public int timeUntilHidersSword;
public int blockAnnouncerTime; public int blockAnnouncerTime;
public boolean seekerProtection; public boolean seekersCanHurtSeekers;
public boolean hidersCanHurtSeekers;
public boolean hidersCanHurtHiders;
public boolean seekersTakeFallDamage;
public boolean hidersTakeFallDamage;
public ArrayList<ItemStack> disguiseBlocks; public ArrayList<ItemStack> disguiseBlocks;
public LocationSerializable lobbyWarp; public LocationSerializable lobbyWarp;
public LocationSerializable hidersWarp; public LocationSerializable hidersWarp;
@ -48,8 +52,9 @@ public class Arena implements ConfigurationSerializable {
public Scoreboard scoreboard; public Scoreboard scoreboard;
public Arena(String arenaName, LocationSerializable pos1, LocationSerializable pos2, int maxPlayers, int minPlayers, int amountSeekersOnStart, public Arena(String arenaName, LocationSerializable pos1, LocationSerializable pos2, int maxPlayers, int minPlayers, int amountSeekersOnStart,
int timeInLobbyUntilStart, int waitingTimeSeeker, int gameTime, int timeUntilHidersSword, int blockAnnouncerTime, boolean seekerProtection, ArrayList<ItemStack> disguiseBlocks, int timeInLobbyUntilStart, int waitingTimeSeeker, int gameTime, int timeUntilHidersSword, int blockAnnouncerTime,
LocationSerializable lobbyWarp, LocationSerializable hidersWarp, LocationSerializable seekersWarp, LocationSerializable spawnWarp, boolean seekersCanHurtSeekers, boolean hidersCanHurtSeekers, boolean hidersCanHurtHiders, boolean seekersTakeFallDamage, boolean hidersTakeFallDamage,
ArrayList<ItemStack> disguiseBlocks, LocationSerializable lobbyWarp, LocationSerializable hidersWarp, LocationSerializable seekersWarp, LocationSerializable spawnWarp,
List<String> seekersWinCommands, List<String> hidersWinCommands, List<String> allowedCommands, int seekersTokenWin, int hidersTokenWin, int killTokens, List<String> seekersWinCommands, List<String> hidersWinCommands, List<String> allowedCommands, int seekersTokenWin, int hidersTokenWin, int killTokens,
List<Player> playersInArena, ArenaState gameState, int timer, List<Player> seekers, Scoreboard scoreboard) { List<Player> playersInArena, ArenaState gameState, int timer, List<Player> seekers, Scoreboard scoreboard) {
this.arenaName = arenaName; this.arenaName = arenaName;
@ -137,9 +142,9 @@ public class Arena implements ConfigurationSerializable {
LocationSerializable loc = new LocationSerializable(Bukkit.getWorld("world"), 0, 0, 0, 0, 0); LocationSerializable loc = new LocationSerializable(Bukkit.getWorld("world"), 0, 0, 0, 0, 0);
return new Arena((String) M.g(map, "arenaName", "UNKNOWN_NAME"), (LocationSerializable) M.g(map, "pos1", loc), (LocationSerializable) M.g(map, "pos2", loc), return new Arena((String) M.g(map, "arenaName", "UNKNOWN_NAME"), (LocationSerializable) M.g(map, "pos1", loc), (LocationSerializable) M.g(map, "pos2", loc),
(Integer) M.g(map, "maxPlayers", 12), (Integer) M.g(map, "minPlayers", 3), (Integer) M.g(map, "amountSeekersOnStart", 1), (Integer) M.g(map, "timeInLobbyUntilStart", 90), (Integer) M.g(map, "maxPlayers", 12), (Integer) M.g(map, "minPlayers", 3), (Integer) M.g(map, "amountSeekersOnStart", 1), (Integer) M.g(map, "timeInLobbyUntilStart", 90),
(Integer) M.g(map, "waitingTimeSeeker", 20), (Integer) M.g(map, "gameTime", 200), (Integer) M.g(map, "timeUntilHidersSword", 30), (Integer) M.g(map, "waitingTimeSeeker", 20), (Integer) M.g(map, "gameTime", 200), (Integer) M.g(map, "timeUntilHidersSword", 30),(Integer) M.g(map, "blockAnnouncerTime", 45),
(Integer) M.g(map, "blockAnnouncerTime", 45), (Boolean) M.g(map, "seekerProtection", false),(ArrayList<ItemStack>) M.g(map, "disguiseBlocks", new ArrayList<ItemStack>()), (Boolean) M.g(map, "seekersCanHurtSeekers", false),(Boolean) M.g(map, "hidersCanHurtSeekers", false),(Boolean) M.g(map, "hidersCanHurtHiders", false),(Boolean) M.g(map, "seekersTakeFallDamage", false),(Boolean) M.g(map, "hidersTakeFallDamage", false),
(LocationSerializable) M.g(map, "lobbyWarp", loc), (LocationSerializable) M.g(map, "hidersWarp", loc), (LocationSerializable) M.g(map, "seekersWarp", loc), (ArrayList<ItemStack>) M.g(map, "disguiseBlocks", new ArrayList<ItemStack>()),(LocationSerializable) M.g(map, "lobbyWarp", loc), (LocationSerializable) M.g(map, "hidersWarp", loc), (LocationSerializable) M.g(map, "seekersWarp", loc),
(LocationSerializable) M.g(map, "spawnWarp", loc), (ArrayList<String>) M.g(map, "seekersWinCommands", new ArrayList<String>()), (LocationSerializable) M.g(map, "spawnWarp", loc), (ArrayList<String>) M.g(map, "seekersWinCommands", new ArrayList<String>()),
(ArrayList<String>) M.g(map, "hidersWinCommands", new ArrayList<String>()), (ArrayList<String>) M.g(map, "allowedCommands", new ArrayList<String>()), (ArrayList<String>) M.g(map, "hidersWinCommands", new ArrayList<String>()), (ArrayList<String>) M.g(map, "allowedCommands", new ArrayList<String>()),
(Integer) M.g(map, "seekersTokenWin", 10), (Integer) M.g(map, "hidersTokenWin", 50), (Integer) M.g(map, "killTokens", 8), new ArrayList<Player>(), (Integer) M.g(map, "seekersTokenWin", 10), (Integer) M.g(map, "hidersTokenWin", 50), (Integer) M.g(map, "killTokens", 8), new ArrayList<Player>(),

View File

@ -25,7 +25,7 @@ public class CMDcreate extends DefaultCMD {
} else { } else {
if (W.pos1.get(player) != null && W.pos2.get(player) != null) { if (W.pos1.get(player) != null && W.pos2.get(player) != null) {
if (W.pos1.get(player).getWorld().equals(W.pos2.get(player).getWorld())) { if (W.pos1.get(player).getWorld().equals(W.pos2.get(player).getWorld())) {
Arena arena = new Arena(args[1], W.pos1.get(player), W.pos2.get(player), 12, 3, 1, 50, 20, 300, 30, 45, false, new ArrayList<ItemStack>(), null, null, null, Arena arena = new Arena(args[1], W.pos1.get(player), W.pos2.get(player), 12, 3, 1, 50, 20, 300, 30, 45, false, false, false, false, false, new ArrayList<ItemStack>(), null, null, null,
null, new ArrayList<String>(), new ArrayList<String>(), new ArrayList<String>(), 10, 50, 8, new ArrayList<Player>(), ArenaState.WAITING, null, new ArrayList<String>(), new ArrayList<String>(), new ArrayList<String>(), 10, 50, 8, new ArrayList<Player>(), ArenaState.WAITING,
0, new ArrayList<Player>(), Bukkit.getScoreboardManager().getNewScoreboard()); 0, new ArrayList<Player>(), Bukkit.getScoreboardManager().getNewScoreboard());
W.arenas.getFile().set(args[1], arena); W.arenas.getFile().set(args[1], arena);

View File

@ -1,6 +1,7 @@
package nl.Steffion.BlockHunt.Listeners; package nl.Steffion.BlockHunt.Listeners;
import nl.Steffion.BlockHunt.Arena; import nl.Steffion.BlockHunt.Arena;
import nl.Steffion.BlockHunt.ArenaHandler;
import nl.Steffion.BlockHunt.W; import nl.Steffion.BlockHunt.W;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -13,8 +14,10 @@ public class OnBlockPlaceEvent implements Listener {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onBlockPlaceEvent(BlockPlaceEvent event) { public void onBlockPlaceEvent(BlockPlaceEvent event) {
Player player = event.getPlayer(); // Early exit if no one is in any arena
if (ArenaHandler.noPlayersInArenas()) return;
Player player = event.getPlayer();
for (Arena arena : W.arenaList) { for (Arena arena : W.arenaList) {
if (arena.playersInArena.contains(player)) { if (arena.playersInArena.contains(player)) {
event.setCancelled(true); event.setCancelled(true);

View File

@ -15,123 +15,160 @@ import nl.Steffion.BlockHunt.Managers.MessageM;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.projectiles.ProjectileSource;
public class OnEntityDamageByEntityEvent implements Listener { public class OnEntityDamageByEntityEvent implements Listener {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onEntityDamageByEntityEvent(EntityDamageByEntityEvent event) { public void onEntityDamageByEntityEvent(EntityDamageByEntityEvent event) {
Player player = null; if (!(event.getEntity() instanceof Player) || event.getEntity() == null) {
if (event.getEntity() instanceof Player) { // We only care about player damage
player = (Player) event.getEntity(); return;
} }
// Early exit if no one is in any arena
if (ArenaHandler.noPlayersInArenas()) return;
Player player = (Player) event.getEntity();
Player damager = null; Player damager = null;
String damagername = "unknown";
if (event.getDamager() instanceof Player) { if (event.getDamager() instanceof Player) {
damager = (Player) event.getDamager(); damager = (Player) event.getDamager();
damagername = damager.getName(); System.out.println("[DEBUG] EntityDamageByEntity: Player = " + player.getName() + " / Damager = " + damager.getName() + " / Cause = " + event.getCause());
} else {
if ((event.getCause() == DamageCause.PROJECTILE) && (event.getDamager() instanceof Arrow)) {
// If damage was caused by an arrow, find out who shot the arrow
Arrow arrow = (Arrow) event.getDamager();
ProjectileSource shooter = arrow.getShooter();
if (shooter instanceof Player) {
damager = (Player) shooter;
}
}
System.out.println("[DEBUG] EntityDamageByEntity: Player = " + player.getName() + " / Damager = " + event.getDamager() + " / Cause = " + event.getCause());
} }
if (player != null) { // Always block all damage not dealt by a player
for (Arena arena : W.arenaList) { if (damager == null || !(damager instanceof Player)) {
if (arena.playersInArena.contains(player)) { event.setCancelled(true);
if (arena.gameState == ArenaState.WAITING || arena.gameState == ArenaState.STARTING) { System.out.println("[DEBUG] EntityDamageByEntity: isCancelled = " + event.isCancelled());
event.setCancelled(true); return;
} else { }
if (arena.seekers.contains(player)) {
event.setCancelled(true);
} else if (arena.seekerProtection && arena.playersInArena.contains(player) && arena.playersInArena.contains(event.getDamager())
&& !arena.seekers.contains(event.getDamager()) && !arena.seekers.contains(player)) {
event.setCancelled(true);
} else {
player.getWorld().playSound(player.getLocation(), Sound.HURT_FLESH, 1, 1);
if (event.getDamage() >= player.getHealth()) { for (Arena arena : W.arenaList) {
player.setHealth(20); if (arena.playersInArena.contains(player)) {
if (arena.gameState == ArenaState.WAITING || arena.gameState == ArenaState.STARTING) {
// Always cancel damage when players are waiting
event.setCancelled(true);
System.out.println("[DEBUG] EntityDamageByEntity: isCancelled = " + event.isCancelled());
return;
} else {
// Seeker receiving damage
if (arena.seekers.contains(player)) {
if (arena.seekers.contains(damager)) {
// Seeker damaged by seeker
if (!arena.seekersCanHurtSeekers) {
event.setCancelled(true); event.setCancelled(true);
System.out.println("[DEBUG] EntityDamageByEntity: isCancelled = " + event.isCancelled());
return;
}
} else {
// Seeker damaged by hider
if (!arena.hidersCanHurtSeekers) {
event.setCancelled(true);
System.out.println("[DEBUG] EntityDamageByEntity: isCancelled = " + event.isCancelled());
return;
}
}
event.setCancelled(true);
System.out.println("[DEBUG] EntityDamageByEntity: isCancelled = " + event.isCancelled());
return;
} else {
// Hider damaged by hider
if (!arena.hidersCanHurtHiders && !arena.seekers.contains(damager)) {
event.setCancelled(true);
System.out.println("[DEBUG] EntityDamageByEntity: isCancelled = " + event.isCancelled());
return;
}
}
System.out.println("[DEBUG] EntityDamageByEntity: isCancelled = " + event.isCancelled());
DisguiseAPI.undisguiseToAll(player); // The damage is allowed, so lets handle it!
W.pBlock.remove(player); player.getWorld().playSound(player.getLocation(), Sound.HURT_FLESH, 1, 1);
if (!arena.seekers.contains(player)) { if (event.getDamage() >= player.getHealth()) {
if (W.shop.getFile().get(damager.getName() + ".tokens") == null) { player.setHealth(20);
W.shop.getFile().set(damager.getName() + ".tokens", 0); event.setCancelled(true);
W.shop.save(); System.out.println("[DEBUG] EntityDamageByEntity: isCancelled = " + event.isCancelled() + "(handling fake damage)");
}
int damagerTokens = W.shop.getFile().getInt(damager.getName() + ".tokens");
W.shop.getFile().set(damager.getName() + ".tokens", damagerTokens + arena.killTokens);
W.shop.save();
MessageM.sendFMessage(damager, ConfigC.normal_addedToken, "amount-" + arena.killTokens); DisguiseAPI.undisguiseToAll(player);
W.pBlock.remove(player);
if (W.shop.getFile().get(player.getName() + ".tokens") == null) { if (!arena.seekers.contains(player)) {
W.shop.getFile().set(player.getName() + ".tokens", 0); if (W.shop.getFile().get(damager.getName() + ".tokens") == null) {
W.shop.save(); W.shop.getFile().set(damager.getName() + ".tokens", 0);
} W.shop.save();
int playerTokens = W.shop.getFile().getInt(player.getName() + ".tokens"); }
float addingTokens = ((float) arena.hidersTokenWin - (((float) arena.timer / (float) arena.gameTime) * (float) arena.hidersTokenWin)); int damagerTokens = W.shop.getFile().getInt(damager.getName() + ".tokens");
W.shop.getFile().set(player.getName() + ".tokens", playerTokens + (int) addingTokens); W.shop.getFile().set(damager.getName() + ".tokens", damagerTokens + arena.killTokens);
W.shop.save(); W.shop.save();
MessageM.sendFMessage(player, ConfigC.normal_addedToken, "amount-" + (int) addingTokens); MessageM.sendFMessage(damager, ConfigC.normal_addedToken, "amount-" + arena.killTokens);
arena.seekers.add(player); if (W.shop.getFile().get(player.getName() + ".tokens") == null) {
ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameHiderDied, "playername-" + player.getName(), "killer-" + damagername); W.shop.getFile().set(player.getName() + ".tokens", 0);
W.shop.save();
}
int playerTokens = W.shop.getFile().getInt(player.getName() + ".tokens");
float addingTokens = ((float) arena.hidersTokenWin - (((float) arena.timer / (float) arena.gameTime) * (float) arena.hidersTokenWin));
W.shop.getFile().set(player.getName() + ".tokens", playerTokens + (int) addingTokens);
W.shop.save();
int hidercount = (arena.playersInArena.size() - arena.seekers.size()); MessageM.sendFMessage(player, ConfigC.normal_addedToken, "amount-" + (int) addingTokens);
if ((hidercount <= 3) && (hidercount > 0)) {
List<String> hiders = new ArrayList<String>();
for (Player p : arena.playersInArena) {
if (!arena.seekers.contains(p)) {
hiders.add(p.getName());
}
}
Collections.sort(hiders);
ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameHidersLeft, "left-" + StringUtils.join(hiders.toArray(), ", ")); arena.seekers.add(player);
} else { ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameHiderDied, "playername-" + player.getDisplayName(), "killer-" + damager.getDisplayName());
ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameHidersLeft, "left-" + hidercount);
int hidercount = (arena.playersInArena.size() - arena.seekers.size());
if ((hidercount <= 3) && (hidercount > 0)) {
List<String> hiders = new ArrayList<String>();
for (Player p : arena.playersInArena) {
if (!arena.seekers.contains(p)) {
hiders.add(p.getName());
} }
} }
Collections.sort(hiders);
player.getInventory().clear(); ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameHidersLeft, "left-" + StringUtils.join(hiders.toArray(), ", "));
player.updateInventory(); } else {
ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameHidersLeft, "left-" + hidercount);
}
}
if (arena.seekers.size() >= arena.playersInArena.size()) { player.getInventory().clear();
ArenaHandler.seekersWin(arena); player.updateInventory();
} else {
DisguiseAPI.undisguiseToAll(player);
W.seekertime.put(player, arena.waitingTimeSeeker);
player.teleport(arena.seekersWarp);
player.setGameMode(GameMode.SURVIVAL);
player.setWalkSpeed(0.3F);
// Fix for client not showing players after if (arena.seekers.size() >= arena.playersInArena.size()) {
// they join ArenaHandler.seekersWin(arena);
for (Player otherplayer : arena.playersInArena) { } else {
if (otherplayer.canSee(player)) DisguiseAPI.undisguiseToAll(player);
otherplayer.showPlayer(player); // Make W.seekertime.put(player, arena.waitingTimeSeeker);
// new player.teleport(arena.seekersWarp);
// player player.setGameMode(GameMode.SURVIVAL);
// visible player.setWalkSpeed(0.3F);
// to
// others // Fix for client not showing players after they join
if (player.canSee(otherplayer)) for (Player otherplayer : arena.playersInArena) {
player.showPlayer(otherplayer); // Make if (otherplayer.canSee(player))
// other otherplayer.showPlayer(player); // Make new player visible to others
// players if (player.canSee(otherplayer))
// visible player.showPlayer(otherplayer); // Make other players visible to new player
// to
// new
// player
}
}
} }
} }
} }

View File

@ -1,6 +1,7 @@
package nl.Steffion.BlockHunt.Listeners; package nl.Steffion.BlockHunt.Listeners;
import nl.Steffion.BlockHunt.Arena; import nl.Steffion.BlockHunt.Arena;
import nl.Steffion.BlockHunt.ArenaHandler;
import nl.Steffion.BlockHunt.W; import nl.Steffion.BlockHunt.W;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
@ -15,17 +16,49 @@ public class OnEntityDamageEvent implements Listener {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onEntityDamageEvent(EntityDamageEvent event) { public void onEntityDamageEvent(EntityDamageEvent event) {
Entity ent = event.getEntity(); // Early exit if no one is in any arena
if (ArenaHandler.noPlayersInArenas()) return;
Entity ent = event.getEntity();
if (ent instanceof Player) { if (ent instanceof Player) {
Player player = (Player) event.getEntity(); Player player = (Player) event.getEntity();
for (Arena arena : W.arenaList) { for (Arena arena : W.arenaList) {
if (arena.playersInArena.contains(player)) { if (arena.playersInArena.contains(player)) {
if (!event.getCause().equals(DamageCause.ENTITY_ATTACK)) { DamageCause cause = event.getCause();
event.setCancelled(true); System.out.println("[DEBUG] EntityDamage: Player = " + player.getName() + " / Cause = " + cause);
switch (cause) {
case ENTITY_ATTACK:
// Do nothing about damage from an entity
// Any entity damage that makes it to here was already allowed by the EntityDamageByEntity event
break;
case FALL:
// Should we prevent the fall damage?
if (arena.seekers.contains(player)) {
if (!arena.seekersTakeFallDamage) {
// Prevent seeker fall damage (if configured)
event.setCancelled(true);
System.out.println("[DEBUG] EntityDamage: isCancelled = " + event.isCancelled());
return;
}
} else {
if (!arena.hidersTakeFallDamage) {
// Prevent hider fall damage (if configured)
event.setCancelled(true);
System.out.println("[DEBUG] EntityDamage: isCancelled = " + event.isCancelled());
return;
}
}
break;
default:
// Cancel all non-entity damage for all players (lava, drowning, fire, etc)
event.setCancelled(true);
System.out.println("[DEBUG] EntityDamage: isCancelled = " + event.isCancelled());
break;
} }
System.out.println("[DEBUG] EntityDamage: isCancelled = " + event.isCancelled());
return;
} }
} }
} }
} }
} }

View File

@ -1,6 +1,7 @@
package nl.Steffion.BlockHunt.Listeners; package nl.Steffion.BlockHunt.Listeners;
import nl.Steffion.BlockHunt.Arena; import nl.Steffion.BlockHunt.Arena;
import nl.Steffion.BlockHunt.ArenaHandler;
import nl.Steffion.BlockHunt.ConfigC; import nl.Steffion.BlockHunt.ConfigC;
import nl.Steffion.BlockHunt.PermissionsC.Permissions; import nl.Steffion.BlockHunt.PermissionsC.Permissions;
import nl.Steffion.BlockHunt.W; import nl.Steffion.BlockHunt.W;
@ -17,8 +18,10 @@ public class OnPlayerCommandPreprocessEvent implements Listener {
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerCommandPreprocessEvent(PlayerCommandPreprocessEvent event) { public void onPlayerCommandPreprocessEvent(PlayerCommandPreprocessEvent event) {
Player player = event.getPlayer(); // Early exit if no one is in any arena
if (ArenaHandler.noPlayersInArenas()) return;
Player player = event.getPlayer();
for (Arena arena : W.arenaList) { for (Arena arena : W.arenaList) {
if (arena.playersInArena.contains(player)) { if (arena.playersInArena.contains(player)) {
String m = event.getMessage(); String m = event.getMessage();

View File

@ -1,6 +1,7 @@
package nl.Steffion.BlockHunt.Listeners; package nl.Steffion.BlockHunt.Listeners;
import nl.Steffion.BlockHunt.Arena; import nl.Steffion.BlockHunt.Arena;
import nl.Steffion.BlockHunt.ArenaHandler;
import nl.Steffion.BlockHunt.Arena.ArenaState; import nl.Steffion.BlockHunt.Arena.ArenaState;
import nl.Steffion.BlockHunt.W; import nl.Steffion.BlockHunt.W;
@ -17,8 +18,10 @@ public class OnPlayerMoveEvent implements Listener {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerMoveEvent(PlayerMoveEvent event) { public void onPlayerMoveEvent(PlayerMoveEvent event) {
Player player = event.getPlayer(); // Early exit if no one is in any arena
if (ArenaHandler.noPlayersInArenas()) return;
Player player = event.getPlayer();
for (Arena arena : W.arenaList) { for (Arena arena : W.arenaList) {
if (arena.playersInArena.contains(player)) { if (arena.playersInArena.contains(player)) {
if (arena.gameState == ArenaState.INGAME) { if (arena.gameState == ArenaState.INGAME) {