Created
April 1, 2013 02:50
-
-
Save LaxWasHere/5282978 to your computer and use it in GitHub Desktop.
Bungeecord ProxyPingEvent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.lazlecraft.BungeeFun; | |
import com.google.common.eventbus.Subscribe; | |
import net.md_5.bungee.api.ProxyServer; | |
import net.md_5.bungee.api.ServerPing; | |
import net.md_5.bungee.api.event.ProxyPingEvent; | |
import net.md_5.bungee.api.plugin.Listener; | |
import net.md_5.bungee.api.plugin.Plugin; | |
public class BF extends Plugin implements Listener { | |
@Override | |
public void onEnable() { | |
ProxyServer.getInstance().getPluginManager().registerListener(this, this); | |
} | |
@Subscribe | |
public void onPing(ProxyPingEvent ev){ //Event called on ping | |
//set the response | |
Byte protocolVersion = Byte.valueOf(ev.getResponse().getProtocolVersion()); //Protocol version | |
String gameVersion = ev.getResponse().getGameVersion(); //Game Version | |
String motd = (ev.getResponse().getMotd()); //MOTD | |
Integer currentPlayers = (Integer.valueOf(ev.getResponse().getCurrentPlayers())); //Current players | |
Integer maxPlayers = Integer.valueOf(ev.getResponse().getMaxPlayers()); //Max Players | |
ServerPing BF = new ServerPing(protocolVersion.byteValue(), gameVersion, motd, currentPlayers.intValue(), maxPlayers.intValue()); | |
ev.setResponse(BF); //Send response | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment