mcmmo.admin.chatspy to spy on party chat

This commit is contained in:
nossr50 2019-01-03 00:52:24 -08:00
parent ebec5d6f70
commit 6136e82ec6
4 changed files with 33 additions and 0 deletions

View File

@ -13,6 +13,8 @@ Version 2.1.0
+ (Config) Added rank settings for the new Woodcutting skill + (Config) Added rank settings for the new Woodcutting skill
+ (Config) Added configurable parameters for the new Tree Feller + (Config) Added configurable parameters for the new Tree Feller
+ (Config) Added classic toggle for 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 + (Permissions) Added permission nodes for Harvest Lumber, Splinter, Nature's Bounty, and Bark Surgeon
! Woodcutting's Double Drop subskill is now named Harvest Lumber ! 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 ! Replaced the old Double Drop permission node for woodcutting with a new Harvest Lumber permission node

View File

@ -1,6 +1,12 @@
package com.gmail.nossr50.chat; 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.entity.Player;
import org.bukkit.permissions.Permissible;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import com.gmail.nossr50.events.chat.McMMOChatEvent; import com.gmail.nossr50.events.chat.McMMOChatEvent;
@ -32,7 +38,27 @@ public abstract class ChatManager {
displayName = useDisplayNames ? event.getDisplayName() : senderName; displayName = useDisplayNames ? event.getDisplayName() : senderName;
message = LocaleLoader.formatString(chatPrefix, displayName) + " " + event.getMessage(); message = LocaleLoader.formatString(chatPrefix, displayName) + " " + event.getMessage();
sendMessage(); 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) { public void handleChat(String senderName, String message) {

View File

@ -36,6 +36,7 @@ public final class Permissions {
public static boolean trapsBypass(Permissible permissible) { return permissible.hasPermission("mcmmo.bypass.fishingtraps"); } public static boolean trapsBypass(Permissible permissible) { return permissible.hasPermission("mcmmo.bypass.fishingtraps"); }
/* CHAT */ /* 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 partyChat(Permissible permissible) { return permissible.hasPermission("mcmmo.chat.partychat"); }
public static boolean adminChat(Permissible permissible) { return permissible.hasPermission("mcmmo.chat.adminchat"); } public static boolean adminChat(Permissible permissible) { return permissible.hasPermission("mcmmo.chat.adminchat"); }

View File

@ -690,8 +690,12 @@ permissions:
default: false default: false
description: Implies access to everything in mcMMO description: Implies access to everything in mcMMO
children: children:
mcmmo.admin.chatspy: false
mcmmo.commands.mcconvert.all: true mcmmo.commands.mcconvert.all: true
mcmmo.commands.xprate.all: true mcmmo.commands.xprate.all: true
mcmmo.admin.chatspy:
default: false
description: Allows admins to monitor party chat
mcmmo.bypass.*: mcmmo.bypass.*:
default: false default: false
description: Implies all bypass permissions. description: Implies all bypass permissions.