Compare commits

..

5 Commits

Author SHA1 Message Date
Auxilor
343508f099 Updated to 6.20.4 2022-01-20 09:44:08 +00:00
Auxilor
76dc4948bc Fixed playerless placeholders 2022-01-20 09:43:53 +00:00
Auxilor
8fa209a981 Switched from shallow to deep packet cloning for async 2022-01-18 09:19:14 +00:00
Auxilor
b3a0634ad0 Updated to 6.20.3 2022-01-18 09:18:36 +00:00
Auxilor
97d7acc0a9 Tweaked async display 2022-01-18 09:18:25 +00:00
4 changed files with 21 additions and 16 deletions

View File

@@ -75,7 +75,7 @@ public final class PlaceholderManager {
public static String getResult(@Nullable final Player player, public static String getResult(@Nullable final Player player,
@NotNull final String identifier, @NotNull final String identifier,
@Nullable final EcoPlugin plugin) { @Nullable final EcoPlugin plugin) {
EcoPlugin owner = player == null ? Eco.getHandler().getEcoPlugin() : plugin; EcoPlugin owner = plugin == null ? Eco.getHandler().getEcoPlugin() : plugin;
PlaceholderEntry entry = REGISTERED_PLACEHOLDERS.getOrDefault(owner, new HashMap<>()).get(identifier.toLowerCase()); PlaceholderEntry entry = REGISTERED_PLACEHOLDERS.getOrDefault(owner, new HashMap<>()).get(identifier.toLowerCase());
if (entry == null && plugin != null) { if (entry == null && plugin != null) {

View File

@@ -6,6 +6,7 @@ import com.comphenix.protocol.events.PacketContainer
import com.comphenix.protocol.events.PacketEvent import com.comphenix.protocol.events.PacketEvent
import com.google.common.util.concurrent.ThreadFactoryBuilder import com.google.common.util.concurrent.ThreadFactoryBuilder
import com.willfp.eco.core.AbstractPacketAdapter import com.willfp.eco.core.AbstractPacketAdapter
import com.willfp.eco.core.Eco
import com.willfp.eco.core.EcoPlugin import com.willfp.eco.core.EcoPlugin
import com.willfp.eco.core.display.Display import com.willfp.eco.core.display.Display
import com.willfp.eco.core.fast.FastItemStack import com.willfp.eco.core.fast.FastItemStack
@@ -47,17 +48,10 @@ class PacketWindowItems(plugin: EcoPlugin) : AbstractPacketAdapter(plugin, Packe
handleRateLimit(player) handleRateLimit(player)
if (usingAsync(player)) { if (usingAsync(player)) {
val newPacket = packet.deepClone()
executor.execute { executor.execute {
runCatching { runCatchingWithLogs { modifyAndSend(newPacket, itemStacks, windowId, player) }
modifyAndSend(packet.shallowClone(), itemStacks, windowId, player)
}.onFailure {
if (this.getPlugin().configYml.getBool("async-display.log-errors")) {
this.getPlugin().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)"
)
}
}
} }
} else { } else {
modifyPacket(packet, itemStacks, windowId, player) modifyPacket(packet, itemStacks, windowId, player)
@@ -82,7 +76,7 @@ class PacketWindowItems(plugin: EcoPlugin) : AbstractPacketAdapter(plugin, Packe
modifyPacket(packet, itemStacks, windowId, player) modifyPacket(packet, itemStacks, windowId, player)
ignorePacketList.add(player.name) ignorePacketList.add(player.name)
this.getPlugin().scheduler.run { this.getPlugin().scheduler.run {
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet) runCatchingWithLogs { ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet) }
} }
} }
@@ -169,4 +163,15 @@ class PacketWindowItems(plugin: EcoPlugin) : AbstractPacketAdapter(plugin, Packe
return itemStacks 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

@@ -69,14 +69,14 @@ async-display:
# If emergency async should be used. # If emergency async should be used.
enabled: true enabled: true
# Below this TPS value, emergency async display will be used. # Below this TPS value, emergency async display will be used.
cutoff: 18 cutoff: 17
# If players with a large amount of display packets should have their processing # 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 # done asynchronously. This will help if a player is trying to crash the server
# by overloading the display system. # by overloading the display system.
ratelimit: ratelimit:
# If rate limit async display should be used. # If rate limit async display should be used.
enabled: true enabled: false
# The amount of window items packets per timeframe needed to enable async display # The amount of window items packets per timeframe needed to enable async display
# for a specified player. # for a specified player.
cutoff: 4 cutoff: 4

View File

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