Fixed duplicate console and player messages when built in server commands where used or an unknown command was issued

This commit is contained in:
stevenh
2011-05-22 20:24:44 +01:00
parent 6319a19073
commit 8b0924bbb4
4 changed files with 77 additions and 30 deletions

View File

@@ -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) {