From ac02bc2a8e9367881dc49b077859395dba01b18e Mon Sep 17 00:00:00 2001 From: Penal Buffalo Date: Wed, 15 Mar 2023 14:24:12 -0500 Subject: [PATCH 1/3] v3.9.5 b741 * fix compatibility with minecraft 1.17 and 1.18 --- pom.xml | 2 +- src/main/java/me/lokka30/levelledmobs/nametag/Definitions.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 90e692aa9..c7815c43e 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ me.lokka30 LevelledMobs - 3.9.4 b740 + 3.9.5 b741 LevelledMobs The Ultimate RPG Mob Levelling Solution diff --git a/src/main/java/me/lokka30/levelledmobs/nametag/Definitions.java b/src/main/java/me/lokka30/levelledmobs/nametag/Definitions.java index 99b10dd1a..298c7280a 100644 --- a/src/main/java/me/lokka30/levelledmobs/nametag/Definitions.java +++ b/src/main/java/me/lokka30/levelledmobs/nametag/Definitions.java @@ -299,7 +299,7 @@ else if (ver.getMinecraftVersion() <= 1.17) { // net.minecraft.world.level.entity.EntityAccess -> // int getId() -> - if (this.isOneNinteenThreeOrNewer){ + if (ver.getMinecraftVersion() >= 1.18){ if (ver.getRevision() >= 4){ methodName = "af"; } From 69effe0f22d9ad8fdb1588f5a6af8e3b4ac185b1 Mon Sep 17 00:00:00 2001 From: Penal Buffalo Date: Wed, 15 Mar 2023 16:32:32 -0500 Subject: [PATCH 2/3] v3.9.5 b742 * fix issue only on spigot servers where a custom nametag format won't show colors if missing `%displayname%` --- pom.xml | 2 +- .../java/me/lokka30/levelledmobs/nametag/NmsNametagSender.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index c7815c43e..fe7c7f1f6 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ me.lokka30 LevelledMobs - 3.9.5 b741 + 3.9.5 b742 LevelledMobs The Ultimate RPG Mob Levelling Solution diff --git a/src/main/java/me/lokka30/levelledmobs/nametag/NmsNametagSender.java b/src/main/java/me/lokka30/levelledmobs/nametag/NmsNametagSender.java index aa9980a6d..2a215e24c 100644 --- a/src/main/java/me/lokka30/levelledmobs/nametag/NmsNametagSender.java +++ b/src/main/java/me/lokka30/levelledmobs/nametag/NmsNametagSender.java @@ -9,6 +9,7 @@ import me.lokka30.levelledmobs.LevelledMobs; import me.lokka30.levelledmobs.result.NametagResult; +import me.lokka30.levelledmobs.util.Utils; import me.lokka30.microlib.messaging.MessageUtils; import org.bukkit.Bukkit; import org.bukkit.entity.LivingEntity; @@ -220,7 +221,7 @@ private Optional buildNametagComponent( final int displayNameIndex = mobName.indexOf(displayName); if (displayNameIndex < 0) { - final Object comp = ComponentUtils.getTextComponent(nametag.getNametagNonNull()); + final Object comp = ComponentUtils.getTextComponent(MessageUtils.colorizeAll(nametag.getNametagNonNull())); return comp == null ? Optional.empty() : Optional.of(comp); } From cb1a0f9688d1641802c5b46e8e74387dfdf6eb7f Mon Sep 17 00:00:00 2001 From: Penal Buffalo Date: Sat, 18 Mar 2023 09:25:44 -0500 Subject: [PATCH 3/3] v3.9.5 b743 * update classes to make custom rules accessible from 3rd party plugins --- pom.xml | 2 +- .../lokka30/levelledmobs/rules/RuleInfo.java | 134 +++++++++--------- .../levelledmobs/rules/RulesManager.java | 7 + .../rules/RulesParsingManager.java | 11 +- 4 files changed, 83 insertions(+), 71 deletions(-) diff --git a/pom.xml b/pom.xml index fe7c7f1f6..e55717185 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ me.lokka30 LevelledMobs - 3.9.5 b742 + 3.9.5 b743 LevelledMobs The Ultimate RPG Mob Levelling Solution diff --git a/src/main/java/me/lokka30/levelledmobs/rules/RuleInfo.java b/src/main/java/me/lokka30/levelledmobs/rules/RuleInfo.java index 468d4119c..808f67aa3 100644 --- a/src/main/java/me/lokka30/levelledmobs/rules/RuleInfo.java +++ b/src/main/java/me/lokka30/levelledmobs/rules/RuleInfo.java @@ -39,80 +39,80 @@ public RuleInfo(final String id) { } private String ruleName; - @DoNotMerge boolean ruleIsEnabled; + public @DoNotMerge boolean ruleIsEnabled; @DoNotMerge boolean isTempDisabled; - Boolean disableVanillaDropsOnChunkMax; - boolean useNoSpawnerParticles; - Boolean babyMobsInheritAdultSetting; - Boolean mobLevelInheritance; + public Boolean disableVanillaDropsOnChunkMax; + public boolean useNoSpawnerParticles; + public Boolean babyMobsInheritAdultSetting; + public Boolean mobLevelInheritance; public Boolean customDrops_UseForMobs; - Boolean customDrops_UseOverride; - Boolean stopProcessingRules; - Boolean useRandomLevelling; - Boolean mergeEntityNameOverrides; - Boolean passengerMatchLevel; + public Boolean customDrops_UseOverride; + public Boolean stopProcessingRules; + public Boolean useRandomLevelling; + public Boolean mergeEntityNameOverrides; + public Boolean passengerMatchLevel; Boolean lockEntity; @DoNotMerge int rulePriority; - Integer spawnerParticlesCount; - Integer maxRandomVariance; - Integer creeperMaxDamageRadius; - Integer conditions_MinLevel; - Integer conditions_MaxLevel; - Integer restrictions_MinLevel; - Integer restrictions_MaxLevel; - Integer conditions_ApplyAboveY; - Integer conditions_ApplyBelowY; - Integer conditions_MinDistanceFromSpawn; - Integer conditions_MaxDistanceFromSpawn; - Long nametagVisibleTime; - Integer maximumDeathInChunkThreshold; - Integer chunkMaxCoolDownTime; - Integer maxAdjacentChunks; - Long conditions_CooldownTime; - Integer conditions_TimesToCooldownActivation; - Float conditions_Chance; - Double sunlightBurnAmount; + public Integer spawnerParticlesCount; + public Integer maxRandomVariance; + public Integer creeperMaxDamageRadius; + public Integer conditions_MinLevel; + public Integer conditions_MaxLevel; + public Integer restrictions_MinLevel; + public Integer restrictions_MaxLevel; + public Integer conditions_ApplyAboveY; + public Integer conditions_ApplyBelowY; + public Integer conditions_MinDistanceFromSpawn; + public Integer conditions_MaxDistanceFromSpawn; + public Long nametagVisibleTime; + public Integer maximumDeathInChunkThreshold; + public Integer chunkMaxCoolDownTime; + public Integer maxAdjacentChunks; + public Long conditions_CooldownTime; + public Integer conditions_TimesToCooldownActivation; + public Float conditions_Chance; + public Double sunlightBurnAmount; public String nametag; - String nametag_CreatureDeath; - String nametag_Placeholder_Levelled; - String nametag_Placeholder_Unlevelled; - @DoNotMerge String presetName; - final @NotNull List customDrop_DropTableIds; - HealthIndicator healthIndicator; - MobCustomNameStatus conditions_MobCustomnameStatus; - MobTamedStatus conditions_MobTamedStatus; - LevellingStrategy levellingStrategy; - PlayerLevellingOptions playerLevellingOptions; - Map> entityNameOverrides_Level; - Map entityNameOverrides; - DeathMessages deathMessages; + public String nametag_CreatureDeath; + public String nametag_Placeholder_Levelled; + public String nametag_Placeholder_Unlevelled; + public @DoNotMerge String presetName; + public final @NotNull List customDrop_DropTableIds; + public HealthIndicator healthIndicator; + public MobCustomNameStatus conditions_MobCustomnameStatus; + public MobTamedStatus conditions_MobTamedStatus; + public LevellingStrategy levellingStrategy; + public PlayerLevellingOptions playerLevellingOptions; + public Map> entityNameOverrides_Level; + public Map entityNameOverrides; + public DeathMessages deathMessages; public List nametagVisibilityEnum; - @NotNull @DoNotMerge public final Map ruleSourceNames; + public @NotNull @DoNotMerge final Map ruleSourceNames; public Particle spawnerParticle; - List tieredColoringInfos; - Map enabledExtCompats; - MergeableStringList mobNBT_Data; - CachedModalList allowedEntities; - MinAndMax conditions_SkyLightLevel; - CachedModalList conditions_Worlds; - CachedModalList conditions_Entities; - CachedModalList conditions_Biomes; - CachedModalList conditions_ApplyPlugins; - CachedModalList conditions_CustomNames; - CachedModalList conditions_NoDropEntities; - CachedModalList conditions_WGRegions; - CachedModalList conditions_WGRegionOwners; - CachedModalList conditions_MM_Names; - CachedModalList conditions_SpawnerNames; - CachedModalList conditions_SpawnegEggNames; - CachedModalList conditions_ScoreboardTags; - CachedModalList conditions_WorldTickTime; - CachedModalList vanillaBonuses; - CachedModalList conditions_SpawnReasons; - CachedModalList conditions_Permission; - WithinCoordinates conditions_WithinCoords; - @Nullable FineTuningAttributes allMobMultipliers; - Map specificMobMultipliers; + public List tieredColoringInfos; + public Map enabledExtCompats; + public MergeableStringList mobNBT_Data; + public CachedModalList allowedEntities; + public MinAndMax conditions_SkyLightLevel; + public CachedModalList conditions_Worlds; + public CachedModalList conditions_Entities; + public CachedModalList conditions_Biomes; + public CachedModalList conditions_ApplyPlugins; + public CachedModalList conditions_CustomNames; + public CachedModalList conditions_NoDropEntities; + public CachedModalList conditions_WGRegions; + public CachedModalList conditions_WGRegionOwners; + public CachedModalList conditions_MM_Names; + public CachedModalList conditions_SpawnerNames; + public CachedModalList conditions_SpawnegEggNames; + public CachedModalList conditions_ScoreboardTags; + public CachedModalList conditions_WorldTickTime; + public CachedModalList vanillaBonuses; + public CachedModalList conditions_SpawnReasons; + public CachedModalList conditions_Permission; + public WithinCoordinates conditions_WithinCoords; + public @Nullable FineTuningAttributes allMobMultipliers; + public Map specificMobMultipliers; public String getRuleName() { return this.ruleName; diff --git a/src/main/java/me/lokka30/levelledmobs/rules/RulesManager.java b/src/main/java/me/lokka30/levelledmobs/rules/RulesManager.java index e32e35529..63c20ad2e 100644 --- a/src/main/java/me/lokka30/levelledmobs/rules/RulesManager.java +++ b/src/main/java/me/lokka30/levelledmobs/rules/RulesManager.java @@ -82,6 +82,13 @@ public boolean getRuleIsWorldAllowedInAnyRule(final @Nullable World world) { return result; } + public void addCustomRule(final @Nullable RuleInfo ri){ + if (ri == null) return; + + main.rulesParsingManager.customRules.add(ri); + main.rulesParsingManager.checkCustomRules(); + } + @NotNull public List getRuleNbtData(final @NotNull LivingEntityWrapper lmEntity) { final List nbtData = new LinkedList<>(); diff --git a/src/main/java/me/lokka30/levelledmobs/rules/RulesParsingManager.java b/src/main/java/me/lokka30/levelledmobs/rules/RulesParsingManager.java index 835aa2707..d832626d2 100644 --- a/src/main/java/me/lokka30/levelledmobs/rules/RulesParsingManager.java +++ b/src/main/java/me/lokka30/levelledmobs/rules/RulesParsingManager.java @@ -93,9 +93,16 @@ public void parseRulesMain(final @Nullable YamlConfiguration config) { || this.defaultRule.conditions_WGRegionOwners != null; this.main.rulesManager.buildBiomeGroupMappings(customBiomeGroups); - final Map ruleMappings = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); this.customRules = parseCustomRules( config.get(ymlHelper.getKeyNameFromConfig(config, "custom-rules"))); + + checkCustomRules(); + autoGenerateWeightedRandom(); + } + + public void checkCustomRules(){ + final Map ruleMappings = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); + for (final RuleInfo ruleInfo : customRules) { if (!this.main.rulesManager.rulesInEffect.containsKey(ruleInfo.rulePriority)) { this.main.rulesManager.rulesInEffect.put(ruleInfo.rulePriority, new LinkedList<>()); @@ -116,8 +123,6 @@ public void parseRulesMain(final @Nullable YamlConfiguration config) { this.main.rulesManager.ruleNameMappings.putAll(ruleMappings); this.main.rulesManager.rulesCooldown.clear(); } - - autoGenerateWeightedRandom(); } public @NotNull List getAllRules() {