Fix stuff

This commit is contained in:
TomTom
2022-11-28 16:04:50 +01:00
parent 452c20f534
commit 332fd55f0b
3 changed files with 21 additions and 15 deletions

View File

@@ -7,7 +7,7 @@ dependencies {
compileOnly 'net.kyori:adventure-api:4.10.1'
compileOnly 'net.essentialsx:EssentialsX:2.19.0'
compileOnly 'com.github.ben-manes.caffeine:caffeine:3.0.6'
compileOnly 'com.ticxo.modelengine:api:R3.0.0'
compileOnly 'com.ticxo.modelengine:api:R3.0.1'
}
build.dependsOn publishToMavenLocal

View File

@@ -53,7 +53,7 @@ class CommandActivate(plugin: EcoPlugin) : Subcommand(plugin, "activate", "ecope
if (args.size == 1) {
StringUtil.copyPartialMatches(
args[1],
args[0],
Pets.values().filter { sender.hasPet(it) }.map { it.id },
completions
)

View File

@@ -9,7 +9,9 @@ import org.bukkit.entity.ArmorStand
import org.bukkit.entity.Player
import org.bukkit.event.EventHandler
import org.bukkit.event.Listener
import org.bukkit.event.player.PlayerChangedWorldEvent
import org.bukkit.event.player.PlayerQuitEvent
import org.bukkit.event.player.PlayerTeleportEvent
import java.util.UUID
import kotlin.math.PI
import kotlin.math.abs
@@ -45,17 +47,7 @@ class PetDisplay(
location.y += NumberUtils.fastSin(tick / (2 * PI) * 0.5) * 0.15
if (location.world != null) {
try {
stand.teleport(location)
} catch (_: Throwable) {
/*
For anyone reading - I KNOW TO NEVER CATCH THROWABLE
but NMS is really stupid and does this sometimes:
java.lang.Throwable: null
at net.minecraft.world.entity.Entity.teleportTo(Entity.java:3336) ~[paper-1.19.2.jar:git-Paper-186]
so I guess that's what has to be done. Not sure what the actual cause is.
*/
}
stand.teleport(location)
}
if (!pet.entityTexture.contains(":")) {
@@ -117,10 +109,24 @@ class PetDisplay(
trackedEntities.clear()
}
private fun remove(player: Player) {
trackedEntities[player.uniqueId]?.stand?.remove()
trackedEntities.remove(player.uniqueId)
}
@EventHandler
fun onLeave(event: PlayerQuitEvent) {
trackedEntities[event.player.uniqueId]?.stand?.remove()
trackedEntities.remove(event.player.uniqueId)
remove(event.player)
}
@EventHandler
fun onTeleport(event: PlayerTeleportEvent) {
remove(event.player)
}
@EventHandler
fun onWorldChange(event: PlayerChangedWorldEvent) {
remove(event.player)
}
private data class PetArmorStand(