Skip to content

Commit

Permalink
Merge pull request #498 from ArcanePlugins/4-dev
Browse files Browse the repository at this point in the history
4 dev
  • Loading branch information
stumper66 authored Jul 27, 2024
2 parents 7c2ea21 + 2c7e4f0 commit 79629c5
Show file tree
Hide file tree
Showing 47 changed files with 1,048 additions and 1,062 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div align="center">
<td style="text-align: center;">

<img src="https://i.ibb.co/ySgMPd0/Levelled-Mobs-Banner-v2-0.png" width="600" height="300" alt="LevelledMobs Banner" />

Expand Down Expand Up @@ -29,7 +29,7 @@

### Also see: [Server Compatibility](https://github.com/lokka30/LevelledMobs/wiki/Compatibilities)[Installation Instructions](https://github.com/lokka30/LevelledMobs/wiki/Installation)

</div>
</td>

<br /><hr />

Expand Down Expand Up @@ -71,10 +71,10 @@ Remember to give these projects a star. :)

<br /><hr />

<div align="center">
<td style="text-align: center;">

## Learn More at [✈️ HangarMC](https://hangar.papermc.io/ArcanePlugins/LevelledMobs) or [🚰 SpigotMC](https://www.spigotmc.org/resources/levelledmobs.74304/)

### Also see: [Server Compatibility](https://github.com/lokka30/LevelledMobs/wiki/Compatibilities)[Installation Instructions](https://github.com/lokka30/LevelledMobs/wiki/Installation)

