18045010223
2025-07-07 0d3a683a0c97154b1f2e6657398664537e4e3e82
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package org.yzh.client.netty;
 
import io.github.yezhihao.netmc.core.model.Message;
 
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
 
public class Handler {
 
    private Object targetObject;
    private Method targetMethod;
    private String desc;
 
    public Handler(Object actionClass, Method actionMethod, String desc) {
        this.targetObject = actionClass;
        this.targetMethod = actionMethod;
        this.desc = desc;
    }
 
    public Handler(Object targetObject, Method actionMethod) {
        this.targetObject = targetObject;
        this.targetMethod = actionMethod;
    }
 
    public <T extends Message> T invoke(Object... args) throws InvocationTargetException, IllegalAccessException {
        return (T) targetMethod.invoke(targetObject, args);
    }
 
    @Override
    public String toString() {
        return desc;
    }
}