From c3cc0833f5b5ace8c65b2e22fc09cebce73e9ef2 Mon Sep 17 00:00:00 2001 From: Shyanne Date: Fri, 1 Mar 2024 12:56:12 -0500 Subject: [PATCH 1/8] Added Island Level Configuration - the other side of [IridiumTeams #49](https://github.com/Iridium-Development/IridiumTeams/pull/49) --- .../iridiumskyblock/database/Island.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/java/com/iridium/iridiumskyblock/database/Island.java b/src/main/java/com/iridium/iridiumskyblock/database/Island.java index a41330930..e2cf842cd 100644 --- a/src/main/java/com/iridium/iridiumskyblock/database/Island.java +++ b/src/main/java/com/iridium/iridiumskyblock/database/Island.java @@ -36,6 +36,24 @@ public Island(int id) { setId(id); } + @Override + public int getLevel() { + if (!IridiumSkyblock.getInstance().getConfiguration().isLevelExponential) { + if (IridiumSkyblock.getInstance().getConfiguration().flatExpRequirement != 0) + return getExperience() / IridiumSkyblock.getInstance().getConfiguration().flatExpRequirement; + + return getExperience(); + } + + if (IridiumSkyblock.getInstance().getConfiguration().flatExpRequirement != 0) { + return (int) Math.floor(Math.pow( + getExperience() / (double) IridiumSkyblock.getInstance().getConfiguration().flatExpRequirement, + IridiumSkyblock.getInstance().getConfiguration().curvedExpModifier) + 1); + } + + return (int) Math.floor(Math.pow(getExperience(), IridiumSkyblock.getInstance().getConfiguration().curvedExpModifier) + 1); + } + @Override public double getValue() { return IridiumSkyblock.getInstance().getTeamManager().getTeamValue(this); From ade87058ff7c155383f27f38ab82ec44fdc0ec9e Mon Sep 17 00:00:00 2001 From: Shyanne Date: Fri, 1 Mar 2024 13:02:00 -0500 Subject: [PATCH 2/8] no negative values here --- .../java/com/iridium/iridiumskyblock/database/Island.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/iridium/iridiumskyblock/database/Island.java b/src/main/java/com/iridium/iridiumskyblock/database/Island.java index e2cf842cd..43cbea79b 100644 --- a/src/main/java/com/iridium/iridiumskyblock/database/Island.java +++ b/src/main/java/com/iridium/iridiumskyblock/database/Island.java @@ -40,18 +40,18 @@ public Island(int id) { public int getLevel() { if (!IridiumSkyblock.getInstance().getConfiguration().isLevelExponential) { if (IridiumSkyblock.getInstance().getConfiguration().flatExpRequirement != 0) - return getExperience() / IridiumSkyblock.getInstance().getConfiguration().flatExpRequirement; + return Math.abs(getExperience() / IridiumSkyblock.getInstance().getConfiguration().flatExpRequirement); return getExperience(); } if (IridiumSkyblock.getInstance().getConfiguration().flatExpRequirement != 0) { - return (int) Math.floor(Math.pow( + return Math.abs((int) Math.floor(Math.pow( getExperience() / (double) IridiumSkyblock.getInstance().getConfiguration().flatExpRequirement, - IridiumSkyblock.getInstance().getConfiguration().curvedExpModifier) + 1); + IridiumSkyblock.getInstance().getConfiguration().curvedExpModifier) + 1)); } - return (int) Math.floor(Math.pow(getExperience(), IridiumSkyblock.getInstance().getConfiguration().curvedExpModifier) + 1); + return Math.abs((int) Math.floor(Math.pow(getExperience(), IridiumSkyblock.getInstance().getConfiguration().curvedExpModifier) + 1)); } @Override From 1c3f686f71db8cbd2c0233fff1c323ac8f90c00d Mon Sep 17 00:00:00 2001 From: Shyanne Date: Fri, 1 Mar 2024 13:07:12 -0500 Subject: [PATCH 3/8] added leveling toggle --- src/main/java/com/iridium/iridiumskyblock/database/Island.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/iridium/iridiumskyblock/database/Island.java b/src/main/java/com/iridium/iridiumskyblock/database/Island.java index 43cbea79b..c46078643 100644 --- a/src/main/java/com/iridium/iridiumskyblock/database/Island.java +++ b/src/main/java/com/iridium/iridiumskyblock/database/Island.java @@ -38,6 +38,9 @@ public Island(int id) { @Override public int getLevel() { + + if(!IridiumSkyblock.getInstance().getConfiguration().enableLeveling) return 1; + if (!IridiumSkyblock.getInstance().getConfiguration().isLevelExponential) { if (IridiumSkyblock.getInstance().getConfiguration().flatExpRequirement != 0) return Math.abs(getExperience() / IridiumSkyblock.getInstance().getConfiguration().flatExpRequirement); From faaf0c9993a09e0906143482b343df956683c7e0 Mon Sep 17 00:00:00 2001 From: Shyanne Date: Sun, 3 Mar 2024 00:55:32 -0500 Subject: [PATCH 4/8] Added More Level Features - added ``minLevel`` to ``BiomeItem`` and ``SchematicConfig`` classes, and functionality to use them - added ``islandCreationCost`` in config to check if we want islands to cost something on creation or just regen - updated configs to reflect changes in teams (also updated default regenCost to be 0 because... y'know) - removed formulas from ``getLevel()`` because we pull from islandManager instead - added ``island_experienceToLevelUp`` and ``island_experienceForNextLevel`` placeholders, which return the amount of experience left needed to level up and the experience needed for the next level respectively --- .../commands/RegenCommand.java | 6 ++++ .../iridiumskyblock/configs/Biomes.java | 33 ++++++++++++------- .../configs/Configuration.java | 1 + .../iridiumskyblock/configs/Missions.java | 20 +++++------ .../iridiumskyblock/configs/Schematics.java | 7 ++-- .../iridiumskyblock/database/Island.java | 18 +--------- .../managers/BiomeManager.java | 18 ++++++++++ .../managers/IslandManager.java | 8 +++-- .../IslandPlaceholderBuilder.java | 2 ++ 9 files changed, 69 insertions(+), 44 deletions(-) diff --git a/src/main/java/com/iridium/iridiumskyblock/commands/RegenCommand.java b/src/main/java/com/iridium/iridiumskyblock/commands/RegenCommand.java index 023494663..941dbf039 100644 --- a/src/main/java/com/iridium/iridiumskyblock/commands/RegenCommand.java +++ b/src/main/java/com/iridium/iridiumskyblock/commands/RegenCommand.java @@ -54,6 +54,12 @@ public boolean execute(User user, Island island, String[] args, IridiumTeams()) + new Cost(100, new HashMap<>()), + 1 ), new BiomeItem( "&9&lSnowy Plains", @@ -34,7 +35,8 @@ public class Biomes { XBiome.SNOWY_PLAINS, 1, 13, - new Cost(50, new HashMap<>()) + new Cost(50, new HashMap<>()), + 1 ), new BiomeItem( "&9&lSavanna", @@ -42,7 +44,8 @@ public class Biomes { XBiome.SAVANNA, 1, 15, - new Cost(100, new HashMap<>()) + new Cost(100, new HashMap<>()), + 1 ) )) .put("Nether", Arrays.asList( @@ -52,7 +55,8 @@ public class Biomes { XBiome.NETHER_WASTES, 1, 11, - new Cost(50, new HashMap<>()) + new Cost(50, new HashMap<>()), + 1 ), new BiomeItem( "&9&lCrimson Forest", @@ -60,7 +64,8 @@ public class Biomes { XBiome.CRIMSON_FOREST, 1, 13, - new Cost(1000, new HashMap<>()) + new Cost(1000, new HashMap<>()), + 1 ), new BiomeItem( "&9&lWarped Forest", @@ -68,7 +73,8 @@ public class Biomes { XBiome.WARPED_FOREST, 1, 15, - new Cost(100, new HashMap<>()) + new Cost(100, new HashMap<>()), + 1 ) ) ) @@ -79,7 +85,8 @@ public class Biomes { XBiome.THE_END, 1, 11, - new Cost(100, new HashMap<>()) + new Cost(100, new HashMap<>()), + 1 ), new BiomeItem( "&9&lEnd Highlands", @@ -87,7 +94,8 @@ public class Biomes { XBiome.END_HIGHLANDS, 1, 13, - new Cost(150, new HashMap<>()) + new Cost(150, new HashMap<>()), + 1 ), new BiomeItem( "&9&lEnd Barrens", @@ -95,8 +103,9 @@ public class Biomes { XBiome.END_BARRENS, 1, 15, - new Cost(150, new HashMap<>()) - ) + new Cost(150, new HashMap<>()), + 1 + ) ) ) .build(); @@ -127,8 +136,9 @@ public static class BiomeItem { public int slot; public int page; public Cost buyCost; + public int minLevel; - public BiomeItem(String name, XMaterial type, XBiome biome, int defaultAmount, int slot, Cost buyCost) { + public BiomeItem(String name, XMaterial type, XBiome biome, int defaultAmount, int slot, Cost buyCost, int minLevel) { this.name = name; this.type = type; this.biome = biome; @@ -137,6 +147,7 @@ public BiomeItem(String name, XMaterial type, XBiome biome, int defaultAmount, i this.slot = slot; this.page = 1; this.buyCost = buyCost; + this.minLevel = minLevel; } } diff --git a/src/main/java/com/iridium/iridiumskyblock/configs/Configuration.java b/src/main/java/com/iridium/iridiumskyblock/configs/Configuration.java index 9d2025b66..a9e622bb7 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 islandCreationCost = false; public int distance = 151; public int netherUnlockLevel = 10; public int endUnlockLevel = 20; diff --git a/src/main/java/com/iridium/iridiumskyblock/configs/Missions.java b/src/main/java/com/iridium/iridiumskyblock/configs/Missions.java index a06fdfa17..8606c7356 100644 --- a/src/main/java/com/iridium/iridiumskyblock/configs/Missions.java +++ b/src/main/java/com/iridium/iridiumskyblock/configs/Missions.java @@ -34,7 +34,7 @@ public Missions() { "", "&9&l * &7Time Remaining: " + "&9%timeremaining_hours% hours %timeremaining_minutes% minutes and %timeremaining_seconds% seconds" ) - ), Arrays.asList("GROW:SUGAR_CANE:10", "GROW:WHEAT:10", "GROW:CARROTS:10"), new Reward(new Item(XMaterial.DIAMOND, 1, "&9&lFarmer Reward", + ), Arrays.asList("GROW:SUGAR_CANE:10", "GROW:WHEAT:10", "GROW:CARROTS:10"), 1, new Reward(new Item(XMaterial.DIAMOND, 1, "&9&lFarmer Reward", Arrays.asList( "&9&l Rewards", "&9&l* &75 Island Crystals", @@ -64,7 +64,7 @@ public Missions() { "", "&9&l * &7Time Remaining: " + "&9%timeremaining_hours% hours %timeremaining_minutes% minutes and %timeremaining_seconds% seconds" ) - ), Arrays.asList("KILL:ZOMBIE:10", "KILL:SKELETON:10", "KILL:CREEPER:10"), new Reward(new Item(XMaterial.DIAMOND, 1, "&9&lHunter Reward", + ), Arrays.asList("KILL:ZOMBIE:10", "KILL:SKELETON:10", "KILL:CREEPER:10"), 1, new Reward(new Item(XMaterial.DIAMOND, 1, "&9&lHunter Reward", Arrays.asList( "&9&l Rewards", "&9&l* &75 Island Crystals", @@ -92,7 +92,7 @@ public Missions() { "", "&9&l * &7Time Remaining: " + "&9%timeremaining_hours% hours %timeremaining_minutes% minutes and %timeremaining_seconds% seconds" ) - ), Collections.singletonList("CRAFT:BREAD:64"), new Reward(new Item(XMaterial.DIAMOND, 1, "&9&lBaker Reward", + ), Collections.singletonList("CRAFT:BREAD:64"), 1, new Reward(new Item(XMaterial.DIAMOND, 1, "&9&lBaker Reward", Arrays.asList( "&9&l Rewards", "&9&l* &75 Island Crystals", @@ -122,7 +122,7 @@ public Missions() { "", "&9&l * &7Time Remaining: " + "&9%timeremaining_hours% hours %timeremaining_minutes% minutes and %timeremaining_seconds% seconds" ) - ), Arrays.asList("MINE:IRON_ORE:15", "MINE:COAL_ORE:30", "MINE:DIAMOND_ORE:1"), new Reward(new Item(XMaterial.DIAMOND, 1, "&9&lMiner Reward", + ), Arrays.asList("MINE:IRON_ORE:15", "MINE:COAL_ORE:30", "MINE:DIAMOND_ORE:1"), 1, new Reward(new Item(XMaterial.DIAMOND, 1, "&9&lMiner Reward", Arrays.asList( "&9&l Rewards", "&9&l* &75 Island Crystals", @@ -150,7 +150,7 @@ public Missions() { "", "&9&l * &7Time Remaining: " + "&9%timeremaining_hours% hours %timeremaining_minutes% minutes and %timeremaining_seconds% seconds" ) - ), Collections.singletonList("FISH:ANY:10"), new Reward(new Item(XMaterial.DIAMOND, 1, "&9&lFisherman Reward", + ), Collections.singletonList("FISH:ANY:10"), 1, new Reward(new Item(XMaterial.DIAMOND, 1, "&9&lFisherman Reward", Arrays.asList( "&9&l Rewards", "&9&l* &75 Island Crystals", @@ -178,7 +178,7 @@ public Missions() { "&9&l* &7$1000", "", "&9&l * &7Time Remaining: " + "&9%timeremaining_hours% hours %timeremaining_minutes% minutes and %timeremaining_seconds% seconds" - )), Arrays.asList("SMELT:" + (XMaterial.supports(17) ? XMaterial.RAW_IRON.name() : XMaterial.IRON_ORE.name()) + ":30", "SMELT:" + (XMaterial.supports(17) ? XMaterial.RAW_GOLD.name() : XMaterial.GOLD_ORE.name()) + ":15"), new Reward(new Item(XMaterial.DIAMOND, 1, "&9&lBlacksmith Reward", + )), Arrays.asList("SMELT:" + (XMaterial.supports(17) ? XMaterial.RAW_IRON.name() : XMaterial.IRON_ORE.name()) + ":30", "SMELT:" + (XMaterial.supports(17) ? XMaterial.RAW_GOLD.name() : XMaterial.GOLD_ORE.name()) + ":15"), 1, new Reward(new Item(XMaterial.DIAMOND, 1, "&9&lBlacksmith Reward", Arrays.asList( "&9&l Rewards", "&9&l* &75 Island Crystals", @@ -207,7 +207,7 @@ public Missions() { "", "&9&l * &7Time Remaining: " + "&9%timeremaining_hours% hours %timeremaining_minutes% minutes and %timeremaining_seconds% seconds" ) - ), Arrays.asList("BREW:SPEED:2:3", "BREW:STRENGTH:2:3"), new Reward(new Item(XMaterial.DIAMOND, 1, "&9&lPotionBrewer Reward", + ), Arrays.asList("BREW:SPEED:2:3", "BREW:STRENGTH:2:3"), 1, new Reward(new Item(XMaterial.DIAMOND, 1, "&9&lPotionBrewer Reward", Arrays.asList( "&9&l Rewards", "&9&l* &75 Island Crystals", @@ -233,7 +233,7 @@ public Missions() { "&9&l* &75 Island Crystals", "&9&l* &7$1000" ) - ), Collections.singletonList("MINE:LOGS:10"), new Reward(new Item(XMaterial.DIAMOND, 1, "&9&lPotionBrewer Reward", + ), Collections.singletonList("MINE:LOGS:10"), 1, new Reward(new Item(XMaterial.DIAMOND, 1, "&9&lPotionBrewer Reward", Arrays.asList( "&9&l Rewards", "&9&l* &75 Island Crystals", @@ -257,7 +257,7 @@ public Missions() { "&9&l* &75 Island Crystals", "&9&l* &7$1000" ) - ), Collections.singletonList("MINE:LOGS:100"), new Reward(new Item(XMaterial.DIAMOND, 1, "&9&lPotionBrewer Reward", + ), Collections.singletonList("MINE:LOGS:100"), 1, new Reward(new Item(XMaterial.DIAMOND, 1, "&9&lPotionBrewer Reward", Arrays.asList( "&9&l Rewards", "&9&l* &75 Island Crystals", @@ -281,7 +281,7 @@ public Missions() { "&9&l* &75 Island Crystals", "&9&l* &7$1000" ) - ), Collections.singletonList("MINE:LOGS:1000"), new Reward(new Item(XMaterial.DIAMOND, 1, "&9&lPotionBrewer Reward", + ), Collections.singletonList("MINE:LOGS:1000"), 1, new Reward(new Item(XMaterial.DIAMOND, 1, "&9&lPotionBrewer Reward", Arrays.asList( "&9&l Rewards", "&9&l* &75 Island Crystals", diff --git a/src/main/java/com/iridium/iridiumskyblock/configs/Schematics.java b/src/main/java/com/iridium/iridiumskyblock/configs/Schematics.java index 593a132b3..17021d1cc 100644 --- a/src/main/java/com/iridium/iridiumskyblock/configs/Schematics.java +++ b/src/main/java/com/iridium/iridiumskyblock/configs/Schematics.java @@ -17,7 +17,7 @@ public class Schematics { public Map schematics = ImmutableMap.builder() .put("desert", new SchematicConfig(new Item(XMaterial.PLAYER_HEAD, 11, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNGY0OTNkZDgwNjUzM2Q5ZDIwZTg0OTUzOTU0MzY1ZjRkMzY5NzA5Y2ViYzlkZGVmMDIyZDFmZDQwZDg2YTY4ZiJ9fX0=", 1, "&9&lDesert Island", Arrays.asList("&7A starter desert island.", "", "&9&l[!] &7Costs $1000")), - new Schematics.Cost(1000, new HashMap<>()), -0.5, 89, -0.5, 90, new SchematicWorld(Biome.DESERT, + new Schematics.Cost(0, new HashMap<>()), 1, -0.5, 89, -0.5, 90, new SchematicWorld(Biome.DESERT, "desert.schem", 90.0, true ), new SchematicWorld(XMaterial.supports(16) ? Biome.NETHER_WASTES : Biome.valueOf("NETHER"), "desert_nether.schem", 90.0, true @@ -25,7 +25,7 @@ public class Schematics { "desert_end.schem", 90.0, true ))) .put("jungle", new SchematicConfig(new Item(XMaterial.PLAYER_HEAD, 13, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNjgzYWRmNDU2MGRlNDc0MTQwNDA5M2FjNjFjMzNmYjU1NmIzZDllZTUxNDBmNjIwMzYyNTg5ZmRkZWRlZmEyZCJ9fX0=", 1, "&9&lJungle Island", Arrays.asList("&7A starter jungle island.", "", "&9&l[!] &7Costs $1000")), - new Schematics.Cost(1000, new HashMap<>()), 1.5, 83, 1.5, 90, new SchematicWorld(Biome.JUNGLE, + new Schematics.Cost(0, new HashMap<>()), 1, 1.5, 83, 1.5, 90, new SchematicWorld(Biome.JUNGLE, "jungle.schem", 90.0, true ), new SchematicWorld(XMaterial.supports(16) ? Biome.NETHER_WASTES : Biome.valueOf("NETHER"), "jungle_nether.schem", 90.0, true @@ -33,7 +33,7 @@ public class Schematics { "jungle_end.schem", 90.0, true ))) .put("mushroom", new SchematicConfig(new Item(XMaterial.PLAYER_HEAD, 15, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZWE0NWQxYjQxN2NiZGRjMjE3NjdiMDYwNDRlODk5YjI2NmJmNzhhNjZlMjE4NzZiZTNjMDUxNWFiNTVkNzEifX19", 1, "&9&lMushroom Island", Arrays.asList("&7A starter mushroom island.", "", "&9&l[!] &7Costs $1000")), - new Schematics.Cost(1000, new HashMap<>()), 0.5, 89, -0.5, 90, new SchematicWorld(Biome.MUSHROOM_FIELDS, + new Schematics.Cost(0, new HashMap<>()), 1, 0.5, 89, -0.5, 90, new SchematicWorld(Biome.MUSHROOM_FIELDS, "mushroom.schem", 90.0, true ), new SchematicWorld(XMaterial.supports(16) ? Biome.NETHER_WASTES : Biome.valueOf("NETHER"), "mushroom_nether.schem", 90.0, true @@ -50,6 +50,7 @@ public class Schematics { public static class SchematicConfig { public Item item; public Cost regenCost; + public int minLevel; public double xHome; public double yHome; public double zHome; diff --git a/src/main/java/com/iridium/iridiumskyblock/database/Island.java b/src/main/java/com/iridium/iridiumskyblock/database/Island.java index c46078643..03458b65f 100644 --- a/src/main/java/com/iridium/iridiumskyblock/database/Island.java +++ b/src/main/java/com/iridium/iridiumskyblock/database/Island.java @@ -38,23 +38,7 @@ public Island(int id) { @Override public int getLevel() { - - if(!IridiumSkyblock.getInstance().getConfiguration().enableLeveling) return 1; - - if (!IridiumSkyblock.getInstance().getConfiguration().isLevelExponential) { - if (IridiumSkyblock.getInstance().getConfiguration().flatExpRequirement != 0) - return Math.abs(getExperience() / IridiumSkyblock.getInstance().getConfiguration().flatExpRequirement); - - return getExperience(); - } - - if (IridiumSkyblock.getInstance().getConfiguration().flatExpRequirement != 0) { - return Math.abs((int) Math.floor(Math.pow( - getExperience() / (double) IridiumSkyblock.getInstance().getConfiguration().flatExpRequirement, - IridiumSkyblock.getInstance().getConfiguration().curvedExpModifier) + 1)); - } - - return Math.abs((int) Math.floor(Math.pow(getExperience(), IridiumSkyblock.getInstance().getConfiguration().curvedExpModifier) + 1)); + return IridiumSkyblock.getInstance().getIslandManager().getTeamLevel(this.getExperience()); } @Override diff --git a/src/main/java/com/iridium/iridiumskyblock/managers/BiomeManager.java b/src/main/java/com/iridium/iridiumskyblock/managers/BiomeManager.java index 05c6e6771..cd4357b0e 100644 --- a/src/main/java/com/iridium/iridiumskyblock/managers/BiomeManager.java +++ b/src/main/java/com/iridium/iridiumskyblock/managers/BiomeManager.java @@ -78,6 +78,24 @@ private void setBankBalance(Player player, String bankItem, double amount) { } private boolean canPurchase(Player player, Biomes.BiomeItem biomeItem) { + + if(biomeItem.minLevel != 1) { + User user = IridiumSkyblock.getInstance().getUserManager().getUser(player); + Optional island = IridiumSkyblock.getInstance().getIslandManager().getTeamViaID(user.getTeamID()); + + if(!island.isPresent()) { + player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().dontHaveTeam + .replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix))); + return false; + } + + if(biomeItem.minLevel < island.get().getLevel()) { + player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().notHighEnoughLevel + .replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix))); + return false; + } + } + double moneyCost = biomeItem.buyCost.money; Economy economy = IridiumSkyblock.getInstance().getEconomy(); for (String bankItem : biomeItem.buyCost.bankItems.keySet()) { diff --git a/src/main/java/com/iridium/iridiumskyblock/managers/IslandManager.java b/src/main/java/com/iridium/iridiumskyblock/managers/IslandManager.java index 7509bd780..765ff0690 100644 --- a/src/main/java/com/iridium/iridiumskyblock/managers/IslandManager.java +++ b/src/main/java/com/iridium/iridiumskyblock/managers/IslandManager.java @@ -174,9 +174,11 @@ 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)) { - return null; + if(IridiumSkyblock.getInstance().getConfiguration().islandCreationCost) { + if (schematicConfig.regenCost.money != 0 || !schematicConfig.regenCost.bankItems.isEmpty()) { + if (!IridiumSkyblock.getInstance().getSchematicManager().buy(owner, schematicConfig)) { + return null; + } } } diff --git a/src/main/java/com/iridium/iridiumskyblock/placeholders/IslandPlaceholderBuilder.java b/src/main/java/com/iridium/iridiumskyblock/placeholders/IslandPlaceholderBuilder.java index 84b8f423a..37092d492 100644 --- a/src/main/java/com/iridium/iridiumskyblock/placeholders/IslandPlaceholderBuilder.java +++ b/src/main/java/com/iridium/iridiumskyblock/placeholders/IslandPlaceholderBuilder.java @@ -49,6 +49,8 @@ public List getPlaceholders(Island island) { 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_experienceToLevelUp", String.valueOf(IridiumSkyblock.getInstance().getIslandManager().getTeamExperienceForNextLevel(island))), + new Placeholder("island_experienceForNextLevel", String.valueOf(IridiumSkyblock.getInstance().getIslandManager().getExperienceForLevel(island.getLevel() + 1))), 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)), From c6348a5e56d2187daf941da7b0cd22cfdfaa7191 Mon Sep 17 00:00:00 2001 From: Shyanne Date: Sun, 3 Mar 2024 01:46:14 -0500 Subject: [PATCH 5/8] small fixes --- .../commands/RegenCommand.java | 3 ++- .../managers/BiomeManager.java | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/iridium/iridiumskyblock/commands/RegenCommand.java b/src/main/java/com/iridium/iridiumskyblock/commands/RegenCommand.java index 941dbf039..4a0f985b6 100644 --- a/src/main/java/com/iridium/iridiumskyblock/commands/RegenCommand.java +++ b/src/main/java/com/iridium/iridiumskyblock/commands/RegenCommand.java @@ -56,7 +56,8 @@ public boolean execute(User user, Island island, String[] args, IridiumTeams biomeOptional = XBiome.matchXBiome(biomeItem.biome.toString()); if (!canPurchase(player, biomeItem)) { - player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().cannotAfford - .replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix) - )); IridiumSkyblock.getInstance().getBiomes().failSound.play(player); return; } @@ -89,13 +86,14 @@ private boolean canPurchase(Player player, Biomes.BiomeItem biomeItem) { return false; } - if(biomeItem.minLevel < island.get().getLevel()) { + if(island.get().getLevel() < biomeItem.minLevel) { player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().notHighEnoughLevel - .replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix))); + .replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix) + .replace("%level%", String.valueOf(biomeItem.minLevel)))); return false; } } - + double moneyCost = biomeItem.buyCost.money; Economy economy = IridiumSkyblock.getInstance().getEconomy(); for (String bankItem : biomeItem.buyCost.bankItems.keySet()) { @@ -103,7 +101,14 @@ private boolean canPurchase(Player player, Biomes.BiomeItem biomeItem) { if (getBankBalance(player, bankItem) < cost) return false; } - return moneyCost == 0 || economy != null && economy.getBalance(player) >= moneyCost; + if(!(moneyCost == 0 || economy != null && economy.getBalance(player) >= moneyCost)) { + player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().cannotAfford + .replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix) + )); + return false; + } + + return true; } private void purchase(Player player, Biomes.BiomeItem biomeItem) { From 28800ec512c8429fa04a744da208026b4d7a5c8f Mon Sep 17 00:00:00 2001 From: Shyanne Date: Sun, 3 Mar 2024 13:26:48 -0500 Subject: [PATCH 6/8] Fixed bank placeholders and GUIs --- .../iridiumskyblock/configs/Biomes.java | 1 + .../iridiumskyblock/configs/Enhancements.java | 9 ++- .../iridiumskyblock/configs/Schematics.java | 3 + .../iridiumskyblock/gui/BiomeCategoryGUI.java | 7 ++- .../iridiumskyblock/gui/SchematicGUI.java | 57 ++++++++++++++++++- .../managers/SchematicManager.java | 8 +++ 6 files changed, 78 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/iridium/iridiumskyblock/configs/Biomes.java b/src/main/java/com/iridium/iridiumskyblock/configs/Biomes.java index 90a5e0286..af3197447 100644 --- a/src/main/java/com/iridium/iridiumskyblock/configs/Biomes.java +++ b/src/main/java/com/iridium/iridiumskyblock/configs/Biomes.java @@ -111,6 +111,7 @@ public class Biomes { .build(); public String buyPriceLore = "&aBuy Price: $%vault_cost%"; public String notPurchasableLore = "&cThis item cannot be purchased!"; + public String levelRequirementLore = "&9[!] &7Must be level %level% to purchase"; public boolean abbreviatePrices = true; public XSound failSound = XSound.BLOCK_ANVIL_LAND; public XSound successSound = XSound.ENTITY_PLAYER_LEVELUP; diff --git a/src/main/java/com/iridium/iridiumskyblock/configs/Enhancements.java b/src/main/java/com/iridium/iridiumskyblock/configs/Enhancements.java index 50eff82e6..3b45d52f2 100644 --- a/src/main/java/com/iridium/iridiumskyblock/configs/Enhancements.java +++ b/src/main/java/com/iridium/iridiumskyblock/configs/Enhancements.java @@ -40,7 +40,7 @@ public Enhancements() { "&9&lInformation:", "&9&l * &7Current Level: &9%current_level%", "&9&l * &7Current Size: &9%size%x%size% Blocks", - "&9&l * &7Upgrade Cost: &9%cost%", + "&9&l * &7Upgrade Cost: &9%vault_cost%, %Crystals_cost% Island Crystals", "&9&lLevels:", "&9&l * &7Level 1: &950x50 Blocks", "&9&l * &7Level 2: &975x75 Blocks", @@ -48,6 +48,7 @@ public Enhancements() { "&9&l * &7Level 4: &9125x125 Blocks", "&9&l * &7Level 5: &9150x150 Blocks", "", + "&9[!] &7Must be level %minLevel% to purchase", "&9&l[!] " + "&9Left Click to Purchase Level %next_level%." )), new ImmutableMap.Builder() .put(0, new SizeEnhancementData(5, 10000, new ImmutableMap.Builder().put("Crystals", 5.00).build(), 50)) @@ -63,7 +64,7 @@ public Enhancements() { "", "&9&lInformation:", "&9&l * &7Current Level: &9%current_level%", - "&9&l * &7Upgrade Cost: &9%cost%", + "&9&l * &7Upgrade Cost: &9%vault_cost%, %Crystals_cost% Island Crystals", "&9&lLevels:", "&9&l * &7Level 1: &9No Void Teleport", "&9&l * &7Level 2: &9100% Item Loss", @@ -72,6 +73,7 @@ public Enhancements() { "&9&l * &7Level 5: &925% Item Loss", "&9&l * &7Level 6: &90% Item Loss", "", + "&9[!] &7Must be level %minLevel% to purchase", "&9&l[!] " + "&9Left Click to Purchase Level %next_level%." )), new ImmutableMap.Builder() .put(0, new VoidEnhancementData(5, 10000, new ImmutableMap.Builder().put("Crystals", 5.00).build(), true, 0.00)) @@ -83,8 +85,9 @@ public Enhancements() { "", "&9&lInformation:", "&9&l * &7Current Level: &9%current_level%", - "&9&l * &7Upgrade Cost: &9%cost%", + "&9&l * &7Upgrade Cost: &9%vault_cost%, %Crystals_cost% Island Crystals", "", + "&9[!] &7Must be level %minLevel% to purchase", "&9&l[!] " + "&9Left Click to Purchase Level %next_level%." )), new ImmutableMap.Builder() .put(0, new GeneratorEnhancementData(5, 10000, new ImmutableMap.Builder().put("Crystals", 5.00).build(), diff --git a/src/main/java/com/iridium/iridiumskyblock/configs/Schematics.java b/src/main/java/com/iridium/iridiumskyblock/configs/Schematics.java index 17021d1cc..f7e4d8fae 100644 --- a/src/main/java/com/iridium/iridiumskyblock/configs/Schematics.java +++ b/src/main/java/com/iridium/iridiumskyblock/configs/Schematics.java @@ -42,6 +42,9 @@ public class Schematics { ))) .build(); public boolean abbreviatePrices = true; + public String buyPriceLore = "&9Buy Price: &7%vault_cost%"; + public String levelRequirementLore = "&9[!] &7Must be level %level% to purchase"; + public String regenDisclaimer = "&9[!] &7Applies to regeneration only"; public XSound failSound = XSound.BLOCK_ANVIL_LAND; public XSound successSound = XSound.ENTITY_PLAYER_LEVELUP; diff --git a/src/main/java/com/iridium/iridiumskyblock/gui/BiomeCategoryGUI.java b/src/main/java/com/iridium/iridiumskyblock/gui/BiomeCategoryGUI.java index eabd13579..c6ecbd5c0 100644 --- a/src/main/java/com/iridium/iridiumskyblock/gui/BiomeCategoryGUI.java +++ b/src/main/java/com/iridium/iridiumskyblock/gui/BiomeCategoryGUI.java @@ -5,6 +5,7 @@ import com.iridium.iridiumcore.utils.StringUtils; import com.iridium.iridiumskyblock.IridiumSkyblock; import com.iridium.iridiumskyblock.configs.Biomes; +import com.iridium.iridiumskyblock.configs.Schematics; import com.iridium.iridiumteams.configs.inventories.NoItemGUI; import lombok.Getter; import org.bukkit.Bukkit; @@ -61,7 +62,7 @@ public void addContent(Inventory inventory) { private List getBiomeLorePlaceholders(Biomes.BiomeItem item) { List placeholders = new ArrayList<>(Arrays.asList( - new Placeholder("amount", IridiumSkyblock.getInstance().getBiomeManager().formatPrice(item.defaultAmount)), + new Placeholder("minLevel", String.valueOf(item.minLevel)), new Placeholder("vault_cost", IridiumSkyblock.getInstance().getBiomeManager().formatPrice(item.buyCost.money)) )); for (Map.Entry bankItem : item.buyCost.bankItems.entrySet()) { @@ -80,6 +81,10 @@ private List getBiomeLore(Biomes.BiomeItem item) { lore.add(IridiumSkyblock.getInstance().getBiomes().notPurchasableLore); } + if(item.minLevel != 1){ + lore.add(IridiumSkyblock.getInstance().getBiomes().levelRequirementLore); + } + lore.addAll(IridiumSkyblock.getInstance().getBiomes().biomeItemLore); return StringUtils.color(StringUtils.processMultiplePlaceholders(lore, placeholders)); diff --git a/src/main/java/com/iridium/iridiumskyblock/gui/SchematicGUI.java b/src/main/java/com/iridium/iridiumskyblock/gui/SchematicGUI.java index 12f2e8ef1..9499e5506 100644 --- a/src/main/java/com/iridium/iridiumskyblock/gui/SchematicGUI.java +++ b/src/main/java/com/iridium/iridiumskyblock/gui/SchematicGUI.java @@ -3,17 +3,27 @@ import com.iridium.iridiumcore.gui.BackGUI; import com.iridium.iridiumcore.utils.InventoryUtils; import com.iridium.iridiumcore.utils.ItemStackUtils; +import com.iridium.iridiumcore.utils.Placeholder; import com.iridium.iridiumcore.utils.StringUtils; import com.iridium.iridiumskyblock.IridiumSkyblock; import com.iridium.iridiumskyblock.configs.Schematics; +import com.iridium.iridiumskyblock.database.User; +import com.iridium.iridiumteams.bank.BankItem; +import com.iridium.iridiumteams.configs.Shop; import com.iridium.iridiumteams.configs.inventories.NoItemGUI; +import com.iridium.iridiumteams.database.TeamBank; import org.bukkit.Bukkit; +import org.bukkit.entity.Player; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; import org.jetbrains.annotations.NotNull; -import java.util.HashMap; -import java.util.Map; +import java.util.*; +import java.util.stream.Collectors; + +import static java.util.Collections.addAll; public abstract class SchematicGUI extends BackGUI { @@ -39,8 +49,49 @@ public void addContent(Inventory inventory) { super.addContent(inventory); for (Map.Entry entry : IridiumSkyblock.getInstance().getSchematics().schematics.entrySet()) { - inventory.setItem(entry.getValue().item.slot, ItemStackUtils.makeItem(entry.getValue().item)); + + ItemStack itemStack = ItemStackUtils.makeItem(entry.getValue().item); + ItemMeta itemMeta = itemStack.getItemMeta(); + + itemMeta.setLore(getSchematicLore(entry.getValue())); + + itemStack.setItemMeta(itemMeta); + inventory.setItem(entry.getValue().item.slot, itemStack); + } + } + + private List getSchematicLore(Schematics.SchematicConfig item) { + List lore = new ArrayList<>(); + List placeholders = getSchematicLorePlaceholders(item); + + lore.addAll(item.item.lore); + + if (item.regenCost.canPurchase()) { + lore.add(String.valueOf(IridiumSkyblock.getInstance().getSchematics().buyPriceLore)); } + + if(item.minLevel != 1) { + lore.add(IridiumSkyblock.getInstance().getSchematics().levelRequirementLore); + } + + if(!IridiumSkyblock.getInstance().getConfiguration().islandCreationCost) { + lore.add(IridiumSkyblock.getInstance().getSchematics().regenDisclaimer); + } + + return StringUtils.color(StringUtils.processMultiplePlaceholders(lore, placeholders)); + } + + private List getSchematicLorePlaceholders(Schematics.SchematicConfig item) { + List placeholders = new ArrayList<>(Arrays.asList( + new Placeholder("vault_cost", IridiumSkyblock.getInstance().getSchematicManager().formatPrice(item.regenCost.money)), + new Placeholder("level", String.valueOf(item.minLevel)) + )); + + for (Map.Entry bankItem : item.regenCost.bankItems.entrySet()) { + placeholders.add(new Placeholder(bankItem.getKey() + "_cost", IridiumSkyblock.getInstance().getSchematicManager().formatPrice(bankItem.getValue()))); + } + + return placeholders; } @Override diff --git a/src/main/java/com/iridium/iridiumskyblock/managers/SchematicManager.java b/src/main/java/com/iridium/iridiumskyblock/managers/SchematicManager.java index 27398b4d4..dacb6dc27 100644 --- a/src/main/java/com/iridium/iridiumskyblock/managers/SchematicManager.java +++ b/src/main/java/com/iridium/iridiumskyblock/managers/SchematicManager.java @@ -177,4 +177,12 @@ private void purchase(Player player, Schematics.SchematicConfig schematic) { } IridiumSkyblock.getInstance().getSchematics().successSound.play(player); } + + public String formatPrice(double value) { + if (IridiumSkyblock.getInstance().getSchematics().abbreviatePrices) { + return IridiumSkyblock.getInstance().getConfiguration().numberFormatter.format(value); + } + return String.valueOf(value); + } + } From a595dae95f2368f7b79b5549ca628d4a312bd34c Mon Sep 17 00:00:00 2001 From: Shyanne Date: Sat, 18 May 2024 23:33:18 -0400 Subject: [PATCH 7/8] switch to > instead of != for level min Co-authored-by: Peaches_MLG --- .../java/com/iridium/iridiumskyblock/managers/BiomeManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iridium/iridiumskyblock/managers/BiomeManager.java b/src/main/java/com/iridium/iridiumskyblock/managers/BiomeManager.java index 44fc1f3fc..008f67aea 100644 --- a/src/main/java/com/iridium/iridiumskyblock/managers/BiomeManager.java +++ b/src/main/java/com/iridium/iridiumskyblock/managers/BiomeManager.java @@ -76,7 +76,7 @@ private void setBankBalance(Player player, String bankItem, double amount) { private boolean canPurchase(Player player, Biomes.BiomeItem biomeItem) { - if(biomeItem.minLevel != 1) { + if(biomeItem.minLevel > 1) { User user = IridiumSkyblock.getInstance().getUserManager().getUser(player); Optional island = IridiumSkyblock.getInstance().getIslandManager().getTeamViaID(user.getTeamID()); From 4a673ad7bd96593d5cd83161db59e41fdc79d9ca Mon Sep 17 00:00:00 2001 From: Peaches_MLG Date: Mon, 10 Jun 2024 18:18:36 +0100 Subject: [PATCH 8/8] Changes --- .../iridiumskyblock/gui/BiomeCategoryGUI.java | 2 +- .../iridium/iridiumskyblock/gui/SchematicGUI.java | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/iridium/iridiumskyblock/gui/BiomeCategoryGUI.java b/src/main/java/com/iridium/iridiumskyblock/gui/BiomeCategoryGUI.java index c6ecbd5c0..a5445f8f4 100644 --- a/src/main/java/com/iridium/iridiumskyblock/gui/BiomeCategoryGUI.java +++ b/src/main/java/com/iridium/iridiumskyblock/gui/BiomeCategoryGUI.java @@ -81,7 +81,7 @@ private List getBiomeLore(Biomes.BiomeItem item) { lore.add(IridiumSkyblock.getInstance().getBiomes().notPurchasableLore); } - if(item.minLevel != 1){ + if(item.minLevel > 1){ lore.add(IridiumSkyblock.getInstance().getBiomes().levelRequirementLore); } diff --git a/src/main/java/com/iridium/iridiumskyblock/gui/SchematicGUI.java b/src/main/java/com/iridium/iridiumskyblock/gui/SchematicGUI.java index 9499e5506..1c8003f8d 100644 --- a/src/main/java/com/iridium/iridiumskyblock/gui/SchematicGUI.java +++ b/src/main/java/com/iridium/iridiumskyblock/gui/SchematicGUI.java @@ -53,28 +53,30 @@ public void addContent(Inventory inventory) { ItemStack itemStack = ItemStackUtils.makeItem(entry.getValue().item); ItemMeta itemMeta = itemStack.getItemMeta(); - itemMeta.setLore(getSchematicLore(entry.getValue())); + if (itemMeta != null) { + itemMeta.setLore(getSchematicLore(entry.getValue())); + + itemStack.setItemMeta(itemMeta); + } - itemStack.setItemMeta(itemMeta); inventory.setItem(entry.getValue().item.slot, itemStack); } } private List getSchematicLore(Schematics.SchematicConfig item) { - List lore = new ArrayList<>(); List placeholders = getSchematicLorePlaceholders(item); - lore.addAll(item.item.lore); + List lore = new ArrayList<>(item.item.lore); if (item.regenCost.canPurchase()) { lore.add(String.valueOf(IridiumSkyblock.getInstance().getSchematics().buyPriceLore)); } - if(item.minLevel != 1) { + if (item.minLevel > 1) { lore.add(IridiumSkyblock.getInstance().getSchematics().levelRequirementLore); } - if(!IridiumSkyblock.getInstance().getConfiguration().islandCreationCost) { + if (!IridiumSkyblock.getInstance().getConfiguration().islandCreationCost) { lore.add(IridiumSkyblock.getInstance().getSchematics().regenDisclaimer); }