Skip to content

Commit

Permalink
Implement last shinx modifications for 3.2.11
Browse files Browse the repository at this point in the history
  • Loading branch information
boiscljo committed Mar 24, 2023
1 parent 7b40ee9 commit 60e5592
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class Biomes {

public Map<String, BiomeCategoryConfig> categories = ImmutableMap.<String, BiomeCategoryConfig>builder()
.put("Overworld", new BiomeCategoryConfig(new Item(XMaterial.GRASS_BLOCK, 11, 1, "&9&lOverworld", Collections.emptyList()), 6))
.put("Nether", new BiomeCategoryConfig(new Item(XMaterial.CRIMSON_HYPHAE, 13, 1, "&9&lNether", Collections.emptyList()), 6))
.put("Nether", new BiomeCategoryConfig(new Item(XMaterial.NETHERRACK, 13, 1, "&9&lNether", Collections.emptyList()), 6))
.put("End", new BiomeCategoryConfig(new Item(XMaterial.END_STONE, 15, 1, "&9&lEnd", Collections.emptyList()), 6))
.build();

Expand Down
35 changes: 16 additions & 19 deletions src/main/java/com/iridium/iridiumskyblock/gui/BiomeCategoryGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import java.util.Optional;

/**
* GUI which shows all items in a {@link BiomeCategory} and allows players to purchase them.
* GUI which shows all biomes in a {@link BiomeCategory} and allows players to purchase them.
*/
public class BiomeCategoryGUI extends GUI {

Expand All @@ -28,7 +28,7 @@ public class BiomeCategoryGUI extends GUI {
/**
* The default constructor.
*
* @param category The category whose items should be displayed in this GUI
* @param category The category whose biomes should be displayed in this GUI
*/
public BiomeCategoryGUI(BiomeCategory category, Inventory previousInventory) {
super(previousInventory);
Expand All @@ -44,7 +44,7 @@ public BiomeCategoryGUI(BiomeCategory category, Inventory previousInventory) {
@Override
public Inventory getInventory() {
Inventory inventory = Bukkit.createInventory(this, category.size, StringUtils.color(IridiumSkyblock.getInstance().getBiomes().categoryTitle
.replace("%category_name%", category.name)
.replace("%biomecategory_name%", category.name)
));

Bukkit.getScheduler().runTaskAsynchronously(IridiumSkyblock.getInstance(), () -> addContent(inventory));
Expand All @@ -61,20 +61,20 @@ public void addContent(Inventory inventory) {

InventoryUtils.fillInventory(inventory, IridiumSkyblock.getInstance().getBiomes().categoryBackground);

for (BiomeItem item : category.items) {
ItemStack itemStack = item.item.parseItem();
for (BiomeItem biomeItem : category.items) {
ItemStack itemStack = biomeItem.item.parseItem();
ItemMeta itemMeta = itemStack.getItemMeta();

itemStack.setAmount(item.defaultAmount);
itemMeta.setDisplayName(StringUtils.color(item.name));
itemStack.setAmount(biomeItem.defaultAmount);
itemMeta.setDisplayName(StringUtils.color(biomeItem.name));

List<String> lore = item.lore == null ? new ArrayList<>() : new ArrayList<>(StringUtils.color(item.lore));
addBiomeLore(lore, item);
List<String> lore = biomeItem.lore == null ? new ArrayList<>() : new ArrayList<>(StringUtils.color(biomeItem.lore));
addBiomeLore(lore, biomeItem);

itemMeta.setLore(lore);
itemStack.setItemMeta(itemMeta);

inventory.setItem(item.slot, itemStack);
inventory.setItem(biomeItem.slot, itemStack);
}

if (IridiumSkyblock.getInstance().getConfiguration().backButtons && getPreviousInventory() != null) {
Expand Down Expand Up @@ -107,24 +107,21 @@ public void onInventoryClick(InventoryClickEvent event) {
}
}

private void addBiomeLore(List<String> lore, BiomeItem item) {
if (item.isPurchasable()) {
private void addBiomeLore(List<String> lore, BiomeItem biomeItem) {
if (biomeItem.isPurchasable()) {
lore.add(
StringUtils.color(IridiumSkyblock.getInstance().getBiomes().buyPriceLore
.replace("%amount%", String.valueOf(item.defaultAmount))
.replace("%buy_price_vault%", formatPrice(item.buyCost.vault))
.replace("%buy_price_crystals%", formatPrice(item.buyCost.crystals))
.replace("%amount%", String.valueOf(biomeItem.defaultAmount))
.replace("%buy_price_vault%", formatPrice(biomeItem.buyCost.vault))
.replace("%buy_price_crystals%", formatPrice(biomeItem.buyCost.crystals))
)
);
} else {
lore.add(StringUtils.color(IridiumSkyblock.getInstance().getBiomes().notPurchasableLore));
}

IridiumSkyblock.getInstance().getBiomes().biomeItemLore.stream()
.map(StringUtils::color)
.forEach(line -> lore.add(
line.replace("%amount%", String.valueOf(item.defaultAmount))
));
.map(StringUtils::color);
}

private String formatPrice(double value) {
Expand Down

0 comments on commit 60e5592

Please sign in to comment.