9
0
mirror of https://github.com/Auxilor/EcoSkills.git synced 2026-01-03 06:12:21 +00:00

Optimised EntityDamageByEntityEvent#isCrit

This commit is contained in:
Auxilor
2021-10-06 15:58:40 +01:00
parent 07e6ed206c
commit 8b27f9524f
2 changed files with 3 additions and 17 deletions

View File

@@ -117,8 +117,7 @@ public class EcoSkillsPlugin extends EcoPlugin {
new SkillDisplayListener(this),
new StatModifierListener(),
new DataListener(),
new PlayerBlockListener(this),
new EcoSkillsEventModifierHandler(this)
new PlayerBlockListener(this)
);
}

View File

@@ -1,22 +1,9 @@
package com.willfp.ecoskills
import org.bukkit.event.EventHandler
import org.bukkit.event.EventPriority
import org.bukkit.event.Listener
import org.bukkit.event.entity.EntityDamageByEntityEvent
import java.util.*
private val critMap = mutableMapOf<EntityDamageByEntityEvent, Boolean>()
class EcoSkillsEventModifierHandler(
private val plugin: EcoSkillsPlugin
) : Listener {
@EventHandler(priority = EventPriority.MONITOR)
fun preventLeak(event: EntityDamageByEntityEvent) {
plugin.scheduler.run {
critMap.remove(event)
}
}
}
private val critMap = WeakHashMap<EntityDamageByEntityEvent, Boolean>()
var EntityDamageByEntityEvent.isCrit: Boolean
get() {