Java Code Examples for com.electronwill.nightconfig.core.Config#Entry

The following examples show how to use com.electronwill.nightconfig.core.Config#Entry . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConfigManager.java    From Survivalist with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@SubscribeEvent
public static void modConfig(ModConfig.ModConfigEvent event)
{
    ModConfig config = event.getConfig();
    if (config.getSpec() != SERVER_SPEC)
        return;

    Config axeLevels = SERVER.axeLevels.get();

    for (Config.Entry e : axeLevels.entrySet())
    {
        Matcher m = AXE_LEVEL_ENTRY_PATTERN.matcher(e.getKey());
        if (m.matches())
        {
            String numberPart = m.group("level");
            int levelNumber = Integer.parseInt(numberPart);
            axeLevelMap.put(levelNumber, e.getIntOrElse(1 + levelNumber));
        }
    }
}
 
Example 2
Source File: ConvertedConfig.java    From night-config with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public Set<Config.Entry> entries() {
	Function<Config.Entry, Config.Entry> readTransfo = entry -> null;/*TODOnew Config.Entry() {
		@Override
		public Object setValue(Object value) {
			return readConversion.apply(entry.setValue(writeConversion.apply(value)));
		}

		@Override
		public String getKey() {
			return entry.getKey();
		}

		@Override
		public <T> T getValue() {
			return (T)readConversion.apply(entry.getValue());
		}
	};*/
	return new TransformingSet<>(config.entries(), readTransfo, o -> null, e -> e);
}
 
Example 3
Source File: CheckedConfig.java    From night-config with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void recursiveCheck(Deque<String> path, Object value) {
	if (value instanceof Config) {
		for (Config.Entry entry : ((Config)value).entries()) {
			path.addLast(entry.getKey());
			recursiveCheck(path, entry.getValue());
			path.removeLast();
		}
	} else {
		String[] arr = (String[])path.toArray();
		checker.checkUpdate(StandardAttributes.VALUE, arr, value, value);
	}
}
 
Example 4
Source File: CheckedConfig.java    From night-config with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public Set<Config.Entry> entries() {
	return new TransformingSet<>(config.entries(), v -> v, this::checkSetWrite, this::searchEntryTransform);
}
 
Example 5
Source File: CheckedConfig.java    From night-config with GNU Lesser General Public License v3.0 4 votes vote down vote up
private Config.Entry checkSetWrite(Config.Entry entry) {
	return checkMapWrite(entry.getKey(), entry.getValue());
}
 
Example 6
Source File: CheckedConfig.java    From night-config with GNU Lesser General Public License v3.0 4 votes vote down vote up
private Config.Entry searchEntryTransform(Object o) {
	if (o instanceof Config.Entry) {
		return (Config.Entry)o;
	}
	return null;
}
 
Example 7
Source File: ConfigWrapper.java    From night-config with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public Config.Entry getEntry(String[] path) {
	return config.getEntry(path);
}
 
Example 8
Source File: ConfigWrapper.java    From night-config with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public Set<Config.Entry> entries() {
	return config.entries();
}
 
Example 9
Source File: AutosaveFileConfig.java    From night-config with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public Config.Entry getEntry(String[] path) {
	return new AutosaveEntry(config.getEntry(path));
}
 
Example 10
Source File: AutosaveFileConfig.java    From night-config with GNU Lesser General Public License v3.0 4 votes vote down vote up
private AutosaveEntry(Config.Entry entry) {
	this.entry = entry;
}