Automatic children setup

This commit is contained in:
Magnus Ulf Jørgensen 2017-03-12 20:50:37 +01:00
parent 0f924843b0
commit a037f6f01f
35 changed files with 112 additions and 416 deletions

View File

@ -1,5 +1,6 @@
package com.massivecraft.massivecore.command;
import com.massivecraft.massivecore.Active;
import com.massivecraft.massivecore.Lang;
import com.massivecraft.massivecore.MassiveException;
@ -17,6 +18,7 @@ import com.massivecraft.massivecore.mson.Mson;
import com.massivecraft.massivecore.predicate.PredicateStartsWithIgnoreCase;
import com.massivecraft.massivecore.util.MUtil;
import com.massivecraft.massivecore.util.PermissionUtil;
import com.massivecraft.massivecore.util.ReflectionUtil;
import com.massivecraft.massivecore.util.Txt;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
@ -25,6 +27,8 @@ import org.bukkit.command.PluginIdentifiableCommand;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@ -916,6 +920,25 @@ public class MassiveCommand implements Active, PluginIdentifiableCommand
if (this.setupPermBaseClassName != null) return this.setupPermBaseClassName;
// Otherwise guess
// Since some commands such as CmdMassiveCoreUsys aren't the base command
// but are still outer/root commands we can't always trust the root command.
// Thus we try by using the plugin name first.
Plugin plugin = this.getRoot().getPlugin();
String pluginName = plugin.getName();
String cmdPackageName = plugin.getClass().getName() + ".cmd.";
// Try Cmd + plugin name
String baseCommandName = "Cmd" + pluginName;
if (ReflectionUtil.classExists(cmdPackageName + baseCommandName)) return baseCommandName;
// Try Cmd + plugin name without "Massive prefix"
if (pluginName.startsWith("Massive"))
{
baseCommandName = "Cmd" + pluginName.substring("Massive".length());
if (ReflectionUtil.classExists(cmdPackageName + baseCommandName)) return baseCommandName;
}
// Use the name of the root command
return this.getRoot().getClass().getSimpleName();
}
public void setSetupPermBaseClassName(String setupPermBaseClassName) { this.setupPermBaseClassName = setupPermBaseClassName; }
@ -948,9 +971,27 @@ public class MassiveCommand implements Active, PluginIdentifiableCommand
Object permission = this.calcPerm();
if (permission != null) this.addRequirements(RequirementHasPerm.get(permission));
this.setupAddChildren();
this.setupChildren();
}
public void setupAddChildren()
{
String s = this.getClass().getSimpleName();
for (Field field : this.getClass().getDeclaredFields())
{
ReflectionUtil.makeAccessible(field);
Class<?> fieldType = field.getType();
if (!MassiveCommand.class.isAssignableFrom(fieldType)) continue;
if (Modifier.isStatic(field.getModifiers())) continue;
MassiveCommand child = ReflectionUtil.getField(field, this);
this.addChild(child);
}
}
public void setupChildren()
{
for (MassiveCommand child : this.getChildren())

View File

@ -3,7 +3,6 @@ package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.MassiveCoreMConf;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.MassiveCommandVersion;
import com.massivecraft.massivecore.command.editor.CommandEditAbstract;
import com.massivecraft.massivecore.command.editor.CommandEditSingleton;
@ -11,7 +10,7 @@ import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import java.util.List;
public class CmdMassiveCore extends MassiveCommand
public class CmdMassiveCore extends MassiveCoreCommand
{
// -------------------------------------------- //
// INSTANCE
@ -36,29 +35,6 @@ public class CmdMassiveCore extends MassiveCommand
public CmdMassiveCoreClick cmdMassiveCoreClick = new CmdMassiveCoreClick();
public MassiveCommandVersion cmdMassiveCoreVersion = new MassiveCommandVersion(MassiveCore.get()).setAliases("v", "version").addRequirements(RequirementHasPerm.get(MassiveCorePerm.VERSION));
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdMassiveCore()
{
// Children
this.addChild(this.cmdMassiveCoreUsys);
this.addChild(this.cmdMassiveCoreMStore);
this.addChild(this.cmdMassiveCoreId);
this.addChild(this.cmdMassiveCoreTest);
this.addChild(this.cmdMassiveCoreHearsound);
this.addChild(this.cmdMassiveCoreBuffer);
this.addChild(this.cmdMassiveCoreCmdurl);
this.addChild(this.cmdMassiveCoreConfig);
this.addChild(this.cmdMassiveCoreSponsor);
this.addChild(this.cmdMassiveCoreClick);
this.addChild(this.cmdMassiveCoreVersion);
// Requirements
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.BASECOMMAND));
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //

View File

@ -1,13 +1,10 @@
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCoreMConf;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import java.util.List;
public class CmdMassiveCoreBuffer extends MassiveCommand
public class CmdMassiveCoreBuffer extends MassiveCoreCommand
{
// -------------------------------------------- //
// INSTANCE
@ -26,24 +23,4 @@ public class CmdMassiveCoreBuffer extends MassiveCommand
public CmdMassiveCoreBufferAdd cmdMassiveCoreBufferAdd = new CmdMassiveCoreBufferAdd();
public CmdMassiveCoreBufferWhitespace cmdMassiveCoreBufferWhitespace = new CmdMassiveCoreBufferWhitespace();
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdMassiveCoreBuffer()
{
// Children
this.addChild(this.cmdMassiveCoreBufferPrint);
this.addChild(this.cmdMassiveCoreBufferClear);
this.addChild(this.cmdMassiveCoreBufferSet);
this.addChild(this.cmdMassiveCoreBufferAdd);
this.addChild(this.cmdMassiveCoreBufferWhitespace);
// Aliases
this.addAliases("buffer");
// Requirements
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.BUFFER));
}
}

