From 303f50d0ab1bc0b413cbabe8c9d4cdf83ae21dc0 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 2 Aug 2019 16:56:34 +0200 Subject: [PATCH] LocalChat --- src/de/steamwar/bungeecore/PlayerListener.java | 13 +++++++++++++ .../steamwar/bungeecore/commands/AlertCommand.java | 2 +- .../steamwar/bungeecore/commands/HelpCommand.java | 5 +++++ .../steamwar/bungeecore/commands/TeamCommand.java | 1 + 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/PlayerListener.java b/src/de/steamwar/bungeecore/PlayerListener.java index 9105421..60507f2 100644 --- a/src/de/steamwar/bungeecore/PlayerListener.java +++ b/src/de/steamwar/bungeecore/PlayerListener.java @@ -170,6 +170,16 @@ public class PlayerListener implements Listener { ChallengeCommand.challenges.remove(e.getPlayer()); } + private void localChat(ChatEvent e, String [] command){ + System.out.println(((ProxiedPlayer) e.getSender()).getDisplayName() + ": " + e.getMessage()); + if(command.length == 1){ + ((ProxiedPlayer) e.getSender()).sendMessage(BungeeCore.ChatPrefix + "§8/§e" + command[0].substring(1) + " §8[§7Nachricht§8]"); + e.setCancelled(true); + return; + } + e.setMessage(e.getMessage().substring(command[0].length() + 1)); + } + @EventHandler public void onChatEvent(ChatEvent e){ if(e.getMessage().startsWith("/")){ @@ -181,7 +191,10 @@ public class PlayerListener implements Listener { sender.sendMessage(BungeeCore.ChatPrefix + "§cUnbekannter Befehl."); } }else if((command[0].equalsIgnoreCase("/bau") || command[0].equalsIgnoreCase("/b")) && e.getSender() instanceof ProxiedPlayer){ + System.out.println(((ProxiedPlayer) e.getSender()).getDisplayName() + ": " + e.getMessage()); BauCommand.onBau(e, command); + }else if(command[0].equalsIgnoreCase("/bc") || command[0].equalsIgnoreCase("/bauchat") || command[0].equalsIgnoreCase("/local")){ + localChat(e, command); } }else{ if(e.getSender() instanceof ProxiedPlayer){ diff --git a/src/de/steamwar/bungeecore/commands/AlertCommand.java b/src/de/steamwar/bungeecore/commands/AlertCommand.java index 3913a1b..69db6c6 100644 --- a/src/de/steamwar/bungeecore/commands/AlertCommand.java +++ b/src/de/steamwar/bungeecore/commands/AlertCommand.java @@ -8,7 +8,7 @@ import net.md_5.bungee.api.ProxyServer; public class AlertCommand extends Command { public AlertCommand() { - super("bc", "bungeecore.alert", "alert"); + super("alert", "bungeecore.alert", "broadcast", "bbc"); } @Override diff --git a/src/de/steamwar/bungeecore/commands/HelpCommand.java b/src/de/steamwar/bungeecore/commands/HelpCommand.java index 5219657..aefc73d 100644 --- a/src/de/steamwar/bungeecore/commands/HelpCommand.java +++ b/src/de/steamwar/bungeecore/commands/HelpCommand.java @@ -50,6 +50,11 @@ public class HelpCommand extends Command { tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eSpieler beitreten").create())); tc.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/join")); sender.sendMessage(tc); + + tc = new TextComponent(BungeeCore.ChatPrefix + "§7Schreibe mit §8/§elocal §7nur auf dem lokalen Server!"); + tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eLokaler Chat").create())); + tc.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/local")); + sender.sendMessage(tc); }else if(args[0].equalsIgnoreCase("bauserver")){ sendBauHelp((ProxiedPlayer) sender); }else if(args[0].equalsIgnoreCase("bau")){ diff --git a/src/de/steamwar/bungeecore/commands/TeamCommand.java b/src/de/steamwar/bungeecore/commands/TeamCommand.java index 304cd17..63876b2 100644 --- a/src/de/steamwar/bungeecore/commands/TeamCommand.java +++ b/src/de/steamwar/bungeecore/commands/TeamCommand.java @@ -25,6 +25,7 @@ public class TeamCommand extends Command { sender.sendMessage(BungeeCore.ChatPrefix + "§7Mit §e/team §7verwaltest du dein Team"); sender.sendMessage(BungeeCore.ChatPrefix + "§8/§eteam create §8- §7Erstelle dein eigenes Team"); sender.sendMessage(BungeeCore.ChatPrefix + "§8/§eteam join §8- §7Trete einem Team bei"); + sender.sendMessage(BungeeCore.ChatPrefix + "§8/§eteamchat §8- §7Sende Nachrichten an dein Team"); sender.sendMessage(BungeeCore.ChatPrefix + "§8/§eteam leave §8- §7Verlasse dein Team"); sender.sendMessage(BungeeCore.ChatPrefix + "§8/§eteam list §8- §7Liste alle Teams auf"); sender.sendMessage(BungeeCore.ChatPrefix + "§8/§eteam info §8- §7Informiere dich über ein Team");