diff --git a/pom.xml b/pom.xml
index 5dfc64c2..49386e5d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -49,7 +49,7 @@
com.comphenix.protocol
ProtocolLib
- 4.5.1-SNAPSHOT
+ 4.5.0
org.spigotmc
diff --git a/src/main/java/me/libraryaddict/disguise/commands/LibsDisguisesCommand.java b/src/main/java/me/libraryaddict/disguise/commands/LibsDisguisesCommand.java
index 34ed0f5d..4db15688 100644
--- a/src/main/java/me/libraryaddict/disguise/commands/LibsDisguisesCommand.java
+++ b/src/main/java/me/libraryaddict/disguise/commands/LibsDisguisesCommand.java
@@ -2,8 +2,12 @@ package me.libraryaddict.disguise.commands;
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.LibsDisguises;
-import me.libraryaddict.disguise.utilities.translations.LibsMsg;
+import me.libraryaddict.disguise.disguisetypes.MetaIndex;
import me.libraryaddict.disguise.utilities.LibsPremium;
+import me.libraryaddict.disguise.utilities.translations.LibsMsg;
+import net.md_5.bungee.api.chat.ClickEvent;
+import net.md_5.bungee.api.chat.ComponentBuilder;
+import net.md_5.bungee.api.chat.HoverEvent;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@@ -76,16 +80,61 @@ public class LibsDisguisesCommand implements CommandExecutor, TabCompleter {
sender.sendMessage(ChatColor.DARK_GREEN + "This server supports the plugin developer!");
}
} else if (args.length > 0) {
- if (sender.hasPermission("libsdisguises.reload")) {
- if (args[0].equalsIgnoreCase("reload")) {
- DisguiseConfig.loadConfig();
- sender.sendMessage(LibsMsg.RELOADED_CONFIG.get());
+ if (args[0].equalsIgnoreCase("reload")) {
+ if (!sender.hasPermission("libsdisguises.reload")) {
+ sender.sendMessage(LibsMsg.NO_PERM.get());
return true;
+ }
+
+ DisguiseConfig.loadConfig();
+ sender.sendMessage(LibsMsg.RELOADED_CONFIG.get());
+ return true;
+ } else if (args[0].equalsIgnoreCase("metainfo") || args[0].equalsIgnoreCase("meta")) {
+ if (!sender.hasPermission("libsdisguises.metainfo")) {
+ sender.sendMessage(LibsMsg.NO_PERM.get());
+ return true;
+ }
+
+ if (args.length > 1) {
+ MetaIndex index = MetaIndex.getMetaIndexByName(args[1]);
+
+ if (index == null) {
+ sender.sendMessage(LibsMsg.META_NOT_FOUND.get());
+ return true;
+ }
+
+ sender.sendMessage(index.toString());
} else {
- sender.sendMessage(LibsMsg.LIBS_RELOAD_WRONG.get());
+ ArrayList names = new ArrayList<>();
+
+ for (MetaIndex index : MetaIndex.values()) {
+ names.add(MetaIndex.getName(index));
+ }
+
+ names.sort(String::compareToIgnoreCase);
+
+ ComponentBuilder builder = new ComponentBuilder("").appendLegacy(LibsMsg.META_VALUES.get());
+
+ Iterator itel = names.iterator();
+
+ while (itel.hasNext()) {
+ String name = itel.next();
+
+ builder.appendLegacy(name);
+ builder.event(
+ new ClickEvent(ClickEvent.Action.RUN_COMMAND, cmd.getName() + " metainfo " + name));
+ builder.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
+ new ComponentBuilder("").appendLegacy(LibsMsg.META_CLICK_SHOW.get(name)).create()));
+
+ if (itel.hasNext()) {
+ builder.appendLegacy(LibsMsg.META_VALUE_SEPERATOR.get());
+ }
+ }
+
+ sender.spigot().sendMessage(builder.create());
}
} else {
- sender.sendMessage(LibsMsg.NO_PERM.get());
+ sender.sendMessage(LibsMsg.LIBS_COMMAND_WRONG_ARG.get());
}
}
return true;
diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/MetaIndex.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/MetaIndex.java
index c6b3980a..489841a1 100644
--- a/src/main/java/me/libraryaddict/disguise/disguisetypes/MetaIndex.java
+++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/MetaIndex.java
@@ -7,7 +7,7 @@ import com.comphenix.protocol.wrappers.nbt.NbtFactory;
import com.comphenix.protocol.wrappers.nbt.NbtType;
import me.libraryaddict.disguise.disguisetypes.watchers.*;
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
-import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
+import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.Particle;
@@ -596,7 +596,6 @@ public class MetaIndex {
* All flag types should never occur twice.
*/
public static void validateMetadata() {
-
HashMap maxValues = new HashMap<>();
for (MetaIndex type : values()) {
@@ -639,10 +638,14 @@ public class MetaIndex {
}
}
+ public String toString() {
+ return LibsMsg.META_INFO.get(getName(this), getFlagWatcher().getSimpleName(), getIndex(),
+ getDefault().getClass().getSimpleName(), DisguiseUtilities.getGson().toJson(getDefault()));
+ }
+
/**
* Used for debugging purposes, prints off the registered MetaIndexes
*/
- @Deprecated
public static void printMetadata() {
ArrayList toPrint = new ArrayList<>();
@@ -653,9 +656,7 @@ public class MetaIndex {
MetaIndex index = (MetaIndex) field.get(null);
- toPrint.add(
- index.getFlagWatcher().getSimpleName() + " " + field.getName() + " " + index.getIndex() + " " +
- index.getDefault().getClass().getSimpleName());
+ toPrint.add(index.toString());
}
}
catch (Exception ex) {
@@ -742,10 +743,28 @@ public class MetaIndex {
return _values;
}
+ public static MetaIndex getMetaIndexByName(String name) {
+ name = name.toUpperCase();
+
+ try {
+ for (Field field : MetaIndex.class.getFields()) {
+ if (!field.getName().equals(name) || field.getType() != MetaIndex.class) {
+ continue;
+ }
+
+ return (MetaIndex) field.get(null);
+ }
+ }
+ catch (IllegalAccessException e) {
+ e.printStackTrace();
+ }
+
+ return null;
+ }
+
/**
* Get the field name of a registered MetaIndex
*/
- @Deprecated
public static String getName(MetaIndex metaIndex) {
try {
for (Field field : MetaIndex.class.getFields()) {
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 67b964ed..ee24a46f 100644
--- a/src/main/java/me/libraryaddict/disguise/utilities/translations/LibsMsg.java
+++ b/src/main/java/me/libraryaddict/disguise/utilities/translations/LibsMsg.java
@@ -113,7 +113,7 @@ public enum LibsMsg {
PLEASE_WAIT(ChatColor.GRAY + "Please wait..."),
INVALID_CLONE(ChatColor.DARK_RED + "Unknown option '%s' - Valid options are 'IgnoreEquipment' 'DoSneakSprint' " +
"'DoSneak' 'DoSprint'"),
- LIBS_RELOAD_WRONG(ChatColor.RED + "[LibsDisguises] Did you mean 'reload'?"),
+ LIBS_COMMAND_WRONG_ARG(ChatColor.RED + "[LibsDisguises] Did you mean 'reload' or 'metainfo'?"),
LIMITED_RADIUS(ChatColor.RED + "Limited radius to %s! Don't want to make too much lag right?"),
LISTEN_ENTITY_ENTITY_DISG_ENTITY(ChatColor.RED + "Disguised %s as a %s!"),
LISTEN_ENTITY_ENTITY_DISG_ENTITY_FAIL(ChatColor.RED + "Failed to disguise %s as a %s!"),
@@ -220,7 +220,8 @@ public enum LibsMsg {
"Means '/savedisguise Notch player Notch setsneaking'"),
SAVE_DISG_HELP_5(ChatColor.GREEN + "Remember! You can upload your own skins, then reference those skins!"),
GRAB_DISG_HELP_1(ChatColor.GREEN +
- "You can choose a name to save the skins under, the names will be usable as if it was an actual player skin"),
+ "You can choose a name to save the skins under, the names will be usable as if it was an actual player " +
+ "skin"),
GRAB_DISG_HELP_2(ChatColor.DARK_GREEN + "/grabskin https://somesite.com/myskin.png "),
GRAB_DISG_HELP_3(ChatColor.DARK_GREEN + "/grabskin myskin.png - Skins must be in the folder!"),
GRAB_DISG_HELP_4(ChatColor.DARK_GREEN + "/grabskin "),
@@ -229,7 +230,12 @@ public enum LibsMsg {
CUSTOM_DISGUISE_NAME_CONFLICT(
ChatColor.RED + "Cannot create the custom disguise '%s' as there is a name conflict!"),
ERROR_LOADING_CUSTOM_DISGUISE(ChatColor.RED + "Error while loading custom disguise '%s'%s"),
- SKIN_API_INTERNAL_ERROR(ChatColor.RED + "Internal error in the skin API, perhaps bad data?");
+ SKIN_API_INTERNAL_ERROR(ChatColor.RED + "Internal error in the skin API, perhaps bad data?"),
+ META_INFO(ChatColor.GREEN + "Name: %s, Watcher: %s, Index: %s, Type: %s, Default: %s"),
+ META_NOT_FOUND(ChatColor.RED + "No meta exists under that name!"),
+ META_VALUES(ChatColor.BLUE + "Metas: " + ChatColor.DARK_AQUA),
+ META_VALUE_SEPERATOR(ChatColor.AQUA + ", " + ChatColor.DARK_AQUA),
+ META_CLICK_SHOW(ChatColor.GOLD + "Click to show %s");
private String string;