View File

@ -1,13 +1,10 @@
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.type.primitive.TypeString;
import com.massivecraft.massivecore.engine.EngineMassiveCoreVariable;
public class CmdMassiveCoreBufferAdd extends MassiveCommand
public class CmdMassiveCoreBufferAdd extends MassiveCoreCommand
{
// -------------------------------------------- //
// CONSTRUCT
@ -15,14 +12,8 @@ public class CmdMassiveCoreBufferAdd extends MassiveCommand
public CmdMassiveCoreBufferAdd()
{
// Aliases
this.addAliases("add");
// Parameters
this.addParameter(TypeString.get(), "text", true).setDesc("the text to add to your buffer");
// Requirements
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.BUFFER_ADD));
}
// -------------------------------------------- //

View File

@ -1,25 +1,9 @@
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.engine.EngineMassiveCoreVariable;
public class CmdMassiveCoreBufferClear extends MassiveCommand
public class CmdMassiveCoreBufferClear extends MassiveCoreCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdMassiveCoreBufferClear()
{
// Aliases
this.addAliases("clear");
// Requirements
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.BUFFER_CLEAR));
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //

View File

@ -1,25 +1,9 @@
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.engine.EngineMassiveCoreVariable;
public class CmdMassiveCoreBufferPrint extends MassiveCommand
public class CmdMassiveCoreBufferPrint extends MassiveCoreCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdMassiveCoreBufferPrint()
{
// Aliases
this.addAliases("print");
// Requirements
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.BUFFER_PRINT));
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //

View File

@ -1,13 +1,10 @@
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.type.primitive.TypeString;
import com.massivecraft.massivecore.engine.EngineMassiveCoreVariable;
public class CmdMassiveCoreBufferSet extends MassiveCommand
public class CmdMassiveCoreBufferSet extends MassiveCoreCommand
{
// -------------------------------------------- //
// CONSTRUCT
@ -15,14 +12,8 @@ public class CmdMassiveCoreBufferSet extends MassiveCommand
public CmdMassiveCoreBufferSet()
{
// Aliases
this.addAliases("set");
// Parameters
this.addParameter(TypeString.get(), "text", true).setDesc("the text to set your buffer to");
// Requirements
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.BUFFER_SET));
}
// -------------------------------------------- //

