Botcraft 26.1.2
Loading...
Searching...
No Matches
Botcraft::ManagersClient Class Reference

A client containing the different managers, and performing client-side physics. More...

#include <ManagersClient.hpp>

Inheritance diagram for Botcraft::ManagersClient:
Botcraft::ConnectionClient ProtocolCraft::Handler ProtocolCraft::GenericHandler< Packet, AllPackets > Botcraft::BehaviourClient Botcraft::TemplatedBehaviourClient< SimpleBehaviourClient > Botcraft::TemplatedBehaviourClient< TDerived > Botcraft::SimpleBehaviourClient

Public Member Functions

 ManagersClient ()
 
virtual ~ManagersClient ()
 
virtual void Disconnect () override
 
void SetSharedWorld (const std::shared_ptr< World > world_)
 
bool GetAutoRespawn () const
 
void SetAutoRespawn (const bool b)
 
int SendInventoryTransaction (const std::shared_ptr< ProtocolCraft::ServerboundContainerClickPacket > &transaction)
 
std::shared_ptr< WorldGetWorld () const
 
std::shared_ptr< EntityManagerGetEntityManager () const
 
std::shared_ptr< LocalPlayerGetLocalPlayer () const
 
std::shared_ptr< InventoryManagerGetInventoryManager () const
 
std::shared_ptr< PhysicsManagerGetPhysicsManager () const
 
std::string GetPlayerName (const ProtocolCraft::UUID &uuid) const
 Get the name of a connected player.
 
Utilities::ScopeLockedWrapper< const std::map< ProtocolCraft::UUID, std::string >, std::shared_mutex, std::shared_lock > GetOnlinePlayers () const
 Get the list of connected player (tab list)
 
int GetDayTime () const
 Get the current tick.
 
- Public Member Functions inherited from Botcraft::ConnectionClient
 ConnectionClient ()
 
virtual ~ConnectionClient ()
 
void Connect (const std::string &address, const std::string &login)
 Connect the client in offline mode if login is not empty, fallback to Microsoft auth flow if empty.
 
void ConnectMicrosoft (const std::string &address, const std::string &cache_key="")
 Connect the client in online mode.
 
void ConnectMinecraftToken (const std::string &address, const std::string &minecraft_token)
 Connect the client in online mode using the provided minecraft token.
 
bool GetShouldBeClosed () const
 
void SetShouldBeClosed (const bool b)
 
std::shared_ptr< NetworkManagerGetNetworkManager () const
 
void SendChatMessage (const std::string &msg)
 Send a message in the game chat.
 
void SendChatCommand (const std::string &command)
 Send a command in the game chat.
 
void Respawn ()
 Ask to respawn when dead.
 

Protected Member Functions

virtual void Handle (ProtocolCraft::ClientboundLoginFinishedPacket &packet) override
 
virtual void Handle (ProtocolCraft::ClientboundChangeDifficultyPacket &packet) override
 
virtual void Handle (ProtocolCraft::ClientboundLoginPacket &packet) override
 
virtual void Handle (ProtocolCraft::ClientboundSetHealthPacket &packet) override
 
virtual void Handle (ProtocolCraft::ClientboundPlayerPositionPacket &packet) override
 
virtual void Handle (ProtocolCraft::ClientboundRespawnPacket &packet) override
 
virtual void Handle (ProtocolCraft::ClientboundSetTimePacket &packet) override
 
virtual void Handle (ProtocolCraft::ClientboundPlayerInfoRemovePacket &packet) override
 
virtual void Handle (ProtocolCraft::ClientboundPlayerInfoUpdatePacket &packet) override
 
virtual void Handle (ProtocolCraft::ClientboundLoginDisconnectPacket &packet) override
 
virtual void Handle (ProtocolCraft::ClientboundDisconnectPacket &packet) override
 
virtual void Handle (ProtocolCraft::ClientboundPlayerPositionPacket &packet) override
 
virtual void Handle (ProtocolCraft::ClientboundDisconnectConfigurationPacket &packet) override
 
virtual void Handle (ProtocolCraft::ClientboundLoginPacket &packet) override
 
virtual void Handle (ProtocolCraft::ClientboundRespawnPacket &packet) override
 

Protected Attributes

std::shared_ptr< Worldworld
 
std::shared_ptr< EntityManagerentity_manager
 
std::shared_ptr< InventoryManagerinventory_manager
 
std::shared_ptr< PhysicsManagerphysics_manager
 
std::shared_ptr< Renderer::RenderingManagerrendering_manager
 
bool auto_respawn
 
Difficulty difficulty
 
bool difficulty_locked
 
bool is_hardcore
 
std::atomic< int > day_time
 
std::map< ProtocolCraft::UUID, std::string > player_names
 Names of all connected players.
 
std::shared_mutex player_names_mutex
 
- Protected Attributes inherited from Botcraft::ConnectionClient
std::shared_ptr< NetworkManagernetwork_manager
 
bool should_be_closed
 

Detailed Description

