Skip to content

Commit

Permalink
fix: check if backpack armorstand is a valid entity before update
Browse files Browse the repository at this point in the history
  • Loading branch information
LoJoSho committed Mar 12, 2023
1 parent 14bbd11 commit bf591e7
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.user.manager.UserBackpackManager;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.configurate.ConfigurationNode;

import java.util.logging.Level;

public class CosmeticBackpackType extends Cosmetic {

private final String modelName;
Expand All @@ -30,6 +33,11 @@ public void update(@NotNull CosmeticUser user) {
Location loc = player.getLocation().clone().add(0, 2, 0);

if (user.isInWardrobe() || !user.isBackpackSpawned()) return;
if (!user.getUserBackpackManager().getArmorStand().isValid()) {
MessagesUtil.sendDebugMessages("Invalid Backpack detected! Respawning backpack, report this on the discord if this happens often!", Level.WARNING);
user.respawnBackpack();
return;
}
if (loc.getWorld() != user.getUserBackpackManager().getArmorStand().getWorld()) {
user.getUserBackpackManager().getArmorStand().teleport(loc);
}
Expand Down

0 comments on commit bf591e7

Please sign in to comment.