mirror of
https://github.com/kaboomserver/extras.git
synced 2025-08-05 12:03:08 +00:00
Allow players to select the vanilla chat format
This commit is contained in:
parent
923a64c906
commit
90ef97a6c0
2 changed files with 16 additions and 1 deletions
|
@ -41,6 +41,10 @@ public final class PlayerChat implements Listener {
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
void onAsyncChatEventRenderer(final AsyncChatEvent event) {
|
void onAsyncChatEventRenderer(final AsyncChatEvent event) {
|
||||||
|
if (PlayerPrefix.isUsingVanillaFormat(event.getPlayer())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
event.renderer(CHAT_RENDERER);
|
event.renderer(CHAT_RENDERER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,14 @@ public final class PlayerPrefix implements Listener {
|
||||||
return prefix;
|
return prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isUsingVanillaFormat(Player player) {
|
||||||
|
final UUID playerUUID = player.getUniqueId();
|
||||||
|
final String stringifiedUUID = playerUUID.toString();
|
||||||
|
final String legacyPrefix = PREFIX_CONFIG.getString(stringifiedUUID);
|
||||||
|
|
||||||
|
return legacyPrefix != null && legacyPrefix.equals("%");
|
||||||
|
}
|
||||||
|
|
||||||
public static Component getPrefix(Player player) throws IOException {
|
public static Component getPrefix(Player player) throws IOException {
|
||||||
final UUID playerUUID = player.getUniqueId();
|
final UUID playerUUID = player.getUniqueId();
|
||||||
final String stringifiedUUID = playerUUID.toString();
|
final String stringifiedUUID = playerUUID.toString();
|
||||||
|
@ -94,7 +102,10 @@ public final class PlayerPrefix implements Listener {
|
||||||
|
|
||||||
private static void onUpdate(Player player) throws IOException {
|
private static void onUpdate(Player player) throws IOException {
|
||||||
final Component component = Component.empty()
|
final Component component = Component.empty()
|
||||||
.append(getPrefix(player))
|
.append(
|
||||||
|
isUsingVanillaFormat(player) ?
|
||||||
|
Component.empty() : getPrefix(player)
|
||||||
|
)
|
||||||
.append(player.displayName());
|
.append(player.displayName());
|
||||||
|
|
||||||
player.playerListName(component);
|
player.playerListName(component);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue