Skip to content

Commit 7cb5195

Browse files
committed
The load command now correctly checks and generates a world according to its type (Overworld, Nether, or End).
1 parent f5ed49c commit 7cb5195

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

src/main/java/com/alihaine/bulmultiverse/command/LoadCommand.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55
import com.alihaine.bulmultiverse.BulMultiverse;
66
import com.alihaine.bulmultiverse.file.Message;
77
import com.alihaine.bulmultiverse.world.WorldData;
8+
import com.alihaine.bulmultiverse.world.WorldOption;
9+
import org.bukkit.Bukkit;
810
import org.bukkit.command.CommandSender;
911

12+
import java.io.File;
1013
import java.util.HashMap;
1114

1215
@CommandAlias(BaseBmvCommand.commandRootAlias)
@@ -15,12 +18,20 @@ public class LoadCommand extends BaseCommand {
1518
@Subcommand("load")
1619
@Description("Load existing world")
1720
@Syntax("/bmv load [world_name]")
18-
public void onLoad(CommandSender sender, String targetWorld) {
21+
public void onLoad(CommandSender sender, String targetWorld) throws Exception {
1922
if (!BulMultiverse.getWorldsFile().isWorldFolderExisting(targetWorld)) {
2023
new Message("world_not_found").withPlaceHolder("name", targetWorld).sendMessage(sender);
2124
return;
2225
}
23-
WorldData worldData = new WorldData(targetWorld, new HashMap<>());
26+
27+
final HashMap<WorldOption, Object> options = new HashMap<>();
28+
File file = new File(Bukkit.getWorldContainer(), targetWorld);
29+
if (new File(file, "DIM-1").exists())
30+
options.put(BulMultiverse.getWorldOptionManager().getOption("-e"), "nether");
31+
else if (new File(file, "DIM1").exists())
32+
options.put(BulMultiverse.getWorldOptionManager().getOption("-e"), "the_end");
33+
34+
WorldData worldData = new WorldData(targetWorld, options);
2435
worldData.createWorld(sender);
2536
BulMultiverse.getWorldsFile().saveWorldDataToFile(worldData);
2637
}

0 commit comments

Comments
 (0)