Java Code Examples for org.bukkit.inventory.Inventory

The following are top voted examples for showing how to use org.bukkit.inventory.Inventory. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: mczone   File: VotePanelEvents.java   Source Code and License 7 votes vote down vote up
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
	Player p = (Player) event.getWhoClicked();
	Inventory inv = event.getInventory();
	if (Chat.stripColor(inv.getTitle()).equalsIgnoreCase("Voting Panel")) {
		event.setCancelled(true);
		if (event.getRawSlot() > 9 || event.getCurrentItem() == null || event.getCurrentItem().getType() == Material.AIR)
			return;
		ItemStack i = event.getCurrentItem();
		Map m = Map.getByTitle(Chat.stripColor(i.getItemMeta().getDisplayName()));
		if (m != null) {
			m.addVote(p);
			p.closeInventory();
			event.setCancelled(true);
		}
	}
}
 
Example 2
Project: ProjectAres   File: WoolMatchModule.java   Source Code and License 6 votes vote down vote up
private void registerContainer(Inventory inv) {
    // When a chest (or other block inventory) is accessed, check if it's a wool chest
    Boolean isWoolChest = this.chests.get(inv);
    if(isWoolChest == null) {
        // If we haven't seen this chest yet, check it for wool
        isWoolChest = this.containsObjectiveWool(inv);
        this.chests.put(inv, isWoolChest);

        if(isWoolChest) {
            // If it is a wool chest, take a snapshot of the wools
            Map<Integer, ItemStack> contents = new HashMap<>();
            this.woolChests.put(inv, contents);
            for(int slot = 0; slot < inv.getSize(); ++slot) {
                ItemStack stack = inv.getItem(slot);
                if(stack != null && this.isObjectiveWool(stack)) {
                    contents.put(slot, stack.clone());
                }
            }
        }
    }
}
 
Example 3
Project: AddGun   File: Guns.java   Source Code and License 6 votes vote down vote up
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void equipWeaponEvent(InventoryDragEvent event) {
	if (Result.DENY.equals(event.getResult())) return;
	HumanEntity human = event.getWhoClicked();
	
	Inventory inv = event.getInventory();
	ItemStack prior = event.getOldCursor();
	StandardGun priorGun = findGun(prior); 
	
	// Don't really care what sort of drag, if we have a gun in inv and this was a gun, deny.
	if (priorGun != null && inv != null && !InventoryType.PLAYER.equals(inv.getType()) && priorGun.isLimitToOne() && priorGun.hasGun(human)) {
		event.setResult(Result.DENY);
		// yes this will prevent drag style of weapon in chest invs. Oh well.
	}
	
}
 
Example 4
Project: HCFCore   File: EventTimer.java   Source Code and License 6 votes vote down vote up
/**
 * Handles the winner for this event.
 *
 * @param winner
 *            the {@link Player} that won
 */
public void handleWinner(Player winner) {
    if (this.eventFaction == null)
        return;

    PlayerFaction playerFaction = plugin.getFactionManager().getPlayerFaction(winner);
    Bukkit.broadcastMessage(ChatColor.GOLD + "[" + "WIN" + "] " + ChatColor.RED + winner.getName() + ChatColor.AQUA
            + ChatColor.YELLOW + " has captured " + ChatColor.RED + this.eventFaction.getName()
            + ChatColor.YELLOW + " after " + ChatColor.RED + DurationFormatUtils.formatDurationWords(getUptime(), true, true) + " of up-time" + ChatColor.YELLOW + '.');

    EventType eventType = this.eventFaction.getEventType();
    World world = winner.getWorld();
    Location location = winner.getLocation();
    EventKey eventKey = plugin.getKeyManager().getEventKey();
    Collection<Inventory> inventories = eventKey.getInventories(eventType);
    ItemStack keyStack = eventKey.getItemStack(new EventKey.EventKeyData(eventType, inventories.isEmpty() ? 1 : plugin.getRandom().nextInt(inventories.size()) + 1));
    Map<Integer, ItemStack> excess = winner.getInventory().addItem(keyStack, EventSignListener.getEventSign(eventFaction.getName(), winner.getName()));
    for (ItemStack entry : excess.values()) {
        world.dropItemNaturally(location, entry);
    }

    this.clearCooldown(); // must always be cooled last as this nulls some variables.
}
 
Example 5
Project: FactionsXL   File: DemandMenu.java   Source Code and License 6 votes vote down vote up
@EventHandler
public void onClick(InventoryClickEvent event) {
    HumanEntity player = event.getWhoClicked();
    Inventory inventory = event.getClickedInventory();
    if (inventory == null || gui == null || !gui.getTitle().equals(inventory.getTitle())) {
        return;
    }
    event.setCancelled(true);
    PageGUI.playSound(event);
    ItemStack button = event.getCurrentItem();
    if (BACK.equals(button)) {
        faction.getPopulationMenu().openDemands(player);
        return;
    }
    Resource resource = Resource.getByIcon(button);
    if (resource != null && faction.isPrivileged(player)) {
        saturationMenu.open(player, resource);
    }
}
 
Example 6
Project: RealSurvival   File: FireCraftTableRecipe.java   Source Code and License 6 votes vote down vote up
public boolean isTrue(Inventory inv){
	short index=0;
	for(String s:shape)
		for(char c:s.toCharArray()){
			if(c==' ')
				if(inv.getItem(FireCraftTableGUI.mSlot.get(index++))==null)
					continue;
				else 
					return false;
			else{
				ItemStack is=inv.getItem(FireCraftTableGUI.mSlot.get(index++));
				if(is==null)return false;
				if(is.equals(materials.get(c)))
					continue;
				else 
					return false;
			}
		}
	return true;
}
 
Example 7
Project: MCLibrary   File: Inventories.java   Source Code and License 6 votes vote down vote up
public static boolean takeItem(Inventory inv, ItemStack item, int takeAmount) {
    Set<Integer> removeSlots = new HashSet<>(takeAmount);
    for (int i = 0; i < inv.getSize(); i++) {
        ItemStack elemItem = inv.getItem(i);
        if (elemItem == null || elemItem.getType() == Material.AIR
                || !elemItem.isSimilar(item))
            continue;

        int amount = elemItem.getAmount();
        if (takeAmount > amount) {
            takeAmount -= amount;
            removeSlots.add(i);
        } else {
            if (takeAmount < amount) {
                elemItem.setAmount(amount - takeAmount);
            } else {
                removeSlots.add(i);
            }
            removeSlots.forEach(inv::clear);
            return true;
        }
    }
    return false;
}
 
