lucky draw system with inventory redo
This commit is contained in:
parent
e64481bda0
commit
a54932f9c0
11 changed files with 328 additions and 105 deletions
|
@ -1,34 +1,24 @@
|
|||
package me.night.nullvalkyrie.commands;
|
||||
|
||||
import me.night.nullvalkyrie.entities.miners.CryptoMiner;
|
||||
import me.night.nullvalkyrie.enums.Items;
|
||||
import me.night.nullvalkyrie.util.RandomCollection;
|
||||
import org.bukkit.Material;
|
||||
import me.night.nullvalkyrie.ui.inventory.LuckyDraw;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BetaCommand extends Command {
|
||||
RandomCollection<String> randomCollection;
|
||||
|
||||
public BetaCommand() {
|
||||
super("beta", new String[]{"b", "npc"}, "Beta", "");
|
||||
randomCollection = new RandomCollection<>();
|
||||
for (Items e : Items.values()) {
|
||||
randomCollection.add(e.getWeight(), e.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandSender sender, String[] args) {
|
||||
if (sender instanceof Player player) {
|
||||
// String s = randomCollection.getRandom();
|
||||
// if (s == null) System.out.println("You have got all rewards from the draw");
|
||||
// System.out.println(s + " with the probability " + Math.round(randomCollection.getChance(s)));
|
||||
// randomCollection.remove(s);
|
||||
CryptoMiner miner = new CryptoMiner(args[0], Material.DIAMOND_ORE, 1, 0.5, System.currentTimeMillis());
|
||||
miner.spawn(player, "https://textures.minecraft.net/texture/c09cc3c75bd13c59602040b5970f30dbc76825c0e817da815a65d76ab0e82198");
|
||||
|
||||
// CryptoMiner miner = new CryptoMiner(args[0], Material.DIAMOND_ORE, 1, 0.5, System.currentTimeMillis());
|
||||
// miner.spawn(player, "https://textures.minecraft.net/texture/c09cc3c75bd13c59602040b5970f30dbc76825c0e817da815a65d76ab0e82198");
|
||||
new LuckyDraw().UI(player);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,19 +40,21 @@ public class CustomWeaponsDataManager {
|
|||
for (String a : attributes.keySet()) attr.put(a, attributes.get(a));
|
||||
Document pdc = (Document) doc.get("PDC");
|
||||
HashMap<String, Object> pdcdata = new HashMap<>();
|
||||
for (String i : pdc.keySet())
|
||||
pdcdata.put(i, pdc.get(i));
|
||||
if (pdc != null)
|
||||
for (String a : pdc.keySet()) pdcdata.put(a, pdc.get(a));
|
||||
Document recipe = (Document) doc.get("Recipes");
|
||||
HashMap<String, Object> recipes = new HashMap<>();
|
||||
Document ing = (Document) recipe.get("Ingredients");
|
||||
HashMap<String, String> ingredients = new HashMap<>();
|
||||
for (String i : ing.keySet())
|
||||
ingredients.put(i, ing.getString(i));
|
||||
List<String> shapes = new ArrayList<>();
|
||||
if (recipe.get("Shapes") != null) shapes.addAll((List<String>) recipe.get("Shapes"));
|
||||
recipes.put("Shape", shapes);
|
||||
recipes.put("Amount", recipe.getInteger("Amount"));
|
||||
recipes.put("Ingredients", ingredients);
|
||||
if (recipe != null) {
|
||||
Document ing = (Document) recipe.get("Ingredients");
|
||||
HashMap<String, String> ingredients = new HashMap<>();
|
||||
for (String i : ing.keySet())
|
||||
ingredients.put(i, ing.getString(i));
|
||||
List<String> shapes = new ArrayList<>();
|
||||
if (recipe.get("Shapes") != null) shapes.addAll((List<String>) recipe.get("Shapes"));
|
||||
recipes.put("Shape", shapes);
|
||||
recipes.put("Amount", recipe.getInteger("Amount"));
|
||||
recipes.put("Ingredients", ingredients);
|
||||
}
|
||||
item.put("Name", name);
|
||||
item.put("Material", Material.matchMaterial(doc.getString("Material")));
|
||||
item.put("Type", doc.getString("Type"));
|
||||
|
|
|
@ -1,26 +1,40 @@
|
|||
package me.night.nullvalkyrie.enums;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
public enum Items {
|
||||
|
||||
COAL("Coal", 27),
|
||||
IRON("Iron", 23),
|
||||
GOLD("Gold", 20),
|
||||
LAPIS("Lapis", 14),
|
||||
REDSTONE("Redstone", 10),
|
||||
EMERALD("Emerald", 6),
|
||||
QUARTZ("Quartz", 4),
|
||||
OBSIDIAN("Obsidian", 3),
|
||||
DIAMOND("Diamond", 2),
|
||||
NETHERITE("Netherite", 1);
|
||||
ETERNALSTARE("Eternal Stare", 29, Rarity.LEGENDARY, Material.COAL), // legendary charm
|
||||
MORNINGTEA("Morning Tea", 28, Rarity.EPIC, Material.IRON_INGOT), // epic emote
|
||||
PARACHUTE("Parachute - Doomed Chorus", 11, Rarity.EPIC, Material.GOLD_INGOT), // epic parachute
|
||||
RALLYCAR("Rally Car - Doomed Chorus", 10, Rarity.EPIC, Material.REDSTONE), //epic backpack
|
||||
WORLDAFLAME("World Aflame", 6.5, Rarity.LEGENDARY, Material.LAPIS_LAZULI), // legendary background
|
||||
MOLOTOVCOTAIL("Molotov Cotail - Soul Flame", 5.5, Rarity.EPIC, Material.COPPER_INGOT), // epic throwable
|
||||
KATANA("Katana - Silent Echo", 4.67, Rarity.EPIC, Material.EMERALD), // epic melee
|
||||
DLQ33("DL Q33 - Doomed Chorus", 4, Rarity.EPIC, Material.QUARTZ), // epic gun
|
||||
DAME("Dame - Shot Caller", 1.25, Rarity.EPIC, Material.DIAMOND), // character epic
|
||||
KILO141("Kilo 141 - Demonsong", 0.08, Rarity.LEGENDARY, Material.NETHERITE_INGOT); // weapon legendary
|
||||
|
||||
private final String name;
|
||||
private final double weight;
|
||||
private final Rarity rarity;
|
||||
private final Material material;
|
||||
|
||||
Items(String name, double weight) {
|
||||
|
||||
Items(String name, double weight, Rarity rarity, Material material) {
|
||||
this.name = name;
|
||||
this.weight = weight;
|
||||
this.rarity = rarity;
|
||||
this.material = material;
|
||||
}
|
||||
public static Items getByName(String name) {
|
||||
for (Items item : Items.values()) {
|
||||
if (item.getName().equalsIgnoreCase(name)) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
@ -28,4 +42,12 @@ public enum Items {
|
|||
public double getWeight() {
|
||||
return weight;
|
||||
}
|
||||
|
||||
public Rarity getRarity() {
|
||||
return rarity;
|
||||
}
|
||||
|
||||
public Material getMaterial() {
|
||||
return material;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ public class CustomItemEvents implements Listener {
|
|||
if (weaponMeta != null) {
|
||||
PersistentDataContainer container = weaponMeta.getPersistentDataContainer();
|
||||
NamespacedKey ammoKey = CustomItemManager.keys.get(name + ".ammo");
|
||||
int ammo = container.get(ammoKey, PersistentDataType.INTEGER);
|
||||
int ammo = container.get(ammoKey, PersistentDataType.INTEGER) != null ? container.get(ammoKey, PersistentDataType.INTEGER) : 0;
|
||||
container.set(ammoKey, PersistentDataType.INTEGER, ammo - 1);
|
||||
int max = container.get(CustomItemManager.keys.get(name + ".max"), PersistentDataType.INTEGER);
|
||||
weapon.setItemMeta(weaponMeta);
|
||||
|
|
|
@ -89,12 +89,15 @@ public class CustomItemManager {
|
|||
}
|
||||
item.setItemMeta(itemMeta);
|
||||
HashMap<String, Object> recipes = (HashMap<String, Object>) weapon.get("Recipes");
|
||||
List<String> shapes = (List<String>) recipes.get("Shape");
|
||||
HashMap<String, String> ind = (HashMap<String, String>) recipes.get("Ingredients");
|
||||
HashMap<Character, Material> indgredients = new HashMap<>();
|
||||
for (String i : ind.keySet())
|
||||
indgredients.put(i.charAt(0), Material.matchMaterial(ind.get(i)));
|
||||
setItemRecipe((String) weapon.get("Name"), item, shapes, indgredients, (int) recipes.get("Amount"));
|
||||
if (recipes.get("Shape") != null) {
|
||||
List<String> shapes = (List<String>) recipes.get("Shape");
|
||||
HashMap<String, String> ind = (HashMap<String, String>) recipes.get("Ingredients");
|
||||
HashMap<Character, Material> indgredients = new HashMap<>();
|
||||
for (String i : ind.keySet())
|
||||
indgredients.put(i.charAt(0), Material.matchMaterial(ind.get(i)));
|
||||
setItemRecipe((String) weapon.get("Name"), item, shapes, indgredients, (int) recipes.get("Amount"));
|
||||
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
package me.night.nullvalkyrie.ui.inventory;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
public abstract class GUIManager {
|
||||
public static Inventory GUI;
|
||||
private boolean close;
|
||||
|
||||
public abstract void UI(Player player);
|
||||
|
||||
public void init(int size, String title) {
|
||||
GUI = Bukkit.createInventory(null, size, title);
|
||||
}
|
||||
|
||||
public void setCloseButton(boolean boo) {
|
||||
if (boo) {
|
||||
close = true;
|
||||
ItemStack close = new ItemStack(Material.BARRIER);
|
||||
ItemMeta closemeta = close.getItemMeta();
|
||||
if (closemeta != null) closemeta.setDisplayName(ChatColor.WHITE + "Close the menu");
|
||||
close.setItemMeta(closemeta);
|
||||
GUI.setItem(0, close);
|
||||
} else close = false;
|
||||
}
|
||||
|
||||
public void setFrame(boolean boo, Material... frame) {
|
||||
if (boo) {
|
||||
ItemStack frames = new ItemStack(frame[0]);
|
||||
switch (GUI.getSize()) {
|
||||
case 27 -> {
|
||||
if (close) {
|
||||
for (int i : new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26})
|
||||
GUI.setItem(i, frames);
|
||||
} else {
|
||||
for (int i : new int[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26})
|
||||
GUI.setItem(i, frames);
|
||||
}
|
||||
}
|
||||
case 36 -> {
|
||||
if (close) {
|
||||
for (int i : new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 17, 18, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35})
|
||||
GUI.setItem(i, frames);
|
||||
} else {
|
||||
for (int i : new int[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 17, 18, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35})
|
||||
GUI.setItem(i, frames);
|
||||
}
|
||||
}
|
||||
case 45 -> {
|
||||
if (close) {
|
||||
for (int i : new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 17, 18, 26, 27, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44})
|
||||
GUI.setItem(i, frames);
|
||||
} else {
|
||||
for (int i : new int[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 17, 18, 26, 27, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44})
|
||||
GUI.setItem(i, frames);
|
||||
}
|
||||
}
|
||||
case 54 -> {
|
||||
if (close) {
|
||||
for (int i : new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 17, 18, 26, 27, 35, 36, 44, 45, 46, 47, 48, 49, 50, 51 ,52, 53})
|
||||
GUI.setItem(i, frames);
|
||||
} else {
|
||||
for (int i : new int[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 17, 18, 26, 27, 35, 36, 44, 45, 46, 47, 48, 49, 50, 51 ,52, 53})
|
||||
GUI.setItem(i, frames);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,16 +1,34 @@
|
|||
package me.night.nullvalkyrie.ui.inventory;
|
||||
|
||||
import me.night.nullvalkyrie.Main;
|
||||
import me.night.nullvalkyrie.enums.Items;
|
||||
import me.night.nullvalkyrie.util.RandomCollection;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class InventoryListener implements Listener {
|
||||
|
||||
RandomCollection<String> randomCollection;
|
||||
public InventoryListener() {
|
||||
randomCollection = new RandomCollection<>();
|
||||
for (Items e : Items.values()) {
|
||||
randomCollection.add(e.getWeight(), e.getName());
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void onClick(InventoryClickEvent e) {
|
||||
if (e.getInventory().equals(Menu.GUI) && e.getCurrentItem() != null) {
|
||||
if (e.getCurrentItem() == null) return;
|
||||
if (e.getView().getTitle().equals(Menu.title)) {
|
||||
e.setCancelled(true);
|
||||
Player player = (Player) e.getWhoClicked();
|
||||
switch (e.getRawSlot()) {
|
||||
|
@ -32,12 +50,108 @@ public class InventoryListener implements Listener {
|
|||
}
|
||||
player.closeInventory();
|
||||
}
|
||||
if (e.getInventory().equals(Shop.GUI) && e.getCurrentItem() != null) {
|
||||
if (e.getView().getTitle().equals(Shop.title)) {
|
||||
e.setCancelled(true);
|
||||
Player player = (Player) e.getWhoClicked();
|
||||
if (e.getRawSlot() == 0) {
|
||||
player.closeInventory();
|
||||
}
|
||||
}
|
||||
if (e.getView().getTitle().equals(LuckyDraw.title)) {
|
||||
e.setCancelled(true);
|
||||
Player player = (Player) e.getWhoClicked();
|
||||
if (e.getRawSlot() == 0) {
|
||||
player.closeInventory();
|
||||
} else if (e.getRawSlot() == 22) {
|
||||
List<String> colors = List.of("WHITE", "ORANGE", "MAGENTA", "LIGHT_BLUE", "YELLOW", "LIME", "PINK", "GRAY", "LIGHT_GRAY", "CYAN", "PURPLE", "BLUE", "BROWN", "GREEN", "RED", "BLACK");
|
||||
List<String> slot1 = new ArrayList<>(colors);
|
||||
List<String> slot2 = new ArrayList<>(colors);
|
||||
List<String> slot3 = new ArrayList<>(colors);
|
||||
List<String> slot4 = new ArrayList<>(colors);
|
||||
List<String> slot5 = new ArrayList<>(colors);
|
||||
List<String> slot6 = new ArrayList<>(colors);
|
||||
List<String> slot7 = new ArrayList<>(colors);
|
||||
List<String> slot8 = new ArrayList<>(colors);
|
||||
Collections.shuffle(slot1);
|
||||
Collections.shuffle(slot2);
|
||||
Collections.shuffle(slot3);
|
||||
Collections.shuffle(slot4);
|
||||
Collections.shuffle(slot5);
|
||||
Collections.shuffle(slot6);
|
||||
Collections.shuffle(slot7);
|
||||
Collections.shuffle(slot8);
|
||||
int[] slots = new int[]{11, 13, 15, 20, 24, 29, 31, 33};
|
||||
new BukkitRunnable() {
|
||||
int i = 0;
|
||||
int ii = 0;
|
||||
int time = 0;
|
||||
@Override
|
||||
public void run() {
|
||||
if (colors.size() - 1 <= i) i = 0;
|
||||
if (ii == 8) ii = 0;
|
||||
if (time == 20) {
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
for (int slot : slots) {
|
||||
if (slot == 11) {
|
||||
ItemStack item = new ItemStack(Material.valueOf(slot1.get(i) + "_STAINED_GLASS_PANE"), 1);
|
||||
LuckyDraw.GUI.setItem(slot, item);
|
||||
}
|
||||
if (slot == 13) {
|
||||
ItemStack item = new ItemStack(Material.valueOf(slot2.get(i) + "_STAINED_GLASS_PANE"), 1);
|
||||
LuckyDraw.GUI.setItem(slot, item);
|
||||
}
|
||||
if (slot == 15) {
|
||||
ItemStack item = new ItemStack(Material.valueOf(slot3.get(i) + "_STAINED_GLASS_PANE"), 1);
|
||||
LuckyDraw.GUI.setItem(slot, item);
|
||||
}
|
||||
if (slot == 20) {
|
||||
ItemStack item = new ItemStack(Material.valueOf(slot4.get(i) + "_STAINED_GLASS_PANE"), 1);
|
||||
LuckyDraw.GUI.setItem(slot, item);
|
||||
}
|
||||
if (slot == 24) {
|
||||
ItemStack item = new ItemStack(Material.valueOf(slot5.get(i) + "_STAINED_GLASS_PANE"), 1);
|
||||
LuckyDraw.GUI.setItem(slot, item);
|
||||
}
|
||||
if (slot == 29) {
|
||||
ItemStack item = new ItemStack(Material.valueOf(slot6.get(i) + "_STAINED_GLASS_PANE"), 1);
|
||||
LuckyDraw.GUI.setItem(slot, item);
|
||||
}
|
||||
if (slot == 31) {
|
||||
ItemStack item = new ItemStack(Material.valueOf(slot7.get(i) + "_STAINED_GLASS_PANE"), 1);
|
||||
LuckyDraw.GUI.setItem(slot, item);
|
||||
}
|
||||
if (slot == 33) {
|
||||
ItemStack item = new ItemStack(Material.valueOf(slot8.get(i) + "_STAINED_GLASS_PANE"), 1);
|
||||
LuckyDraw.GUI.setItem(slot, item);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
ii++;
|
||||
time++;
|
||||
}
|
||||
}.runTaskTimer(Main.getPlugin(Main.class), 1L, 5L);
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (int slot : slots) {
|
||||
LuckyDraw.GUI.setItem(slot, new ItemStack(Material.AIR));
|
||||
}
|
||||
String s = randomCollection.getRandom();
|
||||
randomCollection.remove(s);
|
||||
Items it = Items.getByName(s);
|
||||
ItemStack item = new ItemStack(it.getMaterial(), 1);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta == null) return;
|
||||
meta.setDisplayName(ChatColor.GOLD + it.getName());
|
||||
meta.setLore(List.of(it.getRarity().getDisplay()));
|
||||
item.setItemMeta(meta);
|
||||
player.getInventory().addItem(item);
|
||||
}
|
||||
}.runTaskLater(Main.getPlugin(Main.class), 5L * 20L);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
package me.night.nullvalkyrie.ui.inventory;
|
||||
|
||||
import me.night.nullvalkyrie.enums.Items;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LuckyDraw extends GUIManager {
|
||||
public static final String title = ChatColor.DARK_BLUE.toString() + ChatColor.BOLD + "X Lucky Draw";
|
||||
@Override
|
||||
public void UI(Player player) {
|
||||
init(45, title);
|
||||
setCloseButton(true);
|
||||
setFrame(true, Material.BLUE_STAINED_GLASS_PANE);
|
||||
int[] slots = new int[]{10, 12, 14, 16, 28, 30, 32, 34, 19, 25};
|
||||
int count = 0;
|
||||
for (Items name : Items.values()) {
|
||||
ItemStack item = new ItemStack(name.getMaterial());
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta == null) return;
|
||||
meta.setDisplayName(ChatColor.GOLD + name.getName());
|
||||
meta.setLore(List.of(name.getRarity().getDisplay()));
|
||||
item.setItemMeta(meta);
|
||||
GUI.setItem(slots[count], item);
|
||||
count++;
|
||||
}
|
||||
ItemStack roll = new ItemStack(Material.ARROW);
|
||||
ItemMeta meta = roll.getItemMeta();
|
||||
if (meta == null) return;
|
||||
meta.setLore(List.of("Press to roll!"));
|
||||
roll.setItemMeta(meta);
|
||||
GUI.setItem(22, roll);
|
||||
player.openInventory(GUI);
|
||||
}
|
||||
}
|
|
@ -1,23 +1,23 @@
|
|||
package me.night.nullvalkyrie.ui.inventory;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Menu {
|
||||
public static Inventory GUI;
|
||||
|
||||
public class Menu extends GUIManager {
|
||||
public static final String title = ChatColor.DARK_BLUE.toString() + ChatColor.BOLD + "Valkyrie Menu";
|
||||
@Override
|
||||
public void UI(Player player) {
|
||||
GUI = Bukkit.createInventory(player, 45, ChatColor.DARK_BLUE.toString() + ChatColor.BOLD + "Valkyrie Menu");
|
||||
|
||||
init(45, title);
|
||||
setCloseButton(true);
|
||||
setFrame(true, Material.BLUE_STAINED_GLASS_PANE);
|
||||
ItemStack KYS = new ItemStack(Material.WOODEN_SWORD);
|
||||
ItemMeta KYSmeta = KYS.getItemMeta();
|
||||
if (KYSmeta == null) return;
|
||||
KYSmeta.setDisplayName(ChatColor.RED + "KILL YOURSELF WHEN???");
|
||||
KYSmeta.setLore(Arrays.asList(ChatColor.GRAY + "KYS", ChatColor.WHITE.toString() + ChatColor.BOLD + "COMMON"));
|
||||
KYS.setItemMeta(KYSmeta);
|
||||
|
@ -25,6 +25,7 @@ public class Menu {
|
|||
|
||||
ItemStack home = new ItemStack(Material.MAP);
|
||||
ItemMeta homemeta = home.getItemMeta();
|
||||
if (homemeta == null) return;
|
||||
homemeta.setDisplayName(ChatColor.BLUE + "Teleport to home");
|
||||
homemeta.setLore(Arrays.asList(ChatColor.GRAY + "Click to teleport back to home", ChatColor.WHITE.toString() + ChatColor.BOLD + "COMMON"));
|
||||
home.setItemMeta(homemeta);
|
||||
|
@ -32,22 +33,12 @@ public class Menu {
|
|||
|
||||
ItemStack chest = new ItemStack(Material.ENDER_CHEST);
|
||||
ItemMeta chestmeta = chest.getItemMeta();
|
||||
if (chestmeta == null) return;
|
||||
chestmeta.setDisplayName(ChatColor.GREEN + "Open your chest");
|
||||
chestmeta.setLore(Arrays.asList(ChatColor.GRAY + "Click to open the chest", ChatColor.WHITE.toString() + ChatColor.BOLD + "COMMON"));
|
||||
chest.setItemMeta(chestmeta);
|
||||
GUI.setItem(24, chest);
|
||||
|
||||
ItemStack close = new ItemStack(Material.BARRIER);
|
||||
ItemMeta closemeta = close.getItemMeta();
|
||||
closemeta.setDisplayName(ChatColor.WHITE + "Close the menu");
|
||||
closemeta.setLore(Arrays.asList(ChatColor.GRAY + "Close the menu", ChatColor.WHITE.toString() + ChatColor.BOLD + "COMMON"));
|
||||
close.setItemMeta(closemeta);
|
||||
GUI.setItem(0, close);
|
||||
|
||||
ItemStack frame = new ItemStack(Material.BLUE_STAINED_GLASS_PANE);
|
||||
for (int i : new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 17, 18, 26, 27, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44})
|
||||
GUI.setItem(i, frame);
|
||||
|
||||
player.openInventory(GUI);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,11 +2,9 @@ package me.night.nullvalkyrie.ui.inventory;
|
|||
|
||||
import me.night.nullvalkyrie.database.MinerDataManager;
|
||||
import me.night.nullvalkyrie.entities.miners.CryptoMiner;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
|
@ -15,35 +13,30 @@ import java.util.ArrayList;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class Miner {
|
||||
public static Inventory GUI;
|
||||
|
||||
public class Miner extends GUIManager {
|
||||
public static String title = ChatColor.DARK_AQUA + "Crypto Miners";
|
||||
@Override
|
||||
public void UI(Player player) {
|
||||
GUI = Bukkit.createInventory(null, 45, ChatColor.DARK_AQUA + "Crypto Miners");
|
||||
ItemStack frame = new ItemStack(Material.BLUE_STAINED_GLASS_PANE);
|
||||
for (int i : new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 17, 18, 26, 27, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44}) {
|
||||
GUI.setItem(i, frame);
|
||||
}
|
||||
ItemStack close = new ItemStack(Material.BARRIER);
|
||||
ItemMeta closemeta = close.getItemMeta();
|
||||
if (closemeta != null) closemeta.setDisplayName(ChatColor.WHITE + "Close the menu");
|
||||
close.setItemMeta(closemeta);
|
||||
GUI.setItem(0, close);
|
||||
init(45, title);
|
||||
setCloseButton(true);
|
||||
setFrame(true, Material.BLUE_STAINED_GLASS_PANE);
|
||||
int[] a = new int[]{10, 11, 12, 13, 14, 15, 16, 19, 20, 21, 22, 23, 24, 25, 28, 29, 30, 31, 32, 33, 34};
|
||||
int counter = 0;
|
||||
for (CryptoMiner c : MinerDataManager.getMiners().values()) {
|
||||
if (counter <= 20) {
|
||||
ItemStack item = new ItemStack(c.getType());
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
itemMeta.setDisplayName(c.getName());
|
||||
List<String> lore = new ArrayList<>();
|
||||
lore.add("Level: " + c.getLevel());
|
||||
lore.add("Rate: " + c.getRate());
|
||||
lore.add("Last Claim: " + new SimpleDateFormat("d MMM yyyy HH:mm:ss").format(new Date(c.getLastclaim())));
|
||||
itemMeta.setLore(lore);
|
||||
item.setItemMeta(itemMeta);
|
||||
GUI.setItem(a[counter], item);
|
||||
counter++;
|
||||
if (itemMeta != null) {
|
||||
itemMeta.setDisplayName(c.getName());
|
||||
List<String> lore = new ArrayList<>();
|
||||
lore.add("Level: " + c.getLevel());
|
||||
lore.add("Rate: " + c.getRate());
|
||||
lore.add("Last Claim: " + new SimpleDateFormat("d MMM yyyy HH:mm:ss").format(new Date(c.getLastclaim())));
|
||||
itemMeta.setLore(lore);
|
||||
item.setItemMeta(itemMeta);
|
||||
GUI.setItem(a[counter], item);
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
player.openInventory(GUI);
|
||||
}
|
||||
|
|
|
@ -2,30 +2,23 @@ package me.night.nullvalkyrie.ui.inventory;
|
|||
|
||||
import me.night.nullvalkyrie.database.ShopDataManager;
|
||||
import me.night.nullvalkyrie.items.CustomItemManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class Shop {
|
||||
public static Inventory GUI;
|
||||
|
||||
public class Shop extends GUIManager {
|
||||
public static final String title = ChatColor.GREEN + "7-Eleven 24/7";
|
||||
@Override
|
||||
public void UI(Player player) {
|
||||
GUI = Bukkit.createInventory(null, 54, ChatColor.GREEN + "7-Eleven 24/7");
|
||||
ItemStack frame = new ItemStack(Material.BLUE_STAINED_GLASS_PANE);
|
||||
for (int i : new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 17, 18, 26, 27, 35, 36, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53})
|
||||
GUI.setItem(i, frame);
|
||||
ItemStack close = new ItemStack(Material.BARRIER);
|
||||
ItemMeta closemeta = close.getItemMeta();
|
||||
if (closemeta != null) closemeta.setDisplayName(ChatColor.WHITE + "Close the menu");
|
||||
close.setItemMeta(closemeta);
|
||||
GUI.setItem(0, close);
|
||||
init(54, title);
|
||||
setCloseButton(true);
|
||||
setFrame(true, Material.GREEN_STAINED_GLASS_PANE);
|
||||
HashMap<String, Integer> list = ShopDataManager.getItems();
|
||||
int[] a = new int[]{10, 11, 12, 13, 14, 15, 16, 19, 20, 21, 22, 23, 24, 25, 28, 29, 30, 31, 32, 33, 34, 37, 38, 39, 40, 41, 42, 43, 44};
|
||||
int counter = 0;
|
||||
|
@ -33,7 +26,8 @@ public class Shop {
|
|||
if (counter <= 20) {
|
||||
ItemStack item = CustomItemManager.produceItem(c).clone();
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
List<String> lore = itemMeta.getLore();
|
||||
if (itemMeta == null) return;
|
||||
List<String> lore = itemMeta.getLore() == null ? new ArrayList<>() : itemMeta.getLore();
|
||||
lore.add("Price (BIN): " + list.get(c));
|
||||
itemMeta.setLore(lore);
|
||||
item.setItemMeta(itemMeta);
|
||||
|
|
Loading…
Reference in a new issue