Added a "canInject" property in the injectors.
Dieser Commit ist enthalten in:
Ursprung
d8b300e3a6
Commit
9e402a3ab4
@ -83,6 +83,13 @@ class NetworkFieldInjector extends PlayerInjector {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canInject() {
|
||||
// Probably
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectManager() {
|
||||
|
||||
|
@ -42,6 +42,14 @@ class NetworkObjectInjector extends PlayerInjector {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInject() {
|
||||
// We only support 1.3.0 at the moment. Fixing it require us to
|
||||
// add jMock, which would add another dependency.
|
||||
return networkManager != null &&
|
||||
networkManagerField.getType().isInterface();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectManager() {
|
||||
|
||||
|
@ -67,7 +67,7 @@ public final class PacketFilterManager implements ProtocolManager {
|
||||
/**
|
||||
* Override the network handler object itself.
|
||||
*/
|
||||
NETWORK_MANAGER_OBJECT
|
||||
NETWORK_MANAGER_OBJECT,
|
||||
}
|
||||
|
||||
// Create a concurrent set
|
||||
@ -362,16 +362,20 @@ public final class PacketFilterManager implements ProtocolManager {
|
||||
* @throws IllegalAccessException Unable to do our reflection magic.
|
||||
*/
|
||||
protected PlayerInjector getPlayerHookInstance(Player player) throws IllegalAccessException {
|
||||
|
||||
return getHookInstance(player, playerHook);
|
||||
}
|
||||
|
||||
// Helper
|
||||
private PlayerInjector getHookInstance(Player player, PlayerInjectHooks hook) throws IllegalAccessException {
|
||||
// Construct the correct player hook
|
||||
switch (playerHook) {
|
||||
switch (hook) {
|
||||
case NETWORK_HANDLER_FIELDS:
|
||||
return new NetworkFieldInjector(player, this, sendingFilters);
|
||||
case NETWORK_MANAGER_OBJECT:
|
||||
return new NetworkObjectInjector(player, this, sendingFilters);
|
||||
default:
|
||||
throw new IllegalArgumentException("Cannot construct a player injector.");
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("Cannot construct a player injector.");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -190,6 +190,12 @@ abstract class PlayerInjector {
|
||||
*/
|
||||
public abstract void cleanupAll();
|
||||
|
||||
/**
|
||||
* Determine if we actually can inject.
|
||||
* @return TRUE if this injector is compatible with the current CraftBukkit version, FALSE otherwise.
|
||||
*/
|
||||
public abstract boolean canInject();
|
||||
|
||||
/**
|
||||
* Allows a packet to be recieved by the listeners.
|
||||
* @param packet - packet to recieve.
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren