diff --git a/src/main/java/me/libraryaddict/disguise/DisguiseListener.java b/src/main/java/me/libraryaddict/disguise/DisguiseListener.java index 6f4dc0c1..713be9c0 100644 --- a/src/main/java/me/libraryaddict/disguise/DisguiseListener.java +++ b/src/main/java/me/libraryaddict/disguise/DisguiseListener.java @@ -537,8 +537,9 @@ public class DisguiseListener implements Listener { } try { - DisguiseParser.callMethods(p, disguise, perms, disguisePerm, new ArrayList<>(Arrays.asList(options)), - options); + DisguiseParser + .callMethods(p, disguise, perms, disguisePerm, new ArrayList<>(Arrays.asList(options)), options, + "DisguiseModifyEntity"); p.sendMessage(LibsMsg.LISTENER_MODIFIED_DISG.get()); } catch (DisguiseParseException ex) { diff --git a/src/main/java/me/libraryaddict/disguise/commands/DisguiseModifyCommand.java b/src/main/java/me/libraryaddict/disguise/commands/DisguiseModifyCommand.java index 1200e8ab..801e3074 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/DisguiseModifyCommand.java +++ b/src/main/java/me/libraryaddict/disguise/commands/DisguiseModifyCommand.java @@ -58,7 +58,8 @@ public class DisguiseModifyCommand extends DisguiseBaseCommand implements TabCom options = DisguiseParser.parsePlaceholders(options, sender, sender); try { - DisguiseParser.callMethods(sender, disguise, permissions, disguisePerm, new ArrayList<>(), options); + DisguiseParser.callMethods(sender, disguise, permissions, disguisePerm, new ArrayList<>(), options, + "DisguiseModify"); } catch (DisguiseParseException ex) { if (ex.getMessage() != null) { diff --git a/src/main/java/me/libraryaddict/disguise/commands/DisguiseModifyPlayerCommand.java b/src/main/java/me/libraryaddict/disguise/commands/DisguiseModifyPlayerCommand.java index fbbec796..08119e4f 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/DisguiseModifyPlayerCommand.java +++ b/src/main/java/me/libraryaddict/disguise/commands/DisguiseModifyPlayerCommand.java @@ -87,7 +87,8 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements options = DisguiseParser.parsePlaceholders(options, sender, entityTarget); try { - DisguiseParser.callMethods(sender, disguise, permissions, disguisePerm, new ArrayList<>(), options); + DisguiseParser.callMethods(sender, disguise, permissions, disguisePerm, new ArrayList<>(), options, + "DisguiseModifyPlayer"); } catch (DisguiseParseException ex) { if (ex.getMessage() != null) { diff --git a/src/main/java/me/libraryaddict/disguise/commands/DisguiseModifyRadiusCommand.java b/src/main/java/me/libraryaddict/disguise/commands/DisguiseModifyRadiusCommand.java index 6e07d6a4..2f61b919 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/DisguiseModifyRadiusCommand.java +++ b/src/main/java/me/libraryaddict/disguise/commands/DisguiseModifyRadiusCommand.java @@ -154,7 +154,8 @@ public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements tempArgs = DisguiseParser.parsePlaceholders(tempArgs, sender, entity); try { - DisguiseParser.callMethods(sender, disguise, permissions, disguisePerm, new ArrayList<>(), tempArgs); + DisguiseParser.callMethods(sender, disguise, permissions, disguisePerm, new ArrayList<>(), tempArgs, + "DisguiseModifyRadius"); modifiedDisguises++; } catch (DisguiseParseException ex) { diff --git a/src/main/java/me/libraryaddict/disguise/utilities/parser/DisguiseParser.java b/src/main/java/me/libraryaddict/disguise/utilities/parser/DisguiseParser.java index bb47926b..881ee773 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/parser/DisguiseParser.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/parser/DisguiseParser.java @@ -335,6 +335,7 @@ public class DisguiseParser { * Returns if command user can access the disguise creation permission type */ private static boolean hasPermissionOption(HashMap disguiseOptions, String string) { + string = string.toLowerCase(); // If no permissions were defined, return true if (disguiseOptions.isEmpty()) { return true; @@ -712,18 +713,19 @@ public class DisguiseParser { String[] newArgs = new String[args.length - toSkip]; System.arraycopy(args, toSkip, newArgs, 0, args.length - toSkip); - callMethods(sender, disguise, permissions, disguisePerm, usedOptions, newArgs); + callMethods(sender, disguise, permissions, disguisePerm, usedOptions, newArgs, permNode); // Alright. We've constructed our disguise. return disguise; } public static void callMethods(CommandSender sender, Disguise disguise, DisguisePermissions disguisePermission, - DisguisePerm disguisePerm, Collection usedOptions, - String[] args) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, + DisguisePerm disguisePerm, Collection usedOptions, String[] args, + String permNode) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, DisguiseParseException { Method[] methods = ParamInfoManager.getDisguiseWatcherMethods(disguise.getWatcher().getClass()); List list = new ArrayList<>(Arrays.asList(args)); + HashMap disguiseOptions = null; for (int argIndex = 0; argIndex < args.length; argIndex++) { // This is the method name they provided @@ -788,6 +790,22 @@ public class DisguiseParser { usedOptions.add(methodToUse.getName().toLowerCase()); } + if (methodToUse.getName().equalsIgnoreCase("setpainting") || + methodToUse.getName().equalsIgnoreCase("setpotionid") || + methodToUse.getName().equalsIgnoreCase("setitemstack") || + methodToUse.getName().equalsIgnoreCase("setblock")) { + if (disguiseOptions == null) { + disguiseOptions = getDisguiseOptions(sender, permNode, disguisePerm); + } + + String stringValue = ParamInfoManager.toString(valueToSet); + + if (!hasPermissionOption(disguiseOptions, valueToSet + "")) { + throw new DisguiseParseException(LibsMsg.PARSE_NO_PERM_PARAM, stringValue, + disguisePerm.toReadable()); + } + } + doCheck(sender, disguisePermission, disguisePerm, usedOptions); if (FlagWatcher.class.isAssignableFrom(methodToUse.getDeclaringClass())) {