diff --git a/src/main/java/net/flectone/chat/model/player/FPlayer.java b/src/main/java/net/flectone/chat/model/player/FPlayer.java index 0d83516..60f2eaf 100644 --- a/src/main/java/net/flectone/chat/model/player/FPlayer.java +++ b/src/main/java/net/flectone/chat/model/player/FPlayer.java @@ -104,13 +104,12 @@ public void init() { fromDatabase(); - database.execute(this::reloadStreamPrefix); - - registerWorldPrefix(); registerTeam(); + + database.execute(() -> setStreamPrefix()); } - public void reloadStreamPrefix() { + public void setStreamPrefix() { if (!getPlayer().hasPermission("flectonechat.commands.stream")) return; if (getSettings() == null) return; @@ -119,6 +118,7 @@ public void reloadStreamPrefix() { String prefix = locale.getVaultString(getPlayer(), "commands.stream." + typePrefix + "-prefix"); setStreamPrefix(MessageUtil.formatAll(getPlayer(), prefix)); + updateTeam(); } public void terminate() { @@ -148,6 +148,13 @@ public void registerTeam() { } } + public void updateTeam() { + FModule fModule = moduleManager.get(NameTagModule.class); + if (fModule instanceof NameTagModule nameTagModule) { + nameTagModule.updateTeam(player, team); + } + } + public void unregisterTeam() { if (team == null) return; try { diff --git a/src/main/java/net/flectone/chat/module/commands/CommandAfk.java b/src/main/java/net/flectone/chat/module/commands/CommandAfk.java index cbcd6de..839ba0f 100644 --- a/src/main/java/net/flectone/chat/module/commands/CommandAfk.java +++ b/src/main/java/net/flectone/chat/module/commands/CommandAfk.java @@ -62,6 +62,7 @@ public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command player.sendMessage(MessageUtil.formatAll(player, MessageUtil.formatPlayerString(player, afkMessage))); fPlayer.playSound(player, player, this.toString()); + fPlayer.updateTeam(); return true; } diff --git a/src/main/java/net/flectone/chat/module/commands/CommandStream.java b/src/main/java/net/flectone/chat/module/commands/CommandStream.java index 1540a59..2a34941 100644 --- a/src/main/java/net/flectone/chat/module/commands/CommandStream.java +++ b/src/main/java/net/flectone/chat/module/commands/CommandStream.java @@ -110,7 +110,7 @@ public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command private void setStreaming(@NotNull FPlayer fPlayer, @NotNull String value) { fPlayer.getSettings().set(Settings.Type.STREAM, value); - fPlayer.reloadStreamPrefix(); + fPlayer.setStreamPrefix(); database.execute(() -> database.updateFPlayer("stream", fPlayer)); } diff --git a/src/main/java/net/flectone/chat/module/player/afkTimeout/AfkTimeoutModule.java b/src/main/java/net/flectone/chat/module/player/afkTimeout/AfkTimeoutModule.java index 627487a..bcbbe32 100644 --- a/src/main/java/net/flectone/chat/module/player/afkTimeout/AfkTimeoutModule.java +++ b/src/main/java/net/flectone/chat/module/player/afkTimeout/AfkTimeoutModule.java @@ -53,6 +53,7 @@ public void setAfk(@NotNull Player player, boolean isAfk, @NotNull String takeOu fPlayer.setAfkSuffix(MessageUtil.formatAll(player, afkSuffix)); fPlayer.playSound(player, player, this.toString()); + fPlayer.updateTeam(); if (!config.getVaultBoolean(player, this + ".message.enable")) return; diff --git a/src/main/java/net/flectone/chat/module/player/nameTag/NameTagModule.java b/src/main/java/net/flectone/chat/module/player/nameTag/NameTagModule.java index 2dc32cc..d912f97 100644 --- a/src/main/java/net/flectone/chat/module/player/nameTag/NameTagModule.java +++ b/src/main/java/net/flectone/chat/module/player/nameTag/NameTagModule.java @@ -50,8 +50,14 @@ public Team getTeam(@NotNull Player player) { team.setColor(ChatColor.WHITE); + updateTeam(player, team); + + return team; + } + + public void updateTeam(@NotNull Player player, @NotNull Team team) { FModule fModule = moduleManager.get(NameModule.class); - if (!(fModule instanceof NameModule nameModule)) return team; + if (!(fModule instanceof NameModule nameModule)) return; if (config.getVaultBoolean(player, this + ".prefix.enable")) { team.setPrefix(nameModule.getPrefix(player)); @@ -60,8 +66,6 @@ public Team getTeam(@NotNull Player player) { if (config.getVaultBoolean(player, this + ".suffix.enable")) { team.setSuffix(nameModule.getSuffix(player)); } - - return team; } @NotNull diff --git a/src/main/java/net/flectone/chat/module/player/world/WorldListener.java b/src/main/java/net/flectone/chat/module/player/world/WorldListener.java index 1aa9834..fd68b92 100644 --- a/src/main/java/net/flectone/chat/module/player/world/WorldListener.java +++ b/src/main/java/net/flectone/chat/module/player/world/WorldListener.java @@ -47,5 +47,6 @@ public void setWorld(@NotNull Player player) { if (fPlayer == null) return; fPlayer.setWorldPrefix(((WorldModule) getModule()).getPrefix(player, world)); + fPlayer.updateTeam(); } }