A client containing the different managers, and performing client-side physics.

Can be inherited if you want to handle other packets without a need of any behaviour tree stuff.

Definition at line 31 of file ManagersClient.hpp.

Constructor & Destructor Documentation

◆ ManagersClient()

◆ ~ManagersClient()

Botcraft::ManagersClient::~ManagersClient ( )
virtual

Definition at line 46 of file ManagersClient.cpp.

References Disconnect().

Member Function Documentation

◆ Disconnect()

◆ GetAutoRespawn()

bool Botcraft::ManagersClient::GetAutoRespawn ( ) const

Definition at line 120 of file ManagersClient.cpp.

References auto_respawn.

◆ GetDayTime()

int Botcraft::ManagersClient::GetDayTime ( ) const

Get the current tick.

Returns
An int representing the time of day

Definition at line 95 of file ManagersClient.cpp.

References day_time.

Referenced by Botcraft::IsNightTime().

◆ GetEntityManager()

std::shared_ptr< EntityManager > Botcraft::ManagersClient::GetEntityManager ( ) const

Definition at line 135 of file ManagersClient.cpp.

References entity_manager.

Referenced by Botcraft::InteractEntityImpl(), and Botcraft::PlaceBlockImpl().

◆ GetInventoryManager()

◆ GetLocalPlayer()

◆ GetOnlinePlayers()

Utilities::ScopeLockedWrapper< const std::map< ProtocolCraft::UUID, std::string >, std::shared_mutex, std::shared_lock > Botcraft::ManagersClient::GetOnlinePlayers ( ) const

Get the list of connected player (tab list)

Returns
Basically an object you can use as a std::map<ProtocolCraft::UUID, std::string>*. ALL TAB LIST UPDATE WILL BE BLOCKED WHILE THIS OBJECT IS ALIVE, make sure it goes out of scope as soon as you don't need it.

Definition at line 90 of file ManagersClient.cpp.

References player_names, and player_names_mutex.

◆ GetPhysicsManager()

◆ GetPlayerName()

std::string Botcraft::ManagersClient::GetPlayerName ( const ProtocolCraft::UUID uuid) const

Get the name of a connected player.

Parameters
uuidUUID of the player
Returns
The name, or empty string if not present

Definition at line 155 of file ManagersClient.cpp.

References entity_manager, Botcraft::ConnectionClient::network_manager, player_names, and player_names_mutex.

◆ GetWorld()

std::shared_ptr< World > Botcraft::ManagersClient::GetWorld ( ) const

◆ Handle() [1/15]

void Botcraft::ManagersClient::Handle ( ProtocolCraft::ClientboundChangeDifficultyPacket packet)
overrideprotectedvirtual

Definition at line 223 of file ManagersClient.cpp.

References difficulty, and difficulty_locked.

◆ Handle() [2/15]

void Botcraft::ConnectionClient::Handle ( ProtocolCraft::ClientboundDisconnectConfigurationPacket packet)
overrideprotectedvirtual

Reimplemented from Botcraft::ConnectionClient.

Definition at line 57 of file ConnectionClient.cpp.

References Botcraft::ConnectionClient::should_be_closed.

◆ Handle() [3/15]

void Botcraft::ConnectionClient::Handle ( ProtocolCraft::ClientboundDisconnectPacket packet)
overrideprotectedvirtual

Reimplemented from Botcraft::ConnectionClient.

Definition at line 54 of file ConnectionClient.cpp.

◆ Handle() [4/15]

void Botcraft::ConnectionClient::Handle ( ProtocolCraft::ClientboundLoginDisconnectPacket packet)
overrideprotectedvirtual

Reimplemented from Botcraft::ConnectionClient.

Definition at line 50 of file ConnectionClient.cpp.

◆ Handle() [5/15]

void Botcraft::ManagersClient::Handle ( ProtocolCraft::ClientboundLoginFinishedPacket packet)
overrideprotectedvirtual

◆ Handle() [6/15]

void Botcraft::ConnectionClient::Handle ( ProtocolCraft::ClientboundLoginPacket packet)
overrideprotectedvirtual

Reimplemented from Botcraft::ConnectionClient.

Definition at line 60 of file ConnectionClient.cpp.

◆ Handle() [7/15]

void Botcraft::ManagersClient::Handle ( ProtocolCraft::ClientboundLoginPacket packet)
overrideprotectedvirtual

Reimplemented from Botcraft::ConnectionClient.

Definition at line 231 of file ManagersClient.cpp.

References difficulty, Botcraft::ConnectionClient::Handle(), and is_hardcore.

◆ Handle() [8/15]

void Botcraft::ManagersClient::Handle ( ProtocolCraft::ClientboundPlayerInfoRemovePacket packet)
overrideprotectedvirtual

Definition at line 341 of file ManagersClient.cpp.

References player_names, and player_names_mutex.

◆ Handle() [9/15]

void Botcraft::ManagersClient::Handle ( ProtocolCraft::ClientboundPlayerInfoUpdatePacket packet)
overrideprotectedvirtual

