diff --git a/README.md b/README.md index e8d6a1a08..ef4ad673f 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Every aspect of the plugin has been carefully crafted to suit the server's needs ## Getting Started -Download the plugin from [Spigot](https://www.spigotmc.org/resources/iridium-skyblock-1-13-1-19.62480/), download builds from our [Github](https://github.com/Iridium-Development/IridiumSkyblock/releases), or compile it yourself. +Download the plugin from [Spigot](https://www.spigotmc.org/resources/iridium-skyblock-1-13-1-19.62480/), [Modrinth](https://modrinth.com/plugin/iridiumskyblock), [Hangar](https://hangar.papermc.io/IridiumDevelopment/IridiumSkyblock), [Github Releases](https://github.com/Iridium-Development/IridiumSkyblock/releases), or compile it yourself. Once you have a copy of the plugin (it should be a ``.jar`` file), simply place it in the ``server/plugins`` folder. diff --git a/build.gradle.kts b/build.gradle.kts index 26e6bb158..b5fdd7b96 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 { @@ -23,17 +23,17 @@ 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.1") + implementation("com.iridium:IridiumTeams:2.4.4") // Other dependencies that are not required or already available at runtime - compileOnly("org.projectlombok:lombok:1.18.30") - compileOnly("org.spigotmc:spigot-api:1.20.4-R0.1-SNAPSHOT") + compileOnly("org.projectlombok:lombok:1.18.32") + compileOnly("org.spigotmc:spigot-api:1.20.6-R0.1-SNAPSHOT") compileOnly("com.github.MilkBowl:VaultAPI:1.7.1") compileOnly("net.ess3:EssentialsXSpawn:2.16.1") compileOnly("com.sk89q.worldedit:worldedit-bukkit:7.2.13-SNAPSHOT") // Enable lombok annotation processing - annotationProcessor("org.projectlombok:lombok:1.18.30") + annotationProcessor("org.projectlombok:lombok:1.18.32") } tasks { @@ -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") 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/database/Island.java b/src/main/java/com/iridium/iridiumskyblock/database/Island.java index a41330930..e8ac4374c 100644 --- a/src/main/java/com/iridium/iridiumskyblock/database/Island.java +++ b/src/main/java/com/iridium/iridiumskyblock/database/Island.java @@ -136,7 +136,7 @@ public void setColor(Color color) { if (super.getName() != null) return super.getName(); String ownerName = getOwner() .map(User::getName) - .orElse("N/A"); + .orElse(IridiumSkyblock.getInstance().getMessages().nullPlaceholder); return IridiumSkyblock.getInstance().getConfiguration().defaultIslandName.replace("%owner%", ownerName); } diff --git a/src/main/java/com/iridium/iridiumskyblock/managers/DatabaseManager.java b/src/main/java/com/iridium/iridiumskyblock/managers/DatabaseManager.java index 0bc023b7d..5dc107d5f 100644 --- a/src/main/java/com/iridium/iridiumskyblock/managers/DatabaseManager.java +++ b/src/main/java/com/iridium/iridiumskyblock/managers/DatabaseManager.java @@ -66,20 +66,32 @@ public void init() throws SQLException { this.userTableManager = new UserTableManager(connectionSource); this.islandTableManager = new IslandTableManager(connectionSource); this.lostItemsTableManager = new LostItemsTableManager(connectionSource, LostItems.class); - this.teamMissionDataTableManager = new TableManager<>(teamMissionData -> teamMissionData.getMissionID()+"-"+teamMissionData.getMissionIndex() ,connectionSource, TeamMissionData.class); - this.invitesTableManager = new ForeignIslandTableManager<>(teamInvite -> teamInvite.getTeamID()+"-"+teamInvite.getUser().toString(), connectionSource, TeamInvite.class); - this.trustTableManager = new ForeignIslandTableManager<>(teamTrust -> teamTrust.getTeamID()+"-"+teamTrust.getUser().toString(), connectionSource, TeamTrust.class); - this.permissionsTableManager = new ForeignIslandTableManager<>(teamPermission -> teamPermission.getTeamID()+"-"+teamPermission.getPermission()+"-"+teamPermission.getRank(), connectionSource, TeamPermission.class); - this.bankTableManager = new ForeignIslandTableManager<>(teamBank -> teamBank.getTeamID()+"-"+teamBank.getBankItem(), connectionSource, TeamBank.class); - this.enhancementTableManager = new ForeignIslandTableManager<>(teamEnhancement -> teamEnhancement.getTeamID()+"-"+teamEnhancement.getEnhancementName(), connectionSource, TeamEnhancement.class); - this.teamBlockTableManager = new ForeignIslandTableManager<>(teamBlock -> teamBlock.getTeamID()+"-"+teamBlock.getXMaterial().name(), connectionSource, TeamBlock.class); - this.teamSpawnerTableManager = new ForeignIslandTableManager<>(teamSpawner -> teamSpawner.getTeamID()+"-"+teamSpawner.getEntityType().name(), connectionSource, TeamSpawners.class); - this.teamWarpTableManager = new ForeignIslandTableManager<>(teamWarp -> teamWarp.getTeamID()+"-"+teamWarp.getName(), connectionSource, TeamWarp.class); - this.teamMissionTableManager = new ForeignIslandTableManager<>(teamMission -> teamMission.getTeamID()+"-"+teamMission.getMissionName(), connectionSource, TeamMission.class); - this.teamRewardsTableManager = new ForeignIslandTableManager<>(teamRewards -> String.valueOf(teamRewards.getId()), connectionSource, TeamReward.class); - this.teamSettingsTableManager = new ForeignIslandTableManager<>(teamSetting -> teamSetting.getTeamID()+"-"+teamSetting.getSetting(), connectionSource, TeamSetting.class); + this.teamMissionDataTableManager = new TableManager<>(teamMissionData -> getDatabaseKey(teamMissionData.getMissionID(), teamMissionData.getMissionIndex()), connectionSource, TeamMissionData.class); + this.invitesTableManager = new ForeignIslandTableManager<>(teamInvite -> getDatabaseKey(teamInvite.getTeamID(), teamInvite.getUser()), connectionSource, TeamInvite.class); + this.trustTableManager = new ForeignIslandTableManager<>(teamTrust -> getDatabaseKey(teamTrust.getTeamID(), teamTrust.getUser()), connectionSource, TeamTrust.class); + this.permissionsTableManager = new ForeignIslandTableManager<>(teamPermission -> getDatabaseKey(teamPermission.getTeamID(), teamPermission.getPermission(), teamPermission.getRank()), connectionSource, TeamPermission.class); + this.bankTableManager = new ForeignIslandTableManager<>(teamBank -> getDatabaseKey(teamBank.getTeamID(), teamBank.getBankItem()), connectionSource, TeamBank.class); + this.enhancementTableManager = new ForeignIslandTableManager<>(teamEnhancement -> getDatabaseKey(teamEnhancement.getTeamID(), teamEnhancement.getEnhancementName()), connectionSource, TeamEnhancement.class); + this.teamBlockTableManager = new ForeignIslandTableManager<>(teamBlock -> getDatabaseKey(teamBlock.getTeamID(), teamBlock.getXMaterial().name()), connectionSource, TeamBlock.class); + this.teamSpawnerTableManager = new ForeignIslandTableManager<>(teamSpawner -> getDatabaseKey(teamSpawner.getTeamID(), teamSpawner.getEntityType().name()), connectionSource, TeamSpawners.class); + this.teamWarpTableManager = new ForeignIslandTableManager<>(teamWarp -> getDatabaseKey(teamWarp.getTeamID(), teamWarp.getName()), connectionSource, TeamWarp.class); + this.teamMissionTableManager = new ForeignIslandTableManager<>(teamMission -> getDatabaseKey(teamMission.getTeamID(), teamMission.getMissionName()), connectionSource, TeamMission.class); + this.teamRewardsTableManager = new ForeignIslandTableManager<>(teamRewards -> getDatabaseKey(teamRewards.getId()), connectionSource, TeamReward.class); + this.teamSettingsTableManager = new ForeignIslandTableManager<>(teamSetting -> getDatabaseKey(teamSetting.getTeamID(), teamSetting.getSetting()), connectionSource, TeamSetting.class); } + private String getDatabaseKey(Object... params) { + StringBuilder stringBuilder = new StringBuilder(); + + for (Object obj : params) { + stringBuilder.append(obj); + stringBuilder.append("-"); + } + + return stringBuilder.toString(); + } + + /** * Database connection String used for establishing a connection. * 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/java/com/iridium/iridiumskyblock/placeholders/UserPlaceholderBuilder.java b/src/main/java/com/iridium/iridiumskyblock/placeholders/UserPlaceholderBuilder.java index 5c484651f..483111d75 100644 --- a/src/main/java/com/iridium/iridiumskyblock/placeholders/UserPlaceholderBuilder.java +++ b/src/main/java/com/iridium/iridiumskyblock/placeholders/UserPlaceholderBuilder.java @@ -16,15 +16,15 @@ public class UserPlaceholderBuilder implements PlaceholderBuilder { private final TemporaryCache> cache = new TemporaryCache<>(); private final List defaultPlaceholders = Arrays.asList( - new Placeholder("player_rank", "N/A"), - new Placeholder("player_name", "N/A"), - new Placeholder("player_join", "N/A") + new Placeholder("player_rank", IridiumSkyblock.getInstance().getMessages().nullPlaceholder), + new Placeholder("player_name", IridiumSkyblock.getInstance().getMessages().nullPlaceholder), + new Placeholder("player_join", IridiumSkyblock.getInstance().getMessages().nullPlaceholder) ); @Override public List getPlaceholders(User user) { return cache.get(user, Duration.ofSeconds(1), () -> Arrays.asList( - new Placeholder("player_rank", IridiumSkyblock.getInstance().getUserRanks().getOrDefault(user.getUserRank(), new UserRank("N/A", null)).name), + new Placeholder("player_rank", IridiumSkyblock.getInstance().getUserRanks().getOrDefault(user.getUserRank(), new UserRank(IridiumSkyblock.getInstance().getMessages().nullPlaceholder, null)).name), new Placeholder("player_name", user.getName()), new Placeholder("player_join", user.getJoinTime().format(DateTimeFormatter.ofPattern(IridiumSkyblock.getInstance().getConfiguration().dateTimeFormat))) )); diff --git a/src/main/java/com/iridium/iridiumskyblock/schematics/FastAsyncWorldEdit.java b/src/main/java/com/iridium/iridiumskyblock/schematics/FastAsyncWorldEdit.java index 1cabfffe8..4d8538bf8 100644 --- a/src/main/java/com/iridium/iridiumskyblock/schematics/FastAsyncWorldEdit.java +++ b/src/main/java/com/iridium/iridiumskyblock/schematics/FastAsyncWorldEdit.java @@ -52,7 +52,13 @@ public void paste(File file, Location location, Boolean ignoreAirBlock, Completa int width = clipboard.getDimensions().getBlockX(); int height = clipboard.getDimensions().getBlockY(); int length = clipboard.getDimensions().getBlockZ(); - location.subtract(width / 2.00, height / 2.00, length / 2.00); // Centers the schematic + + int newLength = (int) (length / 2.00); + int newWidth = (int) (width / 2.00); + int newHeight = (int) (height / 2.00); + + location.subtract(newWidth, newHeight, newLength); //Center the schematic (for real this time) + clipboard.setOrigin(clipboard.getRegion().getMinimumPoint()); // Change the //copy point to the minimum // corner { diff --git a/src/main/java/com/iridium/iridiumskyblock/schematics/SchematicAsync.java b/src/main/java/com/iridium/iridiumskyblock/schematics/SchematicAsync.java index 3708e2b52..e58e59225 100644 --- a/src/main/java/com/iridium/iridiumskyblock/schematics/SchematicAsync.java +++ b/src/main/java/com/iridium/iridiumskyblock/schematics/SchematicAsync.java @@ -31,7 +31,11 @@ public void paste(File file, Location location, Boolean ignoreAirBlock, Completa short width = schematicData.width; short height = schematicData.height; - location.subtract(width / 2.00, height / 2.00, length / 2.00); // Centers the schematic + int newLength = (int) (length / 2.00); + int newWidth = (int) (width / 2.00); + int newHeight = (int) (height / 2.00); + + location.subtract(newWidth, newHeight, newLength); //Center the schematic (for real this time) BukkitRunnable runnable = new BukkitRunnable() { diff --git a/src/main/java/com/iridium/iridiumskyblock/schematics/WorldEdit.java b/src/main/java/com/iridium/iridiumskyblock/schematics/WorldEdit.java index 012691247..c4f4dcca2 100644 --- a/src/main/java/com/iridium/iridiumskyblock/schematics/WorldEdit.java +++ b/src/main/java/com/iridium/iridiumskyblock/schematics/WorldEdit.java @@ -46,10 +46,17 @@ public void paste(File file, Location location, Boolean ignoreAirBlock, Completa ClipboardFormat format = cachedClipboardFormat.getOrDefault(file, ClipboardFormats.findByFile(file)); ClipboardReader reader = format.getReader(new FileInputStream(file)); Clipboard clipboard = reader.read(); + int width = clipboard.getDimensions().getBlockX(); int height = clipboard.getDimensions().getBlockY(); int length = clipboard.getDimensions().getBlockZ(); - location.subtract(width / 2.00, height / 2.00, length / 2.00); // Centers the schematic + + int newLength = (int) (length / 2.00); + int newWidth = (int) (width / 2.00); + int newHeight = (int) (height / 2.00); + + location.subtract(newWidth, newHeight, newLength); //Center the schematic (for real this time) + clipboard.setOrigin(clipboard.getRegion().getMinimumPoint()); // Change the //copy point to the minimum corner try (EditSession editSession = com.sk89q.worldedit.WorldEdit.getInstance().newEditSession(new BukkitWorld(location.getWorld()))) { Operation operation = new ClipboardHolder(clipboard) 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: