mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 09:47:38 +00:00
Removed redundant null checks and fixed a potential file separator issue
This commit is contained in:
parent
277046d5c9
commit
4c1d0bc9a6
@ -188,7 +188,7 @@ public class FaweAPI {
|
|||||||
if (!file.getName().toLowerCase(Locale.ROOT).endsWith(".bd")) {
|
if (!file.getName().toLowerCase(Locale.ROOT).endsWith(".bd")) {
|
||||||
throw new IllegalArgumentException("Not a BD file!");
|
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) {
|
if (path.length < 3) {
|
||||||
throw new IllegalArgumentException("Not in history directory!");
|
throw new IllegalArgumentException("Not in history directory!");
|
||||||
}
|
}
|
||||||
|
@ -77,12 +77,10 @@ public class FastByteArrayOutputStream extends OutputStream {
|
|||||||
// Check if we have a list of buffers
|
// Check if we have a list of buffers
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
|
||||||
if (buffers != null) {
|
|
||||||
for (byte[] bytes : buffers) {
|
for (byte[] bytes : buffers) {
|
||||||
System.arraycopy(bytes, 0, data, pos, bytes.length);
|
System.arraycopy(bytes, 0, data, pos, bytes.length);
|
||||||
pos += bytes.length;
|
pos += bytes.length;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// write the internal buffer directly
|
// write the internal buffer directly
|
||||||
System.arraycopy(buffer, 0, data, pos, index);
|
System.arraycopy(buffer, 0, data, pos, index);
|
||||||
|
@ -59,12 +59,11 @@ public abstract class BlockBag {
|
|||||||
}
|
}
|
||||||
fetchBlock(blockState);
|
fetchBlock(blockState);
|
||||||
} catch (OutOfBlocksException e) {
|
} catch (OutOfBlocksException e) {
|
||||||
BlockState placed = blockState; // TODO BlockType.getBlockBagItem(id, data);
|
if (blockState.getBlockType().getMaterial().isAir()) {
|
||||||
if (placed == null || placed.getBlockType().getMaterial().isAir()) {
|
|
||||||
throw e; // TODO: check
|
throw e; // TODO: check
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchBlock(placed);
|
fetchBlock(blockState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user