From 7cf3b4e5214d99e5c50294e21f59fc90412f7418 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Thu, 11 Apr 2019 08:05:15 -0700 Subject: [PATCH] Wire up inspect command settings --- Changelog.txt | 4 ++++ .../java/com/gmail/nossr50/config/MainConfig.java | 13 ------------- .../hocon/commands/ConfigCommandsInspect.java | 8 ++++++-- .../gmail/nossr50/util/commands/CommandUtils.java | 9 +++++++-- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 44c76cb23..6f6da6c86 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -55,6 +55,10 @@ Version 2.2.0 Added some failsafes to prevent mcMMO from saving too often Command config options will now be found in "commands.conf" + Added new toggle to allow players to inspect offline users + Added new toggle to turn off the inspection distance limitation + Players can now inspect players regardless of distance by default + Players can now inspect offline players by default Settings related to party chat have been moved to the party config file Custom item (Chimaera Wing) config options will now be found in "custom_items.conf" diff --git a/src/main/java/com/gmail/nossr50/config/MainConfig.java b/src/main/java/com/gmail/nossr50/config/MainConfig.java index f8c9df480..90143a73e 100644 --- a/src/main/java/com/gmail/nossr50/config/MainConfig.java +++ b/src/main/java/com/gmail/nossr50/config/MainConfig.java @@ -360,10 +360,6 @@ public class MainConfig extends ConfigValidated { } }*/ - /* Inspect command distance */ - if (getInspectDistance() <= 0) { - reason.add(COMMANDS + "." + INSPECT1 + "." + MAX_DISTANCE + " should be greater than 0!"); - } /*if (getTreeFellerThreshold() <= 0) { reason.add(ABILITIES + "." + LIMITS + "." + TREE_FELLER_THRESHOLD + " should be greater than 0!"); @@ -547,15 +543,6 @@ public class MainConfig extends ConfigValidated { return getIntValue(PARTICLES, LEVEL_UP + TIER); } - public boolean getLargeFireworks() { - return getBooleanValue(PARTICLES, LARGE_FIREWORKS); - } - - /* Inspect command distance */ - public double getInspectDistance() { - return getDoubleValue(COMMANDS, INSPECT1, MAX_DISTANCE); - } - /* * SKILL SETTINGS */ diff --git a/src/main/java/com/gmail/nossr50/config/hocon/commands/ConfigCommandsInspect.java b/src/main/java/com/gmail/nossr50/config/hocon/commands/ConfigCommandsInspect.java index 1fd6f2910..c7effc7ab 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/commands/ConfigCommandsInspect.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/commands/ConfigCommandsInspect.java @@ -9,17 +9,21 @@ public class ConfigCommandsInspect { private static final double INSPECT_MAX_DISTANCE_DEFAULT = 30.0D; private static final boolean LIMIT_INSPECT_RANGE_DEFAULT = false; private static final boolean ALLOW_OFFLINE_INSPECTION_DEFAULT = true; + private static final String BYPASS_PERMISSION = "mcmmo.commands.mcrank.others.far"; @Setting(value = "Inspect-Max-Distance", comment = "The maximum range at which players can inspect one another." + "\nIs only used if limit inspect range is turned on." + "\nDefault value: "+INSPECT_MAX_DISTANCE_DEFAULT) private double inspectCommandMaxDistance = INSPECT_MAX_DISTANCE_DEFAULT; - @Setting(value = "Limit-Inspect-Range", comment = "Inspection is limited by the distance between players instead of always being usable.") + @Setting(value = "Limit-Inspect-Range", comment = "Inspection is limited by the distance between players instead of always being usable." + + "Permission to bypass this limit - " + BYPASS_PERMISSION + +"\nDefault value: "+LIMIT_INSPECT_RANGE_DEFAULT) private boolean limitInspectRange = LIMIT_INSPECT_RANGE_DEFAULT; @Setting(value = "Allow-Offline-Inspection", comment = "If set to true players will be able to look at the profiles of anyone on the server whether they are connected or not." + - "\nAdmins and the console can always check the profiles of offline players.") + "\nAdmins and the console can always check the profiles of offline players." + + "\nDefault value: "+ALLOW_OFFLINE_INSPECTION_DEFAULT) private boolean allowInspectOnOfflinePlayers = ALLOW_OFFLINE_INSPECTION_DEFAULT; public double getInspectCommandMaxDistance() { diff --git a/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java b/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java index 5855b6d1f..e240053c4 100644 --- a/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java +++ b/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java @@ -38,7 +38,7 @@ public final class CommandUtils { return true; } - if (!hasPermission) { + if (!hasPermission && !mcMMO.getConfigManager().getConfigCommands().isAllowInspectOnOfflinePlayers()) { sender.sendMessage(LocaleLoader.getString("Inspect.Offline")); return true; } @@ -47,7 +47,12 @@ public final class CommandUtils { } public static boolean tooFar(CommandSender sender, Player target, boolean hasPermission) { - if (sender instanceof Player && !Misc.isNear(((Player) sender).getLocation(), target.getLocation(), MainConfig.getInstance().getInspectDistance()) && !hasPermission) { + if (sender instanceof Player + && mcMMO.getConfigManager().getConfigCommands().isLimitInspectRange() + && !hasPermission + && !Misc.isNear(((Player) sender).getLocation(), + target.getLocation(), + mcMMO.getConfigManager().getConfigCommands().getInspectCommandMaxDistance())) { sender.sendMessage(LocaleLoader.getString("Inspect.TooFar")); return true; }