Example 8
Project: uppercore   File: HotbarView.java   Source Code and License 6 votes vote down vote up
public boolean tryToSaveSlot(int slot) {
    Inventory inv = player.getInventory();
    ItemStack item = inv.getItem(slot);
    if (item == null)
        return true;
    ListIterator<ItemStack> i = inv.iterator();
    while (i.hasNext()) {
        int ind = i.nextIndex();
        ItemStack itm = i.next();
        if (ind == slot || (ind < 9 && hotbarsBySlot[ind] != null))
            continue;
        if(itm == null) {
            i.set(item);
            return true;
        } else if (itm.isSimilar(item)) {
            int free = itm.getAmount() - itm.getMaxStackSize();
            if(item.getAmount() > free) {
                itm.setAmount(itm.getMaxStackSize());
            } else {
                itm.setAmount(itm.getAmount() + free);
                return true;
            }
        }
    }
    return false;
}
 
Example 9
Project: AgarMC   File: CellSpawner.java   Source Code and License 6 votes vote down vote up
@Override
public void run() {
    AgarMC plugin = AgarMC.get();
    if (plugin.getGame().getPlayers().isEmpty())
        return ;

    if(plugin.getGame().getVirus().size() < plugin.getGame().getMaxVirus()) {
        VirusCell virus = new VirusCell(Utils.randomLocation(plugin.getGame().getOrigin().getX(), plugin.getGame().getDimensions()), Utils.randomLocation(plugin.getGame().getOrigin().getZ(), plugin.getGame().getDimensions()));
        plugin.getGame().addVirus(virus);
    }

    for (CPlayer player : plugin.getGame().getPlayers())
    {
        player.getPlayer().getInventory().setItem(1, updateColorBlock(player.getPlayer().getInventory().getItem(1)));
        InventoryView iv = player.getPlayer().getOpenInventory();
        if (iv == null)
            continue ;
        Inventory i = iv.getTopInventory();
        if (i == null || !i.getName().equals(MenuGui.INV_NAME))
            continue ;
        i.setItem(0, updateColorBlock(i.getItem(0)));
    }
}
 
Example 10
Project: OMGPI   File: BukkitEventHandler.java   Source Code and License 6 votes vote down vote up
@EventHandler
public void event(BlockBreakEvent e) {
    new OMGBreakEvent(e, get(e.getPlayer()), e.getBlock());
    if (Area.registeredAreas.values().stream().anyMatch(a -> a.isInside(e.getBlock().getLocation())) && Area.registeredAreas.values().stream().noneMatch(a -> a.isInside(e.getBlock().getLocation()) && a.isBreakAllowed(get(e.getPlayer()).team, e.getBlock().getType()))) {
        e.setCancelled(true);
        return;
    }
    if (g.settings.isLootingOn && e.getBlock().getType() == Material.CHEST) {
        e.setCancelled(true);
        Inventory inv = ((Chest) e.getBlock().getState()).getBlockInventory();
        String lootid = inv.getTitle() == null ? "" : inv.getTitle();
        OMGLoot.LootParser lp = g.loot_contents(get(e.getPlayer()), lootid);
        if (lp != null) {
            inv.clear();
            for (int i = 0; i < inv.getSize(); i++) {
                ItemStack ii = lp.getRandom().toItem();
                if (ii != null && NBTParser.getTagCompound(ii).getByte("Undroppable") != 1)
                    e.getBlock().getWorld().dropItemNaturally(e.getBlock().getLocation(), ii);
            }
        }
        e.getBlock().setType(Material.AIR);
        e.getBlock().getWorld().dropItemNaturally(e.getBlock().getLocation(), new ItemStack(Material.CHEST));
    }
    if (!GameArea.isBlockInside(e.getBlock())) e.setCancelled(true);
}
 
Example 11
Project: ProjectAres   File: ViewInventoryMatchModule.java   Source Code and License 6 votes vote down vote up
public void previewInventory(Player viewer, Inventory realInventory) {
    if(viewer == null) { return; }

    if(realInventory instanceof PlayerInventory) {
        previewPlayerInventory(viewer, (PlayerInventory) realInventory);
    }else {
        Inventory fakeInventory;
        if(realInventory instanceof DoubleChestInventory) {
            if(realInventory.hasCustomName()) {
                fakeInventory = Bukkit.createInventory(viewer, realInventory.getSize(), realInventory.getName());
            } else {
                fakeInventory = Bukkit.createInventory(viewer, realInventory.getSize());
            }
        } else {
            if(realInventory.hasCustomName()) {
                fakeInventory = Bukkit.createInventory(viewer, realInventory.getType(), realInventory.getName());
            } else {
                fakeInventory = Bukkit.createInventory(viewer, realInventory.getType());
            }
        }
        fakeInventory.setContents(realInventory.contents());

        this.showInventoryPreview(viewer, realInventory, fakeInventory);
    }
}
 
Example 12
Project: OpenUHC   File: BenchBlitz.java   Source Code and License 6 votes vote down vote up
private void limitWorkbenches(Player player) {
  boolean workbench = false;
  Inventory inventory = player.getInventory();
  for (int slot = 0; slot < inventory.getSize(); ++slot) {
    ItemStack item = inventory.getItem(slot);
    if (item != null && item.getType().equals(Material.WORKBENCH)) {
      if (workbench) {
        inventory.setItem(slot, null);
      } else {
        workbench = true;
        item.setAmount(1);
        //TODO: Ensure that the amount of workbenches in the inventory updates on the client
      }
    }
  }
}
 
Example 13
Project: EpicBanRequests   File: GUIManager.java   Source Code and License 6 votes vote down vote up
public static Inventory archived(Player player) {
	Inventory i = Bukkit.createInventory(null, 54, Messager.color("&7Archived Requests"));
	
	
	ItemStack back = new ItemStack(Material.ARROW);
	ItemMeta im = back.getItemMeta();
	im.setDisplayName(Messager.color("&cBack"));
	back.setItemMeta(im);		
	i.setItem(45, back);
	
	int tillFull = 0;
	for (int x = Main.getInstance().getConfig().getInt("current_id"); x <= 0; x--) {	
		
		if (tillFull >= 53) {
			Messager.msgPlayer("&cAll of the archived requests could not fit in the GUI. Showing the newest first.", player);
			break;
		}
		BanRequest br = new BanRequest(x);
		if (br.closed) {
			i.addItem(br.getArchivedItem());
			tillFull++;
		}
	}
	
	return i;
}
 
