mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-31 04:46:37 +00:00
更新版本
This commit is contained in:
@@ -92,8 +92,15 @@ public class BukkitServerPlayer extends Player {
|
||||
}
|
||||
|
||||
public void setPlayer(org.bukkit.entity.Player player) {
|
||||
playerRef = new WeakReference<>(player);
|
||||
serverPlayerRef = new WeakReference<>(FastNMS.INSTANCE.method$CraftPlayer$getHandle(player));
|
||||
this.playerRef = new WeakReference<>(player);
|
||||
this.serverPlayerRef = new WeakReference<>(FastNMS.INSTANCE.method$CraftPlayer$getHandle(player));
|
||||
if (Reflections.method$CraftPlayer$setSimplifyContainerDesyncCheck != null) {
|
||||
try {
|
||||
Reflections.method$CraftPlayer$setSimplifyContainerDesyncCheck.invoke(player, true);
|
||||
} catch (Exception e) {
|
||||
this.plugin.logger().warn("Failed to setSimplifyContainerDesyncCheck", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.momirealms.craftengine.bukkit.util;
|
||||
|
||||
import net.momirealms.craftengine.bukkit.nms.FastNMS;
|
||||
import net.momirealms.craftengine.core.util.VersionHelper;
|
||||
import net.momirealms.craftengine.core.world.BlockPos;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
@@ -9,6 +10,8 @@ import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class EntityUtils {
|
||||
|
||||
private EntityUtils() {}
|
||||
@@ -23,12 +26,11 @@ public class EntityUtils {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static Entity spawnEntity(World world, Location loc, EntityType type, org.bukkit.util.Consumer<Entity> function) {
|
||||
try {
|
||||
return (Entity) Reflections.method$World$spawnEntity.invoke(world, loc, type, CreatureSpawnEvent.SpawnReason.CUSTOM, function);
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new RuntimeException("Failed to spawn entity", e);
|
||||
public static Entity spawnEntity(World world, Location loc, EntityType type, Consumer<Entity> function) {
|
||||
if (VersionHelper.isVersionNewerThan1_20_2()) {
|
||||
return world.spawnEntity(loc, type, CreatureSpawnEvent.SpawnReason.CUSTOM, function);
|
||||
} else {
|
||||
return LegacyEntityUtils.spawnEntity(world, loc, type, function);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4000,12 +4000,12 @@ public class Reflections {
|
||||
)
|
||||
);
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static final Method method$World$spawnEntity = requireNonNull(
|
||||
VersionHelper.isVersionNewerThan1_20_2() ?
|
||||
ReflectionUtils.getMethod(World.class, Entity.class, Location.class, EntityType.class, CreatureSpawnEvent.SpawnReason.class, Consumer.class) :
|
||||
ReflectionUtils.getMethod(World.class, Entity.class, Location.class, EntityType.class, CreatureSpawnEvent.SpawnReason.class, org.bukkit.util.Consumer.class)
|
||||
);
|
||||
// @SuppressWarnings("deprecation")
|
||||
// public static final Method method$World$spawnEntity = requireNonNull(
|
||||
// VersionHelper.isVersionNewerThan1_20_2() ?
|
||||
// ReflectionUtils.getMethod(World.class, Entity.class, Location.class, EntityType.class, CreatureSpawnEvent.SpawnReason.class, Consumer.class) :
|
||||
// ReflectionUtils.getMethod(World.class, Entity.class, Location.class, EntityType.class, CreatureSpawnEvent.SpawnReason.class, org.bukkit.util.Consumer.class)
|
||||
// );
|
||||
|
||||
// 1.21.4+
|
||||
public static final Class<?> clazz$ServerboundPickItemFromEntityPacket =
|
||||
@@ -6444,4 +6444,9 @@ public class Reflections {
|
||||
BukkitReflectionUtils.assembleMCClass("network.protocol.game.PacketPlayOutScoreboardScore")
|
||||
)
|
||||
);
|
||||
|
||||
public static final Method method$CraftPlayer$setSimplifyContainerDesyncCheck =
|
||||
ReflectionUtils.getMethod(
|
||||
clazz$CraftPlayer, new String[]{"setSimplifyContainerDesyncCheck"}, boolean.class
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user