Improved PacketWindowItems and DisplayFrame
This commit is contained in:
@@ -14,7 +14,7 @@ import org.bukkit.inventory.ItemStack
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
class PacketWindowItems(plugin: EcoPlugin) : AbstractPacketAdapter(plugin, PacketType.Play.Server.WINDOW_ITEMS, false) {
|
||||
private val ignorePacketList = ConcurrentHashMap.newKeySet<String>()
|
||||
private val lastKnownWindowIDs = ConcurrentHashMap<String, Int>()
|
||||
|
||||
override fun onSend(
|
||||
packet: PacketContainer,
|
||||
@@ -27,19 +27,19 @@ class PacketWindowItems(plugin: EcoPlugin) : AbstractPacketAdapter(plugin, Packe
|
||||
)
|
||||
}
|
||||
|
||||
if (ignorePacketList.contains(player.name)) {
|
||||
ignorePacketList.remove(player.name)
|
||||
return
|
||||
}
|
||||
|
||||
val windowId = packet.integers.read(0)
|
||||
|
||||
// TODO
|
||||
/*
|
||||
Bug here is that sometimes a non-zero window ID packet is then proceeded by three
|
||||
zero ones, causing display frame bugs.
|
||||
*/
|
||||
if (windowId != 0) {
|
||||
// Using name because UUID is unreliable with ProtocolLib players.
|
||||
val name = player.name
|
||||
|
||||
val lastKnownID = lastKnownWindowIDs[name]
|
||||
lastKnownWindowIDs[name] = windowId
|
||||
|
||||
// If there is any change in window ID at any point,
|
||||
// Remove the last display frame to prevent any potential conflicts.
|
||||
// If the window ID is not zero (not a player inventory), then remove too,
|
||||
// as GUIs are not player inventories.
|
||||
if (lastKnownID != windowId || windowId != 0) {
|
||||
player.lastDisplayFrame = DisplayFrame.EMPTY
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user