public abstract class TinyProtocol1_8 extends java.lang.Object implements AbstractTinyProtocol
It now supports intercepting packets during login and status ping (such as OUT_SERVER_PING)!
Modifier and Type | Field and Description |
---|---|
protected boolean |
closed |
protected org.bukkit.plugin.Plugin |
plugin |
Constructor and Description |
---|
TinyProtocol1_8(org.bukkit.plugin.Plugin plugin)
Construct a new instance of TinyProtocol, and start intercepting packets for all connected clients and future clients.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Cease listening for packets.
|
io.netty.channel.Channel |
getChannel(org.bukkit.entity.Player player)
Retrieve the Netty channel associated with a player.
|
protected java.lang.String |
getHandlerName()
Retrieve the name of the channel injector, default implementation is "tiny-" + plugin name + "-" + a unique ID.
|
int |
getProtocolVersion(org.bukkit.entity.Player player) |
boolean |
hasInjected(io.netty.channel.Channel channel)
Determine if the given channel has been injected by TinyProtocol.
|
boolean |
hasInjected(org.bukkit.entity.Player player)
Determine if the given player has been injected by TinyProtocol.
|
void |
injectChannel(io.netty.channel.Channel channel)
Add a custom channel handler to the given channel.
|
void |
injectPlayer(org.bukkit.entity.Player player)
Add a custom channel handler to the given player's channel pipeline, allowing us to intercept sent and received packets.
|
java.lang.Object |
onPacketInAsync(org.bukkit.entity.Player sender,
java.lang.Object packet)
Invoked when the server has received a packet from a given player.
|
java.lang.Object |
onPacketOutAsync(org.bukkit.entity.Player receiver,
java.lang.Object packet)
Invoked when the server is starting to send a packet to a player.
|
void |
receivePacket(io.netty.channel.Channel channel,
java.lang.Object packet)
Pretend that a given packet has been received from a given client.
|
void |
receivePacket(org.bukkit.entity.Player player,
java.lang.Object packet)
Pretend that a given packet has been received from a player.
|
void |
sendPacket(io.netty.channel.Channel channel,
java.lang.Object packet)
Send a packet to a particular client.
|
void |
sendPacket(org.bukkit.entity.Player player,
java.lang.Object packet)
Send a packet to a particular player.
|
void |
uninjectChannel(io.netty.channel.Channel channel)
Uninject a specific channel.
|
void |
uninjectPlayer(org.bukkit.entity.Player player)
Uninject a specific player.
|
protected volatile boolean closed
protected org.bukkit.plugin.Plugin plugin
public TinyProtocol1_8(org.bukkit.plugin.Plugin plugin)
You can construct multiple instances per plugin.
plugin
- - the plugin.public java.lang.Object onPacketOutAsync(org.bukkit.entity.Player receiver, java.lang.Object packet)
Note that this is not executed on the main thread.
receiver
- - the receiving player, NULL for early login/status packets.packet
- - the packet being sent.public java.lang.Object onPacketInAsync(org.bukkit.entity.Player sender, java.lang.Object packet)
Use Channel.remoteAddress()
to get the remote address of the client.
sender
- - the player that sent the packet, NULL for early login/status packets.packet
- - the packet being received.public void sendPacket(org.bukkit.entity.Player player, java.lang.Object packet)
Note that onPacketOutAsync(Player, Object)
will be invoked with this packet.
sendPacket
in interface AbstractTinyProtocol
player
- - the destination player.packet
- - the packet to send.public void sendPacket(io.netty.channel.Channel channel, java.lang.Object packet)
Note that onPacketOutAsync(Player, Object)
will be invoked with this packet.
channel
- - client identified by a channel.packet
- - the packet to send.public void receivePacket(org.bukkit.entity.Player player, java.lang.Object packet)
Note that onPacketInAsync(Player, Object)
will be invoked with this packet.
receivePacket
in interface AbstractTinyProtocol
player
- - the player that sent the packet.packet
- - the packet that will be received by the server.public void receivePacket(io.netty.channel.Channel channel, java.lang.Object packet)
Note that onPacketInAsync(Player, Object)
will be invoked with this packet.
channel
- - client identified by a channel.packet
- - the packet that will be received by the server.protected java.lang.String getHandlerName()
Note that this method will only be invoked once. It is no longer necessary to override this to support multiple instances.
public void injectPlayer(org.bukkit.entity.Player player)
This will automatically be called when a player has logged in.
injectPlayer
in interface AbstractTinyProtocol
player
- - the player to inject.public void injectChannel(io.netty.channel.Channel channel)
channel
- - the channel to inject.public io.netty.channel.Channel getChannel(org.bukkit.entity.Player player)
player
- - the player.public int getProtocolVersion(org.bukkit.entity.Player player)
getProtocolVersion
in interface AbstractTinyProtocol
public void uninjectPlayer(org.bukkit.entity.Player player)
uninjectPlayer
in interface AbstractTinyProtocol
player
- - the injected player.public void uninjectChannel(io.netty.channel.Channel channel)
This will also disable the automatic channel injection that occurs when a player has properly logged in.
channel
- - the injected channel.public boolean hasInjected(org.bukkit.entity.Player player)
hasInjected
in interface AbstractTinyProtocol
player
- - the player.public boolean hasInjected(io.netty.channel.Channel channel)
channel
- - the channel.public final void close()
close
in interface AbstractTinyProtocol