public class PlayerInjectionHandler
extends java.lang.Object
Constructor and Description |
---|
PlayerInjectionHandler(java.lang.ClassLoader classLoader,
ErrorReporter reporter,
com.google.common.base.Predicate<GamePhase> injectionFilter,
ListenerInvoker invoker,
java.util.Set<PacketListener> packetListeners,
org.bukkit.Server server) |
Modifier and Type | Method and Description |
---|---|
void |
addPacketHandler(int packetID)
Add an underlying packet handler of the given ID.
|
void |
checkListener(PacketListener listener)
Determine if a listener is valid or not.
|
void |
checkListener(java.util.Set<PacketListener> listeners)
Determine if the given listeners are valid.
|
void |
close() |
org.bukkit.entity.Player |
getPlayerByConnection(java.io.DataInputStream inputStream)
Retrieve a player by its DataInput connection.
|
PacketFilterManager.PlayerInjectHooks |
getPlayerHook()
Retrieves how the server packets are read.
|
PacketFilterManager.PlayerInjectHooks |
getPlayerHook(GamePhase phase)
Retrieves how the server packets are read.
|
java.util.Set<java.lang.Integer> |
getSendingFilters()
Retrieve the current list of registered sending listeners.
|
void |
handleDisconnect(org.bukkit.entity.Player player)
Invoke special routines for handling disconnect before a player is uninjected.
|
void |
injectPlayer(org.bukkit.entity.Player player)
Initialize a player hook, allowing us to read server packets.
|
boolean |
isInjectionNecessary(GamePhase phase)
Determine if it's truly necessary to perform the given player injection.
|
void |
processPacket(org.bukkit.entity.Player player,
net.minecraft.server.Packet mcPacket)
Process a packet as if it were sent by the given player.
|
void |
removePacketHandler(int packetID)
Remove an underlying packet handler of ths ID.
|
void |
scheduleDataInputRefresh(org.bukkit.entity.Player player)
Inform the current PlayerInjector that it should update the DataInputStream next.
|
void |
sendServerPacket(org.bukkit.entity.Player reciever,
PacketContainer packet,
boolean filters)
Send the given packet to the given reciever.
|
void |
setPlayerHook(GamePhase phase,
PacketFilterManager.PlayerInjectHooks playerHook)
Sets how the server packets are read.
|
void |
setPlayerHook(PacketFilterManager.PlayerInjectHooks playerHook)
Sets how the server packets are read.
|
boolean |
uninjectPlayer(java.net.InetSocketAddress address)
Unregisters a player by the given address.
|
boolean |
uninjectPlayer(org.bukkit.entity.Player player)
Unregisters the given player.
|
boolean |
uninjectPlayer(org.bukkit.entity.Player player,
boolean removeAuxiliary)
Unregisters the given player.
|
public PlayerInjectionHandler(java.lang.ClassLoader classLoader, ErrorReporter reporter, com.google.common.base.Predicate<GamePhase> injectionFilter, ListenerInvoker invoker, java.util.Set<PacketListener> packetListeners, org.bukkit.Server server)
public PacketFilterManager.PlayerInjectHooks getPlayerHook()
public PacketFilterManager.PlayerInjectHooks getPlayerHook(GamePhase phase)
phase
- - the current game phase.public void setPlayerHook(PacketFilterManager.PlayerInjectHooks playerHook)
playerHook
- - the new injection method for reading server packets.public void setPlayerHook(GamePhase phase, PacketFilterManager.PlayerInjectHooks playerHook)
phase
- - the current game phase.playerHook
- - the new injection method for reading server packets.public void addPacketHandler(int packetID)
packetID
- - packet ID to register.public void removePacketHandler(int packetID)
packetID
- - packet ID to unregister.public org.bukkit.entity.Player getPlayerByConnection(java.io.DataInputStream inputStream)
inputStream
- - the associated DataInput connection.public void injectPlayer(org.bukkit.entity.Player player)
This call will be ignored if there's no listener that can receive the given events.
player
- - player to hook.public boolean isInjectionNecessary(GamePhase phase)
phase
- - current game phase.public void handleDisconnect(org.bukkit.entity.Player player)
player
- - player to process.public boolean uninjectPlayer(org.bukkit.entity.Player player)
player
- - player to unregister.public boolean uninjectPlayer(org.bukkit.entity.Player player, boolean removeAuxiliary)
player
- - player to unregister.removeAuxiliary
- - TRUE to remove auxiliary information, such as input stream and address.public boolean uninjectPlayer(java.net.InetSocketAddress address)
If the server handler has been created before we've gotten a chance to unject the player, the method will try a workaround to remove the injected hook in the NetServerHandler.
address
- - address of the player to unregister.serverHandler
- - whether or not the net server handler has already been created.public void sendServerPacket(org.bukkit.entity.Player reciever, PacketContainer packet, boolean filters) throws java.lang.reflect.InvocationTargetException
reciever
- - the player receiver.packet
- - the packet to send.filters
- - whether or not to invoke the packet filters.java.lang.reflect.InvocationTargetException
- If an error occured during sending.public void processPacket(org.bukkit.entity.Player player, net.minecraft.server.Packet mcPacket) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
player
- - the sender.mcPacket
- - the packet to process.java.lang.IllegalAccessException
- If the reflection machinery failed.java.lang.reflect.InvocationTargetException
- If the underlying method caused an error.public void checkListener(java.util.Set<PacketListener> listeners)
listeners
- - listeners to check.public void checkListener(PacketListener listener)
If not, a warning will be printed to the console.
listener
- - listener to check.public java.util.Set<java.lang.Integer> getSendingFilters()
public void close()
public void scheduleDataInputRefresh(org.bukkit.entity.Player player)
player
- - the player to update.