Fix /dxl msg if no map config exists; resolves #144

This commit is contained in:
Daniel Saukel 2016-09-02 20:35:23 +02:00
parent 258e115a38
commit 48744a2175
2 changed files with 23 additions and 1 deletions

View File

@ -61,7 +61,7 @@ public class MsgCommand extends BRCommand {
try { try {
int id = Integer.parseInt(args[1]); int id = Integer.parseInt(args[1]);
WorldConfig config = editWorld.getResource().getConfig(); WorldConfig config = editWorld.getResource().getConfig(true);
if (args.length == 2) { if (args.length == 2) {
String msg = config.getMessage(id); String msg = config.getMessage(id);

View File

@ -25,6 +25,7 @@ import io.github.dre2n.dungeonsxl.player.DEditPlayer;
import io.github.dre2n.dungeonsxl.task.BackupResourceTask; import io.github.dre2n.dungeonsxl.task.BackupResourceTask;
import io.github.dre2n.dungeonsxl.util.worldloader.WorldLoader; import io.github.dre2n.dungeonsxl.util.worldloader.WorldLoader;
import java.io.File; import java.io.File;
import java.io.IOException;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.WorldCreator; import org.bukkit.WorldCreator;
@ -103,6 +104,27 @@ public class DResourceWorld {
* @return the WorldConfig * @return the WorldConfig
*/ */
public WorldConfig getConfig() { 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; return config;
} }