9
0
mirror of https://github.com/Auxilor/EcoMobs.git synced 2025-12-19 15:09:17 +00:00

Compare commits

...

77 Commits

Author SHA1 Message Date
Will FP
828c44dfa4 libreforge-updater 2025-07-05 16:46:16 +01:00
Will FP
597b18b953 libreforge-updater 2025-07-04 09:51:39 +01:00
Will FP
5c294b3fdf libreforge-updater 2025-03-29 14:22:43 +00:00
Will FP
4617528481 libreforge-updater 2025-01-31 11:55:35 +00:00
Will FP
b062ea3e0a libreforge-updater 2025-01-25 13:50:23 +00:00
Will FP
a1dcd0e2c7 Fix 2025-01-25 13:49:21 +00:00
Will FP
af70faa26f libreforge-updater 2025-01-25 13:46:18 +00:00
Will FP
21056bddec libreforge-updater 2024-11-06 18:35:16 +00:00
Will FP
8d1da21565 libreforge-updater 2024-10-22 12:16:17 +01:00
Will FP
44b5c540aa libreforge-updater 2024-09-22 17:03:30 +01:00
Auxilor
b0378a579d libreforge-updater 2024-09-02 11:30:01 +01:00
Auxilor
17579458d2 libreforge-updater 2024-08-30 17:25:01 +01:00
Auxilor
31d9bfd8f3 libreforge-updater 2024-08-29 12:09:10 +01:00
Auxilor
be2320b3a3 libreforge-updater 2024-08-23 15:35:15 +01:00
Auxilor
0ca4886c5d libreforge-updater 2024-08-21 18:58:13 +01:00
Auxilor
ecf183d175 libreforge-updater 2024-08-15 15:07:27 +01:00
Auxilor
100adf8382 libreforge-updater 2024-08-03 13:41:17 +01:00
Auxilor
aeb40958dd libreforge-updater 2024-07-25 10:04:26 +01:00
Auxilor
e8de0d041d libreforge-updater 2024-07-21 12:19:11 +01:00
Auxilor
f887e15992 libreforge-updater 2024-07-19 20:28:31 +01:00
Auxilor
6d69e9c825 libreforge-updater 2024-07-18 13:24:06 +01:00
Auxilor
ccbf8c8fd0 libreforge-updater 2024-07-16 17:13:35 +01:00
Auxilor
b5ace8f36e libreforge-updater 2024-07-13 20:45:12 +01:00
Auxilor
86352ba528 libreforge-updater 2024-07-08 15:58:22 +01:00
Auxilor
f22c290ff5 Downgraded to Java 17 for compatibility 2024-07-08 14:37:27 +01:00
Auxilor
d1afab2ed6 libreforge-updater 2024-07-05 13:02:38 +01:00
Auxilor
6a335a5371 libreforge-updater 2024-07-03 17:43:49 +01:00
Auxilor
f3f2d581e3 libreforge-updater 2024-06-29 16:43:54 +01:00
Auxilor
78dd714c6b libreforge-updater 2024-06-28 15:56:17 +01:00
Auxilor
a7268cc6bd libreforge-updater 2024-06-27 18:54:20 +01:00
Auxilor
3e2079d634 libreforge-updater 2024-06-26 16:52:13 +01:00
Auxilor
0cf9b376e0 libreforge-updater 2024-06-25 15:13:52 +01:00
Auxilor
94bcad4bdb libreforge-updater 2024-06-24 15:06:28 +01:00
Auxilor
8563c6b655 Updated to Java 21 2024-06-24 13:44:48 +01:00
Auxilor
be542028b0 libreforge-updater 2024-06-23 17:26:26 +01:00
Auxilor
831d3661be libreforge-updater 2024-06-23 13:18:48 +01:00
Will FP
bc14c675ad libreforge-updater 2024-05-31 20:38:17 +01:00
Will FP
76d7076877 Merge pull request #60 from stumper66/master
LevelledMobs 4.0 Support
2024-05-24 16:12:26 +01:00
Penal Buffalo
ff8b48587f LevelledMobs 4.0 Support
Updated the API to 4.0
2024-05-24 09:41:28 -05:00
Will FP
23039a73f9 libreforge-updater 2024-05-11 18:21:43 +01:00
Will FP
2e3324c405 libreforge-updater 2024-04-17 20:35:35 +01:00
Auxilor
c24d0876ca libreforge-updater 2024-04-15 18:19:34 +01:00
Auxilor
800ef7732a libreforge-updater 2024-04-11 13:17:32 +01:00
Auxilor
e6c82e6ac4 libreforge-updater 2024-03-29 16:08:40 +00:00
Will FP
7008794445 Fixed _example.yml 2024-03-28 11:25:56 +00:00
Will FP
c9aac17937 libreforge-updater 2024-03-11 17:38:41 +00:00
Will FP
3c2f2ba315 libreforge-updater 2024-03-10 20:10:14 +00:00
Will FP
d4a8665a6a Added chance option to replace 2024-03-04 18:36:38 +00:00
Will FP
eb0a5251d3 libreforge-updater 2024-03-02 15:21:29 +00:00
Will FP
782edf8da1 libreforge-updater 2024-02-22 13:18:55 +00:00
Will FP
ac3de8a0fb libreforge-updater 2024-02-15 13:03:11 +00:00
Will FP
d47b4b9567 libreforge-updater 2024-02-08 19:50:40 +00:00
Will FP
613632e7a9 libreforge-updater 2024-01-30 11:28:25 +00:00
Will FP
b8d8d4999f libreforge-updater 2024-01-18 17:03:56 +00:00
Will FP
aa7000b2aa libreforge-updater 2024-01-16 13:29:47 +00:00
Will FP
afe6b34c65 libreforge-updater 2024-01-13 14:24:37 +00:00
Will FP
c9173c06da libreforge-updater 2024-01-07 13:52:32 +00:00
Will FP
57a4f1a708 Improved _example.yml, added permanent mob effects 2024-01-06 12:06:29 +00:00
Will FP
f031fb51c6 Improved _example.yml, added permanent mob effects 2024-01-06 11:56:04 +00:00
Will FP
8745ee5425 Oops 2024-01-06 09:22:10 +00:00
Will FP
428f022d97 Merge remote-tracking branch 'origin/master'
# Conflicts:
#	gradle.properties
2024-01-06 09:22:03 +00:00
Will FP
f17eb06b03 libreforge-updater 2024-01-06 09:20:57 +00:00
Auxilor
e4a805c627 libreforge-updater 2024-01-04 17:25:24 +00:00
Auxilor
ce24ea4cf4 Updated to 10.0.0-b4 2024-01-03 16:45:47 +00:00
Auxilor
47e9ff13dc Improved top damager placeholders 2024-01-03 16:45:37 +00:00
Auxilor
93c5ce5b6c libreforge-updater 2024-01-01 20:02:25 +00:00
Auxilor
11acfed77c Fixed top damager placeholders 2024-01-01 18:05:27 +00:00
Auxilor
8cca1f7994 Fixed 'death' event, fixed top damagers 2024-01-01 17:59:02 +00:00
Will FP
f6a40d84f7 Updated to 10.0.0-b2 2023-12-30 13:34:28 +01:00
Will FP
9e663e89e8 Fixed model engine integration 2023-12-30 13:34:17 +01:00
Will FP
58b0ba6b81 Updated bStats ID 2023-12-28 16:45:23 +01:00
Will FP
a40164a03d Fixed tickers 2023-12-28 12:48:04 +01:00
Will FP
b946346020 Fix to lang.yml 2023-12-27 18:04:26 +01:00
Will FP
3753c93bf5 Improved error message 2023-12-27 17:53:04 +01:00
Will FP
9d407b9dea Fixed death animation not playing 2023-12-27 17:47:55 +01:00
Will FP
08f8b02d22 Fixed custom entity 2023-12-26 14:19:06 +01:00
Will FP
913120e791 oops 2023-12-24 14:56:21 +01:00
21 changed files with 127 additions and 40 deletions

