From 7fc66b28db41ab1b677d513b2cf21e1cb948e4e1 Mon Sep 17 00:00:00 2001 From: md_5 Date: Fri, 18 Jan 2019 15:59:21 +1100 Subject: [PATCH] Fix minecraft.command.selector permission --- nms-patches/CommandListenerWrapper.patch | 17 +++++++++++++---- nms-patches/EntitySelector.patch | 20 ++++++++++++++++++++ 2 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 nms-patches/EntitySelector.patch diff --git a/nms-patches/CommandListenerWrapper.patch b/nms-patches/CommandListenerWrapper.patch index 7db763ace2..de1d751c20 100644 --- a/nms-patches/CommandListenerWrapper.patch +++ b/nms-patches/CommandListenerWrapper.patch @@ -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 a(boolean flag) { return Collections.singleton(ICompletionProvider.a.b); } diff --git a/nms-patches/EntitySelector.patch b/nms-patches/EntitySelector.patch new file mode 100644 index 0000000000..df6578f3a1 --- /dev/null +++ b/nms-patches/EntitySelector.patch @@ -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) predicate::test)); // CraftBukkit - decompile error + } else { + oclass = this.l; + predicate.getClass();