Use another method to get entity classes, due to inferior jar system someone is using
This commit is contained in:
parent
538346a40b
commit
f52d0fa17d
@ -33,9 +33,16 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
|||||||
|
|
||||||
public DisguiseRadiusCommand(int maxRadius) {
|
public DisguiseRadiusCommand(int maxRadius) {
|
||||||
this.maxRadius = maxRadius;
|
this.maxRadius = maxRadius;
|
||||||
for (Class c : ClassGetter.getClassesForPackage("org.bukkit.entity")) {
|
|
||||||
if (c != Entity.class && Entity.class.isAssignableFrom(c) && c.getAnnotation(Deprecated.class) == null) {
|
validClasses.add(Entity.class);
|
||||||
|
|
||||||
|
for (EntityType type : EntityType.values()) {
|
||||||
|
Class c = type.getEntityClass();
|
||||||
|
|
||||||
|
while (!validClasses.contains(c)) {
|
||||||
validClasses.add(c);
|
validClasses.add(c);
|
||||||
|
|
||||||
|
c = c.getSuperclass();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,10 @@ import me.libraryaddict.disguise.utilities.params.ParamInfoManager;
|
|||||||
import me.libraryaddict.disguise.utilities.reflection.ClassGetter;
|
import me.libraryaddict.disguise.utilities.reflection.ClassGetter;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by libraryaddict on 10/06/2017.
|
* Created by libraryaddict on 10/06/2017.
|
||||||
@ -81,20 +83,25 @@ public class TranslateFiller {
|
|||||||
TranslateType.DISGUISE_OPTIONS.save("baby", "Used as a shortcut for setBaby when disguising an entity");
|
TranslateType.DISGUISE_OPTIONS.save("baby", "Used as a shortcut for setBaby when disguising an entity");
|
||||||
TranslateType.DISGUISE_OPTIONS.save("adult", "Used as a shortcut for setBaby(false) when disguising an entity");
|
TranslateType.DISGUISE_OPTIONS.save("adult", "Used as a shortcut for setBaby(false) when disguising an entity");
|
||||||
|
|
||||||
try {
|
ArrayList<Class> validClasses = new ArrayList<>();
|
||||||
for (Class c : ClassGetter.getClassesForPackage("org.bukkit.entity")) {
|
validClasses.add(Entity.class);
|
||||||
if (c != Entity.class && Entity.class.isAssignableFrom(c) &&
|
|
||||||
c.getAnnotation(Deprecated.class) == null) {
|
for (EntityType type : EntityType.values()) {
|
||||||
|
Class c = type.getEntityClass();
|
||||||
|
|
||||||
|
while (!validClasses.contains(c)) {
|
||||||
|
validClasses.add(c);
|
||||||
|
|
||||||
|
c = c.getSuperclass();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Class c : validClasses) {
|
||||||
|
if (c != Entity.class && Entity.class.isAssignableFrom(c) && c.getAnnotation(Deprecated.class) == null) {
|
||||||
TranslateType.DISGUISES.save(c.getSimpleName(),
|
TranslateType.DISGUISES.save(c.getSimpleName(),
|
||||||
"Name for the " + c.getSimpleName() + " EntityType, " + "this is used in radius commands");
|
"Name for the " + c.getSimpleName() + " EntityType, " + "this is used in radius commands");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (Exception ex) {
|
|
||||||
DisguiseUtilities.getLogger()
|
|
||||||
.severe("Error while trying to read entity types, assuming you're using a weird jar loader and " +
|
|
||||||
"not making this fatal..");
|
|
||||||
}
|
|
||||||
|
|
||||||
TranslateType.DISGUISES.save("EntityType", "Used for the disgiuse radius command to list all entitytypes");
|
TranslateType.DISGUISES.save("EntityType", "Used for the disgiuse radius command to list all entitytypes");
|
||||||
TranslateType.DISGUISES
|
TranslateType.DISGUISES
|
||||||
|
Loading…
Reference in New Issue
Block a user