mirror of
https://github.com/Auxilor/EcoSkills.git
synced 2025-12-31 21:06:40 +00:00
Improved codestyle
This commit is contained in:
@@ -12,9 +12,9 @@ class EcoSkillsEventModifierHandler(
|
||||
) : Listener {
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
fun preventLeak(event: EntityDamageByEntityEvent) {
|
||||
plugin.scheduler.runLater({
|
||||
plugin.scheduler.run {
|
||||
critMap.remove(event)
|
||||
}, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,14 +32,18 @@ class PlayerBlockListener(
|
||||
fun onBreak(event: BlockBreakEvent) {
|
||||
val block = event.block
|
||||
|
||||
this.plugin.scheduler.runLater({
|
||||
this.plugin.scheduler.run {
|
||||
removeKey(block)
|
||||
}, 1)
|
||||
}
|
||||
}
|
||||
|
||||
private fun writeKey(block: Block) {
|
||||
val loc = block.location.hashCode().toString(16)
|
||||
block.chunk.persistentDataContainer.set(NamespacedKeyUtils.create("ecoskills", loc.lowercase()), PersistentDataType.INTEGER, 1)
|
||||
block.chunk.persistentDataContainer.set(
|
||||
NamespacedKeyUtils.create("ecoskills", loc.lowercase()),
|
||||
PersistentDataType.INTEGER,
|
||||
1
|
||||
)
|
||||
}
|
||||
|
||||
private fun removeKey(block: Block) {
|
||||
@@ -50,5 +54,10 @@ class PlayerBlockListener(
|
||||
|
||||
fun Block.isPlayerPlaced(): Boolean {
|
||||
val chunk = this.chunk
|
||||
return chunk.persistentDataContainer.has(NamespacedKeyUtils.create("ecoskills", this.location.hashCode().toString(16)), PersistentDataType.INTEGER)
|
||||
return chunk.persistentDataContainer.has(
|
||||
NamespacedKeyUtils.create(
|
||||
"ecoskills",
|
||||
this.location.hashCode().toString(16)
|
||||
), PersistentDataType.INTEGER
|
||||
)
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import org.bukkit.event.EventPriority
|
||||
import org.bukkit.event.block.BlockBreakEvent
|
||||
import org.bukkit.event.block.BlockDropItemEvent
|
||||
|
||||
class EffectBountifulHarvest: Effect(
|
||||
class EffectBountifulHarvest : Effect(
|
||||
"bountiful_harvest"
|
||||
) {
|
||||
private val blockMap = mutableMapOf<Location, Material>()
|
||||
@@ -26,9 +26,9 @@ class EffectBountifulHarvest: Effect(
|
||||
fun onBreak(event: BlockBreakEvent) {
|
||||
blockMap[event.block.location] = event.block.type
|
||||
|
||||
this.plugin.scheduler.runLater({
|
||||
this.plugin.scheduler.run {
|
||||
blockMap.remove(event.block.location)
|
||||
}, 1)
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
|
||||
@@ -28,9 +28,9 @@ class EffectMasterLumberjack : Effect(
|
||||
fun onBreak(event: BlockBreakEvent) {
|
||||
blockMap[event.block.location] = event.block.type
|
||||
|
||||
this.plugin.scheduler.runLater({
|
||||
this.plugin.scheduler.run {
|
||||
blockMap.remove(event.block.location)
|
||||
}, 1)
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
|
||||
@@ -35,7 +35,7 @@ class EffectPotionmaster : Effect(
|
||||
|
||||
val multiplier = ((player.getEffectLevel(this) * this.config.getDouble("percent-more-per-level")) / 100) + 1
|
||||
|
||||
this.plugin.scheduler.runLater({
|
||||
this.plugin.scheduler.run {
|
||||
for (i in 0..2) {
|
||||
val item = event.contents.getItem(i) ?: continue
|
||||
|
||||
@@ -74,7 +74,7 @@ class EffectPotionmaster : Effect(
|
||||
|
||||
item.itemMeta = meta
|
||||
}
|
||||
}, 1)
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
|
||||
@@ -28,9 +28,9 @@ class EffectSpelunking : Effect(
|
||||
fun onBreak(event: BlockBreakEvent) {
|
||||
blockMap[event.block.location] = event.block.type
|
||||
|
||||
this.plugin.scheduler.runLater({
|
||||
this.plugin.scheduler.run {
|
||||
blockMap.remove(event.block.location)
|
||||
}, 1)
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
|
||||
Reference in New Issue
Block a user