13
0
geforkt von Mirrors/Paper

Wrap player's ICommandListener so that our permission system can handle permission

for vanilla commands

By: Thinkofdeath <thinkofdeath@spigotmc.org>
Dieser Commit ist enthalten in:
CraftBukkit/Spigot 2014-12-12 10:33:54 +00:00
Ursprung 63d1f2368e
Commit 4b848f5848
2 geänderte Dateien mit 70 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,69 @@
package org.bukkit.craftbukkit.command;
import net.minecraft.server.BlockPosition;
import net.minecraft.server.Entity;
import net.minecraft.server.EnumCommandResult;
import net.minecraft.server.IChatBaseComponent;
import net.minecraft.server.ICommandListener;
import net.minecraft.server.Vec3D;
import net.minecraft.server.World;
public class ListenerWrapper implements ICommandListener {
private final ICommandListener listener;
public ListenerWrapper(ICommandListener listener) {
this.listener = listener;
}
@Override
public String getName() {
return listener.getName();
}
@Override
public IChatBaseComponent getScoreboardDisplayName() {
return listener.getScoreboardDisplayName();
}
@Override
public void sendMessage(IChatBaseComponent icbc) {
listener.sendMessage(icbc);
}
@Override
public boolean a(int i, String string) {
return true; // Give access to all commands as we do our own perm check
}
@Override
public BlockPosition getChunkCoordinates() {
return listener.getChunkCoordinates();
}
@Override
public Vec3D d() {
return listener.d();
}
@Override
public World getWorld() {
return listener.getWorld();
}
@Override
public Entity f() {
return listener.f();
}
@Override
public boolean getSendCommandFeedback() {
return listener.getSendCommandFeedback();
}
@Override
public void a(EnumCommandResult ecr, int i) {
listener.a(ecr, i);
}
}

Datei anzeigen

@ -127,7 +127,7 @@ public final class VanillaCommandWrapper extends VanillaCommand {
private ICommandListener getListener(CommandSender sender) { private ICommandListener getListener(CommandSender sender) {
if (sender instanceof Player) { if (sender instanceof Player) {
return ((CraftPlayer) sender).getHandle(); return new ListenerWrapper(((CraftPlayer) sender).getHandle());
} }
if (sender instanceof BlockCommandSender) { if (sender instanceof BlockCommandSender) {
return ((CraftBlockCommandSender) sender).getTileEntity(); return ((CraftBlockCommandSender) sender).getTileEntity();