mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2024-11-28 13:45:22 +01:00
It's an injector container.
This commit is contained in:
parent
c32d225ef3
commit
c7737ca96e
@ -110,8 +110,8 @@ public abstract class AbstractInputStreamLookup {
|
|||||||
Player player = previous.getPlayer();
|
Player player = previous.getPlayer();
|
||||||
|
|
||||||
// Default implementation
|
// Default implementation
|
||||||
if (player instanceof InjectContainer) {
|
if (player instanceof InjectorContainer) {
|
||||||
InjectContainer container = (InjectContainer) player;
|
InjectorContainer container = (InjectorContainer) player;
|
||||||
container.setInjector(current);
|
container.setInjector(current);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ package com.comphenix.protocol.injector.server;
|
|||||||
* A necessary hack.
|
* A necessary hack.
|
||||||
* @author Kristian
|
* @author Kristian
|
||||||
*/
|
*/
|
||||||
class InjectContainer {
|
class InjectorContainer {
|
||||||
private volatile SocketInjector injector;
|
private volatile SocketInjector injector;
|
||||||
|
|
||||||
public SocketInjector getInjector() {
|
public SocketInjector getInjector() {
|
@ -53,8 +53,8 @@ public class TemporaryPlayerFactory {
|
|||||||
* @return The referenced player injector, or NULL if none can be found.
|
* @return The referenced player injector, or NULL if none can be found.
|
||||||
*/
|
*/
|
||||||
public static SocketInjector getInjectorFromPlayer(Player player) {
|
public static SocketInjector getInjectorFromPlayer(Player player) {
|
||||||
if (player instanceof InjectContainer) {
|
if (player instanceof InjectorContainer) {
|
||||||
return ((InjectContainer) player).getInjector();
|
return ((InjectorContainer) player).getInjector();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -65,7 +65,7 @@ public class TemporaryPlayerFactory {
|
|||||||
* @param injector - the injector to store.
|
* @param injector - the injector to store.
|
||||||
*/
|
*/
|
||||||
public static void setInjectorInPlayer(Player player, SocketInjector injector) {
|
public static void setInjectorInPlayer(Player player, SocketInjector injector) {
|
||||||
((InjectContainer) player).setInjector(injector);
|
((InjectorContainer) player).setInjector(injector);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -96,7 +96,7 @@ public class TemporaryPlayerFactory {
|
|||||||
public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
|
public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
|
||||||
|
|
||||||
String methodName = method.getName();
|
String methodName = method.getName();
|
||||||
SocketInjector injector = ((InjectContainer) obj).getInjector();
|
SocketInjector injector = ((InjectorContainer) obj).getInjector();
|
||||||
|
|
||||||
if (injector == null)
|
if (injector == null)
|
||||||
throw new IllegalStateException("Unable to find injector.");
|
throw new IllegalStateException("Unable to find injector.");
|
||||||
@ -149,7 +149,7 @@ public class TemporaryPlayerFactory {
|
|||||||
public int accept(Method method) {
|
public int accept(Method method) {
|
||||||
// Do not override the object method or the superclass methods
|
// Do not override the object method or the superclass methods
|
||||||
if (method.getDeclaringClass().equals(Object.class) ||
|
if (method.getDeclaringClass().equals(Object.class) ||
|
||||||
method.getDeclaringClass().equals(InjectContainer.class))
|
method.getDeclaringClass().equals(InjectorContainer.class))
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
return 1;
|
return 1;
|
||||||
@ -159,7 +159,7 @@ public class TemporaryPlayerFactory {
|
|||||||
|
|
||||||
// CGLib is amazing
|
// CGLib is amazing
|
||||||
Enhancer ex = new Enhancer();
|
Enhancer ex = new Enhancer();
|
||||||
ex.setSuperclass(InjectContainer.class);
|
ex.setSuperclass(InjectorContainer.class);
|
||||||
ex.setInterfaces(new Class[] { Player.class });
|
ex.setInterfaces(new Class[] { Player.class });
|
||||||
ex.setCallbacks(new Callback[] { NoOp.INSTANCE, implementation });
|
ex.setCallbacks(new Callback[] { NoOp.INSTANCE, implementation });
|
||||||
ex.setCallbackFilter(callbackFilter);
|
ex.setCallbackFilter(callbackFilter);
|
||||||
@ -176,7 +176,7 @@ public class TemporaryPlayerFactory {
|
|||||||
public Player createTemporaryPlayer(Server server, SocketInjector injector) {
|
public Player createTemporaryPlayer(Server server, SocketInjector injector) {
|
||||||
Player temporary = createTemporaryPlayer(server);
|
Player temporary = createTemporaryPlayer(server);
|
||||||
|
|
||||||
((InjectContainer) temporary).setInjector(injector);
|
((InjectorContainer) temporary).setInjector(injector);
|
||||||
return temporary;
|
return temporary;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user