View File

@ -1,14 +1,11 @@
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.type.primitive.TypeInteger;
import com.massivecraft.massivecore.engine.EngineMassiveCoreVariable;
import com.massivecraft.massivecore.util.Txt;
public class CmdMassiveCoreBufferWhitespace extends MassiveCommand
public class CmdMassiveCoreBufferWhitespace extends MassiveCoreCommand
{
// -------------------------------------------- //
// CONSTRUCT
@ -16,14 +13,8 @@ public class CmdMassiveCoreBufferWhitespace extends MassiveCommand
public CmdMassiveCoreBufferWhitespace()
{
// Aliases
this.addAliases("whitespace");
// Parameters
this.addParameter(1, TypeInteger.get(), "times").setDesc("the amount of whitespace to add to your buffer");
// Requirements
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.BUFFER_WHITESPACE));
}
// -------------------------------------------- //

View File

@ -1,14 +1,11 @@
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCoreMConf;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.type.TypeStringCommand;
import com.massivecraft.massivecore.mixin.MixinCommand;
public class CmdMassiveCoreClick extends MassiveCommand
public class CmdMassiveCoreClick extends MassiveCoreCommand
{
// -------------------------------------------- //
// INSTANCE
@ -23,14 +20,8 @@ public class CmdMassiveCoreClick extends MassiveCommand
public CmdMassiveCoreClick()
{
// Aliases
this.addAliases("click");
// Parameters
this.addParameter(null, TypeStringCommand.get(), "command", "none", true).setDesc("the command to perform");
// Requirements
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.CLICK));
}
// -------------------------------------------- //

View File

@ -2,10 +2,7 @@ package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.MassiveCoreMConf;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer;
import com.massivecraft.massivecore.command.type.primitive.TypeString;
import com.massivecraft.massivecore.mixin.MixinMessage;
@ -17,7 +14,7 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
public class CmdMassiveCoreCmdurl extends MassiveCommand
public class CmdMassiveCoreCmdurl extends MassiveCoreCommand
{
// -------------------------------------------- //
// INSTANCE
@ -32,14 +29,10 @@ public class CmdMassiveCoreCmdurl extends MassiveCommand
public CmdMassiveCoreCmdurl()
{
// Aliases
this.addAliases("cmdurl");
// Parameters
this.addParameter(TypeString.get(), "url").setDesc("the url to load");
// Requirements
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.CMDURL));
this.addRequirements(RequirementIsPlayer.get());
}

View File

@ -1,17 +1,14 @@
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.SoundEffect;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer;
import com.massivecraft.massivecore.command.type.combined.TypeSoundEffect;
import com.massivecraft.massivecore.command.type.container.TypeList;
import java.util.List;
public class CmdMassiveCoreHearsound extends MassiveCommand
public class CmdMassiveCoreHearsound extends MassiveCoreCommand
{
// -------------------------------------------- //
// CONSTRUCT
@ -20,13 +17,12 @@ public class CmdMassiveCoreHearsound extends MassiveCommand
public CmdMassiveCoreHearsound()
{
// Aliases
this.addAliases("hearsound", "hearsounds");
this.addAliases("hearsounds");
// Parameters
this.addParameter(TypeList.get(TypeSoundEffect.get()), "sound(s)", true).setDesc("the sounds to hear");
// Requirements
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.HEARSOUND));
this.addRequirements(RequirementIsPlayer.get());
}

View File

@ -1,25 +1,9 @@
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.ConfServer;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
public class CmdMassiveCoreId extends MassiveCommand
public class CmdMassiveCoreId extends MassiveCoreCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdMassiveCoreId()
{
// Aliases
this.addAliases("id");
// Requirements
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.ID));
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //

View File

@ -22,7 +22,7 @@ public class CmdMassiveCoreSponsor extends MassiveCommandToggle
{
// Aliases
this.addAliases("sponsor");
// Requirements
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.SPONSOR));
}