Example 14
Project: FactionsXL   File: PageGUICache.java   Source Code and License 6 votes vote down vote up
@EventHandler
public void onClick(InventoryClickEvent event) {
    ItemStack button = event.getCurrentItem();
    if (button == null || button.getType() == Material.AIR) {
        return;
    }
    Inventory inventory = event.getInventory();
    PageGUI gui = PageGUI.getByInventory(inventory);
    if (gui == null) {
        return;
    }

    event.setCancelled(true);
    PageGUI.playSound(event);
    int index = gui.getPages().indexOf(inventory);
    HumanEntity player = event.getWhoClicked();
    if (button.equals(NEXT_PAGE)) {
        gui.open(player, index + 1);
    } else if (button.equals(PREVIOUS_PAGE)) {
        gui.open(player, index - 1);
    }
}
 
Example 15
Project: ArmorPlus   File: GUI.java   Source Code and License 6 votes vote down vote up
public static void openGUI(Player p){
    Inventory inv = Bukkit.createInventory(null, 54, "장신구 장착");

    for(int i = 0; i < 54; i++)
        Util.stack("",101,0,1, Arrays.asList(""),i,inv);

    Util.stack("",1,0,0, Arrays.asList(""),20,inv);
    Util.stack("",1,0,0, Arrays.asList(""),21,inv);
    Util.stack("",1,0,0, Arrays.asList(""),22,inv);
    Util.stack("",1,0,0, Arrays.asList(""),23,inv);
    Util.stack("",1,0,0, Arrays.asList(""),24,inv);

    Util.stack("§e투구 장착",323,0,1, Arrays.asList(""),29,inv); // 모자
    Util.stack("§e갑옷 장착",323,0,1, Arrays.asList(""),30,inv);  // 옷
    Util.stack("§e바지 장착",323,0,1, Arrays.asList(""),31,inv);  // 바지
    Util.stack("§e신발 장착",323,0,1, Arrays.asList(""),32,inv);  // 신발
    Util.stack("§e반지 장착",323,0,1, Arrays.asList(""),33,inv);  // 반지

    p.openInventory(inv);
}
 
Example 16
Project: SuperiorCraft   File: CustomCraftingRecipe.java   Source Code and License 6 votes vote down vote up
public boolean check(ItemStack[] a, Inventory inv) {
	boolean match = true;
	//System.out.println(inv.getName());
	//System.out.println(ncon);
	if (inv.getSize() == 9 && nCheck(inv.getName())) {
		for (int i = 0; i < recipe.length; i++) {
			if (match) {
				System.out.println(a[i]);
				System.out.println(recipe[i]);
				if (recipe[i] != null) {
					match = recipe[i].equals(a[i]);
				}
				else {
					
				}
			}
		}
	} else {
		return false;
	}
	
	return match;
}
 
Example 17
Project: ZorahPractice   File: KitsMenu.java   Source Code and License 6 votes vote down vote up
public static void open(Player player) {
    PracticeProfile profile = ManagerHandler.getPlayerManager().getPlayerProfile(player);

    if (profile.getStatus() != PlayerStatus.LOBBY) {
        player.sendMessage(ChatColor.RED + "You must be in the lobby to open that menu.");
        return;
    }

    Inventory inv = Bukkit.createInventory(null, ManagerHandler.getLadderManager().getLadderAmount(), ChatColor.RED + "Kit Editor");

    if (!ManagerHandler.getLadderManager().getLadders().isEmpty()) {
        for (Ladder ladder : ManagerHandler.getLadderManager().getLadders().values()) {
            if (ladder.allowEdit()) {
                inv.setItem(ladder.getDisplayOrder(), new ItemBuilder(ladder.getDisplayIcon().getType(), MessageUtils.color(ladder.getDisplayName()), 1, ladder.getDisplayIcon().getDurability(), ChatColor.GRAY + "Click to edit this ladder's kits.").getItem());
            }
        }
    }

    player.openInventory(inv);
}
 
Example 18
Project: NyaaCore   File: InventoryUtils.java   Source Code and License 6 votes vote down vote up
public static boolean hasEnoughSpace(Inventory inventory, ItemStack item, int amount) {
    for (int i = 0; i < inventory.getSize(); i++) {
        if (i >= 36 && i <= 39 && inventory instanceof PlayerInventory) {
            continue;
        }
        if (inventory.getItem(i) != null && item.isSimilar(inventory.getItem(i)) &&
                inventory.getItem(i).getAmount() < item.getMaxStackSize()) {
            amount -= item.getMaxStackSize() - inventory.getItem(i).getAmount();
        } else if (inventory.getItem(i) == null || inventory.getItem(i).getType() == Material.AIR) {
            amount = 0;
        }
        if (amount < 1) {
            return true;
        }
    }
    return false;
}
 
Example 19
Project: RPGInventory   File: InventoryListener.java   Source Code and License 6 votes vote down vote up
@EventHandler(priority = EventPriority.LOW)
public void onInventoryOpen(InventoryOpenEvent event) {
    Inventory inventory = event.getInventory();
    HumanEntity player = event.getPlayer();

    if (!InventoryManager.playerIsLoaded(player)) {
        return;
    }

    if (InventoryAPI.isRPGInventory(inventory)) {
        PlayerWrapper playerWrapper = (PlayerWrapper) inventory.getHolder();
        InventoryManager.syncQuickSlots(playerWrapper);
        InventoryManager.syncInfoSlots(playerWrapper);
        InventoryManager.syncShieldSlot(playerWrapper);
        InventoryManager.syncArmor(playerWrapper);
    }
}
 
Example 20
Project: mczone   File: CompassEvents.java   Source Code and License 6 votes vote down vote up
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
	Player p = (Player) event.getWhoClicked();
	Inventory inv = event.getInventory();

	if (p.getGameMode() != GameMode.CREATIVE)
		event.setCancelled(true);
	
	if (Chat.stripColor(inv.getTitle()).equalsIgnoreCase("MC Zone Games")) {
		if (event.getRawSlot() > 9 || event.getCurrentItem() == null || event.getCurrentItem().getType() == Material.AIR)
			return;
		GameIcon game = GameIcon.get(event.getCurrentItem());
		if (game != null) {
			p.teleport(game.getTo());
			p.closeInventory();
		}
	}
}
 
Example 21
Project: AddGun   File: RailGun.java   Source Code and License 6 votes vote down vote up
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void equipWeaponEvent(InventoryDragEvent event) {
	if (!enabled) return;
	HumanEntity human = event.getWhoClicked();
	boolean alreadyHasGun = hasGun(human);
	
	Inventory inv = event.getInventory();
	ItemStack prior = event.getOldCursor();
	
	// Don't really care what sort of drag, if we have a gun in inv and this was a gun, deny.
	if (alreadyHasGun && (inv != null && !InventoryType.PLAYER.equals(inv.getType()))
			&& (prior != null && isGun(prior))) {
		event.setResult(Result.DENY);
		// yes this will prevent drag style of weapon in chest invs. Oh well.
	}
	
}
 
