cn.nukkit.utils.ConfigSection Java Examples

The following examples show how to use cn.nukkit.utils.ConfigSection. 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: NukkitConfigAdapter.java    From LuckPerms with MIT License 5 votes vote down vote up
@Override
public List<String> getKeys(String path, List<String> def) {
    ConfigSection section = this.configuration.getSection(path);
    if (section == null) {
        return def;
    }

    Set<String> keys = section.getKeys(false);
    return keys == null ? def : new ArrayList<>(keys);
}
 
Example #2
Source File: NukkitConfigAdapter.java    From LuckPerms with MIT License 5 votes vote down vote up
@Override
public Map<String, String> getStringMap(String path, Map<String, String> def) {
    Map<String, String> map = new HashMap<>();
    ConfigSection section = this.configuration.getSection(path);
    if (section == null) {
        return def;
    }

    for (String key : section.getKeys(false)) {
        map.put(key, section.getString(key));
    }

    return map;
}
 
Example #3
Source File: SynapseAPI.java    From SynapseAPI with GNU General Public License v3.0 5 votes vote down vote up
private void loadEntries() {
    this.saveDefaultConfig();
    enable = this.getConfig().getBoolean("enable", true);

    if (!enable) {
        this.getLogger().warning("The SynapseAPI is not be enabled!");
    } else {
        if (this.getConfig().getBoolean("disable-rak")) {
            for (SourceInterface sourceInterface : this.getServer().getNetwork().getInterfaces()) {
                if (sourceInterface instanceof RakNetInterface) {
                    sourceInterface.shutdown();
                }
            }
        }

        List entries = this.getConfig().getList("entries");

        for (Object entry : entries) {
            @SuppressWarnings("unchecked")
            ConfigSection section = new ConfigSection((LinkedHashMap) entry);
            String serverIp = section.getString("server-ip", "127.0.0.1");
            int port = section.getInt("server-port", 10305);
            boolean isMainServer = section.getBoolean("isMainServer");
            boolean isLobbyServer = section.getBoolean("isLobbyServer");
            boolean transfer = section.getBoolean("transferOnShutdown", true);
            String password = section.getString("password");
            String serverDescription = section.getString("description");
            this.autoConnect = section.getBoolean("autoConnect", true);
            if (this.autoConnect) {
                this.addSynapseAPI(new SynapseEntry(this, serverIp, port, isMainServer, isLobbyServer, transfer, password, serverDescription));
            }
        }
    }
}