Merge pull request #288 from stargate-rewritten/legacy-config-migration
Legacy config migration
This commit is contained in:
		@@ -25,6 +25,7 @@ import net.knarcraft.stargate.thread.BlockChangeThread;
 | 
				
			|||||||
import net.knarcraft.stargate.thread.ChunkUnloadThread;
 | 
					import net.knarcraft.stargate.thread.ChunkUnloadThread;
 | 
				
			||||||
import net.knarcraft.stargate.thread.StarGateThread;
 | 
					import net.knarcraft.stargate.thread.StarGateThread;
 | 
				
			||||||
import net.knarcraft.stargate.utility.BStatsHelper;
 | 
					import net.knarcraft.stargate.utility.BStatsHelper;
 | 
				
			||||||
 | 
					import org.bukkit.Bukkit;
 | 
				
			||||||
import org.bukkit.Server;
 | 
					import org.bukkit.Server;
 | 
				
			||||||
import org.bukkit.command.PluginCommand;
 | 
					import org.bukkit.command.PluginCommand;
 | 
				
			||||||
import org.bukkit.configuration.InvalidConfigurationException;
 | 
					import org.bukkit.configuration.InvalidConfigurationException;
 | 
				
			||||||
@@ -73,7 +74,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
				
			|||||||
@SuppressWarnings("unused")
 | 
					@SuppressWarnings("unused")
 | 
				
			||||||
public class Stargate extends JavaPlugin {
 | 
					public class Stargate extends JavaPlugin {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private static File configFile;
 | 
					    private static final String CONFIG_FILE_NAME = "config.yml";
 | 
				
			||||||
    private static final Queue<BlockChangeRequest> blockChangeRequestQueue = new LinkedList<>();
 | 
					    private static final Queue<BlockChangeRequest> blockChangeRequestQueue = new LinkedList<>();
 | 
				