View File

@ -1,13 +1,10 @@
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCoreMConf;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import java.util.List;
public class CmdMassiveCoreStore extends MassiveCommand
public class CmdMassiveCoreStore extends MassiveCoreCommand
{
// -------------------------------------------- //
// INSTANCE
@ -24,22 +21,4 @@ public class CmdMassiveCoreStore extends MassiveCommand
public CmdMassiveCoreStoreListcolls cmdMassiveCoreStoreListcolls = new CmdMassiveCoreStoreListcolls();
public CmdMassiveCoreStoreCopydb cmdMassiveCoreStoreCopydb = new CmdMassiveCoreStoreCopydb();
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdMassiveCoreStore()
{
// Children
this.addChild(this.cmdMassiveCoreStoreStats);
this.addChild(this.cmdMassiveCoreStoreListcolls);
this.addChild(this.cmdMassiveCoreStoreCopydb);
// Parameters
this.addAliases("store");
// Requirements
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.STORE));
}
}

View File

@ -1,10 +1,7 @@
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.type.primitive.TypeString;
import com.massivecraft.massivecore.store.Coll;
import com.massivecraft.massivecore.store.Db;
@ -16,7 +13,7 @@ import java.util.Collection;
import java.util.Map.Entry;
import java.util.Set;
public class CmdMassiveCoreStoreCopydb extends MassiveCommand
public class CmdMassiveCoreStoreCopydb extends MassiveCoreCommand
{
// -------------------------------------------- //
// CONSTRUCT
@ -24,15 +21,9 @@ public class CmdMassiveCoreStoreCopydb extends MassiveCommand
public CmdMassiveCoreStoreCopydb()
{
// Aliases
this.addAliases("copydb");
// Parameters
this.addParameter(TypeString.get(), "from").setDesc("the database to copy from");
this.addParameter(TypeString.get(), "to").setDesc("the database to copy to");
// Requirements
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.STORE_COPYDB));
}
// -------------------------------------------- //

View File

@ -1,10 +1,7 @@
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.ConfServer;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.type.primitive.TypeString;
import com.massivecraft.massivecore.comparator.ComparatorNaturalOrder;
import com.massivecraft.massivecore.store.Coll;
@ -15,7 +12,7 @@ import com.massivecraft.massivecore.util.Txt;
import java.util.Set;
import java.util.TreeSet;
public class CmdMassiveCoreStoreListcolls extends MassiveCommand
public class CmdMassiveCoreStoreListcolls extends MassiveCoreCommand
{
// -------------------------------------------- //
// CONSTRUCT
@ -23,14 +20,8 @@ public class CmdMassiveCoreStoreListcolls extends MassiveCommand
public CmdMassiveCoreStoreListcolls()
{
// Aliases
this.addAliases("listcolls");
// Parameters
this.addParameter(TypeString.get(), "db", ConfServer.dburi).setDesc("the database to list colls from");
// Requirements
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.STORE_LISTCOLLS));
}
// -------------------------------------------- //

View File

@ -1,9 +1,6 @@
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.type.store.TypeColl;
import com.massivecraft.massivecore.store.Coll;
import com.massivecraft.massivecore.util.MUtil;
@ -11,7 +8,7 @@ import com.massivecraft.massivecore.util.Txt;
import java.util.Map.Entry;
public class CmdMassiveCoreStoreStats extends MassiveCommand
public class CmdMassiveCoreStoreStats extends MassiveCoreCommand
{
// -------------------------------------------- //
// CONSTRUCT
@ -19,14 +16,8 @@ public class CmdMassiveCoreStoreStats extends MassiveCommand
public CmdMassiveCoreStoreStats()
{
// Aliases
this.addAliases("stats");
// Parameters
this.addParameter(TypeColl.get(), "coll", Coll.TOTAL).setDesc("the coll to show info about");
// Requirements
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.STORE_STATS));
}
// -------------------------------------------- //

View File