Example 22
Project: FactionsXL   File: TradeOfferCommand.java   Source Code and License 6 votes vote down vote up
private Inventory choosePartner(Faction creator) {
    int size = (int) (9 * Math.ceil(((double) factions.getActive().size() / 9)));
    Inventory gui = Bukkit.createInventory(null, size, FMessage.TRADE_OFFER_CHOOSE_PARTNER.getMessage());
    int i = 0;
    for (Faction faction : factions.getActive()) {
        ItemStack icon = faction.getBannerStack();
        ItemMeta meta = icon.getItemMeta();
        meta.setDisplayName(creator.getRelation(faction).getColor() + faction.getName());
        meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
        icon.setItemMeta(meta);
        gui.setItem(i, icon);
        factionBySlot.put(i, faction);
        i++;
    }
    return gui;
}
 
Example 23
Project: NeverLag   File: AntiNegativeItemDupe.java   Source Code and License 6 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onBlockDispense(BlockDispenseEvent e) {
	if (!cm.isAntiNegativeItemDupe) {
		return;
	}
	Inventory content = null;
	if (e.getBlock().getState() instanceof InventoryHolder) {
		content = ((InventoryHolder) e.getBlock().getState()).getInventory();
	}
	if (content == null || content.getSize() == 0) {
		return;
	}
	for (ItemStack item : content.getContents()) {
		if (item != null && item.getType() != Material.AIR) {
			if (item.getAmount() <= 0) {
				item.setType(Material.AIR);
			}
		}
	}
}
 
Example 24
Project: ZentrelaCore   File: MenuManager.java   Source Code and License 5 votes vote down vote up
public static void registerListener(Player p, ItemStack item, Inventory inventory, Runnable runnable) {
    if (!invClickables.containsKey(p.getUniqueId()))
        invClickables.put(p.getUniqueId(), new HashMap<String, HashMap<String, Runnable>>());
    HashMap<String, HashMap<String, Runnable>> inventories = invClickables.get(p.getUniqueId());
    if (!inventories.containsKey(inventory.getName()))
        inventories.put(inventory.getName(), new HashMap<String, Runnable>());
    HashMap<String, Runnable> thisInv = inventories.get(inventory.getName());
    thisInv.put(serializeForMenu(item), runnable);
}
 
Example 25
Project: AsgardAscension   File: MainInventory.java   Source Code and License 5 votes vote down vote up
public static void setupGodFoodInventory(Player player) {
	Inventory inv = Bukkit.createInventory(player, 9, ChatColor.BOLD + "Food of the Gods");
	inv.setItem(2, ItemStackGenerator.createItem(Material.SLIME_BALL, 0, 0,
			ChatColor.RED + "" + ChatColor.BOLD + "Add Food of the Gods", null));
	inv.setItem(4, ItemStackGenerator.createItem(Material.PAPER, 0, 0,
			ChatColor.RED + "" + ChatColor.BOLD + "Statistics", 
			Arrays.asList(ChatColor.GRAY + "Amount of God Foods: " + ChatColor.RED + GodFoodFile.getEffectAmount())));
	inv.setItem(6, ItemStackGenerator.createItem(Material.BOOK_AND_QUILL, 0, 0,
			ChatColor.RED + "" + ChatColor.BOLD + "Edit Food of the Gods", null));
	player.openInventory(inv);
}
 
Example 26
Project: RPGInventory   File: InventoryManager.java   Source Code and License 5 votes vote down vote up
public static void updateQuickSlot(@NotNull Player player, @NotNull Inventory inventory, @NotNull Slot slot, int slotId,
                                   InventoryType.SlotType slotType, InventoryAction action,
                                   ItemStack currentItem, ItemStack cursor) {
    ActionType actionType = ActionType.getTypeOfAction(action);
    if (actionType == ActionType.GET) {
        if (slot.isCup(currentItem)) {
            return;
        }

        if (player.getInventory().getHeldItemSlot() == slot.getQuickSlot()) {
            InventoryUtils.heldFreeSlot(player, slot.getQuickSlot(), InventoryUtils.SearchType.NEXT);
        }

        if (slotType == InventoryType.SlotType.QUICKBAR && InventoryAPI.isRPGInventory(inventory)) {
            inventory.setItem(slot.getSlotId(), slot.getCup());
        } else {
            player.getInventory().setItem(slot.getQuickSlot(), slot.getCup());
        }

        action = InventoryAction.SWAP_WITH_CURSOR;
        cursor = slot.getCup();
    } else if (actionType == ActionType.SET) {
        if (slot.isCup(currentItem)) {
            currentItem = null;
            action = InventoryAction.PLACE_ALL;
        }

        if (slotType == InventoryType.SlotType.QUICKBAR && InventoryAPI.isRPGInventory(inventory)) {
            inventory.setItem(slot.getSlotId(), cursor);
        } else {
            player.getInventory().setItem(slot.getQuickSlot(), cursor);
        }
    }

    InventoryManager.updateInventory(player, inventory, slotId, slotType, action, currentItem, cursor);
}
 
Example 27
Project: Transport-Pipes   File: CreativeCommandExecutor.java   Source Code and License 5 votes vote down vote up
@Override
public boolean onCommand(CommandSender cs, String[] args) {

	if (!cs.hasPermission("transportpipes.creative")) {
		return false;
	}

	if (cs instanceof Player) {
		Inventory inv = Bukkit.createInventory(null, 9 * 3, LocConf.load(LocConf.CREATIVE_TITLE));

		int i = 0;
		List<ItemStack> ductItems = DuctItemUtils.getAllDuctItems();
		for (ItemStack is : ductItems) {
			ItemStack clonedIs = is.clone();
			clonedIs.setAmount(16);
			inv.setItem(i, clonedIs);
			i++;
		}
		inv.setItem(i++, DuctItemUtils.getClonedWrenchItem());

		((Player) cs).openInventory(inv);
	} else {
		cs.sendMessage("§cYou're not a player!");
	}

	return true;
}
 
Example 28
Project: AlphaLibary   File: Menu.java   Source Code and License 5 votes vote down vote up
public void open(Player p, InventoryHolder holder) {
    Inventory inv = Bukkit.createInventory(holder, getSize(), getTitle());

    for (Map.Entry<Integer, MenuElement> element : this.elements.entrySet()) {
        inv.setItem(element.getKey(), element.getValue().getIcon(p));
    }

    getMenuManager().setMenuOpened(p, this);

    p.openInventory(inv);
}
 
