Also refresh permissions when a custom disguise is added

This commit is contained in:
libraryaddict 2023-12-02 12:39:48 +13:00
parent e3cf06db0c
commit ddfa521d13
2 changed files with 6 additions and 22 deletions

View File

@ -994,6 +994,7 @@ public class DisguiseConfig {
customDisguises.put(perm, toParse); customDisguises.put(perm, toParse);
DisguiseUtilities.getLogger().info("Loaded custom disguise " + disguiseName); DisguiseUtilities.getLogger().info("Loaded custom disguise " + disguiseName);
DisguisePermissions.onReload();
} catch (DisguiseParseException e) { } catch (DisguiseParseException e) {
throw new DisguiseParseException(LibsMsg.ERROR_LOADING_CUSTOM_DISGUISE, disguiseName, (e.getMessage() == null ? "" : ": " + e.getMessage())); throw new DisguiseParseException(LibsMsg.ERROR_LOADING_CUSTOM_DISGUISE, disguiseName, (e.getMessage() == null ? "" : ": " + e.getMessage()));
} catch (Throwable e) { } catch (Throwable e) {

View File

@ -1,5 +1,6 @@
package me.libraryaddict.disguise.utilities.parser; package me.libraryaddict.disguise.utilities.parser;
import lombok.Getter;
import me.libraryaddict.disguise.DisguiseConfig; import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.disguisetypes.DisguiseType; import me.libraryaddict.disguise.disguisetypes.DisguiseType;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -42,6 +43,7 @@ public class DisguisePermissions {
private static class ParsedPermission { private static class ParsedPermission {
private final Vector<DisguisePerm> disguisePerm; private final Vector<DisguisePerm> disguisePerm;
private final HashMap<String, Boolean> options; private final HashMap<String, Boolean> options;
@Getter
private boolean negated; private boolean negated;
/** /**
* 0 = Names a specific disguise * 0 = Names a specific disguise
@ -50,7 +52,9 @@ public class DisguisePermissions {
* 3... = etc * 3... = etc
* 4 = * = Disguise wildcard * 4 = * = Disguise wildcard
*/ */
@Getter
private final byte inheritance; private final byte inheritance;
@Getter
private final boolean wildcardCommand; private final boolean wildcardCommand;
public ParsedPermission(DisguisePerm[] disguisePerm, HashMap<String, Boolean> options, byte inheritance, boolean wildcardCommand) { public ParsedPermission(DisguisePerm[] disguisePerm, HashMap<String, Boolean> options, byte inheritance, boolean wildcardCommand) {
@ -60,27 +64,17 @@ public class DisguisePermissions {
this.wildcardCommand = wildcardCommand; this.wildcardCommand = wildcardCommand;
} }
public boolean isWildcardCommand() {
return wildcardCommand;
}
public boolean isDisguise(DisguisePerm perm) { public boolean isDisguise(DisguisePerm perm) {
return disguisePerm.contains(perm); return disguisePerm.contains(perm);
} }
public boolean isNegated() {
return negated;
}
public void setNegated(boolean negated) { public void setNegated(boolean negated) {
this.negated = negated; this.negated = negated;
} }
public byte getInheritance() {
return inheritance;
}
} }
@Getter
static class DisguisePermitted { static class DisguisePermitted {
private final boolean strictAllowed; private final boolean strictAllowed;
private final List<String> optionsAllowed; private final List<String> optionsAllowed;
@ -92,17 +86,6 @@ public class DisguisePermissions {
this.optionsForbidden = optionsForbidden; this.optionsForbidden = optionsForbidden;
} }
public boolean isStrictAllowed() {
return strictAllowed;
}
public List<String> getOptionsAllowed() {
return optionsAllowed;
}
public List<String> getOptionsForbidden() {
return optionsForbidden;
}
} }
/** /**