mirror of
https://github.com/2006-Scape/Parabot-Randoms.git
synced 2026-07-03 00:38:07 +00:00
[CLEANUP] Removed Ikov randoms
This commit is contained in:
@@ -1,62 +0,0 @@
|
||||
package org.parabot.randoms.ikov;
|
||||
|
||||
import org.parabot.environment.api.utils.Time;
|
||||
import org.parabot.environment.input.Mouse;
|
||||
import org.parabot.environment.scripts.framework.SleepCondition;
|
||||
import org.parabot.environment.scripts.randoms.Random;
|
||||
import org.rev317.min.api.methods.Game;
|
||||
|
||||
/**
|
||||
* @author JKetelaar
|
||||
*/
|
||||
public class Login implements Random {
|
||||
|
||||
private static int timer = 0;
|
||||
|
||||
@Override
|
||||
public boolean activate() {
|
||||
return System.currentTimeMillis() - timer > 0 && !Game.isLoggedIn();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
timer = 0;
|
||||
|
||||
// Move and click mouse on the login button
|
||||
Mouse.getInstance().moveMouse(380, 320);
|
||||
Mouse.getInstance().click(380, 320, true);
|
||||
|
||||
Time.sleep(new SleepCondition() {
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return Game.isLoggedIn();
|
||||
}
|
||||
}, 4500);
|
||||
if (Game.isLoggedIn()) {
|
||||
/* Sleep to let the client load their objects and players */
|
||||
Time.sleep(5000);
|
||||
}else{
|
||||
// Move and click mouse on the close button
|
||||
Mouse.getInstance().moveMouse(515, 130);
|
||||
Mouse.getInstance().click(515, 130, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Login";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServer() {
|
||||
return "Ikov";
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param timeOut seconds
|
||||
*/
|
||||
public static void setTimer(int timeOut){
|
||||
timer = ((int) System.currentTimeMillis() + (timeOut * 1000));
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package org.parabot.randoms.ikov;
|
||||
|
||||
import org.parabot.environment.api.utils.Time;
|
||||
import org.parabot.environment.input.Keyboard;
|
||||
import org.parabot.environment.scripts.randoms.Random;
|
||||
import org.rev317.min.api.methods.Game;
|
||||
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
/**
|
||||
* @author JKetelaar
|
||||
*/
|
||||
public class LogoutDisabler implements Random {
|
||||
|
||||
private final int[] keys = {KeyEvent.VK_UP, KeyEvent.VK_DOWN, KeyEvent.VK_LEFT, KeyEvent.VK_RIGHT};
|
||||
private final java.util.Random random = new java.util.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 "Ikov";
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
package org.parabot.randoms.ikov;
|
||||
|
||||
import org.parabot.core.ui.Logger;
|
||||
import org.parabot.environment.scripts.randoms.Random;
|
||||
import org.rev317.min.api.events.MessageEvent;
|
||||
import org.rev317.min.api.events.listeners.MessageListener;
|
||||
import org.rev317.min.api.methods.Game;
|
||||
import org.rev317.min.script.ScriptEngine;
|
||||
|
||||
/**
|
||||
* @author JKetelaar
|
||||
*/
|
||||
public class PacketFail implements Random, MessageListener {
|
||||
|
||||
private int fails = 0;
|
||||
private long lastFail = 0;
|
||||
|
||||
public PacketFail(){
|
||||
ScriptEngine.getInstance().addMessageListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean activate() {
|
||||
if (fails >= 3 && System.currentTimeMillis() - lastFail <= 25 * 1000){
|
||||
return true;
|
||||
}else if (System.currentTimeMillis() - lastFail > 25 * 1000){
|
||||
lastFail = 0;
|
||||
fails = 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
// if (!Game.dropClient()){
|
||||
Logger.addMessage("Couldn't drop the client, please restart if required", true);
|
||||
// }
|
||||
fails = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Client restarter";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServer() {
|
||||
return "Ikov";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived(MessageEvent messageEvent) {
|
||||
if (messageEvent.getType() == 0){
|
||||
String message = messageEvent.getMessage().toLowerCase();
|
||||
switch (message){
|
||||
case "unable to receive input":
|
||||
case "command does not exist":
|
||||
case "too far away from this object":
|
||||
case "that object does not exist":
|
||||
case "party room is currently disabled":
|
||||
fails++;
|
||||
lastFail = System.currentTimeMillis();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,107 +0,0 @@
|
||||
package org.parabot.randoms.ikov;
|
||||
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.ParseException;
|
||||
import org.parabot.core.Context;
|
||||
import org.parabot.core.ui.Logger;
|
||||
import org.parabot.environment.api.utils.Time;
|
||||
import org.parabot.environment.api.utils.WebUtil;
|
||||
import org.parabot.environment.input.Keyboard;
|
||||
import org.parabot.environment.scripts.Script;
|
||||
import org.parabot.environment.scripts.framework.SleepCondition;
|
||||
import org.parabot.environment.scripts.randoms.Random;
|
||||
import org.rev317.min.Loader;
|
||||
import org.rev317.min.api.methods.Game;
|
||||
import org.rev317.min.api.methods.Menu;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
public class QuestionSolver implements Random {
|
||||
|
||||
private final int backlogID = 368, cacheID = 372;
|
||||
|
||||
@Override
|
||||
public boolean activate() {
|
||||
return Game.isLoggedIn() && Game.getOpenBackDialogId() == backlogID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
String message = Loader.getClient().getInterfaceCache()[cacheID].getMessage();
|
||||
if (!message.contains("lose items on death, beware")) {
|
||||
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);
|
||||
}
|
||||
|
||||
public 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")));
|
||||
JSONObject result;
|
||||
if ((result = (JSONObject) object.get("result")) != null){
|
||||
Object answer;
|
||||
if ((answer = result.get("answer")) != null){
|
||||
return (String) answer;
|
||||
}
|
||||
}
|
||||
} catch (ParseException | MalformedURLException | UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}catch (Exception ignored){
|
||||
// Catching for old bots
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void forceRelog() {
|
||||
try {
|
||||
Logger.addMessage("Logging out...", false);
|
||||
Class<?> c = Loader.getClient().getClass();
|
||||
|
||||
Method m = c.getDeclaredMethod("am");
|
||||
m.setAccessible(true);
|
||||
|
||||
m.invoke(Loader.getClient());
|
||||
Time.sleep(new SleepCondition() {
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return !Game.isLoggedIn();
|
||||
}
|
||||
}, 5000);
|
||||
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Login.setTimer(5 * 60);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Question solver";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServer() {
|
||||
return "Ikov";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user