Compare commits

...

12 Commits

Author SHA1 Message Date
Auxilor
e6a59fbc91 Updated to 6.35.10 2022-05-18 10:53:06 +01:00
Will FP
b787f8b76a Merge pull request #133
Bump io.papermc.paperweight.userdev from 1.3.5 to 1.3.6
2022-05-18 10:52:43 +01:00
Will FP
ccc83da5b0 Merge pull request #135
Bump caffeine from 3.0.6 to 3.1.0
2022-05-18 10:52:30 +01:00
Will FP
f11068f2f1 Merge pull request #145
add CMI gradient format
2022-05-18 10:52:18 +01:00
Will FP
a5cc1a5d32 Merge pull request #146
Add an exception for armorstand in interact flag of WG
2022-05-18 10:52:10 +01:00
Kapitowa
7440749ba5 Add an exception for armorstand in interact flag of WG 2022-05-18 01:28:10 +03:00
Kapitowa
75010d25fa add CMI gradient format 2022-05-18 01:01:07 +03:00
Auxilor
bb95376b93 Removed async-display 2022-05-17 19:55:13 +01:00
Auxilor
ab6d4c7aa2 Updated to 6.35.9 2022-05-17 16:53:57 +01:00
Auxilor
9ab8827e55 Fixed non-applied FIS Flags 2022-05-17 16:45:37 +01:00
dependabot[bot]
bd5555ff01 Bump caffeine from 3.0.6 to 3.1.0
Bumps [caffeine](https://github.com/ben-manes/caffeine) from 3.0.6 to 3.1.0.
- [Release notes](https://github.com/ben-manes/caffeine/releases)
- [Commits](https://github.com/ben-manes/caffeine/compare/v3.0.6...v3.1.0)

---
updated-dependencies:
- dependency-name: com.github.ben-manes.caffeine:caffeine
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-28 21:41:30 +00:00
dependabot[bot]
5f80b6052d Bump io.papermc.paperweight.userdev from 1.3.5 to 1.3.6
Bumps [io.papermc.paperweight.userdev](https://github.com/PaperMC/paperweight) from 1.3.5 to 1.3.6.
- [Release notes](https://github.com/PaperMC/paperweight/releases)
- [Commits](https://github.com/PaperMC/paperweight/compare/v1.3.5...v1.3.6)

---
updated-dependencies:
- dependency-name: io.papermc.paperweight.userdev
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-22 21:29:44 +00:00
11 changed files with 13 additions and 152 deletions

View File

@@ -101,7 +101,7 @@ allprojects {
implementation("net.kyori:adventure-text-serializer-legacy:4.10.1")
// Other
implementation("com.github.ben-manes.caffeine:caffeine:3.0.6")
implementation("com.github.ben-manes.caffeine:caffeine:3.1.0")
implementation("org.apache.maven:maven-artifact:3.8.5")
}

View File

@@ -43,6 +43,7 @@ public final class StringUtils {
.add(Pattern.compile("<G#([0-9A-Fa-f]{6})>(.*?)</G#([0-9A-Fa-f]{6})>", Pattern.CASE_INSENSITIVE))
.add(Pattern.compile("<#:([0-9A-Fa-f]{6})>(.*?)</#:([0-9A-Fa-f]{6})>"))
.add(Pattern.compile("\\{#:([0-9A-Fa-f]{6})}(.*?)\\{/#:([0-9A-Fa-f]{6})}"))
.add(Pattern.compile("\\{#([0-9A-Fa-f]{6})>}(.*?)\\{#([0-9A-Fa-f]{6})<}"))
.build();
/**

View File

@@ -1,5 +1,5 @@
plugins {
id("io.papermc.paperweight.userdev") version "1.3.5"
id("io.papermc.paperweight.userdev") version "1.3.6"
}
group = "com.willfp"

View File

@@ -154,12 +154,16 @@ class EcoFastItemStack(
for (f in hideFlags) {
this.flagBits = this.flagBits or getBitModifier(f)
}
apply()
}
override fun removeItemFlags(vararg hideFlags: ItemFlag) {
for (f in hideFlags) {
this.flagBits = this.flagBits and getBitModifier(f).inv()
}
apply()
}
override fun getItemFlags(): Set<ItemFlag> {

View File

@@ -1,5 +1,5 @@
plugins {
id("io.papermc.paperweight.userdev") version "1.3.5"
id("io.papermc.paperweight.userdev") version "1.3.6"
}
group = "com.willfp"

View File

@@ -1,5 +1,5 @@
plugins {
id("io.papermc.paperweight.userdev") version "1.3.5"
id("io.papermc.paperweight.userdev") version "1.3.6"
}
group = "com.willfp"

View File

@@ -1,5 +1,5 @@
plugins {
id("io.papermc.paperweight.userdev") version "1.3.5"
id("io.papermc.paperweight.userdev") version "1.3.6"
}
group = "com.willfp"

View File

@@ -1,30 +1,20 @@
package com.willfp.eco.internal.spigot.display
import com.comphenix.protocol.PacketType
import com.comphenix.protocol.ProtocolLibrary
import com.comphenix.protocol.events.PacketContainer
import com.comphenix.protocol.events.PacketEvent
import com.google.common.util.concurrent.ThreadFactoryBuilder
import com.willfp.eco.core.AbstractPacketAdapter
import com.willfp.eco.core.Eco
import com.willfp.eco.core.EcoPlugin
import com.willfp.eco.core.display.Display
import com.willfp.eco.core.items.HashedItem
import com.willfp.eco.internal.spigot.display.frame.DisplayFrame
import com.willfp.eco.internal.spigot.display.frame.lastDisplayFrame
import com.willfp.eco.util.ServerUtils
import org.bukkit.entity.Player
import org.bukkit.inventory.ItemStack
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit
class PacketWindowItems(plugin: EcoPlugin) : AbstractPacketAdapter(plugin, PacketType.Play.Server.WINDOW_ITEMS, false) {
private val ignorePacketList = ConcurrentHashMap.newKeySet<String>()
private val playerRates = ConcurrentHashMap<String, Int>()
private val threadFactory = ThreadFactoryBuilder().setNameFormat("eco-display-thread-%d").build()
private val executor = Executors.newCachedThreadPool(threadFactory)
private val scheduledExecutor = Executors.newSingleThreadScheduledExecutor(threadFactory)
override fun onSend(
packet: PacketContainer,
@@ -44,90 +34,9 @@ class PacketWindowItems(plugin: EcoPlugin) : AbstractPacketAdapter(plugin, Packe
val itemStacks = packet.itemListModifier.read(0) ?: return
handleRateLimit(player)
if (usingAsync(player)) {
val newPacket = packet.deepClone()
executor.execute {
runCatchingWithLogs { modifyAndSend(newPacket, itemStacks, windowId, player) }
}
} else {
modifyPacket(packet, itemStacks, windowId, player)
}
}
private fun modifyPacket(
packet: PacketContainer,
itemStacks: MutableList<ItemStack>,
windowId: Int,
player: Player
) {
packet.itemListModifier.write(0, modifyWindowItems(itemStacks, windowId, player))
}
private fun modifyAndSend(
packet: PacketContainer,
itemStacks: MutableList<ItemStack>,
windowId: Int,
player: Player
) {
modifyPacket(packet, itemStacks, windowId, player)
ignorePacketList.add(player.name)
this.getPlugin().scheduler.run {
runCatchingWithLogs { ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet) }
}
}
private fun handleRateLimit(player: Player) {
fun modifyRateValueBy(player: Player, amount: Int) {
val name = player.name
val current = playerRates[name] ?: 0
val new = current + amount
if (new <= 0) {
playerRates.remove(name)
} else {
playerRates[name] = new
}
}
modifyRateValueBy(player, 1)
scheduledExecutor.schedule(
{ modifyRateValueBy(player, -1) },
this.getPlugin().configYml.getInt("async-display.ratelimit.timeframe").toLong(),
TimeUnit.SECONDS
)
}
private fun usingAsync(player: Player): Boolean {
if (this.getPlugin().configYml.getStrings("async-display.disable-on-types")
.map { it.lowercase() }.contains(player.openInventory.type.name.lowercase())
) {
return false
}
if (this.getPlugin().configYml.getBool("async-display.always-enabled")) {
return true
}
if (
this.getPlugin().configYml.getBool("async-display.emergency.enabled")
&& ServerUtils.getTps() <= this.getPlugin().configYml.getDouble("async-display.emergency.cutoff")
) {
return true
}
if (
this.getPlugin().configYml.getBool("async-display.ratelimit.enabled")
&& (playerRates[player.name] ?: 0) >= this.getPlugin().configYml.getInt("async-display.ratelimit.cutoff")
) {
return true
}
return false
}
private fun modifyWindowItems(
itemStacks: MutableList<ItemStack>,
windowId: Int,
@@ -162,14 +71,3 @@ class PacketWindowItems(plugin: EcoPlugin) : AbstractPacketAdapter(plugin, Packe
return itemStacks
}
}
private inline fun <T> runCatchingWithLogs(toRun: () -> T): Result<T> {
return runCatching { toRun() }.onFailure {
if (Eco.getHandler().ecoPlugin.configYml.getBool("async-display.log-errors")) {
Eco.getHandler().ecoPlugin.logger.warning(
"Error happened in async processing! Disable async display (/plugins/eco/config.yml)" +
"if this is a frequent issue. (Remember to disable ratelimit and emergency too)"
)
}
}
}

View File

@@ -11,10 +11,7 @@ import com.willfp.eco.core.integrations.antigrief.AntigriefIntegration
import org.apache.commons.lang.Validate
import org.bukkit.Location
import org.bukkit.block.Block
import org.bukkit.entity.Animals
import org.bukkit.entity.LivingEntity
import org.bukkit.entity.Monster
import org.bukkit.entity.Player
import org.bukkit.entity.*
class AntigriefWorldGuard : AntigriefIntegration {
override fun canBreakBlock(
@@ -85,6 +82,7 @@ class AntigriefWorldGuard : AntigriefIntegration {
is Player -> Flags.PVP
is Monster -> Flags.MOB_DAMAGE
is Animals -> Flags.DAMAGE_ANIMALS
is ArmorStand -> Flags.INTERACT
else -> return true
}

View File

@@ -56,43 +56,3 @@ use-safer-namespacedkey-creation: false
# If the stack traces of extensions that failed to load should be logged. Disabled by
# default to prevent users from reporting bugs. Enable if you're a developer.
log-full-extension-errors: false
# Window items packets have the option to be run asynchronously. This may cause
# some bugs and is considered experimental, however it has been tested without
# any apparent issues. Enable this if performance is absolutely crucial or if you
# are experiencing severe display lag.
async-display:
# If async display should always be used.
always-enabled: false
# Log errors that occur in async processing.
log-errors: true
# The inventory types that should never be processed asynchronously.
# A list of IDs can be found here:
# https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/inventory/InventoryType.html
disable-on-types:
- 'anvil'
# If the server is running under heavy load (below a certain TPS value), enable
# async display automatically. This can prevent some server crashes under load.
emergency:
# If emergency async should be used.
enabled: true
# Below this TPS value, emergency async display will be used.
cutoff: 17
# If players with a large amount of display packets should have their processing
# done asynchronously. This will help if a player is trying to crash the server
# by overloading the display system.
ratelimit:
# If rate limit async display should be used.
enabled: false
# The amount of window items packets per timeframe needed to enable async display
# for a specified player.
cutoff: 4
# The length of the timeframe in seconds.
# Cutoff 5, Timeframe 1 means that if there are more than 5 window items packets
# being sent per second for a player, then that player should have their packets
# handled asynchronously.
timeframe: 1

View File

@@ -1,3 +1,3 @@
version = 6.35.8
version = 6.35.10
plugin-name = eco
kotlin.code.style = official