<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.traincarts.net/index.php?action=history&amp;feed=atom&amp;title=BKCommonLib%2FPackets</id>
	<title>BKCommonLib/Packets - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.traincarts.net/index.php?action=history&amp;feed=atom&amp;title=BKCommonLib%2FPackets"/>
	<link rel="alternate" type="text/html" href="https://wiki.traincarts.net/index.php?title=BKCommonLib/Packets&amp;action=history"/>
	<updated>2026-05-09T11:18:57Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.13</generator>
	<entry>
		<id>https://wiki.traincarts.net/index.php?title=BKCommonLib/Packets&amp;diff=7807&amp;oldid=prev</id>
		<title>RyanDo at 09:43, 12 October 2025</title>
		<link rel="alternate" type="text/html" href="https://wiki.traincarts.net/index.php?title=BKCommonLib/Packets&amp;diff=7807&amp;oldid=prev"/>
		<updated>2025-10-12T09:43:36Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 09:43, 12 October 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[BKCommonLib|« Go back]]&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Introduction==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Introduction==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;To keep keep track of packets being sent between the server and the client, BKCommonLib provides a packet listener to intercept and handle these packets. When [https://www.spigotmc.org/resources/protocollib.1997/ ProtocolLib] is found, this plugin is used to provide the listening, otherwise a hacky workaround is used. We recommend you install ProtocolLib as well for that reason.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;To keep keep track of packets being sent between the server and the client, BKCommonLib provides a packet listener to intercept and handle these packets. When [https://www.spigotmc.org/resources/protocollib.1997/ ProtocolLib] is found, this plugin is used to provide the listening, otherwise a hacky workaround is used. We recommend you install ProtocolLib as well for that reason.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key pulseco1_mediawiki:diff::1.12:old-1542:rev-7807 --&gt;
&lt;/table&gt;</summary>
		<author><name>RyanDo</name></author>
	</entry>
	<entry>
		<id>https://wiki.traincarts.net/index.php?title=BKCommonLib/Packets&amp;diff=1542&amp;oldid=prev</id>
		<title>RyanDo: Created page with &quot;« Go back  ==Introduction== To keep keep track of packets being sent between the server and the client, BKCommonLib provides a packet listener to intercept an...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.traincarts.net/index.php?title=BKCommonLib/Packets&amp;diff=1542&amp;oldid=prev"/>
		<updated>2021-06-09T18:55:39Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;&lt;a href=&quot;/p/BKCommonLib&quot; title=&quot;BKCommonLib&quot;&gt;« Go back&lt;/a&gt;  ==Introduction== To keep keep track of packets being sent between the server and the client, BKCommonLib provides a packet listener to intercept an...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[BKCommonLib|« Go back]]&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
To keep keep track of packets being sent between the server and the client, BKCommonLib provides a packet listener to intercept and handle these packets. When [https://www.spigotmc.org/resources/protocollib.1997/ ProtocolLib] is found, this plugin is used to provide the listening, otherwise a hacky workaround is used. We recommend you install ProtocolLib as well for that reason.&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
How to register a packet listener and how to read and change the packets.&lt;br /&gt;
&lt;br /&gt;
==Registering==&lt;br /&gt;
Use the following method to register your [https://github.com/bergerkiller/BKCommonLib/blob/master/src/main/java/com/bergerkiller/bukkit/common/protocol/PacketListener.java PacketListener] implementing class:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;PacketUtil.addPacketListener(plugin, myPacketListener, PacketType.OUT_CHAT);&amp;lt;/pre&amp;gt;&lt;br /&gt;
To create a Packet listener class for your plugin, create a new Class that implements PacketListener, and override the &amp;#039;&amp;#039;&amp;#039;onPacketReceive&amp;#039;&amp;#039;&amp;#039; and &amp;#039;&amp;#039;&amp;#039;onPacketSend&amp;#039;&amp;#039;&amp;#039; methods. There are INcoming and OUTgoing Packet Types, they register for the methods respectively.&lt;br /&gt;
&lt;br /&gt;
==Working with packets==&lt;br /&gt;
Packets change all the time, so it was not possible to include a wrapper class for each and every packet. To work with packets, BKCommonLib provides you a reflection-based system for accessing fields and constructing new packets, namely [https://github.com/bergerkiller/BKCommonLib/blob/master/src/main/java/com/bergerkiller/bukkit/common/protocol/PacketType.java PacketType]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;@Override&lt;br /&gt;
public void onPacketSend(PacketSendEvent event) {&lt;br /&gt;
    CommonPacket packet = event.getPacket();&lt;br /&gt;
    if (packet.getType() == PacketType.OUT_CHAT) {&lt;br /&gt;
        String oldMessage = packet.read(PacketType.OUT_CHAT.message);&lt;br /&gt;
        if (oldMessage.contains(&amp;quot;curse&amp;quot;)) {&lt;br /&gt;
            packet.write(PacketType.OUT_CHAT.message, oldMessage.replace(&amp;quot;curse&amp;quot;, &amp;quot;curse is awesome&amp;quot;));&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
There are also methods to read/write a certain parameter index or by name, but they are generally unsafe. We recommend you use the PacketFields constants for this instead, so your plugin remains compatible when fields change. For example, if the &amp;#039;message&amp;#039; String field is replaced with a List of Strings, we can still provide you with a (deprecated) message field which sets that other field.&lt;/div&gt;</summary>
		<author><name>RyanDo</name></author>
	</entry>
</feed>