use of com.massivecraft.massivecore.collections.MassiveList in project MassiveCore by MassiveCraft.
the class InventoryUtil method getChangesClick.
protected static List<Entry<ItemStack, Integer>> getChangesClick(InventoryClickEvent event) {
// Create
List<Entry<ItemStack, Integer>> ret = new MassiveList<>();
// Fill
final InventoryAlter alter = InventoryUtil.getAlter(event);
final InventoryAction action = event.getAction();
ItemStack item;
int amount;
// Give
if (alter.isGiving()) {
// Special > MOVE_TO_OTHER_INVENTORY
if (action == InventoryAction.MOVE_TO_OTHER_INVENTORY) {
item = event.getCurrentItem();
ItemStack compare = item.clone();
compare.setAmount(1);
amount = InventoryUtil.roomLeft(event.getInventory(), compare, item.getAmount());
} else // Special > HOTBAR_SWAP
if (action == InventoryAction.HOTBAR_SWAP) {
item = event.getView().getBottomInventory().getItem(event.getHotbarButton());
amount = item.getAmount();
} else // Normal
{
item = event.getCursor();
amount = item.getAmount();
if (action == InventoryAction.PLACE_ONE) {
amount = 1;
} else if (action == InventoryAction.PLACE_SOME) {
int max = event.getCurrentItem().getType().getMaxStackSize();
amount = max - event.getCurrentItem().getAmount();
}
}
amount *= -1;
ret.add(new SimpleEntry<>(item, amount));
}
// Take
if (alter.isTaking()) {
item = event.getCurrentItem();
amount = item.getAmount();
if (action == InventoryAction.PICKUP_ONE)
amount = 1;
if (action == InventoryAction.PICKUP_HALF)
amount = (int) Math.ceil(amount / 2.0);
ret.add(new SimpleEntry<>(item, amount));
}
// Return
return ret;
}
use of com.massivecraft.massivecore.collections.MassiveList in project MassiveCore by MassiveCraft.
the class EventMassiveCoreLorePriority method getLoreEntries.
private static List<Entry<String, Integer>> getLoreEntries(ItemStack item) {
ItemMeta meta = item.getItemMeta();
if (!meta.hasLore())
return Collections.emptyList();
List<Entry<String, Integer>> ret = new MassiveList<>();
for (String line : meta.getLore()) {
ret.add(new SimpleEntry<>(line, PRIORITY_DEFAULT));
}
return ret;
}
Aggregations