chunkUnloadQueue = new PriorityQueue<>();
@@ -353,7 +353,7 @@ public class Stargate extends JavaPlugin {
super.reloadConfig();
this.configuration = new StargateYamlConfiguration();
try {
- this.configuration.load(new File(getDataFolder(), configFileName));
+ this.configuration.load(new File(getDataFolder(), CONFIG_FILE_NAME));
} catch (IOException | InvalidConfigurationException e) {
logSevere("Unable to load the configuration! Message: " + e.getMessage());
}
@@ -363,7 +363,7 @@ public class Stargate extends JavaPlugin {
public void saveConfig() {
super.saveConfig();
try {
- this.configuration.save(new File(getDataFolder(), configFileName));
+ this.configuration.save(new File(getDataFolder(), CONFIG_FILE_NAME));
} catch (IOException e) {
logSevere("Unable to save the configuration! Message: " + e.getMessage());
}
@@ -381,15 +381,15 @@ public class Stargate extends JavaPlugin {
@Override
public void onEnable() {
- stargate = this;
- logger = getLogger();
+ Stargate.stargate = this;
+ Stargate.logger = getLogger();
this.saveDefaultConfig();
this.getConfig();
PluginDescriptionFile pluginDescriptionFile = this.getDescription();
pluginManager = getServer().getPluginManager();
this.configuration = new StargateYamlConfiguration();
try {
- this.configuration.load(new File(getDataFolder(), configFileName));
+ this.configuration.load(new File(getDataFolder(), CONFIG_FILE_NAME));
} catch (IOException | InvalidConfigurationException e) {
getLogger().log(Level.SEVERE, e.getMessage());
}
diff --git a/src/main/java/net/knarcraft/stargate/config/StargateConfig.java b/src/main/java/net/knarcraft/stargate/config/StargateConfig.java
index dce9109..5569e4d 100644
--- a/src/main/java/net/knarcraft/stargate/config/StargateConfig.java
+++ b/src/main/java/net/knarcraft/stargate/config/StargateConfig.java
@@ -549,10 +549,8 @@ public final class StargateConfig {
createMissingFolder(new File(portalFolder), "Unable to create portal directory");
File newFile = new File(portalFolder, Stargate.getInstance().getServer().getWorlds().get(0).getName() +
".db");
- if (!newFile.exists() && !newFile.getParentFile().exists()) {
- if (!newFile.getParentFile().mkdirs()) {
- logger.severe("Unable to create portal database folder: " + newFile.getParentFile().getPath());
- }
+ if (!newFile.exists() && !newFile.getParentFile().exists() && !newFile.getParentFile().mkdirs()) {
+ logger.severe("Unable to create portal database folder: " + newFile.getParentFile().getPath());
}
}
@@ -563,10 +561,8 @@ public final class StargateConfig {
* @param errorMessage The error message to display if unable to create the folder
*/
private void createMissingFolder(File folder, String errorMessage) {
- if (!folder.exists()) {
- if (!folder.mkdirs()) {
- logger.severe(errorMessage);
- }
+ if (!folder.exists() && !folder.mkdirs()) {
+ logger.severe(errorMessage);
}
}
diff --git a/src/main/java/net/knarcraft/stargate/config/StargateYamlConfiguration.java b/src/main/java/net/knarcraft/stargate/config/StargateYamlConfiguration.java
index 9e7bfd0..085c3b2 100644
--- a/src/main/java/net/knarcraft/stargate/config/StargateYamlConfiguration.java
+++ b/src/main/java/net/knarcraft/stargate/config/StargateYamlConfiguration.java
@@ -10,7 +10,11 @@ import java.util.ArrayList;
import java.util.List;
/**
- * A YAML configuration which keeps all comments
+ * A YAML configuration which retains all comments
+ *
+ * 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.
*
* @author Thorin
*/