From 1499f71a2850e7a0bab250559847be3e052a32ff Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Sun, 10 Jan 2016 16:48:58 +0100 Subject: [PATCH] Fix possible bugs with test & play commands --- src/io/github/dre2n/dungeonsxl/command/PlayCommand.java | 8 +++++++- src/io/github/dre2n/dungeonsxl/command/TestCommand.java | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/io/github/dre2n/dungeonsxl/command/PlayCommand.java b/src/io/github/dre2n/dungeonsxl/command/PlayCommand.java index 13334adf..a2b1a3e5 100644 --- a/src/io/github/dre2n/dungeonsxl/command/PlayCommand.java +++ b/src/io/github/dre2n/dungeonsxl/command/PlayCommand.java @@ -70,7 +70,7 @@ public class PlayCommand extends DCommand { if ( !GameWorld.canPlayDungeon(identifier, player)) { File file = new File(plugin.getDataFolder() + "/maps/" + identifier + "/config.yml"); - if (file != null) { + if (file.exists()) { WorldConfig confReader = new WorldConfig(file); if (confReader != null) { @@ -96,6 +96,12 @@ public class PlayCommand extends DCommand { dGroup.setGameWorld(GameWorld.load(DGroup.getByPlayer(player).getMapName())); } + if (dGroup.getGameWorld() == null) { + MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_NOT_SAVED, DGroup.getByPlayer(player).getMapName())); + dGroup.remove(); + return; + } + if (dGroup.getGameWorld().getLocLobby() == null) { new DPlayer(player, dGroup.getGameWorld().getWorld(), dGroup.getGameWorld().getWorld().getSpawnLocation(), false); diff --git a/src/io/github/dre2n/dungeonsxl/command/TestCommand.java b/src/io/github/dre2n/dungeonsxl/command/TestCommand.java index 01c676f3..8fb9567e 100644 --- a/src/io/github/dre2n/dungeonsxl/command/TestCommand.java +++ b/src/io/github/dre2n/dungeonsxl/command/TestCommand.java @@ -72,6 +72,12 @@ public class TestCommand extends DCommand { dGroup.setGameWorld(GameWorld.load(DGroup.getByPlayer(player).getMapName())); } + if (dGroup.getGameWorld() == null) { + MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_NOT_SAVED, DGroup.getByPlayer(player).getMapName())); + dGroup.remove(); + return; + } + DPlayer newDPlayer; if (dGroup.getGameWorld().getLocLobby() == null) {