#Paper staff chat plugin issue
1 messages · Page 1 of 1 (latest)
your screenshot doesn't work
ill fix lemme just
public class AsyncChatListener implements Listener {
private Staffchat plugin;
public AsyncChatListener(Staffchat plugin) {
this.plugin = plugin;
}
@EventHandler
public void onAsyncPlayerChat(AsyncPlayerChatEvent event) {
Player player = event.getPlayer();
String message = event.getMessage();
String FULL_MESSAGE = ChatColor.translateAlternateColorCodes('&', this.plugin.getConfig().getString("settings.PREFIX").replace("{msg}", message).replace("{player}", player.getName()));
String PERMISSION = ChatColor.translateAlternateColorCodes('&', this.plugin.getConfig().getString("settings.PERMISSION"));
if (this.plugin.scUsers.contains(player.getUniqueId())) {
event.setCancelled(true);
for (Player online : Bukkit.getOnlinePlayers()) {
if (online.hasPermission(PERMISSION))
online.sendMessage(FULL_MESSAGE);
}
} else if (!this.plugin.scUsers.contains(player.getUniqueId())) {
event.setCancelled(false);
}
}
}```
image (imgbb cause no perms for images lol)
# - {msg} -> Player Message
# - {player} -> Player Name
settings:
ENABLED: '&9You have &a&lenabled &9staff chat.'
DISABLED: '&9You have &c&ldisabled &9staff chat.'
PERMISSION: ' {player} {msg} '
BE_A_PLAYER: please stop using the f*cking staff chat on console ok thx
MISSING_PERMISSIONS: no perm lol
PREFIX: '&8[&3Staff&8] '
ignore the stupid messages lol
edit: it might be the deprecated AsyncPlayerChatEvent, i'll try using AsyncChatEvent instead
AsyncPlayerChatEvent is not deprecated
erm what exactly is the problem? I don't quite get it
ah I see, [Staff] shows no message
it is 😳
yeah exactly
it's not
declaration: package: org.bukkit.event.player, class: AsyncPlayerChatEvent
maybe it is in paper, but this is spigot's discord
paper marks almost everything as deprecated
well your whole code is messed up
why do you cancel the event?
yeaaaaah i forgot sry
you should much rather just change the event's format instead of cancelling the event
e.g. event.setFormat("[STAFF] %s");
ill try doing that
instead of cancelling it and resending the message
you basically ONLY want to cancel the event if you want noone to see the message
to change the format etc, use setFormat
IIRC the first %s is the player name and the second %s is the message
so you can do something like this as general idea:
public void onChat(AsyncPlayerChatEvent event) {
Player player = event.getPlayer();
String prefix = ...; // get your prefix, e.g. "Staff", or "Member"
event.setFormat("[" + prefix + "] %s > %s");
this will result in a chat like this:
[Member] mfnalex > Yo wassup
[Staff] Iki > Nothing