From 7ff4dbf44bafe71d694b17921d2fd6274fa721f2 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Fri, 20 Jan 2023 20:45:41 +0100 Subject: [PATCH] added togglelocal command --- .../commands/ToggleLocalChatCommand.java | 31 +++++++++++++++++++ .../bungeecore/listeners/ChatListener.java | 3 +- .../steamwar/messages/BungeeCore.properties | 6 +++- .../messages/BungeeCore_de.properties | 6 +++- 4 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 src/de/steamwar/bungeecore/commands/ToggleLocalChatCommand.java diff --git a/src/de/steamwar/bungeecore/commands/ToggleLocalChatCommand.java b/src/de/steamwar/bungeecore/commands/ToggleLocalChatCommand.java new file mode 100644 index 0000000..28cbf50 --- /dev/null +++ b/src/de/steamwar/bungeecore/commands/ToggleLocalChatCommand.java @@ -0,0 +1,31 @@ +package de.steamwar.bungeecore.commands; + +import de.steamwar.command.SWCommand; +import de.steamwar.messages.ChatSender; +import lombok.Getter; +import net.md_5.bungee.api.connection.ProxiedPlayer; + +import java.util.ArrayList; +import java.util.List; + +public class ToggleLocalChatCommand extends SWCommand { + @Getter private static List inLocalChat; + + protected ToggleLocalChatCommand() { + super("localtoggle", null, "togglelocal", "lt"); + inLocalChat = new ArrayList<>(); + } + + @Register + public void toggleLocalChat(ProxiedPlayer player) { + if (inLocalChat.contains(player)) { + inLocalChat.remove(player); + ChatSender.of(player).system("LOCALTOGGLE_OFF"); + } else { + inLocalChat.add(player); + ChatSender.of(player).system("LOCALTOGGLE_ON"); + } + } + + // Ich habe keine ahnung ob ich das richtig mache +} diff --git a/src/de/steamwar/bungeecore/listeners/ChatListener.java b/src/de/steamwar/bungeecore/listeners/ChatListener.java index 827fe3e..c613ad9 100644 --- a/src/de/steamwar/bungeecore/listeners/ChatListener.java +++ b/src/de/steamwar/bungeecore/listeners/ChatListener.java @@ -21,6 +21,7 @@ package de.steamwar.bungeecore.listeners; import de.steamwar.bungeecore.*; import de.steamwar.bungeecore.bot.SteamwarDiscordBot; +import de.steamwar.bungeecore.commands.ToggleLocalChatCommand; import de.steamwar.bungeecore.network.NetworkSender; import de.steamwar.bungeecore.sql.*; import de.steamwar.bungeecore.util.Chat19; @@ -69,7 +70,7 @@ public class ChatListener extends BasicListener { Subserver subserver = Subserver.getSubserver(player); if(subserver != null && subserver.getType() == Servertype.ARENA && subserver.getServer() == player.getServer().getInfo()) { localChat(player, message); - } else if (message.startsWith("+")) { + } else if (message.startsWith("+") || ToggleLocalChatCommand.getInLocalChat().contains(player)) { localChat(player, message.substring(1)); } else { sendChat(ChatSender.of(player), ChatSender.globalReceivers(), "CHAT_GLOBAL", null, message); diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 23060c2..913d4aa 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -659,4 +659,8 @@ ADVENT_CALENDAR_TITLE=§eAdvent Calendar ADVENT_CALENDAR_DAY=§7Day§8: §e{0} ADVENT_CALENDAR_MESSAGE=§eDid you already open your advent calendar? ADVENT_CALENDAR_MESSAGE_HOVER=§eClick to open! -ADVENT_CALENDAR_OPEN=§7You got §e{0} §7from the advent calendar! \ No newline at end of file +ADVENT_CALENDAR_OPEN=§7You got §e{0} §7from the advent calendar! + +# Toggle Local Chat +LOCALTOGGLE_ON=§7You toggled §alocal §7chat. +LOCALTOGGLE_OFF=§7You toggled §aglobal §7chat. diff --git a/src/de/steamwar/messages/BungeeCore_de.properties b/src/de/steamwar/messages/BungeeCore_de.properties index f9b11af..43bad13 100644 --- a/src/de/steamwar/messages/BungeeCore_de.properties +++ b/src/de/steamwar/messages/BungeeCore_de.properties @@ -635,4 +635,8 @@ ADVENT_CALENDAR_TITLE=§eAdventskalender ADVENT_CALENDAR_DAY=§7Tag§8: §e{0} ADVENT_CALENDAR_MESSAGE=§eHast du heute schon dein Geschenk geholt? ADVENT_CALENDAR_MESSAGE_HOVER=§eKlicken zum öffnen! -ADVENT_CALENDAR_OPEN=§7Du hast §e{0}§7 aus dem Adventskalender erhalten! \ No newline at end of file +ADVENT_CALENDAR_OPEN=§7Du hast §e{0}§7 aus dem Adventskalender erhalten! + +# Toggle Local Chat +LOCALTOGGLE_ON=§7Du bist jetzt im §aLokalen §7Chat. +LOCALTOGGLE_OFF=§7Du bist jetzt im §aGlobalen §7Chat. \ No newline at end of file