diff --git a/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java b/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java index e8bc3e19..fdee4bca 100644 --- a/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java +++ b/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java @@ -462,20 +462,83 @@ public class DisguiseConfig { } } - int missingConfigs = 0; + boolean verbose = config.getBoolean("VerboseConfig"); + boolean changed = config.getBoolean("ChangedConfig"); - for (String key : config.getDefaultSection().getKeys(true)) { - if (config.contains(key, true)) { + if (!verbose) { + int missingConfigs = 0; + + for (String key : config.getDefaultSection().getKeys(true)) { + if (config.contains(key, true)) { + continue; + } + + missingConfigs++; + } + + if (missingConfigs > 0) { + DisguiseUtilities.getLogger().warning("Your config is missing " + missingConfigs + + " options! Please consider regenerating your config!"); + } + } + + if (verbose || changed) { + ArrayList returns = doOutput(config, changed, verbose); + + if (!returns.isEmpty()) { + DisguiseUtilities.getLogger() + .info("This is not an error! Now outputting " + (verbose ? "missing " : "") + + (changed ? (verbose ? "and " : "") + "changed/invalid " : "") + "config values"); + + for (String v : returns) { + DisguiseUtilities.getLogger().info(v); + } + } + } + } + + public static ArrayList doOutput(ConfigurationSection config, boolean informChangedUnknown, + boolean informMissing) { + HashMap configs = new HashMap<>(); + ConfigurationSection defaultSection = config.getDefaultSection(); + ArrayList returns = new ArrayList<>(); + + for (String key : defaultSection.getKeys(true)) { + if (defaultSection.isConfigurationSection(key)) { continue; } - missingConfigs++; + configs.put(key, defaultSection.get(key)); } - if (missingConfigs > 0) { - DisguiseUtilities.getLogger().warning( - "Your config is missing " + missingConfigs + " options! Please consider regenerating your config!"); + for (String key : config.getKeys(true)) { + if (config.isConfigurationSection(key)) { + continue; + } + + if (!configs.containsKey(key)) { + if (informChangedUnknown) { + returns.add("Unknown config option '" + key + ": " + config.get(key) + "'"); + } + continue; + } + + if (!configs.get(key).equals(config.get(key))) { + if (informChangedUnknown) { + returns.add("Modified config: '" + key + ": " + config.get(key) + "'"); + } + } + + configs.remove(key); } + + if (informMissing) { + for (Entry entry : configs.entrySet()) { + returns.add("Missing '" + entry.getKey() + ": " + entry.getValue() + "'"); + } + } + + return returns; } static void loadCustomDisguises() { diff --git a/src/main/java/me/libraryaddict/disguise/commands/LibsDisguisesCommand.java b/src/main/java/me/libraryaddict/disguise/commands/LibsDisguisesCommand.java index 215f8c05..66ec29a5 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/LibsDisguisesCommand.java +++ b/src/main/java/me/libraryaddict/disguise/commands/LibsDisguisesCommand.java @@ -252,6 +252,23 @@ public class LibsDisguisesCommand implements CommandExecutor, TabCompleter { if (mcArray.size() > 1) { sendMessage(sender, LibsMsg.ITEM_SERIALIZED_MC, LibsMsg.ITEM_SERIALIZED_MC_NO_COPY, ldItem); } + } else if (args[0].equalsIgnoreCase("config")) { + if (!sender.hasPermission("libsdisguises.config")) { + sender.sendMessage(LibsMsg.NO_PERM.get()); + return true; + } + + ArrayList returns = DisguiseConfig + .doOutput(LibsDisguises.getInstance().getConfig(), true, true); + + if (returns.isEmpty()) { + sender.sendMessage(LibsMsg.USING_DEFAULT_CONFIG.get()); + return true; + } + + for (String s : returns) { + sender.sendMessage(ChatColor.AQUA + "[LibsDisguises] " + s); + } } else if (args[0].equalsIgnoreCase("metainfo") || args[0].equalsIgnoreCase("meta")) { if (!sender.hasPermission("libsdisguises.metainfo")) { sender.sendMessage(LibsMsg.NO_PERM.get()); @@ -351,7 +368,7 @@ public class LibsDisguisesCommand implements CommandExecutor, TabCompleter { String[] args = getArgs(origArgs); if (args.length == 0) - tabs.addAll(Arrays.asList("reload", "scoreboard", "permtest", "json", "metainfo")); + tabs.addAll(Arrays.asList("reload", "scoreboard", "permtest", "json", "metainfo", "config")); return filterTabs(tabs, origArgs); } diff --git a/src/main/java/me/libraryaddict/disguise/utilities/packets/PacketsHandler.java b/src/main/java/me/libraryaddict/disguise/utilities/packets/PacketsHandler.java index 8be3a37b..e11b121f 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/packets/PacketsHandler.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/packets/PacketsHandler.java @@ -2,8 +2,10 @@ package me.libraryaddict.disguise.utilities.packets; import com.comphenix.protocol.PacketType; import com.comphenix.protocol.events.PacketContainer; +import me.libraryaddict.disguise.LibsDisguises; import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.DisguiseType; +import me.libraryaddict.disguise.utilities.LibsPremium; import me.libraryaddict.disguise.utilities.packets.packethandlers.*; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -34,7 +36,12 @@ public class PacketsHandler { packetHandlers.add(new PacketHandlerEquipment(this)); packetHandlers.add(new PacketHandlerHeadRotation()); - packetHandlers.add(new PacketHandlerMetadata(this)); + + // If not prem, if build is from jenkins, else its a custom and needs paid info + if (!LibsPremium.isPremium() || LibsDisguises.getInstance().getBuildNo().matches("[0-9]+") || LibsPremium.getPaidInformation() != null) { + packetHandlers.add(new PacketHandlerMetadata(this)); + } + packetHandlers.add(new PacketHandlerMovement()); packetHandlers.add(new PacketHandlerSpawn(this)); packetHandlers.add(new PacketHandlerVelocity()); diff --git a/src/main/java/me/libraryaddict/disguise/utilities/translations/LibsMsg.java b/src/main/java/me/libraryaddict/disguise/utilities/translations/LibsMsg.java index 0bd4c44e..c0236cad 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/translations/LibsMsg.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/translations/LibsMsg.java @@ -265,11 +265,14 @@ public enum LibsMsg { LIBS_SCOREBOARD_NO_TEAM(ChatColor.RED + "Not on a scoreboard team!"), LIBS_SCOREBOARD_NO_TEAM_PUSH(ChatColor.RED + "On scoreboard team '%s' and pushing is enabled!"), LIBS_SCOREBOARD_SUCCESS(ChatColor.GOLD + - "On scoreboard team '%s' with pushing disabled! If you're still having issues and you are disguised right now, then " + - "you have a plugin modifying scoreboard through packets. Example of this is a plugin that modifies your name above head, or the tablist. Check their configs for pushing disabling options"), + "On scoreboard team '%s' with pushing disabled! If you're still having issues and you are disguised right" + + " now, then " + + "you have a plugin modifying scoreboard through packets. Example of this is a plugin that modifies your " + + "name above head, or the tablist. Check their configs for pushing disabling options"), LIBS_SCOREBOARD_DISABLED( "The scoreboard modification has been disabled in config, will continue the debug incase this is intended" + - "."); + "."), + USING_DEFAULT_CONFIG(ChatColor.DARK_GREEN + "Using the default config!"); private String string; diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 2fb426c3..09122f9d 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -28,6 +28,12 @@ Permissions: # NOT_OP = Only non operators can see this SeeCommands: TRUE +# You can also get this information through /libsdisguises config +# Should the plugin output missing config options instead of just counting them +VerboseConfig: false +# Should the plugin output changed config options? Will also list unknown extra options +ChangedConfig: false + # Disables commands with the exception of /libsdisguises. Useful if you don't want the plugin to be used by anything # but a plugin # Useful if you didn't purchase the plugin. diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 976947c3..d701b955 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -109,6 +109,8 @@ permissions: default: true libsdisguises.scoreboardtest: description: Test if the scoreboard is valid, this is a simple test. + libsdisguises.config: + description: Allows player to check Lib's Disguises config for values libsdisguises.noactionbar: description: Hides the action bar even if enabled in config default: false