mirror of
https://github.com/2006-Scape/Parabot-Randoms.git
synced 2026-10-01 10:27:27 +00:00
[FEATURE] Fix for mac address for Dreamscape
This commit is contained in:
@@ -2,11 +2,12 @@ package org.parabot.randoms;
|
|||||||
|
|
||||||
import org.parabot.core.Context;
|
import org.parabot.core.Context;
|
||||||
import org.parabot.environment.randoms.Random;
|
import org.parabot.environment.randoms.Random;
|
||||||
|
import org.parabot.randoms.dreamscape.MacAddressAvoider;
|
||||||
import org.parabot.randoms.dreamscape.SerialBanAvoider;
|
import org.parabot.randoms.dreamscape.SerialBanAvoider;
|
||||||
import org.parabot.randoms.elkoy.AntiDetector;
|
import org.parabot.randoms.elkoy.AntiDetector;
|
||||||
import org.parabot.randoms.elkoy.LogoutDisabler;
|
import org.parabot.randoms.elkoy.LogoutDisabler;
|
||||||
import org.parabot.randoms.elkoy.QuestionSolver;
|
|
||||||
import org.parabot.randoms.elkoy.MouseOnScreen;
|
import org.parabot.randoms.elkoy.MouseOnScreen;
|
||||||
|
import org.parabot.randoms.elkoy.QuestionSolver;
|
||||||
import org.parabot.randoms.pkhonor.*;
|
import org.parabot.randoms.pkhonor.*;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -28,6 +29,7 @@ public class Core {
|
|||||||
|
|
||||||
// Dreamscape
|
// Dreamscape
|
||||||
randoms.add(new SerialBanAvoider());
|
randoms.add(new SerialBanAvoider());
|
||||||
|
randoms.add(new MacAddressAvoider());
|
||||||
|
|
||||||
// Elkoy
|
// Elkoy
|
||||||
randoms.add(new QuestionSolver());
|
randoms.add(new QuestionSolver());
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package org.parabot.randoms.dreamscape;
|
||||||
|
|
||||||
|
import org.parabot.core.Context;
|
||||||
|
import org.parabot.environment.randoms.RandomType;
|
||||||
|
import org.parabot.randoms.utils.Reflection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author EmmaStone
|
||||||
|
*/
|
||||||
|
public class MacAddressAvoider implements org.parabot.environment.randoms.Random {
|
||||||
|
|
||||||
|
private static final String MAC_ADDRESS_FIELD = "MAC_ADDRESS";
|
||||||
|
private static final String MAC_ADDRESS_VALUE = "empty_mac";
|
||||||
|
|
||||||
|
private boolean done;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean activate() {
|
||||||
|
return !done;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
Reflection.workAroundStaticValues(Context.getInstance().getClient().getClass(), MAC_ADDRESS_FIELD, MAC_ADDRESS_VALUE);
|
||||||
|
done = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "Mac address avoider";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getServer() {
|
||||||
|
return "dreamscape";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RandomType getRandomType() {
|
||||||
|
return RandomType.ON_SERVER_START;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,9 +3,7 @@ package org.parabot.randoms.dreamscape;
|
|||||||
import org.parabot.core.Context;
|
import org.parabot.core.Context;
|
||||||
import org.parabot.environment.randoms.Random;
|
import org.parabot.environment.randoms.Random;
|
||||||
import org.parabot.environment.randoms.RandomType;
|
import org.parabot.environment.randoms.RandomType;
|
||||||
|
import org.parabot.randoms.utils.Reflection;
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.lang.reflect.Modifier;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author JKetelaar
|
* @author JKetelaar
|
||||||
@@ -24,24 +22,10 @@ public class SerialBanAvoider implements Random {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
try {
|
Reflection.workAroundStaticValues(Context.getInstance().getClient().getClass(), serialAddressField, serialAddressValue);
|
||||||
workAroundStaticValues(Context.getInstance().getClient().getClass(), serialAddressField, serialAddressValue);
|
|
||||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
done = true;
|
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
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "Serial ban avoider";
|
return "Serial ban avoider";
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package org.parabot.randoms.utils;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author EmmaStone
|
||||||
|
*/
|
||||||
|
public class Reflection {
|
||||||
|
|
||||||
|
public static void workAroundStaticValues(Class clazz, String fieldName, Object newValue) {
|
||||||
|
try {
|
||||||
|
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);
|
||||||
|
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user