From aea1eea730b358f9b4dc4a80e9fa7e480de4f394 Mon Sep 17 00:00:00 2001 From: Vincent Date: Sun, 17 Nov 2024 15:26:24 +0000 Subject: [PATCH] feat: add PlayerProfile class --- include/endstone/ban/ban_entry.h | 6 +-- include/endstone/profile/player_profile.h | 61 +++++++++++++++++++++++ 2 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 include/endstone/profile/player_profile.h diff --git a/include/endstone/ban/ban_entry.h b/include/endstone/ban/ban_entry.h index 128bbf704..82e81dc0f 100644 --- a/include/endstone/ban/ban_entry.h +++ b/include/endstone/ban/ban_entry.h @@ -14,13 +14,12 @@ #pragma once -#pragma once - #include #include #include #include +namespace endstone{ /** * @brief A single entry from a ban list. This may represent either a player ban or an IP ban. * @@ -116,4 +115,5 @@ class BanEntry { * @brief Removes this ban entry from the appropriate ban list. */ virtual void remove() = 0; -}; \ No newline at end of file +}; +} diff --git a/include/endstone/profile/player_profile.h b/include/endstone/profile/player_profile.h new file mode 100644 index 000000000..63e15e666 --- /dev/null +++ b/include/endstone/profile/player_profile.h @@ -0,0 +1,61 @@ +// Copyright (c) 2024, The Endstone Project. (https://endstone.dev) All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include +#include +#include +#include +#include "endstone/util/uuid.h" + +namespace endstone{ +/** + * @brief A player profile. + */ +class PlayerProfile { +public: + virtual ~PlayerProfile() = default; + + /** + * @brief Gets the player's unique id. + * + * @return the player's unique id, or std::nullopt if not available + */ + virtual std::optional getUniqueId() const = 0; + + /** + * @brief Gets the player name. + * + * @return the player name, or std::nullopt if not available + */ + virtual std::optional getName() const = 0; + + /** + * @brief Gets the player's xbox user id (xuid). + * + * @return the player's xbox user id (xuid), or std::nullopt if not available + */ + virtual std::optional getXuid() const = 0; + + /** + * @brief Checks whether this profile is complete. + * + * A profile is currently considered complete if it has a name and a unique id. + * + * @return true if this profile is complete + */ + virtual bool isComplete() const = 0; +}; +} \ No newline at end of file