Added ability to disable setInvisible on disguise commands
This commit is contained in:
parent
24f88338c8
commit
0f0b0b820f
@ -104,6 +104,9 @@ HideDisguisedPlayersFromTab: false
|
|||||||
# Always show player disguises in tab? The names will continue to appear in tab until the disguise is removed.
|
# Always show player disguises in tab? The names will continue to appear in tab until the disguise is removed.
|
||||||
ShowPlayerDisguisesInTab: false
|
ShowPlayerDisguisesInTab: false
|
||||||
|
|
||||||
|
# Don't like players able to set themselves invisible when using the disguise commands? Toggle this to true and no one can use setInvisible! Plugins can still use this however.
|
||||||
|
DisableInvisibility: false
|
||||||
|
|
||||||
# This will help performance, especially with CPU
|
# This will help performance, especially with CPU
|
||||||
# Due to safety reasons, self disguises can never have their packets disabled.
|
# Due to safety reasons, self disguises can never have their packets disabled.
|
||||||
PacketsEnabled:
|
PacketsEnabled:
|
||||||
|
@ -22,6 +22,8 @@ public class DisguiseConfig {
|
|||||||
private static boolean collectEnabled;
|
private static boolean collectEnabled;
|
||||||
private static boolean colorizeSheep;
|
private static boolean colorizeSheep;
|
||||||
private static boolean colorizeWolf;
|
private static boolean colorizeWolf;
|
||||||
|
private static HashMap<String, Disguise> customDisguises = new HashMap<String, Disguise>();
|
||||||
|
private static boolean disableInvisibility;
|
||||||
private static String disguiseBlownMessage;
|
private static String disguiseBlownMessage;
|
||||||
private static int disguiseCloneExpire;
|
private static int disguiseCloneExpire;
|
||||||
private static int disguiseEntityExpire;
|
private static int disguiseEntityExpire;
|
||||||
@ -54,7 +56,21 @@ public class DisguiseConfig {
|
|||||||
private static String updateNotificationPermission;
|
private static String updateNotificationPermission;
|
||||||
private static boolean viewSelfDisguise;
|
private static boolean viewSelfDisguise;
|
||||||
private static boolean witherSkullEnabled;
|
private static boolean witherSkullEnabled;
|
||||||
private static HashMap<String, Disguise> customDisguises = new HashMap<String, Disguise>();
|
|
||||||
|
public static Entry<String, Disguise> getCustomDisguise(String disguise) {
|
||||||
|
for (Entry<String, Disguise> entry : customDisguises.entrySet()) {
|
||||||
|
if (!entry.getKey().equalsIgnoreCase(disguise) && !entry.getKey().replaceAll("_", "").equalsIgnoreCase(disguise))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HashMap<String, Disguise> getCustomDisguises() {
|
||||||
|
return customDisguises;
|
||||||
|
}
|
||||||
|
|
||||||
public static String getDisguiseBlownMessage() {
|
public static String getDisguiseBlownMessage() {
|
||||||
return disguiseBlownMessage;
|
return disguiseBlownMessage;
|
||||||
@ -119,6 +135,7 @@ public class DisguiseConfig {
|
|||||||
setStopShulkerDisguisesFromMoving(config.getBoolean("StopShulkerDisguisesFromMoving", true));
|
setStopShulkerDisguisesFromMoving(config.getBoolean("StopShulkerDisguisesFromMoving", true));
|
||||||
setHideDisguisedPlayers(config.getBoolean("HideDisguisedPlayersFromTab"));
|
setHideDisguisedPlayers(config.getBoolean("HideDisguisedPlayersFromTab"));
|
||||||
setShowDisguisedPlayersInTab(config.getBoolean("ShowPlayerDisguisesInTab"));
|
setShowDisguisedPlayersInTab(config.getBoolean("ShowPlayerDisguisesInTab"));
|
||||||
|
setDisabledInvisibility(config.getBoolean("DisableInvisibility"));
|
||||||
|
|
||||||
customDisguises.clear();
|
customDisguises.clear();
|
||||||
|
|
||||||
@ -168,21 +185,6 @@ public class DisguiseConfig {
|
|||||||
+ (customDisguises.size() == 1 ? "" : "s"));
|
+ (customDisguises.size() == 1 ? "" : "s"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HashMap<String, Disguise> getCustomDisguises() {
|
|
||||||
return customDisguises;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Entry<String, Disguise> getCustomDisguise(String disguise) {
|
|
||||||
for (Entry<String, Disguise> entry : customDisguises.entrySet()) {
|
|
||||||
if (!entry.getKey().equalsIgnoreCase(disguise) && !entry.getKey().replaceAll("_", "").equalsIgnoreCase(disguise))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
return entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isAnimationPacketsEnabled() {
|
public static boolean isAnimationPacketsEnabled() {
|
||||||
return animationEnabled;
|
return animationEnabled;
|
||||||
}
|
}
|
||||||
@ -195,6 +197,10 @@ public class DisguiseConfig {
|
|||||||
return collectEnabled;
|
return collectEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isDisabledInvisibility() {
|
||||||
|
return disableInvisibility;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isDisguiseBlownOnAttack() {
|
public static boolean isDisguiseBlownOnAttack() {
|
||||||
return blowDisguisesOnAttack;
|
return blowDisguisesOnAttack;
|
||||||
}
|
}
|
||||||
@ -354,6 +360,10 @@ public class DisguiseConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setDisabledInvisibility(boolean disableInvis) {
|
||||||
|
disableInvisibility = disableInvis;
|
||||||
|
}
|
||||||
|
|
||||||
public static void setDisguiseBlownMessage(String newMessage) {
|
public static void setDisguiseBlownMessage(String newMessage) {
|
||||||
disguiseBlownMessage = newMessage;
|
disguiseBlownMessage = newMessage;
|
||||||
}
|
}
|
||||||
|
@ -97,25 +97,9 @@ public abstract class DisguiseBaseCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean passesCheck(HashMap<ArrayList<String>, Boolean> theirPermissions, ArrayList<String> usedOptions) {
|
public boolean passesCheck(CommandSender sender, HashMap<ArrayList<String>, Boolean> theirPermissions,
|
||||||
boolean hasPermission = false;
|
ArrayList<String> usedOptions) {
|
||||||
|
return DisguiseParser.passesCheck(sender, theirPermissions, usedOptions);
|
||||||
for (ArrayList<String> list : theirPermissions.keySet()) {
|
|
||||||
boolean myPerms = true;
|
|
||||||
|
|
||||||
for (String option : usedOptions) {
|
|
||||||
if (!(theirPermissions.get(list) && list.contains("*"))
|
|
||||||
&& (list.contains(option) != theirPermissions.get(list))) {
|
|
||||||
myPerms = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (myPerms) {
|
|
||||||
hasPermission = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return hasPermission;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void sendCommandUsage(CommandSender sender,
|
protected abstract void sendCommandUsage(CommandSender sender,
|
||||||
|
@ -114,7 +114,7 @@ public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (passesCheck(perms.get(disguiseType), usedOptions)) {
|
if (passesCheck(sender, perms.get(disguiseType), usedOptions)) {
|
||||||
boolean addMethods = true;
|
boolean addMethods = true;
|
||||||
|
|
||||||
if (args.length > 1) {
|
if (args.length > 1) {
|
||||||
|
@ -98,7 +98,7 @@ public class DisguiseEntityCommand extends DisguiseBaseCommand implements TabCom
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (passesCheck(perms.get(disguiseType), usedOptions)) {
|
if (passesCheck(sender, perms.get(disguiseType), usedOptions)) {
|
||||||
boolean addMethods = true;
|
boolean addMethods = true;
|
||||||
|
|
||||||
if (args.length > 1) {
|
if (args.length > 1) {
|
||||||
|
@ -150,7 +150,7 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (passesCheck(perms.get(disguiseType), usedOptions)) {
|
if (passesCheck(sender, perms.get(disguiseType), usedOptions)) {
|
||||||
boolean addMethods = true;
|
boolean addMethods = true;
|
||||||
|
|
||||||
if (args.length > 2) {
|
if (args.length > 2) {
|
||||||
|
@ -261,7 +261,7 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (passesCheck(perms.get(disguiseType), usedOptions)) {
|
if (passesCheck(sender, perms.get(disguiseType), usedOptions)) {
|
||||||
boolean addMethods = true;
|
boolean addMethods = true;
|
||||||
|
|
||||||
if (args.length > 1 + starting) {
|
if (args.length > 1 + starting) {
|
||||||
|
@ -148,12 +148,12 @@ public class DisguiseParser {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void doCheck(HashMap<ArrayList<String>, Boolean> optionPermissions, ArrayList<String> usedOptions)
|
private static void doCheck(CommandSender sender, HashMap<ArrayList<String>, Boolean> optionPermissions,
|
||||||
throws DisguiseParseException {
|
ArrayList<String> usedOptions) throws DisguiseParseException {
|
||||||
|
|
||||||
if (!passesCheck(optionPermissions, usedOptions)) {
|
if (!passesCheck(sender, optionPermissions, usedOptions)) {
|
||||||
throw new DisguiseParseException(ChatColor.RED + "You do not have the permission to use the option "
|
throw new DisguiseParseException(
|
||||||
+ usedOptions.get(usedOptions.size() - 1));
|
ChatColor.RED + "You do not have permission to use the option " + usedOptions.get(usedOptions.size() - 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -569,7 +569,7 @@ public class DisguiseParser {
|
|||||||
if (args.length > 1) {
|
if (args.length > 1) {
|
||||||
if (args[1].equalsIgnoreCase("baby") || args[1].equalsIgnoreCase("adult")) {
|
if (args[1].equalsIgnoreCase("baby") || args[1].equalsIgnoreCase("adult")) {
|
||||||
usedOptions.add("setbaby");
|
usedOptions.add("setbaby");
|
||||||
doCheck(optionPermissions, usedOptions);
|
doCheck(sender, optionPermissions, usedOptions);
|
||||||
adult = args[1].equalsIgnoreCase("adult");
|
adult = args[1].equalsIgnoreCase("adult");
|
||||||
|
|
||||||
toSkip++;
|
toSkip++;
|
||||||
@ -668,17 +668,17 @@ public class DisguiseParser {
|
|||||||
if (disguisePerm.getType() == DisguiseType.FALLING_BLOCK) {
|
if (disguisePerm.getType() == DisguiseType.FALLING_BLOCK) {
|
||||||
usedOptions.add("setblock");
|
usedOptions.add("setblock");
|
||||||
|
|
||||||
doCheck(optionPermissions, usedOptions);
|
doCheck(sender, optionPermissions, usedOptions);
|
||||||
}
|
}
|
||||||
else if (disguisePerm.getType() == DisguiseType.PAINTING) {
|
else if (disguisePerm.getType() == DisguiseType.PAINTING) {
|
||||||
usedOptions.add("setpainting");
|
usedOptions.add("setpainting");
|
||||||
|
|
||||||
doCheck(optionPermissions, usedOptions);
|
doCheck(sender, optionPermissions, usedOptions);
|
||||||
}
|
}
|
||||||
else if (disguisePerm.getType() == DisguiseType.SPLASH_POTION) {
|
else if (disguisePerm.getType() == DisguiseType.SPLASH_POTION) {
|
||||||
usedOptions.add("setpotionid");
|
usedOptions.add("setpotionid");
|
||||||
|
|
||||||
doCheck(optionPermissions, usedOptions);
|
doCheck(sender, optionPermissions, usedOptions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Construct the disguise
|
// Construct the disguise
|
||||||
@ -961,7 +961,7 @@ public class DisguiseParser {
|
|||||||
usedOptions.add(methodName.toLowerCase());
|
usedOptions.add(methodName.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
doCheck(optionPermissions, usedOptions);
|
doCheck(sender, optionPermissions, usedOptions);
|
||||||
|
|
||||||
if (FlagWatcher.class.isAssignableFrom(methodToUse.getDeclaringClass())) {
|
if (FlagWatcher.class.isAssignableFrom(methodToUse.getDeclaringClass())) {
|
||||||
methodToUse.invoke(disguise.getWatcher(), value);
|
methodToUse.invoke(disguise.getWatcher(), value);
|
||||||
@ -1020,13 +1020,19 @@ public class DisguiseParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean passesCheck(HashMap<ArrayList<String>, Boolean> theirPermissions, ArrayList<String> usedOptions) {
|
public static boolean passesCheck(CommandSender sender, HashMap<ArrayList<String>, Boolean> theirPermissions,
|
||||||
|
ArrayList<String> usedOptions) {
|
||||||
boolean hasPermission = false;
|
boolean hasPermission = false;
|
||||||
|
|
||||||
for (ArrayList<String> list : theirPermissions.keySet()) {
|
for (ArrayList<String> list : theirPermissions.keySet()) {
|
||||||
boolean myPerms = true;
|
boolean myPerms = true;
|
||||||
|
|
||||||
for (String option : usedOptions) {
|
for (String option : usedOptions) {
|
||||||
|
if (!sender.getName().equals("CONSOLE") && option.equalsIgnoreCase("setInvisible")
|
||||||
|
&& DisguiseConfig.isDisabledInvisibility()) {
|
||||||
|
myPerms = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(theirPermissions.get(list) && list.contains("*"))
|
if (!(theirPermissions.get(list) && list.contains("*"))
|
||||||
&& (list.contains(option) != theirPermissions.get(list))) {
|
&& (list.contains(option) != theirPermissions.get(list))) {
|
||||||
myPerms = false;
|
myPerms = false;
|
||||||
@ -1038,6 +1044,7 @@ public class DisguiseParser {
|
|||||||
hasPermission = true;
|
hasPermission = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return hasPermission;
|
return hasPermission;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user