mirror of
https://github.com/trainerlord/WorldSystem.git
synced 2025-02-10 00:11:32 +01:00
Implemented per template generators at ws reset command and at world creation
This commit is contained in:
parent
679ee5e8f9
commit
9a255aedba
@ -71,7 +71,7 @@ public class WorldSettingsCommands {
|
|||||||
WorldTemplate template = WorldTemplateProvider.getInstace()
|
WorldTemplate template = WorldTemplateProvider.getInstace()
|
||||||
.getTemplate(PluginConfig.getDefaultWorldTemplate());
|
.getTemplate(PluginConfig.getDefaultWorldTemplate());
|
||||||
if (template != null)
|
if (template != null)
|
||||||
createWorld(p, worldname, f, new File(template.getPath()), sw);
|
createWorld(p, worldname, f, template, sw);
|
||||||
else {
|
else {
|
||||||
p.sendMessage(PluginConfig.getPrefix() + "§cError in config at \"worldtemplates.default\"");
|
p.sendMessage(PluginConfig.getPrefix() + "§cError in config at \"worldtemplates.default\"");
|
||||||
p.sendMessage(PluginConfig.getPrefix() + "§cPlease contact an administrator");
|
p.sendMessage(PluginConfig.getPrefix() + "§cPlease contact an administrator");
|
||||||
@ -79,7 +79,7 @@ public class WorldSettingsCommands {
|
|||||||
} else {
|
} else {
|
||||||
WorldChooseGUI.letChoose(p, (template) -> {
|
WorldChooseGUI.letChoose(p, (template) -> {
|
||||||
if (template != null)
|
if (template != null)
|
||||||
createWorld(p, worldname, f, new File(template.getPath()), sw);
|
createWorld(p, worldname, f, template, sw);
|
||||||
else {
|
else {
|
||||||
p.sendMessage(PluginConfig.getPrefix() + "§cError in config at \"worldtemplates.default\"");
|
p.sendMessage(PluginConfig.getPrefix() + "§cError in config at \"worldtemplates.default\"");
|
||||||
p.sendMessage(PluginConfig.getPrefix() + "§cPlease contact an administrator");
|
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();
|
File[] files = f.listFiles();
|
||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
@ -206,8 +206,9 @@ public class WorldSettingsCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (exampleworld.isDirectory())
|
File templateDirectory = new File(template.getPath());
|
||||||
FileUtils.copyDirectory(exampleworld, f);
|
if (templateDirectory.isDirectory())
|
||||||
|
FileUtils.copyDirectory(templateDirectory, f);
|
||||||
toConfirm.remove(p);
|
toConfirm.remove(p);
|
||||||
|
|
||||||
FileUtils.moveDirectoryToDirectory(f, Bukkit.getWorldContainer(), false);
|
FileUtils.moveDirectoryToDirectory(f, Bukkit.getWorldContainer(), false);
|
||||||
@ -219,7 +220,7 @@ public class WorldSettingsCommands {
|
|||||||
p.sendMessage(MessageConfig.getWorldReseted());
|
p.sendMessage(MessageConfig.getWorldReseted());
|
||||||
|
|
||||||
// For fast worldcreating after reset
|
// For fast worldcreating after reset
|
||||||
WorldCreator creator = new WorldCreator(worldname);
|
WorldCreator creator = template.getGeneratorSettings().asWorldCreator(worldname);
|
||||||
|
|
||||||
sw.setCreating(true);
|
sw.setCreating(true);
|
||||||
// For #16
|
// For #16
|
||||||
|
@ -253,7 +253,7 @@ public class SystemWorld {
|
|||||||
int id = DependenceConfig.getHighestID() + 1;
|
int id = DependenceConfig.getHighestID() + 1;
|
||||||
String worldname = "ID" + id + "-" + uuid;
|
String worldname = "ID" + id + "-" + uuid;
|
||||||
|
|
||||||
WorldCreator creator = PluginConfig.getWorldCreator(worldname);
|
WorldCreator creator = template.getGeneratorSettings().asWorldCreator(worldname);
|
||||||
|
|
||||||
WorldCreateEvent event = new WorldCreateEvent(p, creator);
|
WorldCreateEvent event = new WorldCreateEvent(p, creator);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
@ -2,11 +2,13 @@ package de.butzlabben.world.wrapper;
|
|||||||
|
|
||||||
import de.butzlabben.inventory.OrcItem;
|
import de.butzlabben.inventory.OrcItem;
|
||||||
import de.butzlabben.world.config.GuiConfig;
|
import de.butzlabben.world.config.GuiConfig;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Butzlabben
|
* @author Butzlabben
|
||||||
* @since 15.12.2018
|
* @since 15.12.2018
|
||||||
*/
|
*/
|
||||||
|
@Getter
|
||||||
public class WorldTemplate {
|
public class WorldTemplate {
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
Loading…
Reference in New Issue
Block a user