mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Fix regen. Fixes #2692
This commit is contained in:
parent
6be26e8047
commit
b99631f1bd
@ -646,7 +646,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
}
|
}
|
||||||
return new BukkitPlotGenerator(world, gen);
|
return new BukkitPlotGenerator(world, gen);
|
||||||
} else {
|
} else {
|
||||||
return new BukkitPlotGenerator(PlotSquared.get().IMP.getDefaultGenerator());
|
return new BukkitPlotGenerator(world, PlotSquared.get().IMP.getDefaultGenerator());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -802,7 +802,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
|
|
||||||
@Override public GeneratorWrapper<?> wrapPlotGenerator(@Nullable final String world,
|
@Override public GeneratorWrapper<?> wrapPlotGenerator(@Nullable final String world,
|
||||||
@NonNull final IndependentPlotGenerator generator) {
|
@NonNull final IndependentPlotGenerator generator) {
|
||||||
return new BukkitPlotGenerator(generator);
|
return new BukkitPlotGenerator(world, generator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public List<Map.Entry<Map.Entry<String, String>, Boolean>> getPluginIds() {
|
@Override public List<Map.Entry<Map.Entry<String, String>, Boolean>> getPluginIds() {
|
||||||
|
@ -12,6 +12,7 @@ import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
|
import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
|
import lombok.Getter;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.generator.BlockPopulator;
|
import org.bukkit.generator.BlockPopulator;
|
||||||
@ -34,10 +35,13 @@ public class BukkitPlotGenerator extends ChunkGenerator
|
|||||||
private List<BlockPopulator> populators;
|
private List<BlockPopulator> populators;
|
||||||
private boolean loaded = false;
|
private boolean loaded = false;
|
||||||
|
|
||||||
public BukkitPlotGenerator(IndependentPlotGenerator generator) {
|
@Getter private final String levelName;
|
||||||
|
|
||||||
|
public BukkitPlotGenerator(String name, IndependentPlotGenerator generator) {
|
||||||
if (generator == null) {
|
if (generator == null) {
|
||||||
throw new IllegalArgumentException("Generator may not be null!");
|
throw new IllegalArgumentException("Generator may not be null!");
|
||||||
}
|
}
|
||||||
|
this.levelName = name;
|
||||||
this.plotGenerator = generator;
|
this.plotGenerator = generator;
|
||||||
this.platformGenerator = this;
|
this.platformGenerator = this;
|
||||||
this.populators = new ArrayList<>();
|
this.populators = new ArrayList<>();
|
||||||
@ -51,6 +55,7 @@ public class BukkitPlotGenerator extends ChunkGenerator
|
|||||||
throw new IllegalArgumentException("ChunkGenerator: " + cg.getClass().getName()
|
throw new IllegalArgumentException("ChunkGenerator: " + cg.getClass().getName()
|
||||||
+ " is already a BukkitPlotGenerator!");
|
+ " is already a BukkitPlotGenerator!");
|
||||||
}
|
}
|
||||||
|
this.levelName = world;
|
||||||
this.full = false;
|
this.full = false;
|
||||||
this.platformGenerator = cg;
|
this.platformGenerator = cg;
|
||||||
this.plotGenerator = new DelegatePlotGenerator(cg, world);
|
this.plotGenerator = new DelegatePlotGenerator(cg, world);
|
||||||
@ -172,6 +177,10 @@ public class BukkitPlotGenerator extends ChunkGenerator
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PlotArea area = PlotSquared.get().getPlotArea(world.getName(), null);
|
PlotArea area = PlotSquared.get().getPlotArea(world.getName(), null);
|
||||||
|
if (area == null && (area = PlotSquared.get().getPlotArea(this.levelName, null)) == null) {
|
||||||
|
throw new IllegalStateException("Cannot regenerate chunk that does not belong to a plot area."
|
||||||
|
+ " Location: " + loc + ", world: " + world);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
this.plotGenerator.generateChunk(result, area);
|
this.plotGenerator.generateChunk(result, area);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
|
@ -7,8 +7,10 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
|
import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class HybridGen extends IndependentPlotGenerator {
|
public class HybridGen extends IndependentPlotGenerator {
|
||||||
|
|
||||||
@ -34,7 +36,10 @@ public class HybridGen extends IndependentPlotGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void generateChunk(ScopedLocalBlockQueue result, PlotArea settings) {
|
@Override public void generateChunk(@NotNull ScopedLocalBlockQueue result, @NotNull PlotArea settings) {
|
||||||
|
Preconditions.checkNotNull(result, "result cannot be null");
|
||||||
|
Preconditions.checkNotNull(settings, "settings cannot be null");
|
||||||
|
|
||||||
HybridPlotWorld hpw = (HybridPlotWorld) settings;
|
HybridPlotWorld hpw = (HybridPlotWorld) settings;
|
||||||
// Biome
|
// Biome
|
||||||
result.fillBiome(hpw.PLOT_BIOME);
|
result.fillBiome(hpw.PLOT_BIOME);
|
||||||
|
@ -86,7 +86,7 @@ public class OperationUtil {
|
|||||||
return weWorld;
|
return weWorld;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static EditSession createEditSession(PlotPlayer plotPlayer) {
|
private static EditSession createEditSession(PlotPlayer plotPlayer) {
|
||||||
Actor actor = plotPlayer.toActor();
|
Actor actor = plotPlayer.toActor();
|
||||||
World weWorld = getWorld(plotPlayer, actor);
|
World weWorld = getWorld(plotPlayer, actor);
|
||||||
return createEditSession(weWorld, actor);
|
return createEditSession(weWorld, actor);
|
||||||
@ -100,7 +100,7 @@ public class OperationUtil {
|
|||||||
return createEditSession(world, actor, getSession(actor));
|
return createEditSession(world, actor, getSession(actor));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static EditSession createEditSession(World world, Actor actor, LocalSession session) {
|
private static EditSession createEditSession(World world, Actor actor, LocalSession session) {
|
||||||
EditSession editSession;
|
EditSession editSession;
|
||||||
Player player = actor.isPlayer() ? (Player) actor : null;
|
Player player = actor.isPlayer() ? (Player) actor : null;
|
||||||
editSession = WorldEdit.getInstance().getEditSessionFactory()
|
editSession = WorldEdit.getInstance().getEditSessionFactory()
|
||||||
|
Loading…
Reference in New Issue
Block a user