use of org.bukkit.inventory.Inventory in project Denizen-For-Bukkit by DenizenScript.
the class ScribeCommand method equipBook.
private void equipBook(Player player, ItemStack book) {
ItemStack currItem = player.getItemInHand();
Inventory inv = player.getInventory();
int emptySpot = inv.firstEmpty();
// if player isn't holding anything
if (currItem == null || currItem.getType() == Material.AIR) {
player.setItemInHand(book);
return;
}
// drop it if inventory has no empty slots
emptySpot = inv.firstEmpty();
dB.log("emptySpot: " + emptySpot);
if (emptySpot == -1) {
player.getWorld().dropItem(player.getLocation(), book);
dB.log("Player's inventory is full, dropped book.");
} else // move current held item to empty spot, set item in hand to the book
{
inv.setItem(emptySpot, currItem);
player.setItemInHand(book);
dB.log("...added book to player hand, moved original item");
}
}
use of org.bukkit.inventory.Inventory in project Denizen-For-Bukkit by DenizenScript.
the class ImprovedOfflinePlayer_v1_8_R3 method getEnderChest.
@Override
public Inventory getEnderChest() {
if (offlineEnderChests.containsKey(getUniqueId())) {
return offlineEnderChests.get(getUniqueId());
}
InventoryEnderChest endchest = new InventoryEnderChest();
endchest.a(((CompoundTag_v1_8_R3) this.compound).toNMSTag().getList("EnderItems", 10));
Inventory inv = new CraftInventory(endchest);
offlineEnderChests.put(getUniqueId(), inv);
return inv;
}
use of org.bukkit.inventory.Inventory in project Denizen-For-Bukkit by DenizenScript.
the class ImprovedOfflinePlayer_v1_10_R1 method getEnderChest.
@Override
public Inventory getEnderChest() {
if (offlineEnderChests.containsKey(getUniqueId())) {
return offlineEnderChests.get(getUniqueId());
}
InventoryEnderChest endchest = new InventoryEnderChest();
endchest.a(((CompoundTag_v1_10_R1) this.compound).toNMSTag().getList("EnderItems", 10));
org.bukkit.inventory.Inventory inv = new CraftInventory(endchest);
offlineEnderChests.put(getUniqueId(), inv);
return inv;
}
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 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;
}
Aggregations