From 5547804398695e65768a439c59eda730c3bacb5a Mon Sep 17 00:00:00 2001 From: Shyanne Date: Fri, 29 Mar 2024 10:01:14 -0400 Subject: [PATCH 01/10] Update README.md (#828) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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. From 3e7b9b03ec6409cecbc3f1fd5461c885aa52f0c5 Mon Sep 17 00:00:00 2001 From: Peaches_MLG Date: Wed, 10 Apr 2024 18:01:50 +0100 Subject: [PATCH 02/10] Utilise String Builders to improve performance of getting keys (#835) --- .../managers/DatabaseManager.java | 36 ++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-) 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. * From 5b30e48d366841fde0bab3fd885ab396da83b957 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 24 Apr 2024 05:10:55 +0000 Subject: [PATCH 03/10] Bump org.spigotmc:spigot-api (#837) Bumps org.spigotmc:spigot-api from 1.20.4-R0.1-SNAPSHOT to 1.20.5-R0.1-SNAPSHOT. --- updated-dependencies: - dependency-name: org.spigotmc:spigot-api dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 20fa69e23..96971d696 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -27,7 +27,7 @@ dependencies { // Other dependencies that are not required or already available at runtime compileOnly("org.projectlombok:lombok:1.18.32") - compileOnly("org.spigotmc:spigot-api:1.20.4-R0.1-SNAPSHOT") + compileOnly("org.spigotmc:spigot-api:1.20.5-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") From 6c5ecd573f297426d2bf2d2e6b6b4f6f46581634 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 30 Apr 2024 04:50:49 +0000 Subject: [PATCH 04/10] Bump org.spigotmc:spigot-api (#838) Bumps org.spigotmc:spigot-api from 1.20.5-R0.1-SNAPSHOT to 1.20.6-R0.1-SNAPSHOT. --- updated-dependencies: - dependency-name: org.spigotmc:spigot-api dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 96971d696..f0492f991 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -27,7 +27,7 @@ dependencies { // Other dependencies that are not required or already available at runtime compileOnly("org.projectlombok:lombok:1.18.32") - compileOnly("org.spigotmc:spigot-api:1.20.5-R0.1-SNAPSHOT") + 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") From c72c52bbbc097617fc5904a0109d1c83bb1fcbff Mon Sep 17 00:00:00 2001 From: Peaches_MLG Date: Mon, 6 May 2024 16:28:14 +0100 Subject: [PATCH 05/10] 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 06/10] 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: From 7878f5f69a116f557a9bda2ee6203b4b382f4345 Mon Sep 17 00:00:00 2001 From: Shyanne Date: Fri, 10 May 2024 13:55:23 -0400 Subject: [PATCH 07/10] Fixed schematic centering (#843) yeah sorry i lied :) we ended up with a decimal value that was rounding up, so now we just dont do that --- .../iridiumskyblock/schematics/FastAsyncWorldEdit.java | 8 +++++++- .../iridiumskyblock/schematics/SchematicAsync.java | 6 +++++- .../iridium/iridiumskyblock/schematics/WorldEdit.java | 9 ++++++++- 3 files changed, 20 insertions(+), 3 deletions(-) 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) From 31061ad84cb1dd815cf30804284fbd4ae1c42266 Mon Sep 17 00:00:00 2001 From: Shyanne Date: Fri, 10 May 2024 14:38:45 -0400 Subject: [PATCH 08/10] replaced "N/A" instances with nullPlaceholder config (#819) Co-authored-by: Peaches_MLG --- .../iridiumskyblock/database/Island.java | 2 +- .../IslandPlaceholderBuilder.java | 36 +++++++++---------- .../placeholders/UserPlaceholderBuilder.java | 8 ++--- 3 files changed, 23 insertions(+), 23 deletions(-) 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/placeholders/IslandPlaceholderBuilder.java b/src/main/java/com/iridium/iridiumskyblock/placeholders/IslandPlaceholderBuilder.java index 84b8f423a..074d7072c 100644 --- a/src/main/java/com/iridium/iridiumskyblock/placeholders/IslandPlaceholderBuilder.java +++ b/src/main/java/com/iridium/iridiumskyblock/placeholders/IslandPlaceholderBuilder.java @@ -43,7 +43,7 @@ public List getPlaceholders(Island island) { .filter(user -> user.getUserRank() == Rank.OWNER.getId()) .findFirst() .map(User::getName) - .orElse("N/A")), + .orElse(IridiumSkyblock.getInstance().getMessages().nullPlaceholder)), new Placeholder("island_create", island.getCreateTime().format(DateTimeFormatter.ofPattern(IridiumSkyblock.getInstance().getConfiguration().dateTimeFormat))), new Placeholder("island_description", island.getDescription()), new Placeholder("island_value", String.valueOf(IridiumSkyblock.getInstance().getTeamManager().getTeamValue(island))), @@ -72,29 +72,29 @@ public List getPlaceholders(Island island) { private List initializeDefaultPlaceholders() { List placeholderList = new ArrayList<>(Arrays.asList( - new Placeholder("island_name", "N/A"), - new Placeholder("island_owner", "N/A"), - new Placeholder("island_description", "N/A"), - new Placeholder("island_create", "N/A"), - new Placeholder("island_value", "N/A"), - new Placeholder("island_level", "N/A"), - new Placeholder("island_experience", "N/A"), - new Placeholder("island_value_rank", "N/A"), - new Placeholder("island_experience_rank", "N/A"), - new Placeholder("island_members_online", "N/A"), - new Placeholder("island_members_online_count", "N/A"), - new Placeholder("island_members_offline", "N/A"), - new Placeholder("island_members_offline_count", "N/A"), - new Placeholder("island_members_count", "N/A") + new Placeholder("island_name", IridiumSkyblock.getInstance().getMessages().nullPlaceholder), + new Placeholder("island_owner", IridiumSkyblock.getInstance().getMessages().nullPlaceholder), + new Placeholder("island_description", IridiumSkyblock.getInstance().getMessages().nullPlaceholder), + new Placeholder("island_create", IridiumSkyblock.getInstance().getMessages().nullPlaceholder), + new Placeholder("island_value", IridiumSkyblock.getInstance().getMessages().nullPlaceholder), + new Placeholder("island_level", IridiumSkyblock.getInstance().getMessages().nullPlaceholder), + new Placeholder("island_experience", IridiumSkyblock.getInstance().getMessages().nullPlaceholder), + new Placeholder("island_value_rank", IridiumSkyblock.getInstance().getMessages().nullPlaceholder), + new Placeholder("island_experience_rank", IridiumSkyblock.getInstance().getMessages().nullPlaceholder), + new Placeholder("island_members_online", IridiumSkyblock.getInstance().getMessages().nullPlaceholder), + new Placeholder("island_members_online_count", IridiumSkyblock.getInstance().getMessages().nullPlaceholder), + new Placeholder("island_members_offline", IridiumSkyblock.getInstance().getMessages().nullPlaceholder), + new Placeholder("island_members_offline_count", IridiumSkyblock.getInstance().getMessages().nullPlaceholder), + new Placeholder("island_members_count", IridiumSkyblock.getInstance().getMessages().nullPlaceholder) )); for (BankItem bankItem : IridiumSkyblock.getInstance().getBankItemList()) { - placeholderList.add(new Placeholder("island_bank_" + bankItem.getName().toLowerCase(), "N/A")); + placeholderList.add(new Placeholder("island_bank_" + bankItem.getName().toLowerCase(), IridiumSkyblock.getInstance().getMessages().nullPlaceholder)); } for (XMaterial xMaterial : XMaterial.values()) { - placeholderList.add(new Placeholder("island_" + xMaterial.name().toLowerCase() + "_amount", "N/A")); + placeholderList.add(new Placeholder("island_" + xMaterial.name().toLowerCase() + "_amount", IridiumSkyblock.getInstance().getMessages().nullPlaceholder)); } for (EntityType entityType : EntityType.values()) { - placeholderList.add(new Placeholder("island_" + entityType.name().toLowerCase() + "_amount", "N/A")); + placeholderList.add(new Placeholder("island_" + entityType.name().toLowerCase() + "_amount", IridiumSkyblock.getInstance().getMessages().nullPlaceholder)); } return placeholderList; } 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))) )); From c5a275d5b734085ee8207369c5d1e4cd94374e36 Mon Sep 17 00:00:00 2001 From: Shyanne Date: Fri, 10 May 2024 14:53:06 -0400 Subject: [PATCH 09/10] added more placeholders (#821) * added more placeholders - modified the fetch for online and offline members to run a single stream to create both lists - added ``island_visitors`` and ``island_visitors_amount`` placeholders to get the list of player names visiting an island and the amount of current visitors to said island - added ``island_booster`` and ``island_upgrade`` placeholders, to get whether they're active, the level of the enhancement, and the time remaining * applied supplier - also removed members from the list of visitors * Merged enhancement placeholders - fixed an error in loop logic * Formatting and nullPlaceholder --------- Co-authored-by: Peaches_MLG --- .../IslandPlaceholderBuilder.java | 113 +++++++++++++----- 1 file changed, 83 insertions(+), 30 deletions(-) diff --git a/src/main/java/com/iridium/iridiumskyblock/placeholders/IslandPlaceholderBuilder.java b/src/main/java/com/iridium/iridiumskyblock/placeholders/IslandPlaceholderBuilder.java index 074d7072c..3e5e8f997 100644 --- a/src/main/java/com/iridium/iridiumskyblock/placeholders/IslandPlaceholderBuilder.java +++ b/src/main/java/com/iridium/iridiumskyblock/placeholders/IslandPlaceholderBuilder.java @@ -9,14 +9,16 @@ import com.iridium.iridiumteams.Rank; import com.iridium.iridiumteams.TemporaryCache; import com.iridium.iridiumteams.bank.BankItem; +import com.iridium.iridiumteams.database.TeamEnhancement; +import com.iridium.iridiumteams.enhancements.Enhancement; +import com.iridium.iridiumteams.enhancements.EnhancementType; +import org.bukkit.Bukkit; import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; import java.time.Duration; import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; +import java.util.*; import java.util.stream.Collectors; public class IslandPlaceholderBuilder implements PlaceholderBuilder { @@ -28,49 +30,79 @@ public class IslandPlaceholderBuilder implements PlaceholderBuilder { public List getPlaceholders(Island island) { return cache.get(island, Duration.ofSeconds(1), () -> { List users = IridiumSkyblock.getInstance().getTeamManager().getTeamMembers(island); - List onlineUsers = users.stream() - .filter(u -> u.getPlayer() != null) - .map(User::getName) - .collect(Collectors.toList()); - List offlineUsers = users.stream() - .filter(u -> u.getPlayer() == null) - .map(User::getName) - .collect(Collectors.toList()); + + List onlineUsers = new ArrayList<>(Collections.emptyList()); + List offlineUsers = new ArrayList<>(Collections.emptyList()); + + for (User user : users) { + if (user.getPlayer() != null) { + onlineUsers.add(user.getName()); + } else { + offlineUsers.add(user.getName()); + } + } List placeholderList = new ArrayList<>(Arrays.asList( - new Placeholder("island_name", island.getName()), - new Placeholder("island_owner", IridiumSkyblock.getInstance().getTeamManager().getTeamMembers(island).stream() + new Placeholder("island_name", island::getName), + new Placeholder("island_owner", () -> IridiumSkyblock.getInstance().getTeamManager().getTeamMembers(island).stream() .filter(user -> user.getUserRank() == Rank.OWNER.getId()) .findFirst() .map(User::getName) .orElse(IridiumSkyblock.getInstance().getMessages().nullPlaceholder)), - new Placeholder("island_create", island.getCreateTime().format(DateTimeFormatter.ofPattern(IridiumSkyblock.getInstance().getConfiguration().dateTimeFormat))), - new Placeholder("island_description", island.getDescription()), - new Placeholder("island_value", String.valueOf(IridiumSkyblock.getInstance().getTeamManager().getTeamValue(island))), - new Placeholder("island_level", String.valueOf(island.getLevel())), - new Placeholder("island_experience", String.valueOf(island.getExperience())), - new Placeholder("island_value_rank", String.valueOf(IridiumSkyblock.getInstance().getTop().valueTeamSort.getRank(island, IridiumSkyblock.getInstance()))), - new Placeholder("island_experience_rank", String.valueOf(IridiumSkyblock.getInstance().getTop().experienceTeamSort.getRank(island, IridiumSkyblock.getInstance()))), - new Placeholder("island_members_online", String.join(", ", onlineUsers)), - new Placeholder("island_members_online_count", String.valueOf(onlineUsers.size())), - new Placeholder("island_members_offline", String.join(", ", offlineUsers)), - new Placeholder("island_members_offline_count", String.valueOf(offlineUsers.size())), - new Placeholder("island_members_count", String.valueOf(users.size())) + new Placeholder("island_create", () -> island.getCreateTime().format(DateTimeFormatter.ofPattern(IridiumSkyblock.getInstance().getConfiguration().dateTimeFormat))), + new Placeholder("island_description", island::getDescription), + new Placeholder("island_value", () -> String.valueOf(IridiumSkyblock.getInstance().getTeamManager().getTeamValue(island))), + new Placeholder("island_level", () -> String.valueOf(island.getLevel())), + new Placeholder("island_experience", () -> String.valueOf(island.getExperience())), + new Placeholder("island_value_rank", () -> String.valueOf(IridiumSkyblock.getInstance().getTop().valueTeamSort.getRank(island, IridiumSkyblock.getInstance()))), + new Placeholder("island_experience_rank", () -> String.valueOf(IridiumSkyblock.getInstance().getTop().experienceTeamSort.getRank(island, IridiumSkyblock.getInstance()))), + new Placeholder("island_members_online", () -> String.join(", ", onlineUsers)), + new Placeholder("island_members_online_count", () -> String.valueOf(onlineUsers.size())), + new Placeholder("island_members_offline", () -> String.join(", ", offlineUsers)), + new Placeholder("island_members_offline_count", () -> String.valueOf(offlineUsers.size())), + new Placeholder("island_members_count", () -> String.valueOf(users.size())) )); + + List visitingPlayers = Bukkit.getOnlinePlayers().stream() + .map(Player::getPlayer) + .filter(Objects::nonNull) + .filter(player -> island.isInIsland(player.getLocation())) + .collect(Collectors.toList()); + + visitingPlayers.removeIf(player -> onlineUsers.contains(player.getName())); + + placeholderList.add(new Placeholder("island_visitors", () -> visitingPlayers.stream().map(Player::getName).collect(Collectors.joining(", ")))); + placeholderList.add(new Placeholder("island_visitors_amount", () -> String.valueOf(visitingPlayers.size()))); + + placeholderList.add(new Placeholder("island_visitors", () -> visitingPlayers.stream().map(Player::getName).collect(Collectors.joining(", ")))); + placeholderList.add(new Placeholder("island_visitors_amount", () -> String.valueOf(visitingPlayers.size()))); + + for (Map.Entry> enhancement : IridiumSkyblock.getInstance().getEnhancementList().entrySet()) { + if (!enhancement.getValue().enabled) continue; + TeamEnhancement teamEnhancement = IridiumSkyblock.getInstance().getIslandManager().getTeamEnhancement(island, enhancement.getKey()); + + placeholderList.add(new Placeholder("island_enhancement_" + enhancement.getKey() + "_active", () -> String.valueOf(teamEnhancement.isActive()))); + placeholderList.add(new Placeholder("island_enhancement_" + enhancement.getKey() + "_level", () -> String.valueOf(teamEnhancement.getLevel()))); + placeholderList.add(new Placeholder("island_enhancement_" + enhancement.getKey() + "_time_hours", () -> String.valueOf(Math.max((int) (teamEnhancement.getRemainingTime() % 60), 0)))); + placeholderList.add(new Placeholder("island_enhancement_" + enhancement.getKey() + "_time_minutes", () -> String.valueOf(Math.max((int) ((teamEnhancement.getRemainingTime() % 3600) / 60), 0)))); + placeholderList.add(new Placeholder("island_enhancement_" + enhancement.getKey() + "_time_seconds", () -> String.valueOf(Math.max((int) (teamEnhancement.getRemainingTime() / 3600), 0)))); + } + for (BankItem bankItem : IridiumSkyblock.getInstance().getBankItemList()) { - placeholderList.add(new Placeholder("island_bank_" + bankItem.getName().toLowerCase(), String.valueOf(IridiumSkyblock.getInstance().getTeamManager().getTeamBank(island, bankItem.getName()).getNumber()))); + placeholderList.add(new Placeholder("island_bank_" + bankItem.getName().toLowerCase(), () -> String.valueOf(IridiumSkyblock.getInstance().getTeamManager().getTeamBank(island, bankItem.getName()).getNumber()))); } for (XMaterial xMaterial : XMaterial.values()) { - placeholderList.add(new Placeholder("island_" + xMaterial.name().toLowerCase() + "_amount", String.valueOf(IridiumSkyblock.getInstance().getTeamManager().getTeamBlock(island, xMaterial).getAmount()))); + placeholderList.add(new Placeholder("island_" + xMaterial.name().toLowerCase() + "_amount", () -> String.valueOf(IridiumSkyblock.getInstance().getTeamManager().getTeamBlock(island, xMaterial).getAmount()))); } for (EntityType entityType : EntityType.values()) { - placeholderList.add(new Placeholder("island_" + entityType.name().toLowerCase() + "_amount", String.valueOf(IridiumSkyblock.getInstance().getTeamManager().getTeamSpawners(island, entityType).getAmount()))); + placeholderList.add(new Placeholder("island_" + entityType.name().toLowerCase() + "_amount", () -> String.valueOf(IridiumSkyblock.getInstance().getTeamManager().getTeamSpawners(island, entityType).getAmount()))); } return placeholderList; }); } private List initializeDefaultPlaceholders() { + List placeholderList = new ArrayList<>(Arrays.asList( new Placeholder("island_name", IridiumSkyblock.getInstance().getMessages().nullPlaceholder), new Placeholder("island_owner", IridiumSkyblock.getInstance().getMessages().nullPlaceholder), @@ -85,8 +117,29 @@ private List initializeDefaultPlaceholders() { new Placeholder("island_members_online_count", IridiumSkyblock.getInstance().getMessages().nullPlaceholder), new Placeholder("island_members_offline", IridiumSkyblock.getInstance().getMessages().nullPlaceholder), new Placeholder("island_members_offline_count", IridiumSkyblock.getInstance().getMessages().nullPlaceholder), - new Placeholder("island_members_count", IridiumSkyblock.getInstance().getMessages().nullPlaceholder) + new Placeholder("island_members_count", IridiumSkyblock.getInstance().getMessages().nullPlaceholder), + new Placeholder("island_visitors", IridiumSkyblock.getInstance().getMessages().nullPlaceholder), + new Placeholder("island_visitors_amount", IridiumSkyblock.getInstance().getMessages().nullPlaceholder) )); + + for (Map.Entry> enhancement : IridiumSkyblock.getInstance().getEnhancementList().entrySet()) { + if (enhancement.getValue().type == EnhancementType.BOOSTER) { + placeholderList.add(new Placeholder("island_booster_" + enhancement.getKey() + "_active", IridiumSkyblock.getInstance().getMessages().nullPlaceholder)); + placeholderList.add(new Placeholder("island_booster_" + enhancement.getKey() + "_level", IridiumSkyblock.getInstance().getMessages().nullPlaceholder)); + placeholderList.add(new Placeholder("island_booster_" + enhancement.getKey() + "_time_hours", IridiumSkyblock.getInstance().getMessages().nullPlaceholder)); + placeholderList.add(new Placeholder("island_booster_" + enhancement.getKey() + "_time_minutes", IridiumSkyblock.getInstance().getMessages().nullPlaceholder)); + placeholderList.add(new Placeholder("island_booster_" + enhancement.getKey() + "_time_seconds", IridiumSkyblock.getInstance().getMessages().nullPlaceholder)); + } + + if (enhancement.getValue().type == EnhancementType.UPGRADE) { + placeholderList.add(new Placeholder("island_upgrade_" + enhancement.getKey() + "_active", IridiumSkyblock.getInstance().getMessages().nullPlaceholder)); + placeholderList.add(new Placeholder("island_upgrade_" + enhancement.getKey() + "_level", IridiumSkyblock.getInstance().getMessages().nullPlaceholder)); + placeholderList.add(new Placeholder("island_upgrade_" + enhancement.getKey() + "_time_hours", IridiumSkyblock.getInstance().getMessages().nullPlaceholder)); + placeholderList.add(new Placeholder("island_upgrade_" + enhancement.getKey() + "_time_minutes", IridiumSkyblock.getInstance().getMessages().nullPlaceholder)); + placeholderList.add(new Placeholder("island_upgrade_" + enhancement.getKey() + "_time_seconds", IridiumSkyblock.getInstance().getMessages().nullPlaceholder)); + } + } + for (BankItem bankItem : IridiumSkyblock.getInstance().getBankItemList()) { placeholderList.add(new Placeholder("island_bank_" + bankItem.getName().toLowerCase(), IridiumSkyblock.getInstance().getMessages().nullPlaceholder)); } From 37bc78e32ca96a25628835b618acfc88b2011ce6 Mon Sep 17 00:00:00 2001 From: Shyanne Date: Sat, 11 May 2024 03:24:59 -0400 Subject: [PATCH 10/10] you can respawn on your island now, or whatever (#842) * you can respawn on your island now, or whatever also rewrote the player utils class to use the spawn support from teams, its pretty cool * Added visit check to keep players off private islands --------- Co-authored-by: Peaches_MLG --- .../configs/Configuration.java | 1 + .../listeners/PlayerRespawnEventListener.java | 28 +++++++++++++ .../iridiumskyblock/utils/PlayerUtils.java | 40 +++++++++++++------ 3 files changed, 56 insertions(+), 13 deletions(-) create mode 100644 src/main/java/com/iridium/iridiumskyblock/listeners/PlayerRespawnEventListener.java diff --git a/src/main/java/com/iridium/iridiumskyblock/configs/Configuration.java b/src/main/java/com/iridium/iridiumskyblock/configs/Configuration.java index 9d2025b66..7bd515121 100644 --- a/src/main/java/com/iridium/iridiumskyblock/configs/Configuration.java +++ b/src/main/java/com/iridium/iridiumskyblock/configs/Configuration.java @@ -56,6 +56,7 @@ public Configuration() { public boolean clearEnderChestOnRegen = false; public boolean allowPvPOnIslands = false; public boolean islandCreateOnJoin = false; + public boolean spawnOnIsland = false; public int distance = 151; public int netherUnlockLevel = 10; public int endUnlockLevel = 20; diff --git a/src/main/java/com/iridium/iridiumskyblock/listeners/PlayerRespawnEventListener.java b/src/main/java/com/iridium/iridiumskyblock/listeners/PlayerRespawnEventListener.java new file mode 100644 index 000000000..adaf0ddf2 --- /dev/null +++ b/src/main/java/com/iridium/iridiumskyblock/listeners/PlayerRespawnEventListener.java @@ -0,0 +1,28 @@ +package com.iridium.iridiumskyblock.listeners; + +import com.iridium.iridiumskyblock.IridiumSkyblock; +import com.iridium.iridiumskyblock.database.Island; +import com.iridium.iridiumskyblock.utils.PlayerUtils; +import lombok.AllArgsConstructor; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerRespawnEvent; + +import java.util.Optional; + +@AllArgsConstructor +public class PlayerRespawnEventListener implements Listener { + + @EventHandler(priority = EventPriority.HIGHEST) + public void onPlayerRespawnEvent(PlayerRespawnEvent event) { + + if (!IridiumSkyblock.getInstance().getConfiguration().spawnOnIsland) return; + if (!event.isBedSpawn() && !event.isAnchorSpawn()) event.setRespawnLocation(PlayerUtils.getSpawn(event.getPlayer())); + + Optional island = IridiumSkyblock.getInstance().getTeamManager().getTeamViaLocation(event.getRespawnLocation()); + if (!island.isPresent()) return; + + if (!IridiumSkyblock.getInstance().getIslandManager().canVisit(event.getPlayer(), island.get())) event.setRespawnLocation(PlayerUtils.getSpawn(event.getPlayer())); + } +} diff --git a/src/main/java/com/iridium/iridiumskyblock/utils/PlayerUtils.java b/src/main/java/com/iridium/iridiumskyblock/utils/PlayerUtils.java index 09fbb2c1d..b6b65508d 100644 --- a/src/main/java/com/iridium/iridiumskyblock/utils/PlayerUtils.java +++ b/src/main/java/com/iridium/iridiumskyblock/utils/PlayerUtils.java @@ -1,26 +1,40 @@ package com.iridium.iridiumskyblock.utils; -import com.earth2me.essentials.Essentials; -import com.earth2me.essentials.spawn.EssentialsSpawn; import com.iridium.iridiumskyblock.IridiumSkyblock; +import com.iridium.iridiumskyblock.database.Island; +import com.iridium.iridiumteams.support.SpawnSupport; + import org.bukkit.Bukkit; +import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Player; +import java.util.Optional; + public class PlayerUtils { + public static void teleportSpawn(Player player) { - World spawnWorld = Bukkit.getWorld(IridiumSkyblock.getInstance().getConfiguration().spawnWorldName); - if (spawnWorld == null) { - spawnWorld = Bukkit.getWorlds().get(0); + player.teleport(getSpawn(player)); + } + + public static Location getSpawn(Player player) { + + if(IridiumSkyblock.getInstance().getConfiguration().spawnOnIsland) { + Optional island = IridiumSkyblock.getInstance().getTeamManager().getTeamViaNameOrPlayer(player.getName()); + if(island.isPresent()) { + return island.get().getHome(); + } } - EssentialsSpawn essentialsSpawn = (EssentialsSpawn) Bukkit.getPluginManager().getPlugin("EssentialsSpawn"); - Essentials essentials = (Essentials) Bukkit.getPluginManager().getPlugin("Essentials"); - if (essentialsSpawn != null && essentials != null) { - player.teleport(essentialsSpawn.getSpawn(essentials.getUser(player).getGroup())); - } else { - player.teleport(spawnWorld.getSpawnLocation()); + for(SpawnSupport spawnSupport : IridiumSkyblock.getInstance().getSupportManager().getSpawnSupport()) { + return spawnSupport.getSpawn(player); + } + + World spawnWorld = Bukkit.getWorld(IridiumSkyblock.getInstance().getConfiguration().spawnWorldName); + if (spawnWorld != null) { + return spawnWorld.getSpawnLocation(); } - } -} + return Bukkit.getWorlds().get(0).getSpawnLocation(); + } +} \ No newline at end of file