mirror of
https://github.com/2006-Scape/Parabot-Randoms.git
synced 2026-07-07 08:39:13 +00:00
Merge pull request #28 from Parabot/development
[MERGE] Development into master
This commit is contained in:
@@ -3,6 +3,10 @@ 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.SerialBanAvoider;
|
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.pkhonor.*;
|
import org.parabot.randoms.pkhonor.*;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -20,11 +24,16 @@ public class Core {
|
|||||||
randoms.add(new SandwichLady());
|
randoms.add(new SandwichLady());
|
||||||
randoms.add(new MysteriousOldMan());
|
randoms.add(new MysteriousOldMan());
|
||||||
randoms.add(new BobsIsland());
|
randoms.add(new BobsIsland());
|
||||||
randoms.add(new PacketBlockInterceptor());
|
|
||||||
|
|
||||||
// Dreamscape
|
// Dreamscape
|
||||||
randoms.add(new SerialBanAvoider());
|
randoms.add(new SerialBanAvoider());
|
||||||
|
|
||||||
|
// Elkoy
|
||||||
|
//randoms.add(new QuestionSolver());
|
||||||
|
randoms.add(new LogoutDisabler());
|
||||||
|
randoms.add(new MouseOnScreen());
|
||||||
|
randoms.add(new AntiDetector());
|
||||||
|
|
||||||
org.parabot.core.Core.verbose("Possible randoms:");
|
org.parabot.core.Core.verbose("Possible randoms:");
|
||||||
for (Random random : randoms) {
|
for (Random random : randoms) {
|
||||||
if (random.getServer().equalsIgnoreCase(server)) {
|
if (random.getServer().equalsIgnoreCase(server)) {
|
||||||
|
|||||||
@@ -0,0 +1,83 @@
|
|||||||
|
package org.parabot.randoms.elkoy;
|
||||||
|
|
||||||
|
import org.parabot.core.Context;
|
||||||
|
import org.parabot.core.reflect.RefClass;
|
||||||
|
import org.parabot.core.reflect.RefField;
|
||||||
|
import org.parabot.environment.api.utils.Time;
|
||||||
|
import org.parabot.environment.randoms.Random;
|
||||||
|
import org.parabot.environment.randoms.RandomType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author JKetelaar, Empathy, Ethan
|
||||||
|
*/
|
||||||
|
public class AntiDetector implements Random, Runnable {
|
||||||
|
|
||||||
|
private boolean activated;
|
||||||
|
|
||||||
|
private final String[] toBeNull = {"P", "Q", "N"};
|
||||||
|
private final String className = "cb";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean activate() {
|
||||||
|
return !activated;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
activated = true;
|
||||||
|
|
||||||
|
new Thread(this).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "Anti Bot Detector";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getServer() {
|
||||||
|
return "Elkoy";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RandomType getRandomType() {
|
||||||
|
return RandomType.ON_SERVER_START;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
while (activated) {
|
||||||
|
try {
|
||||||
|
final RefClass refClass = new RefClass(Context.getInstance().getASMClassLoader().loadClass(className));
|
||||||
|
|
||||||
|
for (RefField refField : refClass.getFields()) {
|
||||||
|
if (refField != null) {
|
||||||
|
if (refClass.isStatic()) {
|
||||||
|
if (refField.getType().getName().equalsIgnoreCase("boolean")) {
|
||||||
|
refField.set(false);
|
||||||
|
} else if (refField.getType().getName().equalsIgnoreCase("int")) {
|
||||||
|
int i = (int) refField.asObject();
|
||||||
|
if (i >= 0) {
|
||||||
|
refField.set(-1);
|
||||||
|
}
|
||||||
|
} else if (refField.getType().getName().equalsIgnoreCase("string")) {
|
||||||
|
String str = (String) refField.asObject();
|
||||||
|
if (str.length() > 0) {
|
||||||
|
refField.set(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String s : toBeNull) {
|
||||||
|
refClass.getField(s).set(null);
|
||||||
|
}
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
Time.sleep(25);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package org.parabot.randoms.elkoy;
|
||||||
|
|
||||||
|
import org.parabot.environment.api.utils.Time;
|
||||||
|
import org.parabot.environment.input.Keyboard;
|
||||||
|
import org.parabot.environment.randoms.RandomType;
|
||||||
|
import org.rev317.min.api.methods.Game;
|
||||||
|
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author EmmaStone
|
||||||
|
*/
|
||||||
|
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 Random random = new Random();
|
||||||
|
private long ms = System.currentTimeMillis();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean activate() {
|
||||||
|
return Game.isLoggedIn() && (System.currentTimeMillis() - ms) / 1000 > random.nextInt((50 - 30) + 1) + 30;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
int keyCode = KEYS[random.nextInt(KEYS.length)];
|
||||||
|
Keyboard.getInstance().pressKey(keyCode);
|
||||||
|
Time.sleep(random.nextInt((20 - 5) + 1) + 5);
|
||||||
|
Keyboard.getInstance().releaseKey(keyCode);
|
||||||
|
|
||||||
|
ms = System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "Logout Disabler";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getServer() {
|
||||||
|
return "Elkoy";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RandomType getRandomType() {
|
||||||
|
return RandomType.SCRIPT;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package org.parabot.randoms.elkoy;
|
||||||
|
|
||||||
|
import org.parabot.core.Context;
|
||||||
|
import org.parabot.environment.input.Mouse;
|
||||||
|
import org.parabot.environment.randoms.Random;
|
||||||
|
import org.parabot.environment.randoms.RandomType;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author JKetelaar, Fryslan
|
||||||
|
*/
|
||||||
|
public class MouseOnScreen implements Random {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean activate() {
|
||||||
|
return !onScreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
int x = org.parabot.environment.api.utils.Random.between(100, Context.getInstance().getApplet().getWidth());
|
||||||
|
int y = org.parabot.environment.api.utils.Random.between(100, Context.getInstance().getApplet().getHeight());
|
||||||
|
|
||||||
|
Mouse.getInstance().moveMouse(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "Mouse on screen";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getServer() {
|
||||||
|
return "Elkoy";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RandomType getRandomType() {
|
||||||
|
return RandomType.SCRIPT;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean onScreen() {
|
||||||
|
Point loc = Mouse.getInstance().getPoint();
|
||||||
|
return Context.getInstance().getApplet().contains(loc);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
package org.parabot.randoms.elkoy;
|
||||||
|
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
import org.json.simple.parser.ParseException;
|
||||||
|
import org.parabot.api.io.WebUtil;
|
||||||
|
import org.parabot.core.Context;
|
||||||
|
import org.parabot.core.ui.Logger;
|
||||||
|
import org.parabot.environment.api.utils.Time;
|
||||||
|
import org.parabot.environment.input.Keyboard;
|
||||||
|
import org.parabot.environment.randoms.Random;
|
||||||
|
import org.parabot.environment.randoms.RandomType;
|
||||||
|
import org.parabot.environment.scripts.Script;
|
||||||
|
import org.parabot.environment.scripts.framework.SleepCondition;
|
||||||
|
import org.rev317.min.Loader;
|
||||||
|
import org.rev317.min.api.methods.Game;
|
||||||
|
import org.rev317.min.api.methods.Interfaces;
|
||||||
|
import org.rev317.min.api.methods.Menu;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author EmmaStone
|
||||||
|
*/
|
||||||
|
public class QuestionSolver implements Random {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean activate() {
|
||||||
|
return Game.isLoggedIn() && Interfaces.getBackDialogId() == 368;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
String message = Loader.getClient().getInterfaceCache()[371].getMessage();
|
||||||
|
if (!message.contains("otherwise you will be teleported")) {
|
||||||
|
message = message.replace("@dre@ ", "");
|
||||||
|
|
||||||
|
Logger.addMessage("Contacting server to get an answer", false);
|
||||||
|
String answer = getAnswer(message);
|
||||||
|
|
||||||
|
if (answer == null) {
|
||||||
|
Logger.addMessage("Could not solve the question, please report this question (and the possible answer) on the forums", true);
|
||||||
|
Logger.addMessage("Question: " + message, true);
|
||||||
|
forceRelog();
|
||||||
|
Logger.addMessage("Logged account out for security measures", true);
|
||||||
|
Context.getInstance().getRunningScript().setState(Script.STATE_STOPPED);
|
||||||
|
} else {
|
||||||
|
Logger.addMessage("Answer found, now trying: " + answer, false);
|
||||||
|
Menu.sendAction(679, -1, -1, 373);
|
||||||
|
Time.sleep(1000);
|
||||||
|
Keyboard.getInstance().sendKeys(answer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Time.sleep(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getAnswer(String question) {
|
||||||
|
try {
|
||||||
|
JSONObject object = (JSONObject) WebUtil.getJsonParser().parse(WebUtil.getContents("http://bdn.parabot.org/api/v2/data/questions/get",
|
||||||
|
"server=ikov&question=" + URLEncoder.encode(question, "UTF-8"))); //TODO Implement BDN V3
|
||||||
|
JSONObject result;
|
||||||
|
if ((result = (JSONObject) object.get("result")) != null) {
|
||||||
|
Object answer;
|
||||||
|
if ((answer = result.get("answer")) != null) {
|
||||||
|
return (String) answer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (MalformedURLException | UnsupportedEncodingException | ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void forceRelog() {
|
||||||
|
Logger.addMessage("Logging out...", false);
|
||||||
|
Loader.getClient().dropClient();
|
||||||
|
Time.sleep(new SleepCondition() {
|
||||||
|
@Override
|
||||||
|
public boolean isValid() {
|
||||||
|
return !Game.isLoggedIn();
|
||||||
|
}
|
||||||
|
}, 5000);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "Question Solver";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getServer() {
|
||||||
|
return "Elkoy";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RandomType getRandomType() {
|
||||||
|
return RandomType.SCRIPT;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,6 +20,7 @@ public class BanFile implements Random {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,7 +31,6 @@ public class BanFile implements Random {
|
|||||||
banfile.delete();
|
banfile.delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -55,6 +55,7 @@ public class BanFile implements Random {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,9 +16,6 @@ public class BobsIsland implements Random {
|
|||||||
private static final Tile center = new Tile(2525, 4777);
|
private static final Tile center = new Tile(2525, 4777);
|
||||||
private static final int portalId = 8987;
|
private static final int portalId = 8987;
|
||||||
|
|
||||||
public BobsIsland() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean activate() {
|
public boolean activate() {
|
||||||
return center.distanceTo() < 25;
|
return center.distanceTo() < 25;
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ public class Jail implements Random {
|
|||||||
this.jailer = getJailer();
|
this.jailer = getJailer();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return false;
|
return false;
|
||||||
@@ -91,6 +92,7 @@ public class Jail implements Random {
|
|||||||
return jailer;
|
return jailer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,6 +102,7 @@ public class Jail implements Random {
|
|||||||
return rock;
|
return rock;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ public class MysteriousOldMan implements Random {
|
|||||||
return man;
|
return man;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,47 +0,0 @@
|
|||||||
package org.parabot.randoms.pkhonor;
|
|
||||||
|
|
||||||
import org.parabot.core.reflect.RefClass;
|
|
||||||
import org.parabot.core.reflect.RefField;
|
|
||||||
import org.parabot.environment.randoms.Random;
|
|
||||||
import org.parabot.environment.randoms.RandomType;
|
|
||||||
import org.rev317.min.Loader;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author EmmaStone
|
|
||||||
*/
|
|
||||||
public class PacketBlockInterceptor implements Random {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean activate() {
|
|
||||||
return !getField();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute() {
|
|
||||||
setField();
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean getField() {
|
|
||||||
return new RefClass(Loader.getClient()).getField("PG").asBoolean();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setField() {
|
|
||||||
RefField refField = new RefClass(Loader.getClient()).getField("PG");
|
|
||||||
refField.set(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return "Packet Block Interceptor";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getServer() {
|
|
||||||
return "pkhonor";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public RandomType getRandomType() {
|
|
||||||
return RandomType.SCRIPT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -41,6 +41,7 @@ public class SandwichLady implements Random {
|
|||||||
return lady;
|
return lady;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,23 +17,28 @@ public class TriangleSandwich implements Random {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean activate() {
|
public boolean activate() {
|
||||||
|
if (Inventory.getItems() != null) {
|
||||||
for (Item i : Inventory.getItems(id)) {
|
for (Item i : Inventory.getItems(id)) {
|
||||||
if (i != null) {
|
if (i != null) {
|
||||||
this.item = i;
|
this.item = i;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
if (this.item != null) {
|
if (this.item != null) {
|
||||||
|
final int sandwich = Inventory.getCount(id);
|
||||||
item.drop();
|
item.drop();
|
||||||
Time.sleep(new SleepCondition() {
|
Time.sleep(new SleepCondition() {
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid() {
|
public boolean isValid() {
|
||||||
return Inventory.getCount(id) == 0;
|
return Inventory.getCount(id) != sandwich;
|
||||||
}
|
}
|
||||||
}, 1500);
|
}, 1500);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user