Remove disguises from tab complete and prevent all usage by changing required permission in config, closes #432

This commit is contained in:
libraryaddict 2020-03-12 15:22:55 +13:00
parent 07ed5908b9
commit 1a12a80a32
No known key found for this signature in database
GPG Key ID: 052E4FBCD257AEA4
3 changed files with 47 additions and 4 deletions

@ -18,11 +18,14 @@ import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Entity;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
@ -209,6 +212,27 @@ public class DisguiseConfig {
@Getter
@Setter
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() {
}
@ -410,6 +434,15 @@ public class DisguiseConfig {
"' 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();
// Another wee trap for the non-legit

@ -14,6 +14,20 @@ Permissions:
# negate with your permissions plugin
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
# but a plugin
# Useful if you didn't purchase the plugin.

@ -11,7 +11,6 @@ api-version: 1.13
commands:
libsdisguises:
aliases: [libsdisg, ld]
#permission: libsdisguises.seecmd.libsdisguises
description: Main command for libsdisguises.
disguise:
aliases: [d, dis]
@ -117,7 +116,6 @@ permissions:
description: See all commands in tab-completion
default: true
children:
#libsdisguises.seecmd.libsdisguises: true
libsdisguises.seecmd.disguise: true
libsdisguises.seecmd.disguiseentity: true
libsdisguises.seecmd.disguisehelp: true
@ -136,8 +134,6 @@ permissions:
libsdisguises.seecmd.copydisguise: true
libsdisguises.seecmd.grabskin: true
libsdisguises.seecmd.savedisguise: true
libsdisguises.seecmd.libsdisguises:
description: See the /libsdisguises command in tab-completion
libsdisguises.seecmd.disguiseviewself:
description: See the /disguiseviewself command in tab-completion
libsdisguises.seecmd.disguise: