From d57d181f68eba925fd8395b362722aa29255c593 Mon Sep 17 00:00:00 2001 From: TimWolla Date: Fri, 8 Jul 2011 22:35:47 +0200 Subject: [PATCH] PVP Message can now be disabled Closes https://github.com/taoneill/war/issues/138 --- war/src/main/java/bukkit/tommytony/war/War.java | 9 +++++++++ .../java/bukkit/tommytony/war/WarEntityListener.java | 4 +++- .../main/java/com/tommytony/war/mappers/WarMapper.java | 6 ++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/war/src/main/java/bukkit/tommytony/war/War.java b/war/src/main/java/bukkit/tommytony/war/War.java index 650fbeb..4b2e010 100644 --- a/war/src/main/java/bukkit/tommytony/war/War.java +++ b/war/src/main/java/bukkit/tommytony/war/War.java @@ -83,6 +83,7 @@ public class War extends JavaPlugin { private boolean pvpInZonesOnly = false; private boolean buildInZonesOnly = false; + private boolean disablePVPMessage = false; private WarHub warHub; @@ -1594,6 +1595,14 @@ public class War extends JavaPlugin { public boolean isBuildInZonesOnly() { return buildInZonesOnly; } + + public void setDisablePVPMessage(boolean disablePVPMessage) { + this.disablePVPMessage = disablePVPMessage; + } + + public boolean isDisablePVPMessage() { + return disablePVPMessage; + } public void setDefaultUnbreakableZoneBlocks(boolean defaultUnbreakableZoneBlocks) { this.defaultUnbreakableZoneBlocks = defaultUnbreakableZoneBlocks; diff --git a/war/src/main/java/bukkit/tommytony/war/WarEntityListener.java b/war/src/main/java/bukkit/tommytony/war/WarEntityListener.java index db4269a..cd26d06 100644 --- a/war/src/main/java/bukkit/tommytony/war/WarEntityListener.java +++ b/war/src/main/java/bukkit/tommytony/war/WarEntityListener.java @@ -106,7 +106,9 @@ public class WarEntityListener extends EntityListener { } else if (attackerTeam == null && defenderTeam == null && (!war.isPvpInZonesOnly() || a.getLocation().getWorld().getName().equals("pvp"))){ // let normal PVP through is its not turned off } else if (attackerTeam == null && defenderTeam == null && war.isPvpInZonesOnly()) { - war.badMsg(a, "Your attack missed! Global PVP is turned off. You can only attack other players in warzones. Try /warhub, /zones and /zone."); + if (!war.isDisablePVPMessage()) { + war.badMsg(a, "Your attack missed! Global PVP is turned off. You can only attack other players in warzones. Try /warhub, /zones and /zone."); + } event.setCancelled(true); // global pvp is off } else { war.badMsg(a, "Your attack missed!"); diff --git a/war/src/main/java/com/tommytony/war/mappers/WarMapper.java b/war/src/main/java/com/tommytony/war/mappers/WarMapper.java index 573fd42..b17fc8f 100644 --- a/war/src/main/java/com/tommytony/war/mappers/WarMapper.java +++ b/war/src/main/java/com/tommytony/war/mappers/WarMapper.java @@ -106,6 +106,9 @@ public class WarMapper { // buildInZonesOnly war.setBuildInZonesOnly(warConfig.getBoolean("buildInZonesOnly")); + // disablePVPMessage + war.setDisablePVPMessage(warConfig.getBoolean("disablePVPMessage")); + // defaultSpawnStyle String spawnStyle = warConfig.getString("defaultspawnStyle"); if(spawnStyle != null && !spawnStyle.equals("")){ @@ -214,6 +217,9 @@ public class WarMapper { // buildInZonesOnly warConfig.setBoolean("buildInZonesOnly", war.isBuildInZonesOnly()); + // disablePVPMessage + warConfig.setBoolean("disablePVPMessage", war.isDisablePVPMessage()); + // spawnStyle warConfig.setString("spawnStyle", war.getDefaultSpawnStyle());