From e39c7dfcde943c7cdb9cf4345cbe18d6b2483674 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20S=C3=B6derberg?= Date: Sun, 23 Feb 2020 21:10:01 +0100 Subject: [PATCH] Fix legacy converter. --- .../plotsquared/bukkit/util/block/GenChunk.java | 5 +++-- .../plotsquared/plot/object/BlockBucket.java | 2 +- .../plotsquared/plot/util/world/PatternUtil.java | 3 +++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/block/GenChunk.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/block/GenChunk.java index a039f7206..ec656d2ba 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/block/GenChunk.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/block/GenChunk.java @@ -7,6 +7,7 @@ import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.world.PatternUtil; +import com.google.common.base.Preconditions; import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.world.biome.BiomeType; @@ -20,9 +21,9 @@ import org.bukkit.World; import org.bukkit.block.Biome; import org.bukkit.generator.ChunkGenerator.BiomeGrid; import org.bukkit.generator.ChunkGenerator.ChunkData; +import org.jetbrains.annotations.NotNull; import java.util.Arrays; -import org.jetbrains.annotations.NotNull; public class GenChunk extends ScopedLocalBlockQueue { @@ -109,7 +110,7 @@ public class GenChunk extends ScopedLocalBlockQueue { } @Override public boolean setBlock(int x, int y, int z, @NotNull Pattern pattern) { - return setBlock(x, y, z, PatternUtil.apply(pattern, x, y, z)); + return setBlock(x, y, z, PatternUtil.apply(Preconditions.checkNotNull(pattern, "Pattern may not be null"), x, y, z)); } @Override public boolean setBlock(int x, int y, int z, BlockState id) { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/BlockBucket.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/BlockBucket.java index 138ac2d6c..670ca26d9 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/BlockBucket.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/BlockBucket.java @@ -78,7 +78,7 @@ public final class BlockBucket implements ConfigurationSerializable { private void addBlock(@NonNull final BlockState block, double chance) { if (chance == -1) chance = 1; String prefix = input.length() == 0 ? "" : ","; - input.append(prefix).append(chance).append("%").append(prefix); + input.append(prefix).append(chance).append("%").append(block.toString()); this.compiled = false; } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/world/PatternUtil.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/world/PatternUtil.java index d281cc4d8..ea3079bb6 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/world/PatternUtil.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/world/PatternUtil.java @@ -3,6 +3,7 @@ package com.github.intellectualsites.plotsquared.plot.util.world; import com.github.intellectualsites.plotsquared.commands.Command; import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; +import com.google.common.base.Preconditions; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.input.InputParseException; @@ -18,7 +19,9 @@ import com.sk89q.worldedit.world.block.BlockType; import org.jetbrains.annotations.NotNull; public class PatternUtil { + public static BaseBlock apply(@NotNull Pattern pattern, int x, int y, int z) { + Preconditions.checkNotNull(pattern, "Pattern may not be null"); if (pattern instanceof BlockPattern || pattern instanceof RandomPattern || pattern instanceof BlockState