View File

@@ -15,11 +15,11 @@ jobs:
- name: Checkout latest code
uses: actions/checkout@v2
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: 17
java-version: 21
- name: Change wrapper permissions
run: chmod +x ./gradlew

View File

@@ -1,9 +1,11 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
plugins {
java
`java-library`
`maven-publish`
kotlin("jvm") version "1.9.20"
id("com.github.johnrengelman.shadow") version "8.0.0"
kotlin("jvm") version "2.1.0"
id("com.gradleup.shadow") version "8.3.0"
id("com.willfp.libreforge-gradle-plugin") version "1.0.0"
}
@@ -23,7 +25,7 @@ allprojects {
apply(plugin = "java")
apply(plugin = "kotlin")
apply(plugin = "maven-publish")
apply(plugin = "com.github.johnrengelman.shadow")
apply(plugin = "com.gradleup.shadow")
repositories {
mavenLocal()
@@ -38,7 +40,7 @@ allprojects {
dependencies {
compileOnly("com.willfp:eco:6.67.0")
compileOnly("org.jetbrains:annotations:23.0.0")
compileOnly("org.jetbrains.kotlin:kotlin-stdlib:1.9.20")
compileOnly("org.jetbrains.kotlin:kotlin-stdlib:2.1.0")
compileOnly("com.github.ben-manes.caffeine:caffeine:3.1.5")
}
@@ -54,8 +56,8 @@ allprojects {
}
compileKotlin {
kotlinOptions {
jvmTarget = "17"
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
}
}

View File

@@ -3,8 +3,8 @@ version = rootProject.version
dependencies {
compileOnly("io.papermc.paper:paper-api:1.20.2-R0.1-SNAPSHOT")
compileOnly("com.github.lokka30:LevelledMobs:3.1.4")
compileOnly("LibsDisguises:LibsDisguises:10.0.38")
compileOnly("io.github.arcaneplugins:levelledmobs-plugin:4.0.2")
compileOnly("LibsDisguises:LibsDisguises:10.0.15")
implementation("com.willfp:ModelEngineBridge:1.0.0")
}

View File

@@ -4,6 +4,7 @@ import com.willfp.eco.core.command.impl.PluginCommand
import com.willfp.eco.core.display.DisplayModule
import com.willfp.eco.core.entities.ai.EntityGoals
import com.willfp.eco.core.integrations.IntegrationLoader
import com.willfp.eco.util.toSingletonList
import com.willfp.ecomobs.category.MobCategories
import com.willfp.ecomobs.category.spawning.spawnpoints.SpawnPointGenerator
import com.willfp.ecomobs.commands.CommandEcoMobs
@@ -19,8 +20,13 @@ import com.willfp.ecomobs.integrations.libsdisguises.IntegrationLibsDisguises
import com.willfp.ecomobs.integrations.modelengine.IntegrationModelEngine
import com.willfp.ecomobs.mob.EcoMobs
import com.willfp.ecomobs.mob.damage.TopDamagerHandler
import com.willfp.ecomobs.mob.impl.ecoMob
import com.willfp.libreforge.EmptyProvidedHolder.holder
import com.willfp.libreforge.EntityProvidedHolder
import com.willfp.libreforge.loader.LibreforgePlugin
import com.willfp.libreforge.loader.configs.ConfigCategory
import com.willfp.libreforge.registerSpecificHolderProvider
import org.bukkit.entity.Mob
import org.bukkit.event.Listener
internal lateinit var plugin: EcoMobsPlugin
@@ -34,6 +40,14 @@ class EcoMobsPlugin : LibreforgePlugin() {
plugin = this
}
override fun handleEnable() {
registerSpecificHolderProvider<Mob> {
it.ecoMob?.entityHolder.toSingletonList().map { holder ->
EntityProvidedHolder(holder, it)
}
}
}
override fun handleLoad() {
EntityGoals.register(EntityGoalRandomTeleport.Deserializer)
}
@@ -52,7 +66,8 @@ class EcoMobsPlugin : LibreforgePlugin() {
VanillaCompatibilityHandlers(),
DiscoverRecipeListener(this),
SpawnEggHandler(this),
SpawnTotemHandler()
SpawnTotemHandler(),
topDamagerHandler
)
}

View File

@@ -2,6 +2,7 @@ package com.willfp.ecomobs.category.spawning.impl
import com.willfp.eco.core.config.interfaces.Config
import com.willfp.eco.core.entities.Entities
import com.willfp.eco.util.randDouble
import com.willfp.ecomobs.EcoMobsPlugin
import com.willfp.ecomobs.category.MobCategory
import com.willfp.ecomobs.category.spawning.SpawnMethod
@@ -57,6 +58,10 @@ object SpawnMethodFactoryReplace : SpawnMethodFactory("replace") {
return
}
if (randDouble(0.0, 100.0) > config.getDouble("chance")) {
return
}
val mob = category.mobs.randomOrNull() ?: return

View File

@@ -3,7 +3,7 @@ package com.willfp.ecomobs.integrations.levelledmobs
import com.willfp.eco.core.integrations.Integration
import com.willfp.ecomobs.integrations.MobIntegration
import com.willfp.ecomobs.mob.impl.ecoMob
import me.lokka30.levelledmobs.events.MobPreLevelEvent
import io.github.arcaneplugins.levelledmobs.events.MobPreLevelEvent
import org.bukkit.entity.Mob
import org.bukkit.event.EventHandler
import org.bukkit.event.Listener

View File

@@ -21,7 +21,7 @@ class IntegrationModelEngine : Listener, Integration {
val modelled = ModelEngineBridge.instance.createModeledEntity(entity)
modelled.addModel(model)
modelled.isBaseEntityVisible = true
modelled.isBaseEntityVisible = false
}
override fun getPluginName(): String {

View File

@@ -7,6 +7,7 @@ import com.willfp.ecomobs.category.MobCategory
import com.willfp.ecomobs.integrations.MobIntegration
import com.willfp.ecomobs.mob.event.MobEvent
import com.willfp.ecomobs.mob.options.SpawnEgg
import com.willfp.libreforge.Holder
import com.willfp.libreforge.triggers.DispatchedTrigger
import org.bukkit.Location
import org.bukkit.entity.Mob
@@ -50,6 +51,11 @@ interface EcoMob : KRegistrable {
*/
val customEntity: CustomEntity
/**
* The entity holder.
*/
val entityHolder: Holder
/**
* Get a living mob from a bukkit mob.
*/

View File

@@ -27,7 +27,7 @@ interface LivingMob {
/**
* Kill the mob.
*/
fun kill(player: Player?)
fun kill(player: Player?, removeTracking: Boolean = true)
/**
* Despawn the mob.

View File

@@ -1,9 +1,11 @@
package com.willfp.ecomobs.mob.damage
import com.willfp.eco.util.savedDisplayName
import com.willfp.eco.util.toNiceString
import com.willfp.eco.util.tryAsPlayer
import com.willfp.ecomobs.EcoMobsPlugin
import com.willfp.libreforge.NamedValue
import com.willfp.libreforge.triggers.TriggerData
import org.bukkit.Bukkit
import org.bukkit.entity.Mob
import org.bukkit.event.EventHandler
@@ -49,10 +51,21 @@ class TopDamagerHandler(
fun generatePlaceholders(mob: Mob): List<NamedValue> {
return mob.topDamagers
.mapIndexed { index, damager ->
NamedValue("top_damager_${index + 1}_name", Bukkit.getOfflinePlayer(damager.uuid).name ?: "Unknown")
NamedValue("top_damager_${index + 1}_display", Bukkit.getOfflinePlayer(damager.uuid).savedDisplayName)
NamedValue("top_damager_${index + 1}_damage", damager.damage.toString())
.flatMapIndexed { index, damager ->
listOf(
NamedValue(
"top_damager_${index + 1}_name",
Bukkit.getOfflinePlayer(damager.uuid).name ?: "Unknown"
),
NamedValue(
"top_damager_${index + 1}_display",
Bukkit.getOfflinePlayer(damager.uuid).savedDisplayName
),
NamedValue(
"top_damager_${index + 1}_damage",
damager.damage.toNiceString()
)
)
}
}
}

View File

@@ -33,6 +33,12 @@ object MobEventKill : MobEvent("kill") {
Bukkit.getPluginManager().callEvent(EcoMobKillEvent(living, player))
living.handleEvent(this, data.dispatch(player.toDispatcher()))
living.kill(player)
// Tracking isn't removed here because it's removed in MobEventDeath, which is called after this one.
// Otherwise, player kills wouldn't fire the death event.
living.kill(
player,
removeTracking = false
)
}
}

View File

@@ -49,14 +49,19 @@ import com.willfp.ecomobs.tick.TickHandlerBossBar
import com.willfp.ecomobs.tick.TickHandlerDisplayName
import com.willfp.ecomobs.tick.TickHandlerLifespan
import com.willfp.libreforge.ConfigViolation
import com.willfp.libreforge.Holder
import com.willfp.libreforge.ViolationContext
import com.willfp.libreforge.conditions.ConditionList
import com.willfp.libreforge.conditions.Conditions
import com.willfp.libreforge.conditions.emptyConditionList
import com.willfp.libreforge.effects.EffectList
import com.willfp.libreforge.effects.Effects
import com.willfp.libreforge.enumValueOfOrNull
import com.willfp.libreforge.triggers.DispatchedTrigger
import net.kyori.adventure.bossbar.BossBar
import org.bukkit.Bukkit
import org.bukkit.Location
import org.bukkit.NamespacedKey
import org.bukkit.entity.Mob
import org.bukkit.entity.Player
import org.bukkit.event.entity.CreatureSpawnEvent
@@ -309,6 +314,17 @@ internal class ConfigDrivenEcoMob(
{ (it as? Mob)?.ecoMob == this }
) {
this.spawn(it, SpawnReason.COMMAND)!!.entity
}.apply { register() }
override val entityHolder = object : Holder {
override val id = plugin.createNamespacedKey(getID())
override val effects: EffectList = Effects.compile(
config.getSubsections("effects.permanent-effects"),
context.with("effects").with("permanent effects")
)
override val conditions = emptyConditionList()
}
/*
@@ -353,7 +369,6 @@ internal class ConfigDrivenEcoMob(
return trackedMobs[uuid]
}
@Suppress("UNCHECKED_CAST")
override fun spawn(location: Location, reason: SpawnReason): LivingMob? {
// Call bukkit event
val preSpawnEvent = EcoMobPreSpawnEvent(this, reason)
@@ -364,7 +379,7 @@ internal class ConfigDrivenEcoMob(
}
// Spawn bukkit mob
val entity = mob.spawn(location) as? Mob ?: throw IllegalStateException("Mob is not a mob")
val entity = mob.spawn(location) as? Mob ?: throw IllegalStateException("Base entity must be a mob!")
// Mark as custom mob
entity.ecoMob = this

View File

@@ -19,7 +19,7 @@ internal class LivingMobImpl(
private val plugin: EcoMobsPlugin,
override val mob: EcoMob,
override val entity: Mob,
private val deathCallback: () -> Unit
private val trackingRemovalCallback: () -> Unit
) : LivingMob {
private val ticker = plugin.runnableFactory.create {
tick(tick)
@@ -27,13 +27,13 @@ internal class LivingMobImpl(
if (!isAlive) {
it.cancel()
remove()
handleRemove()
}
}
private var isRunning = false
private var tick = 1
private var tick = 0
private val tickHandlers = mutableListOf<TickHandler>()
@@ -77,25 +77,26 @@ internal class LivingMobImpl(
mob.handleEvent(event, trigger)
}
override fun kill(player: Player?) {
remove()
override fun kill(player: Player?, removeTracking: Boolean) {
handleRemove(removeTracking = removeTracking)
mob.spawnDrops(entity.location, player)
}
override fun despawn() {
remove()
entity.remove()
handleRemove()
Bukkit.getPluginManager().callEvent(
EcoMobDespawnEvent(this)
)
}
private fun remove() {
private fun handleRemove(removeTracking: Boolean = true) {
ticker.cancel()
entity.remove()
deathCallback()
if (removeTracking) {
trackingRemovalCallback()
}
for (handler in this.tickHandlers) {
handler.onRemove(this, tick)

View File

@@ -26,6 +26,9 @@ spawning:
- zombie
- skeleton
# The chance for the mob to override, as a percentage
chance: 100
# Options for custom spawning
custom:

View File

@@ -4,6 +4,6 @@ environment:
options:
resource-id: 525
bstats-id: 10635
bstats-id: 20581
color: "&9"
proxy-package: "com.willfp.ecomobs.nms"

View File

@@ -1,5 +1,5 @@
messages:
prefix: "&9&lEcoMobs &f» "
prefix: "&9&lEcoMobs &8» &f"
no-permission: "&cYou don't have permission to do this!"
not-player: "&cThis command must be run by a player"
invalid-command: "&cUnknown subcommand!"

View File

@@ -52,43 +52,59 @@ custom-ai:
# How the mob should behave.
entity-goals: [ ]
# Effects are done from the player's perspective: to treat the player as the victim,
# either use self_as_victim in args, or use player_as_victim in mutators.
# Some effects are ran from the perspective of the entity, and others from the perspective
# of the player - each section is marked with which perspective it is run from.
# You can use display name placeholders in effects
# You can also use top damager placeholders:
# %top_damager_<place>_name%, %top_damager_<place>_damage%, %top_damager_<place>_display%
effects:
# Effects that are active all the time
# Ran from the perspective of the entity
permanent-effects: [ ]
# Effects ran when the mob spawns
# Ran from the perspective of the entity
spawn: [ ]
# Effects ran when the mob despawns
# Ran from the perspective of the entity
despawn: [ ]
# Effects ran when the player interacts with the mob
# Ran from the perspective of the player
interact: [ ]
# Effects ran when the player melee attacks the mob
# Ran from the perspective of the player
melee-attack: [ ]
# Effects ran when the player does a ranged attack on the mob
# Ran from the perspective of the player
ranged-attack: [ ]
# Effects ran when the player attacks the mob
# Ran from the perspective of the player
any-attack: [ ]
# Effects ran when the mob takes damage
# Ran from the perspective of the entity
take-damage: [ ]
# Effects ran when the player is damaged by the mob
# Ran from the perspective of the player
damage-player: [ ]
# Effects ran when the player is killed by the mob
# Ran from the perspective of the player
kill-player: [ ]
# Effects ran when the mob dies
# Ran from the perspective of the entity
death: [ ]
# Effects ran when the mob is killed by the player
# Ran from the perspective of the player
kill: [ ]
# The lifespan of the mob, in seconds. Set to -1 to disable.

View File

@@ -1,5 +1,5 @@
#libreforge-updater
#Sun Dec 24 14:55:22 CET 2023
#Sat Jul 05 16:46:16 BST 2025
kotlin.code.style=official
libreforge-version=4.51.0
version=10.0.0-b2
libreforge-version=4.76.1
version=10.21.1

Binary file not shown.

View File

@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@@ -2,12 +2,15 @@ pluginManagement {
repositories {
gradlePluginPortal()
mavenLocal()
maven("https://repo.jpenilla.xyz/snapshots/")
maven("https://repo.auxilor.io/repository/maven-public/")
maven("https://repo.papermc.io/repository/maven-public/")
}
}
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
}
rootProject.name = "EcoMobs"
// Core