diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java index 1f9bff3ec..3a6d64f38 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java @@ -599,17 +599,18 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain setup.step = new ConfigurationNode[0]; setup.world = worldName; SetupUtils.manager.setupWorld(setup); + world = Bukkit.getWorld(worldName); } else { try { if (!PS.get().hasPlotArea(worldName)) { SetGenCB.setGenerator(BukkitUtil.getWorld(worldName)); } } catch (Exception ignored) { - PS.log("Failed to reload world: " + world); + PS.log("Failed to reload world: " + world + " | " + ignored.getMessage()); Bukkit.getServer().unloadWorld(world, false); + return; } } - world = Bukkit.getWorld(worldName); ChunkGenerator gen = world.getGenerator(); if (gen instanceof BukkitPlotGenerator) { PS.get().loadWorld(worldName, (BukkitPlotGenerator) gen); diff --git a/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java b/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java index 3e18a0bf9..90b3cd08d 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java @@ -171,10 +171,7 @@ public class SpongeMain implements IPlotMain { @Override public int[] getPluginVersion() { String ver = this.plugin.getVersion().orElse(""); - if (ver.contains("-")) { - ver = ver.split("-")[0]; - } - String[] split = ver.split("\\."); + String[] split = ver.split("[\\.|-]"); return new int[]{Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])}; } @@ -331,10 +328,10 @@ public class SpongeMain implements IPlotMain { } WorldGenerator wg = world.getWorldGenerator(); GenerationPopulator gen = wg.getBaseGenerationPopulator(); - if (gen instanceof SpongePlotGenerator) { - PS.get().loadWorld(worldName, (SpongePlotGenerator) gen); + if (gen instanceof GeneratorWrapper) { + PS.get().loadWorld(worldName, (GeneratorWrapper) gen); } else { - throw new UnsupportedOperationException("NOT IMPLEMENTED YET! " + worldName + " | " + gen); + throw new UnsupportedOperationException("NOT IMPLEMENTED YET2! " + worldName + " | " + gen); } } diff --git a/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongePlotGenerator.java b/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongePlotGenerator.java index 47e0e2a7b..3233905ee 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongePlotGenerator.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongePlotGenerator.java @@ -71,7 +71,7 @@ public class SpongePlotGenerator implements WorldGeneratorModifier, GeneratorWra @Override public void modifyWorldGenerator(WorldProperties world, DataContainer settings, WorldGenerator worldGenerator) { String worldName = world.getWorldName(); - worldGenerator.setBaseGenerationPopulator(new SpongeTerrainGen(this, this.plotGenerator)); + worldGenerator.setBaseGenerationPopulator(new SpongeTerrainGen(this.plotGenerator)); worldGenerator.setBiomeGenerator(new BiomeGenerator() { @Override public void generateBiomes(MutableBiomeArea buffer) { diff --git a/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongeTerrainGen.java b/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongeTerrainGen.java index b1ca84ce6..e9475d8d4 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongeTerrainGen.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongeTerrainGen.java @@ -2,30 +2,47 @@ package com.plotsquared.sponge.generator; import com.flowpowered.math.vector.Vector3i; import com.intellectualcrafters.plot.PS; +import com.intellectualcrafters.plot.generator.GeneratorWrapper; import com.intellectualcrafters.plot.generator.IndependentPlotGenerator; import com.intellectualcrafters.plot.object.ChunkWrapper; import com.intellectualcrafters.plot.object.PlotArea; import com.intellectualcrafters.plot.object.PseudoRandom; import com.intellectualcrafters.plot.util.ChunkManager; +import com.intellectualcrafters.plot.util.MainUtil; +import com.plotsquared.sponge.util.SpongeUtil; import com.plotsquared.sponge.util.block.GenChunk; import org.spongepowered.api.world.World; import org.spongepowered.api.world.extent.ImmutableBiomeArea; import org.spongepowered.api.world.extent.MutableBlockVolume; import org.spongepowered.api.world.gen.GenerationPopulator; -public class SpongeTerrainGen implements GenerationPopulator { +public class SpongeTerrainGen implements GenerationPopulator, GeneratorWrapper { - public final SpongePlotGenerator parent; public final IndependentPlotGenerator child; + private final boolean full; + private final GenerationPopulator platformGenerator; private final PseudoRandom random = new PseudoRandom(); - public SpongeTerrainGen(SpongePlotGenerator parent, IndependentPlotGenerator ipg) { - this.parent = parent; + public SpongeTerrainGen(IndependentPlotGenerator ipg) { this.child = ipg; + this.full = true; + this.platformGenerator = this; + MainUtil.initCache(); + } + + public SpongeTerrainGen(GenerationPopulator populator) { + this.child = null; + this.platformGenerator = populator; + this.full = false; + MainUtil.initCache(); } @Override public void populate(World world, MutableBlockVolume terrain, ImmutableBiomeArea biomes) { + if (platformGenerator != this) { + platformGenerator.populate(world, terrain, biomes); + return; + } Vector3i size = terrain.getBlockSize(); if (size.getX() != 16 || size.getZ() != 16) { throw new UnsupportedOperationException("NON CHUNK POPULATION NOT SUPPORTED"); @@ -57,4 +74,24 @@ public class SpongeTerrainGen implements GenerationPopulator { e.printStackTrace(); } } + + @Override + public IndependentPlotGenerator getPlotGenerator() { + return child; + } + + @Override + public GenerationPopulator getPlatformGenerator() { + return platformGenerator; + } + + @Override + public void augment(PlotArea area) { + SpongeAugmentedGenerator.get(SpongeUtil.getWorld(area.worldname)); + } + + @Override + public boolean isFull() { + return this.full; + } } diff --git a/Sponge/src/main/java/com/plotsquared/sponge/listener/WorldEvents.java b/Sponge/src/main/java/com/plotsquared/sponge/listener/WorldEvents.java index 1ce7014c3..9fcdc73c4 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/listener/WorldEvents.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/listener/WorldEvents.java @@ -1,14 +1,13 @@ package com.plotsquared.sponge.listener; +import com.intellectualcrafters.plot.PS; +import com.intellectualcrafters.plot.generator.GeneratorWrapper; import org.spongepowered.api.event.Listener; import org.spongepowered.api.event.world.LoadWorldEvent; import org.spongepowered.api.world.World; import org.spongepowered.api.world.gen.GenerationPopulator; import org.spongepowered.api.world.gen.WorldGenerator; -import com.intellectualcrafters.plot.PS; -import com.plotsquared.sponge.generator.SpongeTerrainGen; - public class WorldEvents { @Listener @@ -17,9 +16,9 @@ public class WorldEvents { final String name = world.getName(); WorldGenerator generator = world.getWorldGenerator(); GenerationPopulator terrain = generator.getBaseGenerationPopulator(); - if (terrain instanceof SpongeTerrainGen) { - SpongeTerrainGen stg = (SpongeTerrainGen) terrain; - PS.get().loadWorld(name, stg.parent); + if (terrain instanceof GeneratorWrapper) { + GeneratorWrapper stg = (GeneratorWrapper) terrain; + PS.get().loadWorld(name, stg); } else { PS.get().loadWorld(name, null);