cn.nukkit.network.RakNetInterface Java Examples

The following examples show how to use cn.nukkit.network.RakNetInterface. 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: 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));
            }
        }
    }
}