From 675856cb81170f952bccecda510c35f3404741f3 Mon Sep 17 00:00:00 2001 From: Penal Buffalo Date: Mon, 13 Dec 2021 14:49:20 -0600 Subject: [PATCH 1/5] 3.3.1 b583 * fixed issue causing player levelling not to apply to mobs from spawners and spawn eggs. also fixes a rare error * fixed the embedded easy rules.yml having a typo * updated messages.yml to include the mob level when running command /lm rules show_effective * fixed the rules parser so when using a number as a key (entity override levels for example) you won't get a crash * running command /lm spawner create gives it the name LM Spawner again, rather than LM Spawn Egg --- pom.xml | 2 +- .../commands/subcommands/RulesSubcommand.java | 5 +++-- .../commands/subcommands/SpawnerBaseClass.java | 6 +++--- .../commands/subcommands/SpawnerEggCommand.java | 2 +- .../commands/subcommands/SpawnerSubCommand.java | 2 +- .../levelledmobs/listeners/EntitySpawnListener.java | 4 +++- .../levelledmobs/rules/RulesParsingManager.java | 10 +++++++++- src/main/resources/messages.yml | 2 +- src/main/resources/predefined/rules_easy.yml | 2 +- 9 files changed, 23 insertions(+), 12 deletions(-) diff --git a/pom.xml b/pom.xml index 6372f16f8..34654deaf 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ me.lokka30 LevelledMobs - 3.3.0 b581 + 3.3.1 b583 jar LevelledMobs diff --git a/src/main/java/me/lokka30/levelledmobs/commands/subcommands/RulesSubcommand.java b/src/main/java/me/lokka30/levelledmobs/commands/subcommands/RulesSubcommand.java index fd2ada382..5a406618d 100644 --- a/src/main/java/me/lokka30/levelledmobs/commands/subcommands/RulesSubcommand.java +++ b/src/main/java/me/lokka30/levelledmobs/commands/subcommands/RulesSubcommand.java @@ -343,9 +343,10 @@ else if (findNearbyEntities && entities.isEmpty()) lmEntity.getLivingEntity().getLocation().getBlockX(), lmEntity.getLivingEntity().getLocation().getBlockY(), lmEntity.getLivingEntity().getLocation().getBlockZ()); + final String mobLevel = lmEntity.isLevelled() ? lmEntity.getMobLevel() + "" : "0"; final List messages = getMessage("command.levelledmobs.rules.effective-rules", - new String[]{"%mobname%", "%entitytype%", "%location%", "%world%"}, - new String[]{ entityName, lmEntity.getNameIfBaby(), locationStr, lmEntity.getWorldName() } + new String[]{"%mobname%", "%entitytype%", "%location%", "%world%", "%level%"}, + new String[]{ entityName, lmEntity.getNameIfBaby(), locationStr, lmEntity.getWorldName(), mobLevel } ); diff --git a/src/main/java/me/lokka30/levelledmobs/commands/subcommands/SpawnerBaseClass.java b/src/main/java/me/lokka30/levelledmobs/commands/subcommands/SpawnerBaseClass.java index 3fae3499d..1ef19eb07 100644 --- a/src/main/java/me/lokka30/levelledmobs/commands/subcommands/SpawnerBaseClass.java +++ b/src/main/java/me/lokka30/levelledmobs/commands/subcommands/SpawnerBaseClass.java @@ -91,13 +91,13 @@ private String parseFlagValue(final String keyName, final int argNumber, final S return args[argNumber + 1]; } - static void setMetaItems(final @Nullable ItemMeta meta, final @NotNull CustomSpawnerInfo info){ + static void setMetaItems(final @Nullable ItemMeta meta, final @NotNull CustomSpawnerInfo info, final @NotNull String defaultName){ if (meta == null) return; if (VersionUtils.isRunningPaper()) - PaperUtils.updateItemDisplayName(meta, info.customName == null ? "LM Spawn Egg" : info.customName); + PaperUtils.updateItemDisplayName(meta, info.customName == null ? defaultName : info.customName); else - SpigotUtils.updateItemDisplayName(meta, info.customName == null ? "LM Spawn Egg" : info.customName); + SpigotUtils.updateItemDisplayName(meta, info.customName == null ? defaultName : info.customName); List lore = new LinkedList<>(); diff --git a/src/main/java/me/lokka30/levelledmobs/commands/subcommands/SpawnerEggCommand.java b/src/main/java/me/lokka30/levelledmobs/commands/subcommands/SpawnerEggCommand.java index 621fe88d6..7c69bab7b 100644 --- a/src/main/java/me/lokka30/levelledmobs/commands/subcommands/SpawnerEggCommand.java +++ b/src/main/java/me/lokka30/levelledmobs/commands/subcommands/SpawnerEggCommand.java @@ -148,7 +148,7 @@ private void generateEgg(final @NotNull CustomSpawnerInfo info){ final ItemStack item = new ItemStack(material); final ItemMeta meta = item.getItemMeta(); if (meta != null){ - setMetaItems(meta, info); + setMetaItems(meta, info, "LM Spawn Egg"); meta.getPersistentDataContainer().set(info.main.namespaced_keys.spawnerEgg, PersistentDataType.INTEGER, 1); meta.getPersistentDataContainer().set(info.main.namespaced_keys.keySpawner_MinLevel, PersistentDataType.INTEGER, info.minLevel); diff --git a/src/main/java/me/lokka30/levelledmobs/commands/subcommands/SpawnerSubCommand.java b/src/main/java/me/lokka30/levelledmobs/commands/subcommands/SpawnerSubCommand.java index bc21a177d..c4574becb 100644 --- a/src/main/java/me/lokka30/levelledmobs/commands/subcommands/SpawnerSubCommand.java +++ b/src/main/java/me/lokka30/levelledmobs/commands/subcommands/SpawnerSubCommand.java @@ -242,7 +242,7 @@ public void generateSpawner(final @NotNull CustomSpawnerInfo info){ final ItemStack item = new ItemStack(Material.SPAWNER); final ItemMeta meta = item.getItemMeta(); if (meta != null){ - setMetaItems(meta, info); + setMetaItems(meta, info, "LM Spawner"); meta.getPersistentDataContainer().set(info.main.namespaced_keys.keySpawner, PersistentDataType.INTEGER, 1); meta.getPersistentDataContainer().set(info.main.namespaced_keys.keySpawner_MinLevel, PersistentDataType.INTEGER, info.minLevel); diff --git a/src/main/java/me/lokka30/levelledmobs/listeners/EntitySpawnListener.java b/src/main/java/me/lokka30/levelledmobs/listeners/EntitySpawnListener.java index 6e906650f..a5828cd16 100644 --- a/src/main/java/me/lokka30/levelledmobs/listeners/EntitySpawnListener.java +++ b/src/main/java/me/lokka30/levelledmobs/listeners/EntitySpawnListener.java @@ -166,14 +166,16 @@ private LevelledMobSpawnReason adaptVanillaSpawnReason(final CreatureSpawnEvent. return LevelledMobSpawnReason.valueOf(spawnReason.toString()); } - private void delayedAddToQueue(final LivingEntityWrapper lmEntity, final Event event, final int delay){ + private void delayedAddToQueue(final @NotNull LivingEntityWrapper lmEntity, final Event event, final int delay){ final BukkitRunnable runnable = new BukkitRunnable() { @Override public void run() { main._mobsQueueManager.addToQueue(new QueueItem(lmEntity, event)); + lmEntity.free(); } }; + lmEntity.inUseCount.getAndIncrement(); runnable.runTaskLater(main, delay); } diff --git a/src/main/java/me/lokka30/levelledmobs/rules/RulesParsingManager.java b/src/main/java/me/lokka30/levelledmobs/rules/RulesParsingManager.java index 57a56f367..ff39e6571 100644 --- a/src/main/java/me/lokka30/levelledmobs/rules/RulesParsingManager.java +++ b/src/main/java/me/lokka30/levelledmobs/rules/RulesParsingManager.java @@ -26,6 +26,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.EnumMap; +import java.util.HashMap; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; @@ -1052,7 +1053,14 @@ private ConfigurationSection objTo_CS(final ConfigurationSection cs, final Strin return (ConfigurationSection) object; } else if (object instanceof Map) { final MemoryConfiguration result = new MemoryConfiguration(); - result.addDefaults((Map) object); + + // this is to convert any non-string objects + final Map temp = (Map) object; + final Map temp2 = new HashMap<>(temp.size()); + for (final Object obj : temp.keySet()) + temp2.put(obj.toString(), temp.get(obj)); + + result.addDefaults(temp2); return result.getDefaultSection(); } else { final String currentPath = Utils.isNullOrEmpty(cs.getCurrentPath()) ? diff --git a/src/main/resources/messages.yml b/src/main/resources/messages.yml index 6539c9593..ab003be4f 100644 --- a/src/main/resources/messages.yml +++ b/src/main/resources/messages.yml @@ -282,7 +282,7 @@ command: no-entities-near: - '%prefix% No entities were found within a 10 block radius' effective-rules: - - '%prefix% Showing effective rules for: %entitytype% (%mobname%) in %world%, %location%' + - '%prefix% Showing effective rules for: %entitytype% (lvl %level% %mobname%) in %world%, %location%' no-effective-rules: - '%prefix% No effective rules were found' diff --git a/src/main/resources/predefined/rules_easy.yml b/src/main/resources/predefined/rules_easy.yml index ae8c40674..89cad9ac8 100644 --- a/src/main/resources/predefined/rules_easy.yml +++ b/src/main/resources/predefined/rules_easy.yml @@ -328,7 +328,7 @@ default-rule: # - nametag_using_indicator # - hard_difficulty # - normal_difficulty - - easy_difficulty + - easy_difficulty # - apply_LevellingVariance # - weighted_random_hard # - weighted_random_normal From 95dc3caf98f2f1c9cde2f8706070ad3607294d8c Mon Sep 17 00:00:00 2001 From: Penal Buffalo Date: Mon, 13 Dec 2021 20:45:19 -0600 Subject: [PATCH 2/5] 3.3.1 b584 * fixed player levelling not respecting the match-level option --- pom.xml | 2 +- .../java/me/lokka30/levelledmobs/managers/LevelManager.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 34654deaf..ea596d48d 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ me.lokka30 LevelledMobs - 3.3.1 b583 + 3.3.1 b584 jar LevelledMobs diff --git a/src/main/java/me/lokka30/levelledmobs/managers/LevelManager.java b/src/main/java/me/lokka30/levelledmobs/managers/LevelManager.java index 8461ca963..c5b6fbfef 100644 --- a/src/main/java/me/lokka30/levelledmobs/managers/LevelManager.java +++ b/src/main/java/me/lokka30/levelledmobs/managers/LevelManager.java @@ -213,7 +213,7 @@ private int generateRandomLevel(RandomLevellingStrategy randomLevelling, final i int levelSource; final String variableToUse = Utils.isNullOrEmpty(options.variable) ? "%level%" : options.variable; final double scale = options.playerLevelScale != null ? options.playerLevelScale : 1.0; - final boolean usePlayerMax = options.usePlayerMaxLevel != null && options.matchPlayerLevel; + final boolean usePlayerMax = options.usePlayerMaxLevel != null && options.usePlayerMaxLevel; final boolean matchPlayerLvl = options.matchPlayerLevel != null && options.matchPlayerLevel; final PlayerLevelSourceResult playerLevelSourceResult = getPlayerLevelSourceNumber(lmEntity.getPlayerForLevelling(), variableToUse); final double origLevelSource = playerLevelSourceResult.isNumericResult ? playerLevelSourceResult.numericResult : 1; From 080079a77c1e6fa07745e3e362cc5dd6b2506aae Mon Sep 17 00:00:00 2001 From: Penal Buffalo Date: Mon, 13 Dec 2021 23:59:13 -0600 Subject: [PATCH 3/5] 3.3.1 b585 * fixed timing issue resulting in inconsistent levelling with mobs from spawners and spawn eggs --- pom.xml | 2 +- .../java/me/lokka30/levelledmobs/managers/LevelManager.java | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ea596d48d..0d5631dbd 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ me.lokka30 LevelledMobs - 3.3.1 b584 + 3.3.1 b585 jar LevelledMobs diff --git a/src/main/java/me/lokka30/levelledmobs/managers/LevelManager.java b/src/main/java/me/lokka30/levelledmobs/managers/LevelManager.java index c5b6fbfef..1df1aedfa 100644 --- a/src/main/java/me/lokka30/levelledmobs/managers/LevelManager.java +++ b/src/main/java/me/lokka30/levelledmobs/managers/LevelManager.java @@ -790,6 +790,8 @@ private void runNametagCheck_aSync(final @NotNull Map> entit // Mob must be a livingentity that is ...living. if (!(entity instanceof LivingEntity) || entity instanceof Player || !entity.isValid()) continue; + // this is mostly so for spawner mobs and spawner egg mobs as they have a 20 tick delay in before proessing + if (entity.getTicksLived() < 30) continue; boolean wrapperHasReference = false; final LivingEntityWrapper lmEntity = LivingEntityWrapper.getInstance((LivingEntity) entity, main); From 6dd7962c2167ff85c8dc44c83c8a1266027915ac Mon Sep 17 00:00:00 2001 From: Penal Buffalo Date: Wed, 15 Dec 2021 22:44:44 -0600 Subject: [PATCH 4/5] 3.3.1 b586 * fixed command /lm rules show_effective only showing a few rules * fixed player levelling option decrease-level not following specified rules --- pom.xml | 2 +- .../commands/subcommands/RulesSubcommand.java | 3 ++- .../levelledmobs/listeners/EntitySpawnListener.java | 8 +++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 0d5631dbd..6b0f72b15 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ me.lokka30 LevelledMobs - 3.3.1 b585 + 3.3.1 b586 jar LevelledMobs diff --git a/src/main/java/me/lokka30/levelledmobs/commands/subcommands/RulesSubcommand.java b/src/main/java/me/lokka30/levelledmobs/commands/subcommands/RulesSubcommand.java index 5a406618d..a6c3c42a5 100644 --- a/src/main/java/me/lokka30/levelledmobs/commands/subcommands/RulesSubcommand.java +++ b/src/main/java/me/lokka30/levelledmobs/commands/subcommands/RulesSubcommand.java @@ -408,7 +408,8 @@ private void showEffectiveValues(final CommandSender sender, final @NotNull Livi final RuleInfo pi = effectiveRules.get(i); for (final Field f : pi.getClass().getDeclaredFields()) { - if (!Modifier.isPublic(f.getModifiers())) continue; + if (Modifier.isPrivate(f.getModifiers())) continue; + f.setAccessible(true); if (f.get(pi) == null) continue; if (printedKeys.contains(f.getName())) continue; if (f.getName().equals("ruleSourceNames")) continue; diff --git a/src/main/java/me/lokka30/levelledmobs/listeners/EntitySpawnListener.java b/src/main/java/me/lokka30/levelledmobs/listeners/EntitySpawnListener.java index a5828cd16..5b24184a1 100644 --- a/src/main/java/me/lokka30/levelledmobs/listeners/EntitySpawnListener.java +++ b/src/main/java/me/lokka30/levelledmobs/listeners/EntitySpawnListener.java @@ -325,7 +325,7 @@ else if (lmEntity.isBabyMob()) { } private static boolean shouldDenyLevel(final @NotNull LivingEntityWrapper lmEntity, final int levelAssignment){ - final boolean result = + boolean result = lmEntity.reEvaluateLevel && !lmEntity.isRulesForceAll && lmEntity.playerLevellingAllowDecrease != null && @@ -333,6 +333,12 @@ private static boolean shouldDenyLevel(final @NotNull LivingEntityWrapper lmEnti lmEntity.isLevelled() && levelAssignment < lmEntity.getMobLevel(); + if (result){ + synchronized (lmEntity.getLivingEntity().getPersistentDataContainer()) { + result = lmEntity.getPDC().has(lmEntity.getMainInstance().namespaced_keys.playerLevelling_Id, PersistentDataType.STRING); + } + } + if (!result && lmEntity.pendingPlayerIdToSet != null) { synchronized (lmEntity.getLivingEntity().getPersistentDataContainer()) { lmEntity.getPDC().set(lmEntity.getMainInstance().namespaced_keys.playerLevelling_Id, PersistentDataType.STRING, lmEntity.pendingPlayerIdToSet); From bba70aed8547b822f987fc20aa80fbdadb15a7f7 Mon Sep 17 00:00:00 2001 From: Penal Buffalo Date: Thu, 16 Dec 2021 12:48:34 -0600 Subject: [PATCH 5/5] 3.3.1 b587 * small code cleanup --- pom.xml | 2 +- .../me/lokka30/levelledmobs/Companion.java | 12 ------- .../me/lokka30/levelledmobs/LevelledMobs.java | 1 - .../subcommands/SummonSubcommand.java | 2 +- .../compatibility/Compat1_17.java | 6 ++++ .../customdrops/CustomDropItem.java | 3 +- .../customdrops/CustomDropResult.java | 3 +- .../customdrops/CustomDropsDefaults.java | 1 - .../customdrops/CustomDropsParser.java | 1 - .../levelledmobs/managers/LevelManager.java | 36 +++++++++++-------- .../misc/CustomUniversalGroups.java | 1 - .../levelledmobs/misc/LevellableState.java | 19 ---------- .../misc/LivingEntityPlaceHolder.java | 4 --- .../rules/FineTuningAttributes.java | 2 -- .../rules/RulesParsingManager.java | 1 - 15 files changed, 31 insertions(+), 63 deletions(-) diff --git a/pom.xml b/pom.xml index 6b0f72b15..dcebb06cd 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ me.lokka30 LevelledMobs - 3.3.1 b586 + 3.3.1 b587 jar LevelledMobs diff --git a/src/main/java/me/lokka30/levelledmobs/Companion.java b/src/main/java/me/lokka30/levelledmobs/Companion.java index a02e9a073..cbe76c8be 100644 --- a/src/main/java/me/lokka30/levelledmobs/Companion.java +++ b/src/main/java/me/lokka30/levelledmobs/Companion.java @@ -289,18 +289,6 @@ void registerCommands() { levelledMobsCommand.setExecutor(main.levelledMobsCommand); } - void loadSpigotConfig(){ - try { - main.levelManager.attributeMaxHealthMax = Bukkit.getServer().spigot().getConfig().getDouble("settings.attribute.maxHealth.max", 2048.0); - main.levelManager.attributeMovementSpeedMax = Bukkit.getServer().spigot().getConfig().getDouble("settings.attribute.movementSpeed.max", 2048.0); - main.levelManager.attributeAttackDamageMax = Bukkit.getServer().spigot().getConfig().getDouble("settings.attribute.attackDamage.max", 2048.0); - } catch (final NoSuchMethodError ignored) { - main.levelManager.attributeMaxHealthMax = Integer.MAX_VALUE; - main.levelManager.attributeMovementSpeedMax = Integer.MAX_VALUE; - main.levelManager.attributeAttackDamageMax = Integer.MAX_VALUE; - } - } - void setupMetrics() { final Metrics metrics = new Metrics(main, 6269); diff --git a/src/main/java/me/lokka30/levelledmobs/LevelledMobs.java b/src/main/java/me/lokka30/levelledmobs/LevelledMobs.java index e890683a2..b5dfbce56 100644 --- a/src/main/java/me/lokka30/levelledmobs/LevelledMobs.java +++ b/src/main/java/me/lokka30/levelledmobs/LevelledMobs.java @@ -110,7 +110,6 @@ public void onEnable() { } companion.registerListeners(); companion.registerCommands(); - companion.loadSpigotConfig(); Utils.logger.info("&fStart-up: &7Running misc procedures..."); if (ExternalCompatibilityManager.hasProtocolLibInstalled()) { diff --git a/src/main/java/me/lokka30/levelledmobs/commands/subcommands/SummonSubcommand.java b/src/main/java/me/lokka30/levelledmobs/commands/subcommands/SummonSubcommand.java index 35667b0d3..27e8b5520 100644 --- a/src/main/java/me/lokka30/levelledmobs/commands/subcommands/SummonSubcommand.java +++ b/src/main/java/me/lokka30/levelledmobs/commands/subcommands/SummonSubcommand.java @@ -373,7 +373,7 @@ private void summonMobs(@NotNull final SummonMobOptions options) { final Player target = options.player; Location location = options.lmPlaceHolder.getLocation(); - if (main.levelManager.FORCED_BLOCKED_ENTITY_TYPES.contains(options.lmPlaceHolder.getTypeName())) { + if (main.levelManager.FORCED_BLOCKED_ENTITY_TYPES.contains(options.lmPlaceHolder.getEntityType())) { List messages = main.messagesCfg.getStringList("command.levelledmobs.summon.not-levellable"); messages = Utils.replaceAllInList(messages, "%prefix%", main.configUtils.getPrefix()); messages = Utils.replaceAllInList(messages, "%entity%", options.lmPlaceHolder.getTypeName()); diff --git a/src/main/java/me/lokka30/levelledmobs/compatibility/Compat1_17.java b/src/main/java/me/lokka30/levelledmobs/compatibility/Compat1_17.java index 5ea7f42be..496607a8a 100644 --- a/src/main/java/me/lokka30/levelledmobs/compatibility/Compat1_17.java +++ b/src/main/java/me/lokka30/levelledmobs/compatibility/Compat1_17.java @@ -6,7 +6,9 @@ import org.bukkit.entity.EntityType; +import java.util.Collection; import java.util.HashSet; +import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -26,4 +28,8 @@ public static HashSet getPassiveMobs() { EntityType.GOAT ).collect(Collectors.toCollection(HashSet::new)); } + + public static Collection getForceBlockedEntityType(){ + return List.of(EntityType.GLOW_ITEM_FRAME, EntityType.MARKER); + } } diff --git a/src/main/java/me/lokka30/levelledmobs/customdrops/CustomDropItem.java b/src/main/java/me/lokka30/levelledmobs/customdrops/CustomDropItem.java index 082c667d7..4c7f550eb 100644 --- a/src/main/java/me/lokka30/levelledmobs/customdrops/CustomDropItem.java +++ b/src/main/java/me/lokka30/levelledmobs/customdrops/CustomDropItem.java @@ -27,7 +27,6 @@ public class CustomDropItem extends CustomDropBase { boolean onlyDropIfEquipped; public String customName; public String mobHeadTexture; - String nbtData; public List lore; List itemFlags; private boolean hasDamageRange; @@ -40,7 +39,7 @@ public class CustomDropItem extends CustomDropBase { CustomDropItem(@NotNull final CustomDropsDefaults defaults) { super(defaults); - if (!Utils.isNullOrEmpty(defaults.damage)) this.setDamageRangeFromString(defaults.damage); + this.customModelDataId = defaults.customModelData; this.chance = defaults.chance; this.maxLevel = defaults.maxLevel; diff --git a/src/main/java/me/lokka30/levelledmobs/customdrops/CustomDropResult.java b/src/main/java/me/lokka30/levelledmobs/customdrops/CustomDropResult.java index cbfeaeca7..7eb423306 100644 --- a/src/main/java/me/lokka30/levelledmobs/customdrops/CustomDropResult.java +++ b/src/main/java/me/lokka30/levelledmobs/customdrops/CustomDropResult.java @@ -13,6 +13,5 @@ */ public enum CustomDropResult { HAS_OVERRIDE, - NO_OVERRIDE, - HAS_OVERALL_CHANCE + NO_OVERRIDE } diff --git a/src/main/java/me/lokka30/levelledmobs/customdrops/CustomDropsDefaults.java b/src/main/java/me/lokka30/levelledmobs/customdrops/CustomDropsDefaults.java index 42f29b322..9cd5f244e 100644 --- a/src/main/java/me/lokka30/levelledmobs/customdrops/CustomDropsDefaults.java +++ b/src/main/java/me/lokka30/levelledmobs/customdrops/CustomDropsDefaults.java @@ -36,7 +36,6 @@ class CustomDropsDefaults { float equippedSpawnChance; Float overallChance; String groupId; - public String damage; String playerLevelVariable; public final List permissions; final List overallPermissions; diff --git a/src/main/java/me/lokka30/levelledmobs/customdrops/CustomDropsParser.java b/src/main/java/me/lokka30/levelledmobs/customdrops/CustomDropsParser.java index bb43a0858..c18a498cb 100644 --- a/src/main/java/me/lokka30/levelledmobs/customdrops/CustomDropsParser.java +++ b/src/main/java/me/lokka30/levelledmobs/customdrops/CustomDropsParser.java @@ -434,7 +434,6 @@ else if (singleCommand != null) Utils.logger.warning("custom drop " + item.getMaterial().toString() + " for " + dropInstance.getMobOrGroupName() + " has invalid NBT data: " + result.exceptionMessage); else { item.setItemStack(result.itemStack); - item.nbtData = nbtStuff; this.dropsUtilizeNBTAPI = true; } } else if (!hasMentionedNBTAPI_Missing) { diff --git a/src/main/java/me/lokka30/levelledmobs/managers/LevelManager.java b/src/main/java/me/lokka30/levelledmobs/managers/LevelManager.java index 1df1aedfa..00c510f1c 100644 --- a/src/main/java/me/lokka30/levelledmobs/managers/LevelManager.java +++ b/src/main/java/me/lokka30/levelledmobs/managers/LevelManager.java @@ -7,6 +7,7 @@ import me.lokka30.levelledmobs.LevelInterface; import me.lokka30.levelledmobs.LevelledMobs; import me.lokka30.levelledmobs.LivingEntityInterface; +import me.lokka30.levelledmobs.compatibility.Compat1_17; import me.lokka30.levelledmobs.customdrops.CustomDropResult; import me.lokka30.levelledmobs.events.MobPostLevelEvent; import me.lokka30.levelledmobs.events.MobPreLevelEvent; @@ -35,6 +36,7 @@ import me.lokka30.levelledmobs.rules.strategies.SpawnDistanceStrategy; import me.lokka30.levelledmobs.rules.strategies.YDistanceStrategy; import me.lokka30.microlib.messaging.MessageUtils; +import me.lokka30.microlib.other.VersionUtils; import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Location; @@ -45,6 +47,7 @@ import org.bukkit.entity.ChestedHorse; import org.bukkit.entity.Creeper; import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; import org.bukkit.entity.Horse; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -97,13 +100,26 @@ public LevelManager(final LevelledMobs main) { Material.GOLDEN_HORSE_ARMOR, Material.DIAMOND_HORSE_ARMOR ); + + this.FORCED_BLOCKED_ENTITY_TYPES = new HashSet<>(Arrays.asList( + EntityType.AREA_EFFECT_CLOUD, EntityType.ARMOR_STAND, EntityType.ARROW, EntityType.BOAT, + EntityType.DRAGON_FIREBALL, EntityType.DROPPED_ITEM, EntityType.EGG, EntityType.ENDER_CRYSTAL, + EntityType.ENDER_PEARL, EntityType.ENDER_SIGNAL, EntityType.EXPERIENCE_ORB, EntityType.FALLING_BLOCK, + EntityType.FIREBALL, EntityType.FIREWORK, EntityType.FISHING_HOOK, + EntityType.ITEM_FRAME, EntityType.LEASH_HITCH, EntityType.LIGHTNING, EntityType.LLAMA_SPIT, + EntityType.MINECART, EntityType.MINECART_CHEST, EntityType.MINECART_COMMAND, EntityType.MINECART_FURNACE, + EntityType.MINECART_HOPPER, EntityType.MINECART_MOB_SPAWNER, EntityType.MINECART_TNT, EntityType.PAINTING, + EntityType.PRIMED_TNT, EntityType.SMALL_FIREBALL, EntityType.SNOWBALL, EntityType.SPECTRAL_ARROW, + EntityType.SPLASH_POTION, EntityType.THROWN_EXP_BOTTLE,EntityType.TRIDENT, EntityType.UNKNOWN, + EntityType.WITHER_SKULL, EntityType.SHULKER_BULLET, EntityType.PLAYER + )); + if (VersionUtils.isOneSeventeen()) + this.FORCED_BLOCKED_ENTITY_TYPES.addAll(Compat1_17.getForceBlockedEntityType()); + } private final LevelledMobs main; private final List vehicleNoMultiplierItems; - public double attributeMaxHealthMax = 2048.0; - public double attributeMovementSpeedMax = 2048.0; - public double attributeAttackDamageMax = 2048.0; public final Map summonedOrSpawnEggs; public static final Object summonedOrSpawnEggs_Lock = new Object(); private boolean hasMentionedNBTAPI_Missing; @@ -112,18 +128,8 @@ public LevelManager(final LevelledMobs main) { /** * The following entity types *MUST NOT* be levellable. - * Stored as Strings since older versions may not contain certain entity type constants */ - public final HashSet FORCED_BLOCKED_ENTITY_TYPES = new HashSet<>(Arrays.asList( - "AREA_EFFECT_CLOUD", "ARMOR_STAND", "ARROW", "BOAT", "DRAGON_FIREBALL", "DROPPED_ITEM", - "EGG", "ENDER_CRYSTAL", "ENDER_PEARL", "ENDER_SIGNAL", "EXPERIENCE_ORB", - "FALLING_BLOCK", "FIREBALL", "FIREWORK", "FISHING_HOOK", "GLOW_ITEM_FRAME", - "ITEM_FRAME", "LEASH_HITCH", "LIGHTNING", "LLAMA_SPIT", "MARKER", "MINECART", - "MINECART_CHEST", "MINECART_COMMAND", "MINECART_FURNACE", "MINECART_HOPPER", - "MINECART_MOB_SPAWNER", "MINECART_TNT", "NPC", "PAINTING", "PLAYER", "PRIMED_TNT", - "SMALL_FIREBALL", "SNOWBALL", "SPECTRAL_ARROW", "SPLASH_POTION", "THROWN_EXP_BOTTLE", - "TRIDENT", "UNKNOWN", "WITHER_SKULL" - )); + public final HashSet FORCED_BLOCKED_ENTITY_TYPES; public void clearRandomLevellingCache(){ this.randomLevellingCache.clear(); @@ -1096,7 +1102,7 @@ public LevellableState getLevellableState(@NotNull final LivingEntityInterface l This is also ran in getLevellableState(EntityType), however it is important that this is ensured before all other checks are made. */ - if (FORCED_BLOCKED_ENTITY_TYPES.contains(lmInterface.getTypeName())) + if (FORCED_BLOCKED_ENTITY_TYPES.contains(lmInterface.getEntityType())) return LevellableState.DENIED_FORCE_BLOCKED_ENTITY_TYPE; if (lmInterface.getApplicableRules().isEmpty()) diff --git a/src/main/java/me/lokka30/levelledmobs/misc/CustomUniversalGroups.java b/src/main/java/me/lokka30/levelledmobs/misc/CustomUniversalGroups.java index ae9b19115..19e84bd8e 100644 --- a/src/main/java/me/lokka30/levelledmobs/misc/CustomUniversalGroups.java +++ b/src/main/java/me/lokka30/levelledmobs/misc/CustomUniversalGroups.java @@ -12,7 +12,6 @@ * @since 2.6.0 */ public enum CustomUniversalGroups { - NOT_APPLICABLE, ALL_MOBS, ALL_LEVELLABLE_MOBS, ALL_HOSTILE_MOBS, diff --git a/src/main/java/me/lokka30/levelledmobs/misc/LevellableState.java b/src/main/java/me/lokka30/levelledmobs/misc/LevellableState.java index f92034981..8f2cc3f32 100644 --- a/src/main/java/me/lokka30/levelledmobs/misc/LevellableState.java +++ b/src/main/java/me/lokka30/levelledmobs/misc/LevellableState.java @@ -27,25 +27,12 @@ public enum LevellableState { */ DENIED_FORCE_BLOCKED_ENTITY_TYPE, - /** - * settings.yml has been configured to block mobs - * spawning in entity's world from being levelled - */ - DENIED_CONFIGURATION_BLOCKED_WORLD, - /** * settings.yml has been configured to block mobs * of such entity type from being levelled */ DENIED_CONFIGURATION_BLOCKED_ENTITY_TYPE, - /** - * settings.yml has been configured to block mobs - * that spawn with a specific SpawnReason through - * CreatureSpawnEvent. - */ - DENIED_CONFIGURATION_BLOCKED_SPAWN_REASON, - /** * settings.yml has been configured to block * DangerousCaves mobs from being levelled. @@ -94,12 +81,6 @@ public enum LevellableState { */ DENIED_CONFIGURATION_COMPATIBILITY_SIMPLEPETS, - /** - * WorldGuard region flag states that - * mobs are not levellable in its region - */ - DENIED_CONFIGURATION_COMPATIBILITY_WORLD_GUARD, - /** * A rule has been configured to block * nametagged mobs from being levelled. diff --git a/src/main/java/me/lokka30/levelledmobs/misc/LivingEntityPlaceHolder.java b/src/main/java/me/lokka30/levelledmobs/misc/LivingEntityPlaceHolder.java index 961fe6796..1170fb76a 100644 --- a/src/main/java/me/lokka30/levelledmobs/misc/LivingEntityPlaceHolder.java +++ b/src/main/java/me/lokka30/levelledmobs/misc/LivingEntityPlaceHolder.java @@ -95,10 +95,6 @@ public EntityType getEntityType() { return main.rulesManager.getApplicableRules(this).allApplicableRules; } - public ApplicableRulesResult getRules(){ - return main.rulesManager.getApplicableRules(this); - } - @NotNull public String getTypeName(){ return this.entityType.name(); diff --git a/src/main/java/me/lokka30/levelledmobs/rules/FineTuningAttributes.java b/src/main/java/me/lokka30/levelledmobs/rules/FineTuningAttributes.java index 18062daea..c59e6c055 100644 --- a/src/main/java/me/lokka30/levelledmobs/rules/FineTuningAttributes.java +++ b/src/main/java/me/lokka30/levelledmobs/rules/FineTuningAttributes.java @@ -17,8 +17,6 @@ * @since 3.0.0 */ public class FineTuningAttributes implements Cloneable { - EntityType applicableEntity; - public Double attackDamage; public Double creeperExplosionRadius; public Double maxHealth; diff --git a/src/main/java/me/lokka30/levelledmobs/rules/RulesParsingManager.java b/src/main/java/me/lokka30/levelledmobs/rules/RulesParsingManager.java index ff39e6571..6c68d9e8d 100644 --- a/src/main/java/me/lokka30/levelledmobs/rules/RulesParsingManager.java +++ b/src/main/java/me/lokka30/levelledmobs/rules/RulesParsingManager.java @@ -1004,7 +1004,6 @@ private void parseFineTuning(final ConfigurationSection cs){ final FineTuningAttributes attribs = parseFineTuningValues(objTo_CS(cs_Custom, mobName)); if (attribs == null) continue; - attribs.applicableEntity = entityType; fineTuning.put(mobName, attribs); }