Merge pull request #2142 from dordsor21/master

Cancel plot chat if message event is cancelled to allow for swear block/etc
This commit is contained in:
NotMyFault 2018-10-25 12:11:46 +02:00 committed by GitHub
commit 40e7df8d69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 2 deletions

View File

@ -757,8 +757,11 @@ public class PlayerEvents extends PlotListener implements Listener {
} }
} }
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOW)
public void onChat(AsyncPlayerChatEvent event) { public void onChat(AsyncPlayerChatEvent event) {
if (event.isCancelled())
return;
PlotPlayer plotPlayer = BukkitUtil.getPlayer(event.getPlayer()); PlotPlayer plotPlayer = BukkitUtil.getPlayer(event.getPlayer());
Location location = plotPlayer.getLocation(); Location location = plotPlayer.getLocation();
PlotArea area = location.getPlotArea(); PlotArea area = location.getPlotArea();

View File

@ -553,8 +553,11 @@ public class PlayerEvents extends PlotListener implements Listener {
} }
} }
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOW)
public void onChat(PlayerChatEvent event) { public void onChat(PlayerChatEvent event) {
if (event.isCancelled())
return;
PlotPlayer plotPlayer = NukkitUtil.getPlayer(event.getPlayer()); PlotPlayer plotPlayer = NukkitUtil.getPlayer(event.getPlayer());
Location location = plotPlayer.getLocation(); Location location = plotPlayer.getLocation();
PlotArea area = location.getPlotArea(); PlotArea area = location.getPlotArea();

View File

@ -86,6 +86,9 @@ public class MainListener {
@Listener @Listener
public void onChat(MessageEvent event) { public void onChat(MessageEvent event) {
// TODO // TODO
if (event.isMessageCancelled())
return;
Player player = SpongeUtil.getCause(event.getCause(), Player.class); Player player = SpongeUtil.getCause(event.getCause(), Player.class);
if (player == null) { if (player == null) {
return; return;