Search in sources :

Example 1 with GlowServerIcon

use of net.glowstone.util.GlowServerIcon in project Glowstone by GlowstoneMC.

the class GlowServer method loadConfig.

/**
 * Load the server configuration.
 */
private void loadConfig() {
    config.load();
    worldConfig.load();
    // modifiable values
    spawnRadius = config.getInt(Key.SPAWN_RADIUS);
    whitelistEnabled = config.getBoolean(Key.WHITELIST);
    idleTimeout = config.getInt(Key.PLAYER_IDLE_TIMEOUT);
    maxPlayers = config.getInt(Key.MAX_PLAYERS);
    // special handling
    warnState = WarningState.value(config.getString(Key.WARNING_STATE));
    try {
        defaultGameMode = GameMode.valueOf(config.getString(Key.GAMEMODE));
    } catch (IllegalArgumentException | NullPointerException e) {
        defaultGameMode = GameMode.SURVIVAL;
    }
    // server icon
    defaultIcon = new GlowServerIcon();
    try {
        File serverIconFile = config.getFile(SERVER_ICON_FILE);
        if (serverIconFile.isFile()) {
            defaultIcon = new GlowServerIcon(serverIconFile);
        } else {
            try {
                File vanillaServerIcon = new File(SERVER_ICON_FILE);
                if (vanillaServerIcon.isFile()) {
                    // Import from Vanilla
                    ConsoleMessages.Info.Icon.IMPORT.log(SERVER_ICON_FILE);
                    Files.copy(vanillaServerIcon.toPath(), serverIconFile.toPath());
                    defaultIcon = new GlowServerIcon(serverIconFile);
                }
            } catch (Exception e) {
                ConsoleMessages.Warn.Icon.LOAD_FAILED_IMPORT.log(e, SERVER_ICON_FILE);
            }
        }
    } catch (Exception e) {
        ConsoleMessages.Warn.Icon.LOAD_FAILED.log(e, SERVER_ICON_FILE);
    }
}
Also used : UuidListFile(net.glowstone.util.bans.UuidListFile) File(java.io.File) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) NotImplementedException(org.apache.commons.lang.NotImplementedException) NaetherException(com.tobedevoured.naether.NaetherException) TimeoutException(java.util.concurrent.TimeoutException) CommandException(org.bukkit.command.CommandException) MalformedURLException(java.net.MalformedURLException) GlowServerIcon(net.glowstone.util.GlowServerIcon)

Aggregations

NaetherException (com.tobedevoured.naether.NaetherException)1 File (java.io.File)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 GlowServerIcon (net.glowstone.util.GlowServerIcon)1 UuidListFile (net.glowstone.util.bans.UuidListFile)1 NotImplementedException (org.apache.commons.lang.NotImplementedException)1 CommandException (org.bukkit.command.CommandException)1