@ -1,11 +1,8 @@
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.collections.MassiveList;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.Visibility;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer;
import com.massivecraft.massivecore.command.type.TypeItemStack;
import com.massivecraft.massivecore.command.type.primitive.TypeBooleanYes;
@ -17,7 +14,7 @@ import org.bukkit.inventory.ItemStack;
import java.util.List;
public class CmdMassiveCoreTest extends MassiveCommand
public class CmdMassiveCoreTest extends MassiveCoreCommand
{
// -------------------------------------------- //
// CONSTRUCT
@ -25,14 +22,10 @@ public class CmdMassiveCoreTest extends MassiveCommand
public CmdMassiveCoreTest()
{
// Aliases
this.addAliases("test");
// Parameters
this.addParameter(false, TypeBooleanYes.get(), "set", "no");
// Requirements
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.TEST));
this.addRequirements(RequirementIsPlayer.get());
// VisibilityMode

View File

@ -1,9 +1,7 @@
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCoreMConf;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import java.util.List;
@ -25,23 +23,4 @@ public class CmdMassiveCoreUsys extends MassiveCommand
public CmdMassiveCoreUsysWorld cmdMassiveCoreUsysWorld = new CmdMassiveCoreUsysWorld();
public CmdMassiveCoreUsysAspect cmdMassiveCoreUsysAspect = new CmdMassiveCoreUsysAspect();
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdMassiveCoreUsys()
{
// Children
this.addChild(this.cmdMassiveCoreUsysMultiverse);
this.addChild(this.cmdMassiveCoreUsysUniverse);
this.addChild(this.cmdMassiveCoreUsysWorld);
this.addChild(this.cmdMassiveCoreUsysAspect);
// Aliases
this.addAliases("usys");
// Requirements
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.USYS));
}
}

View File

@ -1,10 +1,6 @@
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
public class CmdMassiveCoreUsysAspect extends MassiveCommand
public class CmdMassiveCoreUsysAspect extends MassiveCoreCommand
{
// -------------------------------------------- //
// FIELDS
@ -14,22 +10,4 @@ public class CmdMassiveCoreUsysAspect extends MassiveCommand
public CmdMassiveCoreUsysAspectShow cmdMassiveCoreUsysAspectShow = new CmdMassiveCoreUsysAspectShow();
public CmdMassiveCoreUsysAspectUse cmdMassiveCoreUsysAspectUse = new CmdMassiveCoreUsysAspectUse();
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdMassiveCoreUsysAspect()
{
// Children
this.addChild(this.cmdMassiveCoreUsysAspectList);
this.addChild(this.cmdMassiveCoreUsysAspectShow);
this.addChild(this.cmdMassiveCoreUsysAspectUse);
// Aliases
this.addAliases("aspect");
// Requirements
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.USYS_ASPECT));
}
}

View File

@ -2,16 +2,13 @@ package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.Aspect;
import com.massivecraft.massivecore.AspectColl;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.Parameter;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.pager.Pager;
import com.massivecraft.massivecore.pager.Stringifier;
import com.massivecraft.massivecore.util.Txt;
public class CmdMassiveCoreUsysAspectList extends MassiveCommand
public class CmdMassiveCoreUsysAspectList extends MassiveCoreCommand
{
// -------------------------------------------- //
// CONSTRUCT
@ -19,14 +16,8 @@ public class CmdMassiveCoreUsysAspectList extends MassiveCommand
public CmdMassiveCoreUsysAspectList()
{
// Aliases
this.addAliases("list");
// Parameters
this.addParameter(Parameter.getPage()).setDesc("the page in the aspect list");
// Requirements
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.USYS_ASPECT_LIST));
}
// -------------------------------------------- //

View File

