Mineserver
A rewrite of Minecraft 1.8.9 in C++ !
Loading...
Searching...
No Matches
clientevents.hpp
Go to the documentation of this file.
1
12#ifndef MINESERVER_CLIENTEVENTS_H
13#define MINESERVER_CLIENTEVENTS_H
14
15#include <plugins/event.h>
18
32class ClientConnectedEvent : public IEvent<ClientConnectedEvent> {
33};
34
50class ClientHandshakeEvent : public IEvent<ClientHandshakeEvent>
51{
52public:
61
68
74 static void loadLua(lua_State *state)
75 {
76 luabridge::getGlobalNamespace(state)
77 .beginNamespace("event")
78 .addFunction("onClientHandshake", [](const luabridge::LuaRef &ref)
79 {
80 if(!ref.isFunction())
81 return;
82
83 EventsManager::inst()->subscribe<ClientHandshakeEvent>(const_cast<luabridge::LuaRef &>(ref)); })
84 .beginClass<ClientHandshakeEvent>("ClientHandshake")
85 .addProperty("packet", &ClientHandshakeEvent::packet)
86 .endClass()
87 .endNamespace();
88 }
89};
90
107class ClientStatusEvent : public IEvent<ClientStatusEvent>
108{
109public:
118
125
131 static void loadLua(lua_State *state)
132 {
133 luabridge::getGlobalNamespace(state)
134 .beginNamespace("event")
135 .addFunction("onClientStatus", [](const luabridge::LuaRef &ref)
136 {
137 if(!ref.isFunction())
138 return;
139
140 EventsManager::inst()->subscribe<ClientStatusEvent>(const_cast<luabridge::LuaRef&>(ref)); })
141 .beginClass<ClientStatusEvent>("ClientStatus")
142 .addProperty("packet", &ClientStatusEvent::packet)
143 .endClass()
144 .endNamespace();
145 }
146};
147
148#endif // MINESERVER_CLIENTEVENTS_H
Event for a client connection.
Definition clientevents.hpp:32
Event for a client status.
Definition clientevents.hpp:51
ClientHandshakeEvent(HandshakePacket *packet)
Construct a new Client Handshake Event object.
Definition clientevents.hpp:67
static void loadLua(lua_State *state)
Loads this event to lua.
Definition clientevents.hpp:74
HandshakePacket * packet
Pointer to handshake packet.
Definition clientevents.hpp:60
Event for a client status.
Definition clientevents.hpp:108
ServerListPacket * packet
Pointer to server list packet.
Definition clientevents.hpp:117
static void loadLua(lua_State *state)
Loads this event to lua.
Definition clientevents.hpp:131
ClientStatusEvent(ServerListPacket *packet)
Construct a new Client Status Event object.
Definition clientevents.hpp:124
static EventsManager * inst()
Gets the instance of the events manager.
Definition event.cpp:20
EventHandler< T >::subId subscribe(const typename EventHandler< T >::callbackType &callback)
Subscribe to T event.
Definition event.h:285
Handshake Packet.
Definition handshake.h:26
Event interface.
Definition event.h:28
Server List packet.
Definition serverlist.h:27
The header-only containing event logic.
constexpr std::string_view type_name()
Gets the name of the type paramater.
Definition event.h:56
The file containing handshake protocol.
The file containing packet logic for server list.