2013-01-22 17:38:48 +00:00
|
|
|
package de.jaschastarke.minecraft.limitedcreative;
|
|
|
|
|
|
|
|
import de.jaschastarke.LocaleString;
|
|
|
|
import de.jaschastarke.bukkit.lib.commands.BukkitCommand;
|
2013-03-20 16:11:32 +00:00
|
|
|
import de.jaschastarke.bukkit.lib.commands.CommandContext;
|
2013-01-22 17:38:48 +00:00
|
|
|
import de.jaschastarke.bukkit.lib.commands.IHelpDescribed;
|
2013-03-20 16:11:32 +00:00
|
|
|
import de.jaschastarke.bukkit.lib.commands.IMethodCommandContainer;
|
|
|
|
import de.jaschastarke.bukkit.lib.commands.annotations.Description;
|
|
|
|
import de.jaschastarke.bukkit.lib.commands.annotations.IsCommand;
|
|
|
|
import de.jaschastarke.bukkit.lib.commands.annotations.NeedsPermission;
|
2013-01-22 17:38:48 +00:00
|
|
|
import de.jaschastarke.maven.ArchiveDocComments;
|
|
|
|
import de.jaschastarke.minecraft.lib.permissions.IAbstractPermission;
|
2013-03-20 16:11:32 +00:00
|
|
|
import de.jaschastarke.minecraft.lib.permissions.IPermission;
|
2013-01-22 17:38:48 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* LimitedCreative: GameMode-Switch, Creative-Regions, Config and more
|
|
|
|
* @usage /<command> - displays LimitedCreative-Help
|
|
|
|
* @permission limitedcreative.command
|
|
|
|
*/
|
|
|
|
@ArchiveDocComments
|
2013-03-20 16:11:32 +00:00
|
|
|
public class MainCommand extends BukkitCommand implements IHelpDescribed, IMethodCommandContainer {
|
2013-01-22 17:38:48 +00:00
|
|
|
private LimitedCreative plugin;
|
|
|
|
|
|
|
|
public MainCommand() {
|
|
|
|
}
|
|
|
|
public MainCommand(LimitedCreative plugin) {
|
|
|
|
this.plugin = plugin;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getName() {
|
|
|
|
return "limitedcreative";
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String[] getAliases() {
|
|
|
|
return new String[]{"lc"};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal has no effect, as not tested by any command handler
|
|
|
|
* @see IHelpDescribed
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public IAbstractPermission[] getRequiredPermissions() {
|
|
|
|
return new IAbstractPermission[]{Permissions.COMMAND};
|
|
|
|
}
|
|
|
|
@Override
|
2013-02-05 20:04:05 +00:00
|
|
|
public String[] getUsages() {
|
|
|
|
return null;
|
2013-01-22 17:38:48 +00:00
|
|
|
}
|
|
|
|
@Override
|
|
|
|
public CharSequence getDescription() {
|
|
|
|
return new LocaleString("command.general");
|
|
|
|
}
|
|
|
|
@Override
|
|
|
|
public String getPackageName() {
|
|
|
|
return plugin.getName();
|
|
|
|
}
|
2013-03-20 16:11:32 +00:00
|
|
|
@Override
|
|
|
|
public IPermission getPermission(String subPerm) {
|
|
|
|
return Permissions.CONTAINER.getPermission(subPerm);
|
|
|
|
}
|
|
|
|
|
|
|
|
@IsCommand("reload")
|
|
|
|
@Description(value = "command.config.reload", translate = true)
|
|
|
|
@NeedsPermission(value={"config"})
|
|
|
|
public boolean doReload(final CommandContext context) {
|
2013-03-23 16:59:14 +00:00
|
|
|
plugin.getServer().getScheduler().runTask(plugin, new Runnable() {
|
2013-03-20 16:11:32 +00:00
|
|
|
@Override
|
|
|
|
public void run() {
|
2013-09-22 09:04:09 +00:00
|
|
|
if (plugin.isDebug())
|
|
|
|
plugin.getLog().debug("Scheduler: Synchronous Task run: Disable");
|
2013-03-20 16:11:32 +00:00
|
|
|
plugin.onDisable();
|
2013-03-23 16:59:14 +00:00
|
|
|
plugin.getPluginConfig().reload();
|
|
|
|
plugin.getServer().getScheduler().runTask(plugin, new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
2013-09-22 09:04:09 +00:00
|
|
|
if (plugin.isDebug())
|
|
|
|
plugin.getLog().debug("Scheduler: Synchronous Task run: Enable");
|
2013-03-23 16:59:14 +00:00
|
|
|
plugin.onEnable();
|
|
|
|
context.response(context.getFormatter().getString("command.config.reload.success"));
|
|
|
|
}
|
|
|
|
});
|
2013-03-20 16:11:32 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
return true;
|
|
|
|
}
|
2013-01-22 17:38:48 +00:00
|
|
|
}
|