From aa4ac4c6d163ba1dbfd86567eb164de711d9596d Mon Sep 17 00:00:00 2001 From: Auxilor Date: Tue, 2 Nov 2021 17:44:57 +0000 Subject: [PATCH] Added option to set rate limit timeframe --- .../com/willfp/eco/spigot/display/PacketWindowItems.kt | 8 +++++--- eco-core/core-plugin/src/main/resources/config.yml | 7 ++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/spigot/display/PacketWindowItems.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/spigot/display/PacketWindowItems.kt index a30902a9..ab0b6c07 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/spigot/display/PacketWindowItems.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/spigot/display/PacketWindowItems.kt @@ -80,9 +80,11 @@ class PacketWindowItems(plugin: EcoPlugin) : AbstractPacketAdapter(plugin, Packe modifyRateValueBy(player, 1) - scheduledExecutor.schedule({ - modifyRateValueBy(player, -1) - }, 1, TimeUnit.SECONDS) + scheduledExecutor.schedule( + { modifyRateValueBy(player, -1) }, + this.getPlugin().configYml.getInt("async-display.ratelimit.timeframe").toLong(), + TimeUnit.SECONDS + ) } private fun usingAsync(player: Player): Boolean { diff --git a/eco-core/core-plugin/src/main/resources/config.yml b/eco-core/core-plugin/src/main/resources/config.yml index e299daf5..53e8c090 100644 --- a/eco-core/core-plugin/src/main/resources/config.yml +++ b/eco-core/core-plugin/src/main/resources/config.yml @@ -52,9 +52,14 @@ async-display: ratelimit: # If rate limit async display should be used. enabled: true - # The amount of window items packets per second needed to enable async display + # The amount of window items packets per timeframe needed to enable async display # for a specified player. cutoff: 5 + # 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 mysql: enabled: false # Set to false, data.yml will be used instead.