Example 29
Project: MCLibrary   File: SimpleGUI.java   Source Code and License 5 votes vote down vote up
@Override
protected Inventory createInventory() {
    GUIData data = getData();
    Inventory inv = data.type() == InventoryType.CHEST
            ? Bukkit.createInventory(null, data.size(), data.title())
            : Bukkit.createInventory(null, data.type(), data.title());
    inv.setContents(data.contents());
    return inv;
}
 
Example 30
Project: ZorahPractice   File: InventoryUtils.java   Source Code and License 5 votes vote down vote up
public static Inventory inventoryFromString(String in) {
    Inventory inv = Bukkit.createInventory((InventoryHolder) null, 54);
    String[] split;
    @SuppressWarnings("unused")
    String[] data = split = in.split(";");

    for (String s : split) {
        String[] info = s.split("#");
        inv.setItem(Integer.parseInt(info[0]), (info.length > 1) ? itemStackFromString(info[1]) : null);
    }

    return inv;
}
 
Example 31
Project: RPGInventory   File: InventoryManager.java   Source Code and License 5 votes vote down vote up
private static void updateInventory(
        @NotNull Player player,
        @NotNull Inventory inventory,
        int slot,
        InventoryAction action,
        ItemStack currentItem,
        @NotNull ItemStack cursor
) {
    InventoryManager.updateInventory(player, inventory, slot, InventoryType.SlotType.CONTAINER, action, currentItem, cursor);
}
 
Example 32
Project: CustomRecipes   File: ShapedAdder.java   Source Code and License 5 votes vote down vote up
@EventHandler
public void onInventoryClose(InventoryCloseEvent event) {
	if (event.getInventory().getHolder() instanceof ShapedRecipeHolder) {
		ShapedRecipeHolder holder = (ShapedRecipeHolder) event.getInventory().getHolder();
		if (holder != this) return;

		Inventory inventory = event.getInventory();
		if (InventoryUtils.isEmpty(inventory)) {
			holder.callbackPlayer.sendMessage(ChatColor.RED + "Do you seriously want to create a recipe without ingredients?");
			return;
		}

		ShapedRecipes nmsRecipe = holder.toRecipe();
		CRShapedRecipe<ShapedRecipes> shapedRecipe = new CRShapedRecipe<>(nmsRecipe);
		List<List<String>> recipeIngredients = shapedRecipe.getIngredients().stream()
				.map((CRChoiceIngredient ingr) -> ingr.getChoices().stream()
						.map(InventoryUtils::getItemName).collect(Collectors.toList()))
				.collect(Collectors.toList());
		String recipeString = recipeIngredients + "" +
				ChatColor.RESET + " -> " +
				InventoryUtils.getItemName(shapedRecipe.getResult());

		boolean success = holder.plugin.getCraftingManager().addRecipe(holder.key, nmsRecipe, shapedRecipe);
		if (success) {
			holder.callbackPlayer.sendMessage(String.format("%sAdded shaped recipe: %s%s%s!",
					ChatColor.GREEN, ChatColor.WHITE, recipeString, ChatColor.WHITE));
			plugin.saveCraftingRecipeFile("shaped", shapedRecipe);
		} else {
			holder.callbackPlayer.sendMessage(ChatColor.RED + "Couldn't create a shaped recipe. Possibly a duplicate key.");
		}

		HandlerList.unregisterAll(holder);
	}
}
 
Example 33
Project: CustomRecipes   File: ListRecipesInventoryHolder.java   Source Code and License 5 votes vote down vote up
public ListRecipesInventoryHolder(String type, Iterable<? extends ItemStack> items) {
	items.forEach(recipeItems::add);
	
	//fill page inventories
	int recipeIndex = 0;
	Inventory inventory = null;
	do {
		int inPageIndex = recipeIndex % MAX_RECIPES_PER_PAGE;
		if (inPageIndex == 0) {
			inventory = Bukkit.createInventory(this, 54, type + " recipes");
			pages.add(inventory);
		}
		
		inventory.setItem(inPageIndex, recipeItems.get(recipeIndex));
	} while (++recipeIndex < recipeItems.size());
	
	//add previous and next buttons where applicable
	for (int pageNr = 0; pageNr < pages.size(); pageNr++) {
		Inventory page = pages.get(pageNr);
		if (pageNr != 0) {
			page.setItem(45, ListRecipesListener.previousItem());
		}
		if (pageNr != pages.size() - 1) {
			page.setItem(53, ListRecipesListener.nextItem());
		}
	}
}
 
Example 34
Project: RPGInventory   File: MyPetManager.java   Source Code and License 5 votes vote down vote up
@EventHandler
public void onMyPetItemUse(PlayerInteractEvent event) {
    if (event.getItem() != null) {
        Player player = event.getPlayer();

        if (!InventoryManager.playerIsLoaded(player)) {
            return;
        }

        Inventory inventory = InventoryManager.get(player).getInventory();

        if (isMyPetItem(event.getItem())
                && (event.getAction() == Action.RIGHT_CLICK_BLOCK
                || event.getAction() == Action.RIGHT_CLICK_AIR)) {
            Slot petSlot = getMyPetSlot();

            ItemStack currentPet = inventory.getItem(petSlot.getSlotId());
            boolean hasPet = !petSlot.isCup(currentPet);
            ItemStack newPet = event.getItem();

            if (!hasPet) {
                currentPet = null;
            }

            player.getEquipment().setItemInMainHand(currentPet);
            inventory.setItem(petSlot.getSlotId(), newPet);

            swapMyPets(player, hasPet, newPet);
        }
    }
}
 
Example 35
Project: CloudNet   File: MobSelector.java   Source Code and License 5 votes vote down vote up
public Collection<Inventory> inventories()
{
    return CollectionWrapper.getCollection(this.mobs, new Catcher<Inventory, MobImpl>() {
        @Override
        public Inventory doCatch(MobImpl key)
        {
            return key.getInventory();
        }
    });
}
 
Example 36
Project: CloudNet   File: MobSelector.java   Source Code and License 5 votes vote down vote up
public MobImpl find(Inventory inventory)
{
    return CollectionWrapper.filter(this.mobs.values(), new Acceptable<MobImpl>() {
        @Override
        public boolean isAccepted(MobImpl value)
        {
            return value.getInventory().equals(inventory);
        }
    });
}
 
Example 37
Project: NeverLag   File: GUISortPing.java   Source Code and License 5 votes vote down vote up
public Inventory getNextPage() {
	if (this.page >= this.maxPage) {
		if (this.guiMaker != null) {
			return this.guiMaker.get();
		} else {
			return get(this.page);
		}
	} else {
		this.page++;
		return get(this.page);
	}
}
 
Example 38
Project: Transport-Pipes   File: SettingsInv.java   Source Code and License 5 votes vote down vote up
private static void populateInventoryLine(Inventory inv, int row, ItemStack... items) {
	for (int i = 0; i < 9; i++) {
		if (items.length > i && items[i] != null) {
			ItemStack is = items[i];
			inv.setItem(row * 9 + i, is);
		}
	}
}
 
Example 39
Project: PA   File: BagEvents.java   Source Code and License 5 votes vote down vote up
private static Inventory getInventory(TOAUser p) {
    Inventory i = Bukkit.createInventory(null, getInvSize(p), ChatColor.RED + "Mochila");
    ItemStack[] item = i.getContents();
    if (FileUtils.getInv().contains(p.getName())) {
        for (int x = 0; x < getInvSize(p); x++)
            item[x] = FileUtils.getInv().getItemStack(p.getName() + ".inv_" + x);
        i.setContents(item);
        return i;
    }
    return i;
}
 
Example 40
Project: ProjectAres   File: GizmoUtils.java   Source Code and License 5 votes vote down vote up
public static void openMenu(Player player) {
    Inventory inventory = Bukkit.createInventory(player, 18, ChatColor.RED + LobbyTranslations.get().t("gizmos", player));
    inventory.setItem(4, Utils.getGhastTear(player, RaindropsListener.raindrops.get(player)));

    int i = 9;
    for(Gizmo gizmo : Gizmos.gizmos) {
        inventory.setItem(i++, gizmo.getItemStack(player));
    }

    player.openInventory(inventory);
}
 
Example 41
Project: AsgardAscension   File: GodTokensInventory.java   Source Code and License 5 votes vote down vote up
public static void setupRepairMenu(Player player) {
	Inventory inv = Bukkit.createInventory(player, 9, ChatColor.BOLD + "Repair Menu");
	
	if(player.getInventory().getItemInMainHand().getType() != Material.AIR) {
		if(ItemStackGenerator.isRepairable(player.getInventory().getItemInMainHand())) {
			if(player.getInventory().getItemInMainHand().getDurability() < 2) {
				inv.setItem(3, ItemStackGenerator.createItem(Material.STRING, 1, 0,
						ChatColor.LIGHT_PURPLE + "Your item in hand doesn't need a repair!", 
						null));
			}
			else {
				ItemStack item = player.getInventory().getItemInMainHand();
				inv.setItem(3, ItemStackGenerator.createItem(item.getType(), item.getAmount(), item.getDurability(),
						ChatColor.LIGHT_PURPLE + "Repair item in main hand", 
						Arrays.asList("Price: " + ChatColor.RED + "1 GT")));
			}
		}
		else {
			inv.setItem(3, ItemStackGenerator.createItem(Material.STRING, 1, 0,
					ChatColor.LIGHT_PURPLE + "Your item in hand can't be repaired!", 
					null));
		}
	}
	else {
		inv.setItem(3, ItemStackGenerator.createItem(Material.STRING, 1, 0,
				ChatColor.LIGHT_PURPLE + "You don't have any item in hand!", 
				null));
	}
	inv.setItem(4, ItemStackGenerator.createItem(Material.CHEST, 1, 0, 
			ChatColor.LIGHT_PURPLE + "Repair entire inventory",
			Arrays.asList("Price: " + ChatColor.RED + "5 GT")));
	
	inv.setItem(8, ItemStackGenerator.createItem(Material.REDSTONE_BLOCK, 0, 0, ChatColor.RED + "Go back!", null));
	player.openInventory(inv);
}
 
Example 42
Project: Debuggery   File: OutputFormatter.java   Source Code and License 5 votes vote down vote up
@Nonnull
private static String handleInventory(Inventory inventory) {
    final String basicInfo = "name=" + inventory.getName() + ", title=" + inventory.getTitle()
            + ", size=" + inventory.getSize() + "\n";

    return basicInfo + handleArray(inventory.getContents());

}
 
Example 43
Project: MCLibrary   File: Inventories.java   Source Code and License 5 votes vote down vote up
public static boolean hasItem(Inventory inv, ItemStack item, int amount) {
    int hasAmount = 0;
    for (ItemStack elemItem : inv) {
        if (elemItem == null || elemItem.getType() == Material.AIR
                || !elemItem.isSimilar(item))
            continue;
        hasAmount += elemItem.getAmount();
        if (hasAmount >= amount)
            return true;
    }
    return false;
}
 
Example 44
Project: ProjectAres   File: WindowListener.java   Source Code and License 5 votes vote down vote up
/**
 * Called when an open window is clicked.
 */
default boolean windowClicked(InventoryView window,
                              Inventory inventory,
                              ClickType clickType,
                              InventoryType.SlotType slotType,
                              int slotIndex,
                              @Nullable ItemStack item) {
    return false;
}
 
Example 45
Project: ZorahPractice   File: InventoryUtils.java   Source Code and License 5 votes vote down vote up
public static String inventoryToString(Inventory inv) {
    StringBuilder builder = new StringBuilder();

    for (int i = 0; i < inv.getContents().length; ++i) {
        builder.append(i).append("#").append(itemStackToString(inv.getContents()[i]));
        if (i != inv.getContents().length - 1) {
            builder.append(";");
        }
    }

    return builder.toString();
}
 
Example 46
Project: RPGInventory   File: PetListener.java   Source Code and License 5 votes vote down vote up
@EventHandler
public void onItemUse(PlayerInteractEvent event) {
    Player player = event.getPlayer();

    if (!event.hasItem() || !InventoryManager.playerIsLoaded(player)) {
        return;
    }

    Inventory inventory = InventoryManager.get(player).getInventory();
    ItemStack petItem = event.getItem();

    if (player.getGameMode() == GameMode.CREATIVE && PetManager.isPetItem(petItem)) {
        petItem = PetManager.toPetItem(petItem);
        player.getEquipment().setItemInMainHand(petItem);
    }

    if (PetType.isPetItem(petItem)
            && (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR)) {
        Slot petSlot = SlotManager.instance().getPetSlot();
        if (petSlot != null && petSlot.isCup(inventory.getItem(PetManager.getPetSlotId()))
                && ItemManager.allowedForPlayer(player, petItem, false)) {
            inventory.setItem(PetManager.getPetSlotId(), event.getItem());
            PetManager.spawnPet(player, petItem);
            player.getEquipment().setItemInMainHand(null);
        }

        event.setCancelled(true);
    }
}
 
Example 47
Project: OMGPI   File: OMGPlayer.java   Source Code and License 5 votes vote down vote up
/**
 * Open hotbar editor menu.
 */
public void hotbarEdit() {
    selectedHBESlot = -1;
    Inventory hbe = Bukkit.createInventory(bukkit, 9, "Hotbar Editor");
    String order = OMGPI.g.player_hotbarOrder(this);
    for (int c = 0; c < order.length(); c++) {
        int i = Integer.parseInt(order.charAt(c) + "");
        NBTParser clickable = OMGPI.g.kit_contents(this, kit).stream().filter(nbt -> nbt.getInt("Slot") == i).findFirst().orElse(new NBTParser("{id:barrier,Count:1,Slot:" + i + "}"));
        clickable.setString("tag.display.Name", i + 1 + "");
        hbe.setItem(c, clickable.toItem());
    }
    bukkit.openInventory(hbe);
}
 
Example 48
Project: RPGInventory   File: InventoryManager.java   Source Code and License 5 votes vote down vote up
public static void updateShieldSlot(@NotNull Player player, @NotNull Inventory inventory, @NotNull Slot slot, int slotId,
                                    InventoryType.SlotType slotType, InventoryAction action,
                                    ItemStack currentItem, ItemStack cursor) {
    ActionType actionType = ActionType.getTypeOfAction(action);
    if (actionType == ActionType.GET) {
        if (slot.isCup(currentItem)) {
            return;
        }

        if (slotType == InventoryType.SlotType.QUICKBAR && InventoryAPI.isRPGInventory(inventory)) {
            inventory.setItem(slot.getSlotId(), slot.getCup());
        } else {
            player.getEquipment().setItemInOffHand(new ItemStack(Material.AIR));
        }
    } else if (actionType == ActionType.SET) {
        if (slot.isCup(currentItem)) {
            currentItem = null;
            action = InventoryAction.PLACE_ALL;
        }

        if (slotType == InventoryType.SlotType.QUICKBAR && InventoryAPI.isRPGInventory(inventory)) {
            inventory.setItem(slot.getSlotId(), cursor);
        } else {
            player.getEquipment().setItemInOffHand(cursor);
        }
    }

    InventoryManager.updateInventory(player, inventory, slotId, slotType, action, currentItem, cursor);
}
 
Example 49
Project: FactionsXL   File: PageGUI.java   Source Code and License 5 votes vote down vote up
public Inventory newPage() {
    Inventory gui = Bukkit.createInventory(null, 54, title);
    gui.setItem(45, PREVIOUS_PAGE);
    gui.setItem(46, PLACEHOLDER);
    gui.setItem(47, PLACEHOLDER);
    gui.setItem(48, PLACEHOLDER);
    gui.setItem(49, PLACEHOLDER);
    gui.setItem(50, PLACEHOLDER);
    gui.setItem(51, PLACEHOLDER);
    gui.setItem(52, PLACEHOLDER);
    gui.setItem(53, NEXT_PAGE);
    pages.add(gui);
    return gui;
}
 
Example 50
Project: RealSurvival   File: CraftItemGUI.java   Source Code and License 5 votes vote down vote up
public  Inventory sFList(int start,Player p){
	Inventory inv = Bukkit.createInventory(null,54 , "��9��l �䷽�б�");
	for(WorkbenchRecipe sf:rs.getSF()){
		if(!(p.hasPermission("RealSurvival.Items."+sf.getName())||(
				p.hasPermission("RealSurvival.Items.*")&&p.hasPermission("RealSurvival.Items."+sf.getName())))) continue;
		if(sf==null||sf.getProduct().get(24)==null)
			inv.addItem(Items.getPlaceholder9(sf.getName(),new ItemStack(Material.BOOK).clone(),sf.getBuiltTime()));
		else
			inv.addItem(Items.getPlaceholder9(sf.getName(),sf.getProduct().get(24).clone(),sf.getBuiltTime()));
	}
	if(rs.getSF().size()>54)
		inv.setItem(53, Items.getPlaceholder7());
	return inv;
}
 
Example 51
Project: RPGInventory   File: PetManager.java   Source Code and License 5 votes vote down vote up
public static void respawnPet(OfflinePlayer player) {
    if (!InventoryManager.playerIsLoaded(player) || !PetManager.isEnabled()) {
        return;
    }

    Inventory inventory = InventoryManager.get(player).getInventory();
    despawnPet(player);
    spawnPet((Player) player, inventory.getItem(SLOT_PET));
}
 
Example 52
Project: WC   File: ChestManager.java   Source Code and License 5 votes vote down vote up
private void setItem(Inventory inv, int slot, ItemStack i){
    if (inv.getItem(slot) != null){
        setItem(inv, getSlot(r, inv), i);
        return;
    }
    inv.setItem(slot, i);
}
 
Example 53
Project: KingdomFactions   File: YesNoConfirmation.java   Source Code and License 5 votes vote down vote up
public Inventory getMenu() {
	Inventory in = Bukkit.createInventory(null, 27, ChatColor.RED + "Weet je het zeker?");
	for (int i = 0; i < 27; i++) {
		in.setItem(i, Item.getInstance().getItem(Material.STAINED_GLASS_PANE, " ", 1, 0));
	}
	in.setItem(4, Item.getInstance().getItem(Material.NETHER_STAR, title, 1));
       in.setItem(11, Item.getInstance().getItem(Material.EMERALD_BLOCK, ChatColor.GREEN + "Ja.", 1, yesLore));
       in.setItem(15, Item.getInstance().getItem(Material.REDSTONE_BLOCK, ChatColor.RED + "Nee.", 1, noLore));
       return in;
}
 
Example 54
Project: EchoPet   File: InventoryMenu.java   Source Code and License 5 votes vote down vote up
public InventoryMenu showTo(Player viewer) {
    Inventory inv = this.getInventory();
    for (Map.Entry<Integer, MenuIcon> entry : slots.entrySet()) {
        inv.setItem(entry.getKey(), entry.getValue().getIcon(viewer));
    }
    viewer.openInventory(inv);
    return this;
}
 
