Skip to content

Commit e173e4d

Browse files
committed
fix: resolve nullability issues in EntityUtil
1 parent f92819c commit e173e4d

File tree

1 file changed

+4
-4
lines changed
  • PacketWrapper/src/main/java/com/comphenix/packetwrapper/util

1 file changed

+4
-4
lines changed

PacketWrapper/src/main/java/com/comphenix/packetwrapper/util/EntityUtil.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
public final class EntityUtil {
1515

1616
private static final int MINOR_VERSION;
17-
private static final Map<EntityType, Integer> ENTITY_TYPE_IDS;
18-
private static final Map<Integer, EntityType> ENTITY_TYPES;
17+
private static final Map<@NotNull EntityType, @NotNull Integer> ENTITY_TYPE_IDS;
18+
private static final Map<@NotNull Integer, @NotNull EntityType> ENTITY_TYPES;
1919

2020
static {
2121
{
@@ -50,8 +50,6 @@ public final class EntityUtil {
5050

5151
ENTITY_TYPES = ENTITY_TYPE_IDS.entrySet().stream()
5252
.collect(Collectors.toMap(Map.Entry::getValue, Map.Entry::getKey));
53-
54-
ENTITY_TYPE_IDS.put(null, -1);
5553
}
5654

5755
private EntityUtil() {
@@ -67,6 +65,8 @@ private EntityUtil() {
6765
* @return type ID of the given entity type
6866
*/
6967
public static int getTypeId(final EntityType entityType) {
68+
if (entityType == null) return -1;
69+
7070
return ENTITY_TYPE_IDS.get(entityType); // the value is always present
7171
}
7272

0 commit comments

Comments
 (0)