use of com.magmaguy.elitemobs.items.EliteItemLore in project EliteMobs by MagmaGuy.
the class ProceduralShopMenu method shopContents.
private static void shopContents(Inventory shopInventory, Player player) {
Random random = new Random();
for (int i : validSlots) {
int balancedMax = ProceduralShopMenuConfig.maxTier - ProceduralShopMenuConfig.minTier;
int balancedMin = ProceduralShopMenuConfig.minTier;
int randomTier = random.nextInt(balancedMax) + balancedMin;
ItemStack itemStack = ItemConstructor.constructItem(randomTier, null, player, true);
// SoulbindEnchantment.addEnchantment(itemStack, player);
new EliteItemLore(itemStack, true);
shopInventory.setItem(i, itemStack);
}
}
use of com.magmaguy.elitemobs.items.EliteItemLore in project EliteMobs by MagmaGuy.
the class ProceduralShopMenu method onClick.
@EventHandler
public void onClick(InventoryClickEvent event) {
if (!event.getView().getTitle().equals(SHOP_NAME))
return;
if (event.getClickedInventory() == null || !event.getClickedInventory().getType().equals(InventoryType.CHEST)) {
event.setCancelled(true);
return;
}
event.setCancelled(true);
if (!SharedShopElements.inventoryNullPointerPreventer(event))
return;
// reroll loot button
if (event.getCurrentItem().getItemMeta().getDisplayName().equals(ProceduralShopMenuConfig.rerollItem.getItemMeta().getDisplayName())) {
populateShop(event.getInventory(), Bukkit.getPlayer(event.getWhoClicked().getUniqueId()));
event.setCancelled(true);
return;
}
if (!ItemTagger.isEliteItem(event.getCurrentItem())) {
event.setCancelled(true);
return;
}
Player player = (Player) event.getWhoClicked();
ItemStack itemStack = event.getCurrentItem();
String itemDisplayName = itemStack.getItemMeta().getDisplayName();
double itemValue = ItemWorthCalculator.determineItemWorth(itemStack, player);
boolean inventoryHasFreeSlots = false;
for (ItemStack iteratedStack : player.getInventory().getStorageContents()) if (iteratedStack == null) {
inventoryHasFreeSlots = true;
break;
}
// These slots are for buying items
if (event.getView().getTitle().equalsIgnoreCase(SHOP_NAME) && validSlots.contains(event.getSlot())) {
if (!inventoryHasFreeSlots) {
player.sendMessage(ProceduralShopMenuConfig.messageFullInventory);
player.closeInventory();
} else if (EconomyHandler.checkCurrency(player.getUniqueId()) >= itemValue) {
// player has enough money
EconomyHandler.subtractCurrency(player.getUniqueId(), itemValue);
new EliteItemLore(itemStack, false);
player.getInventory().addItem(itemStack);
populateShop(event.getInventory(), Bukkit.getPlayer(event.getWhoClicked().getUniqueId()));
SharedShopElements.buyMessage(player, itemDisplayName, itemValue);
} else {
player.closeInventory();
SharedShopElements.insufficientFundsMessage(player, itemValue);
}
}
}
use of com.magmaguy.elitemobs.items.EliteItemLore in project EliteMobs by MagmaGuy.
the class CustomShopMenu method onClick.
@EventHandler
public void onClick(InventoryClickEvent event) {
if (!event.getView().getTitle().equals(SHOP_NAME))
return;
if (event.getClickedInventory() == null || !event.getClickedInventory().getType().equals(InventoryType.CHEST)) {
event.setCancelled(true);
return;
}
event.setCancelled(true);
if (!SharedShopElements.inventoryNullPointerPreventer(event))
return;
// reroll loot button
if (event.getCurrentItem().getItemMeta().getDisplayName().equals(CustomShopMenuConfig.rerollItem.getItemMeta().getDisplayName())) {
populateShop(event.getInventory(), Bukkit.getPlayer(event.getWhoClicked().getUniqueId()));
event.setCancelled(true);
return;
}
if (!ItemTagger.isEliteItem(event.getCurrentItem())) {
event.setCancelled(true);
return;
}
Player player = (Player) event.getWhoClicked();
ItemStack itemStack = event.getCurrentItem();
String itemDisplayName = event.getCurrentItem().getItemMeta().getDisplayName();
double itemValue = ItemWorthCalculator.determineItemWorth(itemStack, player);
// These slots are for buying items
if (CustomShopMenuConfig.storeSlots.contains(event.getSlot()) && event.getView().getTitle().equalsIgnoreCase(SHOP_NAME)) {
boolean inventoryHasFreeSlots = false;
for (ItemStack iteratedStack : player.getInventory()) if (iteratedStack == null) {
inventoryHasFreeSlots = true;
break;
}
if (!inventoryHasFreeSlots) {
player.sendMessage(CustomShopMenuConfig.messageFullInventory);
player.closeInventory();
} else if (EconomyHandler.checkCurrency(player.getUniqueId()) >= itemValue) {
// player has enough money
EconomyHandler.subtractCurrency(player.getUniqueId(), itemValue);
new EliteItemLore(itemStack, false);
player.getInventory().addItem(itemStack);
populateShop(event.getInventory(), Bukkit.getPlayer(event.getWhoClicked().getUniqueId()));
SharedShopElements.buyMessage(player, itemDisplayName, itemValue);
} else {
player.closeInventory();
SharedShopElements.insufficientFundsMessage(player, itemValue);
}
}
}
use of com.magmaguy.elitemobs.items.EliteItemLore in project EliteMobs by MagmaGuy.
the class EnhancementMenu method calculateOutput.
private static void calculateOutput(Inventory EnhancementInventory) {
if (EnhancementInventory.getItem(EnhancementMenuConfig.eliteUpgradeOrbInputSlot) == null || EnhancementInventory.getItem(EnhancementMenuConfig.eliteItemInputSlot) == null) {
EnhancementInventory.setItem(EnhancementMenuConfig.outputSlot, null);
return;
}
int enhancementScore = ItemTagger.getEnchantment(EnhancementInventory.getItem(EnhancementMenuConfig.eliteUpgradeOrbInputSlot).getItemMeta(), "EliteUpgradeItem");
int itemScore = ItemTierFinder.findBattleTier(EnhancementInventory.getItem(EnhancementMenuConfig.eliteItemInputSlot));
if (enhancementScore <= itemScore) {
EnhancementInventory.setItem(EnhancementMenuConfig.outputSlot, null);
return;
}
ItemStack outputItem = EnhancementInventory.getItem(EnhancementMenuConfig.eliteItemInputSlot).clone();
Enchantment mainCombatEnchantment = ItemTierFinder.getMainCombatEnchantment(outputItem.getType());
NamespacedKey enchantmentKey = mainCombatEnchantment.getKey();
ItemMeta itemMeta = outputItem.getItemMeta();
int enchantmentLevel = ItemTagger.getEnchantment(outputItem.getItemMeta(), enchantmentKey) + 1;
if (outputItem.getEnchantmentLevel(mainCombatEnchantment) < mainCombatEnchantment.getMaxLevel())
outputItem.addEnchantment(mainCombatEnchantment, enchantmentLevel);
ItemTagger.registerEnchantment(itemMeta, enchantmentKey, enchantmentLevel);
outputItem.setItemMeta(itemMeta);
new EliteItemLore(outputItem, false);
EnhancementInventory.setItem(outputSlot, outputItem);
}
use of com.magmaguy.elitemobs.items.EliteItemLore in project EliteMobs by MagmaGuy.
the class SoulbindEnchantment method removeEnchantment.
public static void removeEnchantment(ItemStack itemStack) {
if (itemStack == null)
return;
ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.getPersistentDataContainer().remove(SOULBIND_KEY);
itemStack.setItemMeta(itemMeta);
// update item lore display
new EliteItemLore(itemStack, false);
}
Aggregations