Skip to content

Commit

Permalink
Added a message sent to all players on an island when PvP is toggled
Browse files Browse the repository at this point in the history
Implements #1081

Also removed the "protection.flags.PVP_OVERWORLD.active" message as it seemingly wasn't used.
  • Loading branch information
Poslovitch committed Feb 13, 2020
1 parent f04a4fb commit 9abf657
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@
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
Expand Down Expand Up @@ -211,4 +213,17 @@ public void onPlayerShootFireworkEvent(final EntityShootBowEvent e) {
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));
}
}
}
7 changes: 6 additions & 1 deletion src/main/resources/locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 9abf657

Please sign in to comment.