From 329d80f03793cf5b09d83ea9977fb4c5f20747f0 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 22 Apr 2022 17:10:32 +0200 Subject: [PATCH] Fix Arenaserver Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/Message.java | 4 ++-- src/de/steamwar/bungeecore/commands/TpCommand.java | 2 +- src/de/steamwar/bungeecore/listeners/ChatListener.java | 3 +-- src/de/steamwar/messages/ChatSender.java | 7 ++----- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/de/steamwar/bungeecore/Message.java b/src/de/steamwar/bungeecore/Message.java index 1267847..90ee341 100644 --- a/src/de/steamwar/bungeecore/Message.java +++ b/src/de/steamwar/bungeecore/Message.java @@ -116,7 +116,7 @@ public class Message { } public static void broadcast(String message, String onHover, ClickEvent onClick, Object... params) { - ChatSender.allReceivers().forEach(player -> player.prefixless(message, new Message(onHover, params), onClick, params)); + ChatSender.allReceivers().forEach(player -> player.prefixless(message, onHover != null ? new Message(onHover, params) : null, onClick, params)); } public static void team(String message, Object... params) { @@ -124,7 +124,7 @@ public class Message { } public static void team(String message, String onHover, ClickEvent onClick, Object... params) { - ChatSender.serverteamReceivers().filter(player -> player.user().getUserGroup().isTeamGroup()).forEach(player -> player.prefixless(message, new Message(onHover, params), onClick, params)); + ChatSender.serverteamReceivers().filter(player -> player.user().getUserGroup().isTeamGroup()).forEach(player -> player.prefixless(message, onHover != null ? new Message(onHover, params) : null, onClick, params)); } private final String format; diff --git a/src/de/steamwar/bungeecore/commands/TpCommand.java b/src/de/steamwar/bungeecore/commands/TpCommand.java index 704a0aa..801ed2c 100644 --- a/src/de/steamwar/bungeecore/commands/TpCommand.java +++ b/src/de/steamwar/bungeecore/commands/TpCommand.java @@ -81,7 +81,7 @@ public class TpCommand extends BasicCommand { String serverPerm = BungeeCore.serverPermissions.get(server.getName()); Subserver subserver = Subserver.getSubserver(server); - if (subserver instanceof Arenaserver) { + if (subserver != null && subserver.getType() == Servertype.ARENA) { if (!sender.user().isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer)) SubserverSystem.sendPlayer(subserver, player); diff --git a/src/de/steamwar/bungeecore/listeners/ChatListener.java b/src/de/steamwar/bungeecore/listeners/ChatListener.java index 81c4fff..f565677 100644 --- a/src/de/steamwar/bungeecore/listeners/ChatListener.java +++ b/src/de/steamwar/bungeecore/listeners/ChatListener.java @@ -68,9 +68,8 @@ public class ChatListener extends BasicListener { } else { e.setCancelled(true); - //TODO /arena Subserver subserver = Subserver.getSubserver(player); - if(subserver instanceof Arenaserver && subserver.getServer() == player.getServer().getInfo()) { + if(subserver != null && subserver.getType() == Servertype.ARENA && subserver.getServer() == player.getServer().getInfo()) { localChat(player, message); } else if (message.startsWith("+")) { localChat(player, message.substring(1)); diff --git a/src/de/steamwar/messages/ChatSender.java b/src/de/steamwar/messages/ChatSender.java index 3d1fb55..de80541 100644 --- a/src/de/steamwar/messages/ChatSender.java +++ b/src/de/steamwar/messages/ChatSender.java @@ -19,10 +19,7 @@ package de.steamwar.messages; -import de.steamwar.bungeecore.Arenaserver; -import de.steamwar.bungeecore.BungeeCore; -import de.steamwar.bungeecore.Message; -import de.steamwar.bungeecore.Subserver; +import de.steamwar.bungeecore.*; import de.steamwar.bungeecore.bot.listeners.DiscordChatListener; import de.steamwar.bungeecore.sql.SteamwarUser; import net.md_5.bungee.api.ChatMessageType; @@ -59,7 +56,7 @@ public interface ChatSender { static Stream globalReceivers() { return all().filter(player -> { Subserver subserver = Subserver.getSubserver(player); - return !(subserver instanceof Arenaserver && subserver.getServer() == player.getServer().getInfo()); + return subserver == null || !(subserver.getType() == Servertype.ARENA && subserver.getServer() == player.getServer().getInfo()); }).map(ChatSender::of); }