mirror of
https://github.com/darksaid98/Builders-Utilities.git
synced 2026-12-03 14:38:48 +00:00
Banner menu (WIP)
This commit is contained in:
1 parent
d455f46cc7
commit
58c9602594
4 files changed
+218
-238
No files matched your search
+39
-3
@@ -25,13 +25,22 @@
|
||||
|
||||
package net.arcaniax.buildersutilities.menus.bannermenus;
|
||||
|
||||
import net.arcaniax.buildersutilities.menus.Menus;
|
||||
import net.arcaniax.buildersutilities.menus.inv.ClickableItem;
|
||||
import net.arcaniax.buildersutilities.menus.inv.SmartInventory;
|
||||
import net.arcaniax.buildersutilities.menus.inv.content.InventoryContents;
|
||||
import net.arcaniax.buildersutilities.menus.inv.content.InventoryProvider;
|
||||
import net.arcaniax.buildersutilities.menus.inv.content.SlotPos;
|
||||
import net.arcaniax.buildersutilities.utils.BannerUtil;
|
||||
import net.arcaniax.buildersutilities.utils.Items;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BannerMenuProvider implements InventoryProvider {
|
||||
|
||||
private static final ItemStack grayPane = Items
|
||||
@@ -42,12 +51,27 @@ public class BannerMenuProvider implements InventoryProvider {
|
||||
// private static final ItemStack currentColor = BannerUtil.createBanner("&a", 1, DyeColor.WHITE, "");
|
||||
private static final ItemStack closeButton = Items
|
||||
.create(Material.BARRIER, (short) 0, 1, "&cClick to close", "");
|
||||
private static final ItemStack whiteBanner = Items
|
||||
.create(Material.WHITE_BANNER, (short) 0, 1, "&c", "");
|
||||
|
||||
@Override
|
||||
public void init(Player player, InventoryContents contents) {
|
||||
// for (int x = 0; x < 54; x++) {
|
||||
// contents.set(x / 9, x % 9, ClickableItem.empty(grayPane));
|
||||
// }
|
||||
contents.fillRect(0, 0, 5,8, ClickableItem.empty(grayPane));
|
||||
contents.set(0, 1, ClickableItem.of(randomizeHead, inventoryClickEvent -> selectRandomColor(player)));
|
||||
contents.set(0, 7, ClickableItem.empty(whiteBanner));
|
||||
contents.set(0, 7, ClickableItem.of(closeButton, inventoryClickEvent -> contents.inventory().close(player)));
|
||||
|
||||
int row = 2;
|
||||
int column = 1;
|
||||
for (DyeColor color : BannerUtil.allColors){
|
||||
contents.set(row, column, ClickableItem.of(BannerUtil.createBanner("&3" + color.toString().toLowerCase().replace("_", " "), color, "&7__&7click to select"), inventoryClickEvent -> selectColor(player, color)));
|
||||
column++;
|
||||
if (column==9){
|
||||
column = 1;
|
||||
row++;
|
||||
}
|
||||
}
|
||||
|
||||
// contents.set(0, 1, ClickableItem.of(randomizeHead, NULL));
|
||||
// contents.set(0, 4, ClickableItem.empty(currentColor));
|
||||
// contents.set(0, 7, ClickableItem.of(closeButton, inventoryClickEvent -> contents.inventory().close(player)));
|
||||
@@ -60,4 +84,16 @@ public class BannerMenuProvider implements InventoryProvider {
|
||||
// contents.set(x / 9, x % 9, ClickableItem.of(banner, NULL));
|
||||
// }
|
||||
}
|
||||
|
||||
private void selectRandomColor(Player player){
|
||||
Random random = new Random();
|
||||
DyeColor dyeColor = BannerUtil.allColors.get(random.nextInt(BannerUtil.allColors.size()-1));
|
||||
BannerUtil.currentBanner.put(player.getUniqueId(), BannerUtil.createBanner("&3" + dyeColor.toString().toLowerCase().replace("_", " "), dyeColor, "&7__&7click to select"));
|
||||
Menus.BANNER_MENU_COLOR.open(player);
|
||||
}
|
||||
|
||||
private void selectColor(Player player, DyeColor dyeColor){
|
||||
BannerUtil.currentBanner.put(player.getUniqueId(), BannerUtil.createBanner("&3" + dyeColor.toString().toLowerCase().replace("_", " "), dyeColor, "&7__&7click to select"));
|
||||
Menus.BANNER_MENU_COLOR.open(player);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user