Paper/nms-patches/CommandListenerWrapper.patch
2020-06-25 10:00:00 +10:00

62 Zeilen
2.5 KiB
Diff

--- a/net/minecraft/server/CommandListenerWrapper.java
+++ b/net/minecraft/server/CommandListenerWrapper.java
@@ -7,6 +7,7 @@
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
import com.mojang.brigadier.suggestion.Suggestions;
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
+import com.mojang.brigadier.tree.CommandNode;
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;
@@ -32,6 +33,7 @@
private final ResultConsumer<CommandListenerWrapper> l;
private final ArgumentAnchor.Anchor m;
private final Vec2F n;
+ public CommandNode currentCommand; // CraftBukkit
public CommandListenerWrapper(ICommandListener icommandlistener, Vec3D vec3d, Vec2F vec2f, WorldServer worldserver, int i, String s, IChatBaseComponent ichatbasecomponent, MinecraftServer minecraftserver, @Nullable Entity entity) {
this(icommandlistener, vec3d, vec2f, worldserver, i, s, ichatbasecomponent, minecraftserver, entity, false, (commandcontext, flag, j) -> {
@@ -121,9 +123,22 @@
@Override
public boolean hasPermission(int i) {
+ // CraftBukkit start
+ if (currentCommand != null) {
+ return hasPermission(i, org.bukkit.craftbukkit.command.VanillaCommandWrapper.getPermission(currentCommand));
+ }
+ // CraftBukkit end
+
return this.f >= i;
}
+ // CraftBukkit start
+ public boolean hasPermission(int i, String bukkitPermission) {
+ // World is null when loading functions
+ return ((getWorld() == null || !getWorld().getServer().ignoreVanillaPermissions) && this.f >= i) || getBukkitSender().hasPermission(bukkitPermission);
+ }
+ // CraftBukkit end
+
public Vec3D getPosition() {
return this.d;
}
@@ -185,7 +200,7 @@
while (iterator.hasNext()) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
- if (entityplayer != this.base && this.i.getPlayerList().isOp(entityplayer.getProfile())) {
+ if (entityplayer != this.base && entityplayer.getBukkitEntity().hasPermission("minecraft.admin.command_feedback")) { // CraftBukkit
entityplayer.sendMessage(ichatmutablecomponent, SystemUtils.b);
}
}
@@ -240,4 +255,10 @@
public Set<ResourceKey<World>> p() {
return this.i.E();
}
+
+ // CraftBukkit start
+ public org.bukkit.command.CommandSender getBukkitSender() {
+ return base.getBukkitSender(this);
+ }
+ // CraftBukkit end
}