diff --git a/core/src/main/java/io/github/dre2n/dungeonsxl/command/MsgCommand.java b/core/src/main/java/io/github/dre2n/dungeonsxl/command/MsgCommand.java index 8ca129ab..643dccdc 100644 --- a/core/src/main/java/io/github/dre2n/dungeonsxl/command/MsgCommand.java +++ b/core/src/main/java/io/github/dre2n/dungeonsxl/command/MsgCommand.java @@ -61,7 +61,7 @@ public class MsgCommand extends BRCommand { try { int id = Integer.parseInt(args[1]); - WorldConfig config = editWorld.getResource().getConfig(); + WorldConfig config = editWorld.getResource().getConfig(true); if (args.length == 2) { String msg = config.getMessage(id); diff --git a/core/src/main/java/io/github/dre2n/dungeonsxl/world/DResourceWorld.java b/core/src/main/java/io/github/dre2n/dungeonsxl/world/DResourceWorld.java index 9375cd6a..02f06c93 100644 --- a/core/src/main/java/io/github/dre2n/dungeonsxl/world/DResourceWorld.java +++ b/core/src/main/java/io/github/dre2n/dungeonsxl/world/DResourceWorld.java @@ -25,6 +25,7 @@ import io.github.dre2n.dungeonsxl.player.DEditPlayer; import io.github.dre2n.dungeonsxl.task.BackupResourceTask; import io.github.dre2n.dungeonsxl.util.worldloader.WorldLoader; import java.io.File; +import java.io.IOException; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.WorldCreator; @@ -103,6 +104,27 @@ public class DResourceWorld { * @return the WorldConfig */ public WorldConfig getConfig() { + return getConfig(false); + } + + /** + * @param generate + * if a config should be generated if none exists + * @return the WorldConfig + */ + public WorldConfig getConfig(boolean generate) { + if (config == null) { + File file = new File(folder, "config.yml"); + if (file.exists()) { + try { + file.createNewFile(); + } catch (IOException exception) { + exception.printStackTrace(); + } + } + config = new WorldConfig(file); + } + return config; }