fix null metadata happening
This commit is contained in:
parent
cf10f2da50
commit
243413dcce
3 changed files with 4 additions and 5 deletions
|
@ -10,6 +10,7 @@
|
||||||
<set>
|
<set>
|
||||||
<option value="$PROJECT_DIR$" />
|
<option value="$PROJECT_DIR$" />
|
||||||
<option value="$PROJECT_DIR$/test-plugin" />
|
<option value="$PROJECT_DIR$/test-plugin" />
|
||||||
|
<option value="$PROJECT_DIR$/wrapper-entity" />
|
||||||
</set>
|
</set>
|
||||||
</option>
|
</option>
|
||||||
</GradleProjectSettings>
|
</GradleProjectSettings>
|
||||||
|
|
|
@ -104,9 +104,6 @@ public final class EntityLib {
|
||||||
checkInit();
|
checkInit();
|
||||||
Metadata m = new Metadata(entityId);
|
Metadata m = new Metadata(entityId);
|
||||||
BiFunction<Integer, Metadata, EntityMeta> function = metaRegistry.get(entityType);
|
BiFunction<Integer, Metadata, EntityMeta> function = metaRegistry.get(entityType);
|
||||||
if (function == null) {
|
|
||||||
throw new IllegalArgumentException("No meta converter for entity type " + entityType);
|
|
||||||
}
|
|
||||||
EntityMeta meta = function.apply(entityId, m);
|
EntityMeta meta = function.apply(entityId, m);
|
||||||
metadata.put(entityId, meta);
|
metadata.put(entityId, meta);
|
||||||
return meta;
|
return meta;
|
||||||
|
|
|
@ -30,6 +30,7 @@ import me.tofaa.entitylib.meta.mobs.villager.VillagerMeta;
|
||||||
import me.tofaa.entitylib.meta.mobs.villager.WanderingTraderMeta;
|
import me.tofaa.entitylib.meta.mobs.villager.WanderingTraderMeta;
|
||||||
import me.tofaa.entitylib.meta.projectile.*;
|
import me.tofaa.entitylib.meta.projectile.*;
|
||||||
import me.tofaa.entitylib.meta.types.PlayerMeta;
|
import me.tofaa.entitylib.meta.types.PlayerMeta;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -159,8 +160,8 @@ final class MetaConverterRegistry {
|
||||||
return (Class<T>) metaClasses.get(entityType);
|
return (Class<T>) metaClasses.get(entityType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable BiFunction<Integer, Metadata, EntityMeta> get(EntityType entityType) {
|
public @NotNull BiFunction<Integer, Metadata, EntityMeta> get(EntityType entityType) {
|
||||||
return converters.get(entityType);
|
return converters.getOrDefault(entityType, EntityMeta::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue