mirror of
https://github.com/libraryaddict/LibsDisguises.git
synced 2024-11-05 09:09:40 +01:00
Add handy way to tell you what config options you're missing, and check it through LD command
This commit is contained in:
parent
b152a59df7
commit
0319f72633
@ -462,6 +462,10 @@ public class DisguiseConfig {
|
||||
}
|
||||
}
|
||||
|
||||
boolean verbose = config.getBoolean("VerboseConfig");
|
||||
boolean changed = config.getBoolean("ChangedConfig");
|
||||
|
||||
if (!verbose) {
|
||||
int missingConfigs = 0;
|
||||
|
||||
for (String key : config.getDefaultSection().getKeys(true)) {
|
||||
@ -473,11 +477,70 @@ public class DisguiseConfig {
|
||||
}
|
||||
|
||||
if (missingConfigs > 0) {
|
||||
DisguiseUtilities.getLogger().warning(
|
||||
"Your config is missing " + missingConfigs + " options! Please consider regenerating your config!");
|
||||
DisguiseUtilities.getLogger().warning("Your config is missing " + missingConfigs +
|
||||
" options! Please consider regenerating your config!");
|
||||
}
|
||||
}
|
||||
|
||||
if (verbose || changed) {
|
||||
ArrayList<String> 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<String> doOutput(ConfigurationSection config, boolean informChangedUnknown,
|
||||
boolean informMissing) {
|
||||
HashMap<String, Object> configs = new HashMap<>();
|
||||
ConfigurationSection defaultSection = config.getDefaultSection();
|
||||
ArrayList<String> returns = new ArrayList<>();
|
||||
|
||||
for (String key : defaultSection.getKeys(true)) {
|
||||
if (defaultSection.isConfigurationSection(key)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
configs.put(key, defaultSection.get(key));
|
||||
}
|
||||
|
||||
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<String, Object> entry : configs.entrySet()) {
|
||||
returns.add("Missing '" + entry.getKey() + ": " + entry.getValue() + "'");
|
||||
}
|
||||
}
|
||||
|
||||
return returns;
|
||||
}
|
||||
|
||||
static void loadCustomDisguises() {
|
||||
customDisguises.clear();
|
||||
|
||||
|
@ -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<String> 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);
|
||||
}
|
||||
|
@ -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());
|
||||
|
||||
// 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());
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user