001/*
002 * PlotSquared, a land and world management plugin for Minecraft.
003 * Copyright (C) IntellectualSites <https://intellectualsites.com>
004 * Copyright (C) IntellectualSites team and contributors
005 *
006 * This program is free software: you can redistribute it and/or modify
007 * it under the terms of the GNU General Public License as published by
008 * the Free Software Foundation, either version 3 of the License, or
009 * (at your option) any later version.
010 *
011 * This program is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014 * GNU General Public License for more details.
015 *
016 * You should have received a copy of the GNU General Public License
017 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
018 */
019package com.plotsquared.core.plot;
020
021import com.sk89q.worldedit.world.block.BlockState;
022import com.sk89q.worldedit.world.item.ItemType;
023import com.sk89q.worldedit.world.item.ItemTypes;
024
025public class PlotItemStack {
026
027    private final int amount;
028    private final String name;
029    private final String[] lore;
030    private final ItemType type;
031
032    /**
033     * @param id     String ID
034     * @param amount Amount of items in the stack
035     * @param name   The display name of the item stack
036     * @param lore   The item stack lore
037     */
038    public PlotItemStack(
039            final String id, final int amount, final String name,
040            final String... lore
041    ) {
042        this(ItemTypes.get(id), amount, name, lore);
043    }
044
045    /**
046     * @param type   The item type
047     * @param amount Amount of items in the stack
048     * @param name   The display name of the item stack
049     * @param lore   The item stack lore
050     * @since 6.5.0
051     */
052    public PlotItemStack(
053            final ItemType type, final int amount, final String name,
054            final String... lore
055    ) {
056        this.type = type;
057        this.amount = amount;
058        this.name = name;
059        this.lore = lore;
060    }
061
062    public BlockState getBlockState() {
063        return getType().getBlockType().getDefaultState();
064    }
065
066    public ItemType getType() {
067        return this.type;
068    }
069
070    public int getAmount() {
071        return amount;
072    }
073
074    public String getName() {
075        return name;
076    }
077
078    public String[] getLore() {
079        return lore;
080    }
081
082}