Search in sources :

Example 1 with Utf8YamlConfiguration

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);
    }
}
Also used : Utf8YamlConfiguration(io.github.wysohn.triggerreactor.misc.Utf8YamlConfiguration) IItemStack(io.github.wysohn.triggerreactor.core.bridge.IItemStack) InvalidConfigurationException(org.bukkit.configuration.InvalidConfigurationException)

Example 2 with Utf8YamlConfiguration

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());
}
Also used : Utf8YamlConfiguration(io.github.wysohn.triggerreactor.misc.Utf8YamlConfiguration) File(java.io.File)

Example 3 with Utf8YamlConfiguration

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);
}
Also used : Utf8YamlConfiguration(io.github.wysohn.triggerreactor.misc.Utf8YamlConfiguration) InvalidConfigurationException(org.bukkit.configuration.InvalidConfigurationException)

Example 4 with Utf8YamlConfiguration

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);
    }
}
Also used : Utf8YamlConfiguration(io.github.wysohn.triggerreactor.misc.Utf8YamlConfiguration) HashMap(java.util.HashMap) IItemStack(io.github.wysohn.triggerreactor.core.bridge.IItemStack) InvalidConfigurationException(org.bukkit.configuration.InvalidConfigurationException)

Aggregations

Utf8YamlConfiguration (io.github.wysohn.triggerreactor.misc.Utf8YamlConfiguration)4 InvalidConfigurationException (org.bukkit.configuration.InvalidConfigurationException)3 IItemStack (io.github.wysohn.triggerreactor.core.bridge.IItemStack)2 File (java.io.File)1 HashMap (java.util.HashMap)1