diff --git a/src/me/ryanhamshire/GriefPrevention/BlockEventHandler.java b/src/me/ryanhamshire/GriefPrevention/BlockEventHandler.java index 6bd102e..f774d97 100644 --- a/src/me/ryanhamshire/GriefPrevention/BlockEventHandler.java +++ b/src/me/ryanhamshire/GriefPrevention/BlockEventHandler.java @@ -182,7 +182,7 @@ public class BlockEventHandler implements Listener //FEATURE: limit fire placement, to prevent PvP-by-fire //if placed block is fire and pvp is off, apply rules for proximity to other players - if(block.getType() == Material.FIRE && !GriefPrevention.instance.config_pvp_enabledWorlds.contains(block.getWorld()) && !player.hasPermission("griefprevention.lava")) + if(block.getType() == Material.FIRE && !GriefPrevention.instance.pvpRulesApply(block.getWorld()) && !player.hasPermission("griefprevention.lava")) { List players = block.getWorld().getPlayers(); for(int i = 0; i < players.size(); i++) diff --git a/src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java b/src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java index 6ea2d70..2f09ccf 100644 --- a/src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java +++ b/src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java @@ -407,7 +407,7 @@ class EntityEventHandler implements Listener World world = entity.getWorld(); //decide whether or not to apply this feature to this situation (depends on the world where it happens) - boolean isPvPWorld = GriefPrevention.instance.config_pvp_enabledWorlds.contains(world); + boolean isPvPWorld = GriefPrevention.instance.pvpRulesApply(world); if((isPvPWorld && GriefPrevention.instance.config_lockDeathDropsInPvpWorlds) || (!isPvPWorld && GriefPrevention.instance.config_lockDeathDropsInNonPvpWorlds)) { @@ -537,7 +537,7 @@ class EntityEventHandler implements Listener if(event.getEntity() instanceof Horse && !GriefPrevention.instance.config_claims_protectHorses) return; //protect pets from environmental damage types which could be easily caused by griefers - if(event.getEntity() instanceof Tameable && !GriefPrevention.instance.config_pvp_enabledWorlds.contains(event.getEntity().getWorld())) + if(event.getEntity() instanceof Tameable && !GriefPrevention.instance.pvpRulesApply(event.getEntity().getWorld())) { Tameable tameable = (Tameable)event.getEntity(); if(tameable.isTamed()) @@ -836,7 +836,7 @@ class EntityEventHandler implements Listener EntityDamageByEntityEvent subEvent = (EntityDamageByEntityEvent) event; //if not in a pvp rules world, do nothing - if(!GriefPrevention.instance.config_pvp_enabledWorlds.contains(defender.getWorld())) return; + if(!GriefPrevention.instance.pvpRulesApply(defender.getWorld())) return; //determine which player is attacking, if any Player attacker = null; diff --git a/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java b/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java index 6d8d0a3..b453cd0 100644 --- a/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java +++ b/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java @@ -2640,7 +2640,7 @@ public class GriefPrevention extends JavaPlugin if(!this.config_pvp_protectFreshSpawns) return; //if pvp is disabled, do nothing - if(!this.config_pvp_enabledWorlds.contains(player.getWorld())) return; + if(!pvpRulesApply(player.getWorld())) return; //if player is in creative mode, do nothing if(player.getGameMode() == GameMode.CREATIVE) return; @@ -2983,4 +2983,11 @@ public class GriefPrevention extends JavaPlugin return false; } + + public boolean pvpRulesApply(World world) + { + if(this.config_pvp_enabledWorlds.contains(world)) return true; + + 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 0d698df..8b0b368 100644 --- a/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java +++ b/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java @@ -1101,7 +1101,7 @@ class PlayerEventHandler implements Listener return; } - if(!GriefPrevention.instance.config_pvp_enabledWorlds.contains(entity.getLocation().getWorld())) + if(!GriefPrevention.instance.pvpRulesApply(entity.getLocation().getWorld())) { //otherwise disallow OfflinePlayer owner = GriefPrevention.instance.getServer().getOfflinePlayer(ownerID); @@ -1260,7 +1260,7 @@ class PlayerEventHandler implements Listener } //the rest of this code is specific to pvp worlds - if(!GriefPrevention.instance.config_pvp_enabledWorlds.contains(player.getWorld())) return; + if(!GriefPrevention.instance.pvpRulesApply(player.getWorld())) return; //if we're preventing spawn camping and the player was previously empty handed... if(GriefPrevention.instance.config_pvp_protectFreshSpawns && (player.getItemInHand().getType() == Material.AIR)) @@ -1349,7 +1349,7 @@ class PlayerEventHandler implements Listener } //lava buckets can't be dumped near other players unless pvp is on - if(!GriefPrevention.instance.config_pvp_enabledWorlds.contains(block.getWorld()) && !player.hasPermission("griefprevention.lava")) + if(!GriefPrevention.instance.pvpRulesApply(block.getWorld()) && !player.hasPermission("griefprevention.lava")) { if(bucketEvent.getBucket() == Material.LAVA_BUCKET) {