Make automatic loading deal properly with anonymous classes.
This commit is contained in:
parent
a077762b62
commit
334b31e060
@ -949,9 +949,7 @@ public class MassiveCommand implements Active, PluginIdentifiableCommand
|
|||||||
|
|
||||||
public void setupAddChildren()
|
public void setupAddChildren()
|
||||||
{
|
{
|
||||||
String s = this.getClass().getSimpleName();
|
for (Field field : this.getClassOrEnclosing(this).getDeclaredFields())
|
||||||
|
|
||||||
for (Field field : this.getClass().getDeclaredFields())
|
|
||||||
{
|
{
|
||||||
ReflectionUtil.makeAccessible(field);
|
ReflectionUtil.makeAccessible(field);
|
||||||
Class<?> fieldType = field.getType();
|
Class<?> fieldType = field.getType();
|
||||||
@ -972,13 +970,20 @@ public class MassiveCommand implements Active, PluginIdentifiableCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Class<?> getClassOrEnclosing(Object object)
|
||||||
|
{
|
||||||
|
Class<?> clazz = object.getClass();
|
||||||
|
Class<?> enclosingClass = clazz.getEnclosingClass();
|
||||||
|
return enclosingClass == null ? clazz : enclosingClass;
|
||||||
|
}
|
||||||
|
|
||||||
protected String calcName()
|
protected String calcName()
|
||||||
{
|
{
|
||||||
// If this is a child command
|
// If this is a child command
|
||||||
if (this.isRoot()) return null;
|
if (this.isRoot()) return null;
|
||||||
|
|
||||||
// ... get name of parent ...
|
// ... get name of parent ...
|
||||||
String parentName = this.getParent().getClass().getSimpleName();
|
String parentName = this.getClassOrEnclosing(this.getParent()).getSimpleName();
|
||||||
|
|
||||||
// ... and only try if the names match ...
|
// ... and only try if the names match ...
|
||||||
String name = this.getClass().getSimpleName();
|
String name = this.getClass().getSimpleName();
|
||||||
@ -1011,7 +1016,7 @@ public class MassiveCommand implements Active, PluginIdentifiableCommand
|
|||||||
// ... split at new words and separate with underscore.
|
// ... split at new words and separate with underscore.
|
||||||
permName = Txt.implode(Txt.camelsplit(permName), "_");
|
permName = Txt.implode(Txt.camelsplit(permName), "_");
|
||||||
|
|
||||||
// Enums are alway upper case.
|
// Enums are always upper case.
|
||||||
permName = permName.toUpperCase();
|
permName = permName.toUpperCase();
|
||||||
|
|
||||||
// If the name is empty it is the base command
|
// If the name is empty it is the base command
|
||||||
|
Loading…
Reference in New Issue
Block a user