mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-01-08 09:27:38 +01:00
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:
parent
f04a4fb522
commit
9abf65709d
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user