diff --git a/velocity/src/main/java/net/william278/huskchat/velocity/listener/VelocityListener.java b/velocity/src/main/java/net/william278/huskchat/velocity/listener/VelocityListener.java index 90dadb52..372291d9 100644 --- a/velocity/src/main/java/net/william278/huskchat/velocity/listener/VelocityListener.java +++ b/velocity/src/main/java/net/william278/huskchat/velocity/listener/VelocityListener.java @@ -38,14 +38,14 @@ public VelocityListener(@NotNull HuskChat plugin) { super(plugin); } - @Subscribe(order = PostOrder.LAST) + @Subscribe(order = PostOrder.LATE) public void onPlayerChat(PlayerChatEvent e) { - if (e.getMessage().startsWith("/") || !e.getResult().isAllowed()) { + if (!e.getResult().isAllowed()) { return; } final Player player = VelocityPlayer.adapt(e.getPlayer()); - boolean shouldCancel = new ChatMessage(plugin.getPlayerCache().getPlayerChannel(player.getUuid()), + final boolean shouldCancel = new ChatMessage(plugin.getPlayerCache().getPlayerChannel(player.getUuid()), player, e.getMessage(), plugin) .dispatch(); diff --git a/velocity/src/main/java/net/william278/huskchat/velocity/player/VelocityPlayer.java b/velocity/src/main/java/net/william278/huskchat/velocity/player/VelocityPlayer.java index 84b80c10..b7e29a95 100644 --- a/velocity/src/main/java/net/william278/huskchat/velocity/player/VelocityPlayer.java +++ b/velocity/src/main/java/net/william278/huskchat/velocity/player/VelocityPlayer.java @@ -27,7 +27,6 @@ import java.util.Optional; import java.util.UUID; -import java.util.concurrent.atomic.AtomicReference; /** * Velocity implementation of a cross-platform {@link Player} @@ -61,9 +60,8 @@ public int getPing() { @Override @NotNull public String getServerName() { - AtomicReference connection = new AtomicReference<>(); - player.getCurrentServer().ifPresent(connection::set); - if (connection.get() != null) { + final Optional connection = player.getCurrentServer(); + if (connection.isPresent()) { return connection.get().getServerInfo().getName(); } return ""; @@ -71,9 +69,8 @@ public String getServerName() { @Override public int getPlayersOnServer() { - AtomicReference connection = new AtomicReference<>(); - player.getCurrentServer().ifPresent(connection::set); - if (connection.get() != null) { + final Optional connection = player.getCurrentServer(); + if (connection.isPresent()) { return connection.get().getServer().getPlayersConnected().size(); } return 0;