Setup from console now works

This commit is contained in:
boy0001 2015-05-15 03:27:37 +10:00
parent 9567f92eae
commit e7a1e4ecf7
2 changed files with 16 additions and 8 deletions

View File

@ -8,7 +8,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
<artifactId>PlotSquared</artifactId> <artifactId>PlotSquared</artifactId>
<version>2.10.11</version> <version>2.11.0</version>
<name>PlotSquared</name> <name>PlotSquared</name>
<packaging>jar</packaging> <packaging>jar</packaging>
<build> <build>

View File

@ -41,7 +41,7 @@ import com.intellectualcrafters.plot.util.SetupUtils;
public class Setup extends SubCommand { public class Setup extends SubCommand {
public Setup() { public Setup() {
super("setup", "plots.admin.command.setup", "Plotworld setup command", "setup", "create", CommandCategory.ACTIONS, true); super("setup", "plots.admin.command.setup", "Plotworld setup command", "setup", "create", CommandCategory.ACTIONS, false);
} }
public void displayGenerators(PlotPlayer plr) { public void displayGenerators(PlotPlayer plr) {
@ -68,7 +68,13 @@ public class Setup extends SubCommand {
@Override @Override
public boolean execute(final PlotPlayer plr, final String... args) { public boolean execute(final PlotPlayer plr, final String... args) {
// going through setup // going through setup
final String name = plr.getName(); String name;
if (plr == null) {
name = "*";
}
else {
name = plr.getName();
}
if (!SetupUtils.setupMap.containsKey(name)) { if (!SetupUtils.setupMap.containsKey(name)) {
final SetupObject object = new SetupObject(); final SetupObject object = new SetupObject();
SetupUtils.setupMap.put(name, object); SetupUtils.setupMap.put(name, object);
@ -79,12 +85,12 @@ public class Setup extends SubCommand {
} }
if (args.length == 1) { if (args.length == 1) {
if (args[0].equalsIgnoreCase("cancel")) { if (args[0].equalsIgnoreCase("cancel")) {
SetupUtils.setupMap.remove(plr.getName()); SetupUtils.setupMap.remove(name);
MainUtil.sendMessage(plr, "&aCancelled setup"); MainUtil.sendMessage(plr, "&aCancelled setup");
return false; return false;
} }
if (args[0].equalsIgnoreCase("back")) { if (args[0].equalsIgnoreCase("back")) {
final SetupObject object = SetupUtils.setupMap.get(plr.getName()); final SetupObject object = SetupUtils.setupMap.get(name);
if (object.setup_index > 0) { if (object.setup_index > 0) {
object.setup_index--; object.setup_index--;
final ConfigurationNode node = object.step[object.current]; final ConfigurationNode node = object.step[object.current];
@ -224,7 +230,7 @@ public class Setup extends SubCommand {
MainUtil.sendMessage(plr, "&cThat world name is already taken!"); MainUtil.sendMessage(plr, "&cThat world name is already taken!");
} }
object.world = args[0]; object.world = args[0];
SetupUtils.setupMap.remove(plr.getName()); SetupUtils.setupMap.remove(name);
final String world; final String world;
if (object.setupManager == null) { if (object.setupManager == null) {
world = SetupUtils.manager.setupWorld(object); world = SetupUtils.manager.setupWorld(object);
@ -233,13 +239,15 @@ public class Setup extends SubCommand {
world = object.setupManager.setupWorld(object); world = object.setupManager.setupWorld(object);
} }
try { try {
if (plr != null) {
plr.teleport(BlockManager.manager.getSpawn(world)); plr.teleport(BlockManager.manager.getSpawn(world));
}
} catch (final Exception e) { } catch (final Exception e) {
plr.sendMessage("&cAn error occured. See console for more information"); plr.sendMessage("&cAn error occured. See console for more information");
e.printStackTrace(); e.printStackTrace();
} }
sendMessage(plr, C.SETUP_FINISHED, object.world); sendMessage(plr, C.SETUP_FINISHED, object.world);
SetupUtils.setupMap.remove(plr.getName()); SetupUtils.setupMap.remove(name);
} }
} }
return false; return false;