diff --git a/eco-core/core-plugin/build.gradle b/eco-core/core-plugin/build.gradle index 22ea230..b087925 100644 --- a/eco-core/core-plugin/build.gradle +++ b/eco-core/core-plugin/build.gradle @@ -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 diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/EcoPetsPlugin.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/EcoPetsPlugin.kt index 2dc861b..8b0b128 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/EcoPetsPlugin.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/EcoPetsPlugin.kt @@ -41,6 +41,10 @@ class EcoPetsPlugin : LibReforgePlugin() { } override fun handleReloadAdditional() { + if (!this.configYml.getBool("pet-entity.enabled")) { + return + } + this.scheduler.runTimer(1, 1) { petDisplay.tickAll() } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/commands/CommandActivate.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/commands/CommandActivate.kt index 963112a..4ad60ea 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/commands/CommandActivate.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/commands/CommandActivate.kt @@ -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 ) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/pets/PetDisplay.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/pets/PetDisplay.kt index f291752..ebfa13a 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/pets/PetDisplay.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/pets/PetDisplay.kt @@ -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( diff --git a/eco-core/core-plugin/src/main/resources/config.yml b/eco-core/core-plugin/src/main/resources/config.yml index f76e15c..a69983e 100644 --- a/eco-core/core-plugin/src/main/resources/config.yml +++ b/eco-core/core-plugin/src/main/resources/config.yml @@ -217,6 +217,7 @@ level-gui: custom-slots: [ ] pet-entity: + enabled: true # If you disable this, there will be no floating pets name: "%player%&f's %pet%&f (Lvl. %level%)" level-up: