use of io.github.wysohn.triggerreactor.misc.Utf8YamlConfiguration 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.misc.Utf8YamlConfiguration in project TriggerReactor by wysohn.
the class RepeatingTriggerManager method saveInfo.
@Override
protected void saveInfo(RepeatingTrigger trigger) throws IOException {
Utf8YamlConfiguration yaml = new Utf8YamlConfiguration();
yaml.set("AutoStart", false);
yaml.set("Interval", trigger.getInterval());
yaml.save(new File(folder, trigger.getTriggerName() + ".yml"));
FileUtil.writeToFile(new File(folder, trigger.getTriggerName()), trigger.getScript());
}
use of io.github.wysohn.triggerreactor.misc.Utf8YamlConfiguration in project TriggerReactor by wysohn.
the class BukkitConfigurationFileIO method setData.
@Override
default void setData(File file, String key, Object value) throws IOException {
Utf8YamlConfiguration conf = new Utf8YamlConfiguration();
try {
conf.load(file);
} catch (InvalidConfigurationException e) {
e.printStackTrace();
}
conf.set(key, value);
conf.save(file);
}
use of io.github.wysohn.triggerreactor.misc.Utf8YamlConfiguration in project TriggerReactor by wysohn.
the class InventoryTriggerManager method getData.
@Override
public <T> T getData(File file, String key, T def) throws IOException {
if (key.equals(ITEMS)) {
int size = BukkitTriggerManager.super.getData(file, SIZE, 0);
Utf8YamlConfiguration conf = new Utf8YamlConfiguration();
try {
conf.load(file);
} catch (InvalidConfigurationException e) {
e.printStackTrace();
}
Map<Integer, IItemStack> items = new HashMap<>();
if (conf.contains(ITEMS))
parseItemsList(conf.getConfigurationSection(ITEMS), items, size);
return (T) items;
} else {
return BukkitTriggerManager.super.getData(file, key, def);
}
}
Aggregations