Added lots of display frame options
This commit is contained in:
@@ -21,6 +21,7 @@ import com.willfp.eco.proxy.FastItemStackFactoryProxy
|
||||
import com.willfp.eco.proxy.SkullProxy
|
||||
import com.willfp.eco.spigot.arrows.ArrowDataListener
|
||||
import com.willfp.eco.spigot.display.*
|
||||
import com.willfp.eco.spigot.display.frame.clearFrames
|
||||
import com.willfp.eco.spigot.drops.CollatedRunnable
|
||||
import com.willfp.eco.spigot.eventlisteners.EntityDeathByEntityListeners
|
||||
import com.willfp.eco.spigot.eventlisteners.NaturalExpGainListeners
|
||||
@@ -106,6 +107,11 @@ abstract class EcoSpigotPlugin : EcoPlugin(
|
||||
override fun handleReload() {
|
||||
CollatedRunnable(this)
|
||||
DropManager.update(this)
|
||||
this.scheduler.runTimer(
|
||||
{ clearFrames() },
|
||||
this.configYml.getInt("display-frame-ttl").toLong(),
|
||||
this.configYml.getInt("display-frame-ttl").toLong()
|
||||
)
|
||||
}
|
||||
|
||||
override fun handleAfterLoad() {
|
||||
|
||||
@@ -20,12 +20,16 @@ class PacketWindowItems(plugin: EcoPlugin) : AbstractPacketAdapter(plugin, Packe
|
||||
) {
|
||||
val windowId = packet.integers.read(0)
|
||||
|
||||
if (windowId != 0) {
|
||||
player.lastDisplayFrame = DisplayFrame.EMPTY
|
||||
}
|
||||
|
||||
packet.itemListModifier.modify(0) { itemStacks: List<ItemStack>? ->
|
||||
if (itemStacks == null) {
|
||||
return@modify null
|
||||
}
|
||||
|
||||
if (windowId == 0) {
|
||||
if (this.getPlugin().configYml.getBool("use-display-frame") && windowId == 0) {
|
||||
val frameMap = mutableMapOf<Byte, Int>()
|
||||
|
||||
for (index in itemStacks.indices) {
|
||||
@@ -42,9 +46,7 @@ class PacketWindowItems(plugin: EcoPlugin) : AbstractPacketAdapter(plugin, Packe
|
||||
Display.display(itemStacks[index.toInt()], player)
|
||||
}
|
||||
} else {
|
||||
itemStacks.forEach {
|
||||
Display.display(it, player)
|
||||
}
|
||||
itemStacks.forEach { Display.display(it, player) }
|
||||
}
|
||||
itemStacks
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.willfp.eco.spigot.display.frame
|
||||
|
||||
import org.bukkit.entity.Player
|
||||
import java.util.*
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
data class DisplayFrame(val items: Map<Byte, Int>) {
|
||||
fun getChangedSlots(newFrame: DisplayFrame): List<Byte> {
|
||||
@@ -15,14 +16,22 @@ data class DisplayFrame(val items: Map<Byte, Int>) {
|
||||
|
||||
return changes
|
||||
}
|
||||
|
||||
companion object {
|
||||
val EMPTY = DisplayFrame(emptyMap())
|
||||
}
|
||||
}
|
||||
|
||||
private val frames = mutableMapOf<UUID, DisplayFrame>()
|
||||
private val frames = ConcurrentHashMap<UUID, DisplayFrame>()
|
||||
|
||||
var Player.lastDisplayFrame: DisplayFrame
|
||||
get() {
|
||||
return frames[this.uniqueId] ?: DisplayFrame(emptyMap())
|
||||
return frames[this.uniqueId] ?: DisplayFrame.EMPTY
|
||||
}
|
||||
set(value) {
|
||||
frames[this.uniqueId] = value
|
||||
}
|
||||
|
||||
fun clearFrames() {
|
||||
frames.clear()
|
||||
}
|
||||
@@ -19,4 +19,13 @@ enable-bstats: true
|
||||
# Some plugins use their own item display systems (eg Triton)
|
||||
# And must be ran after eco. Don't enable this unless you run a conflicting plugin
|
||||
# and have been told to enable it.
|
||||
use-lower-protocollib-priority: false
|
||||
use-lower-protocollib-priority: false
|
||||
|
||||
# Display frames massively optimize PacketWindowItems, however some users have
|
||||
# reported display bugs by using it. If you have any problems with it, then you
|
||||
# should disable this option.
|
||||
use-display-frame: true
|
||||
|
||||
# Time to live for a display frame. In other words, this is how frequent (in ticks)
|
||||
# that display frames will be cleared / deleted.
|
||||
display-frame-ttl: 17
|
||||
Reference in New Issue
Block a user