diff --git a/api/src/main/java/org/geysermc/geyser/api/entity/data/GeyserEntityDataType.java b/api/src/main/java/org/geysermc/geyser/api/entity/data/GeyserEntityDataType.java index 3484f217b..c1c2e79d1 100644 --- a/api/src/main/java/org/geysermc/geyser/api/entity/data/GeyserEntityDataType.java +++ b/api/src/main/java/org/geysermc/geyser/api/entity/data/GeyserEntityDataType.java @@ -25,6 +25,7 @@ package org.geysermc.geyser.api.entity.data; +import org.checkerframework.checker.nullness.qual.NonNull; import org.geysermc.geyser.api.GeyserApi; import org.geysermc.geyser.api.entity.type.GeyserEntity; @@ -46,7 +47,7 @@ public interface GeyserEntityDataType { * * @return the class of the value used by this entity data type */ - Class typeClass(); + @NonNull Class typeClass(); /** * Gets the unique name of this data type. @@ -56,12 +57,12 @@ public interface GeyserEntityDataType { * * @return the name of this entity data type */ - String name(); + @NonNull String name(); /** * For API usage only; use the types defined in {@link GeyserEntityDataTypes} */ - static GeyserEntityDataType of(Class typeClass, String name) { + static GeyserEntityDataType of(@NonNull Class typeClass, @NonNull String name) { return GeyserApi.api().provider(GeyserEntityDataType.class, typeClass, name); } } diff --git a/api/src/main/java/org/geysermc/geyser/api/entity/data/GeyserListEntityDataType.java b/api/src/main/java/org/geysermc/geyser/api/entity/data/GeyserListEntityDataType.java index 655a87760..3cb948f01 100644 --- a/api/src/main/java/org/geysermc/geyser/api/entity/data/GeyserListEntityDataType.java +++ b/api/src/main/java/org/geysermc/geyser/api/entity/data/GeyserListEntityDataType.java @@ -25,24 +25,28 @@ package org.geysermc.geyser.api.entity.data; +import org.checkerframework.checker.nullness.qual.NonNull; import org.geysermc.geyser.api.GeyserApi; import java.util.List; /** - * Represents a list of objects for an entity data types - * For example, there can be multiple hitboxes on an entity + * Represents a list of objects for specific entity data types. + * For example, there can be multiple hitboxes on an entity. * - * @param + * @param the object type in the list */ public interface GeyserListEntityDataType extends GeyserEntityDataType> { - Class listTypeClass(); + /** + * @return the class of the list entries + */ + @NonNull Class listEntryClass(); /** * API usage only, use the types defined in {@link GeyserEntityDataTypes} */ - static GeyserListEntityDataType of(Class typeClass, String name) { + static GeyserListEntityDataType of(@NonNull Class typeClass, @NonNull String name) { return GeyserApi.api().provider(GeyserListEntityDataType.class, List.class, typeClass, name); } } diff --git a/api/src/main/java/org/geysermc/geyser/api/entity/data/types/Hitbox.java b/api/src/main/java/org/geysermc/geyser/api/entity/data/types/Hitbox.java index 46d284512..f7949eb97 100644 --- a/api/src/main/java/org/geysermc/geyser/api/entity/data/types/Hitbox.java +++ b/api/src/main/java/org/geysermc/geyser/api/entity/data/types/Hitbox.java @@ -25,6 +25,7 @@ package org.geysermc.geyser.api.entity.data.types; +import org.checkerframework.checker.nullness.qual.NonNull; import org.cloudburstmc.math.vector.Vector3f; import org.geysermc.geyser.api.GeyserApi; @@ -47,7 +48,7 @@ public interface Hitbox { /** * The pivot of the hitbox - * @return + * @return the pivot */ Vector3f pivot(); @@ -60,12 +61,33 @@ public interface Hitbox { */ interface Builder { - Builder min(Vector3f min); + /** + * Sets the min corner of the hitbox + * @param min the vector of the corner + * @return this builder + */ + Builder min(@NonNull Vector3f min); - Builder max(Vector3f max); + /** + * Sets the max corner of the hitbox + * @param max the vector of the corner + * @return this builder + */ + Builder max(@NonNull Vector3f max); - Builder origin(Vector3f pivot); + /** + * Sets the pivot of the hitbox + * @param pivot the pivot vector + * @return this builder + */ + Builder pivot(@NonNull Vector3f pivot); + /** + * Builds this hitbox, defaulting to {@code Vector3f.ZERO} if + * any one vector was not provided. + * + * @return a new hitbox + */ Hitbox build(); } } diff --git a/core/src/main/java/org/geysermc/geyser/impl/entity/GeyserEntityDataImpl.java b/core/src/main/java/org/geysermc/geyser/impl/entity/GeyserEntityDataImpl.java index a7c4ec075..e2e12e3fd 100644 --- a/core/src/main/java/org/geysermc/geyser/impl/entity/GeyserEntityDataImpl.java +++ b/core/src/main/java/org/geysermc/geyser/impl/entity/GeyserEntityDataImpl.java @@ -27,6 +27,7 @@ package org.geysermc.geyser.impl.entity; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import lombok.AllArgsConstructor; +import org.checkerframework.checker.nullness.qual.NonNull; import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataType; import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes; import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag; @@ -97,12 +98,12 @@ public class GeyserEntityDataImpl implements GeyserEntityDataType { } @Override - public Class typeClass() { + public @NonNull Class typeClass() { return typeClass; } @Override - public String name() { + public @NonNull String name() { return name; } diff --git a/core/src/main/java/org/geysermc/geyser/impl/entity/GeyserListEntityDataImpl.java b/core/src/main/java/org/geysermc/geyser/impl/entity/GeyserListEntityDataImpl.java index bb11baf64..0594a3aab 100644 --- a/core/src/main/java/org/geysermc/geyser/impl/entity/GeyserListEntityDataImpl.java +++ b/core/src/main/java/org/geysermc/geyser/impl/entity/GeyserListEntityDataImpl.java @@ -26,6 +26,7 @@ package org.geysermc.geyser.impl.entity; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; +import org.checkerframework.checker.nullness.qual.NonNull; import org.cloudburstmc.nbt.NbtMap; import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes; import org.geysermc.geyser.api.entity.data.GeyserListEntityDataType; @@ -57,7 +58,7 @@ public class GeyserListEntityDataImpl extends GeyserEntityDataImpl listTypeClass() { + public @NonNull Class listEntryClass() { return listTypeClass; } @@ -74,7 +75,7 @@ public class GeyserListEntityDataImpl extends GeyserEntityDataImpl