PaperMC / Velocity

The modern, next-generation Minecraft server proxy.
https://papermc.io/software/velocity
GNU General Public License v3.0
1.68k stars 583 forks source link

Custom motd on proxy ping #1349

Closed AydenC77 closed 3 weeks ago

AydenC77 commented 3 weeks ago

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() ); } }); } } }

Warriorrrr commented 3 weeks ago

Solved on the discord