Compare commits

..

No commits in common. "next/1.0.2" and "main" have entirely different histories.

View file

@ -2,7 +2,6 @@ package ch.offbeatwit.bestbuds.modules
import ch.offbeatwit.bestbuds.ADOPTION_OWNER
import ch.offbeatwit.bestbuds.ADOPTION_TARGET
import ch.offbeatwit.bestbuds.inTicks
import ch.offbeatwit.bestbuds.isOwnerOf
import ch.offbeatwit.bestbuds.managers.Context
import ch.offbeatwit.bestbuds.pet.PetInfo
@ -18,13 +17,9 @@ import org.bukkit.entity.Tameable
import org.bukkit.event.EventHandler
import org.bukkit.event.Listener
import org.bukkit.event.player.PlayerInteractEntityEvent
import org.bukkit.event.player.PlayerInteractEvent
import org.bukkit.inventory.EquipmentSlot
import org.bukkit.inventory.ItemStack
import org.bukkit.inventory.meta.BookMeta
import org.bukkit.potion.PotionEffect
import org.bukkit.potion.PotionEffectType
import kotlin.time.Duration.Companion.seconds
class AdoptionModule(ctx: Context) : BestBudsModule(ctx), Listener {
val adoptionItem = Material.PAPER
@ -44,27 +39,6 @@ class AdoptionModule(ctx: Context) : BestBudsModule(ctx), Listener {
}
}
@EventHandler
fun onLocate(ev: PlayerInteractEvent) {
if (!ev.action.isRightClick || !ev.player.isSneaking) return
val held = ev.item
if (held != null && held.type == Material.WRITTEN_BOOK) {
val bookTarget = held.persistentDataContainer[ADOPTION_TARGET, UUIDDataType]
?.let { ev.player.world.getEntity(it) }
?: return
if (bookTarget is Tameable) {
ev.isCancelled = true
val info = PetInfo(bookTarget)
ev.player.sendPotionEffectChange(bookTarget,
PotionEffect(PotionEffectType.GLOWING, 5.seconds.inTicks.toInt(), 1))
ev.player.sendActionBar(tr("Highlighted ").append(info.nameComponent))
}
}
}
fun setupAdoption(sender: Player, hand: EquipmentSlot, pet: Tameable) {
val info = PetInfo(pet)
val stack = sender.inventory.getItem(hand)