From c701621e42abb0113e97667490fea3f57c0f3de7 Mon Sep 17 00:00:00 2001 From: Teriuihi Date: Sun, 8 Aug 2021 18:27:30 +0200 Subject: [PATCH] Added party spy --- api/src/main/java/com/alttd/chat/config/Config.java | 2 ++ .../main/java/com/alttd/chat/commands/ChatParty.java | 10 ++++++---- .../main/java/com/alttd/chat/handler/ChatHandler.java | 9 +++++++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/api/src/main/java/com/alttd/chat/config/Config.java b/api/src/main/java/com/alttd/chat/config/Config.java index 490e050..8e66cc9 100755 --- a/api/src/main/java/com/alttd/chat/config/Config.java +++ b/api/src/main/java/com/alttd/chat/config/Config.java @@ -203,8 +203,10 @@ public final class Config { } public static String PARTY_FORMAT = "( > → Party) "; + public static String PARTY_SPY = "PC: : "; private static void party() { PARTY_FORMAT = getString("party.format", PARTY_FORMAT); + PARTY_SPY = getString("party.spy", PARTY_SPY); } // TODO prefixes need hovers, this hasn't been setup yet! diff --git a/galaxy/src/main/java/com/alttd/chat/commands/ChatParty.java b/galaxy/src/main/java/com/alttd/chat/commands/ChatParty.java index 547aa53..54d86f8 100644 --- a/galaxy/src/main/java/com/alttd/chat/commands/ChatParty.java +++ b/galaxy/src/main/java/com/alttd/chat/commands/ChatParty.java @@ -24,10 +24,7 @@ import org.bukkit.scheduler.BukkitRunnable; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Objects; +import java.util.*; import java.util.stream.Collectors; public class ChatParty implements CommandExecutor, TabCompleter { @@ -152,6 +149,11 @@ public class ChatParty implements CommandExecutor, TabCompleter { } party.removeUser(ChatUserManager.getChatUser(offlinePlayerIfCached.getUniqueId())); + if (offlinePlayerIfCached.getUniqueId().equals(party.getOwnerUuid())) { + sender.sendMessage(MiniMessage.get().parse("You can't remove yourself, please leave instead.")); + return; + } + if (offlinePlayerIfCached.isOnline()) { Objects.requireNonNull(offlinePlayerIfCached.getPlayer()) .sendMessage(MiniMessage.get().parse("You were removed from the '" + party.getPartyName() + "' chat party.")); diff --git a/galaxy/src/main/java/com/alttd/chat/handler/ChatHandler.java b/galaxy/src/main/java/com/alttd/chat/handler/ChatHandler.java index f550e38..b6cd2a5 100755 --- a/galaxy/src/main/java/com/alttd/chat/handler/ChatHandler.java +++ b/galaxy/src/main/java/com/alttd/chat/handler/ChatHandler.java @@ -181,12 +181,21 @@ public class ChatHandler { List