Skip to content

Commit

Permalink
Create PhantomWorld.save for ease-of use.
Browse files Browse the repository at this point in the history
  • Loading branch information
creatorfromhell committed Nov 29, 2023
1 parent ad443bf commit 6ea8537
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ public void gamerule(BukkitCommandActor actor) {
//todo: port gamerule command
}

@Subcommand({"import", "im"})
@CommandPermission("phantomworlds.command.phantomworlds.import")
public void importCMD(BukkitCommandActor actor, final World world) {
InfoCommand.onCommand(actor);
}

@Subcommand({"info", "i"})
@CommandPermission("phantomworlds.command.phantomworlds.info")
public void info(BukkitCommandActor actor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,26 +333,7 @@ public void parseCommand(CommandSender sender, Command cmd, String label, String
new MultiMessage.Placeholder("world", worldName, false)
))).send(sender);

final String cfgPath = "worlds-to-load." + worldName + ".";
PhantomWorlds.instance().data.getConfig().set(cfgPath + "environment", environment.toString());
PhantomWorlds.instance().data.getConfig().set(cfgPath + "generateStructures", generateStructures);
PhantomWorlds.instance().data.getConfig().set(cfgPath + "generator", generator);
PhantomWorlds.instance().data.getConfig().set(cfgPath + "generatorSettings", generatorSettings);
PhantomWorlds.instance().data.getConfig().set(cfgPath + "hardcore", hardcore);
PhantomWorlds.instance().data.getConfig().set(cfgPath + "seed", seed);
PhantomWorlds.instance().data.getConfig().set(cfgPath + "worldType", worldType.toString());
PhantomWorlds.instance().data.getConfig().set(cfgPath + "spawnMobs", spawnMobs);
PhantomWorlds.instance().data.getConfig().set(cfgPath + "spawnAnimals", spawnAnimals);
PhantomWorlds.instance().data.getConfig().set(cfgPath + "keepSpawnInMemory", keepSpawnInMemory);
PhantomWorlds.instance().data.getConfig().set(cfgPath + "allowPvP", allowPvP);
PhantomWorlds.instance().data.getConfig().set(cfgPath + "difficulty", difficulty.toString());
PhantomWorlds.instance().data.getConfig().set(cfgPath + "gameMode", mode.name());

try {
PhantomWorlds.instance().data.save();
} catch(final IOException ex) {
throw new RuntimeException(ex);
}
pworld.save();

(new MultiMessage(
PhantomWorlds.instance().messages.getConfig().getStringList(
Expand Down
25 changes: 25 additions & 0 deletions src/main/java/me/lokka30/phantomworlds/world/PhantomWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

Expand Down Expand Up @@ -146,6 +147,30 @@ public void create() {
}
}

public void save() {

final String cfgPath = "worlds-to-load." + name + ".";
PhantomWorlds.instance().data.getConfig().set(cfgPath + "environment", environment.toString());
PhantomWorlds.instance().data.getConfig().set(cfgPath + "generateStructures", generateStructures);
PhantomWorlds.instance().data.getConfig().set(cfgPath + "generator", generator);
PhantomWorlds.instance().data.getConfig().set(cfgPath + "generatorSettings", generatorSettings);
PhantomWorlds.instance().data.getConfig().set(cfgPath + "hardcore", hardcore);
PhantomWorlds.instance().data.getConfig().set(cfgPath + "seed", seed);
PhantomWorlds.instance().data.getConfig().set(cfgPath + "worldType", worldType.toString());
PhantomWorlds.instance().data.getConfig().set(cfgPath + "spawnMobs", spawnMobs);
PhantomWorlds.instance().data.getConfig().set(cfgPath + "spawnAnimals", spawnAnimals);
PhantomWorlds.instance().data.getConfig().set(cfgPath + "keepSpawnInMemory", keepSpawnInMemory);
PhantomWorlds.instance().data.getConfig().set(cfgPath + "allowPvP", allowPvP);
PhantomWorlds.instance().data.getConfig().set(cfgPath + "difficulty", difficulty.toString());
PhantomWorlds.instance().data.getConfig().set(cfgPath + "gameMode", gameMode.name());

try {
PhantomWorlds.instance().data.save();
} catch(final IOException ex) {
throw new RuntimeException(ex);
}
}

public void loadGameRules() {

}
Expand Down

0 comments on commit 6ea8537

Please sign in to comment.