Fixed duplicate console and player messages when built in server commands where used or an unknown command was issued
By: stevenh <steven.hartland@multiplay.co.uk>
This commit is contained in:
@@ -48,6 +48,7 @@ import org.bukkit.craftbukkit.inventory.CraftFurnaceRecipe;
|
|||||||
import org.bukkit.craftbukkit.inventory.CraftRecipe;
|
import org.bukkit.craftbukkit.inventory.CraftRecipe;
|
||||||
import org.bukkit.craftbukkit.inventory.CraftShapedRecipe;
|
import org.bukkit.craftbukkit.inventory.CraftShapedRecipe;
|
||||||
import org.bukkit.craftbukkit.inventory.CraftShapelessRecipe;
|
import org.bukkit.craftbukkit.inventory.CraftShapelessRecipe;
|
||||||
|
import org.bukkit.craftbukkit.command.ServerCommandListener;
|
||||||
import org.bukkit.scheduler.BukkitWorker;
|
import org.bukkit.scheduler.BukkitWorker;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
import org.bukkit.craftbukkit.scheduler.CraftScheduler;
|
import org.bukkit.craftbukkit.scheduler.CraftScheduler;
|
||||||
@@ -284,7 +285,7 @@ public final class CraftServer implements Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// See if the server can process this command
|
// 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() {
|
public void reload() {
|
||||||
@@ -451,25 +452,6 @@ public final class CraftServer implements Server {
|
|||||||
config.setDataSourceConfig(ds);
|
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) {
|
public boolean addRecipe(Recipe recipe) {
|
||||||
CraftRecipe toAdd;
|
CraftRecipe toAdd;
|
||||||
if(recipe instanceof CraftRecipe) {
|
if(recipe instanceof CraftRecipe) {
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user