Remove disguises from tab complete and prevent all usage by changing required permission in config, closes #432
This commit is contained in:
		| @@ -18,11 +18,14 @@ import org.bukkit.command.CommandSender; | |||||||
| import org.bukkit.configuration.ConfigurationSection; | import org.bukkit.configuration.ConfigurationSection; | ||||||
| import org.bukkit.configuration.file.YamlConfiguration; | import org.bukkit.configuration.file.YamlConfiguration; | ||||||
| import org.bukkit.entity.Entity; | import org.bukkit.entity.Entity; | ||||||
|  | import org.bukkit.permissions.Permission; | ||||||
|  | import org.bukkit.permissions.PermissionDefault; | ||||||
|  |  | ||||||
| import java.io.File; | import java.io.File; | ||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
| import java.io.PrintWriter; | import java.io.PrintWriter; | ||||||
| import java.lang.reflect.InvocationTargetException; | import java.lang.reflect.InvocationTargetException; | ||||||
|  | import java.util.ArrayList; | ||||||
| import java.util.HashMap; | import java.util.HashMap; | ||||||
| import java.util.Iterator; | import java.util.Iterator; | ||||||
| import java.util.Map.Entry; | import java.util.Map.Entry; | ||||||
| @@ -209,6 +212,27 @@ public class DisguiseConfig { | |||||||
|     @Getter |     @Getter | ||||||
|     @Setter |     @Setter | ||||||
|     private static boolean notifyPlayerDisguised; |     private static boolean notifyPlayerDisguised; | ||||||
|  |     private static PermissionDefault commandVisibility = PermissionDefault.TRUE; | ||||||
|  |  | ||||||
|  |     public static PermissionDefault getCommandVisibility() { | ||||||
|  |         return commandVisibility; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public static void setCommandVisibility(PermissionDefault permissionDefault) { | ||||||
|  |         if (permissionDefault == null || getCommandVisibility() == permissionDefault) { | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         commandVisibility = permissionDefault; | ||||||
|  |  | ||||||
|  |         for (Permission perm : LibsDisguises.getInstance().getDescription().getPermissions()) { | ||||||
|  |             if (!perm.getName().startsWith("libsdisguises.seecmd")) { | ||||||
|  |                 continue; | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             perm.setDefault(getCommandVisibility()); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|     private DisguiseConfig() { |     private DisguiseConfig() { | ||||||
|     } |     } | ||||||
| @@ -410,6 +434,15 @@ public class DisguiseConfig { | |||||||
|                     "' to a valid option for SelfDisguisesScoreboard"); |                     "' to a valid option for SelfDisguisesScoreboard"); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         PermissionDefault commandVisibility = PermissionDefault.getByName(config.getString("Permissions.SeeCommands")); | ||||||
|  |  | ||||||
|  |         if (commandVisibility == null) { | ||||||
|  |             DisguiseUtilities.getLogger().warning("Invalid option '" + config.getString("Permissions.SeeCommands") + | ||||||
|  |                     "' for Permissions.SeeCommands when loading config!"); | ||||||
|  |         } else { | ||||||
|  |             setCommandVisibility(commandVisibility); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         loadCustomDisguises(); |         loadCustomDisguises(); | ||||||
|  |  | ||||||
|         // Another wee trap for the non-legit |         // Another wee trap for the non-legit | ||||||
|   | |||||||
| @@ -14,6 +14,20 @@ Permissions: | |||||||
|   # negate with your permissions plugin |   # negate with your permissions plugin | ||||||
|   ExplicitDisguises: false |   ExplicitDisguises: false | ||||||
|  |  | ||||||
|  |   # What should the default permissions be for seeing commands? | ||||||
|  |   # This is a config option because I can't verify if they should be able to see commands normally due to my | ||||||
|  |   # permissions system. My system is complex, but its a ton of control. | ||||||
|  |   # This isn't an issue normally, but I recently received complaints from someone who doesn't believe in permissions... | ||||||
|  |   # Some of you may also wish to hide these commands! | ||||||
|  |   # The permissions for commands are a simple 'libsdisguises.seecmd.command' where 'command' can be | ||||||
|  |   # 'disguise', 'undisguise' etc. A simple 'libsdisguises.seecmd' permission may also work for children | ||||||
|  |   # If you change this while the server is running, players may need to rejoin for it to take effect | ||||||
|  |   # TRUE = Everyone can see this, the default. Can be negated with permissions | ||||||
|  |   # FALSE = No one can see this without permissions to allow it | ||||||
|  |   # OP = Only operators can see this | ||||||
|  |   # NOT_OP = Only non operators can see this | ||||||
|  |   SeeCommands: TRUE | ||||||
|  |  | ||||||
| # Disables commands with the exception of /libsdisguises. Useful if you don't want the plugin to be used by anything | # Disables commands with the exception of /libsdisguises. Useful if you don't want the plugin to be used by anything | ||||||
| #  but a plugin | #  but a plugin | ||||||
| # Useful if you didn't purchase the plugin. | # Useful if you didn't purchase the plugin. | ||||||
|   | |||||||
| @@ -11,7 +11,6 @@ api-version: 1.13 | |||||||
| commands: | commands: | ||||||
|     libsdisguises: |     libsdisguises: | ||||||
|       aliases: [libsdisg, ld] |       aliases: [libsdisg, ld] | ||||||
|       #permission: libsdisguises.seecmd.libsdisguises |  | ||||||
|       description: Main command for libsdisguises. |       description: Main command for libsdisguises. | ||||||
|     disguise: |     disguise: | ||||||
|       aliases: [d, dis] |       aliases: [d, dis] | ||||||
| @@ -117,7 +116,6 @@ permissions: | |||||||
|       description: See all commands in tab-completion |       description: See all commands in tab-completion | ||||||
|       default: true |       default: true | ||||||
|       children: |       children: | ||||||
|          #libsdisguises.seecmd.libsdisguises: true |  | ||||||
|          libsdisguises.seecmd.disguise: true |          libsdisguises.seecmd.disguise: true | ||||||
|          libsdisguises.seecmd.disguiseentity: true |          libsdisguises.seecmd.disguiseentity: true | ||||||
|          libsdisguises.seecmd.disguisehelp: true |          libsdisguises.seecmd.disguisehelp: true | ||||||
| @@ -136,8 +134,6 @@ permissions: | |||||||
|          libsdisguises.seecmd.copydisguise: true |          libsdisguises.seecmd.copydisguise: true | ||||||
|          libsdisguises.seecmd.grabskin: true |          libsdisguises.seecmd.grabskin: true | ||||||
|          libsdisguises.seecmd.savedisguise: true |          libsdisguises.seecmd.savedisguise: true | ||||||
|     libsdisguises.seecmd.libsdisguises: |  | ||||||
|       description: See the /libsdisguises command in tab-completion |  | ||||||
|     libsdisguises.seecmd.disguiseviewself: |     libsdisguises.seecmd.disguiseviewself: | ||||||
|       description: See the /disguiseviewself command in tab-completion |       description: See the /disguiseviewself command in tab-completion | ||||||
|     libsdisguises.seecmd.disguise: |     libsdisguises.seecmd.disguise: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user