Java Code Examples for org.bukkit.Bukkit#getMotd()

The following examples show how to use org.bukkit.Bukkit#getMotd() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SpigotPingResponseHandler.java    From ProtocolSupport with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public ServerPingResponseEvent createResponse(Connection connection) {
	List<Player> players = new ArrayList<>(Bukkit.getOnlinePlayers());

	String motd = Bukkit.getMotd();
	int maxPlayers = Bukkit.getMaxPlayers();

	InternalServerListPingEvent bevent = new InternalServerListPingEvent(connection.getAddress().getAddress(), motd, maxPlayers, players);
	bevent.setServerIcon(Bukkit.getServerIcon());
	Bukkit.getPluginManager().callEvent(bevent);

	ServerPingResponseEvent revent = new ServerPingResponseEvent(
		connection,
		new ProtocolInfo(connection.getVersion(), createServerVersionString()),
		bevent.getIcon() != null ? ServerPlatform.get().getMiscUtils().convertBukkitIconToBase64(bevent.getIcon()) : null,
		bevent.getMotd(),
		bevent.getNumPlayers(), bevent.getMaxPlayers(),
		bevent.players.stream()
		.limit(SpigotConfig.playerSample)
		.map(Player::getName)
		.collect(Collectors.toList())
	);
	Bukkit.getPluginManager().callEvent(revent);

	return revent;
}
 
Example 2
Source File: GeyserBukkitPingPassthrough.java    From Geyser with MIT License 5 votes vote down vote up
@Override
public GeyserPingInfo getPingInformation() {
    try {
        ServerListPingEvent event = new GeyserPingEvent(InetAddress.getLocalHost(), Bukkit.getMotd(), Bukkit.getOnlinePlayers().size(), Bukkit.getMaxPlayers());
        Bukkit.getPluginManager().callEvent(event);
        GeyserPingInfo geyserPingInfo = new GeyserPingInfo(event.getMotd(), event.getNumPlayers(), event.getMaxPlayers());
        Bukkit.getOnlinePlayers().forEach(player -> {
            geyserPingInfo.addPlayer(player.getName());
        });
        return geyserPingInfo;
    } catch (Exception e) {
        logger.debug("Error while getting Bukkit ping passthrough: " + e.toString());
        return new GeyserPingInfo(null, 0, 0);
    }
}
 
Example 3
Source File: PaperPingResponseHandler.java    From ProtocolSupport with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public ServerPingResponseEvent createResponse(Connection connection) {
	PaperServerListPingEvent bevent = new PaperServerListPingEvent(
		new StatusClientImpl(connection),
		Bukkit.getMotd(),
		Bukkit.getOnlinePlayers().size(), Bukkit.getMaxPlayers(),
		createServerVersionString(), connection.getVersion().getId(),
		Bukkit.getServerIcon()
	);
	List<PlayerProfile> playerSample = bevent.getPlayerSample();
	Bukkit.getOnlinePlayers().stream()
	.limit(SpigotConfig.playerSample)
	.map(player -> new NameUUIDPlayerProfile(player.getUniqueId(), player.getName()))
	.forEach(playerSample::add);
	Bukkit.getPluginManager().callEvent(bevent);

	ServerPingResponseEvent revent = new ServerPingResponseEvent(
		connection,
		new ProtocolInfo(bevent.getProtocolVersion(), bevent.getVersion()),
		bevent.getServerIcon() != null ? ServerPlatform.get().getMiscUtils().convertBukkitIconToBase64(bevent.getServerIcon()) : null,
		bevent.getMotd(),
		bevent.getNumPlayers(), bevent.getMaxPlayers(),
		bevent.getPlayerSample().stream().map(PlayerProfile::getName).collect(Collectors.toList())
	);
	Bukkit.getPluginManager().callEvent(revent);

	return revent;
}