From 21b8c16886ad4b4fd5cfeaa5a03bc15c8af95077 Mon Sep 17 00:00:00 2001 From: Dinnerbone Date: Tue, 1 Feb 2011 18:13:12 +0000 Subject: [PATCH] Commands can be sent from the console (WIP, needs improvements) --- src/main/java/net/minecraft/server/MinecraftServer.java | 8 ++++++++ src/main/java/net/minecraft/server/NetServerHandler.java | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java index af37abb28f..fca5b9d4e8 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -15,6 +15,7 @@ import java.util.logging.Logger; // CraftBukkit start import java.net.UnknownHostException; import joptsimple.OptionSet; +import org.bukkit.command.ConsoleCommandSender; import org.bukkit.craftbukkit.CraftServer; // CraftBukkit end @@ -46,6 +47,7 @@ public class MinecraftServer implements ICommandListener, Runnable { } public CraftServer server; public OptionSet options; + public ConsoleCommandSender console = new ConsoleCommandSender(); private boolean d() throws UnknownHostException { // CraftBukkit end -- added throws UnknownHostException @@ -299,6 +301,12 @@ public class MinecraftServer implements ICommandListener, Runnable { ICommandListener icommandlistener = servercommand.b; String s1 = icommandlistener.c(); + // Craftbukkit start + if (server.dispatchCommand(console, s)) { + continue; + } + // Craftbukkit end + if (!s.toLowerCase().startsWith("help") && !s.toLowerCase().startsWith("?")) { if (s.toLowerCase().startsWith("list")) { icommandlistener.b("Connected players: " + this.f.c()); diff --git a/src/main/java/net/minecraft/server/NetServerHandler.java b/src/main/java/net/minecraft/server/NetServerHandler.java index 5ce2485bc8..64df900d2a 100644 --- a/src/main/java/net/minecraft/server/NetServerHandler.java +++ b/src/main/java/net/minecraft/server/NetServerHandler.java @@ -581,7 +581,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { private void c(String s) { // CraftBukkit start CraftPlayer player = getPlayer(); - boolean targetPluginFound = server.dispatchCommand(player, s); + boolean targetPluginFound = server.dispatchCommand(player, s.substring(1)); if (targetPluginFound) { return; }