mirror of
https://github.com/trainerlord/WorldSystem.git
synced 2025-01-11 19:31:55 +01:00
setup world creation
This commit is contained in:
parent
bb65475364
commit
1ec5157f4f
@ -5,14 +5,11 @@ package de.butzlabben.WorldSystem;
|
||||
|
||||
import co.aikar.commands.BukkitCommandManager;
|
||||
import de.butzlabben.WorldSystem.commands.WSCommands;
|
||||
import de.butzlabben.WorldSystem.configs.Config;
|
||||
import de.butzlabben.WorldSystem.configs.LanguageConfig;
|
||||
|
||||
public class WorldSystem { //TODO extends JavaPlugin
|
||||
|
||||
private static final String LOCALE = "en";
|
||||
|
||||
|
||||
|
||||
//TODO: @Override
|
||||
public void onEnable() {
|
||||
//create configs
|
||||
@ -30,7 +27,7 @@ public class WorldSystem { //TODO extends JavaPlugin
|
||||
private void create_configs() {
|
||||
//Establish the language for the plugin
|
||||
LanguageConfig.verify_all_configs();
|
||||
LanguageConfig.set_config(LOCALE);
|
||||
LanguageConfig.set_config(Config.getLanguage());
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,40 +1,46 @@
|
||||
package de.butzlabben.WorldSystem.commands;
|
||||
|
||||
import de.butzlabben.WorldSystem.configs.Config;
|
||||
import de.butzlabben.WorldSystem.configs.LanguageConfig;
|
||||
import de.butzlabben.WorldSystem.data.WorldSystemData;
|
||||
import de.butzlabben.world.WorldSystem;
|
||||
import de.butzlabben.world.config.MessageConfig;
|
||||
import de.butzlabben.world.wrapper.SystemWorld;
|
||||
import de.butzlabben.WorldSystem.worldgen.WorldTemplate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CreateWorldCommand {
|
||||
|
||||
private static final int WORLD_COUNT_LIMIT = 1; //REPLACE WITH CONFIG
|
||||
private static final boolean ALLOW_TEMPLATE_CHOICE = false; //REPLACE WITH CONFIG
|
||||
|
||||
|
||||
public CreateWorldCommand(Player player) {
|
||||
WorldSystemData ws_data = WorldSystemData.connect();
|
||||
int world_count = ws_data.getWorldCountForPlayer(player.getUniqueId().toString());
|
||||
|
||||
if (world_count < WORLD_COUNT_LIMIT) {
|
||||
if (world_count < Config.getPlayerWorldCountLimit()) {
|
||||
player.sendMessage(LanguageConfig.getWorldAlreadyExists());
|
||||
}
|
||||
|
||||
if (ALLOW_TEMPLATE_CHOICE) {
|
||||
if (Config.AllowTemplateChoice()) {
|
||||
//TODO
|
||||
} else {
|
||||
create_default_world();
|
||||
create_default_world(player);
|
||||
}
|
||||
}
|
||||
|
||||
private void create_default_world() {
|
||||
private void create_default_world(Player player) {
|
||||
//get default template from world generator
|
||||
WorldTemplate template = WorldTemplate.default_template();
|
||||
//then create
|
||||
create_world();
|
||||
create_world(player, template);
|
||||
}
|
||||
|
||||
private void create_world() {
|
||||
|
||||
private void create_world(Player player, WorldTemplate template ) {
|
||||
Bukkit.getScheduler().runTask(WorldSystem.getInstance(), () -> {
|
||||
//create the world
|
||||
if (template.create()) { //add settings;
|
||||
player.sendMessage(MessageConfig.getSettingUpWorld());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,45 @@
|
||||
package de.butzlabben.WorldSystem.configs;
|
||||
|
||||
public class Config {
|
||||
private static ConfigData data;
|
||||
|
||||
private static ConfigData get_config() {
|
||||
if (data == null) {
|
||||
data = new ConfigData();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public static String getLanguage() {return get_config().locale;}
|
||||
|
||||
|
||||
public static boolean AllowTemplateChoice() {return get_config().allow_template_choice;}
|
||||
public static int getPlayerWorldCountLimit() {return get_config().player_world_limit;}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
class ConfigData {
|
||||
//general
|
||||
public String locale;
|
||||
|
||||
//player world stuff
|
||||
public boolean allow_template_choice;
|
||||
public int player_world_limit;
|
||||
|
||||
|
||||
public ConfigData() {
|
||||
//load the yaml file
|
||||
|
||||
|
||||
//set data
|
||||
this.locale = "en";
|
||||
|
||||
|
||||
this.allow_template_choice = false;
|
||||
this.player_world_limit = 1;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,14 @@
|
||||
package de.butzlabben.WorldSystem.worldgen;
|
||||
|
||||
public class WorldTemplate {
|
||||
|
||||
|
||||
|
||||
public static WorldTemplate default_template() {
|
||||
return new WorldTemplate();
|
||||
}
|
||||
|
||||
public boolean create() {
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user