diff --git a/src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java b/src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java index b7c3e61..6b93a70 100644 --- a/src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java +++ b/src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java @@ -584,7 +584,7 @@ class EntityEventHandler implements Listener } //if the attacker is a player and defender is a player (pvp combat) - if(attacker != null && event.getEntity() instanceof Player && GriefPrevention.instance.config_pvp_enabledWorlds.contains(attacker.getWorld())) + if(attacker != null && event.getEntity() instanceof Player && GriefPrevention.instance.pvpRulesApply(attacker.getWorld())) { //FEATURE: prevent pvp in the first minute after spawn, and prevent pvp when one or both players have no inventory @@ -726,7 +726,7 @@ class EntityEventHandler implements Listener if(attackerData.ignoreClaims) return; //otherwise disallow in non-pvp worlds - if(!GriefPrevention.instance.config_pvp_enabledWorlds.contains(subEvent.getEntity().getLocation().getWorld())) + if(!GriefPrevention.instance.pvpRulesApply(subEvent.getEntity().getLocation().getWorld())) { OfflinePlayer owner = GriefPrevention.instance.getServer().getOfflinePlayer(ownerID); String ownerName = owner.getName(); diff --git a/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java b/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java index 8f3c6ca..b80554a 100644 --- a/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java +++ b/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java @@ -124,7 +124,7 @@ public class GriefPrevention extends JavaPlugin public String config_spam_allowedIpAddresses; //IP addresses which will not be censored public int config_spam_deathMessageCooldownSeconds; //cooldown period for death messages (per player) in seconds - public ArrayList config_pvp_enabledWorlds; //list of worlds where pvp anti-grief rules apply + HashMap config_pvp_specifiedWorlds; //list of worlds where pvp anti-grief rules apply, according to the config file public boolean config_pvp_protectFreshSpawns; //whether to make newly spawned players immune until they pick up an item public boolean config_pvp_punishLogout; //whether to kill players who log out during PvP combat public int config_pvp_combatTimeoutSeconds; //how long combat is considered to continue after the most recent damage @@ -471,14 +471,11 @@ public class GriefPrevention extends JavaPlugin } //pvp worlds list - this.config_pvp_enabledWorlds = new ArrayList(); + this.config_pvp_specifiedWorlds = new HashMap(); for(World world : worlds) { boolean pvpWorld = config.getBoolean("GriefPrevention.PvP.RulesEnabledInWorld." + world.getName(), world.getPVP()); - if(pvpWorld) - { - this.config_pvp_enabledWorlds.add(world); - } + this.config_pvp_specifiedWorlds.put(world, pvpWorld); } //sea level @@ -751,7 +748,7 @@ public class GriefPrevention extends JavaPlugin for(World world : worlds) { - outConfig.set("GriefPrevention.PvP.RulesEnabledInWorld." + world.getName(), this.config_pvp_enabledWorlds.contains(world)); + outConfig.set("GriefPrevention.PvP.RulesEnabledInWorld." + world.getName(), this.pvpRulesApply(world)); } outConfig.set("GriefPrevention.PvP.ProtectFreshSpawns", this.config_pvp_protectFreshSpawns); outConfig.set("GriefPrevention.PvP.PunishLogout", this.config_pvp_punishLogout); @@ -3006,8 +3003,8 @@ public class GriefPrevention extends JavaPlugin public boolean pvpRulesApply(World world) { - if(this.config_pvp_enabledWorlds.contains(world)) return true; - + Boolean configSetting = this.config_pvp_specifiedWorlds.get(world); + if(configSetting != null) return configSetting; return world.getPVP(); } } \ No newline at end of file diff --git a/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java b/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java index 3e64713..4d52be6 100644 --- a/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java +++ b/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java @@ -1110,7 +1110,6 @@ class PlayerEventHandler implements Listener return; } - if(!GriefPrevention.instance.pvpRulesApply(entity.getLocation().getWorld())) { //otherwise disallow