From e07b7362d5c43945cd2918077c2a2a8b7ab0722f Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sat, 29 Aug 2020 18:23:31 +0200 Subject: [PATCH 1/4] @Player Autocomplete --- src/de/steamwar/bungeecore/listeners/ChatListener.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/ChatListener.java b/src/de/steamwar/bungeecore/listeners/ChatListener.java index cb255d67..a387104b 100644 --- a/src/de/steamwar/bungeecore/listeners/ChatListener.java +++ b/src/de/steamwar/bungeecore/listeners/ChatListener.java @@ -163,7 +163,7 @@ public class ChatListener extends BasicListener { for(ProxiedPlayer target : ProxyServer.getInstance().getPlayers()){ Subserver targetServer = Subserver.getSubserver(target); if(targetServer == null || targetServer.getType() != Servertype.ARENA || targetServer.getServer() != target.getServer().getInfo()){ - if(msg.contains("@" + target.getName())) { + if(msg.toLowerCase().contains("@" + target.getName().toLowerCase())) { BungeeCore.send(target, ChatMessageType.CHAT, msg.replace("@" + target.getName(), "§e@" + target.getName() + chatcolor)); }else { BungeeCore.send(target, ChatMessageType.CHAT, msg); @@ -208,7 +208,7 @@ public class ChatListener extends BasicListener { else last = ""; for(ProxiedPlayer player : ProxyServer.getInstance().getPlayers()){ - String name = player.getName(); + String name = player.getName().replace("@", ""); if(last.isEmpty() || name.startsWith(last)){ suggestions.add(name); } @@ -221,6 +221,7 @@ public class ChatListener extends BasicListener { } } } + } @EventHandler From 6534a56b1703d620a2139cf019be826a7df2299b Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sat, 29 Aug 2020 21:21:21 +0200 Subject: [PATCH 2/4] @Player IgnoreCase --- .../bungeecore/listeners/ChatListener.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/ChatListener.java b/src/de/steamwar/bungeecore/listeners/ChatListener.java index a387104b..664bffb2 100644 --- a/src/de/steamwar/bungeecore/listeners/ChatListener.java +++ b/src/de/steamwar/bungeecore/listeners/ChatListener.java @@ -155,7 +155,7 @@ public class ChatListener extends BasicListener { message = ChatColor.translateAlternateColorCodes('&', message); } - String msg = name + "§7» " + chatcolor + message; + String msg = name + "§7»" + chatcolor + " " + message; if(user.getTeam() != 0){ msg = "§8" + Team.get(user.getTeam()).getTeamKuerzel() + " §r" + msg; } @@ -164,7 +164,15 @@ public class ChatListener extends BasicListener { Subserver targetServer = Subserver.getSubserver(target); if(targetServer == null || targetServer.getType() != Servertype.ARENA || targetServer.getServer() != target.getServer().getInfo()){ if(msg.toLowerCase().contains("@" + target.getName().toLowerCase())) { - BungeeCore.send(target, ChatMessageType.CHAT, msg.replace("@" + target.getName(), "§e@" + target.getName() + chatcolor)); + String toSend = ""; + for (String curr : msg.split(" ")) { + if(curr.equalsIgnoreCase("@" + target.getName())) { + toSend += "§e@" + target.getName() + chatcolor + " "; + }else { + toSend += curr + " "; + } + } + BungeeCore.send(target, ChatMessageType.CHAT, toSend); }else { BungeeCore.send(target, ChatMessageType.CHAT, msg); } @@ -208,8 +216,8 @@ public class ChatListener extends BasicListener { else last = ""; for(ProxiedPlayer player : ProxyServer.getInstance().getPlayers()){ - String name = player.getName().replace("@", ""); - if(last.isEmpty() || name.startsWith(last)){ + String name = player.getName(); + if (last.isEmpty() || name.startsWith(last)) { suggestions.add(name); } } From 092417ac910e32d001955e90ed1ac8bce95f3909 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 30 Aug 2020 12:26:08 +0200 Subject: [PATCH 3/4] @Player IgnoreCase --- .../bungeecore/listeners/ChatListener.java | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/ChatListener.java b/src/de/steamwar/bungeecore/listeners/ChatListener.java index 536688d1..6b8b4a25 100644 --- a/src/de/steamwar/bungeecore/listeners/ChatListener.java +++ b/src/de/steamwar/bungeecore/listeners/ChatListener.java @@ -160,23 +160,21 @@ public class ChatListener extends BasicListener { msg = "§8" + Team.get(user.getTeam()).getTeamKuerzel() + " §r" + msg; } + String[] msgSplits = msg.split(" "); + StringBuilder builder = new StringBuilder(); + for(ProxiedPlayer target : ProxyServer.getInstance().getPlayers()){ Subserver targetServer = Subserver.getSubserver(target); - if(targetServer == null || targetServer.getType() != Servertype.ARENA || targetServer.getServer() != target.getServer().getInfo()){ - if(msg.toLowerCase().contains("@" + target.getName().toLowerCase())) { - String toSend = ""; - for (String curr : msg.split(" ")) { - if(curr.equalsIgnoreCase("@" + target.getName())) { - toSend += "§e@" + target.getName() + chatcolor + " "; - }else { - toSend += curr + " "; - } - } - BungeeCore.send(target, ChatMessageType.CHAT, toSend); + if(!(targetServer == null || targetServer.getType() != Servertype.ARENA || targetServer.getServer() != target.getServer().getInfo())) continue; + for (String curr : msgSplits) { + if(curr.equalsIgnoreCase("@" + target.getName())) { + builder.append("§e@").append(target.getName()).append(chatcolor).append(" "); }else { - BungeeCore.send(target, ChatMessageType.CHAT, msg); + builder.append(curr).append(" "); } } + BungeeCore.send(target, ChatMessageType.CHAT, builder.toString()); + builder = new StringBuilder(); } BungeeCore.log(sender.getServer().getInfo(), msg); } From 45048a272a3a62a336c8a06e955848c3de86eb12 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 30 Aug 2020 12:31:54 +0200 Subject: [PATCH 4/4] Clean up --- src/de/steamwar/bungeecore/listeners/ChatListener.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/listeners/ChatListener.java b/src/de/steamwar/bungeecore/listeners/ChatListener.java index 6b8b4a25..723f095a 100644 --- a/src/de/steamwar/bungeecore/listeners/ChatListener.java +++ b/src/de/steamwar/bungeecore/listeners/ChatListener.java @@ -227,7 +227,6 @@ public class ChatListener extends BasicListener { } } } - } @EventHandler