From 0ef8b4ad1416234979c4e387d4a7d2db7ce4b064 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Wed, 20 Feb 2019 11:55:39 +0000 Subject: [PATCH 1/3] Update to WorldEdit's *breaking* Biome handling changes --- .../plotsquared/plot/listener/ProcessedWEExtent.java | 4 ++-- .../intellectualsites/plotsquared/plot/listener/WEExtent.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/listener/ProcessedWEExtent.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/listener/ProcessedWEExtent.java index 431c2c378..d7ebf1c86 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/listener/ProcessedWEExtent.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/listener/ProcessedWEExtent.java @@ -13,7 +13,7 @@ import com.sk89q.worldedit.extent.NullExtent; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.util.Location; -import com.sk89q.worldedit.world.biome.BaseBiome; +import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; @@ -171,7 +171,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent { return null; } - @Override public boolean setBiome(BlockVector2 position, BaseBiome biome) { + @Override public boolean setBiome(BlockVector2 position, BiomeType biome) { return WEManager.maskContains(this.mask, position.getX(), position.getZ()) && super .setBiome(position, biome); } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/listener/WEExtent.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/listener/WEExtent.java index ac0503886..073819fa3 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/listener/WEExtent.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/listener/WEExtent.java @@ -9,7 +9,7 @@ import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.util.Location; -import com.sk89q.worldedit.world.biome.BaseBiome; +import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; @@ -42,7 +42,7 @@ public class WEExtent extends AbstractDelegateExtent { return null; } - @Override public boolean setBiome(BlockVector2 position, BaseBiome biome) { + @Override public boolean setBiome(BlockVector2 position, BiomeType biome) { return WEManager.maskContains(this.mask, position.getX(), position.getZ()) && super .setBiome(position, biome); } From 72b031e3e50f24286350f7f9156311aaeb65d062 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Wed, 20 Feb 2019 11:59:39 +0000 Subject: [PATCH 2/3] Update offset to match CI --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 388b6406d..699a14d3d 100644 --- a/build.gradle +++ b/build.gradle @@ -32,7 +32,7 @@ ext { date = git.head().getDate().format("yy.MM.dd") revision = "-${git.head().abbreviatedId}" parents = git.head().parentIds; - index = -2044; // Offset to match CI + index = -2042; // Offset to match CI for (; parents != null && !parents.isEmpty(); index++) { parents = git.getResolve().toCommit(parents.get(0)).getParentIds() } From 350e1512149032b2fe4dc634697fb42500475306 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Wed, 20 Feb 2019 14:50:49 +0000 Subject: [PATCH 3/3] Don't use streams as they're lower performance for our use cases. Some minor reformating too. --- .../plotsquared/bukkit/util/NbtFactory.java | 7 +++++-- .../intellectualsites/plotsquared/commands/Argument.java | 8 ++++---- .../plotsquared/plot/commands/Owner.java | 4 ++-- .../plotsquared/plot/object/Direction.java | 3 +-- .../intellectualsites/plotsquared/plot/object/Plot.java | 4 ++-- .../plotsquared/plot/util/ArrayUtil.java | 4 +++- 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/NbtFactory.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/NbtFactory.java index 6a9017cf8..acf0f82fa 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/NbtFactory.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/NbtFactory.java @@ -154,7 +154,8 @@ public class NbtFactory { * @return The decoded NBT compound. * @throws IOException If anything went wrong. */ - @SuppressWarnings({"IOResourceOpenedButNotSafelyClosed", "resource"}) public static NbtCompound fromStream(InputStream input, StreamOptions option) + @SuppressWarnings({"IOResourceOpenedButNotSafelyClosed", "resource"}) + public static NbtCompound fromStream(InputStream input, StreamOptions option) throws IOException { DataInputStream data = null; boolean suppress = true; @@ -527,7 +528,9 @@ public class NbtFactory { * * @author Kristian */ - public enum StreamOptions {NO_COMPRESSION, GZIP_COMPRESSION,} + public enum StreamOptions { + NO_COMPRESSION, GZIP_COMPRESSION, + } private enum NbtType { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/commands/Argument.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/commands/Argument.java index bcd2932af..dd5221a3a 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/commands/Argument.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/commands/Argument.java @@ -2,8 +2,6 @@ package com.github.intellectualsites.plotsquared.commands; import com.github.intellectualsites.plotsquared.plot.object.PlotId; -import java.util.stream.Stream; - public abstract class Argument { public static final Argument Integer = new Argument("int", 16) { @@ -19,9 +17,11 @@ public abstract class Argument { public static final Argument Boolean = new Argument("boolean", true) { @Override public Boolean parse(String in) { Boolean value = null; - if (Stream.of("true", "Yes", "1").anyMatch(in::equalsIgnoreCase)) { + if (in.equalsIgnoreCase("true") || in.equalsIgnoreCase("Yes") || in + .equalsIgnoreCase("1")) { value = true; - } else if (Stream.of("false", "No", "0").anyMatch(in::equalsIgnoreCase)) { + } else if (in.equalsIgnoreCase("false") || in.equalsIgnoreCase("No") || in + .equalsIgnoreCase("0")) { value = false; } return value; diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Owner.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Owner.java index 2ef7ece5b..4095c15c9 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Owner.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Owner.java @@ -9,7 +9,6 @@ import com.github.intellectualsites.plotsquared.plot.util.*; import java.util.Set; import java.util.UUID; -import java.util.stream.Stream; @CommandDeclaration(command = "setowner", permission = "plots.set.owner", description = "Set the plot owner", usage = "/plot setowner ", @@ -32,7 +31,8 @@ import java.util.stream.Stream; name = name == null ? value : name; } if (uuid == null || value.equalsIgnoreCase("-")) { - if (Stream.of("none", "null", "-").anyMatch(value::equalsIgnoreCase)) { + if (value.equalsIgnoreCase("none") || value.equalsIgnoreCase("null") || value + .equalsIgnoreCase("-")) { if (!Permissions .hasPermission(player, C.PERMISSION_ADMIN_COMMAND_SETOWNER.s(), true)) { return false; diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Direction.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Direction.java index 0c7de4905..9ce6e1621 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Direction.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Direction.java @@ -3,8 +3,7 @@ package com.github.intellectualsites.plotsquared.plot.object; public enum Direction { NORTH(0, "north"), EAST(1, "east"), SOUTH(2, "south"), WEST(3, "west"), NORTHEAST(4, "northeast"), SOUTHEAST(5, "southeast"), SOUTHWEST(6, "southwest"), NORTHWEST(7, - "northwest"), - ; + "northwest"),; private int index; diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java index 15954f8a3..ce1798c3a 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java @@ -33,7 +33,6 @@ import java.util.*; import java.util.Map.Entry; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; -import java.util.stream.IntStream; /** * The plot class
@@ -516,7 +515,8 @@ public class Plot { * @return true if this plot is merged, otherwise false */ public boolean isMerged() { - return IntStream.of(0, 2, 1, 3).anyMatch(i -> getSettings().getMerged(i)); + return getSettings().getMerged(0) || getSettings().getMerged(2) || getSettings() + .getMerged(1) || getSettings().getMerged(3); } /** diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/ArrayUtil.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/ArrayUtil.java index e902faffd..6052c2a93 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/ArrayUtil.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/ArrayUtil.java @@ -5,7 +5,9 @@ import java.util.Arrays; public class ArrayUtil { public static final T[] concatAll(T[] first, T[]... rest) { int totalLength = first.length; - totalLength += Arrays.stream(rest).mapToInt(array -> array.length).sum(); + for (T[] array : rest) { + totalLength += array.length; + } T[] result = Arrays.copyOf(first, totalLength); int offset = first.length; for (T[] array : rest) {