Skip to content

Commit

Permalink
Added More Level Features
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
sh0inx committed Mar 3, 2024
1 parent 1c3f686 commit faaf0c9
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ public boolean execute(User user, Island island, String[] args, IridiumTeams<Isl

Schematics.SchematicConfig schematicConfig = IridiumSkyblock.getInstance().getSchematics().schematics.get(schematic.get());

if(island.getLevel() < schematicConfig.minLevel) {
player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().notHighEnoughLevel
.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
return false;
}

if (schematicConfig.regenCost.money != 0 || !schematicConfig.regenCost.bankItems.isEmpty()) {
if (!IridiumSkyblock.getInstance().getSchematicManager().buy(player, schematicConfig)) {
return false;
Expand Down
33 changes: 22 additions & 11 deletions src/main/java/com/iridium/iridiumskyblock/configs/Biomes.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,26 @@ public class Biomes {
XBiome.PLAINS,
1,
11,
new Cost(100, new HashMap<>())
new Cost(100, new HashMap<>()),
1
),
new BiomeItem(
"&9&lSnowy Plains",
XMaterial.SNOW_BLOCK,
XBiome.SNOWY_PLAINS,
1,
13,
new Cost(50, new HashMap<>())
new Cost(50, new HashMap<>()),
1
),
new BiomeItem(
"&9&lSavanna",
XMaterial.TALL_GRASS,
XBiome.SAVANNA,
1,
15,
new Cost(100, new HashMap<>())
new Cost(100, new HashMap<>()),
1
)
))
.put("Nether", Arrays.asList(
Expand All @@ -52,23 +55,26 @@ public class Biomes {
XBiome.NETHER_WASTES,
1,
11,
new Cost(50, new HashMap<>())
new Cost(50, new HashMap<>()),
1
),
new BiomeItem(
"&9&lCrimson Forest",
XMaterial.CRIMSON_NYLIUM,
XBiome.CRIMSON_FOREST,
1,
13,
new Cost(1000, new HashMap<>())
new Cost(1000, new HashMap<>()),
1
),
new BiomeItem(
"&9&lWarped Forest",
XMaterial.WARPED_NYLIUM,
XBiome.WARPED_FOREST,
1,
15,
new Cost(100, new HashMap<>())
new Cost(100, new HashMap<>()),
1
)
)
)
Expand All @@ -79,24 +85,27 @@ public class Biomes {
XBiome.THE_END,
1,
11,
new Cost(100, new HashMap<>())
new Cost(100, new HashMap<>()),
1
),
new BiomeItem(
"&9&lEnd Highlands",
XMaterial.PURPUR_BLOCK,
XBiome.END_HIGHLANDS,
1,
13,
new Cost(150, new HashMap<>())
new Cost(150, new HashMap<>()),
1
),
new BiomeItem(
"&9&lEnd Barrens",
XMaterial.ENDER_EYE,
XBiome.END_BARRENS,
1,
15,
new Cost(150, new HashMap<>())
)
new Cost(150, new HashMap<>()),
1
)
)
)
.build();
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/com/iridium/iridiumskyblock/configs/Missions.java
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ public class Schematics {

public Map<String, SchematicConfig> schematics = ImmutableMap.<String, SchematicConfig>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
), new SchematicWorld(Biome.THE_END,
"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
), new SchematicWorld(Biome.THE_END,
"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
Expand All @@ -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;
Expand Down
18 changes: 1 addition & 17 deletions src/main/java/com/iridium/iridiumskyblock/database/Island.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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> 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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,11 @@ public CompletableFuture<Island> 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;
}
}
}

Expand Down
Loading

0 comments on commit faaf0c9

Please sign in to comment.