now using new command system

This commit is contained in:
Redecouverte 2011-02-28 10:15:47 +01:00
parent 82dc78523f
commit e4d05e14ac
4 changed files with 22 additions and 12 deletions

View File

@ -88,6 +88,8 @@ public void onBlockDamage(BlockDamageEvent event) {
return;
}
}
}
/**

View File

@ -78,6 +78,7 @@ public void onEntityDamageByBlock(EntityDamageByBlockEvent event) {
event.setCancelled(true);
return;
}
}
}

View File

@ -19,8 +19,6 @@
package com.sk89q.worldguard.bukkit;
import java.util.logging.*;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event;
import org.bukkit.plugin.java.JavaPlugin;
@ -58,6 +56,7 @@ public void onEnable() {
getDataFolder().mkdirs();
globalRegionManager.onEnable();
registerEvents();
commandHandler.registerCommands();
logger.info("WorldGuard " + this.getDescription().getVersion() + " enabled.");
}
@ -106,13 +105,6 @@ private void registerEvents() {
this.getServer().getScheduler().scheduleSyncRepeatingTask(this, new TimedFlagsTimer(this), 25 * 5, 25 * 5);
}
/**
* Handles a command.
*/
@Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
return commandHandler.handleCommand(sender, cmd, commandLabel, args);
}
/**
* Get the GlobalRegionManager.

View File

@ -25,14 +25,16 @@
import java.util.Map;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Player;
/**
*
* @author Michael
*/
public class CommandHandler {
public class CommandHandler implements CommandExecutor {
private WorldGuardPlugin wg;
private Map<String, WgCommand> commandMap;
@ -68,8 +70,20 @@ public CommandHandler(WorldGuardPlugin wg)
this.commandMap.put("tpregrion", new CommandTpRegion());
}
public boolean handleCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
public void registerCommands()
{
for(String cmd : this.commandMap.keySet())
{
PluginCommand command = wg.getCommand(cmd);
if(command != null)
{
command.setExecutor(this);
}
}
}
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
try {
String cmdName = cmd.getName().toLowerCase();
@ -134,6 +148,7 @@ public static void checkArgs(String[] args, int min, int max, String help)
}
}
/**
* Thrown when command handling has raised an exception.
*