From a1570f68e5d07bafebf76a84ae98ca2073b8e542 Mon Sep 17 00:00:00 2001 From: Minecrell Date: Wed, 3 Sep 2014 17:31:35 +0200 Subject: [PATCH] Add title packet for use by plugins. --- .../0180-Snapshot-protocol.patch | 91 ++++++++++++++++++- 1 file changed, 88 insertions(+), 3 deletions(-) diff --git a/CraftBukkit-Patches/0180-Snapshot-protocol.patch b/CraftBukkit-Patches/0180-Snapshot-protocol.patch index c6b6a057..671139ca 100644 --- a/CraftBukkit-Patches/0180-Snapshot-protocol.patch +++ b/CraftBukkit-Patches/0180-Snapshot-protocol.patch @@ -1,4 +1,4 @@ -From 7a82d01c51bcd2f9d36da3e5db271dc6ef80db64 Mon Sep 17 00:00:00 2001 +From 9c66dfb14a3824b06707afff337f81484ca53ecf Mon Sep 17 00:00:00 2001 From: Thinkofdeath Date: Mon, 1 Sep 2014 16:47:48 +1000 Subject: [PATCH] Snapshot protocol @@ -3883,10 +3883,10 @@ index 0000000..ff93cbe +} diff --git a/src/main/java/org/spigotmc/ProtocolInjector.java b/src/main/java/org/spigotmc/ProtocolInjector.java new file mode 100644 -index 0000000..d8ac388 +index 0000000..3b2df91 --- /dev/null +++ b/src/main/java/org/spigotmc/ProtocolInjector.java -@@ -0,0 +1,168 @@ +@@ -0,0 +1,253 @@ +package org.spigotmc; + +import net.minecraft.server.ChatSerializer; @@ -3909,6 +3909,7 @@ index 0000000..d8ac388 + { + addPacket( EnumProtocol.LOGIN, true, 0x3, PacketLoginCompression.class ); + ++ addPacket( EnumProtocol.PLAY, true, 0x45, PacketTitle.class ); + addPacket( EnumProtocol.PLAY, true, 0x47, PacketTabHeader.class ); + addPacket( EnumProtocol.PLAY, true, 0x48, PacketPlayResourcePackSend.class ); + addPacket( EnumProtocol.PLAY, false, 0x19, PacketPlayResourcePackStatus.class ); @@ -4054,6 +4055,90 @@ index 0000000..d8ac388 + { + } + } ++ ++ public static class PacketTitle extends Packet ++ { ++ private Action action; ++ ++ // TITLE & SUBTITLE ++ private IChatBaseComponent text; ++ ++ // TIMES ++ private int fadeIn = -1; ++ private int stay = -1; ++ private int fadeOut = -1; ++ ++ public PacketTitle() {} ++ ++ public PacketTitle(Action action) ++ { ++ this.action = action; ++ } ++ ++ public PacketTitle(Action action, IChatBaseComponent text) ++ { ++ this( action ); ++ this.text = text; ++ } ++ ++ public PacketTitle(Action action, int fadeIn, int stay, int fadeOut) ++ { ++ this( action ); ++ this.fadeIn = fadeIn; ++ this.stay = stay; ++ this.fadeOut = fadeOut; ++ } ++ ++ ++ @Override ++ public void a(PacketDataSerializer packetdataserializer) throws IOException ++ { ++ this.action = Action.values()[packetdataserializer.a()]; ++ switch ( action ) ++ { ++ case TITLE: ++ case SUBTITLE: ++ this.text = ChatSerializer.a( packetdataserializer.c(32767) ); ++ break; ++ case TIMES: ++ this.fadeIn = packetdataserializer.readInt(); ++ this.stay = packetdataserializer.readInt(); ++ this.fadeOut = packetdataserializer.readInt(); ++ break; ++ } ++ } ++ ++ @Override ++ public void b(PacketDataSerializer packetdataserializer) throws IOException ++ { ++ packetdataserializer.b( action.ordinal() ); ++ switch ( action ) ++ { ++ case TITLE: ++ case SUBTITLE: ++ packetdataserializer.a( ChatSerializer.a( this.text ) ); ++ break; ++ case TIMES: ++ packetdataserializer.writeInt( this.fadeIn ); ++ packetdataserializer.writeInt( this.stay ); ++ packetdataserializer.writeInt( this.fadeOut ); ++ break; ++ } ++ } ++ ++ @Override ++ public void handle(PacketListener packetlistener) ++ { ++ } ++ ++ public static enum Action { ++ TITLE, ++ SUBTITLE, ++ TIMES, ++ CLEAR, ++ RESET ++ } ++ } +} diff --git a/src/main/java/org/spigotmc/SpigotComponentReverter.java b/src/main/java/org/spigotmc/SpigotComponentReverter.java new file mode 100644