SPIGOT-7948: Bukkit#dispatchCommand uses the wrong CommandListenerWrapper for Players

This commit is contained in:
md_5 2024-11-06 20:20:36 +11:00
parent 7b44d46401
commit 9b048cc845
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11

View File

@ -9,7 +9,6 @@ import java.util.Collections;
import java.util.List;
import net.minecraft.commands.CommandDispatcher;
import net.minecraft.commands.CommandListenerWrapper;
import net.minecraft.server.level.EntityPlayer;
import net.minecraft.server.level.WorldServer;
import net.minecraft.world.entity.vehicle.EntityMinecartCommandBlock;
import org.bukkit.Location;
@ -22,6 +21,7 @@ import org.bukkit.command.defaults.BukkitCommand;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftEntity;
import org.bukkit.craftbukkit.entity.CraftMinecartCommand;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.entity.minecart.CommandMinecart;
public final class VanillaCommandWrapper extends BukkitCommand {
@ -68,8 +68,8 @@ public final class VanillaCommandWrapper extends BukkitCommand {
return ((EntityMinecartCommandBlock) ((CraftMinecartCommand) sender).getHandle()).getCommandBlock().createCommandSourceStack();
}
if (sender instanceof EntityPlayer player) {
return player.createCommandSourceStack();
if (sender instanceof CraftPlayer player) {
return player.getHandle().createCommandSourceStack();
}
return entity.getHandle().createCommandSourceStackForNameResolution((WorldServer) entity.getHandle().level());