From 6136e82ec67992f0cb62c0c162ed4ca896a077b8 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Thu, 3 Jan 2019 00:52:24 -0800 Subject: [PATCH] mcmmo.admin.chatspy to spy on party chat --- Changelog.txt | 2 ++ .../com/gmail/nossr50/chat/ChatManager.java | 26 +++++++++++++++++++ .../com/gmail/nossr50/util/Permissions.java | 1 + src/main/resources/plugin.yml | 4 +++ 4 files changed, 33 insertions(+) diff --git a/Changelog.txt b/Changelog.txt index b24b0621f..3fa9d3b3b 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -13,6 +13,8 @@ Version 2.1.0 + (Config) Added rank settings for the new Woodcutting skill + (Config) Added configurable parameters for the new Tree Feller + (Config) Added classic toggle for Tree Feller + + (Chat) Added ability for admins to spy on party chat + + (Permissions) Added permission node mcmmo.admin.chatspy + (Permissions) Added permission nodes for Harvest Lumber, Splinter, Nature's Bounty, and Bark Surgeon ! Woodcutting's Double Drop subskill is now named Harvest Lumber ! Replaced the old Double Drop permission node for woodcutting with a new Harvest Lumber permission node diff --git a/src/main/java/com/gmail/nossr50/chat/ChatManager.java b/src/main/java/com/gmail/nossr50/chat/ChatManager.java index 42407d152..93bed810e 100644 --- a/src/main/java/com/gmail/nossr50/chat/ChatManager.java +++ b/src/main/java/com/gmail/nossr50/chat/ChatManager.java @@ -1,6 +1,12 @@ package com.gmail.nossr50.chat; +import com.gmail.nossr50.datatypes.party.Party; +import com.gmail.nossr50.events.chat.McMMOPartyChatEvent; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.player.UserManager; +import org.bukkit.ChatColor; import org.bukkit.entity.Player; +import org.bukkit.permissions.Permissible; import org.bukkit.plugin.Plugin; import com.gmail.nossr50.events.chat.McMMOChatEvent; @@ -32,7 +38,27 @@ public abstract class ChatManager { displayName = useDisplayNames ? event.getDisplayName() : senderName; message = LocaleLoader.formatString(chatPrefix, displayName) + " " + event.getMessage(); + sendMessage(); + + if(event instanceof McMMOPartyChatEvent) + { + McMMOPartyChatEvent partyChatEvent = (McMMOPartyChatEvent) event; + + for(Player player : event.getPlugin().getServer().getOnlinePlayers()) + { + //TODO: Online check necessary? + if(player.isOnline() && Permissions.adminChatSpy(player)) + { + Party adminParty = UserManager.getPlayer(player).getParty(); + if(adminParty != null && !adminParty.getName().equalsIgnoreCase(partyChatEvent.getParty())) + { + //TODO: Incorporate JSON + player.sendMessage(ChatColor.GOLD+"[SPY: "+ChatColor.GREEN+partyChatEvent.getParty()+ChatColor.GOLD+"] "+message); + } + } + } + } } public void handleChat(String senderName, String message) { diff --git a/src/main/java/com/gmail/nossr50/util/Permissions.java b/src/main/java/com/gmail/nossr50/util/Permissions.java index 0217a29f0..4b617da07 100644 --- a/src/main/java/com/gmail/nossr50/util/Permissions.java +++ b/src/main/java/com/gmail/nossr50/util/Permissions.java @@ -36,6 +36,7 @@ public final class Permissions { public static boolean trapsBypass(Permissible permissible) { return permissible.hasPermission("mcmmo.bypass.fishingtraps"); } /* CHAT */ + public static boolean adminChatSpy(Permissible permissible) { return permissible.hasPermission("mcmmo.admin.chatspy");} public static boolean partyChat(Permissible permissible) { return permissible.hasPermission("mcmmo.chat.partychat"); } public static boolean adminChat(Permissible permissible) { return permissible.hasPermission("mcmmo.chat.adminchat"); } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 00dfe4441..26869cbf4 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -690,8 +690,12 @@ permissions: default: false description: Implies access to everything in mcMMO children: + mcmmo.admin.chatspy: false mcmmo.commands.mcconvert.all: true mcmmo.commands.xprate.all: true + mcmmo.admin.chatspy: + default: false + description: Allows admins to monitor party chat mcmmo.bypass.*: default: false description: Implies all bypass permissions.