From 4c1d0bc9a6299a08929f78641c6e81b1009a7848 Mon Sep 17 00:00:00 2001 From: MattBDev <4009945+MattBDev@users.noreply.github.com> Date: Tue, 11 May 2021 20:01:11 -0400 Subject: [PATCH] Removed redundant null checks and fixed a potential file separator issue --- worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java | 2 +- .../boydti/fawe/object/io/FastByteArrayOutputStream.java | 8 +++----- .../com/sk89q/worldedit/extent/inventory/BlockBag.java | 5 ++--- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java b/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java index 30dedb3f0..09b7a9691 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java @@ -188,7 +188,7 @@ public class FaweAPI { if (!file.getName().toLowerCase(Locale.ROOT).endsWith(".bd")) { throw new IllegalArgumentException("Not a BD file!"); } - String[] path = file.getPath().split(File.separator); + String[] path = file.getPath().split(File.separatorChar=='\\' ? "\\\\" : File.separator); if (path.length < 3) { throw new IllegalArgumentException("Not in history directory!"); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/io/FastByteArrayOutputStream.java b/worldedit-core/src/main/java/com/boydti/fawe/object/io/FastByteArrayOutputStream.java index 05be47f90..ba5cb52d5 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/io/FastByteArrayOutputStream.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/io/FastByteArrayOutputStream.java @@ -77,11 +77,9 @@ public class FastByteArrayOutputStream extends OutputStream { // Check if we have a list of buffers int pos = 0; - if (buffers != null) { - for (byte[] bytes : buffers) { - System.arraycopy(bytes, 0, data, pos, bytes.length); - pos += bytes.length; - } + for (byte[] bytes : buffers) { + System.arraycopy(bytes, 0, data, pos, bytes.length); + pos += bytes.length; } // write the internal buffer directly diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBag.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBag.java index 5ca8aaabe..ff17d6a97 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBag.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBag.java @@ -59,12 +59,11 @@ public abstract class BlockBag { } fetchBlock(blockState); } catch (OutOfBlocksException e) { - BlockState placed = blockState; // TODO BlockType.getBlockBagItem(id, data); - if (placed == null || placed.getBlockType().getMaterial().isAir()) { + if (blockState.getBlockType().getMaterial().isAir()) { throw e; // TODO: check } - fetchBlock(placed); + fetchBlock(blockState); } }