9
0
mirror of https://github.com/HibiscusMC/HibiscusCommons.git synced 2025-12-19 15:09:26 +00:00

fix: check if vanished is empty before getting boolean

This commit is contained in:
lojosho
2025-05-01 18:02:18 -05:00
parent 2c4894c35c
commit 08dbf79d77

View File

@@ -14,6 +14,7 @@ import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.MetadataValue;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@@ -169,6 +170,8 @@ public class Hooks {
} }
public static boolean isInvisible(@NotNull Player player) { public static boolean isInvisible(@NotNull Player player) {
return player.getMetadata("vanished").getFirst().asBoolean(); List<MetadataValue> metadataValues = player.getMetadata("vanished");
if (metadataValues.isEmpty()) return false;
return metadataValues.getFirst().asBoolean();
} }
} }