diff --git a/build.gradle.kts b/build.gradle.kts index 44236d55f..26e6bb158 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.3.7") + implementation("com.iridium:IridiumTeams:2.4.1") // Other dependencies that are not required or already available at runtime compileOnly("org.projectlombok:lombok:1.18.30") @@ -88,6 +88,9 @@ tasks { // Maven publishing publishing { publications.create("maven") { - from(components["java"]) + setGroupId("com.iridium") + setArtifactId("IridiumSkyblock") + setVersion(version) + artifact(tasks["shadowJar"]) } } diff --git a/src/main/java/com/iridium/iridiumskyblock/api/IridiumSkyblockAPI.java b/src/main/java/com/iridium/iridiumskyblock/api/IridiumSkyblockAPI.java index e0035bb54..0b146866b 100644 --- a/src/main/java/com/iridium/iridiumskyblock/api/IridiumSkyblockAPI.java +++ b/src/main/java/com/iridium/iridiumskyblock/api/IridiumSkyblockAPI.java @@ -24,13 +24,9 @@ */ public class IridiumSkyblockAPI { - private static final IridiumSkyblockAPI instance; + private static IridiumSkyblockAPI instance; private final IridiumSkyblock iridiumSkyblock; - static { - instance = new IridiumSkyblockAPI(IridiumSkyblock.getInstance()); - } - /** * Constructor for api initialization. * @@ -47,7 +43,10 @@ private IridiumSkyblockAPI(@NotNull IridiumSkyblock iridiumSkyblock) { * @return the instance of this api * @since 3.0.0 */ - public static @NotNull IridiumSkyblockAPI getInstance() { + public static @Nullable IridiumSkyblockAPI getInstance() { + if(instance == null && IridiumSkyblock.getInstance() != null) { + instance = new IridiumSkyblockAPI(IridiumSkyblock.getInstance()); + } return instance; } diff --git a/src/main/java/com/iridium/iridiumskyblock/database/Island.java b/src/main/java/com/iridium/iridiumskyblock/database/Island.java index 0ea60025e..a41330930 100644 --- a/src/main/java/com/iridium/iridiumskyblock/database/Island.java +++ b/src/main/java/com/iridium/iridiumskyblock/database/Island.java @@ -15,6 +15,8 @@ import org.jetbrains.annotations.NotNull; import java.time.LocalDateTime; +import java.util.List; +import java.util.Optional; @NoArgsConstructor @Getter @@ -132,11 +134,19 @@ public void setColor(Color color) { @Override public @NotNull String getName() { if (super.getName() != null) return super.getName(); - String ownerName = IridiumSkyblock.getInstance().getTeamManager().getTeamMembers(this).stream() - .filter(user -> user.getUserRank() == Rank.OWNER.getId()) - .findFirst() + String ownerName = getOwner() .map(User::getName) .orElse("N/A"); return IridiumSkyblock.getInstance().getConfiguration().defaultIslandName.replace("%owner%", ownerName); } + + public List getMembers() { + return IridiumSkyblock.getInstance().getTeamManager().getTeamMembers(this); + } + + public Optional getOwner() { + return getMembers().stream() + .filter(user -> user.getUserRank() == Rank.OWNER.getId()) + .findFirst(); + } } diff --git a/src/main/java/com/iridium/iridiumskyblock/managers/IslandManager.java b/src/main/java/com/iridium/iridiumskyblock/managers/IslandManager.java index c58bbef5f..8739f6709 100644 --- a/src/main/java/com/iridium/iridiumskyblock/managers/IslandManager.java +++ b/src/main/java/com/iridium/iridiumskyblock/managers/IslandManager.java @@ -135,7 +135,7 @@ public void setIslandBiome(@NotNull Island island, @NotNull XBiome biome) { World.Environment dimension = biome.getEnvironment(); World world = getWorld(dimension); - if(world == null) return; + if (world == null) return; getIslandChunks(island).thenAccept(chunks -> { Location pos1 = island.getPosition1(world); @@ -221,8 +221,8 @@ public CompletableFuture createTeam(@NotNull Player owner, String name) User user = IridiumSkyblock.getInstance().getUserManager().getUser(owner); Schematics.SchematicConfig schematicConfig = IridiumSkyblock.getInstance().getSchematics().schematics.get(schematic); - if(schematicConfig.regenCost.money != 0 || !schematicConfig.regenCost.bankItems.isEmpty()) { - if(!IridiumSkyblock.getInstance().getSchematicManager().buy(owner, schematicConfig)) { + if (schematicConfig.regenCost.money != 0 || !schematicConfig.regenCost.bankItems.isEmpty()) { + if (!IridiumSkyblock.getInstance().getSchematicManager().buy(owner, schematicConfig)) { return null; } } @@ -536,9 +536,12 @@ public synchronized TeamBlock getTeamBlock(Island island, XMaterial xMaterial) { } @Override - public synchronized TeamSetting getTeamSetting(Island island, String settingKey) { + public synchronized @Nullable TeamSetting getTeamSetting(Island island, String settingKey) { Setting settingConfig = IridiumSkyblock.getInstance().getSettingsList().get(settingKey); - String defaultValue = settingConfig == null ? "" : settingConfig.getDefaultValue(); + if (settingConfig == null) { + return null; + } + String defaultValue = settingConfig.getDefaultValue(); Optional teamSetting = IridiumSkyblock.getInstance().getDatabaseManager().getTeamSettingsTableManager().getEntry(new TeamSetting(island, settingKey, defaultValue)); if (teamSetting.isPresent()) { return teamSetting.get(); @@ -725,21 +728,28 @@ public void deleteTeamReward(TeamReward teamReward) { } public @Nullable World getWorld(World.Environment environment) { + String worldName = getWorldName(environment); + if (worldName == null) return null; + return Bukkit.getWorld(worldName); + } + + public @Nullable String getWorldName(World.Environment environment) { if (!IridiumSkyblock.getInstance().getConfiguration().enabledWorlds.getOrDefault(environment, true)) return null; switch (environment) { case NORMAL: - return Bukkit.getWorld(IridiumSkyblock.getInstance().getConfiguration().worldName); + return IridiumSkyblock.getInstance().getConfiguration().worldName; case NETHER: - return Bukkit.getWorld(IridiumSkyblock.getInstance().getConfiguration().worldName + "_nether"); + return IridiumSkyblock.getInstance().getConfiguration().worldName + "_nether"; case THE_END: - return Bukkit.getWorld(IridiumSkyblock.getInstance().getConfiguration().worldName + "_the_end"); + return IridiumSkyblock.getInstance().getConfiguration().worldName + "_the_end"; } return null; } public boolean isInSkyblockWorld(World world) { - return Objects.equals(world, getWorld(World.Environment.NORMAL)) || Objects.equals(world, getWorld(World.Environment.NETHER)) || Objects.equals(world, getWorld(World.Environment.THE_END)); + 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)); } public void sendIslandBorder(Player player) {