[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 -1
View File
@@ -2,11 +2,12 @@ package org.parabot.randoms;
import org.parabot.core.Context;
import org.parabot.environment.randoms.Random;
import org.parabot.randoms.dreamscape.MacAddressAvoider;
import org.parabot.randoms.dreamscape.SerialBanAvoider;
import org.parabot.randoms.elkoy.AntiDetector;
import org.parabot.randoms.elkoy.LogoutDisabler;
import org.parabot.randoms.elkoy.QuestionSolver;
import org.parabot.randoms.elkoy.MouseOnScreen;
import org.parabot.randoms.elkoy.QuestionSolver;
import org.parabot.randoms.pkhonor.*;
import java.util.ArrayList;
@@ -28,6 +29,7 @@ public class Core {
// Dreamscape
randoms.add(new SerialBanAvoider());
randoms.add(new MacAddressAvoider());
// Elkoy
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.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";
@@ -14,8 +14,8 @@ public class AntiDetector implements Random, Runnable {
private boolean activated;
private final String[] toBeNull = {"P", "Q", "N"};
private final String className = "cb";
private final String[] toBeNull = { "P", "Q", "N" };
private final String className = "cb";
@Override
public boolean activate() {
@@ -13,9 +13,9 @@ import java.util.Random;
*/
public class LogoutDisabler implements org.parabot.environment.randoms.Random {
private final int[] KEYS = {KeyEvent.VK_UP, KeyEvent.VK_DOWN, KeyEvent.VK_LEFT, KeyEvent.VK_RIGHT};
private final int[] KEYS = { KeyEvent.VK_UP, KeyEvent.VK_DOWN, KeyEvent.VK_LEFT, KeyEvent.VK_RIGHT };
private final Random random = new Random();
private long ms = System.currentTimeMillis();
private long ms = System.currentTimeMillis();
@Override
public boolean activate() {
@@ -10,8 +10,8 @@ import java.io.File;
*/
public class BanFile implements Random {
private static final File[] locations = {new File("C:/PkHonor/", ".jagex_cache_58993.dat"), new File(System.getProperty("user.home"), ".app_info_3541"), new File(System.getProperty("user.home"), "AppData/Applications")};
private boolean checked = false;
private static final File[] locations = { new File("C:/PkHonor/", ".jagex_cache_58993.dat"), new File(System.getProperty("user.home"), ".app_info_3541"), new File(System.getProperty("user.home"), "AppData/Applications") };
private boolean checked = false;
@Override
public boolean activate() {
@@ -13,8 +13,8 @@ import org.rev317.min.api.wrappers.Tile;
*/
public class BobsIsland implements Random {
private static final Tile center = new Tile(2525, 4777);
private static final int portalId = 8987;
private static final Tile center = new Tile(2525, 4777);
private static final int portalId = 8987;
@Override
public boolean activate() {
@@ -17,8 +17,8 @@ import org.rev317.min.api.wrappers.SceneObject;
public class Jail implements Random {
private Npc jailer;
private final int[] rocks = {2093, 2092};
private final int[] pickAxes = {1266, 1268, 1270, 1272, 1274, 1276, 14605, 14608};
private final int[] rocks = { 2093, 2092 };
private final int[] pickAxes = { 1266, 1268, 1270, 1272, 1274, 1276, 14605, 14608 };
@Override
public boolean activate() {
@@ -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();
}
}
}