mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-09-30 08:07:29 +02:00
Started implementing the new CommandHandler
This commit is contained in:
parent
4d39f2ec56
commit
f1c94bf851
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -1,3 +1,6 @@
|
||||
[submodule "lib/allpay"]
|
||||
path = lib/allpay
|
||||
url = git://github.com/FernFerret/AllPay.git
|
||||
[submodule "lib/commandhandler"]
|
||||
path = lib/commandhandler
|
||||
url = git://github.com/PneumatiCraft/CommandHandler.git
|
||||
|
1
lib/commandhandler
Submodule
1
lib/commandhandler
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 5d1210ed57b1d3552821a5d45798101d27b8e244
|
@ -30,6 +30,7 @@ import com.onarandombox.MultiverseCore.configuration.DefaultConfiguration;
|
||||
import com.onarandombox.utils.DebugLog;
|
||||
import com.onarandombox.utils.PurgeWorlds;
|
||||
import com.onarandombox.utils.UpdateChecker;
|
||||
import com.pneumaticraft.commandhandler.CommandHandler;
|
||||
|
||||
public class MultiverseCore extends JavaPlugin {
|
||||
|
||||
@ -41,7 +42,7 @@ public class MultiverseCore extends JavaPlugin {
|
||||
private boolean debug;
|
||||
|
||||
// Setup our Map for our Commands using the CommandHandler.
|
||||
private CommandManager commandManager;
|
||||
private CommandHandler commandManager;
|
||||
|
||||
private final String tag = "[Multiverse-Core]";
|
||||
|
||||
@ -92,7 +93,7 @@ public class MultiverseCore extends JavaPlugin {
|
||||
|
||||
this.bank = this.banker.loadEconPlugin();
|
||||
// Setup the command manager
|
||||
this.commandManager = new CommandManager(this);
|
||||
this.commandManager = new CommandHandler(this);
|
||||
// Setup the world purger
|
||||
this.worldPurger = new PurgeWorlds(this);
|
||||
// Call the Function to assign all the Commands to their Class.
|
||||
@ -169,30 +170,30 @@ public class MultiverseCore extends JavaPlugin {
|
||||
*/
|
||||
private void registerCommands() {
|
||||
// Page 1
|
||||
this.commandManager.addCommand(new HelpCommand(this));
|
||||
this.commandManager.addCommand(new CoordCommand(this));
|
||||
this.commandManager.addCommand(new TeleportCommand(this));
|
||||
this.commandManager.addCommand(new ListCommand(this));
|
||||
this.commandManager.addCommand(new WhoCommand(this));
|
||||
this.commandManager.addCommand(new SetSpawnCommand(this));
|
||||
this.commandManager.addCommand(new CreateCommand(this));
|
||||
this.commandManager.addCommand(new ImportCommand(this));
|
||||
this.commandManager.addCommand(new SpawnCommand(this));
|
||||
this.commandManager.addCommand(new RemoveCommand(this));
|
||||
this.commandManager.addCommand(new DeleteCommand(this));
|
||||
this.commandManager.addCommand(new UnloadCommand(this));
|
||||
this.commandManager.addCommand(new ConfirmCommand(this));
|
||||
this.commandManager.addCommand(new InfoCommand(this));
|
||||
this.commandManager.addCommand(new ReloadCommand(this));
|
||||
this.commandManager.registerCommand(new HelpCommand(this));
|
||||
this.commandManager.registerCommand(new CoordCommand(this));
|
||||
this.commandManager.registerCommand(new TeleportCommand(this));
|
||||
this.commandManager.registerCommand(new ListCommand(this));
|
||||
this.commandManager.registerCommand(new WhoCommand(this));
|
||||
this.commandManager.registerCommand(new SetSpawnCommand(this));
|
||||
this.commandManager.registerCommand(new CreateCommand(this));
|
||||
this.commandManager.registerCommand(new ImportCommand(this));
|
||||
this.commandManager.registerCommand(new SpawnCommand(this));
|
||||
this.commandManager.registerCommand(new RemoveCommand(this));
|
||||
this.commandManager.registerCommand(new DeleteCommand(this));
|
||||
this.commandManager.registerCommand(new UnloadCommand(this));
|
||||
this.commandManager.registerCommand(new ConfirmCommand(this));
|
||||
this.commandManager.registerCommand(new InfoCommand(this));
|
||||
this.commandManager.registerCommand(new ReloadCommand(this));
|
||||
|
||||
this.commandManager.addCommand(new ModifyAddCommand(this));
|
||||
this.commandManager.addCommand(new ModifySetCommand(this));
|
||||
this.commandManager.addCommand(new ModifyRemoveCommand(this));
|
||||
this.commandManager.addCommand(new ModifyClearCommand(this));
|
||||
this.commandManager.registerCommand(new ModifyAddCommand(this));
|
||||
this.commandManager.registerCommand(new ModifySetCommand(this));
|
||||
this.commandManager.registerCommand(new ModifyRemoveCommand(this));
|
||||
this.commandManager.registerCommand(new ModifyClearCommand(this));
|
||||
// This modify MUST go last.
|
||||
this.commandManager.addCommand(new ModifyCommand(this));
|
||||
this.commandManager.addCommand(new EnvironmentCommand(this));
|
||||
this.commandManager.addCommand(new PurgeCommand(this));
|
||||
this.commandManager.registerCommand(new ModifyCommand(this));
|
||||
this.commandManager.registerCommand(new EnvironmentCommand(this));
|
||||
this.commandManager.registerCommand(new PurgeCommand(this));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,88 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.command;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Calendar;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
|
||||
public class QueuedCommand {
|
||||
|
||||
private String name;
|
||||
private Object[] args;
|
||||
private Class<?> paramTypes[];
|
||||
private CommandSender sender;
|
||||
private MultiverseCore plugin;
|
||||
private Calendar timeRequested;
|
||||
private String success;
|
||||
private String fail;
|
||||
|
||||
public QueuedCommand(String commandName, Object[] args, Class<?> partypes[], CommandSender sender, Calendar instance, MultiverseCore plugin, String success, String fail) {
|
||||
this.plugin = plugin;
|
||||
this.name = commandName;
|
||||
this.args = args;
|
||||
this.sender = sender;
|
||||
this.timeRequested = instance;
|
||||
this.paramTypes = partypes;
|
||||
this.setSuccess(success);
|
||||
this.setFail(fail);
|
||||
}
|
||||
|
||||
public CommandSender getSender() {
|
||||
return this.sender;
|
||||
}
|
||||
|
||||
public boolean execute() {
|
||||
this.timeRequested.add(Calendar.SECOND, 10);
|
||||
if (this.timeRequested.after(Calendar.getInstance())) {
|
||||
try {
|
||||
Method method = this.plugin.getClass().getMethod(this.name, this.paramTypes);
|
||||
try {
|
||||
method.invoke(this.plugin, this.args);
|
||||
} catch (IllegalArgumentException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
} catch (IllegalAccessException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
} catch (InvocationTargetException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
} catch (SecurityException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
} catch (NoSuchMethodException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
this.sender.sendMessage("This command has expried. Please type the original command again.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void setSuccess(String success) {
|
||||
this.success = success;
|
||||
}
|
||||
|
||||
public String getSuccess() {
|
||||
return this.success;
|
||||
}
|
||||
|
||||
private void setFail(String fail) {
|
||||
this.fail = fail;
|
||||
}
|
||||
|
||||
public String getFail() {
|
||||
return this.fail;
|
||||
}
|
||||
}
|
@ -1,28 +1,32 @@
|
||||
package com.onarandombox.MultiverseCore.command.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.command.BaseCommand;
|
||||
import com.pneumaticraft.commandhandler.Command;
|
||||
|
||||
public class ConfirmCommand extends BaseCommand {
|
||||
public class ConfirmCommand extends Command {
|
||||
|
||||
public ConfirmCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.name = "Confirms a command that could destroy life, the universe and everything.";
|
||||
this.description = "If you have not been prompted to use this, it will not do anything.";
|
||||
this.usage = "/mvconfirm";
|
||||
this.minArgs = 0;
|
||||
this.maxArgs = 0;
|
||||
this.identifiers.add("mvconfirm");
|
||||
this.commandName = "Confirms a command that could destroy life, the universe and everything.";
|
||||
this.commandDesc = "If you have not been prompted to use this, it will not do anything.";
|
||||
this.commandUsage = "/mvconfirm";
|
||||
this.minimumArgLength = 0;
|
||||
this.maximumArgLength = 0;
|
||||
this.commandKeys.add("mvconfirm");
|
||||
this.permission = "multiverse.world.confirm";
|
||||
// Any command that is dangerous should require op
|
||||
this.requiresOp = true;
|
||||
this.opRequired = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
this.plugin.getCommandManager().confirmQueuedCommand(sender);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user