Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
convert last menu to inventory holders
- Loading branch information
1 parent
7c30648
commit 6948ec4
Showing
5 changed files
with
74 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
paper/src/main/java/com/badbones69/crazyenchantments/paper/api/builders/types/ShopMenu.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.badbones69.crazyenchantments.paper.api.builders.types; | ||
|
||
import com.badbones69.crazyenchantments.paper.Starter; | ||
import com.badbones69.crazyenchantments.paper.api.builders.InventoryBuilder; | ||
import com.badbones69.crazyenchantments.paper.api.economy.Currency; | ||
import com.badbones69.crazyenchantments.paper.api.economy.CurrencyAPI; | ||
import com.badbones69.crazyenchantments.paper.api.managers.ShopManager; | ||
import com.badbones69.crazyenchantments.paper.api.objects.other.ItemBuilder; | ||
import org.bukkit.entity.Player; | ||
import org.jetbrains.annotations.NotNull; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class ShopMenu extends InventoryBuilder { | ||
|
||
@NotNull | ||
private final Starter starter = this.plugin.getStarter(); | ||
|
||
@NotNull | ||
private final CurrencyAPI currencyAPI = this.starter.getCurrencyAPI(); | ||
|
||
private final ShopManager shopManager = this.starter.getShopManager(); | ||
|
||
public ShopMenu(Player player, int size, String title) { | ||
super(player, size, title); | ||
} | ||
|
||
@Override | ||
public InventoryBuilder build() { | ||
HashMap<String, String> placeholders = new HashMap<>(); | ||
|
||
for (Currency currency : Currency.values()) { | ||
placeholders.put("%" + currency.getName() + "%", String.valueOf(this.currencyAPI.getCurrency(getPlayer(), currency))); | ||
} | ||
|
||
for (Map.Entry<ItemBuilder, Integer> itemBuilders : this.shopManager.getCustomizerItems().entrySet()) { | ||
itemBuilders.getKey().setNamePlaceholders(placeholders).setLorePlaceholders(placeholders); | ||
getInventory().setItem(itemBuilders.getValue(), itemBuilders.getKey().build()); | ||
} | ||
|
||
this.shopManager.getShopItems().keySet().forEach(itemBuilder -> getInventory().setItem(this.shopManager.getShopItems().get(itemBuilder), itemBuilder.build())); | ||
|
||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters