From 8c9ed7cda24452079e065a2ec4e5ce9cddd0171b Mon Sep 17 00:00:00 2001 From: petethepossum <47347759+petethepossum@users.noreply.github.com> Date: Fri, 2 Jan 2026 13:52:32 +1300 Subject: [PATCH] FEAT: Staff chat Add: Friendlist functionality --- .../swofty/service/friend/FriendCache.java | 23 +++++++- .../service/friend/PresenceStorage.java | 32 ++++++++++ .../endpoints/UpdatePresenceEndpoint.java | 4 +- .../bedwarsgame/events/ActionPlayerChat.java | 11 ++++ .../bedwarslobby/events/ActionPlayerChat.java | 11 ++++ .../swofty/type/generic/chat/StaffChat.java | 35 +++++++++++ .../generic/command/commands/ChatCommand.java | 59 +++++++++++++++++-- .../command/commands/FriendListCommand.java | 56 ++++++++++++++++++ .../data/datapoints/DatapointChatType.java | 3 +- .../actions/ActionStaffJoinNotification.java | 22 +++++++ .../events/ActionPlayerChat.java | 21 +++++-- .../events/ActionPlayerChat.java | 11 ++++ .../events/ActionPlayerChat.java | 11 ++++ .../actions/player/ActionPlayerChat.java | 11 ++++ 14 files changed, 296 insertions(+), 14 deletions(-) create mode 100644 type.generic/src/main/java/net/swofty/type/generic/chat/StaffChat.java create mode 100644 type.generic/src/main/java/net/swofty/type/generic/command/commands/FriendListCommand.java create mode 100644 type.generic/src/main/java/net/swofty/type/generic/event/actions/ActionStaffJoinNotification.java diff --git a/service.friend/src/main/java/net/swofty/service/friend/FriendCache.java b/service.friend/src/main/java/net/swofty/service/friend/FriendCache.java index e60e8e131..2a413b255 100644 --- a/service.friend/src/main/java/net/swofty/service/friend/FriendCache.java +++ b/service.friend/src/main/java/net/swofty/service/friend/FriendCache.java @@ -365,7 +365,7 @@ public static void handleRequestsListRequest(FriendRequestsListEvent event) { } public static void handlePlayerJoin(UUID playerUuid, String playerName) { - PresenceStorage.upsert(new net.swofty.commons.presence.PresenceInfo( + PresenceStorage.upsertPreservingServer(new net.swofty.commons.presence.PresenceInfo( playerUuid, true, null, @@ -376,7 +376,15 @@ public static void handlePlayerJoin(UUID playerUuid, String playerName) { FriendData playerData = getFriendData(playerUuid); for (Friend friend : playerData.getFriends()) { + net.swofty.commons.presence.PresenceInfo friendPresence = PresenceStorage.get(friend.getUuid()); + if (friendPresence == null || !friendPresence.isOnline()) continue; + FriendData friendData = cachedFriendData.get(friend.getUuid()); + if (friendData == null) { + friendData = getFriendData(friend.getUuid()); + cachedFriendData.put(friend.getUuid(), friendData); + } + if (friendData != null && friendData.getSettings().isJoinLeaveNotifications()) { sendEvent(new FriendJoinNotificationEvent(friend.getUuid(), playerUuid, playerName)); } @@ -384,7 +392,7 @@ public static void handlePlayerJoin(UUID playerUuid, String playerName) { } public static void handlePlayerLeave(UUID playerUuid, String playerName) { - PresenceStorage.upsert(new net.swofty.commons.presence.PresenceInfo( + PresenceStorage.upsertPreservingServer(new net.swofty.commons.presence.PresenceInfo( playerUuid, false, null, @@ -396,7 +404,15 @@ public static void handlePlayerLeave(UUID playerUuid, String playerName) { if (playerData == null) return; for (Friend friend : playerData.getFriends()) { + net.swofty.commons.presence.PresenceInfo friendPresence = PresenceStorage.get(friend.getUuid()); + if (friendPresence == null || !friendPresence.isOnline()) continue; + FriendData friendData = cachedFriendData.get(friend.getUuid()); + if (friendData == null) { + friendData = getFriendData(friend.getUuid()); + cachedFriendData.put(friend.getUuid(), friendData); + } + if (friendData != null && friendData.getSettings().isJoinLeaveNotifications()) { sendEvent(new FriendLeaveNotificationEvent(friend.getUuid(), playerUuid, playerName)); } @@ -464,6 +480,9 @@ private static String formatServerDisplay(net.swofty.commons.presence.PresenceIn String type = info.getServerType(); String id = info.getServerId(); if (type == null && id == null) return null; + if (id != null && id.matches("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$")) { + return type; // hide raw UUIDs; show type only + } if (type != null && id != null) return type + " - " + id; return type != null ? type : id; } diff --git a/service.friend/src/main/java/net/swofty/service/friend/PresenceStorage.java b/service.friend/src/main/java/net/swofty/service/friend/PresenceStorage.java index a71fcba2b..4dd34d7e8 100644 --- a/service.friend/src/main/java/net/swofty/service/friend/PresenceStorage.java +++ b/service.friend/src/main/java/net/swofty/service/friend/PresenceStorage.java @@ -16,6 +16,38 @@ public static void upsert(PresenceInfo presence) { presenceByUuid.put(presence.getUuid(), presence); } + /** + * Upsert presence and return the previous entry (if any). + */ + public static PresenceInfo upsertAndGetPrevious(PresenceInfo presence) { + return presenceByUuid.put(presence.getUuid(), presence); + } + + /** + * Upsert presence while preserving non-null server metadata from previous entries. + */ + public static PresenceInfo upsertPreservingServer(PresenceInfo incoming) { + PresenceInfo previous = presenceByUuid.get(incoming.getUuid()); + if (previous == null) { + presenceByUuid.put(incoming.getUuid(), incoming); + return null; + } + + String serverType = incoming.getServerType() != null ? incoming.getServerType() : previous.getServerType(); + String serverId = incoming.getServerId() != null ? incoming.getServerId() : previous.getServerId(); + long lastSeen = incoming.getLastSeen() > 0 ? incoming.getLastSeen() : previous.getLastSeen(); + + PresenceInfo merged = new PresenceInfo( + incoming.getUuid(), + incoming.isOnline(), + serverType, + serverId, + lastSeen + ); + presenceByUuid.put(incoming.getUuid(), merged); + return previous; + } + public static List getBulk(Collection uuids) { if (uuids == null || uuids.isEmpty()) return List.of(); return uuids.stream() diff --git a/service.friend/src/main/java/net/swofty/service/friend/endpoints/UpdatePresenceEndpoint.java b/service.friend/src/main/java/net/swofty/service/friend/endpoints/UpdatePresenceEndpoint.java index 7352eba94..ea355bc62 100644 --- a/service.friend/src/main/java/net/swofty/service/friend/endpoints/UpdatePresenceEndpoint.java +++ b/service.friend/src/main/java/net/swofty/service/friend/endpoints/UpdatePresenceEndpoint.java @@ -22,11 +22,9 @@ public UpdatePresenceProtocolObject.UpdatePresenceResponse onMessage( UpdatePresenceProtocolObject.UpdatePresenceMessage messageObject) { PresenceInfo incoming = messageObject.presence(); - PresenceInfo previous = PresenceStorage.get(incoming.getUuid()); + PresenceInfo previous = PresenceStorage.upsertPreservingServer(incoming); - // Detect state change to trigger friend join/leave notifications boolean stateChanged = previous == null || previous.isOnline() != incoming.isOnline(); - PresenceStorage.upsert(incoming); if (stateChanged) { String playerName = FriendCache.getPlayerName(incoming.getUuid()); diff --git a/type.bedwarsgame/src/main/java/net/swofty/type/bedwarsgame/events/ActionPlayerChat.java b/type.bedwarsgame/src/main/java/net/swofty/type/bedwarsgame/events/ActionPlayerChat.java index df531928e..92b505c29 100644 --- a/type.bedwarsgame/src/main/java/net/swofty/type/bedwarsgame/events/ActionPlayerChat.java +++ b/type.bedwarsgame/src/main/java/net/swofty/type/bedwarsgame/events/ActionPlayerChat.java @@ -8,6 +8,7 @@ import net.swofty.type.bedwarsgame.game.Game; import net.swofty.type.bedwarsgame.game.GameStatus; import net.swofty.type.bedwarsgame.user.BedWarsPlayer; +import net.swofty.type.generic.chat.StaffChat; import net.swofty.type.generic.data.datapoints.DatapointChatType; import net.swofty.type.generic.data.datapoints.DatapointLeaderboardLong; import net.swofty.type.generic.data.handlers.BedWarsDataHandler; @@ -45,6 +46,16 @@ public void run(PlayerChatEvent event) { String finalMessage = message; DatapointChatType.Chats chatType = player.getChatType().currentChatType; + if (chatType == DatapointChatType.Chats.STAFF) { + if (!rank.isStaff()) { + player.sendMessage("§cUnknown chat type."); + player.getChatType().switchTo(DatapointChatType.Chats.ALL); + return; + } + StaffChat.sendMessage(player, finalMessage); + return; + } + if (chatType == DatapointChatType.Chats.PARTY) { if (!PartyManager.isInParty(player)) { player.sendMessage("§cYou are not in a party and were moved to the ALL channel."); diff --git a/type.bedwarslobby/src/main/java/net/swofty/type/bedwarslobby/events/ActionPlayerChat.java b/type.bedwarslobby/src/main/java/net/swofty/type/bedwarslobby/events/ActionPlayerChat.java index 63d7d25c3..ec5500b25 100644 --- a/type.bedwarslobby/src/main/java/net/swofty/type/bedwarslobby/events/ActionPlayerChat.java +++ b/type.bedwarslobby/src/main/java/net/swofty/type/bedwarslobby/events/ActionPlayerChat.java @@ -5,6 +5,7 @@ import net.swofty.commons.bedwars.BedwarsLevelColor; import net.swofty.commons.bedwars.BedwarsLevelUtil; import net.swofty.type.generic.HypixelGenericLoader; +import net.swofty.type.generic.chat.StaffChat; import net.swofty.type.generic.data.HypixelDataHandler; import net.swofty.type.generic.data.datapoints.DatapointChatType; import net.swofty.type.generic.data.datapoints.DatapointLeaderboardLong; @@ -44,6 +45,16 @@ public void run(PlayerChatEvent event) { String finalMessage = message; DatapointChatType.Chats chatType = player.getChatType().currentChatType; + if (chatType == DatapointChatType.Chats.STAFF) { + if (!rank.isStaff()) { + player.sendMessage("§cUnknown chat type."); + player.getChatType().switchTo(DatapointChatType.Chats.ALL); + return; + } + StaffChat.sendMessage(player, finalMessage); + return; + } + if (chatType == DatapointChatType.Chats.PARTY) { if (!PartyManager.isInParty(player)) { player.sendMessage("§cYou are not in a party and were moved to the ALL channel."); diff --git a/type.generic/src/main/java/net/swofty/type/generic/chat/StaffChat.java b/type.generic/src/main/java/net/swofty/type/generic/chat/StaffChat.java new file mode 100644 index 000000000..ea48b2c04 --- /dev/null +++ b/type.generic/src/main/java/net/swofty/type/generic/chat/StaffChat.java @@ -0,0 +1,35 @@ +package net.swofty.type.generic.chat; + +import net.swofty.type.generic.HypixelGenericLoader; +import net.swofty.type.generic.command.commands.ChatCommand; +import net.swofty.type.generic.user.HypixelPlayer; + +import java.util.List; +import java.util.UUID; +import java.util.stream.Collectors; + +public final class StaffChat { + private StaffChat() {} + + public static void sendMessage(HypixelPlayer sender, String message) { + String formatted = "§b[STAFF] " + sender.getRank().getPrefix() + sender.getUsername() + "§f: " + message; + broadcast(formatted, sender.getUuid()); + } + + public static void sendNotification(String message) { + String formatted = "§b[STAFF] §7" + message; + broadcast(formatted, null); + } + + private static void broadcast(String message, UUID senderUuid) { + List viewers = HypixelGenericLoader.getLoadedPlayers().stream() + .filter(player -> player.getRank().isStaff()) + .filter(player -> ChatCommand.isStaffViewEnabled(player.getUuid()) || (senderUuid != null && player.getUuid().equals(senderUuid))) + .collect(Collectors.toList()); + + for (HypixelPlayer viewer : viewers) { + viewer.sendMessage(message); + } + } +} + diff --git a/type.generic/src/main/java/net/swofty/type/generic/command/commands/ChatCommand.java b/type.generic/src/main/java/net/swofty/type/generic/command/commands/ChatCommand.java index f750a4ec9..03139c9e2 100644 --- a/type.generic/src/main/java/net/swofty/type/generic/command/commands/ChatCommand.java +++ b/type.generic/src/main/java/net/swofty/type/generic/command/commands/ChatCommand.java @@ -1,7 +1,8 @@ package net.swofty.type.generic.command.commands; -import net.minestom.server.command.builder.arguments.ArgumentEnum; import net.minestom.server.command.builder.arguments.ArgumentType; +import net.minestom.server.command.builder.arguments.ArgumentWord; +import net.minestom.server.command.builder.suggestion.SuggestionEntry; import net.swofty.type.generic.command.CommandParameters; import net.swofty.type.generic.command.HypixelCommand; import net.swofty.type.generic.data.datapoints.DatapointChatType; @@ -14,15 +15,52 @@ aliases = "chatmode", allowsConsole = false) public class ChatCommand extends HypixelCommand { + private static final java.util.concurrent.ConcurrentHashMap staffView = new java.util.concurrent.ConcurrentHashMap<>(); + @Override public void registerUsage(MinestomCommand command) { - ArgumentEnum chatType = ArgumentType.Enum("type", PickerChatType.class); + ArgumentWord chatType = ArgumentType.Word("type"); + chatType.setSuggestionCallback((sender, context, suggestion) -> { + boolean isStaff = sender instanceof HypixelPlayer hp && hp.getRank().isStaff(); + suggestion.addEntry(new SuggestionEntry("p")); + suggestion.addEntry(new SuggestionEntry("party")); + suggestion.addEntry(new SuggestionEntry("a")); + suggestion.addEntry(new SuggestionEntry("all")); + if (isStaff) { + suggestion.addEntry(new SuggestionEntry("s")); + suggestion.addEntry(new SuggestionEntry("staff")); + suggestion.addEntry(new SuggestionEntry("staffview")); + suggestion.addEntry(new SuggestionEntry("sv")); + } + }); command.addSyntax((sender, context) -> { if (!permissionCheck(sender)) return; - PickerChatType type = context.get(chatType); HypixelPlayer player = (HypixelPlayer) sender; + String raw = context.get(chatType).toLowerCase(); + + if ((raw.equals("staffview") || raw.equals("sv"))) { + if (!player.getRank().isStaff()) { + sender.sendMessage("§cUnknown chat type."); + return; + } + boolean enabled = staffView.getOrDefault(player.getUuid(), true); + staffView.put(player.getUuid(), !enabled); + sender.sendMessage("§aStaff chat viewing is now " + (!enabled ? "§aenabled" : "§cdisabled")); + return; + } + + PickerChatType type = PickerChatType.fromString(raw); + if (type == null) { + sender.sendMessage("§cUnknown chat type."); + return; + } + + if (type.getChatType() == DatapointChatType.Chats.STAFF && !player.getRank().isStaff()) { + sender.sendMessage("§cUnknown chat type."); + return; + } player.getChatType().switchTo(type.getChatType()); sender.sendMessage("§aYou are now in the §6" + type.chatType.name() + " §achannel"); @@ -33,7 +71,9 @@ enum PickerChatType { p(DatapointChatType.Chats.PARTY), party(DatapointChatType.Chats.PARTY), a(DatapointChatType.Chats.ALL), - all(DatapointChatType.Chats.ALL); + all(DatapointChatType.Chats.ALL), + s(DatapointChatType.Chats.STAFF), + staff(DatapointChatType.Chats.STAFF); private final DatapointChatType.Chats chatType; @@ -44,5 +84,16 @@ enum PickerChatType { public DatapointChatType.Chats getChatType() { return chatType; } + + public static PickerChatType fromString(String input) { + for (PickerChatType val : values()) { + if (val.name().equalsIgnoreCase(input)) return val; + } + return null; + } + } + + public static boolean isStaffViewEnabled(java.util.UUID uuid) { + return staffView.getOrDefault(uuid, true); } } diff --git a/type.generic/src/main/java/net/swofty/type/generic/command/commands/FriendListCommand.java b/type.generic/src/main/java/net/swofty/type/generic/command/commands/FriendListCommand.java new file mode 100644 index 000000000..dc1a62758 --- /dev/null +++ b/type.generic/src/main/java/net/swofty/type/generic/command/commands/FriendListCommand.java @@ -0,0 +1,56 @@ +package net.swofty.type.generic.command.commands; + +import net.minestom.server.command.builder.arguments.ArgumentString; +import net.minestom.server.command.builder.arguments.ArgumentType; +import net.swofty.type.generic.command.CommandParameters; +import net.swofty.type.generic.command.HypixelCommand; +import net.swofty.type.generic.friend.FriendManager; +import net.swofty.type.generic.user.HypixelPlayer; +import net.swofty.type.generic.user.categories.Rank; + +@CommandParameters( + aliases = "fl friendlist", + description = "List your friends", + usage = "/fl [page]", + permission = Rank.DEFAULT, + allowsConsole = false +) +public class FriendListCommand extends HypixelCommand { + + @Override + public void registerUsage(MinestomCommand command) { + ArgumentString pageArg = ArgumentType.String("page"); + + // No args -> page 1 + command.addSyntax((sender, context) -> { + if (!permissionCheck(sender)) return; + HypixelPlayer player = (HypixelPlayer) sender; + FriendManager.listFriends(player, 1, false); + }); + + // With page/best + command.addSyntax((sender, context) -> { + if (!permissionCheck(sender)) return; + HypixelPlayer player = (HypixelPlayer) sender; + String arg = context.get(pageArg); + + if ("best".equalsIgnoreCase(arg)) { + FriendManager.listFriends(player, 1, true); + return; + } + + int page = parsePageNumber(arg); + FriendManager.listFriends(player, page, false); + }, pageArg); + } + + private int parsePageNumber(String arg) { + try { + return Math.max(1, Integer.parseInt(arg)); + } catch (NumberFormatException e) { + return 1; + } + } +} + + diff --git a/type.generic/src/main/java/net/swofty/type/generic/data/datapoints/DatapointChatType.java b/type.generic/src/main/java/net/swofty/type/generic/data/datapoints/DatapointChatType.java index d936b3839..8a3005035 100644 --- a/type.generic/src/main/java/net/swofty/type/generic/data/datapoints/DatapointChatType.java +++ b/type.generic/src/main/java/net/swofty/type/generic/data/datapoints/DatapointChatType.java @@ -43,6 +43,7 @@ public void switchTo(Chats chatType) { public enum Chats { ALL, - PARTY + PARTY, + STAFF } } diff --git a/type.generic/src/main/java/net/swofty/type/generic/event/actions/ActionStaffJoinNotification.java b/type.generic/src/main/java/net/swofty/type/generic/event/actions/ActionStaffJoinNotification.java new file mode 100644 index 000000000..e70f17f44 --- /dev/null +++ b/type.generic/src/main/java/net/swofty/type/generic/event/actions/ActionStaffJoinNotification.java @@ -0,0 +1,22 @@ +package net.swofty.type.generic.event.actions; + +import net.minestom.server.event.player.PlayerSpawnEvent; +import net.swofty.type.generic.chat.StaffChat; +import net.swofty.type.generic.event.EventNodes; +import net.swofty.type.generic.event.HypixelEvent; +import net.swofty.type.generic.event.HypixelEventClass; +import net.swofty.type.generic.user.HypixelPlayer; + +public class ActionStaffJoinNotification implements HypixelEventClass { + + @HypixelEvent(node = EventNodes.PLAYER, requireDataLoaded = true) + public void run(PlayerSpawnEvent event) { + if (!event.isFirstSpawn()) return; + HypixelPlayer player = (HypixelPlayer) event.getPlayer(); + if (!player.getRank().isStaff()) return; + + StaffChat.sendNotification(player.getFullDisplayName() + " §7joined."); + } +} + + diff --git a/type.murdermysterygame/src/main/java/net/swofty/type/murdermysterygame/events/ActionPlayerChat.java b/type.murdermysterygame/src/main/java/net/swofty/type/murdermysterygame/events/ActionPlayerChat.java index b1d3e6b60..a78530429 100644 --- a/type.murdermysterygame/src/main/java/net/swofty/type/murdermysterygame/events/ActionPlayerChat.java +++ b/type.murdermysterygame/src/main/java/net/swofty/type/murdermysterygame/events/ActionPlayerChat.java @@ -4,15 +4,17 @@ import net.kyori.adventure.text.format.NamedTextColor; import net.minestom.server.event.player.PlayerChatEvent; import net.swofty.commons.StringUtility; +import net.swofty.type.generic.chat.StaffChat; +import net.swofty.type.generic.data.datapoints.DatapointChatType; +import net.swofty.type.generic.event.EventNodes; +import net.swofty.type.generic.event.HypixelEvent; +import net.swofty.type.generic.event.HypixelEventClass; +import net.swofty.type.generic.user.categories.Rank; import net.swofty.type.murdermysterygame.TypeMurderMysteryGameLoader; import net.swofty.type.murdermysterygame.game.Game; import net.swofty.type.murdermysterygame.game.GameStatus; import net.swofty.type.murdermysterygame.role.GameRole; import net.swofty.type.murdermysterygame.user.MurderMysteryPlayer; -import net.swofty.type.generic.event.EventNodes; -import net.swofty.type.generic.event.HypixelEvent; -import net.swofty.type.generic.event.HypixelEventClass; -import net.swofty.type.generic.user.categories.Rank; public class ActionPlayerChat implements HypixelEventClass { @@ -34,6 +36,17 @@ public void run(PlayerChatEvent event) { String finalMessage = message; + DatapointChatType.Chats chatType = player.getChatType().currentChatType; + if (chatType == DatapointChatType.Chats.STAFF) { + if (!rank.isStaff()) { + player.sendMessage("§cUnknown chat type."); + player.getChatType().switchTo(DatapointChatType.Chats.ALL); + return; + } + StaffChat.sendMessage(player, finalMessage); + return; + } + // Dead players can only talk to other dead players if (player.isEliminated() && game.getGameStatus() == GameStatus.IN_PROGRESS) { for (MurderMysteryPlayer gamePlayer : game.getPlayers()) { diff --git a/type.murdermysterylobby/src/main/java/net/swofty/type/murdermysterylobby/events/ActionPlayerChat.java b/type.murdermysterylobby/src/main/java/net/swofty/type/murdermysterylobby/events/ActionPlayerChat.java index 8f5d01bd5..9cfe6c720 100644 --- a/type.murdermysterylobby/src/main/java/net/swofty/type/murdermysterylobby/events/ActionPlayerChat.java +++ b/type.murdermysterylobby/src/main/java/net/swofty/type/murdermysterylobby/events/ActionPlayerChat.java @@ -3,6 +3,7 @@ import net.minestom.server.event.player.PlayerChatEvent; import net.swofty.commons.StringUtility; import net.swofty.type.generic.HypixelGenericLoader; +import net.swofty.type.generic.chat.StaffChat; import net.swofty.type.generic.data.HypixelDataHandler; import net.swofty.type.generic.data.datapoints.DatapointChatType; import net.swofty.type.generic.event.EventNodes; @@ -34,6 +35,16 @@ public void run(PlayerChatEvent event) { String finalMessage = message; DatapointChatType.Chats chatType = player.getChatType().currentChatType; + if (chatType == DatapointChatType.Chats.STAFF) { + if (!rank.isStaff()) { + player.sendMessage("§cUnknown chat type."); + player.getChatType().switchTo(DatapointChatType.Chats.ALL); + return; + } + StaffChat.sendMessage(player, finalMessage); + return; + } + if (chatType == DatapointChatType.Chats.PARTY) { if (!PartyManager.isInParty(player)) { player.sendMessage("§cYou are not in a party and were moved to the ALL channel."); diff --git a/type.prototypelobby/src/main/java/net/swofty/type/prototypelobby/events/ActionPlayerChat.java b/type.prototypelobby/src/main/java/net/swofty/type/prototypelobby/events/ActionPlayerChat.java index 07e1d92f3..ad4b4db48 100644 --- a/type.prototypelobby/src/main/java/net/swofty/type/prototypelobby/events/ActionPlayerChat.java +++ b/type.prototypelobby/src/main/java/net/swofty/type/prototypelobby/events/ActionPlayerChat.java @@ -3,6 +3,7 @@ import net.minestom.server.event.player.PlayerChatEvent; import net.swofty.commons.StringUtility; import net.swofty.type.generic.HypixelGenericLoader; +import net.swofty.type.generic.chat.StaffChat; import net.swofty.type.generic.data.HypixelDataHandler; import net.swofty.type.generic.data.datapoints.DatapointChatType; import net.swofty.type.generic.event.EventNodes; @@ -34,6 +35,16 @@ public void run(PlayerChatEvent event) { String finalMessage = message; DatapointChatType.Chats chatType = player.getChatType().currentChatType; + if (chatType == DatapointChatType.Chats.STAFF) { + if (!rank.isStaff()) { + player.sendMessage("§cUnknown chat type."); + player.getChatType().switchTo(DatapointChatType.Chats.ALL); + return; + } + StaffChat.sendMessage(player, finalMessage); + return; + } + if (chatType == DatapointChatType.Chats.PARTY) { if (!PartyManager.isInParty(player)) { player.sendMessage("§cYou are not in a party and were moved to the ALL channel."); diff --git a/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/event/actions/player/ActionPlayerChat.java b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/event/actions/player/ActionPlayerChat.java index a53e9462b..933283a78 100644 --- a/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/event/actions/player/ActionPlayerChat.java +++ b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/event/actions/player/ActionPlayerChat.java @@ -4,6 +4,7 @@ import net.swofty.commons.ServerType; import net.swofty.commons.StringUtility; import net.swofty.type.generic.HypixelConst; +import net.swofty.type.generic.chat.StaffChat; import net.swofty.type.generic.data.datapoints.DatapointChatType; import net.swofty.type.generic.data.datapoints.DatapointToggles; import net.swofty.type.generic.event.EventNodes; @@ -37,6 +38,16 @@ public void run(PlayerChatEvent event) { String finalMessage = message; DatapointChatType.Chats chatType = player.getChatType().currentChatType; + if (chatType == DatapointChatType.Chats.STAFF) { + if (!rank.isStaff()) { + player.sendMessage("§cUnknown chat type."); + player.getChatType().switchTo(DatapointChatType.Chats.ALL); + return; + } + StaffChat.sendMessage(player, finalMessage); + return; + } + if (chatType == DatapointChatType.Chats.PARTY) { if (!PartyManager.isInParty(player)) { player.sendMessage("§cYou are not in a party and were moved to the ALL channel.");