Skip to content

Commit

Permalink
Improved PR. TODO: Recode the whole plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
WillFP committed Aug 4, 2023
1 parent 6079e24 commit 7742d76
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ import com.willfp.ecoarmor.sets.ArmorSet
interface ArmorSetEvent {
val set: ArmorSet
val advanced: Boolean
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
abstract class PlayerArmorSetEvent(
who: Player,
override val set: ArmorSet,
override val advanced: Boolean
) : PlayerEvent(who), ArmorSetEvent
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -18,4 +21,4 @@ class PlayerArmorSetUnequipEvent(who: Player, override val set: ArmorSet,
return handlerList
}
}
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -8,15 +8,18 @@ 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)
val advancedBefore = ArmorUtils.isWearingAdvanced(event.before)
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(
Expand All @@ -30,4 +33,4 @@ class PlayerArmorSetEventListeners: Listener {
)
}
}
}
}

0 comments on commit 7742d76

Please sign in to comment.