use of org.bukkit.inventory.Inventory in project EliteMobs by MagmaGuy.
the class LootGUI method lootGUI.
public void lootGUI(Player player) {
Inventory fakeChestInventory = Bukkit.createInventory(null, 54, "EliteMobs loot.yml");
tierConstructor(fakeChestInventory);
headerConstructor(fakeChestInventory);
lootNavigationConstructor(fakeChestInventory);
lootConstructor(fakeChestInventory);
player.openInventory(fakeChestInventory);
}
use of org.bukkit.inventory.Inventory in project Essentials by drtshock.
the class Commandinvsee method run.
//This method has a hidden param, which if given will display the equip slots. #easteregg
@Override
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
if (args.length < 1) {
throw new NotEnoughArgumentsException();
}
final User invUser = getPlayer(server, user, args, 0);
Inventory inv;
if (args.length > 1 && user.isAuthorized("essentials.invsee.equip")) {
inv = server.createInventory(invUser.getBase(), 9, "Equipped");
inv.setContents(invUser.getBase().getInventory().getArmorContents());
} else {
inv = invUser.getBase().getInventory();
}
user.getBase().closeInventory();
user.getBase().openInventory(inv);
user.setInvSee(true);
}
use of org.bukkit.inventory.Inventory in project Essentials by drtshock.
the class SignFree method onSignInteract.
@Override
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException {
ItemStack itemStack = getItemStack(sign.getLine(1), 1, ess);
itemStack = getItemMeta(itemStack, sign.getLine(2), ess);
final ItemStack item = getItemMeta(itemStack, sign.getLine(3), ess);
if (item.getType() == Material.AIR) {
throw new SignException(tl("cantSpawnItem", "Air"));
}
item.setAmount(item.getType().getMaxStackSize());
ItemMeta meta = item.getItemMeta();
final String displayName = meta.hasDisplayName() ? meta.getDisplayName() : item.getType().toString();
Inventory invent = ess.getServer().createInventory(player.getBase(), 36, displayName);
for (int i = 0; i < 36; i++) {
invent.addItem(item);
}
player.getBase().openInventory(invent);
Trade.log("Sign", "Free", "Interact", username, null, username, new Trade(item, ess), sign.getBlock().getLocation(), ess);
return true;
}
use of org.bukkit.inventory.Inventory in project Essentials by drtshock.
the class EssentialsPlayerListener method onInventoryCloseEvent.
@EventHandler(priority = EventPriority.MONITOR)
public void onInventoryCloseEvent(final InventoryCloseEvent event) {
Player refreshPlayer = null;
final Inventory top = event.getView().getTopInventory();
final InventoryType type = top.getType();
if (type == InventoryType.PLAYER) {
final User user = ess.getUser((Player) event.getPlayer());
user.setInvSee(false);
refreshPlayer = user.getBase();
} else if (type == InventoryType.ENDER_CHEST) {
final User user = ess.getUser((Player) event.getPlayer());
user.setEnderSee(false);
refreshPlayer = user.getBase();
} else if (type == InventoryType.WORKBENCH) {
final User user = ess.getUser((Player) event.getPlayer());
if (user.isRecipeSee()) {
user.setRecipeSee(false);
event.getView().getTopInventory().clear();
refreshPlayer = user.getBase();
}
} else if (type == InventoryType.CHEST && top.getSize() == 9) {
final InventoryHolder invHolder = top.getHolder();
if (invHolder != null && invHolder instanceof HumanEntity) {
final User user = ess.getUser((Player) event.getPlayer());
user.setInvSee(false);
refreshPlayer = user.getBase();
}
}
if (refreshPlayer != null) {
final Player player = refreshPlayer;
ess.scheduleSyncDelayedTask(new Runnable() {
@Override
public void run() {
player.updateInventory();
}
}, 1);
}
}
use of org.bukkit.inventory.Inventory in project Essentials by drtshock.
the class InventoryWorkaround method addAllItems.
// Returns what it couldn't store
// This will will abort if it couldn't store all items
public static Map<Integer, ItemStack> addAllItems(final Inventory inventory, final ItemStack... items) {
ItemStack[] contents = inventory.getContents();
final Inventory fakeInventory;
if (isCombinedInventory(inventory)) {
fakeInventory = makeTruncatedPlayerInventory((PlayerInventory) inventory);
} else {
fakeInventory = Bukkit.getServer().createInventory(null, inventory.getType());
fakeInventory.setContents(contents);
}
Map<Integer, ItemStack> overflow = addItems(fakeInventory, items);
if (overflow.isEmpty()) {
addItems(inventory, items);
return null;
}
return addItems(fakeInventory, items);
}
Aggregations