Compare commits
29 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d36551a94b | ||
|
|
42ed601fd7 | ||
|
|
3cd800aeac | ||
|
|
a8e4f886a5 | ||
|
|
fffdca4515 | ||
|
|
03fe0f6116 | ||
|
|
93ff547fcf | ||
|
|
60af2e8414 | ||
|
|
37b3aab105 | ||
|
|
1065989f7b | ||
|
|
39545ac9bd | ||
|
|
273b7ee712 | ||
|
|
6dfaf353b2 | ||
|
|
6abcf482f1 | ||
|
|
6f56b11b21 | ||
|
|
6c1b283b1b | ||
|
|
864c909f18 | ||
|
|
6fc68f2121 | ||
|
|
27bef81957 | ||
|
|
73c9d85f61 | ||
|
|
87e4669e29 | ||
|
|
b1fcadc46d | ||
|
|
571b39f0a7 | ||
|
|
db3120f1de | ||
|
|
f1b5bac9cd | ||
|
|
c67eee5af9 | ||
|
|
068ca3e4d6 | ||
|
|
f10084d523 | ||
|
|
99d4b13715 |
@@ -47,8 +47,8 @@ allprojects {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly 'com.willfp:eco:6.37.1'
|
||||
implementation 'com.willfp:libreforge:3.105.0'
|
||||
compileOnly 'com.willfp:eco:6.42.0'
|
||||
implementation 'com.willfp:libreforge:3.113.0'
|
||||
implementation 'org.joml:joml:1.10.4'
|
||||
|
||||
compileOnly 'org.jetbrains:annotations:23.0.0'
|
||||
|
||||
@@ -54,7 +54,7 @@ class EcoPetsPlugin : LibReforgePlugin() {
|
||||
return listOf(
|
||||
IntegrationLoader("ModelEngine") {
|
||||
PetEntity.registerPetEntity("modelengine") { pet, id ->
|
||||
ModelEnginePetEntity(pet, id)
|
||||
ModelEnginePetEntity(pet, id, this)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.willfp.ecopets.commands
|
||||
|
||||
import com.willfp.eco.core.EcoPlugin
|
||||
import com.willfp.eco.core.command.impl.Subcommand
|
||||
import com.willfp.eco.util.StringUtils
|
||||
import com.willfp.ecopets.pets.Pets
|
||||
import com.willfp.ecopets.pets.activePet
|
||||
import com.willfp.ecopets.pets.hasPet
|
||||
import org.bukkit.command.CommandSender
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.util.StringUtil
|
||||
|
||||
class CommandActivate(plugin: EcoPlugin) : Subcommand(plugin, "activate", "ecopets.command.activate", true) {
|
||||
override fun onExecute(player: CommandSender, args: List<String>) {
|
||||
player as Player
|
||||
|
||||
if (args.isEmpty()) {
|
||||
player.sendMessage(plugin.langYml.getMessage("needs-pet"))
|
||||
return
|
||||
}
|
||||
|
||||
val id = args[0]
|
||||
|
||||
val pet = Pets.getByID(id)
|
||||
|
||||
if (pet == null || !player.hasPet(pet)) {
|
||||
player.sendMessage(plugin.langYml.getMessage("invalid-pet"))
|
||||
return
|
||||
}
|
||||
|
||||
if (player.activePet == pet) {
|
||||
player.sendMessage(plugin.langYml.getMessage("pet-already-active"))
|
||||
return
|
||||
}
|
||||
|
||||
player.sendMessage(
|
||||
plugin.langYml.getMessage("activated-pet", StringUtils.FormatOption.WITHOUT_PLACEHOLDERS)
|
||||
.replace("%pet%", pet.name)
|
||||
)
|
||||
player.activePet = pet
|
||||
}
|
||||
|
||||
override fun tabComplete(sender: CommandSender, args: List<String>): List<String> {
|
||||
if (sender !is Player) {
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
val completions = mutableListOf<String>()
|
||||
if (args.isEmpty()) {
|
||||
// Currently, this case is not ever reached
|
||||
return Pets.values().filter { sender.hasPet(it) }.map { it.id }
|
||||
}
|
||||
|
||||
if (args.size == 1) {
|
||||
StringUtil.copyPartialMatches(
|
||||
args[1],
|
||||
Pets.values().filter { sender.hasPet(it) }.map { it.id },
|
||||
completions
|
||||
)
|
||||
return completions
|
||||
}
|
||||
|
||||
return emptyList()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.willfp.ecopets.commands
|
||||
|
||||
import com.willfp.eco.core.EcoPlugin
|
||||
import com.willfp.eco.core.command.impl.Subcommand
|
||||
import com.willfp.eco.util.StringUtils
|
||||
import com.willfp.ecopets.pets.activePet
|
||||
import org.bukkit.command.CommandSender
|
||||
import org.bukkit.entity.Player
|
||||
|
||||
class CommandDeactivate(plugin: EcoPlugin) : Subcommand(plugin, "deactivate", "ecopets.command.deactivate", true) {
|
||||
override fun onExecute(player: CommandSender, args: List<String>) {
|
||||
player as Player
|
||||
|
||||
if (player.activePet == null) {
|
||||
player.sendMessage(plugin.langYml.getMessage("no-pet-active"))
|
||||
return
|
||||
}
|
||||
|
||||
player.sendMessage(
|
||||
plugin.langYml.getMessage("deactivated-pet", StringUtils.FormatOption.WITHOUT_PLACEHOLDERS)
|
||||
.replace("%pet%", player.activePet?.name ?: "")
|
||||
)
|
||||
|
||||
player.activePet = null
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,29 @@
|
||||
package com.willfp.ecopets.commands
|
||||
|
||||
import com.willfp.eco.core.EcoPlugin
|
||||
import com.willfp.eco.core.command.impl.PluginCommand
|
||||
import com.willfp.ecopets.pets.Pets
|
||||
import com.willfp.libreforge.LibReforgePlugin
|
||||
import com.willfp.libreforge.lrcdb.CommandExport
|
||||
import com.willfp.libreforge.lrcdb.CommandImport
|
||||
import com.willfp.libreforge.lrcdb.ExportableConfig
|
||||
import org.bukkit.command.CommandSender
|
||||
|
||||
class CommandEcopets(plugin: EcoPlugin) : PluginCommand(plugin, "ecopets", "ecopets.command.ecopets", false) {
|
||||
class CommandEcopets(plugin: LibReforgePlugin) : PluginCommand(plugin, "ecopets", "ecopets.command.ecopets", false) {
|
||||
init {
|
||||
this.addSubcommand(CommandReload(plugin))
|
||||
.addSubcommand(CommandGive(plugin))
|
||||
.addSubcommand(CommandGiveEgg(plugin))
|
||||
.addSubcommand(CommandGiveXP(plugin))
|
||||
.addSubcommand(CommandReset(plugin))
|
||||
.addSubcommand(CommandImport("pets", plugin))
|
||||
.addSubcommand(CommandExport(plugin) {
|
||||
Pets.values().map {
|
||||
ExportableConfig(
|
||||
it.id,
|
||||
it.config
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun onExecute(sender: CommandSender, args: List<String>) {
|
||||
|
||||
@@ -7,6 +7,11 @@ import org.bukkit.command.CommandSender
|
||||
import org.bukkit.entity.Player
|
||||
|
||||
class CommandPets(plugin: EcoPlugin) : PluginCommand(plugin, "pets", "ecopets.command.pets", true) {
|
||||
init {
|
||||
this.addSubcommand(CommandActivate(plugin))
|
||||
.addSubcommand(CommandDeactivate(plugin))
|
||||
}
|
||||
|
||||
override fun onExecute(player: CommandSender, args: List<String>) {
|
||||
player as Player
|
||||
PetsGUI.open(player)
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.bukkit.OfflinePlayer
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.inventory.ItemStack
|
||||
import org.bukkit.persistence.PersistentDataType
|
||||
import java.util.*
|
||||
import java.util.Objects
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.math.abs
|
||||
|
||||
@@ -113,6 +113,7 @@ class Pet(
|
||||
}
|
||||
|
||||
val entityTexture = config.getString("entity-texture")
|
||||
val modelEngineAnimation = config.getStringOrNull("modelengine-animation")
|
||||
|
||||
private val levelXpRequirements = listOf(0) + config.getInts("level-xp-requirements")
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import org.bukkit.entity.Player
|
||||
import org.bukkit.event.EventHandler
|
||||
import org.bukkit.event.Listener
|
||||
import org.bukkit.event.player.PlayerQuitEvent
|
||||
import java.util.*
|
||||
import java.util.UUID
|
||||
import kotlin.math.PI
|
||||
import kotlin.math.abs
|
||||
|
||||
@@ -44,10 +44,18 @@ class PetDisplay(
|
||||
|
||||
location.y += NumberUtils.fastSin(tick / (2 * PI) * 0.5) * 0.15
|
||||
|
||||
try {
|
||||
stand.teleport(location)
|
||||
} catch (_: Exception) {
|
||||
|
||||
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.
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
if (!pet.entityTexture.contains(":")) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.willfp.eco.core.EcoPlugin
|
||||
import com.willfp.eco.core.gui.menu
|
||||
import com.willfp.eco.core.gui.menu.Menu
|
||||
import com.willfp.eco.core.gui.slot
|
||||
import com.willfp.eco.core.gui.slot.ConfigSlot
|
||||
import com.willfp.eco.core.gui.slot.FillerMask
|
||||
import com.willfp.eco.core.gui.slot.MaskItems
|
||||
import com.willfp.eco.core.items.Items
|
||||
@@ -178,6 +179,14 @@ class PetLevelGUI(
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
for (config in plugin.configYml.getSubsections("level-gui.custom-slots")) {
|
||||
setSlot(
|
||||
config.getInt("row"),
|
||||
config.getInt("column"),
|
||||
ConfigSlot(config)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.willfp.eco.core.config.updating.ConfigUpdater
|
||||
import com.willfp.eco.core.gui.menu
|
||||
import com.willfp.eco.core.gui.menu.Menu
|
||||
import com.willfp.eco.core.gui.slot
|
||||
import com.willfp.eco.core.gui.slot.ConfigSlot
|
||||
import com.willfp.eco.core.gui.slot.FillerMask
|
||||
import com.willfp.eco.core.gui.slot.MaskItems
|
||||
import com.willfp.eco.core.items.Items
|
||||
@@ -200,6 +201,14 @@ object PetsGUI {
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
for (config in plugin.configYml.getSubsections("gui.custom-slots")) {
|
||||
setSlot(
|
||||
config.getInt("row"),
|
||||
config.getInt("column"),
|
||||
ConfigSlot(config)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,39 @@
|
||||
package com.willfp.ecopets.pets.entity
|
||||
|
||||
import com.ticxo.modelengine.api.ModelEngineAPI
|
||||
import com.willfp.ecopets.EcoPetsPlugin
|
||||
import com.willfp.ecopets.pets.Pet
|
||||
import org.bukkit.Location
|
||||
import org.bukkit.entity.ArmorStand
|
||||
|
||||
class ModelEnginePetEntity(
|
||||
pet: Pet,
|
||||
private val modelID: String
|
||||
private val modelID: String,
|
||||
private val plugin: EcoPetsPlugin
|
||||
) : PetEntity(pet) {
|
||||
override fun spawn(location: Location): ArmorStand {
|
||||
val stand = emptyArmorStandAt(location, pet)
|
||||
val meAnimation = pet.modelEngineAnimation
|
||||
|
||||
val model = ModelEngineAPI.createActiveModel(modelID)
|
||||
|
||||
if (meAnimation != null) {
|
||||
val animationHandler = model.animationHandler
|
||||
val animationProperty = animationHandler.getAnimation(meAnimation)
|
||||
|
||||
if (animationProperty != null) {
|
||||
animationHandler.playAnimation(animationProperty, true)
|
||||
} else {
|
||||
plugin.logger.warning("Animation $meAnimation not found in model $modelID, defaulting to walk!")
|
||||
val animationPropertyWalk = animationHandler.getAnimation("walk")
|
||||
if (animationPropertyWalk != null) {
|
||||
animationHandler.playAnimation(animationPropertyWalk, true)
|
||||
} else {
|
||||
plugin.logger.warning("Walk animation not found in $modelID!")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val modelled = ModelEngineAPI.createModeledEntity(stand)
|
||||
modelled.addModel(model, true)
|
||||
|
||||
|
||||
@@ -116,6 +116,9 @@ gui:
|
||||
row: 6
|
||||
column: 2
|
||||
|
||||
# Custom GUI slots; see here for a how-to: https://plugins.auxilor.io/all-plugins/custom-gui-slots
|
||||
custom-slots: [ ]
|
||||
|
||||
level-gui:
|
||||
rows: 6
|
||||
|
||||
@@ -210,6 +213,9 @@ level-gui:
|
||||
row: 6
|
||||
column: 5
|
||||
|
||||
# Custom GUI slots; see here for a how-to: https://plugins.auxilor.io/all-plugins/custom-gui-slots
|
||||
custom-slots: [ ]
|
||||
|
||||
pet-entity:
|
||||
name: "%player%&f's %pet%&f (Lvl. %level%)"
|
||||
|
||||
@@ -268,5 +274,3 @@ potions:
|
||||
particles:
|
||||
permanent: false
|
||||
triggered: true
|
||||
|
||||
share-configs: true # If your configs are allowed to be used to gather data and improve the plugin. Nothing identifying (IP, Name, etc) is shared.
|
||||
@@ -21,6 +21,17 @@ messages:
|
||||
gave-pet-egg: "&fSuccessfully gave %player%&f the %pet%&f pet egg!"
|
||||
cannot-spawn-pet: "&cYou already have this pet unlocked!"
|
||||
invalid-amount: "&cInvalid amount!"
|
||||
pet-already-active: "&cYou already have this pet active!"
|
||||
no-pet-active: "&cYou don't have a pet active!"
|
||||
activated-pet: "&fYou have activated the %pet%&f pet!"
|
||||
deactivated-pet: "&fYou have deactivated the %pet%&f pet!"
|
||||
must-specify-lrcdb-id: "&cYou must specify the ID of the config to download! Not sure what this means? Go to &alrcdb.auxilor.io"
|
||||
lrcdb-import-error: "&cError importing config: &f%message%"
|
||||
lrcdb-import-success: "&fImported &a%name%&f! Reload the plugin to install it"
|
||||
must-specify-config-name: "&cYou must specify the config name!"
|
||||
invalid-config-name: "&cInvalid config name!"
|
||||
lrcdb-export-error: "&cError exporting config: &f%message%"
|
||||
lrcdb-export-success: "&fExported &a%name%&f! View it on &alrcdb.auxilor.io&f, or share your config ID: &f%id%"
|
||||
|
||||
menu:
|
||||
title: "Pets"
|
||||
|
||||
19
eco-core/core-plugin/src/main/resources/lrcdb.yml
Normal file
19
eco-core/core-plugin/src/main/resources/lrcdb.yml
Normal file
@@ -0,0 +1,19 @@
|
||||
# Options for lrcdb (https://lrcdb.auxilor.io), a website to share configs
|
||||
# with other server owners, so you can get more configs without making them
|
||||
# yourself!
|
||||
|
||||
author: "Unknown Author" # The name attached to configs you export
|
||||
|
||||
# Options about automatically sharing configs you create
|
||||
share-configs:
|
||||
# If you want all your configs to automatically be publicly available,
|
||||
# set this to true. This really helps out other users!
|
||||
publicly: false
|
||||
|
||||
# If you don't want your configs to be usable to gather information about
|
||||
# plugin usage or to improve the plugins in the future, disable this.
|
||||
# Nothing identifying is shared.
|
||||
enabled: true
|
||||
|
||||
# If you disable share-configs, you can still share select configs publicly
|
||||
# with /ecopets export <config>.
|
||||
@@ -116,6 +116,7 @@ conditions: [ ]
|
||||
# The texture of the pet entity in game
|
||||
# If you're using modelengine, use modelengine:id as the texture
|
||||
entity-texture: "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTA5NWZjYzFlM2Q3Y2JkMzUwZjE5YjM4OTQ5OGFiOGJiOTZjNjVhZDE4NWQzNDU5MjA2N2E3ZDAzM2FjNDhkZSJ9fX0="
|
||||
modelengine-animation: "fly" # If you're using ModelEngine, you can specify an animation here
|
||||
|
||||
# The icon in GUIs
|
||||
icon: player_head texture:eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTA5NWZjYzFlM2Q3Y2JkMzUwZjE5YjM4OTQ5OGFiOGJiOTZjNjVhZDE4NWQzNDU5MjA2N2E3ZDAzM2FjNDhkZSJ9fX0=
|
||||
|
||||
@@ -52,6 +52,10 @@ permissions:
|
||||
ecopets.command.giveegg: true
|
||||
ecopets.command.givexp: true
|
||||
ecopets.command.reset: true
|
||||
ecopets.command.activate: true
|
||||
ecopets.command.deactivate: true
|
||||
ecopets.command.import: true
|
||||
ecopets.command.export: true
|
||||
|
||||
ecopets.command.reload:
|
||||
description: Allows reloading the config
|
||||
@@ -74,6 +78,18 @@ permissions:
|
||||
ecopets.command.reset:
|
||||
description: Allows the use of /ecopets reset.
|
||||
default: op
|
||||
ecopets.command.import:
|
||||
description: Allows the use of /ecopets import.
|
||||
default: op
|
||||
ecopets.command.export:
|
||||
description: Allows the use of /ecopets export.
|
||||
default: op
|
||||
ecopets.command.activate:
|
||||
description: Allows the use of /pets activate.
|
||||
default: true
|
||||
ecopets.command.deactivate:
|
||||
description: Allows the use of /pets deactivate.
|
||||
default: true
|
||||
|
||||
ecopets.xpmultiplier.50percent:
|
||||
description: Gives the player 50% more skill experience
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#libreforge-updater
|
||||
#Mon Sep 26 14:42:58 BST 2022
|
||||
version=1.41.0
|
||||
#Tue Oct 18 14:15:28 BST 2022
|
||||
version=1.52.0
|
||||
plugin-name=EcoPets
|
||||
|
||||
Reference in New Issue
Block a user