mirror of
https://github.com/2006-Scape/Parabot-Randoms.git
synced 2026-07-05 00:37:58 +00:00
[FEATURE] Fix for mac address for Dreamscape
This commit is contained in:
@@ -3,9 +3,7 @@ package org.parabot.randoms.dreamscape;
|
||||
import org.parabot.core.Context;
|
||||
import org.parabot.environment.randoms.Random;
|
||||
import org.parabot.environment.randoms.RandomType;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import org.parabot.randoms.utils.Reflection;
|
||||
|
||||
/**
|
||||
* @author JKetelaar
|
||||
@@ -24,24 +22,10 @@ public class SerialBanAvoider implements Random {
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
try {
|
||||
workAroundStaticValues(Context.getInstance().getClient().getClass(), serialAddressField, serialAddressValue);
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Reflection.workAroundStaticValues(Context.getInstance().getClient().getClass(), serialAddressField, serialAddressValue);
|
||||
done = true;
|
||||
}
|
||||
|
||||
private void workAroundStaticValues(Class clazz, String fieldName, Object newValue) throws NoSuchFieldException, IllegalAccessException {
|
||||
Field field = clazz.getDeclaredField(fieldName);
|
||||
field.setAccessible(true);
|
||||
Field modifiers = field.getClass().getDeclaredField("modifiers");
|
||||
modifiers.setAccessible(true);
|
||||
modifiers.setInt(field, field.getModifiers() & ~Modifier.FINAL);
|
||||
field.set(null, newValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Serial ban avoider";
|
||||
|
||||
Reference in New Issue
Block a user