Implemented per template generators at ws reset command and at world creation

This commit is contained in:
Daniel 2019-05-03 20:08:40 +02:00
parent 679ee5e8f9
commit 9a255aedba
3 changed files with 10 additions and 7 deletions

View File

@ -71,7 +71,7 @@ public class WorldSettingsCommands {
WorldTemplate template = WorldTemplateProvider.getInstace()
.getTemplate(PluginConfig.getDefaultWorldTemplate());
if (template != null)
createWorld(p, worldname, f, new File(template.getPath()), sw);
createWorld(p, worldname, f, template, sw);
else {
p.sendMessage(PluginConfig.getPrefix() + "§cError in config at \"worldtemplates.default\"");
p.sendMessage(PluginConfig.getPrefix() + "§cPlease contact an administrator");
@ -79,7 +79,7 @@ public class WorldSettingsCommands {
} else {
WorldChooseGUI.letChoose(p, (template) -> {
if (template != null)
createWorld(p, worldname, f, new File(template.getPath()), sw);
createWorld(p, worldname, f, template, sw);
else {
p.sendMessage(PluginConfig.getPrefix() + "§cError in config at \"worldtemplates.default\"");
p.sendMessage(PluginConfig.getPrefix() + "§cPlease contact an administrator");
@ -196,7 +196,7 @@ public class WorldSettingsCommands {
}
}
private void createWorld(Player p, String worldname, File f, File exampleworld, SystemWorld sw) {
private void createWorld(Player p, String worldname, File f, WorldTemplate template, SystemWorld sw) {
File[] files = f.listFiles();
for (File file : files) {
@ -206,8 +206,9 @@ public class WorldSettingsCommands {
}
try {
if (exampleworld.isDirectory())
FileUtils.copyDirectory(exampleworld, f);
File templateDirectory = new File(template.getPath());
if (templateDirectory.isDirectory())
FileUtils.copyDirectory(templateDirectory, f);
toConfirm.remove(p);
FileUtils.moveDirectoryToDirectory(f, Bukkit.getWorldContainer(), false);
@ -219,7 +220,7 @@ public class WorldSettingsCommands {
p.sendMessage(MessageConfig.getWorldReseted());
// For fast worldcreating after reset
WorldCreator creator = new WorldCreator(worldname);
WorldCreator creator = template.getGeneratorSettings().asWorldCreator(worldname);
sw.setCreating(true);
// For #16

View File

@ -253,7 +253,7 @@ public class SystemWorld {
int id = DependenceConfig.getHighestID() + 1;
String worldname = "ID" + id + "-" + uuid;
WorldCreator creator = PluginConfig.getWorldCreator(worldname);
WorldCreator creator = template.getGeneratorSettings().asWorldCreator(worldname);
WorldCreateEvent event = new WorldCreateEvent(p, creator);
Bukkit.getPluginManager().callEvent(event);

View File

@ -2,11 +2,13 @@ package de.butzlabben.world.wrapper;
import de.butzlabben.inventory.OrcItem;
import de.butzlabben.world.config.GuiConfig;
import lombok.Getter;
/**
* @author Butzlabben
* @since 15.12.2018
*/
@Getter
public class WorldTemplate {
private final String name;