From 492dcff64d4633bf1f4390256e898c10653ea6b4 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 25 Jul 2020 11:23:49 +0200 Subject: [PATCH] Fix double announcements + chat messages refinement Signed-off-by: Lixfel --- .../bungeecore/commands/MsgCommand.java | 2 +- .../bungeecore/commands/RCommand.java | 2 +- .../bungeecore/listeners/ChatListener.java | 1 + .../listeners/ConnectionListener.java | 20 +++++++++++++------ .../steamwar/bungeecore/sql/SteamwarUser.java | 3 ++- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/MsgCommand.java b/src/de/steamwar/bungeecore/commands/MsgCommand.java index 33dd194..b5f3bc6 100644 --- a/src/de/steamwar/bungeecore/commands/MsgCommand.java +++ b/src/de/steamwar/bungeecore/commands/MsgCommand.java @@ -46,7 +46,7 @@ public class MsgCommand extends BasicCommand { } StringBuilder msgBuilder = new StringBuilder(); - msgBuilder.append("§8").append(player.getName()).append("»").append(target.getName()).append(" §r§7"); + msgBuilder.append("§e").append(player.getName()).append("§8»§e").append(target.getName()).append(" §r§7"); for (int i = 1; i < args.length; i++){ msgBuilder.append(args[i]).append(" "); } diff --git a/src/de/steamwar/bungeecore/commands/RCommand.java b/src/de/steamwar/bungeecore/commands/RCommand.java index 2ff68d2..5e6a2b0 100644 --- a/src/de/steamwar/bungeecore/commands/RCommand.java +++ b/src/de/steamwar/bungeecore/commands/RCommand.java @@ -41,7 +41,7 @@ public class RCommand extends BasicCommand { } StringBuilder msgBuilder = new StringBuilder(); - msgBuilder.append("§8").append(player.getName()).append("»").append(target.getName()).append(" §r§7"); + msgBuilder.append("§e").append(player.getName()).append("§8»§e").append(target.getName()).append(" §r§7"); for (String arg : args){ msgBuilder.append(arg).append(" "); } diff --git a/src/de/steamwar/bungeecore/listeners/ChatListener.java b/src/de/steamwar/bungeecore/listeners/ChatListener.java index bfcf1f0..6780e94 100644 --- a/src/de/steamwar/bungeecore/listeners/ChatListener.java +++ b/src/de/steamwar/bungeecore/listeners/ChatListener.java @@ -126,6 +126,7 @@ public class ChatListener extends BasicListener { String name = sender.getDisplayName(); String chatsuffix = "§7» "; + message = message.replace('§', '&'); if(sender.hasPermission("bungeecore.group.admin")){ chatsuffix = "§7» §e"; message = ChatColor.translateAlternateColorCodes('&', message); diff --git a/src/de/steamwar/bungeecore/listeners/ConnectionListener.java b/src/de/steamwar/bungeecore/listeners/ConnectionListener.java index 3d6e1df..c36e972 100644 --- a/src/de/steamwar/bungeecore/listeners/ConnectionListener.java +++ b/src/de/steamwar/bungeecore/listeners/ConnectionListener.java @@ -19,8 +19,7 @@ import net.md_5.bungee.api.event.ServerDisconnectEvent; import net.md_5.bungee.api.event.ServerKickEvent; import net.md_5.bungee.event.EventHandler; -import java.util.Collection; -import java.util.Iterator; +import java.util.*; public class ConnectionListener extends BasicListener { @@ -29,6 +28,12 @@ public class ConnectionListener extends BasicListener { public static final String CHECK_PERMISSION = "bungeecore.check"; private static final String YOUTUBER_MODS = "bungeecore.youtubermods"; + private static final Set newPlayers = new HashSet<>(); + + public static void newPlayer(UUID player){ + newPlayers.add(player); + } + @EventHandler public void onPostLogin(PostLoginEvent event) { ProxiedPlayer player = event.getPlayer(); @@ -38,28 +43,28 @@ public class ConnectionListener extends BasicListener { case "Admin": player.addGroups(ADMIN_GROUP, TEAM_GROUP); player.setPermission("bungeecore.group.admin", true); - player.setPermission("bungeecore.check", true); + player.setPermission(CHECK_PERMISSION, true); player.setPermission(YOUTUBER_MODS, true); player.setDisplayName("§4Admin " + player.getName() + "§r"); break; case "Developer": player.addGroups(ADMIN_GROUP, TEAM_GROUP); player.setPermission("bungeecore.group.developer", true); - player.setPermission("bungeecore.check", true); + player.setPermission(CHECK_PERMISSION, true); player.setPermission(YOUTUBER_MODS, true); player.setDisplayName("§3Developer " + player.getName() + "§r"); break; case "Moderator": player.addGroups(ADMIN_GROUP, TEAM_GROUP); player.setPermission("bungeecore.group.moderator", true); - player.setPermission("bungeecore.check", true); + player.setPermission(CHECK_PERMISSION, true); player.setPermission(YOUTUBER_MODS, true); player.setDisplayName("§bModerator " + player.getName() + "§r"); break; case "Supporter": player.addGroups(TEAM_GROUP); player.setPermission("bungeecore.group.supporter", true); - player.setPermission("bungeecore.check", true); + player.setPermission(CHECK_PERMISSION, true); player.setPermission(YOUTUBER_MODS, true); player.setDisplayName("§1Supporter " + player.getName() + "§r"); break; @@ -91,6 +96,9 @@ public class ConnectionListener extends BasicListener { } } } + + if(newPlayers.contains(player.getUniqueId())) + BungeeCore.broadcast(BungeeCore.CHAT_PREFIX + "§7Begrüßt alle mal §e" + player.getName() + " §7auf dem Server§8!"); } /** To redirect players to the lobby in case of server closure. */ diff --git a/src/de/steamwar/bungeecore/sql/SteamwarUser.java b/src/de/steamwar/bungeecore/sql/SteamwarUser.java index e37255a..74cad26 100644 --- a/src/de/steamwar/bungeecore/sql/SteamwarUser.java +++ b/src/de/steamwar/bungeecore/sql/SteamwarUser.java @@ -2,6 +2,7 @@ package de.steamwar.bungeecore.sql; import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.commands.WebregisterCommand; +import de.steamwar.bungeecore.listeners.ConnectionListener; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.connection.PendingConnection; @@ -62,7 +63,7 @@ public class SteamwarUser { user = dbInit(SQL.select("SELECT * FROM UserData WHERE UUID = ?", connection.getUniqueId().toString())); if(user == null) throw new SecurityException("user == null"); - BungeeCore.broadcast(BungeeCore.CHAT_PREFIX + "§7Begrüßt alle mal §e" + connection.getName() + " §7auf dem Server§8!"); + ConnectionListener.newPlayer(user.uuid); } return user;