Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented Biome Shop #719

Merged
merged 11 commits into from
Sep 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group = "com.iridium"
version = "4.0.3"
version = "4.0.4-BETA-1"
description = "IridiumSkyblock"

repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class IridiumSkyblock extends IridiumTeams<Island, User> {
private Missions missions;
private Schematics schematics;
private Shop shop;
private Biomes biomes;
private Settings settings;

private IslandPlaceholderBuilder teamsPlaceholderBuilder;
Expand All @@ -61,6 +62,7 @@ public class IridiumSkyblock extends IridiumTeams<Island, User> {
private MissionManager<Island, User> missionManager;
private SchematicManager schematicManager;
private ShopManager<Island, User> shopManager;
private BiomeManager<Island, User> biomeManager;

private Economy economy;

Expand Down Expand Up @@ -97,6 +99,7 @@ public void onEnable() {
this.databaseManager = new DatabaseManager();
this.missionManager = new MissionManager<>(this);
this.shopManager = new ShopManager<>(this);
this.biomeManager = new BiomeManager<>(this);
try {
databaseManager.init();
} catch (SQLException exception) {
Expand Down Expand Up @@ -156,6 +159,7 @@ public void loadConfigs() {
this.missions = getPersist().load(Missions.class);
this.schematics = getPersist().load(Schematics.class);
this.shop = getPersist().load(Shop.class);
this.biomes = getPersist().load(Biomes.class);
this.settings = getPersist().load(Settings.class);
super.loadConfigs();

Expand Down Expand Up @@ -189,6 +193,7 @@ public void saveConfigs() {
getPersist().save(missions);
getPersist().save(schematics);
getPersist().save(shop);
getPersist().save(biomes);
getPersist().save(settings);
saveSchematics();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.iridium.iridiumskyblock.commands;

import com.iridium.iridiumcore.utils.StringUtils;
import com.iridium.iridiumskyblock.IridiumSkyblock;
import com.iridium.iridiumskyblock.database.Island;
import com.iridium.iridiumskyblock.database.User;
import com.iridium.iridiumskyblock.gui.BiomeCategoryGUI;
import com.iridium.iridiumskyblock.gui.BiomeOverviewGUI;
import com.iridium.iridiumteams.IridiumTeams;
import com.iridium.iridiumteams.commands.Command;
import org.bukkit.entity.Player;

import java.util.Arrays;
import java.util.Collections;
import java.util.Optional;

public class BiomeCommand extends Command<Island, User> {

public BiomeCommand() {
super(Collections.singletonList("biomes"), "Refresh your Island Biome", "%prefix% &7/is biomes <biome>", "");
}

@Override
public void execute(User user, String[] args, IridiumTeams<Island, User> iridiumTeams) {
Player player = user.getPlayer();
if(args.length == 0){
player.openInventory(new BiomeOverviewGUI(player.getOpenInventory().getTopInventory(), IridiumSkyblock.getInstance()).getInventory());
}else{
String[] commandArguments = Arrays.copyOfRange(args, 0, args.length);
Optional<String> categoryName = getCategoryName(String.join(" ", commandArguments), IridiumSkyblock.getInstance());

if (!categoryName.isPresent()) {
player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().noBiomeCategory
.replace("%prefix%", iridiumTeams.getConfiguration().prefix)
));
return;
}

player.openInventory(new BiomeCategoryGUI<>(categoryName.get(), player.getOpenInventory().getTopInventory(), IridiumSkyblock.getInstance()).getInventory());
}
}

private Optional<String> getCategoryName(String name, IridiumSkyblock iridiumSkyblock){
for(String category : iridiumSkyblock.getBiomes().categories.keySet()){
if(category.equalsIgnoreCase(name)){
return Optional.of(category);
}
}
return Optional.empty();
}
}
186 changes: 186 additions & 0 deletions src/main/java/com/iridium/iridiumskyblock/configs/Biomes.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
package com.iridium.iridiumskyblock.configs;

import com.google.common.collect.ImmutableMap;
import com.iridium.iridiumcore.Item;
import com.iridium.iridiumcore.dependencies.fasterxml.annotation.JsonIgnore;
import com.iridium.iridiumcore.dependencies.xseries.XBiome;
import com.iridium.iridiumcore.dependencies.xseries.XMaterial;
import com.iridium.iridiumcore.dependencies.xseries.XSound;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;

import java.util.*;

public class Biomes {

public Map<String, BiomeCategory> categories;
public Map<String, List<BiomeItem>> items;
public String buyPriceLore;
public String notPurchasableLore;
public boolean abbreviatePrices;
public XSound failSound;
public XSound successSound;
public List<String> biomeItemLore;

public Biomes() {
this("&c");
}

public Biomes(String color) {
PeachesMLG marked this conversation as resolved.
Show resolved Hide resolved
categories = ImmutableMap.<String, BiomeCategory>builder()
.put("Overworld", new BiomeCategory(new Item(XMaterial.GRASS_BLOCK, 20, 1, color + "&lOverworld", Collections.emptyList()), 54))
.put("Nether", new BiomeCategory(new Item(XMaterial.CRIMSON_NYLIUM, 22, 1, color + "&lNether", Collections.emptyList()), 36))
.put("End", new BiomeCategory(new Item(XMaterial.END_STONE, 24, 1, color + "&lEnd", Collections.emptyList()), 36))
.build();

items = ImmutableMap.<String, List<BiomeItem>>builder()
.put("Overworld", Arrays.asList(
new BiomeItem(
color + "&lPlains",
XMaterial.GRASS_BLOCK,
XBiome.PLAINS,
"",
1,
20,
new Cost(100, new HashMap<>())
),
new BiomeItem(
color + "&lSnowy Plains",
XMaterial.SNOW_BLOCK,
XBiome.SNOWY_PLAINS,
"",
1,
22,
new Cost(50, new HashMap<>())
),
new BiomeItem(
color + "&lSavanna",
XMaterial.TALL_GRASS,
XBiome.SAVANNA,
"",
1,
24,
new Cost(100, new HashMap<>())
)
))
.put("Nether", Arrays.asList(
new BiomeItem(
color + "&lNether Wastes",
XMaterial.NETHERRACK,
XBiome.NETHER_WASTES,
"",
1,
20,
new Cost(50, new HashMap<>())
),
new BiomeItem(
color + "&lCrimson Forest",
XMaterial.CRIMSON_NYLIUM,
XBiome.CRIMSON_FOREST,
"",
1,
22,
new Cost(1000, new HashMap<>())
),
new BiomeItem(
color + "&lWarped Forest",
XMaterial.WARPED_NYLIUM,
XBiome.WARPED_FOREST,
"",
1,
24,
new Cost(100, new HashMap<>())
)
)
)
.put("End", Arrays.asList(
new BiomeItem(
color + "&lTHE END",
XMaterial.END_STONE,
XBiome.THE_END,
"",
1,
20,
new Cost(100, new HashMap<>())
),
new BiomeItem(
color + "&lEnd Highlands",
XMaterial.PURPUR_BLOCK,
XBiome.END_HIGHLANDS,
"",
1,
22,
new Cost(150, new HashMap<>())
),
new BiomeItem(
color + "&lEnd Barrens",
XMaterial.ENDER_EYE,
XBiome.END_BARRENS,
"",
1,
24,
new Cost(150, new HashMap<>())
)
)
)
.build();

buyPriceLore = "&aBuy Price: $%vault_cost%";
notPurchasableLore = "&cThis item cannot be purchased!";

abbreviatePrices = true;

failSound = XSound.BLOCK_ANVIL_LAND;
successSound = XSound.ENTITY_PLAYER_LEVELUP;

biomeItemLore = Arrays.asList(
color + "&l[!] " + color + "Left-Click to Purchase"
);
}

@NoArgsConstructor
@AllArgsConstructor
public static class BiomeCategory {
public Item item;
public int inventorySize;
}

@NoArgsConstructor
@AllArgsConstructor
public static class BiomeItem {
public String name;
public XMaterial type;
public XBiome biome;
public List<String> lore;
public String command;
public int defaultAmount;
public int slot;
public int page;
public Cost buyCost;

public BiomeItem(String name, XMaterial type, XBiome biome, String command, int defaultAmount, int slot, Cost buyCost) {
this.name = name;
this.type = type;
this.biome = biome;
this.lore = Collections.emptyList();
this.command = command;
this.defaultAmount = defaultAmount;
this.slot = slot;
this.page = 1;
this.buyCost = buyCost;
}
}

@AllArgsConstructor
@NoArgsConstructor
public static class Cost {
public double money;
public Map<String, Double> bankItems;

@JsonIgnore
public boolean canPurchase() {
return money > 0 || bankItems.values().stream().anyMatch(value -> value > 0);
}
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.iridium.iridiumskyblock.configs;

import com.iridium.iridiumskyblock.commands.BiomeCommand;
import com.iridium.iridiumskyblock.commands.BorderCommand;
import com.iridium.iridiumskyblock.commands.RegenCommand;
import com.iridium.iridiumskyblock.commands.VisitCommand;
Expand All @@ -14,4 +15,5 @@ public Commands() {
public VisitCommand visitCommand = new VisitCommand();
public BorderCommand borderCommand = new BorderCommand();
public RegenCommand regenCommand = new RegenCommand();
public BiomeCommand biomeCommand = new BiomeCommand();
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import com.iridium.iridiumcore.dependencies.fasterxml.annotation.JsonIgnore;
import com.iridium.iridiumcore.dependencies.xseries.XMaterial;
import com.iridium.iridiumskyblock.configs.inventories.BorderInventoryConfig;
import com.iridium.iridiumskyblock.gui.BiomeCategoryGUI;
import com.iridium.iridiumskyblock.gui.BiomeOverviewGUI;
import com.iridium.iridiumteams.configs.inventories.InventoryConfig;
import com.iridium.iridiumteams.configs.inventories.NoItemGUI;
import com.iridium.iridiumteams.configs.inventories.SingleItemGUI;
Expand Down Expand Up @@ -42,6 +44,7 @@ public class Inventories extends com.iridium.iridiumteams.configs.Inventories {
.put("is boosters", new Item(XMaterial.EXPERIENCE_BOTTLE, 23, 1, "&9&lIsland Boosters", Collections.singletonList("&7View your island boosters")))
.put("is home", new Item(XMaterial.WHITE_BED, 13, 1, "&9&lIsland Home", Collections.singletonList("&7Teleport to your island home")))
.put("is members", new Item(XMaterial.PLAYER_HEAD, 14, 1, "&9&lIsland Members", "Peaches_MLG", Collections.singletonList("&7View your island members")))
.put("is biomes", new Item(XMaterial.GRASS_BLOCK, 15, 1, "&9&lIsland Biomes", Collections.singletonList("&7Change your island biome")))
PeachesMLG marked this conversation as resolved.
Show resolved Hide resolved
.put("is warps", new Item(XMaterial.END_PORTAL_FRAME, 20, 1, "&9&lIsland Warps", Collections.singletonList("&7View your island warps")))
.put("is upgrades", new Item(XMaterial.DIAMOND, 21, 1, "&9&lIsland Upgrades", Collections.singletonList("&7View your island upgrades")))
.put("is missions", new Item(XMaterial.IRON_SWORD, 22, 1, "&9&lIsland Missions", Collections.singletonList("&7View your island missions")))
Expand All @@ -59,6 +62,8 @@ public class Inventories extends com.iridium.iridiumteams.configs.Inventories {
)));

public NoItemGUI islandSchematicGUI = new NoItemGUI(27, "&7Select a Schematic", background2);
public NoItemGUI biomeOverviewGUI = new NoItemGUI(54, "Biomes", background1);
public NoItemGUI biomeCategoryGUI = new NoItemGUI(54, "Biomes - %biome_category_name%", background2);

public Inventories() {
super("Island", "&9");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@ public Messages() {
public String unknownSchematic = "%prefix% &7No schematic with that name exists.";
public String noSafeLocation = "%prefix% &7Could not find a safe location to teleport to.";
public String cannotHurtPlayers = "%prefix% &7You cannot hurt players on your Island.";
public String notOnIsland = "%prefix% &7You must be on your island to perform this operation.";
public String noBiomeCategory = "%prefix% &7No biome category with that name.";
public String noBiome = "%prefix% &7No biome with that name.";
public String changedBiome = "%prefix% &7Successfully changed Island biome to %biome%.";
public String boughtBiome = "%prefix% &7Successfully bought the %biome% biome for %vault_cost%.";
}
Loading