mirror of
				https://github.com/mcMMO-Dev/mcMMO.git
				synced 2025-10-26 23:03:44 +01:00 
			
		
		
		
	mcchatspy is now a command based instead of permission node based
This commit is contained in:
		| @@ -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 | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
							
								
								
									
										30
									
								
								src/main/java/com/gmail/nossr50/commands/chat/McChatSpy.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								src/main/java/com/gmail/nossr50/commands/chat/McChatSpy.java
									
									
									
									
									
										Normal 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)); | ||||
|     } | ||||
| } | ||||
| @@ -76,6 +76,7 @@ public class McMMOPlayer { | ||||
|  | ||||
|     private boolean abilityUse = true; | ||||
|     private boolean godMode; | ||||
|     private boolean chatSpy = true; | ||||
|  | ||||
|     private final Map<SuperAbility, Boolean> abilityMode     = new HashMap<SuperAbility, Boolean>(); | ||||
|     private final Map<SuperAbility, Boolean> abilityInformed = new HashMap<SuperAbility, Boolean>(); | ||||
| @@ -364,6 +365,14 @@ public class McMMOPlayer { | ||||
|         godMode = !godMode; | ||||
|     } | ||||
|  | ||||
|     /* | ||||
|      * Party Chat Spy | ||||
|      */ | ||||
|  | ||||
|     public boolean isPartyChatSpying() { return chatSpy; } | ||||
|  | ||||
|     public void togglePartyChatSpying() { chatSpy = !chatSpy;} | ||||
|  | ||||
|     /* | ||||
|      * Skill notifications | ||||
|      */ | ||||
|   | ||||
| @@ -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"); } | ||||
|  | ||||
|   | ||||
| @@ -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(); | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 nossr50
					nossr50