Archiviert
1
0

Replace 7 at beginning of chat massages to /

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2020-05-23 11:06:23 +02:00
Ursprung 42234d579c
Commit 01dcd0152e

Datei anzeigen

@ -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(":")){