Definition at line 350 of file ManagersClient.cpp.

References player_names, and player_names_mutex.

◆ Handle() [10/15]

void Botcraft::ConnectionClient::Handle ( ProtocolCraft::ClientboundPlayerPositionPacket packet)
overrideprotectedvirtual

Reimplemented from Botcraft::ConnectionClient.

Definition at line 55 of file ConnectionClient.cpp.

◆ Handle() [11/15]

void Botcraft::ManagersClient::Handle ( ProtocolCraft::ClientboundPlayerPositionPacket packet)
overrideprotectedvirtual

Reimplemented from Botcraft::ConnectionClient.

Definition at line 256 of file ManagersClient.cpp.

◆ Handle() [12/15]

void Botcraft::ConnectionClient::Handle ( ProtocolCraft::ClientboundRespawnPacket packet)
overrideprotectedvirtual

Reimplemented from Botcraft::ConnectionClient.

Definition at line 61 of file ConnectionClient.cpp.

◆ Handle() [13/15]

void Botcraft::ManagersClient::Handle ( ProtocolCraft::ClientboundRespawnPacket packet)
overrideprotectedvirtual

Reimplemented from Botcraft::ConnectionClient.

Definition at line 261 of file ManagersClient.cpp.

References difficulty, and Botcraft::ConnectionClient::Handle().

◆ Handle() [14/15]

void Botcraft::ManagersClient::Handle ( ProtocolCraft::ClientboundSetHealthPacket packet)
overrideprotectedvirtual

Definition at line 248 of file ManagersClient.cpp.

References auto_respawn, and Botcraft::ConnectionClient::Respawn().

◆ Handle() [15/15]

void Botcraft::ManagersClient::Handle ( ProtocolCraft::ClientboundSetTimePacket packet)
overrideprotectedvirtual

Definition at line 272 of file ManagersClient.cpp.

References day_time, and world.

◆ SendInventoryTransaction()

int Botcraft::ManagersClient::SendInventoryTransaction ( const std::shared_ptr< ProtocolCraft::ServerboundContainerClickPacket > &  transaction)

◆ SetAutoRespawn()

void Botcraft::ManagersClient::SetAutoRespawn ( const bool  b)

Definition at line 125 of file ManagersClient.cpp.

References auto_respawn.

◆ SetSharedWorld()

void Botcraft::ManagersClient::SetSharedWorld ( const std::shared_ptr< World world_)

Definition at line 115 of file ManagersClient.cpp.

References world.

Member Data Documentation

◆ auto_respawn

bool Botcraft::ManagersClient::auto_respawn
protected

Definition at line 99 of file ManagersClient.hpp.

Referenced by GetAutoRespawn(), Handle(), ManagersClient(), and SetAutoRespawn().

◆ day_time

std::atomic<int> Botcraft::ManagersClient::day_time
protected

Definition at line 106 of file ManagersClient.hpp.

Referenced by GetDayTime(), and Handle().

◆ difficulty

Difficulty Botcraft::ManagersClient::difficulty
protected

Definition at line 101 of file ManagersClient.hpp.

Referenced by Disconnect(), Handle(), Handle(), Handle(), and ManagersClient().

◆ difficulty_locked

bool Botcraft::ManagersClient::difficulty_locked
protected

Definition at line 103 of file ManagersClient.hpp.

Referenced by Disconnect(), Handle(), and ManagersClient().

◆ entity_manager

std::shared_ptr<EntityManager> Botcraft::ManagersClient::entity_manager
protected

◆ inventory_manager

std::shared_ptr<InventoryManager> Botcraft::ManagersClient::inventory_manager
protected

◆ is_hardcore

bool Botcraft::ManagersClient::is_hardcore
protected

Definition at line 105 of file ManagersClient.hpp.

Referenced by Disconnect(), Handle(), and ManagersClient().

◆ physics_manager

std::shared_ptr<PhysicsManager> Botcraft::ManagersClient::physics_manager
protected

Definition at line 94 of file ManagersClient.hpp.

Referenced by Disconnect(), GetPhysicsManager(), and ManagersClient().

◆ player_names

std::map<ProtocolCraft::UUID, std::string> Botcraft::ManagersClient::player_names
protected

Names of all connected players.

Definition at line 109 of file ManagersClient.hpp.

Referenced by Disconnect(), GetOnlinePlayers(), GetPlayerName(), Handle(), and Handle().

◆ player_names_mutex

std::shared_mutex Botcraft::ManagersClient::player_names_mutex
mutableprotected

Definition at line 110 of file ManagersClient.hpp.

Referenced by Disconnect(), GetOnlinePlayers(), GetPlayerName(), Handle(), and Handle().

◆ rendering_manager

◆ world

std::shared_ptr<World> Botcraft::ManagersClient::world
protected

Definition at line 91 of file ManagersClient.hpp.

Referenced by Disconnect(), GetWorld(), Handle(), ManagersClient(), and SetSharedWorld().


The documentation for this class was generated from the following files: