PaperMC / Velocity

The modern, next-generation Minecraft server proxy.

Home Page:https://papermc.io/software/velocity

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Custom motd on proxy ping

AydenC77 opened this issue · comments

Hello i had to make my own force host system and i wanted to be able to set motds for the servers i made this code but its not working can someone help btw i have a global motd set in the velocity.toml file
@Subscribe public void onProxyPing(ProxyPingEvent event) { String skypixelip = "skypixle.gg"; InetSocketAddress address = event.getConnection().getVirtualHost().orElse(null); if (address.toString().contains(skypixelip)) { String host = address.getHostString(); String[] namesplit = host.split("\\."); String name = namesplit[0]; String lowername = name.toLowerCase(); Optional<RegisteredServer> server = proxy.getServer(name); if (server.isPresent()) { server.get().ping().whenComplete((serverPing, throwable) -> { if (throwable != null) { event.setPing(event.getPing().asBuilder() .description(Component.text(name + " is offline!").color(TextColor.color(170, 0, 0)).appendNewline().append(Component.text("Start it via /Start in the lobby").color(TextColor.color(85, 255, 85)))) .onlinePlayers(server.get().getPlayersConnected().size()) .build() ); } else { event.setPing(event.getPing().asBuilder() .description(Component.text("A Skypixle Server").color(TextColor.color(85, 255, 255))) .build() ); } }); } } }

Solved on the discord