Skip to content

Commit

Permalink
Fix /dxl msg if no map config exists; resolves #144
Browse files Browse the repository at this point in the history
  • Loading branch information
Sataniel98 committed Sep 2, 2016
1 parent 258e115 commit 48744a2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void onExecute(String[] args, CommandSender sender) {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
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;
Expand Down Expand Up @@ -103,6 +104,27 @@ public void setName(String name) {
* @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;
}

Expand Down

0 comments on commit 48744a2

Please sign in to comment.