diff --git a/VelocityCore/src/de/steamwar/messages/BungeeCore.properties b/VelocityCore/src/de/steamwar/messages/BungeeCore.properties index c9db69bb..36fdc284 100644 --- a/VelocityCore/src/de/steamwar/messages/BungeeCore.properties +++ b/VelocityCore/src/de/steamwar/messages/BungeeCore.properties @@ -612,8 +612,7 @@ CHAT_CHANNEL_SERVERTEAM = §eSTC CHAT_CHANNEL_MSG = §eMSG §7{0} CHAT_CHANNEL_ALERT = §cAlert CHAT_CHANNEL_LOCAL = §eLocal -CHAT_CHANNEL_CURRENT = §7You are writing into §e{0}§7. -CHAT_CHANNEL_SWITCHED = §7You are now writing into §e{0}§7. +CHAT_CHANNEL_DEFAULT = §ais your default channel CHAT_CHANNEL_NOT_SWITCHABLE = §cYou cannot write into this channel by default. CHAT_NO_WRITE = §cYou cannot write into this channel. CHAT_FIGHT_NO_TEAM = §cYou are not in a fight team. diff --git a/VelocityCore/src/de/steamwar/messages/BungeeCore_de.properties b/VelocityCore/src/de/steamwar/messages/BungeeCore_de.properties index 09199878..0c54dccc 100644 --- a/VelocityCore/src/de/steamwar/messages/BungeeCore_de.properties +++ b/VelocityCore/src/de/steamwar/messages/BungeeCore_de.properties @@ -577,8 +577,7 @@ CHAT_CHANNEL_SERVERTEAM = §eSTC CHAT_CHANNEL_MSG = §eMSG §7{0} CHAT_CHANNEL_ALERT = §cAlert CHAT_CHANNEL_LOCAL = §eLokal -CHAT_CHANNEL_CURRENT = §7Du schreibst in §e{0}§7. -CHAT_CHANNEL_SWITCHED = §7Du schreibst jetzt in §e{0}§7. +CHAT_CHANNEL_DEFAULT = §aist dein Standardkanal CHAT_CHANNEL_NOT_SWITCHABLE = §cIn diesen Kanal kannst du nicht standardmäßig schreiben. CHAT_NO_WRITE = §cDu kannst nicht in diesen Kanal schreiben. CHAT_FIGHT_NO_TEAM = §cDu bist in keinem Kampfteam. diff --git a/VelocityCore/src/de/steamwar/velocitycore/chat/ChatManager.java b/VelocityCore/src/de/steamwar/velocitycore/chat/ChatManager.java index c8565b8e..95359244 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/chat/ChatManager.java +++ b/VelocityCore/src/de/steamwar/velocitycore/chat/ChatManager.java @@ -28,6 +28,7 @@ import com.velocitypowered.api.proxy.ServerConnection; import com.velocitypowered.api.proxy.server.RegisteredServer; import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; +import de.steamwar.messages.Message; import de.steamwar.messages.PlayerChatter; import de.steamwar.network.packets.common.FightInfoPacket; import de.steamwar.persistent.Subserver; @@ -41,6 +42,8 @@ import de.steamwar.velocitycore.EventStarter; import de.steamwar.velocitycore.VelocityCore; import de.steamwar.velocitycore.listeners.BasicListener; import lombok.Getter; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.event.HoverEvent; import java.util.*; import java.util.concurrent.ConcurrentHashMap; @@ -313,7 +316,7 @@ public class ChatManager extends BasicListener { } defaults.put(uuid, channel); - player.system("CHAT_CHANNEL_SWITCHED", channel.tag(player)); + notifyDefault(player, channel); } private static void setDefault(PlayerChatter player, ChatChannel channel) { @@ -322,12 +325,25 @@ public class ChatManager extends BasicListener { ChatChannel previous = defaults.put(uuid, channel); if (announced.add(uuid)) { - player.system("CHAT_CHANNEL_CURRENT", channel.tag(player)); + notifyDefault(player, channel); } else if (previous != channel && !player.parseToPlain(previous.tag(player)).equals(player.parseToPlain(channel.tag(player)))) { - player.system("CHAT_CHANNEL_SWITCHED", channel.tag(player)); + notifyDefault(player, channel); } } + /** + * Tells the player which channel they write into, showing the channel icon with its name on hover. + */ + public static void notifyDefault(PlayerChatter player, ChatChannel channel) { + Message icon = channel.icon(player); + Component iconComponent = icon == null ? player.parse(channel.tag(player)) : player.parse(new Message("CHAT_ICON", "§a", icon)); + player.sendMessage(Component.text() + .append(iconComponent.hoverEvent(HoverEvent.showText(player.parse(channel.tag(player))))) + .append(Component.text(" ")) + .append(player.parse(new Message("CHAT_CHANNEL_DEFAULT"))) + .build()); + } + /** * Handles a chat message the player typed without a command. */ diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/ChatCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/ChatCommand.java index cd563a81..b7a5bb05 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/ChatCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/ChatCommand.java @@ -47,7 +47,7 @@ public class ChatCommand extends SWCommand { @Register(description = "CHAT_USAGE") public void current(PlayerChatter sender) { - sender.system("CHAT_CHANNEL_CURRENT", ChatManager.getDefault(sender).tag(sender)); + ChatManager.notifyDefault(sender, ChatManager.getDefault(sender)); } @Register