summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/bukkit
diff options
context:
space:
mode:
authorstevenh <steven.hartland@multiplay.co.uk>2011-05-22 20:24:44 +0100
committerstevenh <steven.hartland@multiplay.co.uk>2011-05-22 20:30:01 +0100
commit8b0924bbb449d1bf7d38d1d4743b383ba0ae0471 (patch)
tree2255e95b111a1f482a6268c54ec1c249f8a18aa3 /src/main/java/org/bukkit
parent6319a19073b10bc5f2d16ac7ce104b5ced267cdc (diff)
downloadcraftbukkit-8b0924bbb449d1bf7d38d1d4743b383ba0ae0471.tar
craftbukkit-8b0924bbb449d1bf7d38d1d4743b383ba0ae0471.tar.gz
craftbukkit-8b0924bbb449d1bf7d38d1d4743b383ba0ae0471.tar.lz
craftbukkit-8b0924bbb449d1bf7d38d1d4743b383ba0ae0471.tar.xz
craftbukkit-8b0924bbb449d1bf7d38d1d4743b383ba0ae0471.zip
Fixed duplicate console and player messages when built in server commands where used or an unknown command was issued
Diffstat (limited to 'src/main/java/org/bukkit')
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftServer.java22
-rw-r--r--src/main/java/org/bukkit/craftbukkit/command/ServerCommandListener.java36
2 files changed, 38 insertions, 20 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 04246e2f..e245e549 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -48,6 +48,7 @@ import org.bukkit.craftbukkit.inventory.CraftFurnaceRecipe;
import org.bukkit.craftbukkit.inventory.CraftRecipe;
import org.bukkit.craftbukkit.inventory.CraftShapedRecipe;
import org.bukkit.craftbukkit.inventory.CraftShapelessRecipe;
+import org.bukkit.craftbukkit.command.ServerCommandListener;
import org.bukkit.scheduler.BukkitWorker;
import org.bukkit.scheduler.BukkitTask;
import org.bukkit.craftbukkit.scheduler.CraftScheduler;
@@ -284,7 +285,7 @@ public final class CraftServer implements Server {
}
// See if the server can process this command
- return console.consoleCommandHandler.handle(new ServerCommand(commandLine, new CommandListener(sender)));
+ return console.consoleCommandHandler.handle(new ServerCommand(commandLine, new ServerCommandListener(sender)));
}
public void reload() {
@@ -451,25 +452,6 @@ public final class CraftServer implements Server {
config.setDataSourceConfig(ds);
}
- // Inner class to capture the output of default server commands
- class CommandListener implements ICommandListener {
- private final CommandSender commandSender;
- private final String prefix;
- CommandListener(CommandSender commandSender) {
- this.commandSender = commandSender;
- String[] parts = commandSender.getClass().getName().split("\\.");
- this.prefix = parts[parts.length-1];
- }
-
- public void sendMessage(String msg) {
- this.commandSender.sendMessage(msg);
- }
-
- public String getName() {
- return this.prefix;
- }
- }
-
public boolean addRecipe(Recipe recipe) {
CraftRecipe toAdd;
if(recipe instanceof CraftRecipe) {
diff --git a/src/main/java/org/bukkit/craftbukkit/command/ServerCommandListener.java b/src/main/java/org/bukkit/craftbukkit/command/ServerCommandListener.java
new file mode 100644
index 00000000..f8d38d6a
--- /dev/null
+++ b/src/main/java/org/bukkit/craftbukkit/command/ServerCommandListener.java
@@ -0,0 +1,36 @@
+package org.bukkit.craftbukkit.command;
+
+import java.lang.reflect.Method;
+
+import net.minecraft.server.ICommandListener;
+
+import org.bukkit.command.CommandSender;
+
+public class ServerCommandListener implements ICommandListener {
+ private final CommandSender commandSender;
+ private final String prefix;
+
+ public ServerCommandListener(CommandSender commandSender) {
+ this.commandSender = commandSender;
+ String[] parts = commandSender.getClass().getName().split("\\.");
+ this.prefix = parts[parts.length-1];
+ }
+
+ public void sendMessage(String msg) {
+ this.commandSender.sendMessage(msg);
+ }
+
+ public CommandSender getSender() {
+ return commandSender;
+ }
+
+ public String getName() {
+ try {
+ Method getName = commandSender.getClass().getMethod( "getName" );
+ return (String) getName.invoke(commandSender);
+ } catch (Exception e) {
+ }
+
+ return this.prefix;
+ }
+} \ No newline at end of file