File server_list_ping_event.h¶
File List > endstone > event > server > server_list_ping_event.h
Go to the documentation of this file
// 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 <utility>
#include "endstone/event/cancellable.h"
#include "endstone/event/server/server_event.h"
#include "endstone/game_mode.h"
#include "endstone/util/socket_address.h"
namespace endstone {
class ServerListPingEvent : public Cancellable<ServerEvent> {
public:
ENDSTONE_EVENT(ServerListPingEvent);
ServerListPingEvent(SocketAddress address, std::string motd, int network_protocol_version,
std::string minecraft_version_network, int num_players, int max_players,
std::string server_guid, std::string level_name, GameMode game_mode, int local_port,
int local_port_v6)
: Cancellable(true), address_(std::move(address)), motd_(std::move(motd)),
network_protocol_version_(network_protocol_version),
minecraft_version_network_(std::move(minecraft_version_network)), num_players_(num_players),
max_players_(max_players), server_guid_(std::move(server_guid)), level_name_(std::move(level_name)),
game_mode_(game_mode), local_port_(local_port), local_port_v6_(local_port_v6)
{
}
[[nodiscard]] SocketAddress getAddress() const { return address_; }
[[nodiscard]] std::string getServerGuid() const { return server_guid_; }
void setServerGuid(std::string guid) { server_guid_ = std::move(guid); }
[[nodiscard]] int getLocalPort() const { return local_port_; }
void setLocalPort(int port) { local_port_ = port; }
[[nodiscard]] int getLocalPortV6() const { return local_port_v6_; }
void setLocalPortV6(int port) { local_port_v6_ = port; }
[[nodiscard]] std::string getMotd() const { return motd_; }
void setMotd(std::string motd) { motd_ = std::move(motd); }
[[nodiscard]] int getNetworkProtocolVersion() const { return network_protocol_version_; }
[[nodiscard]] std::string getMinecraftVersionNetwork() const { return minecraft_version_network_; }
void setMinecraftVersionNetwork(std::string minecraft_version_network)
{
minecraft_version_network_ = std::move(minecraft_version_network);
}
[[nodiscard]] int getNumPlayers() const { return num_players_; }
void setNumPlayers(int num_players) { num_players_ = num_players; }
[[nodiscard]] int getMaxPlayers() const { return max_players_; }
void setMaxPlayers(int max_players) { max_players_ = max_players; }
[[nodiscard]] std::string getLevelName() const { return level_name_; }
void setLevelName(std::string level_name) { level_name_ = std::move(level_name); }
[[nodiscard]] GameMode getGameMode() const { return game_mode_; }
void setGameMode(GameMode game_mode) { game_mode_ = game_mode; }
private:
SocketAddress address_;
std::string motd_;
int network_protocol_version_;
std::string minecraft_version_network_;
int num_players_;
int max_players_;
std::string server_guid_;
std::string level_name_;
GameMode game_mode_;
int local_port_;
int local_port_v6_;
};
} // namespace endstone