			||||||
    private static final Queue<ChunkUnloadRequest> chunkUnloadQueue = new PriorityQueue<>();
 | 
					    private static final Queue<ChunkUnloadRequest> chunkUnloadQueue = new PriorityQueue<>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -206,7 +207,7 @@ public class Stargate extends JavaPlugin {
 | 
				
			|||||||
     * @param message <p>A message describing what happened</p>
 | 
					     * @param message <p>A message describing what happened</p>
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public static void debug(String route, String message) {
 | 
					    public static void debug(String route, String message) {
 | 
				
			||||||
        if (stargateConfig == null || stargateConfig.isDebuggingEnabled()) {
 | 
					        if (stargateConfig == null || stargateConfig.isNotLoaded() || stargateConfig.isDebuggingEnabled()) {
 | 
				
			||||||
            logger.info("[Stargate::" + route + "] " + message);
 | 
					            logger.info("[Stargate::" + route + "] " + message);
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            logger.log(Level.FINEST, "[Stargate::" + route + "] " + message);
 | 
					            logger.log(Level.FINEST, "[Stargate::" + route + "] " + message);
 | 
				
			||||||
@@ -219,7 +220,7 @@ public class Stargate extends JavaPlugin {
 | 
				
			|||||||
     * @param message <p>The message to log</p>
 | 
					     * @param message <p>The message to log</p>
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public static void logInfo(String message) {
 | 
					    public static void logInfo(String message) {
 | 
				
			||||||
        logger.info(getBackupString("prefix") + message);
 | 
					        log(Level.INFO, message);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -247,7 +248,10 @@ public class Stargate extends JavaPlugin {
 | 
				
			|||||||
     * @param message  <p>The message to log</p>
 | 
					     * @param message  <p>The message to log</p>
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private static void log(Level severity, String message) {
 | 
					    private static void log(Level severity, String message) {
 | 
				
			||||||
        logger.log(severity, getBackupString("prefix") + message);
 | 
					        if (logger == null) {
 | 
				
			||||||
 | 
					            logger = Bukkit.getLogger();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        logger.log(severity, message);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -349,9 +353,9 @@ public class Stargate extends JavaPlugin {
 | 
				
			|||||||
        super.reloadConfig();
 | 
					        super.reloadConfig();
 | 
				
			||||||
        this.configuration = new StargateYamlConfiguration();
 | 
					        this.configuration = new StargateYamlConfiguration();
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            configuration.load(configFile);
 | 
					            this.configuration.load(new File(getDataFolder(), CONFIG_FILE_NAME));
 | 
				
			||||||
        } catch (IOException | InvalidConfigurationException e) {
 | 
					        } catch (IOException | InvalidConfigurationException e) {
 | 
				
			||||||
            Stargate.logSevere(e.getMessage());
 | 
					            logSevere("Unable to load the configuration! Message: " + e.getMessage());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -359,9 +363,9 @@ public class Stargate extends JavaPlugin {
 | 
				
			|||||||
    public void saveConfig() {
 | 
					    public void saveConfig() {
 | 
				
			||||||
        super.saveConfig();
 | 
					        super.saveConfig();
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            configuration.save(configFile);
 | 
					            this.configuration.save(new File(getDataFolder(), CONFIG_FILE_NAME));
 | 
				
			||||||
        } catch (IOException e) {
 | 
					        } catch (IOException e) {
 | 
				
			||||||
            logSevere(e.getMessage());
 | 
					            logSevere("Unable to save the configuration! Message: " + e.getMessage());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -369,30 +373,41 @@ public class Stargate extends JavaPlugin {
 | 
				
			|||||||
    public void onDisable() {
 | 
					    public void onDisable() {
 | 
				
			||||||
        PortalHandler.closeAllPortals();
 | 
					        PortalHandler.closeAllPortals();
 | 
				
			||||||
        PortalRegistry.clearPortals();
 | 
					        PortalRegistry.clearPortals();
 | 
				
			||||||
        stargateConfig.clearManagedWorlds();
 | 
					        if (stargateConfig != null) {
 | 
				
			||||||
 | 
					            stargateConfig.clearManagedWorlds();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        getServer().getScheduler().cancelTasks(this);
 | 
					        getServer().getScheduler().cancelTasks(this);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void onEnable() {
 | 
					    public void onEnable() {
 | 
				
			||||||
        configFile = new File(this.getDataFolder(), "config.yml");
 | 
					        Stargate.stargate = this;
 | 
				
			||||||
 | 
					        Stargate.logger = getLogger();
 | 
				
			||||||
 | 
					        this.saveDefaultConfig();
 | 
				
			||||||
 | 
					        this.getConfig();
 | 
				
			||||||
        PluginDescriptionFile pluginDescriptionFile = this.getDescription();
 | 
					        PluginDescriptionFile pluginDescriptionFile = this.getDescription();
 | 
				
			||||||
        pluginManager = getServer().getPluginManager();
 | 
					        pluginManager = getServer().getPluginManager();
 | 
				
			||||||
        configuration = new StargateYamlConfiguration();
 | 
					        this.configuration = new StargateYamlConfiguration();
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            configuration.load(configFile);
 | 
					            this.configuration.load(new File(getDataFolder(), CONFIG_FILE_NAME));
 | 
				
			||||||
        } catch (IOException | InvalidConfigurationException e) {
 | 
					        } catch (IOException | InvalidConfigurationException e) {
 | 
				
			||||||
            Stargate.logSevere(e.getMessage());
 | 
					            getLogger().log(Level.SEVERE, e.getMessage());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        this.saveDefaultConfig();
 | 
					        this.configuration.options().copyDefaults(true);
 | 
				
			||||||
        configuration.options().copyDefaults(true);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        logger = Logger.getLogger("Minecraft");
 | 
					 | 
				
			||||||
        Server server = getServer();
 | 
					        Server server = getServer();
 | 
				
			||||||
        stargate = this;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        stargateConfig = new StargateConfig(logger);
 | 
					        try {
 | 
				
			||||||
        stargateConfig.finishSetup();
 | 
					            stargateConfig = new StargateConfig(logger);
 | 
				
			||||||
 | 
					            stargateConfig.finishSetup();
 | 
				
			||||||
 | 
					        } catch (NoClassDefFoundError exception) {
 | 
				
			||||||
 | 
					            logSevere("Could not properly load. Class not found: " +
 | 
				
			||||||
 | 
					                    exception.getMessage() + "\nThis is probably because you are using CraftBukkit, or other outdated" +
 | 
				
			||||||
 | 
					                    "Minecraft server software. Minecraft server software based on Spigot or Paper is required. Paper" +
 | 
				
			||||||
 | 
					                    " is recommended, and can be downloaded at: https://papermc.io/downloads/paper");
 | 
				
			||||||
 | 
					            this.onDisable();
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        pluginVersion = pluginDescriptionFile.getVersion();
 | 
					        pluginVersion = pluginDescriptionFile.getVersion();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -45,7 +45,7 @@ public final class LanguageLoader {
 | 
				
			|||||||
            loadedBackupStrings = load("en", inputStream);
 | 
					            loadedBackupStrings = load("en", inputStream);
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            loadedBackupStrings = null;
 | 
					            loadedBackupStrings = null;
 | 
				
			||||||
            Stargate.getConsoleLogger().severe("[stargate] Error loading backup language. " +
 | 
					            Stargate.logSevere("Error loading backup language. " +
 | 
				
			||||||
                    "There may be missing text in-game");
 | 
					                    "There may be missing text in-game");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -120,8 +120,8 @@ public final class LanguageLoader {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            readChangedLanguageStrings(inputStream, language, currentLanguageValues);
 | 
					            readChangedLanguageStrings(inputStream, language, currentLanguageValues);
 | 
				
			||||||
        } catch (IOException ex) {
 | 
					        } catch (IOException exception) {
 | 
				
			||||||
            ex.printStackTrace();
 | 
					            Stargate.logSevere("Unable to read language strings! Message: " + exception.getMessage());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -226,7 +226,7 @@ public final class LanguageLoader {
 | 
				
			|||||||
            strings = FileHelper.readKeyValuePairs(bufferedReader, "=", ColorConversion.NORMAL);
 | 
					            strings = FileHelper.readKeyValuePairs(bufferedReader, "=", ColorConversion.NORMAL);
 | 
				
			||||||
        } catch (Exception e) {
 | 
					        } catch (Exception e) {
 | 
				
			||||||
            if (Stargate.getStargateConfig().isDebuggingEnabled()) {
 | 
					            if (Stargate.getStargateConfig().isDebuggingEnabled()) {
 | 
				
			||||||
                Stargate.getConsoleLogger().info("[Stargate] Unable to load language " + lang);
 | 
					                Stargate.logInfo("Unable to load language " + lang);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            return null;
 | 
					            return null;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -14,7 +14,9 @@ import net.knarcraft.stargate.utility.PortalFileHelper;
 | 
				
			|||||||
import org.bukkit.Bukkit;
 | 
					import org.bukkit.Bukkit;
 | 
				
			||||||
import org.bukkit.World;
 | 
					import org.bukkit.World;
 | 
				
			||||||
import org.bukkit.command.CommandSender;
 | 
					import org.bukkit.command.CommandSender;
 | 
				
			||||||
 | 
					import org.bukkit.configuration.MemorySection;
 | 
				
			||||||
import org.bukkit.configuration.file.FileConfiguration;
 | 
					import org.bukkit.configuration.file.FileConfiguration;
 | 
				
			||||||
 | 
					import org.bukkit.configuration.file.YamlConfiguration;
 | 
				
			||||||
import org.bukkit.plugin.messaging.Messenger;
 | 
					import org.bukkit.plugin.messaging.Messenger;
 | 
				
			||||||
import org.dynmap.DynmapAPI;
 | 
					import org.dynmap.DynmapAPI;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -47,6 +49,7 @@ public final class StargateConfig {
 | 
				
			|||||||
    private String gateFolder;
 | 
					    private String gateFolder;
 | 
				
			||||||
    private String portalFolder;
 | 
					    private String portalFolder;
 | 
				
			||||||
    private String languageName = "en";
 | 
					    private String languageName = "en";
 | 
				
			||||||
 | 
					    private boolean isLoaded = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private final Map<ConfigOption, Object> configOptions;
 | 
					    private final Map<ConfigOption, Object> configOptions;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -108,6 +111,17 @@ public final class StargateConfig {
 | 
				
			|||||||
            DynmapManager.initialize(dynmapAPI);
 | 
					            DynmapManager.initialize(dynmapAPI);
 | 
				
			||||||
            DynmapManager.addAllPortalMarkers();
 | 
					            DynmapManager.addAllPortalMarkers();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        this.isLoaded = true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Gets whether this configuration has been fully loaded
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @return <p>True if not fully loaded</p>
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public boolean isNotLoaded() {
 | 
				
			||||||
 | 
					        return !this.isLoaded;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -364,10 +378,11 @@ public final class StargateConfig {
 | 
				
			|||||||
        FileConfiguration newConfig = Stargate.getInstance().getConfiguration();
 | 
					        FileConfiguration newConfig = Stargate.getInstance().getConfiguration();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        boolean isMigrating = false;
 | 
					        boolean isMigrating = false;
 | 
				
			||||||
        if (newConfig.getString("lang") != null || newConfig.getString("economy.freeGatesGreen") != null ||
 | 
					        if (newConfig.getString("lang") != null || newConfig.getString("economy.taxAccount") == null) {
 | 
				
			||||||
                newConfig.getString("economy.taxAccount") == null) {
 | 
					 | 
				
			||||||
            migrateConfig(newConfig);
 | 
					            migrateConfig(newConfig);
 | 
				
			||||||
            isMigrating = true;
 | 
					            isMigrating = true;
 | 
				
			||||||
 | 
					            Stargate.getInstance().reloadConfig();
 | 
				
			||||||
 | 
					            newConfig = Stargate.getInstance().getConfiguration();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //Copy missing default values if any values are missing
 | 
					        //Copy missing default values if any values are missing
 | 
				
			||||||
@@ -398,10 +413,17 @@ public final class StargateConfig {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        //Get important folders from the config
 | 
					        //Get important folders from the config
 | 
				
			||||||
        portalFolder = (String) configOptions.get(ConfigOption.PORTAL_FOLDER);
 | 
					        portalFolder = (String) configOptions.get(ConfigOption.PORTAL_FOLDER);
 | 
				
			||||||
 | 
					        if (portalFolder.isEmpty()) {
 | 
				
			||||||
 | 
					            portalFolder = dataFolderPath + "/portals/";
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        gateFolder = (String) configOptions.get(ConfigOption.GATE_FOLDER);
 | 
					        gateFolder = (String) configOptions.get(ConfigOption.GATE_FOLDER);
 | 
				
			||||||
 | 
					        if (gateFolder.isEmpty()) {
 | 
				
			||||||
 | 
					            gateFolder = dataFolderPath + "/gates/";
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //If users have an outdated config, assume they also need to update their default gates
 | 
					        //If users have an outdated config, assume they also need to update their default gates
 | 
				
			||||||
        if (isMigrating) {
 | 
					        if (isMigrating) {
 | 
				
			||||||
 | 
					            this.createMissingFolders();
 | 
				
			||||||
            GateHandler.writeDefaultGatesToFolder(gateFolder);
 | 
					            GateHandler.writeDefaultGatesToFolder(gateFolder);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -434,18 +456,26 @@ public final class StargateConfig {
 | 
				
			|||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Changes all configuration values from the old name to the new name
 | 
					     * Changes all configuration values from the old name to the new name
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     * @param newConfig <p>The config to read from and write to</p>
 | 
					     * @param currentConfiguration <p>The current config to back up</p>
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private void migrateConfig(FileConfiguration newConfig) {
 | 
					    private void migrateConfig(FileConfiguration currentConfiguration) {
 | 
				
			||||||
 | 
					        String debugPath = "StargateConfig::migrateConfig";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //Save the old config just in case something goes wrong
 | 
					        //Save the old config just in case something goes wrong
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            newConfig.save(dataFolderPath + "/config.yml.old");
 | 
					            currentConfiguration.save(new File(dataFolderPath, "config.yml.old"));
 | 
				
			||||||
        } catch (IOException e) {
 | 
					        } catch (IOException e) {
 | 
				
			||||||
            Stargate.debug("Stargate::migrateConfig", "Unable to save old backup and do migration");
 | 
					            Stargate.debug(debugPath, "Unable to save old backup and do migration");
 | 
				
			||||||
            e.printStackTrace();
 | 
					 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //Load old and new configuration
 | 
				
			||||||
 | 
					        Stargate.getInstance().reloadConfig();
 | 
				
			||||||
 | 
					        FileConfiguration oldConfiguration = Stargate.getInstance().getConfig();
 | 
				
			||||||
 | 
					        YamlConfiguration newConfiguration = StargateYamlConfiguration.loadConfiguration(
 | 
				
			||||||
 | 
					                FileHelper.getBufferedReaderFromInputStream(
 | 
				
			||||||
 | 
					                        FileHelper.getInputStreamForInternalFile("/config.yml")));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //Read all available config migrations
 | 
					        //Read all available config migrations
 | 
				
			||||||
        Map<String, String> migrationFields;
 | 
					        Map<String, String> migrationFields;
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
@@ -453,22 +483,39 @@ public final class StargateConfig {
 | 
				
			|||||||
                            FileHelper.getInputStreamForInternalFile("/config-migrations.txt")), "=",
 | 
					                            FileHelper.getInputStreamForInternalFile("/config-migrations.txt")), "=",
 | 
				
			||||||
                    ColorConversion.NORMAL);
 | 
					                    ColorConversion.NORMAL);
 | 
				
			||||||
        } catch (IOException e) {
 | 
					        } catch (IOException e) {
 | 
				
			||||||
            Stargate.debug("Stargate::migrateConfig", "Unable to load config migration file");
 | 
					            Stargate.debug(debugPath, "Unable to load config migration file");
 | 
				
			||||||
            e.printStackTrace();
 | 
					 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //Replace old config names with the new ones
 | 
					        //Replace old config names with the new ones
 | 
				
			||||||
        for (String key : migrationFields.keySet()) {
 | 
					        for (String key : migrationFields.keySet()) {
 | 
				
			||||||
            if (newConfig.contains(key)) {
 | 
					            if (oldConfiguration.contains(key)) {
 | 
				
			||||||
                String newPath = migrationFields.get(key);
 | 
					                String newPath = migrationFields.get(key);
 | 
				
			||||||
                Object oldValue = newConfig.get(key);
 | 
					                Object oldValue = oldConfiguration.get(key);
 | 
				
			||||||
                if (!newPath.trim().isEmpty()) {
 | 
					                if (!newPath.trim().isEmpty()) {
 | 
				
			||||||
                    newConfig.set(newPath, oldValue);
 | 
					                    oldConfiguration.set(newPath, oldValue);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                newConfig.set(key, null);
 | 
					                oldConfiguration.set(key, null);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Copy all keys to the new config
 | 
				
			||||||
 | 
					        for (String key : oldConfiguration.getKeys(true)) {
 | 
				
			||||||
 | 
					            if (oldConfiguration.get(key) instanceof MemorySection) {
 | 
				
			||||||
 | 
					                continue;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            Stargate.debug(debugPath, "Setting " + key + " to " +
 | 
				
			||||||
 | 
					                    oldConfiguration.get(key));
 | 
				
			||||||
 | 
					            newConfiguration.set(key, oldConfiguration.get(key));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            newConfiguration.save(new File(dataFolderPath, "config.yml"));
 | 
				
			||||||
 | 
					        } catch (IOException exception) {
 | 
				
			||||||
 | 
					            Stargate.debug(debugPath, "Unable to save migrated config");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Stargate.getInstance().reloadConfig();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -498,18 +545,24 @@ public final class StargateConfig {
 | 
				
			|||||||
     * Creates missing folders
 | 
					     * Creates missing folders
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private void createMissingFolders() {
 | 
					    private void createMissingFolders() {
 | 
				
			||||||
        File newPortalDir = new File(portalFolder);
 | 
					        createMissingFolder(new File(gateFolder), "Unable to create gate directory");
 | 
				
			||||||
        if (!newPortalDir.exists()) {
 | 
					        createMissingFolder(new File(portalFolder), "Unable to create portal directory");
 | 
				
			||||||
            if (!newPortalDir.mkdirs()) {
 | 
					 | 
				
			||||||
                logger.severe("Unable to create portal directory");
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        File newFile = new File(portalFolder, Stargate.getInstance().getServer().getWorlds().get(0).getName() +
 | 
					        File newFile = new File(portalFolder, Stargate.getInstance().getServer().getWorlds().get(0).getName() +
 | 
				
			||||||
                ".db");
 | 
					                ".db");
 | 
				
			||||||
        if (!newFile.exists() && !newFile.getParentFile().exists()) {
 | 
					        if (!newFile.exists() && !newFile.getParentFile().exists() && !newFile.getParentFile().mkdirs()) {
 | 
				
			||||||
            if (!newFile.getParentFile().mkdirs()) {
 | 
					            logger.severe("Unable to create portal database folder: " + newFile.getParentFile().getPath());
 | 
				
			||||||
                logger.severe("Unable to create portal database folder: " + newFile.getParentFile().getPath());
 | 
					        }
 | 
				
			||||||
            }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Creates the given folder if it's missing
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param folder       <p>The folder to create</p>
 | 
				
			||||||
 | 
					     * @param errorMessage <p>The error message to display if unable to create the folder</p>
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    private void createMissingFolder(File folder, String errorMessage) {
 | 
				
			||||||
 | 
					        if (!folder.exists() && !folder.mkdirs()) {
 | 
				
			||||||
 | 
					            logger.severe(errorMessage);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -313,14 +313,16 @@ public final class StargateGateConfig {
 | 
				
			|||||||
        try {
 | 
					        try {
 | 
				
			||||||
            PortalSignDrawer.setMainColor(ChatColor.of(mainSignColor.toUpperCase()));
 | 
					            PortalSignDrawer.setMainColor(ChatColor.of(mainSignColor.toUpperCase()));
 | 
				
			||||||
        } catch (IllegalArgumentException | NullPointerException exception) {
 | 
					        } catch (IllegalArgumentException | NullPointerException exception) {
 | 
				
			||||||
            Stargate.logWarning("You have specified an invalid main sign color in your config.yml. Defaulting to BLACK");
 | 
					            Stargate.logWarning("You have specified an invalid main sign color in your config.yml (" + mainSignColor +
 | 
				
			||||||
 | 
					                    "). Defaulting to BLACK");
 | 
				
			||||||
            PortalSignDrawer.setMainColor(ChatColor.BLACK);
 | 
					            PortalSignDrawer.setMainColor(ChatColor.BLACK);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            PortalSignDrawer.setHighlightColor(ChatColor.of(highlightSignColor.toUpperCase()));
 | 
					            PortalSignDrawer.setHighlightColor(ChatColor.of(highlightSignColor.toUpperCase()));
 | 
				
			||||||
        } catch (IllegalArgumentException | NullPointerException exception) {
 | 
					        } catch (IllegalArgumentException | NullPointerException exception) {
 | 
				
			||||||
            Stargate.logWarning("You have specified an invalid highlighting sign color in your config.yml. Defaulting to WHITE");
 | 
					            Stargate.logWarning("You have specified an invalid highlighting sign color in your config.yml (" +
 | 
				
			||||||
 | 
					                    highlightSignColor + "). Defaulting to WHITE");
 | 
				
			||||||
            PortalSignDrawer.setHighlightColor(ChatColor.WHITE);
 | 
					            PortalSignDrawer.setHighlightColor(ChatColor.WHITE);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,22 +10,35 @@ import java.util.ArrayList;
 | 
				
			|||||||
import java.util.List;
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * A YAML configuration which keeps all comments
 | 
					 * A YAML configuration which retains all comments
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * <p>This configuration converts all comments to YAML values when loaded, which all start with comment_. When saved,
 | 
				
			||||||
 | 
					 * those YAML values are converted to normal text comments. This ensures that the comments aren't removed by the
 | 
				
			||||||
 | 
					 * YamlConfiguration during its parsing.</p>
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * @author Thorin
 | 
					 * @author Thorin
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public class StargateYamlConfiguration extends YamlConfiguration {
 | 
					public class StargateYamlConfiguration extends YamlConfiguration {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static final String START_OF_COMMENT_LINE = "[HASHTAG]";
 | 
				
			||||||
    static public final String END_OF_COMMENT = "_endOfComment_";
 | 
					    static public final String END_OF_COMMENT = "_endOfComment_";
 | 
				
			||||||
    static public final String START_OF_COMMENT = "comment_";
 | 
					    static public final String START_OF_COMMENT = "comment_";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    @SuppressWarnings("deprecation")
 | 
				
			||||||
 | 
					    protected @NotNull String buildHeader() {
 | 
				
			||||||
 | 
					        return "";
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public @NotNull String saveToString() {
 | 
					    public @NotNull String saveToString() {
 | 
				
			||||||
 | 
					        // Convert YAML comments to normal comments
 | 
				
			||||||
        return this.convertYAMLMappingsToComments(super.saveToString());
 | 
					        return this.convertYAMLMappingsToComments(super.saveToString());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void loadFromString(@NotNull String contents) throws InvalidConfigurationException {
 | 
					    public void loadFromString(@NotNull String contents) throws InvalidConfigurationException {
 | 
				
			||||||
 | 
					        // Convert normal comments to YAML comments to prevent them from disappearing
 | 
				
			||||||
        super.loadFromString(this.convertCommentsToYAMLMappings(contents));
 | 
					        super.loadFromString(this.convertCommentsToYAMLMappings(contents));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -41,27 +54,64 @@ public class StargateYamlConfiguration extends YamlConfiguration {
 | 
				
			|||||||
        StringBuilder yamlBuilder = new StringBuilder();
 | 
					        StringBuilder yamlBuilder = new StringBuilder();
 | 
				
			||||||
        List<String> currentComment = new ArrayList<>();
 | 
					        List<String> currentComment = new ArrayList<>();
 | 
				
			||||||
        int commentId = 0;
 | 
					        int commentId = 0;
 | 
				
			||||||
 | 
					        int previousIndentation = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (String line : configString.split("\n")) {
 | 
					        for (String line : configString.split("\n")) {
 | 
				
			||||||
            if (line.trim().startsWith("#")) {
 | 
					            String trimmed = line.trim();
 | 
				
			||||||
 | 
					            if (trimmed.startsWith("#")) {
 | 
				
			||||||
 | 
					                // Store the indentation of the block
 | 
				
			||||||
 | 
					                if (currentComment.isEmpty()) {
 | 
				
			||||||
 | 
					                    previousIndentation = getIndentation(line);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
                //Temporarily store the comment line
 | 
					                //Temporarily store the comment line
 | 
				
			||||||
                currentComment.add(line.trim().replaceFirst("#", ""));
 | 
					                addComment(currentComment, trimmed);
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                //Write the full formatted comment to the StringBuilder
 | 
					                addYamlString(yamlBuilder, currentComment, line, previousIndentation, commentId);
 | 
				
			||||||
                if (!currentComment.isEmpty()) {
 | 
					                commentId++;
 | 
				
			||||||
                    int indentation = getIndentation(line);
 | 
					                previousIndentation = 0;
 | 
				
			||||||
                    generateCommentYAML(yamlBuilder, currentComment, commentId++, indentation);
 | 
					 | 
				
			||||||
                    currentComment = new ArrayList<>();
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                //Add the non-comment line assuming it isn't empty
 | 
					 | 
				
			||||||
                if (!line.trim().isEmpty()) {
 | 
					 | 
				
			||||||
                    yamlBuilder.append(line).append("\n");
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return yamlBuilder.toString();
 | 
					        return yamlBuilder.toString();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Adds a YAML string to the given string builder
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param yamlBuilder         <p>The string builder used for building YAML</p>
 | 
				
			||||||
 | 
					     * @param currentComment      <p>The comment to add as a YAML string</p>
 | 
				
			||||||
 | 
					     * @param line                <p>The current line</p>
 | 
				
			||||||
 | 
					     * @param previousIndentation <p>The indentation of the current block comment</p>
 | 
				
			||||||
 | 
					     * @param commentId           <p>The id of the comment</p>
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    private void addYamlString(StringBuilder yamlBuilder, List<String> currentComment, String line,
 | 
				
			||||||
 | 
					                               int previousIndentation, int commentId) {
 | 
				
			||||||
 | 
					        String trimmed = line.trim();
 | 
				
			||||||
 | 
					        //Write the full formatted comment to the StringBuilder
 | 
				
			||||||
 | 
					        if (!currentComment.isEmpty()) {
 | 
				
			||||||
 | 
					            int indentation = trimmed.isEmpty() ? previousIndentation : getIndentation(line);
 | 
				
			||||||
 | 
					            generateCommentYAML(yamlBuilder, currentComment, commentId, indentation);
 | 
				
			||||||
 | 
					            currentComment.clear();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        //Add the non-comment line assuming it isn't empty
 | 
				
			||||||
 | 
					        if (!trimmed.isEmpty()) {
 | 
				
			||||||
 | 
					            yamlBuilder.append(line).append("\n");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Adds the given comment to the given list
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param commentParts <p>The list to add to</p>
 | 
				
			||||||
 | 
					     * @param comment      <p>The comment to add</p>
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    private void addComment(List<String> commentParts, String comment) {
 | 
				
			||||||
 | 
					        if (comment.startsWith("# ")) {
 | 
				
			||||||
 | 
					            commentParts.add(comment.replaceFirst("# ", START_OF_COMMENT_LINE));
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            commentParts.add(comment.replaceFirst("#", START_OF_COMMENT_LINE));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Generates a YAML-compatible string for one comment block
 | 
					     * Generates a YAML-compatible string for one comment block
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
@@ -94,35 +144,49 @@ public class StargateYamlConfiguration extends YamlConfiguration {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    private String convertYAMLMappingsToComments(String yamlString) {
 | 
					    private String convertYAMLMappingsToComments(String yamlString) {
 | 
				
			||||||
        StringBuilder finalText = new StringBuilder();
 | 
					        StringBuilder finalText = new StringBuilder();
 | 
				
			||||||
        boolean isReadingCommentBlock = false;
 | 
					
 | 
				
			||||||
        int commentIndentation = 0;
 | 
					        String[] lines = yamlString.split("\n");
 | 
				
			||||||
        for (String line : yamlString.split("\n")) {
 | 
					        for (int currentIndex = 0; currentIndex < lines.length; currentIndex++) {
 | 
				
			||||||
 | 
					            String line = lines[currentIndex];
 | 
				
			||||||
            String possibleComment = line.trim();
 | 
					            String possibleComment = line.trim();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (isReadingCommentBlock && line.contains(END_OF_COMMENT)) {
 | 
					            if (possibleComment.startsWith(START_OF_COMMENT)) {
 | 
				
			||||||
                //Skip the line signifying the end of a comment
 | 
					 | 
				
			||||||
                isReadingCommentBlock = false;
 | 
					 | 
				
			||||||
            } else if (possibleComment.startsWith(START_OF_COMMENT)) {
 | 
					 | 
				
			||||||
                //Skip the comment start line, and start comment parsing
 | 
					 | 
				
			||||||
                isReadingCommentBlock = true;
 | 
					 | 
				
			||||||
                //Get the indentation to use for the comment block
 | 
					 | 
				
			||||||
                commentIndentation = getIndentation(line);
 | 
					 | 
				
			||||||
                //Add an empty line before every comment block
 | 
					                //Add an empty line before every comment block
 | 
				
			||||||
                finalText.append("\n");
 | 
					                finalText.append("\n");
 | 
				
			||||||
            } else if (line.isEmpty() && !isReadingCommentBlock) {
 | 
					                currentIndex = readComment(finalText, lines, currentIndex + 1, getIndentation(line));
 | 
				
			||||||
                //Output the empty line as-is, as it's not part of a comment
 | 
					 | 
				
			||||||
                finalText.append("\n");
 | 
					 | 
				
			||||||
            } else if (isReadingCommentBlock) {
 | 
					 | 
				
			||||||
                //Output the comment with correct indentation
 | 
					 | 
				
			||||||
                finalText.append(addIndentation(commentIndentation)).append("# ").append(possibleComment).append("\n");
 | 
					 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                //Output the configuration key
 | 
					                //Output the configuration key
 | 
				
			||||||
                finalText.append(line).append("\n");
 | 
					                finalText.append(line).append("\n");
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return finalText.toString().trim();
 | 
					        return finalText.toString().trim();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Fully reads a comment
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param builder            <p>The string builder to write to</p>
 | 
				
			||||||
 | 
					     * @param lines              <p>The lines to read from</p>
 | 
				
			||||||
 | 
					     * @param startIndex         <p>The index to start reading from</p>
 | 
				
			||||||
 | 
					     * @param commentIndentation <p>The indentation of the read comment</p>
 | 
				
			||||||
 | 
					     * @return <p>The index containing the next non-comment line</p>
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    private int readComment(StringBuilder builder, String[] lines, int startIndex, int commentIndentation) {
 | 
				
			||||||
 | 
					        for (int currentIndex = startIndex; currentIndex < lines.length; currentIndex++) {
 | 
				
			||||||
 | 
					            String line = lines[currentIndex];
 | 
				
			||||||
 | 
					            String possibleComment = line.trim();
 | 
				
			||||||
 | 
					            if (!line.contains(END_OF_COMMENT)) {
 | 
				
			||||||
 | 
					                possibleComment = possibleComment.replace(START_OF_COMMENT_LINE, "");
 | 
				
			||||||
 | 
					                builder.append(addIndentation(commentIndentation)).append("# ").append(possibleComment).append("\n");
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                return currentIndex;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return startIndex;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Gets a string containing the given indentation
 | 
					     * Gets a string containing the given indentation
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,6 +7,7 @@ import org.bukkit.Material;
 | 
				
			|||||||
import org.bukkit.Tag;
 | 
					import org.bukkit.Tag;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.io.BufferedWriter;
 | 
					import java.io.BufferedWriter;
 | 
				
			||||||
 | 
					import java.io.File;
 | 
				
			||||||
import java.io.FileWriter;
 | 
					import java.io.FileWriter;
 | 
				
			||||||
import java.io.IOException;
 | 
					import java.io.IOException;
 | 
				
			||||||
import java.util.HashMap;
 | 
					import java.util.HashMap;
 | 
				
			||||||
@@ -290,7 +291,7 @@ public class Gate {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public void save(String gateFolder) {
 | 
					    public void save(String gateFolder) {
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(gateFolder + filename));
 | 
					            BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(new File(gateFolder, filename)));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            //Save main material names
 | 
					            //Save main material names
 | 
				
			||||||
            writeConfig(bufferedWriter, "portal-open", portalOpenBlock.name());
 | 
					            writeConfig(bufferedWriter, "portal-open", portalOpenBlock.name());
 | 
				
			||||||
@@ -309,8 +310,8 @@ public class Gate {
 | 
				
			|||||||
            layout.saveLayout(bufferedWriter);
 | 
					            layout.saveLayout(bufferedWriter);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            bufferedWriter.close();
 | 
					            bufferedWriter.close();
 | 
				
			||||||
        } catch (IOException ex) {
 | 
					        } catch (IOException exception) {
 | 
				
			||||||
            Stargate.logSevere(String.format("Could not save Gate %s - %s", filename, ex.getMessage()));
 | 
					            Stargate.logSevere(String.format("Could not save Gate %s - %s", filename, exception.getMessage()));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -152,7 +152,7 @@ public class GateHandler {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //Update gate file in case the format has changed between versions
 | 
					        //Update gate file in case the format has changed between versions
 | 
				
			||||||
        gate.save(parentFolder + "/");
 | 
					        gate.save(parentFolder);
 | 
				
			||||||
        return gate;
 | 
					        return gate;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -82,8 +82,7 @@ public final class BungeeHelper {
 | 
				
			|||||||
            //Send the plugin message
 | 
					            //Send the plugin message
 | 
				
			||||||
            player.sendPluginMessage(Stargate.getInstance(), bungeeChannel, byteArrayOutputStream.toByteArray());
 | 
					            player.sendPluginMessage(Stargate.getInstance(), bungeeChannel, byteArrayOutputStream.toByteArray());
 | 
				
			||||||
        } catch (IOException ex) {
 | 
					        } catch (IOException ex) {
 | 
				
			||||||
            Stargate.logSevere("Error sending BungeeCord teleport packet");
 | 
					            Stargate.logSevere("Error sending BungeeCord teleport packet! Message: " + ex.getMessage());
 | 
				
			||||||
            ex.printStackTrace();
 | 
					 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
@@ -107,9 +106,8 @@ public final class BungeeHelper {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            //Send the plugin message
 | 
					            //Send the plugin message
 | 
				
			||||||
            player.sendPluginMessage(Stargate.getInstance(), bungeeChannel, byteArrayOutputStream.toByteArray());
 | 
					            player.sendPluginMessage(Stargate.getInstance(), bungeeChannel, byteArrayOutputStream.toByteArray());
 | 
				
			||||||
        } catch (IOException ex) {
 | 
					        } catch (IOException exception) {
 | 
				
			||||||
            Stargate.logSevere("Error sending BungeeCord connect packet");
 | 
					            Stargate.logSevere("Error sending BungeeCord connect packet! Message: " + exception.getMessage());
 | 
				
			||||||
            ex.printStackTrace();
 | 
					 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
@@ -137,9 +135,8 @@ public final class BungeeHelper {
 | 
				
			|||||||
            data = new byte[dataLength];
 | 
					            data = new byte[dataLength];
 | 
				
			||||||
            //Read the message to the prepared array
 | 
					            //Read the message to the prepared array
 | 
				
			||||||
            dataInputStream.readFully(data);
 | 
					            dataInputStream.readFully(data);
 | 
				
			||||||
        } catch (IOException ex) {
 | 
					        } catch (IOException exception) {
 | 
				
			||||||
            Stargate.logSevere("Error receiving BungeeCord message");
 | 
					            Stargate.logSevere("Error receiving BungeeCord message. Message: " + exception.getMessage());
 | 
				
			||||||
            ex.printStackTrace();
 | 
					 | 
				
			||||||
            return null;
 | 
					            return null;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return new String(data);
 | 
					        return new String(data);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -170,10 +170,9 @@ public final class PortalFileHelper {
 | 
				
			|||||||
                    "Starting post loading tasks", world));
 | 
					                    "Starting post loading tasks", world));
 | 
				
			||||||
            doPostLoadTasks(world, needsToSaveDatabase);
 | 
					            doPostLoadTasks(world, needsToSaveDatabase);
 | 
				
			||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
        } catch (Exception e) {
 | 
					        } catch (Exception exception) {
 | 
				
			||||||
            Stargate.logSevere(String.format("Exception while reading stargates from %s: %d", database.getName(),
 | 
					            Stargate.logSevere(String.format("Exception while reading stargates from %s: %d! Message: %s",
 | 
				
			||||||
                    lineIndex));
 | 
					                    database.getName(), lineIndex, exception.getMessage()));
 | 
				
			||||||
            e.printStackTrace();
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
#                                                                                  Version: ${project.version}
 | 
					#                                                                                   Version: ${project.version}
 | 
				
			||||||
# +--------------▄▄▄-- ‚——. -▄--▄-▄--▄-▄-▄▄▄▄▄---------------------------------------------------+ #
 | 
					# +--------------▄▄▄-- ‚——. -▄--▄-▄--▄-▄-▄▄▄▄▄---------------------------------------------------+ #
 | 
				
			||||||
# |              █▄▄▀ (“‡‡”) █▄▄▀ █▄▄▀ █   █       Support available at: sgrewritten.org/discord | #
 | 
					# |              █▄▄▀ (“‡‡”) █▄▄▀ █▄▄▀ █   █       Support available at: sgrewritten.org/discord | #
 | 
				
			||||||
# |              █▄▄█  \__/  █  █ █  █ █   █                    ‚-.                              | #
 | 
					# |              █▄▄█  \__/  █  █ █  █ █   █                    ‚-.                              | #
 | 
				
			||||||
@@ -107,6 +107,33 @@ gates:
 | 
				
			|||||||
    # This is more resource intensive, and should really only be used if verifyPortals is true.
 | 
					    # This is more resource intensive, and should really only be used if verifyPortals is true.
 | 
				
			||||||
    # Or if using an easily destroyable open/closed material.
 | 
					    # Or if using an easily destroyable open/closed material.
 | 
				
			||||||
    protectEntrance: false
 | 
					    protectEntrance: false
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  cosmetic:
 | 
				
			||||||
 | 
					    # Will the destination a networked portal last connected to be listed first in its scroll menu?
 | 
				
			||||||
 | 
					    rememberDestination: false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # For networked gates, are destinations listed alphabetically instead of chronologically?
 | 
				
			||||||
 | 
					    # (This applies to all non-fixed and non-random gates).
 | 
				
			||||||
 | 
					    sortNetworkDestinations: false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # What color will StarGate use for the text on gate signs?
 | 
				
			||||||
 | 
					    # Note that players can override this with DYE and/or GLOW_INK_SAC
 | 
				
			||||||
 | 
					    mainSignColor: BLACK
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # What color will StarGate use to accent the above text?
 | 
				
			||||||
 | 
					    highlightSignColor: WHITE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # Text and highlight colors can be modified on a per-sign basis (below).
 | 
				
			||||||
 | 
					    # Format: 'SIGN_TYPE:mainSignColor,highlightSignColor'
 | 
				
			||||||
 | 
					    perSignColors:
 | 
				
			||||||
 | 
					      - 'ACACIA:default,default'
 | 
				
			||||||
 | 
					      - 'BIRCH:default,default'
 | 
				
			||||||
 | 
					      - 'CRIMSON:inverted,inverted'
 | 
				
			||||||
 | 
					      - 'DARK_OAK:inverted,inverted'
 | 
				
			||||||
 | 
					      - 'JUNGLE:default,default'
 | 
				
			||||||
 | 
					      - 'OAK:default,default'
 | 
				
			||||||
 | 
					      - 'SPRUCE:inverted,inverted'
 | 
				
			||||||
 | 
					      - 'WARPED:inverted,inverted'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# +----------------------------------------------------------------------------------------------+ #
 | 
					# +----------------------------------------------------------------------------------------------+ #
 | 
				
			||||||
# |                                            Economy                                           | #
 | 
					# |                                            Economy                                           | #
 | 
				
			||||||
@@ -149,32 +176,12 @@ economy:
 | 
				
			|||||||
  # https://hub.spigotmc.org/javadocs/spigot/org/bukkit/ChatColor.html 
 | 
					  # https://hub.spigotmc.org/javadocs/spigot/org/bukkit/ChatColor.html 
 | 
				
			||||||
  freeGatesColor: DARK_GREEN
 | 
					  freeGatesColor: DARK_GREEN
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  cosmetic:
 | 
					  # Does your server have a tax account (closed economy)?
 | 
				
			||||||
    # Will the destination a networked portal last connected to be listed first in its scroll menu?
 | 
					  # If so, please provide the name of your tax account (collected money will be sent to it).
 | 
				
			||||||
    rememberDestination: false
 | 
					  # If not, leave this section blank (collected money will be deleted).
 | 
				
			||||||
    
 | 
					  #
 | 
				
			||||||
    # For networked gates, are destinations listed alphabetically instead of chronologically?
 | 
					  # Note that useCost money is excluded from this system when toOwner is true.
 | 
				
			||||||
    # (This applies to all non-fixed and non-random gates).
 | 
					  taxAccount: ''
 | 
				
			||||||
    sortNetworkDestinations: false
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    # What color will StarGate use for the text on gate signs?
 | 
					 | 
				
			||||||
    # Note that players can override this with DYE and/or GLOW_INK_SAC
 | 
					 | 
				
			||||||
    mainSignColor: BLACK
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    # What color will StarGate use to accent the above text?
 | 
					 | 
				
			||||||
    highlightSignColor: WHITE
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    # Text and highlight colors can be modified on a per-sign basis (below).
 | 
					 | 
				
			||||||
    # Format: 'SIGN_TYPE:mainSignColor,highlightSignColor'
 | 
					 | 
				
			||||||
    perSignColors:
 | 
					 | 
				
			||||||
      - 'ACACIA:default,default'
 | 
					 | 
				
			||||||
      - 'BIRCH:default,default'
 | 
					 | 
				
			||||||
      - 'CRIMSON:inverted,inverted'
 | 
					 | 
				
			||||||
      - 'DARK_OAK:inverted,inverted'
 | 
					 | 
				
			||||||
      - 'JUNGLE:default,default'
 | 
					 | 
				
			||||||
      - 'OAK:default,default'
 | 
					 | 
				
			||||||
      - 'SPRUCE:inverted,inverted'
 | 
					 | 
				
			||||||
      - 'WARPED:inverted,inverted'
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# +----------------------------------------------------------------------------------------------+ #
 | 
					# +----------------------------------------------------------------------------------------------+ #
 | 
				
			||||||
# |                                           Technical                                          | #
 | 
					# |                                           Technical                                          | #
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user