From c72c52bbbc097617fc5904a0109d1c83bb1fcbff Mon Sep 17 00:00:00 2001 From: Peaches_MLG Date: Mon, 6 May 2024 16:28:14 +0100 Subject: [PATCH 1/2] Version Increment --- build.gradle.kts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index f0492f991..8d8444c0d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,7 +5,7 @@ plugins { } group = "com.iridium" -version = "4.0.8" +version = "4.0.9.1" description = "IridiumSkyblock" repositories { @@ -51,6 +51,7 @@ tasks { archiveClassifier.set("") // Relocate dependencies + relocate("com.iridium.iridiumcore") relocate("com.j256.ormlite") relocate("org.bstats") relocate("de.jeff_media.updatechecker") From 38d86177abd9090e28a1a4dac937faaf250fcf4d Mon Sep 17 00:00:00 2001 From: Peaches_MLG Date: Tue, 7 May 2024 21:21:02 +0100 Subject: [PATCH 2/2] Spawner stacker implementation (#841) * Implemented Stacker Support * . * Second Implementation * Bump Teams --- build.gradle.kts | 2 +- .../iridiumskyblock/IridiumSkyblock.java | 6 +++ .../managers/IslandManager.java | 41 ++++++++++++++++--- src/main/resources/plugin.yml | 1 + 4 files changed, 44 insertions(+), 6 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 8d8444c0d..b5fdd7b96 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -23,7 +23,7 @@ dependencies { implementation("org.jetbrains:annotations:24.1.0") implementation("com.j256.ormlite:ormlite-core:6.1") implementation("com.j256.ormlite:ormlite-jdbc:6.1") - implementation("com.iridium:IridiumTeams:2.4.2") + implementation("com.iridium:IridiumTeams:2.4.4") // Other dependencies that are not required or already available at runtime compileOnly("org.projectlombok:lombok:1.18.32") diff --git a/src/main/java/com/iridium/iridiumskyblock/IridiumSkyblock.java b/src/main/java/com/iridium/iridiumskyblock/IridiumSkyblock.java index 0f6dd096e..b70f11258 100644 --- a/src/main/java/com/iridium/iridiumskyblock/IridiumSkyblock.java +++ b/src/main/java/com/iridium/iridiumskyblock/IridiumSkyblock.java @@ -13,6 +13,7 @@ import com.iridium.iridiumteams.IridiumTeams; import com.iridium.iridiumteams.managers.MissionManager; import com.iridium.iridiumteams.managers.ShopManager; +import com.iridium.iridiumteams.managers.SupportManager; import lombok.Getter; import net.milkbowl.vault.economy.Economy; import org.bukkit.Bukkit; @@ -62,6 +63,7 @@ public class IridiumSkyblock extends IridiumTeams { private SchematicManager schematicManager; private ShopManager shopManager; private BiomeManager biomeManager; + private SupportManager supportManager; private Economy economy; @@ -99,6 +101,10 @@ public void onEnable() { this.missionManager = new MissionManager<>(this); this.shopManager = new ShopManager<>(this); this.biomeManager = new BiomeManager(); + this.supportManager = new SupportManager<>(this); + + supportManager.registerSupport(); + try { databaseManager.init(); } catch (SQLException exception) { diff --git a/src/main/java/com/iridium/iridiumskyblock/managers/IslandManager.java b/src/main/java/com/iridium/iridiumskyblock/managers/IslandManager.java index 7509bd780..051dbd6ac 100644 --- a/src/main/java/com/iridium/iridiumskyblock/managers/IslandManager.java +++ b/src/main/java/com/iridium/iridiumskyblock/managers/IslandManager.java @@ -25,6 +25,7 @@ import com.iridium.iridiumteams.missions.Mission; import com.iridium.iridiumteams.missions.MissionData; import com.iridium.iridiumteams.missions.MissionType; +import com.iridium.iridiumteams.support.StackerSupport; import org.bukkit.*; import org.bukkit.block.Block; import org.bukkit.block.BlockState; @@ -40,7 +41,6 @@ import org.jetbrains.annotations.Nullable; import java.io.File; -import java.io.IOException; import java.time.LocalDateTime; import java.util.*; import java.util.concurrent.CompletableFuture; @@ -152,6 +152,11 @@ public List getTeams() { return IridiumSkyblock.getInstance().getDatabaseManager().getIslandTableManager().getEntries(); } + @Override + public boolean isInTeam(Island island, Location location) { + return island.isInIsland(location); + } + private CompletableFuture getSchematic(Player player) { CompletableFuture schematicNameCompletableFuture = new CompletableFuture<>(); if (IridiumSkyblock.getInstance().getSchematics().schematics.entrySet().size() == 1) { @@ -459,6 +464,27 @@ public synchronized TeamEnhancement getTeamEnhancement(Island island, String enh } } + private HashMap getBlockStacks(Chunk chunk, Island island) { + HashMap hashMap = new HashMap<>(); + + for (StackerSupport stackerSupport : IridiumSkyblock.getInstance().getSupportManager().getStackerSupport()) { + stackerSupport.getBlocksStacked(chunk, island).forEach((key, value) -> hashMap.put(key, hashMap.getOrDefault(key, 0) + value)); + } + + return hashMap; + } + + private CompletableFuture getSpawnerStackAmount(CreatureSpawner creatureSpawner) { + CompletableFuture completableFuture = new CompletableFuture<>(); + Bukkit.getScheduler().runTask(IridiumSkyblock.getInstance(), () -> { + completableFuture.complete(IridiumSkyblock.getInstance().getSupportManager().getSpawnerSupport().stream() + .mapToInt(stackerSupport -> stackerSupport.getStackAmount(creatureSpawner)) + .max() + .orElse(1)); + }); + return completableFuture; + } + @Override public CompletableFuture recalculateTeam(Island island) { Map teamBlocks = new HashMap<>(); @@ -478,9 +504,14 @@ public CompletableFuture recalculateTeam(Island island) { } } } - getSpawners(chunk, island).join().forEach(creatureSpawner -> - teamSpawners.put(creatureSpawner.getSpawnedType(), teamSpawners.getOrDefault(creatureSpawner.getSpawnedType(), 0) + 1) - ); + getBlockStacks(chunk, island).forEach((key, value) -> { + teamBlocks.put(key, teamBlocks.getOrDefault(key, 0) + value); + }); + + getSpawners(chunk, island).join().forEach(creatureSpawner -> { + int amount = getSpawnerStackAmount(creatureSpawner).join(); + teamSpawners.put(creatureSpawner.getSpawnedType(), teamSpawners.getOrDefault(creatureSpawner.getSpawnedType(), 0) + amount); + }); } }).thenRun(() -> Bukkit.getScheduler().runTask(IridiumSkyblock.getInstance(), () -> { List blocks = IridiumSkyblock.getInstance().getDatabaseManager().getTeamBlockTableManager().getEntries(island); @@ -643,7 +674,7 @@ public void deleteTeamReward(TeamReward teamReward) { } public boolean isInSkyblockWorld(World world) { - if(world == null) return false; + if (world == null) return false; return world.getName().equals(getWorldName(World.Environment.NORMAL)) || world.getName().equals(getWorldName(World.Environment.NETHER)) || world.getName().equals(getWorldName(World.Environment.THE_END)); } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 5777b667d..7ca14cebe 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -12,6 +12,7 @@ softdepend: - "EssentialsSpawn" - "RoseStacker" - "WorldEdit" + - "ObsidianStacker" loadbefore: - "Multiverse-Core" commands: