Fixed #2 and added generation setting and changed config defaults

This commit is contained in:
BuildTools 2018-05-13 22:46:09 +02:00
parent 3e9140be89
commit ee8d79e159
3 changed files with 22 additions and 2 deletions

View File

@ -27,7 +27,15 @@ public class WSLeaveCommand implements CommandExecutor {
}
String worldname = p.getWorld().getName();
WorldPlayer wp = new WorldPlayer(p, worldname);
if (wp.isOnSystemWorld()) {
// Extra safety for #2
if (PluginConfig.getSpawn().getWorld() == null) {
Bukkit.getConsoleSender().sendMessage(PluginConfig.getPrefix() + "§cThe spawn is not properly set");
cs.sendMessage(PluginConfig.getPrefix() + "§cThe spawn is not properly set");
return true;
}
p.teleport(PluginConfig.getSpawn());
p.setGameMode(PluginConfig.getSpawnGamemode());
World w = Bukkit.getWorld(p.getWorld().getName());

View File

@ -38,8 +38,9 @@ public class PluginConfig {
cfg.isInt("lagsystem.period_in_seconds") && cfg.isInt("lagsystem.entities_per_world")
&& cfg.isBoolean("lagsystem.garbagecollector.use")
&& cfg.isInt("lagsystem.garbagecollector.period_in_minutes") &&
cfg.isString("worldgeneration.type") && cfg.isString("worldgeneration.environment")
&& cfg.isString("worldgeneration.generation")
&& (cfg.isLong("worldgeneration.seed") || cfg.isInt("worldgeneration.seed")) &&
cfg.isString("spawn.spawnpoint.world") && cfg.isInt("spawn.gamemode")
@ -54,7 +55,10 @@ public class PluginConfig {
&& (cfg.isDouble("worldspawn.spawnpoint.y") || cfg.isInt("worldspawn.spawnpoint.y"))
&& (cfg.isDouble("worldspawn.spawnpoint.z") || cfg.isInt("worldspawn.spawnpoint.z"))
&& (cfg.isDouble("worldspawn.spawnpoint.yaw") || cfg.isInt("worldspawn.spawnpoint.yaw"))
&& (cfg.isDouble("worldspawn.spawnpoint.pitch") || cfg.isInt("worldspawn.spawnpoint.pitch")))) {
&& (cfg.isDouble("worldspawn.spawnpoint.pitch") || cfg.isInt("worldspawn.spawnpoint.pitch"))
//Should fix #2
&& getSpawn().getWorld() != null)) {
try {
Files.copy(file.toPath(),
new File(file.getParentFile(), "config-broken-"
@ -162,6 +166,10 @@ public class PluginConfig {
return e;
}
public static String getGenerator() {
return getConfig().getString("worldgeneration.generator");
}
public static WorldType getWorldType() {
YamlConfiguration cfg = getConfig();
String t = cfg.getString("worldgeneration.type");
@ -187,4 +195,5 @@ public class PluginConfig {
public static boolean confirmNeed() {
return getConfig().getBoolean("need_confirm", true);
}
}

View File

@ -251,6 +251,9 @@ public class SystemWorld {
creator.seed(seed);
creator.type(type);
creator.environment(env);
String generator = PluginConfig.getGenerator();
if(!generator.trim().isEmpty())
creator.generator(generator);
WorldCreateEvent event = new WorldCreateEvent(p, creator);
Bukkit.getPluginManager().callEvent(event);