public abstract class PlayerInjector extends Object implements SocketInjector
| Modifier and Type | Class and Description |
|---|---|
static class |
PlayerInjector.ServerHandlerNull
Indicates that a player's NetServerHandler or PlayerConnection was NULL.
|
| Constructor and Description |
|---|
PlayerInjector(ErrorReporter reporter,
org.bukkit.entity.Player player,
ListenerInvoker invoker) |
| Modifier and Type | Method and Description |
|---|---|
abstract boolean |
canInject(GamePhase state)
Determine if this inject method can even be attempted.
|
abstract com.comphenix.protocol.injector.player.UnsupportedListener |
checkListener(MinecraftVersion version,
PacketListener listener)
Invoked before a new listener is registered.
|
protected abstract void |
cleanHook()
Override to add custom cleanup behavior.
|
void |
cleanupAll()
Remove all hooks and modifications.
|
void |
disconnect(String message)
Attempt to disconnect the current client.
|
SocketAddress |
getAddress()
Retrieve the associated remote address of a player.
|
protected Object |
getEntityPlayer(org.bukkit.entity.Player player)
Retrieve the notch (NMS) entity player object.
|
abstract PlayerInjectHooks |
getHookType()
Retrieve the hook type this class represents.
|
DataInputStream |
getInputStream(boolean cache)
Retrieve the current player's input stream.
|
ListenerInvoker |
getInvoker()
Object that can invoke the packet events.
|
protected Object |
getNetHandler()
Retrieves the current net handler for this player.
|
protected Object |
getNetHandler(boolean refresh)
Retrieves the current net handler for this player.
|
Object |
getNetworkManager()
Retrieve the current network manager.
|
org.bukkit.entity.Player |
getPlayer()
Retrieve the hooked player.
|
Object |
getServerHandler()
Retrieve the current server handler (PlayerConnection).
|
Socket |
getSocket()
Retrieve the associated socket of this player.
|
org.bukkit.entity.Player |
getUpdatedPlayer()
Retrieve the hooked player object OR the more up-to-date player instance.
|
abstract void |
handleDisconnect()
Clean up after the player has disconnected.
|
Object |
handlePacketSending(Object packet)
Allows a packet to be sent by the listeners.
|
protected abstract boolean |
hasListener(int packetID)
Determine if the given injector is listening for this packet ID.
|
protected boolean |
hasProxyServerHandler()
Retrieve whether or not the server handler is a proxy object.
|
void |
initialize(Object injectionSource)
Initialize all fields for this player injector, if it hasn't already.
|
void |
initializeLogin(Object netLoginHandler)
Initialize the player injector from a NetLoginHandler.
|
void |
initializePlayer(org.bukkit.entity.Player player)
Initialize the player injector using an actual player instance.
|
abstract void |
injectManager()
Inject a hook to catch packets sent to the current player.
|
boolean |
isClean()
Determine whether or not this hook has already been cleaned.
|
void |
processPacket(Object packet)
Processes the given packet as if it was transmitted by the current player.
|
abstract void |
sendServerPacket(Object packet,
NetworkMarker marker,
boolean filtered)
Send a packet to the client.
|
void |
setNetworkManager(Object value,
boolean force)
Set the current network manager.
|
void |
setPlayer(org.bukkit.entity.Player player)
Set the hooked player.
|
void |
setUpdatedPlayer(org.bukkit.entity.Player updatedPlayer)
Set the real Bukkit player that we will use.
|
void |
transferState(SocketInjector delegate)
Invoked when a delegated socket injector transfers the state of one injector to the next.
|
public static final ReportType REPORT_ASSUME_DISCONNECT_METHOD
public static final ReportType REPORT_INVALID_ARGUMENT_DISCONNECT
public static final ReportType REPORT_CANNOT_ACCESS_DISCONNECT
public static final ReportType REPORT_CANNOT_CLOSE_SOCKET
public static final ReportType REPORT_ACCESS_DENIED_CLOSE_SOCKET
public static final ReportType REPORT_DETECTED_CUSTOM_SERVER_HANDLER
public static final ReportType REPORT_CANNOT_PROXY_SERVER_HANDLER
public static final ReportType REPORT_CANNOT_UPDATE_PLAYER
public static final ReportType REPORT_CANNOT_HANDLE_PACKET
public static final ReportType REPORT_INVALID_NETWORK_MANAGER
protected static Field serverHandlerField
protected static Field proxyServerField
protected static Field networkManagerField
protected static Field netHandlerField
protected static Field socketField
protected static Field socketAddressField
protected static StructureModifier<Object> networkModifier
protected static Method queueMethod
protected static Method processMethod
protected volatile org.bukkit.entity.Player player
protected boolean hasInitialized
protected VolatileField networkManagerRef
protected VolatileField serverHandlerRef
protected Object networkManager
protected Object loginHandler
protected Object serverHandler
protected Object netHandler
protected Socket socket
protected SocketAddress socketAddress
protected ListenerInvoker invoker
protected DataInputStream cachedInput
protected ErrorReporter reporter
protected Map<Object,NetworkMarker> queuedMarkers
protected InterceptWritePacket writePacketInterceptor
public PlayerInjector(ErrorReporter reporter, org.bukkit.entity.Player player, ListenerInvoker invoker)
protected Object getEntityPlayer(org.bukkit.entity.Player player)
player - - the player to retrieve.public void initialize(Object injectionSource) throws IllegalAccessException
injectionSource - - Injection sourceIllegalAccessException - An error has occured.public void initializePlayer(org.bukkit.entity.Player player)
player - - the player to hook.public void initializeLogin(Object netLoginHandler)
netLoginHandler - - the net login handler to inject.protected boolean hasProxyServerHandler()
public Object getNetworkManager()
public Object getServerHandler()
public void setNetworkManager(Object value, boolean force)
value - - new network manager.force - - whether or not to save this value.public Socket getSocket() throws IllegalAccessException
getSocket in interface SocketInjectorIllegalAccessException - If we're unable to read the socket field.public SocketAddress getAddress() throws IllegalAccessException
getAddress in interface SocketInjectorIllegalAccessException - If we're unable to read the socket address field.public void disconnect(String message) throws InvocationTargetException
disconnect in interface SocketInjectormessage - - the message to display.InvocationTargetException - If disconnection failed.protected Object getNetHandler() throws IllegalAccessException
IllegalAccessException - Unable to find or retrieve net handler.protected Object getNetHandler(boolean refresh) throws IllegalAccessException
refresh - - Whether or not to refreshIllegalAccessException - Unable to find or retrieve net handler.public void processPacket(Object packet) throws IllegalAccessException, InvocationTargetException
packet - - packet to process.IllegalAccessException - If the reflection machinery failed.InvocationTargetException - If the underlying method caused an error.public abstract void sendServerPacket(Object packet, NetworkMarker marker, boolean filtered) throws InvocationTargetException
sendServerPacket in interface SocketInjectorpacket - - server packet to send.marker - - the network marker.filtered - - whether or not the packet will be filtered by our listeners.InvocationTargetException - If an error occured when sending the packet.public abstract void injectManager()
public final void cleanupAll()
public abstract void handleDisconnect()
protected abstract void cleanHook()
public boolean isClean()
public abstract boolean canInject(GamePhase state)
state - - Game phasepublic abstract PlayerInjectHooks getHookType()
public abstract com.comphenix.protocol.injector.player.UnsupportedListener checkListener(MinecraftVersion version, PacketListener listener)
The player injector should only return a non-null value if some or all of the packet IDs are unsupported.
version - - the current Minecraft version, or NULL if unknown.listener - - the listener that is about to be registered.public Object handlePacketSending(Object packet)
packet - - packet to sent.protected abstract boolean hasListener(int packetID)
packetID - - packet ID to check.public DataInputStream getInputStream(boolean cache)
cache - - whether or not to cache the result of this method.public org.bukkit.entity.Player getPlayer()
getPlayer in interface SocketInjectorpublic void setPlayer(org.bukkit.entity.Player player)
Should only be called during the creation of the injector.
player - - the new hooked player.public ListenerInvoker getInvoker()
public org.bukkit.entity.Player getUpdatedPlayer()
getUpdatedPlayer in interface SocketInjectorpublic void transferState(SocketInjector delegate)
SocketInjectortransferState in interface SocketInjectordelegate - - the new injector.public void setUpdatedPlayer(org.bukkit.entity.Player updatedPlayer)
SocketInjectorsetUpdatedPlayer in interface SocketInjectorupdatedPlayer - - the real Bukkit player.Copyright © 2012–2017 Comphenix and dmulloy2. Licensed under the GNU GPL v2.