@@ -1,7 +1,6 @@
|
||||
package org.bukkit.craftbukkit.command;
|
||||
|
||||
import net.minecraft.server.ICommandListener;
|
||||
import net.minecraft.server.CommandBlockListenerAbstract;
|
||||
import net.minecraft.server.IChatBaseComponent;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
@@ -12,20 +11,20 @@ import org.bukkit.craftbukkit.util.CraftChatMessage;
|
||||
* Represents input from a command block
|
||||
*/
|
||||
public class CraftBlockCommandSender extends ServerCommandSender implements BlockCommandSender {
|
||||
private final CommandBlockListenerAbstract commandBlock;
|
||||
private final ICommandListener block;
|
||||
|
||||
public CraftBlockCommandSender(CommandBlockListenerAbstract commandBlockListenerAbstract) {
|
||||
public CraftBlockCommandSender(ICommandListener commandBlockListenerAbstract) {
|
||||
super();
|
||||
this.commandBlock = commandBlockListenerAbstract;
|
||||
this.block = commandBlockListenerAbstract;
|
||||
}
|
||||
|
||||
public Block getBlock() {
|
||||
return commandBlock.getWorld().getWorld().getBlockAt(commandBlock.getChunkCoordinates().getX(), commandBlock.getChunkCoordinates().getY(), commandBlock.getChunkCoordinates().getZ());
|
||||
return block.getWorld().getWorld().getBlockAt(block.getChunkCoordinates().getX(), block.getChunkCoordinates().getY(), block.getChunkCoordinates().getZ());
|
||||
}
|
||||
|
||||
public void sendMessage(String message) {
|
||||
for (IChatBaseComponent component : CraftChatMessage.fromString(message)) {
|
||||
commandBlock.sendMessage(component);
|
||||
block.sendMessage(component);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +35,7 @@ public class CraftBlockCommandSender extends ServerCommandSender implements Bloc
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return commandBlock.getName();
|
||||
return block.getName();
|
||||
}
|
||||
|
||||
public boolean isOp() {
|
||||
@@ -48,6 +47,6 @@ public class CraftBlockCommandSender extends ServerCommandSender implements Bloc
|
||||
}
|
||||
|
||||
public ICommandListener getTileEntity() {
|
||||
return commandBlock;
|
||||
return block;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,13 +5,16 @@ import net.minecraft.server.RemoteControlCommandListener;
|
||||
import org.bukkit.command.RemoteConsoleCommandSender;
|
||||
|
||||
public class CraftRemoteConsoleCommandSender extends ServerCommandSender implements RemoteConsoleCommandSender {
|
||||
public CraftRemoteConsoleCommandSender() {
|
||||
super();
|
||||
|
||||
private final RemoteControlCommandListener listener;
|
||||
|
||||
public CraftRemoteConsoleCommandSender(RemoteControlCommandListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
RemoteControlCommandListener.getInstance().sendMessage(new ChatComponentText(message + "\n")); // Send a newline after each message, to preserve formatting.
|
||||
listener.sendMessage(new ChatComponentText(message + "\n")); // Send a newline after each message, to preserve formatting.
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -49,7 +49,7 @@ public final class VanillaCommandWrapper extends VanillaCommand {
|
||||
Validate.notNull(sender, "Sender cannot be null");
|
||||
Validate.notNull(args, "Arguments cannot be null");
|
||||
Validate.notNull(alias, "Alias cannot be null");
|
||||
return (List<String>) vanillaCommand.tabComplete(getListener(sender), args, new BlockPosition(0, 0, 0));
|
||||
return (List<String>) vanillaCommand.tabComplete(MinecraftServer.getServer(), getListener(sender), args, new BlockPosition(0, 0, 0));
|
||||
}
|
||||
|
||||
public static CommandSender lastSender = null; // Nasty :(
|
||||
@@ -75,7 +75,7 @@ public final class VanillaCommandWrapper extends VanillaCommand {
|
||||
}
|
||||
|
||||
try {
|
||||
if (vanillaCommand.canUse(icommandlistener)) {
|
||||
if (vanillaCommand.canUse(server, icommandlistener)) {
|
||||
if (i > -1) {
|
||||
List<Entity> list = ((List<Entity>)PlayerSelector.getPlayers(icommandlistener, as[i], Entity.class));
|
||||
String s2 = as[i];
|
||||
@@ -90,14 +90,14 @@ public final class VanillaCommandWrapper extends VanillaCommand {
|
||||
lastSender = bSender;
|
||||
try {
|
||||
as[i] = entity.getUniqueID().toString();
|
||||
vanillaCommand.execute(icommandlistener, as);
|
||||
vanillaCommand.execute(server, icommandlistener, as);
|
||||
j++;
|
||||
} catch (ExceptionUsage exceptionusage) {
|
||||
ChatMessage chatmessage = new ChatMessage("commands.generic.usage", new Object[] { new ChatMessage(exceptionusage.getMessage(), exceptionusage.getArgs())});
|
||||
chatmessage.getChatModifier().setColor(EnumChatFormat.RED);
|
||||
icommandlistener.sendMessage(chatmessage);
|
||||
} catch (CommandException commandexception) {
|
||||
CommandAbstract.a(icommandlistener, vanillaCommand, 1, commandexception.getMessage(), commandexception.getArgs());
|
||||
CommandAbstract.a(icommandlistener, vanillaCommand, 0, commandexception.getMessage(), commandexception.getArgs());
|
||||
} finally {
|
||||
lastSender = oldSender;
|
||||
}
|
||||
@@ -105,7 +105,7 @@ public final class VanillaCommandWrapper extends VanillaCommand {
|
||||
as[i] = s2;
|
||||
} else {
|
||||
icommandlistener.a(CommandObjectiveExecutor.EnumCommandResult.AFFECTED_ENTITIES, 1);
|
||||
vanillaCommand.execute(icommandlistener, as);
|
||||
vanillaCommand.execute(server, icommandlistener, as);
|
||||
j++;
|
||||
}
|
||||
} else {
|
||||
@@ -118,7 +118,7 @@ public final class VanillaCommandWrapper extends VanillaCommand {
|
||||
chatmessage1.getChatModifier().setColor(EnumChatFormat.RED);
|
||||
icommandlistener.sendMessage(chatmessage1);
|
||||
} catch (CommandException commandexception) {
|
||||
CommandAbstract.a(icommandlistener, vanillaCommand, 1, commandexception.getMessage(), commandexception.getArgs());
|
||||
CommandAbstract.a(icommandlistener, vanillaCommand, 0, commandexception.getMessage(), commandexception.getArgs());
|
||||
} catch (Throwable throwable) {
|
||||
ChatMessage chatmessage3 = new ChatMessage("commands.generic.exception", new Object[0]);
|
||||
chatmessage3.getChatModifier().setColor(EnumChatFormat.RED);
|
||||
@@ -149,7 +149,7 @@ public final class VanillaCommandWrapper extends VanillaCommand {
|
||||
return ((EntityMinecartCommandBlock) ((CraftMinecartCommand) sender).getHandle()).getCommandBlock();
|
||||
}
|
||||
if (sender instanceof RemoteConsoleCommandSender) {
|
||||
return RemoteControlCommandListener.getInstance();
|
||||
return ((DedicatedServer)MinecraftServer.getServer()).remoteControlCommandListener;
|
||||
}
|
||||
if (sender instanceof ConsoleCommandSender) {
|
||||
return ((CraftServer) sender.getServer()).getServer();
|
||||
|
||||
Reference in New Issue
Block a user