Add config options to disable commands, explicit permissions definitions
This commit is contained in:
parent
fd05c7a5dd
commit
19d3053201
@ -66,6 +66,23 @@ public class DisguiseConfig {
|
|||||||
private static boolean modifyCollisions;
|
private static boolean modifyCollisions;
|
||||||
private static boolean disableFriendlyInvisibles;
|
private static boolean disableFriendlyInvisibles;
|
||||||
private static boolean warnScoreboardConflict;
|
private static boolean warnScoreboardConflict;
|
||||||
|
private static boolean explicitDisguisePermissions;
|
||||||
|
private static boolean disableCommands;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* No setter provided as this cannot be changed after startup
|
||||||
|
*/
|
||||||
|
public static boolean isDisableCommands() {
|
||||||
|
return disableCommands;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isExplicitDisguisePermissions() {
|
||||||
|
return explicitDisguisePermissions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setExplicitDisguisePermissions(boolean explictDisguisePermission) {
|
||||||
|
explicitDisguisePermissions = explictDisguisePermission;
|
||||||
|
}
|
||||||
|
|
||||||
public static Entry<String, Disguise> getCustomDisguise(String disguise) {
|
public static Entry<String, Disguise> getCustomDisguise(String disguise) {
|
||||||
for (Entry<String, Disguise> entry : customDisguises.entrySet()) {
|
for (Entry<String, Disguise> entry : customDisguises.entrySet()) {
|
||||||
@ -226,6 +243,8 @@ public class DisguiseConfig {
|
|||||||
setModifyCollisions(config.getBoolean("Scoreboard.Collisions"));
|
setModifyCollisions(config.getBoolean("Scoreboard.Collisions"));
|
||||||
setDisableFriendlyInvisibles(config.getBoolean("Scoreboard.DisableFriendlyInvisibles"));
|
setDisableFriendlyInvisibles(config.getBoolean("Scoreboard.DisableFriendlyInvisibles"));
|
||||||
setWarnScoreboardConflict(config.getBoolean("Scoreboard.WarnConflict"));
|
setWarnScoreboardConflict(config.getBoolean("Scoreboard.WarnConflict"));
|
||||||
|
disableCommands = config.getBoolean("DisableCommands");
|
||||||
|
setExplicitDisguisePermissions(config.getBoolean("Permissions.ExplictDisguises"));
|
||||||
|
|
||||||
if (!LibsPremium.isPremium() && (isSavePlayerDisguises() || isSaveEntityDisguises())) {
|
if (!LibsPremium.isPremium() && (isSavePlayerDisguises() || isSaveEntityDisguises())) {
|
||||||
DisguiseUtilities.getLogger().warning("You must purchase the plugin to use saved disguises!");
|
DisguiseUtilities.getLogger().warning("You must purchase the plugin to use saved disguises!");
|
||||||
|
@ -69,6 +69,7 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
|
|
||||||
Bukkit.getPluginManager().registerEvents(listener, this);
|
Bukkit.getPluginManager().registerEvents(listener, this);
|
||||||
|
|
||||||
|
if (!DisguiseConfig.isDisableCommands()) {
|
||||||
registerCommand("disguise", new DisguiseCommand());
|
registerCommand("disguise", new DisguiseCommand());
|
||||||
registerCommand("undisguise", new UndisguiseCommand());
|
registerCommand("undisguise", new UndisguiseCommand());
|
||||||
registerCommand("disguiseplayer", new DisguisePlayerCommand());
|
registerCommand("disguiseplayer", new DisguisePlayerCommand());
|
||||||
@ -86,6 +87,7 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
registerCommand("disguisemodifyplayer", new DisguiseModifyPlayerCommand());
|
registerCommand("disguisemodifyplayer", new DisguiseModifyPlayerCommand());
|
||||||
registerCommand("disguisemodifyradius",
|
registerCommand("disguisemodifyradius",
|
||||||
new DisguiseModifyRadiusCommand(getConfig().getInt("DisguiseRadiusMax")));
|
new DisguiseModifyRadiusCommand(getConfig().getInt("DisguiseRadiusMax")));
|
||||||
|
}
|
||||||
|
|
||||||
infectWithMetrics();
|
infectWithMetrics();
|
||||||
}
|
}
|
||||||
@ -230,8 +232,17 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
});
|
});
|
||||||
|
|
||||||
metrics.addCustomChart(new Metrics.SimplePie("targeted_disguises") {
|
metrics.addCustomChart(new Metrics.SimplePie("targeted_disguises") {
|
||||||
|
/**
|
||||||
|
* Store value just to minimize amount of times it's called, and to persist even when not using anymore
|
||||||
|
*/
|
||||||
|
private boolean targetedDisguises;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
|
if (targetedDisguises) {
|
||||||
|
return "Yes";
|
||||||
|
}
|
||||||
|
|
||||||
Collection<HashSet<TargetedDisguise>> list = DisguiseUtilities.getDisguises().values();
|
Collection<HashSet<TargetedDisguise>> list = DisguiseUtilities.getDisguises().values();
|
||||||
|
|
||||||
if (list.isEmpty())
|
if (list.isEmpty())
|
||||||
@ -242,6 +253,7 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
if (disg.getObservers().isEmpty())
|
if (disg.getObservers().isEmpty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
targetedDisguises = true;
|
||||||
return "Yes";
|
return "Yes";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -189,12 +189,10 @@ public class DisguisePermissions {
|
|||||||
Map<String, Boolean> permissions = new HashMap<>();
|
Map<String, Boolean> permissions = new HashMap<>();
|
||||||
|
|
||||||
// If the command sender is OP, then this will work even as the below code doesn't
|
// If the command sender is OP, then this will work even as the below code doesn't
|
||||||
for (String perm : new String[]{permissionNode + "*", "libsdisguises.*.*"}) {
|
// libsdisguises.[command].[disguise].[options]
|
||||||
if (!sender.hasPermission(perm)) {
|
// They can use all commands, all disguises, all options
|
||||||
continue;
|
if (sender.hasPermission("libsdisguises.*.*.*")) {
|
||||||
}
|
permissions.put("libsdisguises.*.*.*", true);
|
||||||
|
|
||||||
permissions.put(perm, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (PermissionAttachmentInfo permission : sender.getEffectivePermissions()) {
|
for (PermissionAttachmentInfo permission : sender.getEffectivePermissions()) {
|
||||||
@ -294,8 +292,9 @@ public class DisguisePermissions {
|
|||||||
disabled = false;
|
disabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the child disguise does not have any options defined, give them wildcard by default
|
// If the child disguise does not have any options defined, give them wildcard by default if
|
||||||
if (parsedPermission.options.isEmpty()) {
|
// config allows
|
||||||
|
if (parsedPermission.options.isEmpty() && !DisguiseConfig.isExplictDisguisePermissions()) {
|
||||||
storage.wildcardAllow = true;
|
storage.wildcardAllow = true;
|
||||||
// If this disguise has options defined, unless wildcard was explictly given then remove it
|
// If this disguise has options defined, unless wildcard was explictly given then remove it
|
||||||
} else if (!storage.permittedOptions.contains("*")) {
|
} else if (!storage.permittedOptions.contains("*")) {
|
||||||
|
@ -1,5 +1,22 @@
|
|||||||
# Shall I notify people of a LibsDisguises update?
|
Permissions:
|
||||||
NotifyUpdate: true
|
# By default "libsdisguises.disguise.cow" will allow all options for cow disguise unless another permission has
|
||||||
|
# defined otherwise.
|
||||||
|
# If given "libsdisguises.disguise.animals.setburning" then "libsdisguises.disguise.cow" they will still be able to
|
||||||
|
# use other options like "setbaby". This was provided for backwards compatibility.
|
||||||
|
# By turning this from 'false' to 'true' the plugin will no longer give them the options unless the player was
|
||||||
|
# explicitly granted it. Even if by wildcard. The above example means they can only use "setburning"
|
||||||
|
|
||||||
|
# To summerize, "libsdisguises.disguise.cow" will no longer let them do any options on the cow disguise unless it
|
||||||
|
# was added to their permissions
|
||||||
|
|
||||||
|
# You can read more about permissions here: https://www.spigotmc.org/wiki/lib-s-disguises-setting-up-permissions/
|
||||||
|
# The permission used to check OPs who may not have permissions defined, is "libsdisguises.*.*.*" which you can
|
||||||
|
# negate with your permissions plugin
|
||||||
|
ExplicitDisguises: false
|
||||||
|
|
||||||
|
# Disables commands with the exception of /libsdisguises. Useful if you don't want the plugin to be used by anything
|
||||||
|
# but a plugin
|
||||||
|
DisableCommands: false
|
||||||
|
|
||||||
# The disguise plugin stores all GameProfiles inside a file called 'cache.yml'
|
# The disguise plugin stores all GameProfiles inside a file called 'cache.yml'
|
||||||
# This means that the plugin doesn't need to constantly call Mojang just to find a skin for an offline player
|
# This means that the plugin doesn't need to constantly call Mojang just to find a skin for an offline player
|
||||||
@ -49,6 +66,9 @@ Scoreboard:
|
|||||||
# If self disguises are disabled, or the scoreboard is using IGNORE_SCOREBOARD then this does nothing.
|
# If self disguises are disabled, or the scoreboard is using IGNORE_SCOREBOARD then this does nothing.
|
||||||
WarnConflict: true
|
WarnConflict: true
|
||||||
|
|
||||||
|
# Shall I notify those with the correct permission when there's a LibsDisguises update?
|
||||||
|
NotifyUpdate: true
|
||||||
|
|
||||||
# Whats the permission to get the notification?
|
# Whats the permission to get the notification?
|
||||||
Permission: 'libsdisguises.update'
|
Permission: 'libsdisguises.update'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user