Skip to content

Instantly share code, notes, and snippets.

@arxenix
Created September 6, 2013 20:53
Show Gist options
  • Save arxenix/6469894 to your computer and use it in GitHub Desktop.
Save arxenix/6469894 to your computer and use it in GitHub Desktop.
Set Minecraft MOTD with ProtocolLib
ProtocolLibrary.getProtocolManager().addPacketListener(
new PacketAdapter(this, ConnectionSide.SERVER_SIDE,
Packets.Server.KICK_DISCONNECT) {
@Override
public void onPacketSending(PacketEvent event) {
StructureModifier<String> packetStr = event.getPacket().getSpecificModifier(String.class);
String p = (String)packetStr.read(0);
String prep = p.substring(0, 3);
String motd = "Custom MOTD";
String alert = "Custom Alert/Protocol message";
int protocol = -1; //set this to 74 if you DONT want the alert message
int online = Bukkit.getOnlinePlayers().length;
int max = Bukkit.getMaxPlayers();
packetStr.write(0,
prep //first 3 bytes
+ protocol //protocol vesion
+ "\u0000"
+ alert //message near ping
+ "\u0000"
+ motd //motd
+ "\u0000"
+ online //online players count
+ "\u0000"
+ max // max players
);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment