Compare commits
27 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7da97170cf | ||
|
|
0f8e9b07e7 | ||
|
|
bb411f6b9d | ||
|
|
dff4bdc24f | ||
|
|
b05fef4dc3 | ||
|
|
05a45739e3 | ||
|
|
edc98b1300 | ||
|
|
a08286cd39 | ||
|
|
6f370657c4 | ||
|
|
8d28445639 | ||
|
|
5ca0cb4f82 | ||
|
|
c2f2088986 | ||
|
|
02c120fc0a | ||
|
|
404d908efe | ||
|
|
b430dcaf5b | ||
|
|
84acf13c8d | ||
|
|
5465a7412f | ||
|
|
4a8ea43b5b | ||
|
|
a2d147e54c | ||
|
|
2ceb670999 | ||
|
|
a4cef52d5c | ||
|
|
b653d97794 | ||
|
|
f44ca8a7e3 | ||
|
|
56ddfeca39 | ||
|
|
332fd55f0b | ||
|
|
452c20f534 | ||
|
|
6002bc0b47 |
@@ -49,7 +49,7 @@ allprojects {
|
||||
|
||||
dependencies {
|
||||
compileOnly 'com.willfp:eco:6.44.0'
|
||||
implementation 'com.willfp:libreforge:3.122.0'
|
||||
implementation 'com.willfp:libreforge:3.129.0'
|
||||
implementation 'com.willfp:ecomponent:1.0.0'
|
||||
implementation 'org.joml:joml:1.10.4'
|
||||
|
||||
|
||||
@@ -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.1.4'
|
||||
}
|
||||
|
||||
build.dependsOn publishToMavenLocal
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.willfp.ecopets.api.event
|
||||
|
||||
import com.willfp.ecopets.pets.Pet
|
||||
|
||||
interface PetEvent {
|
||||
val pet: Pet
|
||||
}
|
||||
@@ -1,18 +1,17 @@
|
||||
package com.willfp.ecopets.api.event
|
||||
|
||||
import org.bukkit.entity.Player
|
||||
import com.willfp.ecopets.pets.Pet
|
||||
import org.bukkit.event.player.PlayerEvent
|
||||
import org.bukkit.event.HandlerList
|
||||
import com.willfp.ecopets.api.event.PlayerPetExpGainEvent
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.event.Cancellable
|
||||
import org.bukkit.event.HandlerList
|
||||
import org.bukkit.event.player.PlayerEvent
|
||||
|
||||
class PlayerPetExpGainEvent(
|
||||
who: Player,
|
||||
val pet: Pet,
|
||||
override val pet: Pet,
|
||||
var amount: Double,
|
||||
val isMultiply: Boolean
|
||||
) : PlayerEvent(who), Cancellable {
|
||||
) : PlayerEvent(who), Cancellable, PetEvent {
|
||||
private var cancelled = false
|
||||
|
||||
override fun setCancelled(cancel: Boolean) {
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
package com.willfp.ecopets.api.event
|
||||
|
||||
import org.bukkit.entity.Player
|
||||
import com.willfp.ecopets.pets.Pet
|
||||
import org.bukkit.event.player.PlayerEvent
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.event.HandlerList
|
||||
import com.willfp.ecopets.api.event.PlayerPetLevelUpEvent
|
||||
import org.bukkit.event.player.PlayerEvent
|
||||
|
||||
class PlayerPetLevelUpEvent(
|
||||
who: Player,
|
||||
val pet: Pet,
|
||||
override val pet: Pet,
|
||||
val level: Int
|
||||
) : PlayerEvent(who) {
|
||||
) : PlayerEvent(who), PetEvent {
|
||||
override fun getHandlers(): HandlerList {
|
||||
return handlerList
|
||||
}
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#libreforge-updater
|
||||
#Thu Nov 24 14:31:26 GMT 2022
|
||||
version=1.62.0
|
||||
#Thu Feb 09 14:13:23 GMT 2023
|
||||
version=1.70.0
|
||||
plugin-name=EcoPets
|
||||
|
||||
Reference in New Issue
Block a user