From 7742d76f52a7b6c49f795e4aa536e6b2f3f65a1c Mon Sep 17 00:00:00 2001 From: Auxilor Date: Fri, 4 Aug 2023 15:53:51 +0200 Subject: [PATCH] Improved PR. TODO: Recode the whole plugin --- .../main/kotlin/com/willfp/ecoarmor/EcoArmorPlugin.kt | 8 ++++++-- .../com/willfp/ecoarmor/api/event/ArmorSetEvent.kt | 2 +- .../ecoarmor/api/event/PlayerArmorSetEquipEvent.kt | 7 +++++-- .../willfp/ecoarmor/api/event/PlayerArmorSetEvent.kt | 7 +++++-- .../ecoarmor/api/event/PlayerArmorSetUnequipEvent.kt | 9 ++++++--- .../{api => sets}/PlayerArmorSetEventListeners.kt | 11 +++++++---- 6 files changed, 30 insertions(+), 14 deletions(-) rename eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/{api => sets}/PlayerArmorSetEventListeners.kt (88%) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/EcoArmorPlugin.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/EcoArmorPlugin.kt index e7c43e0..61794bb 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/EcoArmorPlugin.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/EcoArmorPlugin.kt @@ -3,11 +3,15 @@ package com.willfp.ecoarmor import com.willfp.eco.core.command.impl.PluginCommand import com.willfp.eco.core.display.DisplayModule import com.willfp.eco.core.items.Items -import com.willfp.ecoarmor.api.PlayerArmorSetEventListeners +import com.willfp.ecoarmor.sets.PlayerArmorSetEventListeners import com.willfp.ecoarmor.commands.CommandEcoArmor import com.willfp.ecoarmor.display.ArmorDisplay import com.willfp.ecoarmor.libreforge.ConditionIsWearingSet -import com.willfp.ecoarmor.sets.* +import com.willfp.ecoarmor.sets.ArmorSetEquipSoundListeners +import com.willfp.ecoarmor.sets.ArmorSets +import com.willfp.ecoarmor.sets.ArmorUtils +import com.willfp.ecoarmor.sets.EffectiveDurabilityListener +import com.willfp.ecoarmor.sets.PreventSkullPlaceListener import com.willfp.ecoarmor.upgrades.AdvancementShardListener import com.willfp.ecoarmor.upgrades.CrystalListener import com.willfp.ecoarmor.upgrades.TierArgParser diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/api/event/ArmorSetEvent.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/api/event/ArmorSetEvent.kt index 53916e5..d2099d5 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/api/event/ArmorSetEvent.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/api/event/ArmorSetEvent.kt @@ -5,4 +5,4 @@ import com.willfp.ecoarmor.sets.ArmorSet interface ArmorSetEvent { val set: ArmorSet val advanced: Boolean -} \ No newline at end of file +} diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/api/event/PlayerArmorSetEquipEvent.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/api/event/PlayerArmorSetEquipEvent.kt index f9cc2ce..8a05600 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/api/event/PlayerArmorSetEquipEvent.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/api/event/PlayerArmorSetEquipEvent.kt @@ -4,8 +4,11 @@ import com.willfp.ecoarmor.sets.ArmorSet import org.bukkit.entity.Player import org.bukkit.event.HandlerList -class PlayerArmorSetEquipEvent(who: Player, override val set: ArmorSet, - override val advanced: Boolean): PlayerArmorSetEvent(who, set, advanced) { +class PlayerArmorSetEquipEvent( + who: Player, + override val set: ArmorSet, + override val advanced: Boolean +) : PlayerArmorSetEvent(who, set, advanced) { override fun getHandlers(): HandlerList { return handlerList } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/api/event/PlayerArmorSetEvent.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/api/event/PlayerArmorSetEvent.kt index e2a20f6..756dc19 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/api/event/PlayerArmorSetEvent.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/api/event/PlayerArmorSetEvent.kt @@ -4,5 +4,8 @@ import com.willfp.ecoarmor.sets.ArmorSet import org.bukkit.entity.Player import org.bukkit.event.player.PlayerEvent -abstract class PlayerArmorSetEvent(who: Player, override val set: ArmorSet, - override val advanced: Boolean): PlayerEvent(who), ArmorSetEvent \ No newline at end of file +abstract class PlayerArmorSetEvent( + who: Player, + override val set: ArmorSet, + override val advanced: Boolean +) : PlayerEvent(who), ArmorSetEvent diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/api/event/PlayerArmorSetUnequipEvent.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/api/event/PlayerArmorSetUnequipEvent.kt index 23aaaac..0f35daa 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/api/event/PlayerArmorSetUnequipEvent.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/api/event/PlayerArmorSetUnequipEvent.kt @@ -4,8 +4,11 @@ import com.willfp.ecoarmor.sets.ArmorSet import org.bukkit.entity.Player import org.bukkit.event.HandlerList -class PlayerArmorSetUnequipEvent(who: Player, override val set: ArmorSet, - override val advanced: Boolean): PlayerArmorSetEvent(who, set, advanced) { +class PlayerArmorSetUnequipEvent( + who: Player, + override val set: ArmorSet, + override val advanced: Boolean +) : PlayerArmorSetEvent(who, set, advanced) { override fun getHandlers(): HandlerList { return handlerList } @@ -18,4 +21,4 @@ class PlayerArmorSetUnequipEvent(who: Player, override val set: ArmorSet, return handlerList } } -} \ No newline at end of file +} diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/api/PlayerArmorSetEventListeners.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/sets/PlayerArmorSetEventListeners.kt similarity index 88% rename from eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/api/PlayerArmorSetEventListeners.kt rename to eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/sets/PlayerArmorSetEventListeners.kt index 62f91ad..6f667e3 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/api/PlayerArmorSetEventListeners.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/sets/PlayerArmorSetEventListeners.kt @@ -1,4 +1,4 @@ -package com.willfp.ecoarmor.api +package com.willfp.ecoarmor.sets import com.willfp.eco.core.events.ArmorChangeEvent import com.willfp.ecoarmor.api.event.PlayerArmorSetEquipEvent @@ -8,7 +8,8 @@ import org.bukkit.Bukkit import org.bukkit.event.EventHandler import org.bukkit.event.Listener -class PlayerArmorSetEventListeners: Listener { +class PlayerArmorSetEventListeners : Listener { + // disgusting @EventHandler fun handle(event: ArmorChangeEvent) { val setBefore = ArmorUtils.getSetOn(event.before) @@ -16,7 +17,9 @@ class PlayerArmorSetEventListeners: Listener { val setAfter = ArmorUtils.getSetOn(event.after) val advancedAfter = ArmorUtils.isWearingAdvanced(event.after) - if (setBefore == setAfter && advancedBefore == advancedAfter) return + if (setBefore == setAfter && advancedBefore == advancedAfter) { + return + } if (setBefore != null) { Bukkit.getPluginManager().callEvent( @@ -30,4 +33,4 @@ class PlayerArmorSetEventListeners: Listener { ) } } -} \ No newline at end of file +}