From 4408d957604e2fc01ea7dc32796f933f3cf5b08f Mon Sep 17 00:00:00 2001 From: Auxilor Date: Thu, 30 Sep 2021 12:37:45 +0100 Subject: [PATCH] Improved codestyle --- .../ecoskills/EcoSkillsEventModifierHandler.kt | 4 ++-- .../ecoskills/data/PlayerBlockListener.kt | 17 +++++++++++++---- .../effects/effects/EffectBountifulHarvest.kt | 6 +++--- .../effects/effects/EffectMasterLumberjack.kt | 4 ++-- .../effects/effects/EffectPotionmaster.kt | 4 ++-- .../effects/effects/EffectSpelunking.kt | 4 ++-- 6 files changed, 24 insertions(+), 15 deletions(-) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/EcoSkillsEventModifierHandler.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/EcoSkillsEventModifierHandler.kt index 89ee365..84996a9 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/EcoSkillsEventModifierHandler.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/EcoSkillsEventModifierHandler.kt @@ -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) + } } } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/PlayerBlockListener.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/PlayerBlockListener.kt index 09a149a..b6602e3 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/PlayerBlockListener.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/PlayerBlockListener.kt @@ -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 + ) } \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/effects/effects/EffectBountifulHarvest.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/effects/effects/EffectBountifulHarvest.kt index 6476225..507f20b 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/effects/effects/EffectBountifulHarvest.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/effects/effects/EffectBountifulHarvest.kt @@ -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() @@ -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) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/effects/effects/EffectMasterLumberjack.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/effects/effects/EffectMasterLumberjack.kt index e825b97..97549fc 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/effects/effects/EffectMasterLumberjack.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/effects/effects/EffectMasterLumberjack.kt @@ -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) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/effects/effects/EffectPotionmaster.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/effects/effects/EffectPotionmaster.kt index 9d1995b..d66df9d 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/effects/effects/EffectPotionmaster.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/effects/effects/EffectPotionmaster.kt @@ -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) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/effects/effects/EffectSpelunking.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/effects/effects/EffectSpelunking.kt index bed38a7..17ed7af 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/effects/effects/EffectSpelunking.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/effects/effects/EffectSpelunking.kt @@ -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)