@@ -0,0 +1,2477 @@
+package org.mcphoton.impl.server;%0A%0Aimport com.electronwill.nightconfig.core.UnmodifiableCommentedConfig;%0Aimport com.electronwill.nightconfig.core.conversion.ObjectConverter;%0Aimport com.electronwill.nightconfig.toml.TomlConfig;%0Aimport com.electronwill.nightconfig.toml.TomlParser;%0Aimport java.awt.image.BufferedImage;%0Aimport java.io.File;%0Aimport java.util.Map;%0Aimport org.mcphoton.Photon;%0Aimport org.mcphoton.server.ServerConfiguration;%0Aimport org.mcphoton.utils.Location;%0A%0A/**%0A * The server configuration, loaded from the file server-config.toml with the Night-Config library.%0A *%0A * @author TheElectronWill%0A */%0Apublic final class ServerConfigImpl implements ServerConfiguration %7B%0A%09private static final File configFile = new File(Photon.getMainDirectory(), %22server-config.toml%22);%0A%0A%09private volatile String motd;%0A%09private volatile int maxPlayers, port;%0A%09private volatile Location spawnLocation;%0A%09private volatile boolean onlineMode;%0A%09private volatile transient BufferedImage icon;// not saved in the config but loaded from icon.jpg or .png%0A%09private volatile transient Map%3CString, UnmodifiableCommentedConfig.CommentNode%3E savedComments;%0A%0A%09@Override%0A%09public String getMOTD() %7B%0A%09%09return motd;%0A%09%7D%0A%0A%09@Override%0A%09public void setMOTD(String motd) %7B%0A%09%09this.motd = motd;%0A%09%7D%0A%0A%09@Override%0A%09public int getMaxPlayers() %7B%0A%09%09return maxPlayers;%0A%09%7D%0A%0A%09@Override%0A%09public void setMaxPlayers(int maxPlayers) %7B%0A%09%09this.maxPlayers = maxPlayers;%0A%09%7D%0A%0A%09@Override%0A%09public int getPort() %7B%0A%09%09return port;%0A%09%7D%0A%0A%09@Override%0A%09public void setPort(int port) %7B%0A%09%09this.port = port;%0A%09%7D%0A%0A%09@Override%0A%09public BufferedImage getIcon() %7B%0A%09%09return icon;%0A%09%7D%0A%0A%09@Override%0A%09public void setIcon(BufferedImage icon) %7B%0A%09%09this.icon = icon;%0A%09%7D%0A%0A%09@Override%0A%09public Location getSpawnLocation() %7B%0A%09%09return spawnLocation;%0A%09%7D%0A%0A%09@Override%0A%09public void setSpawnLocation(Location location) %7B%0A%09%09this.spawnLocation = location;%0A%09%7D%0A%0A%09@Override%0A%09public boolean isOnlineMode() %7B%0A%09%09return onlineMode;%0A%09%7D%0A%0A%09@Override%0A%09public void setOnlineMode(boolean online) %7B%0A%09%09this.onlineMode = online;%0A%09%7D%0A%0A%09static ServerConfiguration load() %7B%0A%09%09TomlConfig config = new TomlParser().parse(configFile);%0A%09%09ServerConfigImpl impl = new ObjectConverter().toObject(config, ServerConfigImpl::new);%0A%09%09impl.savedComments = config.getComments();// Remembers the comments%0A%09%09return impl;%0A%09%7D%0A%0A%09void save() %7B%0A%09%09TomlConfig config = new ObjectConverter().toConfig(this, TomlConfig::new);%0A%09%09config.setComments(savedComments);// Restores the comments%0A%09%09config.write(configFile);%0A%09%7D%0A%7D%0A

Implement ServerConfiguration with the NightConfig library