mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 22:56:45 +01:00
Optimize vanilla world generation*
*For single plot worlds Reuse base world data. Instead of taking several seconds, it should now take tens of milliseconds.
This commit is contained in:
parent
27eda9eb7c
commit
7e63ffe745
@ -123,15 +123,16 @@ public class BukkitSetupUtils extends SetupUtils {
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
if (!object.plotManager.endsWith(":single")) {
|
||||
if (!PlotSquared.get().worlds.contains(worldPath)) {
|
||||
PlotSquared.get().worlds.createSection(worldPath);
|
||||
}
|
||||
ConfigurationSection worldSection =
|
||||
PlotSquared.get().worlds.getConfigurationSection(worldPath);
|
||||
if (steps.length != 0) {
|
||||
ConfigurationSection worldSection = PlotSquared.get().worlds.getConfigurationSection(worldPath);
|
||||
for (ConfigurationNode step : steps) {
|
||||
worldSection.set(step.getConstant(), step.getValue());
|
||||
}
|
||||
if (!object.plotManager.endsWith(":single")) {
|
||||
}
|
||||
PlotSquared.get().worlds.set("worlds." + world + ".generator.type", object.type);
|
||||
PlotSquared.get().worlds.set("worlds." + world + ".generator.terrain", object.terrain);
|
||||
PlotSquared.get().worlds.set("worlds." + world + ".generator.plugin", object.plotManager);
|
||||
|
@ -1,16 +1,26 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.object.worlds;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.configuration.ConfigurationSection;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Configuration;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.ConfigurationNode;
|
||||
import com.github.intellectualsites.plotsquared.plot.generator.GridPlotWorld;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotLoc;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotSettings;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.SetupObject;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.SetupUtils;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
||||
public class SinglePlotArea extends GridPlotWorld {
|
||||
|
||||
@ -26,9 +36,12 @@ public class SinglePlotArea extends GridPlotWorld {
|
||||
VOID = config.getBoolean("void", false);
|
||||
}
|
||||
|
||||
@Override public void saveConfiguration(ConfigurationSection config) {
|
||||
new Exception().printStackTrace();
|
||||
super.saveConfiguration(config);
|
||||
}
|
||||
|
||||
public void loadWorld(final PlotId id) {
|
||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||
@Override public void run(Object value) {
|
||||
String worldName = id.toCommaSeparatedString();
|
||||
if (WorldUtil.IMP.isWorld(worldName)) {
|
||||
return;
|
||||
@ -40,6 +53,44 @@ public class SinglePlotArea extends GridPlotWorld {
|
||||
setup.terrain = TERRAIN;
|
||||
setup.step = new ConfigurationNode[0];
|
||||
setup.world = worldName;
|
||||
|
||||
// Duplicate 0;0
|
||||
if (setup.type != 0) {
|
||||
File container = PlotSquared.imp().getWorldContainer();
|
||||
File dest = new File(container, worldName);
|
||||
if (!dest.exists()) {
|
||||
File src = new File(container, "0,0");
|
||||
if (src.exists()) {
|
||||
if (!dest.exists()) {
|
||||
dest.mkdirs();
|
||||
}
|
||||
File levelDat = new File(src, "level.dat");
|
||||
if (levelDat.exists()) {
|
||||
try {
|
||||
Files.copy(levelDat.toPath(), new File(dest, levelDat.getName()).toPath());
|
||||
File data = new File(src, "data");
|
||||
if (data.exists()) {
|
||||
File dataDest = new File(dest, "data");
|
||||
dataDest.mkdirs();
|
||||
for (File file : data.listFiles()) {
|
||||
Files.copy(file.toPath(), new File(dataDest, file.getName()).toPath());
|
||||
}
|
||||
}
|
||||
} catch (IOException ignore) {
|
||||
ignore.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||
@Override public void run(Object value) {
|
||||
String worldName = id.toCommaSeparatedString();
|
||||
if (WorldUtil.IMP.isWorld(worldName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
SetupUtils.manager.setupWorld(setup);
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user