Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -7,7 +7,7 @@ dependencies {
|
|||||||
compileOnly 'net.kyori:adventure-api:4.10.1'
|
compileOnly 'net.kyori:adventure-api:4.10.1'
|
||||||
compileOnly 'net.essentialsx:EssentialsX:2.19.0'
|
compileOnly 'net.essentialsx:EssentialsX:2.19.0'
|
||||||
compileOnly 'com.github.ben-manes.caffeine:caffeine:3.0.6'
|
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
|
build.dependsOn publishToMavenLocal
|
||||||
|
|||||||
@@ -41,6 +41,10 @@ class EcoPetsPlugin : LibReforgePlugin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun handleReloadAdditional() {
|
override fun handleReloadAdditional() {
|
||||||
|
if (!this.configYml.getBool("pet-entity.enabled")) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
this.scheduler.runTimer(1, 1) {
|
this.scheduler.runTimer(1, 1) {
|
||||||
petDisplay.tickAll()
|
petDisplay.tickAll()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class CommandActivate(plugin: EcoPlugin) : Subcommand(plugin, "activate", "ecope
|
|||||||
|
|
||||||
if (args.size == 1) {
|
if (args.size == 1) {
|
||||||
StringUtil.copyPartialMatches(
|
StringUtil.copyPartialMatches(
|
||||||
args[1],
|
args[0],
|
||||||
Pets.values().filter { sender.hasPet(it) }.map { it.id },
|
Pets.values().filter { sender.hasPet(it) }.map { it.id },
|
||||||
completions
|
completions
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ import org.bukkit.entity.ArmorStand
|
|||||||
import org.bukkit.entity.Player
|
import org.bukkit.entity.Player
|
||||||
import org.bukkit.event.EventHandler
|
import org.bukkit.event.EventHandler
|
||||||
import org.bukkit.event.Listener
|
import org.bukkit.event.Listener
|
||||||
|
import org.bukkit.event.player.PlayerChangedWorldEvent
|
||||||
import org.bukkit.event.player.PlayerQuitEvent
|
import org.bukkit.event.player.PlayerQuitEvent
|
||||||
|
import org.bukkit.event.player.PlayerTeleportEvent
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
import kotlin.math.PI
|
import kotlin.math.PI
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
@@ -45,17 +47,7 @@ class PetDisplay(
|
|||||||
location.y += NumberUtils.fastSin(tick / (2 * PI) * 0.5) * 0.15
|
location.y += NumberUtils.fastSin(tick / (2 * PI) * 0.5) * 0.15
|
||||||
|
|
||||||
if (location.world != null) {
|
if (location.world != null) {
|
||||||
try {
|
stand.teleport(location)
|
||||||
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.
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pet.entityTexture.contains(":")) {
|
if (!pet.entityTexture.contains(":")) {
|
||||||
@@ -117,10 +109,24 @@ class PetDisplay(
|
|||||||
trackedEntities.clear()
|
trackedEntities.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun remove(player: Player) {
|
||||||
|
trackedEntities[player.uniqueId]?.stand?.remove()
|
||||||
|
trackedEntities.remove(player.uniqueId)
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
fun onLeave(event: PlayerQuitEvent) {
|
fun onLeave(event: PlayerQuitEvent) {
|
||||||
trackedEntities[event.player.uniqueId]?.stand?.remove()
|
remove(event.player)
|
||||||
trackedEntities.remove(event.player.uniqueId)
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
fun onTeleport(event: PlayerTeleportEvent) {
|
||||||
|
remove(event.player)
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
fun onWorldChange(event: PlayerChangedWorldEvent) {
|
||||||
|
remove(event.player)
|
||||||
}
|
}
|
||||||
|
|
||||||
private data class PetArmorStand(
|
private data class PetArmorStand(
|
||||||
|
|||||||
@@ -217,6 +217,7 @@ level-gui:
|
|||||||
custom-slots: [ ]
|
custom-slots: [ ]
|
||||||
|
|
||||||
pet-entity:
|
pet-entity:
|
||||||
|
enabled: true # If you disable this, there will be no floating pets
|
||||||
name: "%player%&f's %pet%&f (Lvl. %level%)"
|
name: "%player%&f's %pet%&f (Lvl. %level%)"
|
||||||
|
|
||||||
level-up:
|
level-up:
|
||||||
|
|||||||
Reference in New Issue
Block a user