From c750231b144a1bc7bef675766105cae7b1251e41 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sat, 26 Jun 2021 11:13:01 +0200 Subject: [PATCH 1/3] Add + to Local Chat --- .../bungeecore/listeners/ChatListener.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/ChatListener.java b/src/de/steamwar/bungeecore/listeners/ChatListener.java index b41ea78f..9fd80619 100644 --- a/src/de/steamwar/bungeecore/listeners/ChatListener.java +++ b/src/de/steamwar/bungeecore/listeners/ChatListener.java @@ -19,10 +19,7 @@ package de.steamwar.bungeecore.listeners; -import de.steamwar.bungeecore.BungeeCore; -import de.steamwar.bungeecore.Message; -import de.steamwar.bungeecore.Servertype; -import de.steamwar.bungeecore.Subserver; +import de.steamwar.bungeecore.*; import de.steamwar.bungeecore.commands.BauCommand; import de.steamwar.bungeecore.commands.TpCommand; import de.steamwar.bungeecore.comms.packets.PingPacket; @@ -51,6 +48,8 @@ public class ChatListener extends BasicListener { sanitize7(e); if(e.getMessage().startsWith("/")) onCommand(e); + else if(e.getMessage().startsWith("+")) + onPlusMessage(e); else onChat(e); } @@ -116,6 +115,21 @@ public class ChatListener extends BasicListener { scheduler.schedule(BungeeCore.get(), () -> Message.sendPrefixless("MSG_FORMAT", sender, "YoyoNow", sender.getDisplayName(), Message.parse("CHAT_YOYONOW_4", sender)), 12, TimeUnit.SECONDS); } + private void onPlusMessage(ChatEvent e) { + ProxiedPlayer p = (ProxiedPlayer) e.getSender(); + Subserver subserver = Subserver.getSubserver(p); + if(/*subserver instanceof Bauserver*/true) { + String[] smolArgs = e.getMessage().split(" "); + String[] args = new String[smolArgs.length + 1]; + smolArgs[0] = smolArgs[0].substring(1); + args[0] = ""; + System.arraycopy(smolArgs, 0, args, 1, smolArgs.length); + localChat(e, args); + } else { + onChat(e); + } + } + private void onChat(ChatEvent e){ if(e.getSender() instanceof ProxiedPlayer){ ProxiedPlayer sender = (ProxiedPlayer) e.getSender(); From 955cb8863a0e57259e490186da07c3fa0aed2993 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sat, 26 Jun 2021 11:14:13 +0200 Subject: [PATCH 2/3] Remove Debug --- src/de/steamwar/bungeecore/listeners/ChatListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/listeners/ChatListener.java b/src/de/steamwar/bungeecore/listeners/ChatListener.java index 9fd80619..aeffc193 100644 --- a/src/de/steamwar/bungeecore/listeners/ChatListener.java +++ b/src/de/steamwar/bungeecore/listeners/ChatListener.java @@ -118,7 +118,7 @@ public class ChatListener extends BasicListener { private void onPlusMessage(ChatEvent e) { ProxiedPlayer p = (ProxiedPlayer) e.getSender(); Subserver subserver = Subserver.getSubserver(p); - if(/*subserver instanceof Bauserver*/true) { + if(subserver instanceof Bauserver) { String[] smolArgs = e.getMessage().split(" "); String[] args = new String[smolArgs.length + 1]; smolArgs[0] = smolArgs[0].substring(1); From 906be50771cd2ef488433d9a17ef596b4b048d3f Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 27 Jun 2021 08:10:15 +0200 Subject: [PATCH 3/3] Compress ChatListener.onPlusMessage --- src/de/steamwar/bungeecore/listeners/ChatListener.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/ChatListener.java b/src/de/steamwar/bungeecore/listeners/ChatListener.java index aeffc193..12903c07 100644 --- a/src/de/steamwar/bungeecore/listeners/ChatListener.java +++ b/src/de/steamwar/bungeecore/listeners/ChatListener.java @@ -119,9 +119,8 @@ public class ChatListener extends BasicListener { ProxiedPlayer p = (ProxiedPlayer) e.getSender(); Subserver subserver = Subserver.getSubserver(p); if(subserver instanceof Bauserver) { - String[] smolArgs = e.getMessage().split(" "); + String[] smolArgs = e.getMessage().substring(1).split(" "); String[] args = new String[smolArgs.length + 1]; - smolArgs[0] = smolArgs[0].substring(1); args[0] = ""; System.arraycopy(smolArgs, 0, args, 1, smolArgs.length); localChat(e, args);