Skip to content
This repository has been archived by the owner on Oct 12, 2024. It is now read-only.

Commit

Permalink
Changed ChatListener PostOrder to LATE (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
4drian3d authored Oct 17, 2023
1 parent 1380c7b commit 5d41615
Showing 2 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -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();

Original file line number Diff line number Diff line change
@@ -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,19 +60,17 @@ public int getPing() {
@Override
@NotNull
public String getServerName() {
AtomicReference<ServerConnection> connection = new AtomicReference<>();
player.getCurrentServer().ifPresent(connection::set);
if (connection.get() != null) {
final Optional<ServerConnection> connection = player.getCurrentServer();
if (connection.isPresent()) {
return connection.get().getServerInfo().getName();
}
return "";
}

@Override
public int getPlayersOnServer() {
AtomicReference<ServerConnection> connection = new AtomicReference<>();
player.getCurrentServer().ifPresent(connection::set);
if (connection.get() != null) {
final Optional<ServerConnection> connection = player.getCurrentServer();
if (connection.isPresent()) {
return connection.get().getServer().getPlayersConnected().size();
}
return 0;

0 comments on commit 5d41615

Please sign in to comment.