[FEATURE] Fix for mac address for Dreamscape

This commit is contained in:
Emma Stone
2017-04-22 13:17:12 +01:00
parent 5b0fd906d5
commit 5779b6132e
9 changed files with 80 additions and 29 deletions
@@ -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";