requested changes

This commit is contained in:
rudde 2024-05-02 00:04:03 +03:00
parent 0d2725ec8d
commit d26f2c0da0
5 changed files with 11 additions and 13 deletions

View File

@ -5,7 +5,7 @@ import org.bukkit.entity.Player
import org.bukkit.event.Cancellable
import org.bukkit.event.HandlerList
class MinionPreBreakEvent(private val player: Player, minion: Minion) : MinionEvent(minion), Cancellable {
class PreMinionPickupEvent(private val player: Player, minion: Minion) : MinionEvent(minion), Cancellable {
companion object {
private val handlerList = HandlerList()
@ -16,7 +16,7 @@ class MinionPreBreakEvent(private val player: Player, minion: Minion) : MinionEv
private var isCancelled = false
override fun getHandlers(): HandlerList {
return MinionPreBreakEvent.handlerList
return PreMinionPickupEvent.handlerList
}
fun getPlayer(): Player {

View File

@ -6,7 +6,7 @@ import org.bukkit.event.Cancellable
import org.bukkit.event.Event
import org.bukkit.event.HandlerList
class MinionPrePlaceEvent(private val player: Player, private val location: Location) : Cancellable, Event() {
class PreMinionPlaceEvent(private val player: Player, private val location: Location) : Cancellable, Event() {
companion object {
private val handlerList = HandlerList()
@ -18,7 +18,7 @@ class MinionPrePlaceEvent(private val player: Player, private val location: Loca
private var shouldOverridePlayerLimit = false
override fun getHandlers(): HandlerList {
return MinionPrePlaceEvent.handlerList
return PreMinionPlaceEvent.handlerList
}
override fun isCancelled(): Boolean {

View File

@ -48,7 +48,7 @@ class AxMinionsCommand {
receiver: Player
) {
AxMinionsAPI.INSTANCE.getMinions().fastFor {
if(it.getOwnerUUID() == receiver.uniqueId) {
if (it.getOwnerUUID() == receiver.uniqueId) {
it.remove()
}
}

View File

@ -20,7 +20,7 @@ import org.bukkit.event.player.PlayerInteractEvent
import org.bukkit.inventory.ItemStack
import org.bukkit.persistence.PersistentDataType
import org.bukkit.event.block.BlockPlaceEvent
import com.artillexstudios.axminions.api.events.MinionPrePlaceEvent
import com.artillexstudios.axminions.api.events.PreMinionPlaceEvent
import org.bukkit.Bukkit
class MinionPlaceListener : Listener {
@ -47,7 +47,7 @@ class MinionPlaceListener : Listener {
return
}
val prePlaceEvent = MinionPrePlaceEvent(event.player, event.clickedBlock!!.location)
val prePlaceEvent = PreMinionPlaceEvent(event.player, event.clickedBlock!!.location)
val level = meta.persistentDataContainer.get(Keys.LEVEL, PersistentDataType.INTEGER) ?: 0
val stats = meta.persistentDataContainer.get(Keys.STATISTICS, PersistentDataType.LONG) ?: 0
@ -61,7 +61,7 @@ class MinionPlaceListener : Listener {
if (meta.persistentDataContainer.has(Keys.PLACED, PersistentDataType.BYTE)) return
Bukkit.getPluginManager().callEvent(prePlaceEvent)
if(prePlaceEvent.isCancelled) return
if (prePlaceEvent.isCancelled) return
meta.persistentDataContainer.set(Keys.PLACED, PersistentDataType.BYTE, 0)
item.itemMeta = meta

View File

@ -16,8 +16,7 @@ import com.artillexstudios.axminions.AxMinionsPlugin
import com.artillexstudios.axminions.api.AxMinionsAPI
import com.artillexstudios.axminions.api.config.Config
import com.artillexstudios.axminions.api.config.Messages
import com.artillexstudios.axminions.api.events.MinionPreBreakEvent
import com.artillexstudios.axminions.api.events.MinionPrePlaceEvent
import com.artillexstudios.axminions.api.events.PreMinionPickupEvent
import com.artillexstudios.axminions.api.minions.Direction
import com.artillexstudios.axminions.api.minions.Minion
import com.artillexstudios.axminions.api.minions.miniontype.MinionType
@ -41,7 +40,6 @@ import org.bukkit.block.Container
import org.bukkit.enchantments.Enchantment
import org.bukkit.entity.EntityType
import org.bukkit.entity.Player
import org.bukkit.inventory.CreativeCategory
import org.bukkit.inventory.Inventory
import org.bukkit.inventory.ItemStack
import org.bukkit.inventory.meta.Damageable
@ -166,9 +164,9 @@ class Minion(
}
private fun breakMinion(event: PacketEntityInteractEvent) {
val preBreakEvent = MinionPreBreakEvent(event.player, this)
val preBreakEvent = PreMinionPickupEvent(event.player, this)
Bukkit.getPluginManager().callEvent(preBreakEvent)
if(preBreakEvent.isCancelled) return
if (preBreakEvent.isCancelled) return
LinkingListener.linking.remove(event.player)
remove()