</div>
</td>
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.6 b35
version = 4.1.0 b47
description = The Ultimate RPG Mob Levelling Solution
9 changes: 6 additions & 3 deletions levelledmobs-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,18 @@ dependencies {
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.6.0-snapshot") // https://github.com/JorelAli/CommandAPI
// implementation("dev.jorel:commandapi-bukkit-shade:9.3.0") // 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
// now found in the lib directory

compileOnly("LibsDisguises:LibsDisguises:10.0.43-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
compileOnly("me.clip:placeholderapi:2.11.5") // https://repo.extendedclip.com/content/repositories/placeholderapi/me/clip/placeholderapi/
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT") // https://maven.enginehub.org/repo/com/sk89q/worldguard/worldguard-bukkit/
compileOnly("de.tr7zw:item-nbt-api-plugin:2.12.4") // https://mvnrepository.com/artifact/de.tr7zw/item-nbt-api-plugin
compileOnly("io.github.stumper66:LM_Items:1.3.0") // https://mvnrepository.com/artifact/io.github.stumper66/LM_Items

implementation(fileTree("lib") { include("*.jar") })
}

repositories {
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ class LevelledMobs : JavaPlugin() {
val random = Random()
var placeholderApiIntegration: PlaceholderApiIntegration? = null
internal set
var migratedFromPre30 = false
val helperSettings = YmlParsingHelper(YamlConfiguration())
var playerLevellingMinRelevelTime = 0L
internal set
Expand Down Expand Up @@ -131,6 +130,7 @@ class LevelledMobs : JavaPlugin() {
}

prepareToLoadCustomDrops()
mainCompanion.checkSettingsWithMaxPlayerOptions()
mainCompanion.startCleanupTask()
mainCompanion.setupMetrics()
mainCompanion.checkUpdates()
Expand Down Expand Up @@ -158,7 +158,6 @@ class LevelledMobs : JavaPlugin() {
}

fun reloadLM(sender: CommandSender) {
migratedFromPre30 = false
NotifyManager.clearLastError()
customDropsHandler.customDropsParser.invalidExternalItems.clear()
var reloadStartedMsg = messagesCfg.getStringList(
Expand Down Expand Up @@ -206,10 +205,6 @@ class LevelledMobs : JavaPlugin() {
))
}

levelManager.entitySpawnListener.processMobSpawns = helperSettings.getBoolean(
"level-mobs-upon-spawn", true
)

rulesManager.clearTempDisabledRulesCounts()
definitions.useTranslationComponents = helperSettings.getBoolean(
"use-translation-components", true
Expand All @@ -219,6 +214,7 @@ class LevelledMobs : JavaPlugin() {
"use-legacy-serializer", true
)
)
mainCompanion.checkSettingsWithMaxPlayerOptions()
nametagQueueManager.nametagSenderHandler.refresh()

reloadFinishedMsg.forEach(Consumer { s: String ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import io.github.arcaneplugins.levelledmobs.managers.ExternalCompatibilityManage
import io.github.arcaneplugins.levelledmobs.managers.PlaceholderApiIntegration
import io.github.arcaneplugins.levelledmobs.result.ChunkKillInfo
import io.github.arcaneplugins.levelledmobs.debug.DebugType
import io.github.arcaneplugins.levelledmobs.listeners.EntitySpawnListener
import io.github.arcaneplugins.levelledmobs.listeners.ServerLoadEvent
import io.github.arcaneplugins.levelledmobs.misc.FileLoader
import io.github.arcaneplugins.levelledmobs.misc.FileLoader.loadFile
Expand All @@ -31,6 +32,7 @@ import io.github.arcaneplugins.levelledmobs.misc.OutdatedServerVersionException
import io.github.arcaneplugins.levelledmobs.misc.VersionInfo
import io.github.arcaneplugins.levelledmobs.rules.MetricsInfo
import io.github.arcaneplugins.levelledmobs.util.Log
import io.github.arcaneplugins.levelledmobs.util.MessageUtils
import io.github.arcaneplugins.levelledmobs.util.UpdateChecker
import io.github.arcaneplugins.levelledmobs.util.Utils.colorizeAllInList
import io.github.arcaneplugins.levelledmobs.util.Utils.replaceAllInList
Expand Down Expand Up @@ -199,16 +201,27 @@ class MainCompanion{
this.showCustomDrops = main.debugManager.isDebugTypeEnabled(DebugType.CUSTOM_DROPS)
}

fun checkSettingsWithMaxPlayerOptions(playerJustLeft: Boolean = false){
val levelMobsUponSpawnMaxPlayers = LevelledMobs.instance.helperSettings.getInt(
"level-mobs-upon-spawn-max-players", 10
)
val updateMobsUponNonplayerDamageMaxPlayers = LevelledMobs.instance.helperSettings.getInt(
"update-mobs-upon-nonplayer-damage-max-players", 5
)
var currentPlayerCount = Bukkit.getOnlinePlayers().size
if (playerJustLeft) currentPlayerCount--

EntitySpawnListener.instance.processMobSpawns = currentPlayerCount <= levelMobsUponSpawnMaxPlayers
EntityDamageListener.instance.updateMobsOnNonPlayerdamage = currentPlayerCount <= updateMobsUponNonplayerDamageMaxPlayers
}

fun registerListeners() {
Log.inf("&fListeners: &7Registering event listeners...")

val main = LevelledMobs.instance
main.levelManager.load()
main.mobsQueueManager.start()
main.nametagQueueManager.start()
main.levelManager.entitySpawnListener.processMobSpawns = main.helperSettings.getBoolean(
"level-mobs-upon-spawn", true
)
main.entityDamageDebugListener = EntityDamageDebugListener()
main.blockPlaceListener = BlockPlaceListener()

Expand Down Expand Up @@ -483,7 +496,6 @@ class MainCompanion{
updateResult = replaceAllInList(
updateResult, "%latestVersion%", latestVersion
)
updateResult = colorizeAllInList(updateResult)

if (main.messagesCfg.getBoolean(
"other.update-notice.send-in-console",
Expand All @@ -503,7 +515,7 @@ class MainCompanion{
)
) {
for (msg in updateResult) {
onlinePlayer.sendMessage(msg)
onlinePlayer.sendMessage(MessageUtils.colorizeAll(msg))
}
//updateResult.forEach(onlinePlayer::sendMessage); //compiler didn't like this :(
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ object DebugSubcommand {
.includeSuggestions(ArgumentSuggestions.strings("enable", "disable")))
.executes(CommandExecutor { sender, args -> processDamageDebugOutput(sender, args) })
)
.withSubcommands(
CommandAPICommand("view-queues")
.executes(CommandExecutor { sender, _ -> viewQueues(sender) })
)
}

private fun processDamageDebugOutput(
Expand Down Expand Up @@ -249,6 +253,13 @@ object DebugSubcommand {
)
}

private fun viewQueues(sender: CommandSender){
val nametagQueueNum = LevelledMobs.instance.nametagQueueManager.showNumberQueued()
val mobQueueNum = LevelledMobs.instance.mobsQueueManager.showNumberQueued()

sender.sendMessage("Nametag Manager items: $nametagQueueNum, Mob Queue Manager items: $mobQueueNum")
}

private fun getListenForValues(): MutableList<String>{
val values = mutableListOf<String>()

Expand Down Expand Up @@ -887,7 +898,6 @@ object DebugSubcommand {
"location is ${l.blockX}, ${l.blockY}, ${l.blockZ} in ${l.world.name}"

sender.sendMessage("Your location: $locationStr")
Log.inf("Player ${sender.getName()}, location: $locationStr")
}

private fun getDebugTypes(): MutableList<String> {
Expand All @@ -900,9 +910,7 @@ object DebugSubcommand {

private fun getOutputToTypes(): Array<String>{
val values = mutableListOf<String>()
Log.inf("current output type: ${LevelledMobs.instance.debugManager.outputType}")
for (outputType in DebugManager.OutputTypes.entries) {
Log.inf("checking: $outputType")
if (LevelledMobs.instance.debugManager.outputType != outputType)
values.add(outputType.name.replace("_", "-").lowercase())
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.github.arcaneplugins.levelledmobs.customdrops

import io.github.arcaneplugins.levelledmobs.enums.DeathCause
import java.util.TreeSet
import java.util.UUID
import io.github.arcaneplugins.levelledmobs.misc.CachedModalList
Expand Down Expand Up @@ -36,7 +35,7 @@ abstract class CustomDropBase(
val permissions = mutableListOf<String>()
val playeerVariableMatches = mutableListOf<String>()
val excludedMobs: MutableSet<String> = TreeSet(String.CASE_INSENSITIVE_ORDER)
var causeOfDeathReqs: CachedModalList<DeathCause>? = null
var causeOfDeathReqs: CachedModalList<String>? = null

var amount: Int = 1
set(value) {
Expand All @@ -49,7 +48,7 @@ abstract class CustomDropBase(
get() = !this.groupId.isNullOrEmpty()


val amountAsString: String
open val amountAsString: String
get() {
return if (this.hasAmountRange) {
"$amountRangeMin-$amountRangeMax"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class CustomDropItem() : CustomDropBase(
LevelledMobs.instance.customDropsHandler.customDropsParser.defaults),
Cloneable {
var customModelDataId = 0
var amountFormula: String? = null
var equippedChance: SlidingChance? = null
var noMultiplier = false
var onlyDropIfEquipped = false
Expand Down Expand Up @@ -79,6 +80,14 @@ class CustomDropItem() : CustomDropBase(
return copy
}

override val amountAsString: String
get() {
return if (amountFormula.isNullOrEmpty())
super.amountAsString
else
"'${amountFormula!!}'"
}

fun setDamageRangeFromString(numberOrNumberRange: String?): Boolean {
if (numberOrNumberRange.isNullOrEmpty()) {
return false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import java.util.UUID
import io.github.arcaneplugins.levelledmobs.LevelledMobs
import io.github.arcaneplugins.levelledmobs.debug.DebugManager
import io.github.arcaneplugins.levelledmobs.debug.DebugType
import io.github.arcaneplugins.levelledmobs.enums.DeathCause
import io.github.arcaneplugins.levelledmobs.enums.EquipmentClass
import io.github.arcaneplugins.levelledmobs.rules.CustomDropsRuleSet
import io.github.arcaneplugins.levelledmobs.wrappers.LivingEntityWrapper
Expand All @@ -23,7 +22,7 @@ class CustomDropProcessingInfo {
var lmEntity: LivingEntityWrapper? = null
var mobKiller: Player? = null
val playerLevelVariableCache = mutableMapOf<String, Int>()
var deathCause: DeathCause? = null
var deathCause: String? = null
var addition = 0f
var isSpawner = false
var equippedOnly = false
Expand All @@ -42,6 +41,8 @@ class CustomDropProcessingInfo {
var newDrops: MutableList<ItemStack>? = null
var dropInstance: CustomDropInstance? = null
var equippedItemsInfo: EquippedItemsInfo? = null
var overallChanceDebugMessage: String = ""
private var debugTypeToUse = DebugType.CUSTOM_DROPS
private val groupIDsDroppedAlready: MutableMap<String, Int> = TreeMap(String.CASE_INSENSITIVE_ORDER)
private val itemsDroppedById = mutableMapOf<UUID, Int>()
var prioritizedDrops: MutableMap<Int, MutableList<CustomDropBase>>? = null
Expand All @@ -62,9 +63,8 @@ class CustomDropProcessingInfo {
val count = itemsDroppedById.getOrDefault(dropBase.uid, 0) + amountDropped
itemsDroppedById[dropBase.uid] = count

if (equipmentClass != null && dropBase is CustomDropItem && equippedItemsInfo != null){
if (equipmentClass != null && dropBase is CustomDropItem && equippedItemsInfo != null)
EquippedItemsInfo.droppedEquipmentByClass.add(equipmentClass!!)
}
}

fun getDropItemsCountForGroup(dropBase: CustomDropBase): Int {
Expand All @@ -84,31 +84,29 @@ class CustomDropProcessingInfo {
}

fun addDebugMessage(debugType: DebugType, message: String?) {
if (!LevelledMobs.instance.debugManager.isDebugTypeEnabled(debugType)) {
if (!LevelledMobs.instance.debugManager.isDebugTypeEnabled(debugType))
return
}

this.debugTypeToUse = debugType
addDebugMessage(message)
}

fun addDebugMessage(message: String?) {
if (this.debugMessages == null) {
if (this.debugMessages == null)
this.debugMessages = StringBuilder()
}

if (debugMessages!!.isNotEmpty()) {
debugMessages!!.append(System.lineSeparator())
}
if (debugMessages!!.isNotEmpty())
debugMessages!!.append("\n")

debugMessages!!.append(message)
}

fun writeAnyDebugMessages() {
if (this.debugMessages == null || debugMessages!!.isEmpty()) {
if (this.debugMessages == null || debugMessages!!.isEmpty())
return
}

DebugManager.log(DebugType.CUSTOM_DROPS, lmEntity) { debugMessages.toString() }
DebugManager.logNoComma(debugTypeToUse, lmEntity) { "\n$debugMessages" }
debugMessages!!.setLength(0)
this.debugTypeToUse = DebugType.CUSTOM_DROPS
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.github.arcaneplugins.levelledmobs.customdrops

import io.github.arcaneplugins.levelledmobs.enums.DeathCause
import io.github.arcaneplugins.levelledmobs.misc.CachedModalList

/**
Expand All @@ -16,6 +15,7 @@ class CustomDropsDefaults {
var playerCausedOnly = false
var onlyDropIfEquipped = false
var amount = 1
var amountFormula: String? = null
var priority = 0
var minLevel = -1
var maxLevel = -1
Expand All @@ -35,7 +35,7 @@ class CustomDropsDefaults {
var itemFlagsStrings: MutableList<String>? = null
var permissions = mutableListOf<String>()
var overallPermissions = mutableListOf<String>()
var causeOfDeathReqs: CachedModalList<DeathCause>? = null
var causeOfDeathReqs: CachedModalList<String>? = null
var externalType: String? = null
var externalItemId: String? = null
var externalAmount: Double? = null
Expand Down Expand Up @@ -68,6 +68,8 @@ class CustomDropsDefaults {
this.causeOfDeathReqs = dropBase.causeOfDeathReqs

if (dropBase is CustomDropItem) {
if (!dropBase.amountFormula.isNullOrEmpty())
this.amountFormula = dropBase.amountFormula
this.customModelData = dropBase.customModelDataId
if (this.equippedChance != null)
this.equippedChance!!.setFromInstance(dropBase.equippedChance)
Expand Down
Loading

0 comments on commit 79629c5

Please sign in to comment.