diff --git a/src/main/java/world/bentobox/bentobox/listeners/flags/settings/PVPListener.java b/src/main/java/world/bentobox/bentobox/listeners/flags/settings/PVPListener.java index 1b43ab6c7..740eb5102 100644 --- a/src/main/java/world/bentobox/bentobox/listeners/flags/settings/PVPListener.java +++ b/src/main/java/world/bentobox/bentobox/listeners/flags/settings/PVPListener.java @@ -24,10 +24,12 @@ import org.bukkit.event.entity.LingeringPotionSplashEvent; import org.bukkit.event.entity.PotionSplashEvent; import org.bukkit.event.player.PlayerFishEvent; +import world.bentobox.bentobox.api.events.flags.FlagSettingChangeEvent; import world.bentobox.bentobox.api.flags.Flag; import world.bentobox.bentobox.api.flags.FlagListener; import world.bentobox.bentobox.api.user.User; import world.bentobox.bentobox.lists.Flags; +import world.bentobox.bentobox.managers.RanksManager; /** * Handles PVP @@ -211,4 +213,17 @@ public class PVPListener extends FlagListener { firedFireworks.put(e.getProjectile(), (Player)e.getEntity()); } } + + @EventHandler(priority = EventPriority.NORMAL) + public void onPVPFlagToggle(final FlagSettingChangeEvent e) { + Flag flag = e.getEditedFlag(); + // Only care about PVP Flags + if (Flags.PVP_OVERWORLD.equals(flag) || Flags.PVP_NETHER.equals(flag) || Flags.PVP_END.equals(flag)) { + String message = "protection.flags." + flag.getID() + "." + (e.isSetTo() ? "enabled" : "disabled"); + // Send the message to visitors + e.getIsland().getVisitors().forEach(visitor -> User.getInstance(visitor).sendMessage(message)); + // Send the message to island members (and coops and trusted) + e.getIsland().getMemberSet(RanksManager.COOP_RANK).forEach(member -> User.getInstance(member).sendMessage(message)); + } + } } diff --git a/src/main/resources/locales/en-US.yml b/src/main/resources/locales/en-US.yml index 1fa97865a..9fa9ac071 100644 --- a/src/main/resources/locales/en-US.yml +++ b/src/main/resources/locales/en-US.yml @@ -1066,19 +1066,24 @@ protection: &c in the End. name: "End PVP" hint: "PVP disabled in the End" + enabled: "&c The PVP in the End has been enabled." + disabled: "&a The PVP in the End has been disabled." PVP_NETHER: description: |- &c Enable/Disable PVP &c in the Nether. name: "Nether PVP" hint: "PVP disabled in the Nether" + enabled: "&c The PVP in the Nether has been enabled." + disabled: "&a The PVP in the Nether has been disabled." PVP_OVERWORLD: description: |- &c Enable/Disable PVP &c on island. name: "Overworld PVP" hint: "&c PVP disabled in the Overworld" - active: "&c PVP is active here!" + enabled: "&c The PVP in the Overworld has been enabled." + disabled: "&a The PVP in the Overworld has been disabled." REDSTONE: description: "Toggle use" name: "Redstone items"