Add Title API.
This commit is contained in:
@@ -27,6 +27,7 @@ import net.md_5.bungee.protocol.packet.PingPacket;
|
||||
import net.md_5.bungee.protocol.packet.StatusRequest;
|
||||
import net.md_5.bungee.protocol.packet.StatusResponse;
|
||||
import net.md_5.bungee.protocol.packet.TabCompleteResponse;
|
||||
import net.md_5.bungee.protocol.packet.Title;
|
||||
|
||||
public abstract class AbstractPacketHandler
|
||||
{
|
||||
@@ -115,6 +116,10 @@ public abstract class AbstractPacketHandler
|
||||
{
|
||||
}
|
||||
|
||||
public void handle(Title title) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
public void handle(PluginMessage pluginMessage) throws Exception
|
||||
{
|
||||
}
|
||||
|
@@ -32,6 +32,7 @@ import net.md_5.bungee.protocol.packet.StatusResponse;
|
||||
import net.md_5.bungee.protocol.packet.TabCompleteRequest;
|
||||
import net.md_5.bungee.protocol.packet.TabCompleteResponse;
|
||||
import net.md_5.bungee.protocol.packet.Team;
|
||||
import net.md_5.bungee.protocol.packet.Title;
|
||||
|
||||
public enum Protocol
|
||||
{
|
||||
@@ -61,6 +62,7 @@ public enum Protocol
|
||||
TO_CLIENT.registerPacket( 0x3E, Team.class );
|
||||
TO_CLIENT.registerPacket( 0x3F, PluginMessage.class );
|
||||
TO_CLIENT.registerPacket( 0x40, Kick.class );
|
||||
TO_CLIENT.registerPacket( 0x45, Title.class );
|
||||
TO_CLIENT.registerPacket( 0x46, SetCompression.class );
|
||||
TO_CLIENT.registerPacket( 0x47, PlayerListHeaderFooter.class );
|
||||
|
||||
|
@@ -0,0 +1,77 @@
|
||||
package net.md_5.bungee.protocol.packet;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
||||
import net.md_5.bungee.protocol.DefinedPacket;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class Title extends DefinedPacket
|
||||
{
|
||||
private Action action;
|
||||
|
||||
// TITLE & SUBTITLE
|
||||
private String text;
|
||||
|
||||
// TIMES
|
||||
private int fadeIn;
|
||||
private int stay;
|
||||
private int fadeOut;
|
||||
|
||||
@Override
|
||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||
{
|
||||
action = Action.values()[readVarInt( buf )];
|
||||
switch ( action )
|
||||
{
|
||||
case TITLE:
|
||||
case SUBTITLE:
|
||||
text = readString( buf );
|
||||
break;
|
||||
case TIMES:
|
||||
fadeIn = buf.readInt();
|
||||
stay = buf.readInt();
|
||||
fadeOut = buf.readInt();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||
{
|
||||
writeVarInt( action.ordinal(), buf );
|
||||
switch ( action )
|
||||
{
|
||||
case TITLE:
|
||||
case SUBTITLE:
|
||||
writeString( text, buf );
|
||||
break;
|
||||
case TIMES:
|
||||
buf.writeInt( fadeIn );
|
||||
buf.writeInt( stay );
|
||||
buf.writeInt( fadeOut );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(AbstractPacketHandler handler) throws Exception
|
||||
{
|
||||
handler.handle( this );
|
||||
}
|
||||
|
||||
public static enum Action
|
||||
{
|
||||
TITLE,
|
||||
SUBTITLE,
|
||||
TIMES,
|
||||
CLEAR,
|
||||
RESET
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user