diff --git a/build.gradle.kts b/build.gradle.kts index 7cee771..d9f8c04 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -38,10 +38,10 @@ dependencies { compileOnlyApi("dev.lone:api-itemsadder:4.0.2-beta-release-11") compileOnlyApi("net.kyori:adventure-text-serializer-legacy:4.18.0") compileOnlyApi("net.kyori:adventure-platform-bukkit:4.3.4") - compileOnlyApi("beer.devs:FastNbt-jar:1.4.2") + compileOnlyApi("beer.devs:FastNbt-jar:1.4.15") compileOnlyApi("commons-io:commons-io:2.18.0") - implementation("de.tr7zw:item-nbt-api:2.14.1") + implementation("de.tr7zw:item-nbt-api:2.15.3") compileOnly("com.github.MilkBowl:VaultAPI:1.7") { exclude(group = "org.bukkit", module = "bukkit") diff --git a/src/main/java/beer/devs/rpgmoney/Main.java b/src/main/java/beer/devs/rpgmoney/Main.java index 207b0ad..c12ad14 100644 --- a/src/main/java/beer/devs/rpgmoney/Main.java +++ b/src/main/java/beer/devs/rpgmoney/Main.java @@ -172,6 +172,11 @@ private void initConfig() entitiesLootsRegistry = new EntitiesLootsRegistry(this); blocksLootsRegistry = new BlocksLootsRegistry(this); fishesLootsRegistry = new FishesLootsRegistry(this); + + onDisable(); + permissions.clear(); + multipliersDrops.clear(); + multipliersPickup.clear(); ConfigurationSection sec = config.getConfig().getConfigurationSection("multipliers_groups.drop"); if (sec != null) @@ -461,34 +466,41 @@ public static void playPickupMoneySound(Player p) private static float mergeNearMoney(Location location, float money) { - if (Settings.PICKUPS_MERGE) + if (!Settings.PICKUPS_MERGE) + return money; + + Collection nearDrops = location.getWorld().getNearbyEntitiesByType( + Item.class, + location, + Settings.PICKUPS_MERGE_RADIUS, + Settings.PICKUPS_MERGE_RADIUS, + Settings.PICKUPS_MERGE_RADIUS + ); + + int count = 0; + + for (Item drop : nearDrops) { - Collection nearDrops = location.getWorld().getNearbyEntitiesByType(Item.class, - location, - Settings.PICKUPS_MERGE_RADIUS, - Settings.PICKUPS_MERGE_RADIUS, - Settings.PICKUPS_MERGE_RADIUS); - - int count = 0; - for (Item drop : nearDrops) - { - float otherMoney = Main.inst.getMoneyFromPickup(drop.getItemStack()); - if (otherMoney == -1) - continue; - money += otherMoney; - count++; - } + float otherMoney = Main.inst.getMoneyFromPickup(drop.getItemStack()); + if (otherMoney == -1) + continue; - if (count >= Settings.PICKUPS_MERGE_MIN_PICKUPS) - { - nearDrops.forEach(Entity::remove); - return Utils.round(money, 2); + money += otherMoney; + count++; + + // REMOVE the old money entity + drop.remove(); } - } + + // If we merged enough pickups, return merged value + if (count >= Settings.PICKUPS_MERGE_MIN_PICKUPS) + return Utils.round(money, 2); return money; } + + @Nullable public static Item spawnMoney(Entity player, float money, Location location) { diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 87701e1..e93c659 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -8,7 +8,7 @@ depend: softdepend: - ItemsAdder libraries: - - beer.devs:FastNbt-jar:1.4.2 + - beer.devs:FastNbt-jar:1.4.15 - net.kyori:adventure-api:4.18.0 - net.kyori:adventure-text-serializer-gson:4.18.0 - net.kyori:adventure-text-serializer-gson-legacy-impl:4.18.0