Added a message sent to all players on an island when PvP is toggled

Implements https://github.com/BentoBoxWorld/BentoBox/issues/1081

Also removed the "protection.flags.PVP_OVERWORLD.active" message as it seemingly wasn't used.
This commit is contained in:
Florian CUNY 2020-02-13 10:25:18 +01:00
parent f04a4fb522
commit 9abf65709d
2 changed files with 21 additions and 1 deletions

View File

@ -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));
}
}
}

View File

@ -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"