Skip to content

Commit

Permalink
Merge pull request #504 from ArcanePlugins/4-dev
Browse files Browse the repository at this point in the history
4 dev
  • Loading branch information
stumper66 authored Nov 9, 2024
2 parents 3de1995 + c23bf7b commit cd64ce4
Show file tree
Hide file tree
Showing 19 changed files with 404 additions and 334 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version = 4.1.3 b68
version = 4.1.4 b75
description = The Ultimate RPG Mob Levelling Solution
3 changes: 2 additions & 1 deletion levelledmobs-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ idea {

dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib:2.0.20")
compileOnly("io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT")
compileOnly("io.papermc.paper:paper-api:1.21.3-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.1.0") // https://mvnrepository.com/artifact/org.bstats/bstats-bukkit
Expand All @@ -50,6 +50,7 @@ repositories {
gradlePluginPortal()
mavenCentral()
mavenLocal()
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
maven("https://repo.md-5.net/content/groups/public/")
maven("https://repo.papermc.io/repository/maven-public/")
maven("https://repo.essentialsx.net/releases/")
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -434,27 +434,32 @@ class MainCompanion{
}
}

//Check for updates on the Spigot page.
// check for updates on the Hangar page.
fun checkUpdates() {
val main = LevelledMobs.instance
if (main.helperSettings.getBoolean("use-update-checker", true)) {
val updateChecker = UpdateChecker(main, 74304)
val updateChecker = UpdateChecker(main, "LevelledMobs")
try {
updateChecker.getLatestVersion { latestVersion: String ->
val currentVersion =
updateChecker.currentVersion.split(" ".toRegex()).dropLastWhile { it.isEmpty() }
.toTypedArray()[0]
updateChecker.getLatestVersion { latestVersionFull: String? ->
val currentVersion = updateChecker.currentVersion.split(" ")[0]
val thisVersion: VersionInfo
val spigotVersion: VersionInfo
val hangarVersion: VersionInfo
var isOutOfDate: Boolean
var isNewerVersion: Boolean

if (latestVersionFull == null){
Log.war("Unable to retreive latest version, string was null")
return@getLatestVersion
}

val latestVersion = latestVersionFull.split("-")[0]

try {
thisVersion = VersionInfo(currentVersion)
spigotVersion = VersionInfo(latestVersion)
hangarVersion = VersionInfo(latestVersion)

isOutOfDate = (thisVersion < spigotVersion)
isNewerVersion = (thisVersion > spigotVersion)
isOutOfDate = (thisVersion < hangarVersion)
isNewerVersion = (thisVersion > hangarVersion)
} catch (e: InvalidObjectException) {
Log.war("Got exception creating version objects: ${e.message}")

Expand All @@ -467,10 +472,10 @@ class MainCompanion{
)

updateResult = replaceAllInList(
updateResult, "%currentVersion%", currentVersion
updateResult, "%currentVersion%", updateChecker.currentVersion
)
updateResult = replaceAllInList(
updateResult, "%latestVersion%", latestVersion
updateResult, "%latestVersion%", latestVersionFull.replace("-", " ")
)
updateResult = colorizeAllInList(updateResult)

Expand Down Expand Up @@ -556,8 +561,11 @@ class MainCompanion{
// include interfaces: Animals, WaterMob
passiveMobsGroup.addAll(mutableListOf(
EntityType.IRON_GOLEM,
EntityType.SNOWMAN
))
val snowGolem = if (versionInfo.useOldEnums) EntityType.valueOf("SNOWMAN")
else EntityType.valueOf("SNOW_GOLEM")

passiveMobsGroup.add(snowGolem)

if (versionInfo.minorVersion >= 19) {
passiveMobsGroup.addAll(Compat119.getPassiveMobs())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ object RulesSubcommand {
private fun spawnParticles(location: Location, world: World) {
try {
for (i in 0..9) {
world.spawnParticle(Particle.SPELL, location, 20, 0.0, 0.0, 0.0, 0.1)
world.spawnParticle(Particle.EFFECT, location, 20, 0.0, 0.0, 0.0, 0.1)
Thread.sleep(50)
}
} catch (ignored: InterruptedException) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import java.util.Locale
import java.util.SortedMap
import java.util.TreeMap
import org.bukkit.Material
import org.bukkit.NamespacedKey
import org.bukkit.Registry
import org.bukkit.command.CommandSender
import org.bukkit.configuration.ConfigurationSection
import org.bukkit.configuration.MemorySection
Expand Down Expand Up @@ -708,36 +706,33 @@ class CustomDropsParser(
if (value is LinkedHashMap<*, *>) {
// contains enchantment chances

val en = Registry.ENCHANTMENT.get(
NamespacedKey.minecraft(enchantName.lowercase(Locale.getDefault()))
)
val enchantment = Utils.getEnchantment(enchantName)

if (en == null) {
if (enchantment == null) {
hadError("Invalid enchantment: $enchantName")
continue
}

val enchantments = value as MutableMap<Any, Any>
parseEnchantmentChances(en, enchantments, item)
parseEnchantmentChances(enchantment, enchantments, item)
continue
}

var enchantLevel = 1
if (value != null && Utils.isInteger(value.toString()))
enchantLevel = value.toString().toInt()

val en = Registry.ENCHANTMENT.get(
NamespacedKey.minecraft(enchantName.lowercase(Locale.getDefault()))
)
if (en != null) {
val enchantment = Utils.getEnchantment(enchantName)

if (enchantment != null) {
if (item.material == Material.ENCHANTED_BOOK) {
val meta = item.itemStack
?.itemMeta as EnchantmentStorageMeta
meta.addStoredEnchant(en, enchantLevel, true)
meta.addStoredEnchant(enchantment, enchantLevel, true)
item.itemStack!!.setItemMeta(meta)
}
else
item.itemStack!!.addUnsafeEnchantment(en, enchantLevel)
item.itemStack!!.addUnsafeEnchantment(enchantment, enchantLevel)
}
else
hadError("Invalid enchantment: $enchantName")
Expand Down Expand Up @@ -1205,15 +1200,17 @@ class CustomDropsParser(
sb.append(enchantmentLevels)
}

// enchantment info here
if (item.itemStack != null) {
val meta = item.itemStack!!.itemMeta
val itemStack = item.itemStack!!
val meta = itemStack.itemMeta
val sb2 = StringBuilder()
if (meta != null) {
for (enchant in meta.enchants.keys) {
if (sb2.isNotEmpty()) sb2.append(", ")

sb2.append(
"&b${enchant.key.key}&r (${item.itemStack!!.itemMeta.enchants[enchant]})", enchant.key.key
"&b${enchant.key.key}&r (${itemStack.itemMeta.enchants[enchant]})"
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class EntityDeathListener : Listener {

// These entity types will be forced not to be processed
private val bypassEntity = mutableListOf(
EntityType.ARMOR_STAND,EntityType.ITEM_FRAME, EntityType.DROPPED_ITEM, EntityType.PAINTING)
EntityType.ARMOR_STAND,EntityType.ITEM_FRAME, EntityType.ITEM_DISPLAY, EntityType.PAINTING)

@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
fun onDeath(event: EntityDeathEvent) {
Expand All @@ -45,12 +45,8 @@ class EntityDeathListener : Listener {
damageMappings.remove(event.entity.uniqueId)
}

if (event.entity is Player) {
return
}
if (bypassEntity.contains(event.entityType)) {
return
}
if (event.entity is Player) return
if (bypassEntity.contains(event.entityType)) return

val main = LevelledMobs.instance
val killer = damagingPlayer ?: event.entity.killer
Expand All @@ -64,9 +60,7 @@ class EntityDeathListener : Listener {
lmEntity.associatedPlayer = killer
val damage = lmEntity.livingEntity.lastDamageCause

if (damage != null) {
lmEntity.deathCause = damage.cause
}
if (damage != null) lmEntity.deathCause = damage.cause

if (killer != null && main.placeholderApiIntegration != null) {
main.placeholderApiIntegration!!.putPlayerOrMobDeath(
Expand All @@ -89,12 +83,8 @@ class EntityDeathListener : Listener {
event.drops.clear()
disableXpDrops = true
}
if (opts.getDisableItemBoost()) {
doNotMultiplyDrops = true
}
if (opts.getDisableXpDrops()) {
doNotBoostXp = true
}
if (opts.getDisableItemBoost()) doNotMultiplyDrops = true
if (opts.getDisableXpDrops()) doNotBoostXp = true
}
}

Expand All @@ -120,22 +110,20 @@ class EntityDeathListener : Listener {
main.levelManager.setLevelledItemDrops(lmEntity, event.drops, doNotMultiplyDrops)

// Set levelled exp drops
if (disableXpDrops) {
if (disableXpDrops)
event.droppedExp = 0
} else if (!doNotBoostXp) {
if (event.droppedExp > 0) {
else if (!doNotBoostXp) {
if (event.droppedExp > 0)
event.droppedExp = main.levelManager.getLevelledExpDrops(lmEntity, event.droppedExp.toDouble())
}
}
} else if (lmEntity.lockedCustomDrops != null || main.rulesManager.getRuleUseCustomDropsForMob(lmEntity).useDrops) {
val drops = mutableListOf<ItemStack>()
val result: CustomDropResult = main.customDropsHandler.getCustomItemDrops(
lmEntity,
drops, false
)
if (result.hasOverride) {
if (result.hasOverride)
main.levelManager.removeVanillaDrops(lmEntity, event.drops)
}

event.drops.addAll(drops)
}
Expand Down
Loading

0 comments on commit cd64ce4

Please sign in to comment.