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)),