mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-30 12:29:15 +00:00
feat(bukkit): 初步更新1.21.6
This commit is contained in:
@@ -396,7 +396,7 @@ public class BukkitFurnitureManager extends AbstractFurnitureManager {
|
||||
for (Entity bukkitEntity : nearbyEntities) {
|
||||
if (bukkitEntity instanceof Player) continue;
|
||||
Object nmsEntity = FastNMS.INSTANCE.method$CraftEntity$getHandle(bukkitEntity);
|
||||
return (boolean) CoreReflections.method$Entity$canBeCollidedWith.invoke(nmsEntity);
|
||||
return FastNMS.INSTANCE.method$Entity$canBeCollidedWith(nmsEntity);
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
return false;
|
||||
|
||||
@@ -485,6 +485,7 @@ public class BukkitNetworkManager implements NetworkManager, Listener, PluginMes
|
||||
|
||||
@Override
|
||||
public void write(ChannelHandlerContext context, Object packet, ChannelPromise channelPromise) throws Exception {
|
||||
boolean isWrote = false;
|
||||
try {
|
||||
NMSPacketEvent event = new NMSPacketEvent(packet);
|
||||
onNMSPacketSend(player, event, packet);
|
||||
@@ -494,6 +495,8 @@ public class BukkitNetworkManager implements NetworkManager, Listener, PluginMes
|
||||
} else {
|
||||
super.write(context, packet, channelPromise);
|
||||
}
|
||||
isWrote = true;
|
||||
if (VersionHelper.isOrAbove1_21_6()) return; // TODO: 需排查为什么从 1.21.6 开始执行 addListener 后会报错
|
||||
channelPromise.addListener((p) -> {
|
||||
for (Runnable task : event.getDelayedTasks()) {
|
||||
task.run();
|
||||
@@ -501,7 +504,9 @@ public class BukkitNetworkManager implements NetworkManager, Listener, PluginMes
|
||||
});
|
||||
} catch (Throwable e) {
|
||||
plugin.logger().severe("An error occurred when reading packets. Packet class: " + packet.getClass(), e);
|
||||
super.write(context, packet, channelPromise);
|
||||
if (!isWrote) {
|
||||
super.write(context, packet, channelPromise);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -200,12 +200,12 @@ public final class CoreReflections {
|
||||
)
|
||||
);
|
||||
|
||||
public static final Class<?> clazz$Component$Serializer = requireNonNull(
|
||||
// 1.20~1.21.5
|
||||
public static final Class<?> clazz$Component$Serializer =
|
||||
BukkitReflectionUtils.findReobfOrMojmapClass(
|
||||
"network.chat.IChatBaseComponent$ChatSerializer",
|
||||
"network.chat.Component$Serializer"
|
||||
)
|
||||
);
|
||||
);
|
||||
|
||||
public static final Class<?> clazz$ComponentContents = requireNonNull(
|
||||
ReflectionUtils.getClazz(
|
||||
@@ -2533,30 +2533,6 @@ public final class CoreReflections {
|
||||
ReflectionUtils.getMethod(clazz$AttributeInstance, void.class, double.class)
|
||||
);
|
||||
|
||||
public static final Method method$Entity$canBeCollidedWith = requireNonNull(
|
||||
VersionHelper.isOrAbove1_20_5()
|
||||
? ReflectionUtils.getMethod(clazz$Entity, boolean.class, new String[]{"canBeCollidedWith"})
|
||||
: VersionHelper.isOrAbove1_20_3()
|
||||
? ReflectionUtils.getMethod(clazz$Entity, boolean.class, new String[]{"bz"})
|
||||
: VersionHelper.isOrAbove1_20_2()
|
||||
? ReflectionUtils.getMethod(clazz$Entity, boolean.class, new String[]{"bx"})
|
||||
: VersionHelper.isOrAbove1_20()
|
||||
? ReflectionUtils.getMethod(clazz$Entity, boolean.class, new String[]{"bu"})
|
||||
: ReflectionUtils.getMethod(clazz$Entity, boolean.class, new String[]{"canBeCollidedWith", "bu", "bx", "bz"})
|
||||
);
|
||||
|
||||
public static final Method method$Entity$getId = requireNonNull(
|
||||
VersionHelper.isOrAbove1_20_5()
|
||||
? ReflectionUtils.getMethod(clazz$Entity, int.class, new String[]{"getId"})
|
||||
: VersionHelper.isOrAbove1_20_3()
|
||||
? ReflectionUtils.getMethod(clazz$Entity, int.class, new String[]{"aj"})
|
||||
: VersionHelper.isOrAbove1_20_2()
|
||||
? ReflectionUtils.getMethod(clazz$Entity, int.class, new String[]{"ah"})
|
||||
: VersionHelper.isOrAbove1_20()
|
||||
? ReflectionUtils.getMethod(clazz$Entity, int.class, new String[]{"af"})
|
||||
: ReflectionUtils.getMethod(clazz$Entity, int.class, new String[]{"getId", "aj", "ah", "af"})
|
||||
);
|
||||
|
||||
public static final Class<?> clazz$Rotation = requireNonNull(
|
||||
BukkitReflectionUtils.findReobfOrMojmapClass(
|
||||
"world.level.block.EnumBlockRotation",
|
||||
|
||||
Reference in New Issue
Block a user