forked from SteamWar/SteamWar
Add BauSystem module
Fix ci java version Fix LinkageProcessor
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2022 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.lobby.util;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemBuilder {
|
||||
|
||||
private final ItemStack item;
|
||||
private final ItemMeta meta;
|
||||
|
||||
public ItemBuilder(Material matrial) {
|
||||
item = new ItemStack(matrial);
|
||||
meta = item.getItemMeta();
|
||||
}
|
||||
|
||||
|
||||
public ItemBuilder(Material matrial, int amount) {
|
||||
item = new ItemStack(matrial, amount);
|
||||
meta = item.getItemMeta();
|
||||
}
|
||||
|
||||
public ItemBuilder removeAllAttributes() {
|
||||
meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
|
||||
meta.addItemFlags(ItemFlag.HIDE_DESTROYS);
|
||||
meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
|
||||
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||
meta.addItemFlags(ItemFlag.HIDE_PLACED_ON);
|
||||
meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder setDisplayName(String name) {
|
||||
meta.setDisplayName(name);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder addLore(List<String> lore) {
|
||||
meta.setLore(lore);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder addEnchantment(Enchantment enchantment, int level) {
|
||||
meta.addEnchant(enchantment, level, true);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStack build() {
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
|
||||
public ItemBuilder setUnbreakable(boolean unbreakable) {
|
||||
meta.setUnbreakable(unbreakable);
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user