@ -1,14 +1,11 @@
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.Aspect;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.type.store.TypeAspect;
import com.massivecraft.massivecore.util.Txt;
public class CmdMassiveCoreUsysAspectShow extends MassiveCommand
public class CmdMassiveCoreUsysAspectShow extends MassiveCoreCommand
{
// -------------------------------------------- //
// CONSTRUCT
@ -16,14 +13,8 @@ public class CmdMassiveCoreUsysAspectShow extends MassiveCommand
public CmdMassiveCoreUsysAspectShow()
{
// Aliases
this.addAliases("show");
// Parameters
this.addParameter(TypeAspect.get(), "aspect").setDesc("the aspect to show info about");
// Requirements
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.USYS_ASPECT_SHOW));
}
// -------------------------------------------- //

View File

@ -1,15 +1,12 @@
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.Aspect;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.Multiverse;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.type.store.TypeAspect;
import com.massivecraft.massivecore.command.type.store.TypeMultiverse;
public class CmdMassiveCoreUsysAspectUse extends MassiveCommand
public class CmdMassiveCoreUsysAspectUse extends MassiveCoreCommand
{
// -------------------------------------------- //
// CONSTRUCT
@ -17,15 +14,9 @@ public class CmdMassiveCoreUsysAspectUse extends MassiveCommand
public CmdMassiveCoreUsysAspectUse()
{
// Aliases
this.addAliases("use");
// Parameters
this.addParameter(TypeAspect.get(), "aspect").setDesc("the aspect to modify");
this.addParameter(TypeMultiverse.get(), "multiverse").setDesc("the multiverse which the aspect should use");
// Requirements
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.USYS_ASPECT_USE));
}
// -------------------------------------------- //

View File

@ -1,10 +1,6 @@
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
public class CmdMassiveCoreUsysMultiverse extends MassiveCommand
public class CmdMassiveCoreUsysMultiverse extends MassiveCoreCommand
{
// -------------------------------------------- //
// FIELDS
@ -14,24 +10,5 @@ public class CmdMassiveCoreUsysMultiverse extends MassiveCommand
public CmdMassiveCoreUsysMultiverseShow cmdMassiveCoreUsysMultiverseShow = new CmdMassiveCoreUsysMultiverseShow();
public CmdMassiveCoreUsysMultiverseNew cmdMassiveCoreUsysMultiverseNew = new CmdMassiveCoreUsysMultiverseNew();
public CmdMassiveCoreUsysMultiverseDel cmdMassiveCoreUsysMultiverseDel = new CmdMassiveCoreUsysMultiverseDel();
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdMassiveCoreUsysMultiverse()
{
// Children
this.addChild(this.cmdMassiveCoreUsysMultiverseList);
this.addChild(this.cmdMassiveCoreUsysMultiverseShow);
this.addChild(this.cmdMassiveCoreUsysMultiverseNew);
this.addChild(this.cmdMassiveCoreUsysMultiverseDel);
// Aliases
this.addAliases("multiverse");
// Requirements
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.USYS_MULTIVERSE));
}
}

View File

@ -1,14 +1,11 @@
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.Multiverse;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.type.store.TypeMultiverse;
public class CmdMassiveCoreUsysMultiverseDel extends MassiveCommand
public class CmdMassiveCoreUsysMultiverseDel extends MassiveCoreCommand
{
// -------------------------------------------- //
// CONSTRUCT
@ -16,14 +13,8 @@ public class CmdMassiveCoreUsysMultiverseDel extends MassiveCommand
public CmdMassiveCoreUsysMultiverseDel()
{
// Aliases
this.addAliases("del");
// Parameters
this.addParameter(TypeMultiverse.get(), "multiverse").setDesc("the multiverse to delete");
// Requirements
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.USYS_MULTIVERSE_DEL));
}
// -------------------------------------------- //

View File

