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