diff --git a/LabApi/Features/Stores/CustomDataStore.cs b/LabApi/Features/Stores/CustomDataStore.cs index 8677c738..62f524e0 100644 --- a/LabApi/Features/Stores/CustomDataStore.cs +++ b/LabApi/Features/Stores/CustomDataStore.cs @@ -57,6 +57,23 @@ public static TStore GetOrAdd(Player player) return (TStore)store; } + /// + /// Checks if the for the specified exists. + /// + /// The to check the for. + /// The type of the + /// True if the exists for the specified , false if not. + public static bool Exists(Player player) + where TStore : CustomDataStore + { + Type type = typeof(TStore); + + if (!StoreInstances.TryGetValue(type, out Dictionary? playerStores)) + return false; + + return playerStores.ContainsKey(player); + } + /// /// Called when a new instance of the is created. /// @@ -133,4 +150,12 @@ protected CustomDataStore(Player owner) /// The to get the for. /// The for the specified . public static TStore Get(Player player) => GetOrAdd(player); + + /// + /// Checks if the for the specified exists. + /// + /// The to check the for. + /// The type of the + /// True if the exists for the specified , false if not. + public static bool Exists(Player player) => Exists(player); } \ No newline at end of file diff --git a/LabApi/Features/Wrappers/Players/Player.cs b/LabApi/Features/Wrappers/Players/Player.cs index 929cb526..e721f197 100644 --- a/LabApi/Features/Wrappers/Players/Player.cs +++ b/LabApi/Features/Wrappers/Players/Player.cs @@ -1504,6 +1504,17 @@ public TStore GetDataStore() return CustomDataStore.GetOrAdd(this); } + /// + /// Checks if the exists on the player. + /// + /// The type of the + /// True if the exists on the player, false if not. + public bool HasDataStore() + where TStore : CustomDataStore + { + return CustomDataStore.Exists(this); + } + /// /// Handles the creation of a player in the server. ///