mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-19 15:09:15 +00:00
fix(gui): 修复某些 GUI 界面导致严重卡服的问题
This commit is contained in:
@@ -3,6 +3,7 @@ package net.momirealms.craftengine.bukkit.plugin.gui;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.momirealms.craftengine.bukkit.nms.FastNMS;
|
||||
import net.momirealms.craftengine.bukkit.plugin.BukkitCraftEngine;
|
||||
import net.momirealms.craftengine.bukkit.plugin.reflection.bukkit.CraftBukkitReflections;
|
||||
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.CoreReflections;
|
||||
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.NetworkReflections;
|
||||
import net.momirealms.craftengine.bukkit.util.ComponentUtils;
|
||||
@@ -91,6 +92,9 @@ public class BukkitGuiManager implements GuiManager, Listener {
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
org.bukkit.inventory.Inventory inventory = event.getInventory();
|
||||
if (!CraftBukkitReflections.clazz$MinecraftInventory.isInstance(FastNMS.INSTANCE.method$CraftInventory$getInventory(inventory))) {
|
||||
return;
|
||||
}
|
||||
if (!(inventory.getHolder() instanceof CraftEngineInventoryHolder craftEngineInventoryHolder)) {
|
||||
return;
|
||||
}
|
||||
@@ -106,6 +110,9 @@ public class BukkitGuiManager implements GuiManager, Listener {
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOW)
|
||||
public void onInventoryDrag(InventoryDragEvent event) {
|
||||
org.bukkit.inventory.Inventory inventory = event.getInventory();
|
||||
if (!CraftBukkitReflections.clazz$MinecraftInventory.isInstance(FastNMS.INSTANCE.method$CraftInventory$getInventory(inventory))) {
|
||||
return;
|
||||
}
|
||||
if (!(inventory.getHolder() instanceof CraftEngineInventoryHolder)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -353,4 +353,8 @@ public final class CraftBukkitReflections {
|
||||
public static final Method method$Level$getCraftWorld = requireNonNull(
|
||||
ReflectionUtils.getMethod(CoreReflections.clazz$Level, clazz$CraftWorld)
|
||||
);
|
||||
|
||||
public static final Class<?> clazz$MinecraftInventory = requireNonNull(
|
||||
ReflectionUtils.getClazz(BukkitReflectionUtils.assembleCBClass("inventory.CraftInventoryCustom$MinecraftInventory"))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import net.momirealms.craftengine.bukkit.nms.FastNMS;
|
||||
import net.momirealms.craftengine.bukkit.plugin.BukkitCraftEngine;
|
||||
import net.momirealms.craftengine.bukkit.plugin.gui.CraftEngineInventoryHolder;
|
||||
import net.momirealms.craftengine.bukkit.plugin.network.payload.DiscardedPayload;
|
||||
import net.momirealms.craftengine.bukkit.plugin.reflection.bukkit.CraftBukkitReflections;
|
||||
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.CoreReflections;
|
||||
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.MAttributeHolders;
|
||||
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.MMobEffects;
|
||||
@@ -456,6 +457,9 @@ public class BukkitServerPlayer extends Player {
|
||||
|
||||
private void updateGUI() {
|
||||
org.bukkit.inventory.Inventory top = !VersionHelper.isOrAbove1_21() ? LegacyInventoryUtils.getTopInventory(platformPlayer()) : platformPlayer().getOpenInventory().getTopInventory();
|
||||
if (!CraftBukkitReflections.clazz$MinecraftInventory.isInstance(FastNMS.INSTANCE.method$CraftInventory$getInventory(top))) {
|
||||
return;
|
||||
}
|
||||
if (top.getHolder() instanceof CraftEngineInventoryHolder holder) {
|
||||
holder.gui().onTimer();
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ byte_buddy_version=1.17.5
|
||||
ahocorasick_version=0.6.3
|
||||
snake_yaml_version=2.4
|
||||
anti_grief_version=0.18
|
||||
nms_helper_version=1.0.54
|
||||
nms_helper_version=1.0.55
|
||||
evalex_version=3.5.0
|
||||
reactive_streams_version=1.0.4
|
||||
amazon_awssdk_version=2.31.23
|
||||
|
||||
Reference in New Issue
Block a user