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

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot 2024-11-06 20:20:36 +11:00
parent d27615dcaf
commit b9a4bb1cd1

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());