From 01dcd0152e2eb05590bb39e43092f349fdc371f0 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 23 May 2020 11:06:23 +0200 Subject: [PATCH] Replace 7 at beginning of chat massages to / Signed-off-by: Lixfel --- .../steamwar/bungeecore/listeners/ChatListener.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/de/steamwar/bungeecore/listeners/ChatListener.java b/src/de/steamwar/bungeecore/listeners/ChatListener.java index 48e990b3..c762a984 100644 --- a/src/de/steamwar/bungeecore/listeners/ChatListener.java +++ b/src/de/steamwar/bungeecore/listeners/ChatListener.java @@ -28,12 +28,25 @@ public class ChatListener extends BasicListener { @EventHandler public void onChatEvent(ChatEvent e){ + sanitize7(e); if(e.getMessage().startsWith("/")) onCommand(e); else onChat(e); } + /* + * Replaces 7(7)command to /(/)command. + * */ + private void sanitize7(ChatEvent e){ + String begin = e.getMessage().split(" ", 2)[0]; + if(begin.startsWith("7") && begin.substring(1).matches("[A-Za-z]+")){ + e.setMessage("/" + e.getMessage().substring(1)); + }else if(begin.startsWith("77") && begin.substring(2).matches("[A-Za-z]+")){ + e.setMessage("//" + e.getMessage().substring(2)); + } + } + private void onCommand(ChatEvent e){ String [] command = e.getMessage().split(" "); if(command[0].contains(":")){