Skip to content

Commit

Permalink
Add null checks in EntityFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
OliverSchlueter committed Nov 21, 2024
1 parent 47db3a6 commit aee1593
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {

allprojects {
group = "de.oliver"
version = "0.0.11"
version = "0.0.12"
description = "Simple, lightweight and fast library for minecraft internals"

repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
public class EntityFactory {

public void spawnEntityFor(FS_RealPlayer player, FS_Entity entity) {
if (entity == null) {
return;
}

FancySitula.PACKET_FACTORY.createAddEntityPacket(
entity.getId(),
entity.getUuid(),
Expand All @@ -29,13 +33,21 @@ public void spawnEntityFor(FS_RealPlayer player, FS_Entity entity) {
}

public void despawnEntityFor(FS_RealPlayer player, FS_Entity entity) {
if (entity == null) {
return;
}

FancySitula.PACKET_FACTORY.createRemoveEntitiesPacket(
List.of(entity.getId())
)
.send(player);
}

public void setEntityDataFor(FS_RealPlayer player, FS_Entity entity) {
if (entity == null) {
return;
}

if (entity.getEntityData().isEmpty()) {
return;
}
Expand All @@ -47,6 +59,10 @@ public void setEntityDataFor(FS_RealPlayer player, FS_Entity entity) {
}

public void setEntityEquipmentFor(FS_RealPlayer player, FS_Player entity) {
if (entity == null) {
return;
}

FancySitula.PACKET_FACTORY.createSetEquipmentPacket(
entity.getId(),
entity.getEquipment()
Expand Down

0 comments on commit aee1593

Please sign in to comment.