Fix some disguise methods not working
This commit is contained in:
parent
4bc046f4e3
commit
43aa37a9ec
@ -18,4 +18,10 @@ public class WatcherMethod {
|
|||||||
private final Class returnType;
|
private final Class returnType;
|
||||||
private final Class param;
|
private final Class param;
|
||||||
private final boolean randomDefault;
|
private final boolean randomDefault;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "WatcherMethod{" + "watcherClass=" + watcherClass + ", method=" + method + ", name='" + name + '\'' + ", returnType=" + returnType + ", param=" +
|
||||||
|
param + ", randomDefault=" + randomDefault + '}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import me.libraryaddict.disguise.disguisetypes.Disguise;
|
|||||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||||
import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
|
import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.watchers.PlayerWatcher;
|
||||||
import me.libraryaddict.disguise.utilities.params.ParamInfoManager;
|
import me.libraryaddict.disguise.utilities.params.ParamInfoManager;
|
||||||
import me.libraryaddict.disguise.utilities.parser.WatcherMethod;
|
import me.libraryaddict.disguise.utilities.parser.WatcherMethod;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||||
@ -106,7 +107,8 @@ public class DisguiseMethods {
|
|||||||
|
|
||||||
methods.add(m);
|
methods.add(m);
|
||||||
|
|
||||||
if (m.getName().startsWith("get") || m.getName().startsWith("has") || param == null || param == Void.TYPE || ParamInfoManager.getParamInfo(m) == null) {
|
if (m.getName().startsWith("get") || m.getName().startsWith("has") || param == null || param == Void.TYPE ||
|
||||||
|
ParamInfoManager.getParamInfo(m) == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,6 +124,7 @@ public class DisguiseMethods {
|
|||||||
try {
|
try {
|
||||||
Class cl = boolean.class;
|
Class cl = boolean.class;
|
||||||
Class disguiseClass = Disguise.class;
|
Class disguiseClass = Disguise.class;
|
||||||
|
boolean randomDefault = false;
|
||||||
|
|
||||||
switch (methodName) {
|
switch (methodName) {
|
||||||
case "setExpires":
|
case "setExpires":
|
||||||
@ -136,8 +139,9 @@ public class DisguiseMethods {
|
|||||||
case "setBossBarStyle":
|
case "setBossBarStyle":
|
||||||
cl = BarStyle.class;
|
cl = BarStyle.class;
|
||||||
break;
|
break;
|
||||||
case "setSoundGroup":
|
|
||||||
case "setDisguiseName":
|
case "setDisguiseName":
|
||||||
|
randomDefault = true;
|
||||||
|
case "setSoundGroup":
|
||||||
cl = String.class;
|
cl = String.class;
|
||||||
break;
|
break;
|
||||||
case "setDeadmau5Ears":
|
case "setDeadmau5Ears":
|
||||||
@ -151,9 +155,20 @@ public class DisguiseMethods {
|
|||||||
try {
|
try {
|
||||||
WatcherMethod method = new WatcherMethod(disguiseClass,
|
WatcherMethod method = new WatcherMethod(disguiseClass,
|
||||||
MethodHandles.publicLookup().findVirtual(disguiseClass, methodName, MethodType.methodType(returnType, cl)), methodName,
|
MethodHandles.publicLookup().findVirtual(disguiseClass, methodName, MethodType.methodType(returnType, cl)), methodName,
|
||||||
null, cl, false);
|
null, cl, randomDefault);
|
||||||
|
|
||||||
methods.add(method);
|
methods.add(method);
|
||||||
|
|
||||||
|
watcherMethods.computeIfAbsent(disguiseClass == Disguise.class ? FlagWatcher.class : PlayerWatcher.class, (a) -> new ArrayList<>())
|
||||||
|
.add(method);
|
||||||
|
|
||||||
|
String getName = (cl == boolean.class ? "is" : "get") + methodName.substring(3);
|
||||||
|
|
||||||
|
WatcherMethod getMethod = new WatcherMethod(disguiseClass,
|
||||||
|
MethodHandles.publicLookup().findVirtual(disguiseClass, getName, MethodType.methodType(cl)), getName, cl, null,
|
||||||
|
randomDefault);
|
||||||
|
|
||||||
|
methods.add(getMethod);
|
||||||
break;
|
break;
|
||||||
} catch (NoSuchMethodException ex) {
|
} catch (NoSuchMethodException ex) {
|
||||||
if (returnType == disguiseClass) {
|
if (returnType == disguiseClass) {
|
||||||
|
Loading…
Reference in New Issue
Block a user