3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-18 04:20:08 +01:00

Redirect execute through our command system and allow entities to be CommandSenders

Dieser Commit ist enthalten in:
Thinkofdeath 2015-01-04 23:25:31 +00:00
Ursprung 922e0a1a7f
Commit 6ac32df219
2 geänderte Dateien mit 161 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,62 @@
--- ../work/decompile-8eb82bde//net/minecraft/server/CommandExecute.java 2015-01-04 23:24:40.781538505 +0000
+++ src/main/java/net/minecraft/server/CommandExecute.java 2015-01-04 23:24:40.781538505 +0000
@@ -2,6 +2,7 @@
import java.util.Collection;
import java.util.List;
+import org.bukkit.craftbukkit.command.ProxiedNativeCommandSender;
public class CommandExecute extends CommandAbstract {
@@ -19,7 +20,7 @@
return "commands.execute.usage";
}
- public void execute(ICommandListener icommandlistener, String[] astring) {
+ public void execute(ICommandListener icommandlistener, String[] astring) throws ExceptionUsage, CommandException { // CraftBukkit - added throws
if (astring.length < 5) {
throw new ExceptionUsage("commands.execute.usage", new Object[0]);
} else {
@@ -52,12 +53,28 @@
ICommandHandler icommandhandler = MinecraftServer.getServer().getCommandHandler();
try {
- int j = icommandhandler.a(commandlistenerentity, s);
-
+ // CraftBukkit start
+ org.bukkit.command.CommandSender sender = null;
+ if (icommandlistener.f() != null) {
+ sender = icommandlistener.f().getBukkitEntity();
+ } else if (icommandlistener instanceof DedicatedServer) {
+ sender = MinecraftServer.getServer().server.getConsoleSender();
+ } else if (icommandlistener instanceof TileEntityCommandListener) {
+ sender = ((TileEntityCommandListener) icommandlistener).sender;
+ } else {
+ throw new CommandException("Unhandled executor " + icommandlistener.getClass().getSimpleName(), new Object[0]);
+ }
+ int j = CommandBlockListenerAbstract.executeCommand(commandlistenerentity, new ProxiedNativeCommandSender(commandlistenerentity, sender, entity.getBukkitEntity()), s); // icommandhandler.a(commandlistenerentity, s);
+ // CraftBukkit end
if (j < 1) {
throw new CommandException("commands.execute.allInvocationsFailed", new Object[] { s});
}
} catch (Throwable throwable) {
+ // CraftBukkit start
+ if (throwable instanceof CommandException) {
+ throw (CommandException) throwable;
+ }
+ // CraftBukkit end
throw new CommandException("commands.execute.failed", new Object[] { s, entity.getName()});
}
}
@@ -70,4 +87,11 @@
public boolean isListStart(String[] astring, int i) {
return i == 0;
}
+
+ // CraftBukkit start - fix decompiler error
+ @Override
+ public int compareTo(Object o) {
+ return a((ICommand) o);
+ }
+ // CraftBukkit end
}

Datei anzeigen

@ -1,6 +1,7 @@
package org.bukkit.craftbukkit.entity;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import net.minecraft.server.*;
@ -14,10 +15,28 @@ import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.permissions.PermissibleBase;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionAttachment;
import org.bukkit.permissions.PermissionAttachmentInfo;
import org.bukkit.permissions.ServerOperator;
import org.bukkit.plugin.Plugin;
import org.bukkit.util.Vector;
public abstract class CraftEntity implements org.bukkit.entity.Entity {
private static final PermissibleBase perm = new PermissibleBase(new ServerOperator() {
@Override
public boolean isOp() {
return false;
}
@Override
public void setOp(boolean value) {
}
});
protected final CraftServer server;
protected Entity entity;
private EntityDamageEvent lastDamageEvent;
@ -436,4 +455,84 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
public boolean isCustomNameVisible() {
return getHandle().getCustomNameVisible();
}
@Override
public void sendMessage(String message) {
}
@Override
public void sendMessage(String[] messages) {
}
@Override
public String getName() {
return getHandle().getName();
}
@Override
public boolean isPermissionSet(String name) {
return perm.isPermissionSet(name);
}
@Override
public boolean isPermissionSet(Permission perm) {
return CraftEntity.perm.isPermissionSet(perm);
}
@Override
public boolean hasPermission(String name) {
return perm.hasPermission(name);
}
@Override
public boolean hasPermission(Permission perm) {
return this.perm.hasPermission(perm);
}
@Override
public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value) {
return perm.addAttachment(plugin, name, value);
}
@Override
public PermissionAttachment addAttachment(Plugin plugin) {
return perm.addAttachment(plugin);
}
@Override
public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value, int ticks) {
return perm.addAttachment(plugin, name, value, ticks);
}
@Override
public PermissionAttachment addAttachment(Plugin plugin, int ticks) {
return perm.addAttachment(plugin, ticks);
}
@Override
public void removeAttachment(PermissionAttachment attachment) {
perm.removeAttachment(attachment);
}
@Override
public void recalculatePermissions() {
perm.recalculatePermissions();
}
@Override
public Set<PermissionAttachmentInfo> getEffectivePermissions() {
return perm.getEffectivePermissions();
}
@Override
public boolean isOp() {
return perm.isOp();
}
@Override
public void setOp(boolean value) {
perm.setOp(value);
}
}