mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-27 10:59:14 +00:00
fix: check if backpack armorstand is a valid entity before update
This commit is contained in:
@@ -3,6 +3,7 @@ package com.hibiscusmc.hmccosmetics.cosmetic.types;
|
||||
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;
|
||||
@@ -10,6 +11,8 @@ 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;
|
||||
@@ -30,6 +33,11 @@ public class CosmeticBackpackType extends Cosmetic {
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user