summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorVictorD <victor.danell@gmail.com>2011-01-16 16:35:37 +0100
committerVictorD <victor.danell@gmail.com>2011-01-16 16:35:37 +0100
commit7ea93a11059f9c36e0cbda207b7c4dc13a67c8ef (patch)
treeb5c665c46b65f0aa691a92c829a6d2a64fb35977 /src/main
parent78cd77ef713e9073f2a46c5c2a3fea90db470158 (diff)
downloadcraftbukkit-7ea93a11059f9c36e0cbda207b7c4dc13a67c8ef.tar
craftbukkit-7ea93a11059f9c36e0cbda207b7c4dc13a67c8ef.tar.gz
craftbukkit-7ea93a11059f9c36e0cbda207b7c4dc13a67c8ef.tar.lz
craftbukkit-7ea93a11059f9c36e0cbda207b7c4dc13a67c8ef.tar.xz
craftbukkit-7ea93a11059f9c36e0cbda207b7c4dc13a67c8ef.zip
Added registration of plugin commands on plugin load.
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/net/minecraft/server/NetServerHandler.java6
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftServer.java13
2 files changed, 18 insertions, 1 deletions
diff --git a/src/main/java/net/minecraft/server/NetServerHandler.java b/src/main/java/net/minecraft/server/NetServerHandler.java
index be47ba2e..5d8c0e37 100644
--- a/src/main/java/net/minecraft/server/NetServerHandler.java
+++ b/src/main/java/net/minecraft/server/NetServerHandler.java
@@ -18,6 +18,7 @@ import org.bukkit.event.block.BlockRightClickEvent;
import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerItemEvent;
import org.bukkit.event.player.PlayerMoveEvent;
+import org.bukkit.plugin.Plugin;
// CraftBukkit end
public class NetServerHandler extends NetHandler implements ICommandListener {
@@ -536,6 +537,11 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
private void c(String s) {
// CraftBukkit start
+ boolean targetPluginFound = server.dispatchCommand(player, s);
+ if (targetPluginFound) {
+ return;
+ }
+
PlayerChatEvent event = new PlayerChatEvent(Type.PLAYER_COMMAND, player, s);
server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 048feb89..d52e468e 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -10,8 +10,10 @@ import net.minecraft.server.EntityPlayerMP;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.ServerConfigurationManager;
import org.bukkit.*;
+import org.bukkit.plugin.CommandManager;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
+import org.bukkit.plugin.SimpleCommandManager;
import org.bukkit.plugin.SimplePluginManager;
import org.bukkit.plugin.java.JavaPluginLoader;
@@ -19,6 +21,7 @@ public final class CraftServer implements Server {
private final String serverName = "Craftbukkit";
private final String serverVersion = "1.2_01";
private final PluginManager pluginManager = new SimplePluginManager(this);
+ private final CommandManager commandManager = new SimpleCommandManager();
protected final MinecraftServer console;
protected final ServerConfigurationManager server;
@@ -38,7 +41,11 @@ public final class CraftServer implements Server {
Plugin[] plugins = pluginManager.loadPlugins(pluginFolder);
for (Plugin plugin : plugins) {
- pluginManager.enablePlugin(plugin);
+ if (commandManager.registerCommands(plugin)) {
+ pluginManager.enablePlugin(plugin);
+ } else {
+ Logger.getLogger(CraftServer.class.getName()).log(Level.SEVERE, "Plugin " + plugin.getDescription().getName() + " failed to load. Reason: Requested commands already in use.");
+ }
}
} catch (Throwable ex) {
Logger.getLogger(CraftServer.class.getName()).log(Level.SEVERE, ex.getMessage() + " (Is it up to date?)", ex);
@@ -133,4 +140,8 @@ public final class CraftServer implements Server {
public ServerConfigurationManager getHandle() {
return server;
}
+
+ public boolean dispatchCommand(Player player, String cmd) {
+ return commandManager.dispatchCommand(player, cmd);
+ }
}