Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-18 04:20:08 +01:00
Wrap player's ICommandListener so that our permission system can handle permission
for vanilla commands
Dieser Commit ist enthalten in:
Ursprung
81db41b4d2
Commit
54888dfafb
69
src/main/java/org/bukkit/craftbukkit/command/ListenerWrapper.java
Normale Datei
69
src/main/java/org/bukkit/craftbukkit/command/ListenerWrapper.java
Normale Datei
@ -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);
|
||||
}
|
||||
|
||||
}
|
@ -127,7 +127,7 @@ public final class VanillaCommandWrapper extends VanillaCommand {
|
||||
|
||||
private ICommandListener getListener(CommandSender sender) {
|
||||
if (sender instanceof Player) {
|
||||
return ((CraftPlayer) sender).getHandle();
|
||||
return new ListenerWrapper(((CraftPlayer) sender).getHandle());
|
||||
}
|
||||
if (sender instanceof BlockCommandSender) {
|
||||
return ((CraftBlockCommandSender) sender).getTileEntity();
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren