Search in sources :

Example 1 with ShopCategory

use of com.iridium.iridiumskyblock.shop.ShopCategory in project IridiumSkyblock by Iridium-Development.

the class ShopOverviewGUI method addContent.

/**
 * Called when updating the Inventories contents
 */
@Override
public void addContent(Inventory inventory) {
    inventory.clear();
    InventoryUtils.fillInventory(inventory, IridiumSkyblock.getInstance().getShop().overviewBackground);
    for (ShopCategory category : IridiumSkyblock.getInstance().getShopManager().getCategories()) {
        inventory.setItem(category.item.slot, ItemStackUtils.makeItem(category.item));
    }
    if (IridiumSkyblock.getInstance().getConfiguration().backButtons && getPreviousInventory() != null) {
        inventory.setItem(inventory.getSize() + IridiumSkyblock.getInstance().getInventories().backButton.slot, ItemStackUtils.makeItem(IridiumSkyblock.getInstance().getInventories().backButton));
    }
}
Also used : ShopCategory(com.iridium.iridiumskyblock.shop.ShopCategory)

Example 2 with ShopCategory

use of com.iridium.iridiumskyblock.shop.ShopCategory in project IridiumSkyblock by Iridium-Development.

the class ShopCommand method execute.

/**
 * Executes the command for the specified {@link CommandSender} with the provided arguments. Not
 * called when the command execution was invalid (no permission, no player or command
 * disabled).
 *
 * @param sender    The CommandSender which executes this command
 * @param arguments The arguments used with this command. They contain the sub-command
 */
@Override
public boolean execute(CommandSender sender, String[] arguments) {
    Player player = (Player) sender;
    User user = IridiumSkyblockAPI.getInstance().getUser(player);
    if (!user.getIsland().isPresent()) {
        player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().noIsland.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
        return false;
    }
    if (arguments.length == 1) {
        player.openInventory(new ShopOverviewGUI(player.getOpenInventory().getTopInventory()).getInventory());
    } else {
        String[] commandArguments = Arrays.copyOfRange(arguments, 1, arguments.length);
        String categoryName = String.join(" ", commandArguments);
        Optional<ShopCategory> category = IridiumSkyblock.getInstance().getShopManager().getCategoryByName(categoryName);
        if (!category.isPresent()) {
            player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().noShopCategory.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
            return false;
        }
        player.openInventory(new ShopCategoryGUI(category.get(), player.getOpenInventory().getTopInventory()).getInventory());
    }
    return true;
}
Also used : ShopCategoryGUI(com.iridium.iridiumskyblock.gui.ShopCategoryGUI) Player(org.bukkit.entity.Player) ShopCategory(com.iridium.iridiumskyblock.shop.ShopCategory) User(com.iridium.iridiumskyblock.database.User) ShopOverviewGUI(com.iridium.iridiumskyblock.gui.ShopOverviewGUI)

Aggregations

ShopCategory (com.iridium.iridiumskyblock.shop.ShopCategory)2 User (com.iridium.iridiumskyblock.database.User)1 ShopCategoryGUI (com.iridium.iridiumskyblock.gui.ShopCategoryGUI)1 ShopOverviewGUI (com.iridium.iridiumskyblock.gui.ShopOverviewGUI)1 Player (org.bukkit.entity.Player)1