@ -1,17 +1,14 @@
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.Multiverse;
import com.massivecraft.massivecore.MultiverseColl;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.Parameter;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.pager.Pager;
import com.massivecraft.massivecore.pager.Stringifier;
import com.massivecraft.massivecore.util.Txt;
public class CmdMassiveCoreUsysMultiverseList extends MassiveCommand
public class CmdMassiveCoreUsysMultiverseList extends MassiveCoreCommand
{
// -------------------------------------------- //
// CONSTRUCT
@ -19,14 +16,8 @@ public class CmdMassiveCoreUsysMultiverseList extends MassiveCommand
public CmdMassiveCoreUsysMultiverseList()
{
// Aliases
this.addAliases("list");
// Parameters
this.addParameter(Parameter.getPage());
// Requirements
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.USYS_MULTIVERSE_LIST));
}
// -------------------------------------------- //

View File

@ -1,13 +1,10 @@
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.MultiverseColl;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.type.primitive.TypeString;
public class CmdMassiveCoreUsysMultiverseNew extends MassiveCommand
public class CmdMassiveCoreUsysMultiverseNew extends MassiveCoreCommand
{
// -------------------------------------------- //
// CONSTRUCT
@ -15,14 +12,8 @@ public class CmdMassiveCoreUsysMultiverseNew extends MassiveCommand
public CmdMassiveCoreUsysMultiverseNew()
{
// Aliases
this.addAliases("new");
// Parameters
this.addParameter(TypeString.get(), "multiverse").setDesc("name of multiverse to create");
// Requirements
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.USYS_MULTIVERSE_NEW));
}
// -------------------------------------------- //

View File

@ -2,18 +2,16 @@ package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.Aspect;
import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.Multiverse;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.type.store.TypeMultiverse;
import com.massivecraft.massivecore.util.Txt;
import java.util.ArrayList;
import java.util.List;
public class CmdMassiveCoreUsysMultiverseShow extends MassiveCommand
public class CmdMassiveCoreUsysMultiverseShow extends MassiveCoreCommand
{
// -------------------------------------------- //
// CONSTRUCT
@ -21,14 +19,8 @@ public class CmdMassiveCoreUsysMultiverseShow extends MassiveCommand
public CmdMassiveCoreUsysMultiverseShow()
{
// Aliases
this.addAliases("show");
// Parameters
this.addParameter(TypeMultiverse.get(), "multiverse").setDesc("the multiverse to show info about");
// Requirements
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.USYS_MULTIVERSE_SHOW));
}
// -------------------------------------------- //

View File

@ -1,10 +1,6 @@
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
public class CmdMassiveCoreUsysUniverse extends MassiveCommand
public class CmdMassiveCoreUsysUniverse extends MassiveCoreCommand
{
// -------------------------------------------- //
// FIELDS
@ -13,23 +9,5 @@ public class CmdMassiveCoreUsysUniverse extends MassiveCommand
public CmdMassiveCoreUsysUniverseNew cmdMassiveCoreUsysUniverseNew = new CmdMassiveCoreUsysUniverseNew();
public CmdMassiveCoreUsysUniverseDel cmdMassiveCoreUsysUniverseDel = new CmdMassiveCoreUsysUniverseDel();
public CmdMassiveCoreUsysUniverseClear cmdMassiveCoreUsysUniverseClear = new CmdMassiveCoreUsysUniverseClear();
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdMassiveCoreUsysUniverse()
{
// Children
this.addChild(this.cmdMassiveCoreUsysUniverseNew);
this.addChild(this.cmdMassiveCoreUsysUniverseDel);
this.addChild(this.cmdMassiveCoreUsysUniverseClear);
// Aliases
this.addAliases("universe");
// Requirements
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.USYS_UNIVERSE));
}
}

View File

@ -1,15 +1,12 @@
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.Multiverse;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.type.primitive.TypeString;
import com.massivecraft.massivecore.command.type.store.TypeMultiverse;
public class CmdMassiveCoreUsysUniverseClear extends MassiveCommand
public class CmdMassiveCoreUsysUniverseClear extends MassiveCoreCommand
{
// -------------------------------------------- //
// CONSTRUCT
@ -17,15 +14,9 @@ public class CmdMassiveCoreUsysUniverseClear extends MassiveCommand
public CmdMassiveCoreUsysUniverseClear()
{
// Aliases
this.addAliases("clear");
// Parameters
this.addParameter(TypeString.get(), "universe").setDesc("the universe to clear");
this.addParameter(TypeMultiverse.get(), "multiverse").setDesc("the multiverse of the universe to clear");
// Requirements
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.USYS_UNIVERSE_CLEAR));
}
// -------------------------------------------- //

