mirror of
https://github.com/Minestom/Minestom.git
synced 2024-11-07 19:31:37 +01:00
Unnecessary null check
This commit is contained in:
parent
4ab2f43eed
commit
03cf585121
@ -202,9 +202,8 @@ record BlockImpl(@NotNull Registry.BlockEntry registry,
|
||||
|
||||
private Block compute(byte[] properties) {
|
||||
if (Arrays.equals(propertiesArray, properties)) return this;
|
||||
BlockImpl block = possibleProperties().get(new PropertiesHolder(properties));
|
||||
if (block == null)
|
||||
throw new IllegalArgumentException("Invalid properties: " + Arrays.toString(properties) + " for block " + this);
|
||||
final BlockImpl block = possibleProperties().get(new PropertiesHolder(properties));
|
||||
assert block != null;
|
||||
return nbt == null && handler == null ? block : new BlockImpl(block.registry(), block.propertiesArray, nbt, handler);
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ public class BlockTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProperty() {
|
||||
public void validProperties() {
|
||||
Block block = Block.CHEST;
|
||||
assertEquals(block.properties(), Objects.requireNonNull(Block.fromBlockId(block.id())).properties());
|
||||
|
||||
@ -48,8 +48,13 @@ public class BlockTest {
|
||||
|
||||
assertEquals(block.withProperty("facing", "north").getProperty("facing"), "north");
|
||||
assertNotEquals(block.withProperty("facing", "north"), block.withProperty("facing", "south"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void invalidProperties() {
|
||||
Block block = Block.CHEST;
|
||||
assertThrows(Exception.class, () -> block.withProperty("random", "randomKey"));
|
||||
assertThrows(Exception.class, () -> block.withProperties(Map.of("random", "randomKey")));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user