Skip to content

Commit

Permalink
feat: add PlayerProfile class
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-vincent committed Nov 17, 2024
1 parent 27b2756 commit aea1eea
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 3 deletions.
6 changes: 3 additions & 3 deletions include/endstone/ban/ban_entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@

#pragma once

#pragma once

#include <string>
#include <memory>
#include <optional>
#include <chrono>

namespace endstone{
/**
* @brief A single entry from a ban list. This may represent either a player ban or an IP ban.
*
Expand Down Expand Up @@ -116,4 +115,5 @@ class BanEntry {
* @brief Removes this ban entry from the appropriate ban list.
*/
virtual void remove() = 0;
};
};
}
61 changes: 61 additions & 0 deletions include/endstone/profile/player_profile.h
Original file line number Diff line number Diff line change
@@ -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 <string>
#include <memory>
#include <future>
#include <optional>
#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<UUID> getUniqueId() const = 0;

/**
* @brief Gets the player name.
*
* @return the player name, or std::nullopt if not available
*/
virtual std::optional<std::string> 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<std::string> 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;
};
}

0 comments on commit aea1eea

Please sign in to comment.