use of io.github.wysohn.triggerreactor.core.bridge.IItemStack in project TriggerReactor by wysohn.
the class InventoryTriggerManager method setData.
@Override
public void setData(File file, String key, Object value) throws IOException {
if (key.equals(ITEMS)) {
Utf8YamlConfiguration conf = new Utf8YamlConfiguration();
try {
conf.load(file);
} catch (InvalidConfigurationException e) {
e.printStackTrace();
}
IItemStack[] items = (IItemStack[]) value;
writeItemList(conf, items);
conf.save(file);
} else {
BukkitTriggerManager.super.setData(file, key, value);
}
}
use of io.github.wysohn.triggerreactor.core.bridge.IItemStack in project TriggerReactor by wysohn.
the class InventoryTriggerManager method parseItemsList.
@SuppressWarnings("unchecked")
private void parseItemsList(ConfigurationSection itemSection, Map<Integer, IItemStack> items, int size) {
for (int i = 0; i < size; i++) {
ConfigurationSection section = itemSection.getConfigurationSection(String.valueOf(i));
if (section == null)
continue;
Material type = Material.valueOf((String) section.get("Type", Material.DIRT.name()));
int amount = section.getInt("Amount", 1);
short data = (short) section.getInt("Data", 0);
ItemMeta IM = (ItemMeta) section.get("Meta");
ItemStack IS = new ItemStack(type, amount, data);
if (IM == null)
IM = IS.getItemMeta();
if (IM != null) {
// leave these for backward compatibility
String title = section.getString("Title", null);
Object lore = section.get("Lore", null);
if (title != null)
IM.setDisplayName(title);
if (lore != null && lore instanceof List)
IM.setLore((List<String>) lore);
IS.setItemMeta(IM);
}
items.put(i, new BukkitItemStack(IS));
}
}
use of io.github.wysohn.triggerreactor.core.bridge.IItemStack in project TriggerReactor by wysohn.
the class JavaPluginBridge method setLore.
@Override
protected boolean setLore(IItemStack iS, int index, String lore) {
ItemStack IS = iS.get();
ItemMeta IM = IS.getItemMeta();
List<String> lores = IM.hasLore() ? IM.getLore() : new ArrayList<>();
if (lore == null || index < 0 || index > lores.size() - 1)
return false;
lores.set(index, lore);
IM.setLore(lores);
IS.setItemMeta(IM);
return true;
}
use of io.github.wysohn.triggerreactor.core.bridge.IItemStack in project TriggerReactor by wysohn.
the class JavaPluginBridge method setItemTitle.
@Override
protected void setItemTitle(IItemStack iS, String title) {
ItemStack IS = iS.get();
ItemMeta IM = IS.getItemMeta();
IM.setDisplayName(title);
IS.setItemMeta(IM);
}
use of io.github.wysohn.triggerreactor.core.bridge.IItemStack in project TriggerReactor by wysohn.
the class JavaPluginBridge method addItemLore.
@Override
protected void addItemLore(IItemStack iS, String lore) {
ItemStack IS = iS.get();
ItemMeta IM = IS.getItemMeta();
List<String> lores = IM.hasLore() ? IM.getLore() : new ArrayList<>();
lores.add(lore);
IM.setLore(lores);
IS.setItemMeta(IM);
}
Aggregations