Skip to content

Commit

Permalink
Merge pull request #494 from ArcanePlugins/4.0.0-dev
Browse files Browse the repository at this point in the history
4.0.0 dev
  • Loading branch information
stumper66 authored Jul 3, 2024
2 parents a8956b6 + fca9a92 commit 7c2ea21
Show file tree
Hide file tree
Showing 34 changed files with 298 additions and 320 deletions.
2 changes: 0 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ plugins {
id("org.jetbrains.dokka") version "1.9.20"
}

apply(plugin = "kotlin")

repositories {
mavenCentral()
maven("https://mvnrepository.com/")
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version = 4.0.5 b29
version = 4.0.6 b35
description = The Ultimate RPG Mob Levelling Solution
9 changes: 3 additions & 6 deletions levelledmobs-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@ idea {

dependencies {
implementation(kotlin("stdlib", version = "2.0.0"))
implementation("org.jetbrains.kotlin:kotlin-reflect:2.0.0")
compileOnly("io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT")
compileOnly("dev.folia:folia-api:1.20.4-R0.1-SNAPSHOT") // https://repo.papermc.io/#browse/browse:maven-public:dev%2Ffolia%2Ffolia-api
implementation("com.github.Redempt:Crunch:2.0.3") // https://redempt.dev/com/github/Redempt/Crunch
implementation("org.bstats:bstats-bukkit:3.0.2") // https://mvnrepository.com/artifact/org.bstats/bstats-bukkit
//implementation("dev.jorel:commandapi-bukkit-shade:9.3.0") // https://github.com/JorelAli/CommandAPI
implementation("nomaven:CommandAPI:9.5.0-mod") // https://github.com/JorelAli/CommandAPI
implementation("nomaven:CommandAPI:9.6.0-snapshot") // https://github.com/JorelAli/CommandAPI
// stumper66's fork: https://github.com/stumper66/CommandAPI
compileOnly("LibsDisguises:LibsDisguises:10.0.44-SNAPSHOT") // https://repo.md-5.net/#browse/browse:public:LibsDisguises%2FLibsDisguises
compileOnly("net.essentialsx:EssentialsX:2.20.1") // https://repo.essentialsx.net/#/releases/net/essentialsx/EssentialsX
Expand Down Expand Up @@ -75,11 +74,9 @@ tasks {
relocate("org.bstats", "io.github.arcaneplugins.levelledmobs.libs.bstats")
relocate("redempt.crunch", "io.github.arcaneplugins.levelledmobs.libs.crunch")
relocate("org.jetbrains.annotations", "io.github.arcaneplugins.levelledmobs.libs.jetbrains.annotations")
relocate("kotlin", "io.github.arcaneplugins.levelledmobs.libs.kotlin")
}
// if you don't exclude the reflection dep then reflection will be broken
minimize {
exclude(dependency("org.jetbrains.kotlin:kotlin-reflect"))
}
minimize{}
}

jar.configure {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ package io.github.arcaneplugins.levelledmobs.annotations
* @author stumper66
* @since 3.2.0
*/
@Target(AnnotationTarget.PROPERTY)
@Target(AnnotationTarget.FIELD)
annotation class DoNotMerge
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.arcaneplugins.levelledmobs.annotations

@Target(AnnotationTarget.PROPERTY)
@Target(AnnotationTarget.FIELD)
annotation class DoNotShow
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ package io.github.arcaneplugins.levelledmobs.annotations
* @author stumper66
* @since 3.12.0
*/
@Target(AnnotationTarget.PROPERTY)
@Target(AnnotationTarget.FIELD)
annotation class ExcludeFromHash
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package io.github.arcaneplugins.levelledmobs.annotations

import io.github.arcaneplugins.levelledmobs.enums.RuleType

@Target(AnnotationTarget.PROPERTY)
@Target(AnnotationTarget.FIELD)
annotation class RuleFieldInfo(
val value: String,
val ruleType: RuleType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import io.github.arcaneplugins.levelledmobs.debug.DebugCreator
import io.github.arcaneplugins.levelledmobs.debug.DebugManager
import io.github.arcaneplugins.levelledmobs.debug.DebugType
import io.github.arcaneplugins.levelledmobs.managers.ExternalCompatibilityManager
import io.github.arcaneplugins.levelledmobs.nametag.MiscUtils
import io.github.arcaneplugins.levelledmobs.util.MiscUtils
import io.github.arcaneplugins.levelledmobs.util.Log
import io.github.arcaneplugins.levelledmobs.util.MessageUtils
import io.github.arcaneplugins.levelledmobs.util.Utils
Expand Down Expand Up @@ -321,15 +321,23 @@ object DebugSubcommand {
sb.append("key: &b${items.key}&r, ${items.value}")
}

val message = formatDumpMessage(
"Showing PDC keys for",
lmEntity,
sb.toString()
)
val message = if (results.isEmpty()){
formatDumpMessage(
"No PDC keys were found for",
lmEntity,
null
)
} else{
formatDumpMessage(
"Showing PDC keys for",
lmEntity,
sb.toString()
)
}

lmEntity.free()

if (showOnConsole) {
if (showOnConsole && results.isNotEmpty()) {
Log.inf(message)
sender.sendMessage("PDC keys have been printed in the console")
}
Expand Down Expand Up @@ -418,7 +426,7 @@ object DebugSubcommand {
private fun formatDumpMessage(
messageStart: String,
lmEntity: LivingEntityWrapper,
values: String
values: String?
): String {
var entityName = lmEntity.nameIfBaby
if (ExternalCompatibilityManager.hasMythicMobsInstalled
Expand All @@ -435,11 +443,12 @@ object DebugSubcommand {
"${lmEntity.livingEntity.location.blockZ}"

val mobLevel = if (lmEntity.isLevelled) lmEntity.getMobLevel.toString() else "0"
val showValues = if (values != null) "\n$values" else ""

return if (lmEntity.nameIfBaby.equals(entityName, ignoreCase = true))
"$messageStart: $entityName (lvl $mobLevel) in ${lmEntity.worldName}, $locationStr&r\n$values"
"$messageStart: $entityName (lvl $mobLevel) in ${lmEntity.worldName}, $locationStr&r$showValues"
else
"$messageStart: $entityName (lvl $mobLevel ${lmEntity.typeName}) in ${lmEntity.worldName}, $locationStr&r\n$values"
"$messageStart: $entityName (lvl $mobLevel ${lmEntity.typeName}) in ${lmEntity.worldName}, $locationStr&r$showValues"
}

private fun parseEnableTimer(sender: CommandSender, args: CommandArguments) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ object KillSubcommand {
.executes(CommandExecutor { sender, args -> processCmd(sender, args, true) })
.withOptionalArguments(
ListArgumentBuilder<String>("values")
.skipListValidation(true)
.allowAnyValue(true)
.allowDuplicates(true)
.withList { info -> buildTabSuggestions(info) }
.withStringMapper()
.buildGreedy()
Expand All @@ -60,7 +61,8 @@ object KillSubcommand {
.executes(CommandExecutor { sender, args -> processCmd(sender, args, false) })
.withOptionalArguments(
ListArgumentBuilder<String>("values")
.skipListValidation(true)
.allowAnyValue(true)
.allowDuplicates(true)
.withList { info -> buildTabSuggestions(info) }
.withStringMapper()
.buildGreedy()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ import org.bukkit.entity.LivingEntity
import org.bukkit.entity.Player
import org.bukkit.persistence.PersistentDataType
import org.bukkit.util.Vector
import kotlin.reflect.KVisibility
import kotlin.reflect.full.declaredMemberProperties
import kotlin.reflect.full.findAnnotation
import kotlin.reflect.full.hasAnnotation

/**
* Shows the current rules as parsed from the various config files
Expand Down Expand Up @@ -568,17 +564,18 @@ object RulesSubcommand {
for (i in effectiveRules.indices) {
val pi = effectiveRules[i]

for (f in pi::class.declaredMemberProperties) {
if (f.visibility == KVisibility.PRIVATE) continue
if (f.hasAnnotation<DoNotMerge>()) continue
if (f.hasAnnotation<DoNotShow>()) continue
val value = f.getter.call(pi) ?: continue
for (f in pi::class.java.declaredFields) {
f.trySetAccessible()

if (f.isAnnotationPresent(DoNotMerge::class.java)) continue
if (f.isAnnotationPresent(DoNotShow::class.java)) continue
val value = f.get(pi) ?: continue
if (value.toString().isEmpty()) continue

var ruleName = f.name
var showValue: String? = null
var ruleInfoType = RuleType.MISC
val ruleTypeInfo = f.findAnnotation<RuleFieldInfo>()
val ruleTypeInfo = f.getAnnotation(RuleFieldInfo::class.java)
if (ruleTypeInfo != null) {
ruleInfoType = ruleTypeInfo.ruleType
ruleName = ruleTypeInfo.value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ object SpawnerEggCommand : SpawnerBaseClass() {
})
.withOptionalArguments(
ListArgumentBuilder<String>("values")
.skipListValidation(true)
.allowAnyValue(true)
.allowDuplicates(true)
.withList { info -> buildTabSuggestions(allEggOptions, info) }
.withStringMapper()
.buildGreedy()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ object SpawnerSubcommand : SpawnerBaseClass() {
})
.withOptionalArguments(
ListArgumentBuilder<String>("values")
.skipListValidation(true)
.allowAnyValue(true)
.allowDuplicates(true)
.withList { info -> buildTabSuggestions(allSpawnerOptions, info) }
.withStringMapper()
.buildGreedy()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ object SummonSubcommand {
.replaceSuggestions(ArgumentSuggestions.strings("here", "at-player", "at-location")))
.withOptionalArguments(
ListArgumentBuilder<String>("values")
.skipListValidation(true)
.allowAnyValue(true)
.allowDuplicates(true)
.withList { info -> buildTabSuggestions(info) }
.withStringMapper()
.buildGreedy()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ class CustomDropsHandler {
info.dropInstance = groupIdToInstance[drop.groupId]
info.groupLimits = groupLimitsMap.getOrDefault(drop.groupId, defaultLimits)
maxRetries =
info.groupLimits!!.retries.coerceAtMost(retriesHardcodedMax)
info.groupLimits?.retries?.coerceAtMost(retriesHardcodedMax) ?: 0
} else {
info.dropInstance = null
info.groupLimits = null
Expand Down Expand Up @@ -764,7 +764,7 @@ class CustomDropsHandler {

info.addDebugMessage(
"&8 - &7item: &b${newItem.type.name}&7, amount: &b${dropBase.amountAsString}&7, newAmount: &b$newDropAmount&7, " +
"chance: &b{dropBase.chance?.showMatchedChance()}&7, chanceRole: " +
"chance: &b${dropBase.chance?.showMatchedChance()}&7, chanceRole: " +
"&b${Utils.round(chanceRole.toDouble(), 4)}&7, dropped: &btrue&7$retryMsg."
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ enum class DeathCause {
VOID,
WITHER,
PLAYER_CAUSED,
CAMPFIRE
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@ enum class LevelledMobSpawnReason {
SPELL,
LM_SUMMON,
DEFAULT,
DUPLICATION
DUPLICATION,
TRIAL_SPAWNER
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@ class ChunkLoadListener : Listener {
}

private fun checkEntity(livingEntity: LivingEntity, event: ChunkLoadEvent) {
val main = LevelledMobs.instance
val lmEntity = LivingEntityWrapper.getInstance(livingEntity)
val wrapper = SchedulerWrapper(livingEntity){
val lmEntity = LivingEntityWrapper.getInstance(livingEntity)
if (main.levelManager.doCheckMobHash && Utils.checkIfMobHashChanged(lmEntity)) {
if (LevelledMobs.instance.levelManager.doCheckMobHash && Utils.checkIfMobHashChanged(lmEntity)) {
lmEntity.reEvaluateLevel = true
lmEntity.isRulesForceAll = true
lmEntity.wasPreviouslyLevelled = lmEntity.isLevelled
Expand All @@ -53,10 +52,12 @@ class ChunkLoadListener : Listener {
return@SchedulerWrapper
}

main.mobsQueueManager.addToQueue(QueueItem(lmEntity, event))
LevelledMobs.instance.mobsQueueManager.addToQueue(QueueItem(lmEntity, event))
lmEntity.free()
}

lmEntity.buildCacheIfNeeded()
lmEntity.inUseCount.getAndIncrement()
wrapper.runDirectlyInBukkit = true
wrapper.run()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ class EntityDamageListener : Listener {
}

val theHitter = LivingEntityWrapper.getInstance(event.damager as LivingEntity)
val nametagVisibilityEnums = LevelledMobs.instance.rulesManager.getRuleCreatureNametagVisbility(
theHitter
)
val nametagVisibilityEnums = theHitter.nametagVisibilityEnum
val nametagVisibleTime = theHitter.getNametagCooldownTime()

if (nametagVisibleTime > 0L &&
Expand Down Expand Up @@ -106,9 +104,7 @@ class EntityDamageListener : Listener {
lmEntity.associatedPlayer = (event.damager as Player)
}
}
val nametagVisibilityEnums = lmEntity.main.rulesManager.getRuleCreatureNametagVisbility(
lmEntity
)
val nametagVisibilityEnums = lmEntity.nametagVisibilityEnum
val nametagVisibleTime = lmEntity.getNametagCooldownTime()

if (nametagVisibleTime > 0L && wasDamagedByEntity &&
Expand Down Expand Up @@ -171,10 +167,7 @@ class EntityDamageListener : Listener {
val lmEntity = LivingEntityWrapper.getInstance(event.entity as LivingEntity)
MobDataManager.populateAttributeCache(lmEntity)

if (lmEntity.isLevelled && lmEntity.main.rulesManager.getRuleCreatureNametagVisbility(
lmEntity
).contains(NametagVisibilityEnum.ATTACKED)
) {
if (lmEntity.isLevelled && (lmEntity.nametagVisibilityEnum).contains(NametagVisibilityEnum.ATTACKED)) {
if (lmEntity.playersNeedingNametagCooldownUpdate == null) {
lmEntity.playersNeedingNametagCooldownUpdate = java.util.HashSet()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ class EntityPickupItemListener : Listener {
val pickedUpEquipment = PickedUpEquipment(lmEntity)
val wrapper = SchedulerWrapper(lmEntity.livingEntity) {
pickedUpEquipment.checkEquipment(itemStack)
lmEntity.free()
}

lmEntity.inUseCount.getAndIncrement()
wrapper.runDelayed(1L)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class EntitySpawnListener : Listener{
lmEntity.skylightLevel = lmEntity.currentSkyLightLevel
lmEntity.isNewlySpawned = true
lmEntity.populateShowShowLMNametag()
lmEntity.buildCacheIfNeeded()
MobDataManager.populateAttributeCache(lmEntity, null)

if (event is CreatureSpawnEvent) {
Expand Down Expand Up @@ -447,9 +448,7 @@ class EntitySpawnListener : Listener{
)

lmEntity.playerForLevelling = closestPlayer
val nametagVisibilityEnums = main.rulesManager.getRuleCreatureNametagVisbility(
lmEntity
)
val nametagVisibilityEnums = lmEntity.nametagVisibilityEnum
if (nametagVisibilityEnums.contains(NametagVisibilityEnum.TARGETED) &&
lmEntity.livingEntity.hasLineOfSight(closestPlayer)
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ class EntityTargetListener : Listener {
return
}

if (main.rulesManager.getRuleCreatureNametagVisbility(lmEntity)
.contains(NametagVisibilityEnum.TRACKING)
) {
if (lmEntity.nametagVisibilityEnum.contains(NametagVisibilityEnum.TRACKING)) {
synchronized(NametagTimerChecker.entityTarget_Lock) {
main.nametagTimerChecker.entityTargetMap.put(
lmEntity.livingEntity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ class LevelManager : LevelInterface2 {
val evalResult = MobDataManager.evaluateExpression(formula)
if (evalResult.hadError){
NotifyManager.notifyOfError("Error evaluating formula for construct-level on mob: ${lmEntity.nameIfBaby}, ${evalResult.error}")
DebugManager.log(DebugType.CONSTRUCT_LEVEL, lmEntity){
"result (error, ${evalResult.error})\n" +
" formulaPre: '$formulaPre'\n" +
" formula: '$formula'" }
throw EvaluationException()
}

Expand Down Expand Up @@ -1238,9 +1242,7 @@ class LevelManager : LevelInterface2 {
if (!lmEntity.isPopulated) {
return
}
val nametagVisibilityEnums = main.rulesManager.getRuleCreatureNametagVisbility(
lmEntity
)
val nametagVisibilityEnums = lmEntity.nametagVisibilityEnum
val nametagVisibleTime = lmEntity.getNametagCooldownTime()
if (nametagVisibleTime > 0L &&
nametagVisibilityEnums.contains(NametagVisibilityEnum.TARGETED) &&
Expand Down
Loading

0 comments on commit 7c2ea21

Please sign in to comment.