mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 07:06:44 +01:00
Fixed template creation
This commit is contained in:
parent
b0384f4074
commit
93e6a2d87c
@ -8,7 +8,7 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<artifactId>PlotSquared</artifactId>
|
||||
<version>2.9.2</version>
|
||||
<version>2.9.3</version>
|
||||
<name>PlotSquared</name>
|
||||
<packaging>jar</packaging>
|
||||
<build>
|
||||
|
@ -178,6 +178,10 @@ public class Template extends SubCommand {
|
||||
public static byte[] getBytes(PlotWorld plotworld) {
|
||||
ConfigurationSection section = PlotSquared.config.getConfigurationSection("worlds." + plotworld.worldname);
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
String generator = SetupUtils.manager.getGenerator(plotworld);
|
||||
if (generator != null) {
|
||||
config.set("generator.plugin", generator);
|
||||
}
|
||||
for (String key : section.getKeys(true)) {
|
||||
config.set(key, section.get(key));
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.intellectualcrafters.plot.object.PlotGenerator;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.SetupObject;
|
||||
|
||||
public abstract class SetupUtils {
|
||||
@ -15,5 +16,7 @@ public abstract class SetupUtils {
|
||||
|
||||
public abstract void updateGenerators();
|
||||
|
||||
public abstract String getGenerator(PlotWorld plotworld);
|
||||
|
||||
public abstract String setupWorld(final SetupObject object);
|
||||
}
|
||||
|
@ -1,11 +1,14 @@
|
||||
package com.intellectualcrafters.plot.util.bukkit;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
@ -13,6 +16,7 @@ import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
||||
import com.intellectualcrafters.plot.generator.SquarePlotManager;
|
||||
import com.intellectualcrafters.plot.object.PlotGenerator;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.SetupObject;
|
||||
import com.intellectualcrafters.plot.util.SetupUtils;
|
||||
|
||||
@ -85,4 +89,24 @@ public class BukkitSetupUtils extends SetupUtils {
|
||||
return object.world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGenerator(PlotWorld plotworld) {
|
||||
if (SetupUtils.generators.size() == 0) {
|
||||
updateGenerators();
|
||||
}
|
||||
World world = Bukkit.getWorld(plotworld.worldname);
|
||||
if (world == null) {
|
||||
return null;
|
||||
}
|
||||
ChunkGenerator generator = world.getGenerator();
|
||||
if (!(generator instanceof PlotGenerator)) {
|
||||
return null;
|
||||
}
|
||||
for (Entry<String, PlotGenerator> entry : generators.entrySet()) {
|
||||
if (entry.getValue().getClass().getName().equals(generator.getClass().getName())) {
|
||||
return entry.getKey();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user