mcchatspy is now a command based instead of permission node based

This commit is contained in:
nossr50 2019-01-03 01:26:08 -08:00
parent 6136e82ec6
commit 85e1f2eb7e
8 changed files with 79 additions and 12 deletions

View File

@ -13,8 +13,9 @@ 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 + (Chat) Added ability for admins to spy on party chat (off unless toggled on)
+ (Permissions) Added permission node mcmmo.admin.chatspy + (Commands) Added toggle command /mcchatspy
+ (Permissions) Added permission node mcmmo.commands.mcchatspy & mcmmo.commands.mcchatspy.others
+ (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

@ -2,11 +2,9 @@ package com.gmail.nossr50.chat;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent; import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.ChatColor; 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;
@ -38,19 +36,26 @@ 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();
/*
* Party Chat Spying
* Party messages will be copied to people with the mcmmo.admin.chatspy permission node
*/
if(event instanceof McMMOPartyChatEvent) if(event instanceof McMMOPartyChatEvent)
{ {
//We need to grab the party chat name
McMMOPartyChatEvent partyChatEvent = (McMMOPartyChatEvent) event; McMMOPartyChatEvent partyChatEvent = (McMMOPartyChatEvent) event;
//Find the people with permissions
for(Player player : event.getPlugin().getServer().getOnlinePlayers()) for(Player player : event.getPlugin().getServer().getOnlinePlayers())
{ {
//TODO: Online check necessary? //Check for toggled players
if(player.isOnline() && Permissions.adminChatSpy(player)) if(UserManager.getPlayer(player).isPartyChatSpying())
{ {
Party adminParty = UserManager.getPlayer(player).getParty(); Party adminParty = UserManager.getPlayer(player).getParty();
//Only message admins not part of this party
if(adminParty != null && !adminParty.getName().equalsIgnoreCase(partyChatEvent.getParty())) if(adminParty != null && !adminParty.getName().equalsIgnoreCase(partyChatEvent.getParty()))
{ {
//TODO: Incorporate JSON //TODO: Incorporate JSON

View File

@ -0,0 +1,30 @@
package com.gmail.nossr50.commands.chat;
import com.gmail.nossr50.commands.ToggleCommand;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import org.bukkit.command.CommandSender;
public class McChatSpy extends ToggleCommand {
@Override
protected boolean hasOtherPermission(CommandSender sender) {
return Permissions.adminChatSpyOthers(sender);
}
@Override
protected boolean hasSelfPermission(CommandSender sender) {
return Permissions.adminChatSpy(sender);
}
@Override
protected void applyCommandAction(McMMOPlayer mcMMOPlayer) {
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.AdminChatSpy." + (mcMMOPlayer.getGodMode() ? "Disabled" : "Enabled")));
mcMMOPlayer.togglePartyChatSpying();
}
@Override
protected void sendSuccessMessage(CommandSender sender, String playerName) {
sender.sendMessage(LocaleLoader.getString("Commands.AdminChatSpy.Toggle", playerName));
}
}

View File

@ -76,6 +76,7 @@ public class McMMOPlayer {
private boolean abilityUse = true; private boolean abilityUse = true;
private boolean godMode; private boolean godMode;
private boolean chatSpy = true;
private final Map<SuperAbility, Boolean> abilityMode = new HashMap<SuperAbility, Boolean>(); private final Map<SuperAbility, Boolean> abilityMode = new HashMap<SuperAbility, Boolean>();
private final Map<SuperAbility, Boolean> abilityInformed = new HashMap<SuperAbility, Boolean>(); private final Map<SuperAbility, Boolean> abilityInformed = new HashMap<SuperAbility, Boolean>();
@ -364,6 +365,14 @@ public class McMMOPlayer {
godMode = !godMode; godMode = !godMode;
} }
/*
* Party Chat Spy
*/
public boolean isPartyChatSpying() { return chatSpy; }
public void togglePartyChatSpying() { chatSpy = !chatSpy;}
/* /*
* Skill notifications * Skill notifications
*/ */

View File

@ -36,7 +36,6 @@ 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"); }
@ -64,6 +63,9 @@ public final class Permissions {
public static boolean mcability(Permissible permissible) { return (permissible.hasPermission("mcmmo.commands.mcability")); } public static boolean mcability(Permissible permissible) { return (permissible.hasPermission("mcmmo.commands.mcability")); }
public static boolean mcabilityOthers(Permissible permissible) { return (permissible.hasPermission("mcmmo.commands.mcability.others")); } public static boolean mcabilityOthers(Permissible permissible) { return (permissible.hasPermission("mcmmo.commands.mcability.others")); }
public static boolean adminChatSpy(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.mcchatspy");}
public static boolean adminChatSpyOthers(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.mcchatspy.others");}
public static boolean mcgod(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.mcgod"); } public static boolean mcgod(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.mcgod"); }
public static boolean mcgodOthers(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.mcgod.others"); } public static boolean mcgodOthers(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.mcgod.others"); }

View File

@ -3,6 +3,7 @@ package com.gmail.nossr50.util.commands;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.gmail.nossr50.commands.chat.McChatSpy;
import org.bukkit.command.PluginCommand; import org.bukkit.command.PluginCommand;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
@ -169,6 +170,15 @@ public final class CommandRegistrationManager {
command.setExecutor(new McgodCommand()); command.setExecutor(new McgodCommand());
} }
private static void registerMcChatSpyCommand() {
PluginCommand command = mcMMO.p.getCommand("mcchatspy");
command.setDescription(LocaleLoader.getString("Commands.Description.mcchatspy"));
command.setPermission("mcmmo.commands.mcchatspy;mcmmo.commands.mcchatspy.others");
command.setPermissionMessage(permissionsMessage);
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcchatspy", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]"));
command.setExecutor(new McChatSpy());
}
private static void registerMcrefreshCommand() { private static void registerMcrefreshCommand() {
PluginCommand command = mcMMO.p.getCommand("mcrefresh"); PluginCommand command = mcMMO.p.getCommand("mcrefresh");
command.setDescription(LocaleLoader.getString("Commands.Description.mcrefresh")); command.setDescription(LocaleLoader.getString("Commands.Description.mcrefresh"));
@ -435,6 +445,7 @@ public final class CommandRegistrationManager {
registerKrakenCommand(); registerKrakenCommand();
registerMcabilityCommand(); registerMcabilityCommand();
registerMcgodCommand(); registerMcgodCommand();
registerMcChatSpyCommand();
registerMcmmoCommand(); registerMcmmoCommand();
registerMcnotifyCommand(); registerMcnotifyCommand();
registerMcrefreshCommand(); registerMcrefreshCommand();

View File

@ -468,6 +468,9 @@ Commands.Disabled=[[RED]]This command is disabled.
Commands.DoesNotExist= [[RED]]Player does not exist in the database! Commands.DoesNotExist= [[RED]]Player does not exist in the database!
Commands.GodMode.Disabled=[[YELLOW]]mcMMO Godmode Disabled Commands.GodMode.Disabled=[[YELLOW]]mcMMO Godmode Disabled
Commands.GodMode.Enabled=[[YELLOW]]mcMMO Godmode Enabled Commands.GodMode.Enabled=[[YELLOW]]mcMMO Godmode Enabled
Commands.AdminChatSpy.Enabled=[[YELLOW]]mcMMO Party Chat Spy Enabled
Commands.AdminChatSpy.Disabled=[[YELLOW]]mcMMO Party Chat Spy Disabled
Commands.AdminChatSpy.Toggle=[[YELLOW]]mcMMO Party Chat has been toggled for [[YELLOW]]{0}
Commands.GodMode.Forbidden=[mcMMO] God Mode not permitted on this world (See Permissions) Commands.GodMode.Forbidden=[mcMMO] God Mode not permitted on this world (See Permissions)
Commands.GodMode.Toggle=God mode has been toggled for [[YELLOW]]{0} Commands.GodMode.Toggle=God mode has been toggled for [[YELLOW]]{0}
Commands.Healthbars.Changed.HEARTS=[mcMMO] Your healthbar display type was changed to [[RED]]Hearts[[WHITE]]. Commands.Healthbars.Changed.HEARTS=[mcMMO] Your healthbar display type was changed to [[RED]]Hearts[[WHITE]].
@ -934,6 +937,7 @@ Commands.Description.hardcore=Modify the mcMMO hardcore percentage or toggle har
Commands.Description.inspect=View detailed mcMMO info on another player Commands.Description.inspect=View detailed mcMMO info on another player
Commands.Description.mcability=Toggle mcMMO abilities being readied on right-click on/off Commands.Description.mcability=Toggle mcMMO abilities being readied on right-click on/off
Commands.Description.mccooldown=View all of the mcMMO ability cooldowns Commands.Description.mccooldown=View all of the mcMMO ability cooldowns
Commands.Description.mcchatspy=Toggle mcMMO party chat spying on or off
Commands.Description.mcgod=Toggle mcMMO god-mode on/off Commands.Description.mcgod=Toggle mcMMO god-mode on/off
Commands.Description.mchud=Change your mcMMO HUD style Commands.Description.mchud=Change your mcMMO HUD style
Commands.Description.mcmmo=Show a brief description of mcMMO Commands.Description.mcmmo=Show a brief description of mcMMO

View File

@ -48,6 +48,9 @@ commands:
description: Show the cooldowns on all your mcMMO abilities description: Show the cooldowns on all your mcMMO abilities
aliases: [mccooldowns] aliases: [mccooldowns]
permission: mcmmo.commands.mccooldown permission: mcmmo.commands.mccooldown
mcchatspy:
description: Toggle mcMMO Party Chat spying on/off
permission: mcmmo.commands.mcchatspy
mcgod: mcgod:
description: Toggle mcMMO god-mode on/off description: Toggle mcMMO god-mode on/off
permission: mcmmo.commands.mcgod permission: mcmmo.commands.mcgod
@ -690,12 +693,8 @@ 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.
@ -797,6 +796,8 @@ permissions:
mcmmo.commands.kraken.others: true mcmmo.commands.kraken.others: true
mcmmo.commands.mcability.others: true mcmmo.commands.mcability.others: true
mcmmo.commands.mcconvert.all: true mcmmo.commands.mcconvert.all: true
mcmmo.commands.mcchatspy: true
mcmmo.commands.mcchatspy.others: true
mcmmo.commands.mcgod: true mcmmo.commands.mcgod: true
mcmmo.commands.mcgod.others: true mcmmo.commands.mcgod.others: true
mcmmo.commands.mcimport: true mcmmo.commands.mcimport: true
@ -900,6 +901,10 @@ permissions:
description: Allows access to the mcgod command description: Allows access to the mcgod command
mcmmo.commands.mcgod.others: mcmmo.commands.mcgod.others:
description: Allows access to the mcgod command for other players description: Allows access to the mcgod command for other players
mcmmo.commands.mcchatspy:
description: Allows access to the mcchatspy command
mcmmo.commands.mcchatspy.others:
description: Allows access to the mcchatspy command for other players
mcmmo.commands.mcmmo.*: mcmmo.commands.mcmmo.*:
default: false default: false
description: Implies access to all mcmmo.commands.mcmmo permissions description: Implies access to all mcmmo.commands.mcmmo permissions