Add MetaIndex.printMetadata()
This commit is contained in:
		| @@ -123,7 +123,8 @@ public class LibsDisguises extends JavaPlugin { | ||||
|         registerCommand("disguisemodify", new DisguiseModifyCommand()); | ||||
|         registerCommand("disguisemodifyentity", new DisguiseModifyEntityCommand()); | ||||
|         registerCommand("disguisemodifyplayer", new DisguiseModifyPlayerCommand()); | ||||
|         registerCommand("disguisemodifyradius", new DisguiseModifyRadiusCommand(getConfig().getInt("DisguiseRadiusMax"))); | ||||
|         registerCommand("disguisemodifyradius", | ||||
|                 new DisguiseModifyRadiusCommand(getConfig().getInt("DisguiseRadiusMax"))); | ||||
|  | ||||
|         try { | ||||
|             Metrics metrics = new Metrics(this); | ||||
| @@ -201,8 +202,8 @@ public class LibsDisguises extends JavaPlugin { | ||||
|                         watcherClass = SkeletonWatcher.class; | ||||
|                         break; | ||||
|                     default: | ||||
|                     watcherClass = Class.forName( | ||||
|                             "me.libraryaddict.disguise.disguisetypes.watchers." + toReadable(disguiseType.name()) + "Watcher"); | ||||
|                         watcherClass = Class.forName("me.libraryaddict.disguise.disguisetypes.watchers." + toReadable( | ||||
|                                 disguiseType.name()) + "Watcher"); | ||||
|                         break; | ||||
|                 } | ||||
|             } | ||||
| @@ -213,21 +214,16 @@ public class LibsDisguises extends JavaPlugin { | ||||
|                 if (entityClass != null) { | ||||
|                     if (Tameable.class.isAssignableFrom(entityClass)) { | ||||
|                         watcherClass = TameableWatcher.class; | ||||
|                     } | ||||
|                     else if (Ageable.class.isAssignableFrom(entityClass)) { | ||||
|                     } else if (Ageable.class.isAssignableFrom(entityClass)) { | ||||
|                         watcherClass = AgeableWatcher.class; | ||||
|                     } | ||||
|                     else if (Creature.class.isAssignableFrom(entityClass)) { | ||||
|                     } else if (Creature.class.isAssignableFrom(entityClass)) { | ||||
|                         watcherClass = InsentientWatcher.class; | ||||
|                     } | ||||
|                     else if (LivingEntity.class.isAssignableFrom(entityClass)) { | ||||
|                     } else if (LivingEntity.class.isAssignableFrom(entityClass)) { | ||||
|                         watcherClass = LivingWatcher.class; | ||||
|                     } | ||||
|                     else { | ||||
|                     } else { | ||||
|                         watcherClass = FlagWatcher.class; | ||||
|                     } | ||||
|                 } | ||||
|                 else { | ||||
|                 } else { | ||||
|                     watcherClass = FlagWatcher.class; // Disguise is unknown type | ||||
|                 } | ||||
|             } | ||||
| @@ -337,21 +333,21 @@ public class LibsDisguises extends JavaPlugin { | ||||
|                     MetaIndex flagType = MetaIndex.getFlag(watcherClass, watch.getIndex()); | ||||
|  | ||||
|                     if (flagType == null) { | ||||
|                         System.err.println("Error finding the FlagType for " + disguiseType.name() + "! Index " + watch.getIndex() | ||||
|                                 + " can't be found!"); | ||||
|                         System.err.println("Value is " + watch.getRawValue() + " (" + watch.getRawValue().getClass() + ") (" | ||||
|                                 + nmsEntity.getClass() + ") & " + watcherClass.getSimpleName()); | ||||
|                         System.err.println( | ||||
|                                 "Error finding the FlagType for " + disguiseType.name() + "! Index " + watch.getIndex() + " can't be found!"); | ||||
|                         System.err.println( | ||||
|                                 "Value is " + watch.getRawValue() + " (" + watch.getRawValue().getClass() + ") (" + nmsEntity.getClass() + ") & " + watcherClass.getSimpleName()); | ||||
|                         System.err.println("Lib's Disguises will continue to load, but this will not work properly!"); | ||||
|                         continue; | ||||
|                     } | ||||
|  | ||||
|                     if (ReflectionManager.convertInvalidItem(flagType.getDefault()).getClass() != ReflectionManager | ||||
|                             .convertInvalidItem(watch.getValue()).getClass()) { | ||||
|                         System.err.println("Mismatch of FlagType's for " + disguiseType.name() + "! Index " + watch.getIndex() | ||||
|                                 + " has the wrong classtype!"); | ||||
|                         System.err.println("Value is " + watch.getRawValue() + " (" + watch.getRawValue().getClass() + ") (" | ||||
|                                 + nmsEntity.getClass() + ") & " + watcherClass.getSimpleName() + " which doesn't match up with " | ||||
|                                 + flagType.getDefault().getClass()); | ||||
|                     if (ReflectionManager.convertInvalidItem( | ||||
|                             flagType.getDefault()).getClass() != ReflectionManager.convertInvalidItem( | ||||
|                             watch.getValue()).getClass()) { | ||||
|                         System.err.println( | ||||
|                                 "Mismatch of FlagType's for " + disguiseType.name() + "! Index " + watch.getIndex() + " has the wrong classtype!"); | ||||
|                         System.err.println( | ||||
|                                 "Value is " + watch.getRawValue() + " (" + watch.getRawValue().getClass() + ") (" + nmsEntity.getClass() + ") & " + watcherClass.getSimpleName() + " which doesn't match up with " + flagType.getDefault().getClass()); | ||||
|                         System.err.println("Lib's Disguises will continue to load, but this will not work properly!"); | ||||
|                         continue; | ||||
|                     } | ||||
| @@ -374,8 +370,7 @@ public class LibsDisguises extends JavaPlugin { | ||||
|                     ((Ageable) bukkitEntity).setBaby(); | ||||
|  | ||||
|                     disguiseValues.setBabyBox(ReflectionManager.getBoundingBox(bukkitEntity)); | ||||
|                 } | ||||
|                 else if (bukkitEntity instanceof Zombie) { | ||||
|                 } else if (bukkitEntity instanceof Zombie) { | ||||
|                     ((Zombie) bukkitEntity).setBaby(true); | ||||
|  | ||||
|                     disguiseValues.setBabyBox(ReflectionManager.getBoundingBox(bukkitEntity)); | ||||
| @@ -386,10 +381,10 @@ public class LibsDisguises extends JavaPlugin { | ||||
|             catch (SecurityException | IllegalArgumentException | IllegalAccessException | FieldAccessException ex) { | ||||
|                 System.out.print( | ||||
|                         "[LibsDisguises] Uh oh! Trouble while making values for the disguise " + disguiseType.name() + "!"); | ||||
|                 System.out.print("[LibsDisguises] Before reporting this error, " | ||||
|                         + "please make sure you are using the latest version of LibsDisguises and ProtocolLib."); | ||||
|                 System.out.print("[LibsDisguises] Development builds are available at (ProtocolLib) " | ||||
|                         + "http://ci.dmulloy2.net/job/ProtocolLib/ and (LibsDisguises) http://server.o2gaming.com:8080/job/LibsDisguises%201.9+/"); | ||||
|                 System.out.print( | ||||
|                         "[LibsDisguises] Before reporting this error, " + "please make sure you are using the latest version of LibsDisguises and ProtocolLib."); | ||||
|                 System.out.print( | ||||
|                         "[LibsDisguises] Development builds are available at (ProtocolLib) " + "http://ci.dmulloy2.net/job/ProtocolLib/ and (LibsDisguises) http://server.o2gaming.com:8080/job/LibsDisguises%201.9+/"); | ||||
|  | ||||
|                 ex.printStackTrace(); | ||||
|             } | ||||
|   | ||||
| @@ -10,11 +10,9 @@ import org.bukkit.Color; | ||||
| import org.bukkit.Material; | ||||
| import org.bukkit.inventory.ItemStack; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
| import java.util.HashMap; | ||||
| import java.lang.reflect.Field; | ||||
| import java.util.*; | ||||
| import java.util.Map.Entry; | ||||
| import java.util.UUID; | ||||
|  | ||||
| public class MetaIndex<Y> { | ||||
|     private static MetaIndex[] _values = new MetaIndex[0]; | ||||
| @@ -313,6 +311,31 @@ public class MetaIndex<Y> { | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public static void printMetadata() { | ||||
|         ArrayList<String> toPrint = new ArrayList<>(); | ||||
|  | ||||
|         try { | ||||
|             for (Field field : MetaIndex.class.getFields()) { | ||||
|                 if (field.getType() != MetaIndex.class) | ||||
|                     continue; | ||||
|  | ||||
|                 MetaIndex index = (MetaIndex) field.get(null); | ||||
|  | ||||
|                 toPrint.add( | ||||
|                         index.getFlagWatcher().getSimpleName() + " " + field.getName() + " " + index.getIndex() + " " + index.getDefault().getClass().getSimpleName()); | ||||
|             } | ||||
|         } | ||||
|         catch (Exception ex) { | ||||
|             ex.printStackTrace(); | ||||
|         } | ||||
|  | ||||
|         Collections.sort(toPrint, String.CASE_INSENSITIVE_ORDER); | ||||
|  | ||||
|         for (String s : toPrint) { | ||||
|             System.out.println(s); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public static MetaIndex getFlag(Class<? extends FlagWatcher> watcherClass, int flagNo) { | ||||
|         for (MetaIndex type : values()) { | ||||
|             if (type.getIndex() != flagNo) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user