diff --git a/Changelog.txt b/Changelog.txt index 3fa9d3b3b..b854822f8 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -13,8 +13,9 @@ 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 + + (Chat) Added ability for admins to spy on party chat (off unless toggled on) + + (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 ! 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 93bed810e..cb8497d3b 100644 --- a/src/main/java/com/gmail/nossr50/chat/ChatManager.java +++ b/src/main/java/com/gmail/nossr50/chat/ChatManager.java @@ -2,11 +2,9 @@ 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; @@ -38,19 +36,26 @@ public abstract class ChatManager { displayName = useDisplayNames ? event.getDisplayName() : senderName; message = LocaleLoader.formatString(chatPrefix, displayName) + " " + event.getMessage(); - sendMessage(); + /* + * Party Chat Spying + * Party messages will be copied to people with the mcmmo.admin.chatspy permission node + */ if(event instanceof McMMOPartyChatEvent) { + //We need to grab the party chat name McMMOPartyChatEvent partyChatEvent = (McMMOPartyChatEvent) event; + //Find the people with permissions for(Player player : event.getPlugin().getServer().getOnlinePlayers()) { - //TODO: Online check necessary? - if(player.isOnline() && Permissions.adminChatSpy(player)) + //Check for toggled players + if(UserManager.getPlayer(player).isPartyChatSpying()) { Party adminParty = UserManager.getPlayer(player).getParty(); + + //Only message admins not part of this party if(adminParty != null && !adminParty.getName().equalsIgnoreCase(partyChatEvent.getParty())) { //TODO: Incorporate JSON diff --git a/src/main/java/com/gmail/nossr50/commands/chat/McChatSpy.java b/src/main/java/com/gmail/nossr50/commands/chat/McChatSpy.java new file mode 100644 index 000000000..daa46c57b --- /dev/null +++ b/src/main/java/com/gmail/nossr50/commands/chat/McChatSpy.java @@ -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)); + } +} diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java index 12c0fd69b..e588ed151 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -76,6 +76,7 @@ public class McMMOPlayer { private boolean abilityUse = true; private boolean godMode; + private boolean chatSpy = true; private final Map abilityMode = new HashMap(); private final Map abilityInformed = new HashMap(); @@ -364,6 +365,14 @@ public class McMMOPlayer { godMode = !godMode; } + /* + * Party Chat Spy + */ + + public boolean isPartyChatSpying() { return chatSpy; } + + public void togglePartyChatSpying() { chatSpy = !chatSpy;} + /* * Skill notifications */ diff --git a/src/main/java/com/gmail/nossr50/util/Permissions.java b/src/main/java/com/gmail/nossr50/util/Permissions.java index 4b617da07..faec531cb 100644 --- a/src/main/java/com/gmail/nossr50/util/Permissions.java +++ b/src/main/java/com/gmail/nossr50/util/Permissions.java @@ -36,7 +36,6 @@ 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"); } @@ -64,6 +63,9 @@ public final class Permissions { 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 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 mcgodOthers(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.mcgod.others"); } diff --git a/src/main/java/com/gmail/nossr50/util/commands/CommandRegistrationManager.java b/src/main/java/com/gmail/nossr50/util/commands/CommandRegistrationManager.java index 1018357b1..ce8c08930 100644 --- a/src/main/java/com/gmail/nossr50/util/commands/CommandRegistrationManager.java +++ b/src/main/java/com/gmail/nossr50/util/commands/CommandRegistrationManager.java @@ -3,6 +3,7 @@ package com.gmail.nossr50.util.commands; import java.util.ArrayList; import java.util.List; +import com.gmail.nossr50.commands.chat.McChatSpy; import org.bukkit.command.PluginCommand; import com.gmail.nossr50.mcMMO; @@ -169,6 +170,15 @@ public final class CommandRegistrationManager { 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() { PluginCommand command = mcMMO.p.getCommand("mcrefresh"); command.setDescription(LocaleLoader.getString("Commands.Description.mcrefresh")); @@ -435,6 +445,7 @@ public final class CommandRegistrationManager { registerKrakenCommand(); registerMcabilityCommand(); registerMcgodCommand(); + registerMcChatSpyCommand(); registerMcmmoCommand(); registerMcnotifyCommand(); registerMcrefreshCommand(); diff --git a/src/main/resources/locale/locale_en_US.properties b/src/main/resources/locale/locale_en_US.properties index 13a2c1722..b9e787c58 100644 --- a/src/main/resources/locale/locale_en_US.properties +++ b/src/main/resources/locale/locale_en_US.properties @@ -468,6 +468,9 @@ Commands.Disabled=[[RED]]This command is disabled. Commands.DoesNotExist= [[RED]]Player does not exist in the database! Commands.GodMode.Disabled=[[YELLOW]]mcMMO Godmode Disabled 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.Toggle=God mode has been toggled for [[YELLOW]]{0} 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.mcability=Toggle mcMMO abilities being readied on right-click on/off 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.mchud=Change your mcMMO HUD style Commands.Description.mcmmo=Show a brief description of mcMMO diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 26869cbf4..05d5d3388 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -48,6 +48,9 @@ commands: description: Show the cooldowns on all your mcMMO abilities aliases: [mccooldowns] permission: mcmmo.commands.mccooldown + mcchatspy: + description: Toggle mcMMO Party Chat spying on/off + permission: mcmmo.commands.mcchatspy mcgod: description: Toggle mcMMO god-mode on/off permission: mcmmo.commands.mcgod @@ -690,12 +693,8 @@ 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. @@ -797,6 +796,8 @@ permissions: mcmmo.commands.kraken.others: true mcmmo.commands.mcability.others: true mcmmo.commands.mcconvert.all: true + mcmmo.commands.mcchatspy: true + mcmmo.commands.mcchatspy.others: true mcmmo.commands.mcgod: true mcmmo.commands.mcgod.others: true mcmmo.commands.mcimport: true @@ -900,6 +901,10 @@ permissions: description: Allows access to the mcgod command mcmmo.commands.mcgod.others: 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.*: default: false description: Implies access to all mcmmo.commands.mcmmo permissions