Skip to content

Commit

Permalink
Merge branch 'master' into beta3-4.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
PeachesMLG authored May 10, 2024
2 parents f18a6a1 + 38d8617 commit 8c3ac48
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 25 deletions.
5 changes: 3 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group = "com.iridium"
version = "4.0.8"
version = "4.0.9.1"
description = "IridiumSkyblock"

repositories {
Expand All @@ -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")
Expand All @@ -50,6 +50,7 @@ tasks {
archiveClassifier.set("")

// Relocate dependencies
relocate("com.iridium.iridiumcore")
relocate("com.j256.ormlite")
relocate("org.bstats")
relocate("de.jeff_media.updatechecker")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,8 @@
import com.iridium.iridiumteams.missions.Mission;
import com.iridium.iridiumteams.missions.MissionData;
import com.iridium.iridiumteams.missions.MissionType;
import com.iridium.iridiumteams.support.SpawnerSupport;
import com.iridium.iridiumteams.support.StackerSupport;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.Chunk;
import org.bukkit.ChunkSnapshot;
import org.bukkit.OfflinePlayer;
import org.bukkit.Material;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.CreatureSpawner;
Expand Down Expand Up @@ -208,6 +200,11 @@ public List<Island> getTeams() {
return IridiumSkyblock.getInstance().getDatabaseManager().getIslandTableManager().getEntries();
}

@Override
public boolean isInTeam(Island island, Location location) {
return island.isInIsland(location);
}

private CompletableFuture<String> getSchematic(Player player) {
CompletableFuture<String> schematicNameCompletableFuture = new CompletableFuture<>();
if (IridiumSkyblock.getInstance().getSchematics().schematics.entrySet().size() == 1) {
Expand Down Expand Up @@ -575,6 +572,27 @@ public synchronized TeamEnhancement getTeamEnhancement(Island island, String enh
}
}

private HashMap<XMaterial, Integer> getBlockStacks(Chunk chunk, Island island) {
HashMap<XMaterial, Integer> hashMap = new HashMap<>();

for (StackerSupport<Island> stackerSupport : IridiumSkyblock.getInstance().getSupportManager().getStackerSupport()) {
stackerSupport.getBlocksStacked(chunk, island).forEach((key, value) -> hashMap.put(key, hashMap.getOrDefault(key, 0) + value));
}

return hashMap;
}

private CompletableFuture<Integer> getSpawnerStackAmount(CreatureSpawner creatureSpawner) {
CompletableFuture<Integer> 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<Void> recalculateTeam(Island island) {
Map<XMaterial, Integer> teamBlocks = new HashMap<>();
Expand Down Expand Up @@ -618,19 +636,14 @@ public CompletableFuture<Void> recalculateTeam(Island island) {
}
}
}

getSpawners(chunk, island).join().forEach(creatureSpawner ->
teamSpawners.put(creatureSpawner.getSpawnedType(), teamSpawners.getOrDefault(creatureSpawner.getSpawnedType(), 0) + 1)
);

for(StackerSupport stackerSupport : stackerSupportList) {
stackedBlocksList.get(stackerSupport.supportProvider()).addAll(stackerSupport.getBlocksStacked(chunk));
}

for(SpawnerSupport spawnerSupport : spawnerSupportList) {
stackedSpawnersList.get(spawnerSupport.supportProvider()).addAll(spawnerSupport.getSpawnersStacked(chunk));
}

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<TeamBlock> blocks = IridiumSkyblock.getInstance().getDatabaseManager().getTeamBlockTableManager().getEntries(island);
Expand Down Expand Up @@ -808,7 +821,7 @@ public boolean isInTeam(Island island, Location location){
}

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));
}

Expand Down

0 comments on commit 8c3ac48

Please sign in to comment.