View File

@ -1,15 +1,12 @@
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.Multiverse;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.type.primitive.TypeString;
import com.massivecraft.massivecore.command.type.store.TypeMultiverse;
public class CmdMassiveCoreUsysUniverseDel extends MassiveCommand
public class CmdMassiveCoreUsysUniverseDel extends MassiveCoreCommand
{
// -------------------------------------------- //
// CONSTRUCT
@ -17,15 +14,9 @@ public class CmdMassiveCoreUsysUniverseDel extends MassiveCommand
public CmdMassiveCoreUsysUniverseDel()
{
// Aliases
this.addAliases("del");
// Parameters
this.addParameter(TypeString.get(), "universe").setDesc("the universe to delete");
this.addParameter(TypeMultiverse.get(), "multiverse").setDesc("the multiverse of the universe to delete");
// Requirements
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.USYS_MULTIVERSE_DEL));
}
// -------------------------------------------- //

View File

@ -1,14 +1,11 @@
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.Multiverse;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.type.primitive.TypeString;
import com.massivecraft.massivecore.command.type.store.TypeMultiverse;
public class CmdMassiveCoreUsysUniverseNew extends MassiveCommand
public class CmdMassiveCoreUsysUniverseNew extends MassiveCoreCommand
{
// -------------------------------------------- //
// CONSTRUCT
@ -16,15 +13,9 @@ public class CmdMassiveCoreUsysUniverseNew extends MassiveCommand
public CmdMassiveCoreUsysUniverseNew()
{
// Aliases
this.addAliases("new");
// Parameters
this.addParameter(TypeString.get(), "universe").setDesc("name of universe to create");
this.addParameter(TypeMultiverse.get(), "multiverse").setDesc("the multiverse of the universe to create");
// Requirements
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.USYS_UNIVERSE_NEW));
}
// -------------------------------------------- //

View File

@ -1,14 +1,11 @@
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.Multiverse;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.type.primitive.TypeString;
import com.massivecraft.massivecore.command.type.store.TypeMultiverse;
public class CmdMassiveCoreUsysWorld extends MassiveCommand
public class CmdMassiveCoreUsysWorld extends MassiveCoreCommand
{
// -------------------------------------------- //
// CONSTRUCT
@ -16,16 +13,10 @@ public class CmdMassiveCoreUsysWorld extends MassiveCommand
public CmdMassiveCoreUsysWorld()
{
// Aliases
this.addAliases("w", "world");
// Parameters
this.addParameter(TypeString.get(), "world").setDesc("the world to move");
this.addParameter(TypeString.get(), "universe").setDesc("the universe to move the world ro");
this.addParameter(TypeMultiverse.get(), "multiverse").setDesc("the multiverse of the universe to move the world to");
// Requirements
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.USYS_WORLD));
}
// -------------------------------------------- //

View File

@ -0,0 +1,21 @@
package com.massivecraft.massivecore.command.massivecore;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.command.MassiveCommand;
public class MassiveCoreCommand extends MassiveCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public MassiveCoreCommand()
{
this.setSetupEnabled(true);
this.setSetupPermClass(MassiveCorePerm.class);
// The commands are not placed in their ususal place so it can't be found automatically.
this.setSetupPermBaseClassName(CmdMassiveCore.class.getSimpleName());
}
}

View File

@ -488,6 +488,23 @@ public class ReflectionUtil
System.out.println(className);
}
}
// -------------------------------------------- //
// CLASS EXISTENCE
// -------------------------------------------- //
public static boolean classExists(String className)
{
try
{
Class.forName(className);
return true;
}
catch (ClassNotFoundException ex)
{
return false;
}
}
// -------------------------------------------- //
// TYPE CHECKS