Fix minecraft.command.selector permission

This commit is contained in:
md_5 2019-01-18 15:59:21 +11:00
parent 47b06d5b4e
commit 7fc66b28db
2 changed files with 33 additions and 4 deletions

View File

@ -16,21 +16,30 @@
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) -> {
@@ -119,6 +121,13 @@
@@ -119,9 +121,22 @@
}
public boolean hasPermission(int i) {
+ // CraftBukkit start
+ if (currentCommand != null) {
+ // World is null when loading functions
+ return ((getWorld() == null || !getWorld().getServer().ignoreVanillaPermissions) && this.f >= i) || getBukkitSender().hasPermission(org.bukkit.craftbukkit.command.VanillaCommandWrapper.getPermission(currentCommand));
+ return hasPermission(i, org.bukkit.craftbukkit.command.VanillaCommandWrapper.getPermission(currentCommand));
+ }
+ // CraftBukkit end
+
return this.f >= i;
}
@@ -232,4 +241,10 @@
+ // 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;
}
@@ -232,4 +247,10 @@
public Collection<ICompletionProvider.a> a(boolean flag) {
return Collections.singleton(ICompletionProvider.a.b);
}

View File

@ -0,0 +1,20 @@
--- a/net/minecraft/server/EntitySelector.java
+++ b/net/minecraft/server/EntitySelector.java
@@ -63,7 +63,7 @@
}
private void e(CommandListenerWrapper commandlistenerwrapper) throws CommandSyntaxException {
- if (this.m && !commandlistenerwrapper.hasPermission(2)) {
+ if (this.m && !commandlistenerwrapper.hasPermission(2, "minecraft.command.selector")) { // CraftBukkit
throw ArgumentEntity.f.create();
}
}
@@ -139,7 +139,7 @@
AxisAlignedBB axisalignedbb = this.g.a(vec3d);
predicate.getClass();
- list.addAll(worldserver.a(oclass, axisalignedbb, predicate::test));
+ list.addAll(worldserver.a(oclass, axisalignedbb, (java.util.function.Predicate<Entity>) predicate::test)); // CraftBukkit - decompile error
} else {
oclass = this.l;
predicate.getClass();