Example 55
Project: UltraCore   File: TeleportMenu.java   Source Code and License 4 votes vote down vote up
public static void newInventory(CommandSender sender) {
    Inventory tpmenu = Bukkit.createInventory(null, 54, ChatColor.DARK_GRAY + "Teleport Menu - Page 1");

    ItemStack empty = new ItemStack(Material.STAINED_GLASS_PANE, 1, (byte) 15);
    ItemMeta emptyMeta = empty.getItemMeta();
    emptyMeta.setDisplayName(" ");
    empty.setItemMeta(emptyMeta);

    ItemStack close = new ItemStack(Material.BARRIER);
    ItemStack nextpage = new ItemStack(Material.SIGN);
    ItemStack previouspage = new ItemStack(Material.SIGN);
    ItemMeta npMeta = nextpage.getItemMeta();
    ItemMeta ppMeta = previouspage.getItemMeta();
    ItemMeta closeMeta = close.getItemMeta();
    closeMeta.setDisplayName(ChatColor.RED + "Close the menu.");
    npMeta.setDisplayName(ChatColor.AQUA + "" + ChatColor.BOLD + "Next Page");
    ppMeta.setDisplayName(ChatColor.AQUA + "" + ChatColor.BOLD + "Previous Page");

    for (int i = 0; i < Bukkit.getOnlinePlayers().size(); i++) {
        Player targetPlayer = (Player) Bukkit.getOnlinePlayers().toArray()[i];
        ItemStack skulls = new ItemStack(Material.SKULL_ITEM, 1, (byte) 3);
        SkullMeta skullsMeta = (SkullMeta) skulls.getItemMeta();
        skullsMeta.setDisplayName(ChatColor.YELLOW + "Teleport to " + ChatColor.GREEN + targetPlayer.getName());
        skullsMeta.setOwner(targetPlayer.getName());
        skulls.setItemMeta(skullsMeta);

        int beginningSlot = 9;
        tpmenu.setItem(i + beginningSlot, skulls);
    }

    tpmenu.setItem(0, empty);
    tpmenu.setItem(1, empty);
    tpmenu.setItem(2, empty);
    tpmenu.setItem(3, empty);
    tpmenu.setItem(4, empty);
    tpmenu.setItem(5, empty);
    tpmenu.setItem(6, empty);
    tpmenu.setItem(7, empty);
    tpmenu.setItem(8, empty);
    tpmenu.setItem(45, empty);
    tpmenu.setItem(46, empty);
    tpmenu.setItem(47, empty);
    tpmenu.setItem(48, empty);
    tpmenu.setItem(49, close);
    tpmenu.setItem(50, empty);
    tpmenu.setItem(51, empty);
    tpmenu.setItem(52, empty);
    tpmenu.setItem(53, nextpage);

    ((HumanEntity) sender).openInventory(tpmenu);
}
 
Example 56
Project: AlphaLibary   File: AdvancedInventory.java   Source Code and License 4 votes vote down vote up
public Inventory getBukkitInventory() {
    return bukkitInventory;
}
 
Example 57
Project: KingdomFactions   File: Shop.java   Source Code and License 4 votes vote down vote up
public void removeItems(KingdomFactionsPlayer p, Material material, int amount, short data, int coins,
		ShopItem shopItem) {
	Inventory inv = p.getInventory();
	for (int i = 0; i < inv.getSize(); i++) {
		if (inv.getItem(i) != null) {
			if (inv.getItem(i).getType() == material) {
				if (inv.getItem(i).getAmount() == amount) {
					if (inv.getItem(i).getDurability() == data && inv.getItem(i).getItemMeta().getEnchants()
							.toString().equalsIgnoreCase(shopItem.getItem().getEnchantments().toString())) {
						inv.setItem(i, new ItemStack(Material.AIR));
						p.addCoins(coins);
						new ShopLog(p, shopItem, ShopAction.SELL);
						if (amount == 1) {
							p.sendMessage(
									Messages.getInstance().getPrefix() + "Je hebt " + amount + " item verkocht.");
						} else
							p.sendMessage(
									Messages.getInstance().getPrefix() + "Je hebt " + amount + " items verkocht.");
						return;
					}
				} else if (inv.getItem(i).getAmount() >= amount) {
					if (inv.getItem(i).getDurability() == data) {
						int newAmount = inv.getItem(i).getAmount() - amount;
						if (newAmount >= 0) {
							p.getInventory().getItem(i).setAmount(newAmount);
							p.addCoins(coins);
							new ShopLog(p, shopItem, ShopAction.SELL);
							if (amount == 1) {
								p.sendMessage(Messages.getInstance().getPrefix() + "Je hebt " + amount
										+ " item verkocht.");
							} else
								p.sendMessage(Messages.getInstance().getPrefix() + "Je hebt " + amount
										+ " items verkocht.");
						}
						return;
					}
				}
			}
		}
	}
	if (amount <= 1) {
		p.sendMessage(Messages.getInstance().getPrefix() + "Je hebt minimaal " + amount + " item nodig.");
	} else
		p.sendMessage(Messages.getInstance().getPrefix() + "Je hebt minimaal " + amount + " items nodig.");
}
 
Example 58
Project: ProjectAres   File: FillListener.java   Source Code and License 4 votes vote down vote up
@Override
Stream<Inventory> inventories() {
    return Stream.of(inventory);
}
 
Example 59
Project: HCFCore   File: EventSetLootArgument.java   Source Code and License 4 votes vote down vote up
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (!(sender instanceof Player)) {
        sender.sendMessage(ChatColor.RED + "This command is only executable by players.");
        return true;
    }

    if (args.length < 3) {
        sender.sendMessage(ChatColor.RED + "Usage: " + getUsage(label));
        return true;
    }

    EventType eventType = EventType.getByDisplayName(args[1]);

    if (eventType == null) {
        sender.sendMessage(ChatColor.RED + "There is not an event type named " + args[1] + '.');
        return true;
    }

    Integer index = Ints.tryParse(args[2]);

    if (index == null) {
        sender.sendMessage(ChatColor.RED + "'" + args[2] + "' is not a number.");
        return true;
    }

    List<Inventory> inventories = plugin.getKeyManager().getEventKey().getInventories(eventType);
    int size = inventories.size();

    if (index < 1) {
        sender.sendMessage(ChatColor.RED + "You cannot edit an inventory less than 1.");
        return true;
    }

    if (index > size) {
        sender.sendMessage(ChatColor.RED + "There are only " + size + " possible loot inventories for " + eventType.getDisplayName() + ChatColor.RED + ". Use " + ChatColor.YELLOW + '/' + label
                + " addloottable " + eventType.name() + ChatColor.RED + " to add another.");

        return true;
    }

    ((Player) sender).openInventory(inventories.get(--index));
    return true;
}
 
Example 60
Project: RealSurvival   File: CraftItemGUI.java   Source Code and License 4 votes vote down vote up
public static Inventory createWorkbenchGUI(ItemStack itemKey){
	Inventory inv=createDefaultGUI(rs.getWorkbenchItems()[7]);
	inv.setItem(0, itemKey);
	inv.setItem(49, Items.createPItem((short) 14, "��b��l==>��c��l��ʼ�����b��l<=="));
	return inv;
}