mirror of
https://github.com/Minestom/Minestom.git
synced 2025-03-13 07:09:51 +01:00
Add Supplier instead of direct reference and fix a @NotNull error.
This commit is contained in:
parent
b31f76615a
commit
674c6d6182
@ -5,9 +5,11 @@ import net.minestom.server.map.MapColors;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
class BlockDataImpl implements BlockData {
|
||||
private final double explosionResistance;
|
||||
private final @NotNull Material item;
|
||||
private final @NotNull Supplier<@NotNull Material> item;
|
||||
private final double friction;
|
||||
private final double speedFactor;
|
||||
private final double jumpFactor;
|
||||
@ -30,7 +32,7 @@ class BlockDataImpl implements BlockData {
|
||||
|
||||
BlockDataImpl(
|
||||
double explosionResistance,
|
||||
@NotNull Material item,
|
||||
@NotNull Supplier<@NotNull Material> item,
|
||||
double friction,
|
||||
double speedFactor,
|
||||
double jumpFactor,
|
||||
@ -78,7 +80,7 @@ class BlockDataImpl implements BlockData {
|
||||
|
||||
@Override
|
||||
public @Nullable Material getCorrespondingItem() {
|
||||
return item;
|
||||
return item.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -251,7 +251,8 @@ class BlockImpl implements Block {
|
||||
double speedFactor = block.get("speedFactor").getAsDouble();
|
||||
double jumpFactor = block.get("jumpFactor").getAsDouble();
|
||||
boolean blockEntity = block.get("blockEntity").getAsBoolean();
|
||||
Material item = Registries.getMaterial(block.get("itemId").getAsString());
|
||||
final String blockId = block.get("itemId").getAsString();
|
||||
java.util.function.Supplier<Material> itemSupplier = () -> Registries.getMaterial(blockId);
|
||||
JsonArray states = block.get("states").getAsJsonArray();
|
||||
for (JsonElement stateEntry : states) {
|
||||
// Load Data
|
||||
@ -262,7 +263,7 @@ class BlockImpl implements Block {
|
||||
stateId,
|
||||
new BlockDataImpl(
|
||||
explosionResistance,
|
||||
item,
|
||||
itemSupplier,
|
||||
friction,
|
||||
speedFactor,
|
||||
jumpFactor,
|
||||
|
@ -25,7 +25,7 @@ public enum ChatPosition {
|
||||
|
||||
private final MessageType messageType;
|
||||
|
||||
ChatPosition(@NotNull MessageType messageType) {
|
||||
ChatPosition(@Nullable MessageType messageType) {
|
||||
this.messageType = messageType;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user