mirror of
https://github.com/2006-Scape/Parabot-Randoms.git
synced 2026-07-04 16:49:11 +00:00
Merge pull request #22 from Parabot/development
[MERGE] Development into master
This commit is contained in:
+2
-22
@@ -14,26 +14,7 @@ buildNumber.properties
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff:
|
||||
.idea/workspace.xml
|
||||
.idea/tasks.xml
|
||||
.idea/dictionaries
|
||||
.idea/vcs.xml
|
||||
.idea/jsLibraryMappings.xml
|
||||
|
||||
# Sensitive or high-churn files:
|
||||
.idea/dataSources.ids
|
||||
.idea/dataSources.xml
|
||||
.idea/dataSources.local.xml
|
||||
.idea/sqlDataSources.xml
|
||||
.idea/dynamic.xml
|
||||
.idea/uiDesigner.xml
|
||||
|
||||
# Gradle:
|
||||
.idea/gradle.xml
|
||||
.idea/libraries
|
||||
|
||||
# Mongo Explorer plugin:
|
||||
.idea/mongoSettings.xml
|
||||
.idea
|
||||
|
||||
## File-based project format:
|
||||
*.iws
|
||||
@@ -68,5 +49,4 @@ fabric.properties
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
|
||||
*.iml
|
||||
.i€dea
|
||||
*.iml
|
||||
Generated
-32
@@ -1,32 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<resourceExtensions />
|
||||
<wildcardResourcePatterns>
|
||||
<entry name="!?*.java" />
|
||||
<entry name="!?*.form" />
|
||||
<entry name="!?*.class" />
|
||||
<entry name="!?*.groovy" />
|
||||
<entry name="!?*.scala" />
|
||||
<entry name="!?*.flex" />
|
||||
<entry name="!?*.kt" />
|
||||
<entry name="!?*.clj" />
|
||||
<entry name="!?*.aj" />
|
||||
</wildcardResourcePatterns>
|
||||
<annotationProcessing>
|
||||
<profile default="true" name="Default" enabled="false">
|
||||
<processorPath useClasspath="true" />
|
||||
</profile>
|
||||
<profile default="false" name="Maven default annotation processors profile" enabled="true">
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<processorPath useClasspath="true" />
|
||||
<module name="Randoms" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
<bytecodeTargetLevel>
|
||||
<module name="Randoms" target="1.7" />
|
||||
</bytecodeTargetLevel>
|
||||
</component>
|
||||
</project>
|
||||
Generated
-3
@@ -1,3 +0,0 @@
|
||||
<component name="CopyrightManager">
|
||||
<settings default="" />
|
||||
</component>
|
||||
Generated
-6
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="PROJECT" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
||||
Generated
-26
@@ -1,26 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="EntryPointsManager">
|
||||
<entry_points version="2.0" />
|
||||
</component>
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
|
||||
<OptionsSetting value="true" id="Add" />
|
||||
<OptionsSetting value="true" id="Remove" />
|
||||
<OptionsSetting value="true" id="Checkout" />
|
||||
<OptionsSetting value="true" id="Update" />
|
||||
<OptionsSetting value="true" id="Status" />
|
||||
<OptionsSetting value="true" id="Edit" />
|
||||
<ConfirmationsSetting value="0" id="Add" />
|
||||
<ConfirmationsSetting value="0" id="Remove" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
Generated
-9
@@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/Randoms.iml" filepath="$PROJECT_DIR$/.idea/Randoms.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/Randoms.iml" filepath="$PROJECT_DIR$/Randoms.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
+10
-3
@@ -2,12 +2,16 @@ language: java
|
||||
|
||||
jdk:
|
||||
- oraclejdk7
|
||||
- oraclejdk8
|
||||
|
||||
before_install:
|
||||
- chmod +x ./.travis/maven-build.sh
|
||||
- chmod +x ./.travis/call-creation.sh
|
||||
- mvn clean
|
||||
|
||||
install:
|
||||
- sudo apt-get update && sudo apt-get --assume-yes install zip unzip
|
||||
|
||||
script: "./.travis/maven-build.sh"
|
||||
|
||||
after_deploy: "./.travis/call-creation.sh"
|
||||
@@ -15,7 +19,7 @@ after_deploy: "./.travis/call-creation.sh"
|
||||
notifications:
|
||||
email: false
|
||||
slack:
|
||||
secure: ciAOsdv9lf/IbAwyzeR/z2nlBSevmBHBqca6tf0Yh2DIyAx/uUo1ojon0W7Kv6tCECGhSTdfQAnZ+nFjjqaRs+Jq4svd9WKYrFuZyOWmT31iSJ/nvPymRvevSsgwpSKr0nJS9dxePKto/T3ozW29kx88eaJQH17zOaX2rfuIje4=
|
||||
secure: B3FrxPmZ/h3dj+39aRMLJas6d62tazECB6OYsI0fTnOO9VpFOrsH67JpcaQM928zv9AItFpkYHxapqCdIZw8mYJnKOlqSqHKZE9Wu/O09ZTknxIsPnkjNknQW+6B+tHvBni3fkC29OocEePf89ZesQ6vSO/10J3OmdVlGDLyr0ShUHXgQOimWXtkjb5YVDNIrOcQ5Jx0U6h26NMx67cmYtEyR88DnLO0dBmpGjbf/o6Y+99HcBQJdotLl40h6yKufwwNiv0bVZRKfi8emMA1jvUPRqLt1CWatn2wzp1MCqpgSGBM3DnK9X5arTu6iURea2EIP3vXs9c17BLRqwVEM9YA+DCqAtze6sQstNtNiwzibWDwU/Ft8xWivdk3yqNlPE+8tx3BdBCi1gAplph2x4+7xY+icbL46tKt/UKqJdZeEIiWP8jzqWuhYDlRSFvUhvRh0DHJSO6IiY049eBQF7pwzTtofA5HXTplKByGHrqraWgxM5rUCWoKoWm9xOOwZ0lJhmjUsB1yp2ZQY1abEVmEo0uHIzeSulufUnTjqlAMzok1ZRn9YqJgUELgcCN4JSjCHQhGT/WRbOD1BSLl7XC9zdKalgVvGYyAVTIJRDF581E7VIYe6Dt9c6M+T/M3FPq86IUL0/iLxsgsvNY0+16k95D+jbVWYv8OYzZRtt4=
|
||||
webhooks:
|
||||
on_success: always
|
||||
on_failure: always
|
||||
@@ -26,7 +30,7 @@ env:
|
||||
- secure: UG+b1tEgc8xv9x4r//2OAIK1RrYv6n209KTTFMMwcnAa7DI8HaP8nljRa5/VhDhuKHdlVrYH/tI90v7UVBs0GDVNwK5V17Io0fMm3FUGZekSthTCqqno5wAGa9r6a6mMLtSaSmIFeIKi0+0d2ZwplRuhj/dtEYjjBBj+kK8g4nE=
|
||||
- secure: St/fecUDInFBCRriYqgp2F8PU9/SooorgxD9Mrs+b0EsC7AbtSsQXvdIv2Lp6xzdQ0VSXPcLIhULPOYrmBKnGQ/NjXTIZXxnroyQxxnI6xyEWIZwiHRY/bKRJDRbQTxD9NL32szKiDSwnw7pu6llF4D64UqQvziq4Gm6VohU75M=
|
||||
- secure: bD15GVZWowiknbfLavh8CxSh0GsnF5kT4kZ6ggCuUDGyj0mzqf7dNRnchQIKkCG0WRYyTrFN4pEiygeywWsipEeAVv9Xhx3cuUZmzeQaR5KCWabSwJ8gK6jZd1YhcWmM9vrdPHobZr65MP0y/8mu/Fovgky9dY7KDf4G3SebNrM=
|
||||
- RANDOMS_VERSION=0.1
|
||||
- RANDOMS_VERSION=0.22
|
||||
|
||||
cache:
|
||||
directories:
|
||||
@@ -47,4 +51,7 @@ deploy:
|
||||
acl: public_read
|
||||
on:
|
||||
repo: Parabot/Randoms
|
||||
all_branches: true
|
||||
branch:
|
||||
- master
|
||||
- development
|
||||
jdk: 'oraclejdk7'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#! /bin/bash
|
||||
|
||||
sleep 15
|
||||
curl -sS "http://v3.bdn.parabot.org/api/bot/create/random?build_id=$TRAVIS_BUILD_ID&version=$RANDOMS_VERSION" >/dev/null
|
||||
sleep 1
|
||||
curl --data "build_id=$TRAVIS_BUILD_ID&version=$RANDOMS_VERSION" "http://v3.bdn.parabot.org/api/bot/create/randoms"
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>org.parabot</groupId>
|
||||
<artifactId>randoms</artifactId>
|
||||
<version>0.1</version>
|
||||
<version>0.22</version>
|
||||
|
||||
<properties>
|
||||
<jdk.version>1.7</jdk.version>
|
||||
@@ -15,9 +15,9 @@
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>git-parabot</id>
|
||||
<name>Parabot's Git based repo</name>
|
||||
<url>https://github.com/parabot/Maven-Repository/raw/master/</url>
|
||||
<id>parabot-maven</id>
|
||||
<name>Parabot its Maven Repository</name>
|
||||
<url>http://maven.parabot.org/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
<dependency>
|
||||
<groupId>org.parabot</groupId>
|
||||
<artifactId>client</artifactId>
|
||||
<version>2.5</version>
|
||||
<version>2.6.1</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>*</artifactId>
|
||||
@@ -45,7 +45,7 @@
|
||||
<dependency>
|
||||
<groupId>org.parabot</groupId>
|
||||
<artifactId>317-api-minified</artifactId>
|
||||
<version>1.14</version>
|
||||
<version>1.201</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>*</artifactId>
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
package org.parabot.randoms;
|
||||
|
||||
import org.parabot.core.Context;
|
||||
import org.parabot.environment.scripts.randoms.Random;
|
||||
import org.parabot.randoms.ikov.LogoutDisabler;
|
||||
import org.parabot.randoms.ikov.PacketFail;
|
||||
import org.parabot.randoms.ikov.Login;
|
||||
import org.parabot.randoms.ikov.QuestionSolver;
|
||||
import org.parabot.environment.randoms.Random;
|
||||
import org.parabot.randoms.dreamscape.SerialBanAvoider;
|
||||
import org.parabot.randoms.pkhonor.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -17,19 +14,20 @@ public class Core {
|
||||
private ArrayList<Random> randoms = new ArrayList<>();
|
||||
|
||||
public void init(String server) {
|
||||
// PkHonor
|
||||
randoms.add(new Jail());
|
||||
randoms.add(new TriangleSandwich());
|
||||
randoms.add(new SandwichLady());
|
||||
randoms.add(new MysteriousOldMan());
|
||||
randoms.add(new QuestionSolver());
|
||||
randoms.add(new BobsIsland());
|
||||
randoms.add(new LogoutDisabler());
|
||||
randoms.add(new Login());
|
||||
randoms.add(new PacketFail());
|
||||
randoms.add(new PacketBlockInterceptor());
|
||||
|
||||
// Dreamscape
|
||||
randoms.add(new SerialBanAvoider());
|
||||
|
||||
org.parabot.core.Core.verbose("Possible randoms:");
|
||||
for (Random random : randoms) {
|
||||
if (random.getServer().toLowerCase().equalsIgnoreCase(server.toLowerCase())) {
|
||||
if (random.getServer().equalsIgnoreCase(server)) {
|
||||
org.parabot.core.Core.verbose("-> " + random.getName());
|
||||
Context.getInstance().getRandomHandler().addRandom(random);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author JKetelaar
|
||||
*/
|
||||
public class SerialBanAvoider implements Random {
|
||||
|
||||
private static final String serialAddressField = "SERIAL_ADDRESS";
|
||||
private static final String serialAddressValue = "empty_or_unknown";
|
||||
|
||||
private boolean done;
|
||||
|
||||
@Override
|
||||
public boolean activate() {
|
||||
return !done;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
try {
|
||||
workAroundStaticValues(Context.getInstance().getClient().getClass(), serialAddressField, serialAddressValue);
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
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";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServer() {
|
||||
return "dreamscape";
|
||||
}
|
||||
|
||||
@Override
|
||||
public RandomType getRandomType() {
|
||||
return RandomType.ON_SERVER_START;
|
||||
}
|
||||
}
|
||||
@@ -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";
|
||||
}
|
||||
}
|
||||
@@ -1,28 +1,33 @@
|
||||
package org.parabot.randoms.pkhonor;
|
||||
|
||||
import org.parabot.environment.scripts.randoms.Random;
|
||||
import org.parabot.environment.randoms.Random;
|
||||
import org.parabot.environment.randoms.RandomType;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Created by Fryslan.
|
||||
* @author Fryslan
|
||||
*/
|
||||
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 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() {
|
||||
checked = true;
|
||||
return !checked && filePresent();
|
||||
if (!checked) {
|
||||
if (filePresent()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
for(File banfile : locations){
|
||||
if(banfile.exists()){
|
||||
banfile.delete();
|
||||
for (File banfile : locations) {
|
||||
if (banfile.exists()) {
|
||||
banfile.delete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,9 +43,15 @@ public class BanFile implements Random {
|
||||
return "pkhonor";
|
||||
}
|
||||
|
||||
@Override
|
||||
public RandomType getRandomType() {
|
||||
return RandomType.ON_SERVER_START;
|
||||
}
|
||||
|
||||
private boolean filePresent() {
|
||||
for(File banfile : locations){
|
||||
if(banfile.exists()){
|
||||
checked = true;
|
||||
for (File banfile : locations) {
|
||||
if (banfile.exists()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,19 @@
|
||||
package org.parabot.randoms.pkhonor;
|
||||
|
||||
import org.parabot.environment.api.utils.Time;
|
||||
import org.parabot.environment.randoms.Random;
|
||||
import org.parabot.environment.randoms.RandomType;
|
||||
import org.parabot.environment.scripts.framework.SleepCondition;
|
||||
import org.parabot.environment.scripts.randoms.Random;
|
||||
import org.rev317.min.api.methods.Players;
|
||||
import org.rev317.min.api.methods.SceneObjects;
|
||||
import org.rev317.min.api.wrappers.Area;
|
||||
import org.rev317.min.api.wrappers.SceneObject;
|
||||
import org.rev317.min.api.wrappers.Tile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: Piet Jetse
|
||||
* Date: 2-1-2015
|
||||
* Time: 13:19
|
||||
* @author Fryslan
|
||||
*/
|
||||
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;
|
||||
|
||||
public BobsIsland() {
|
||||
@@ -34,8 +28,8 @@ public class BobsIsland implements Random {
|
||||
public void execute() {
|
||||
SceneObject[] portals = SceneObjects.getNearest(portalId);
|
||||
|
||||
for(final SceneObject portal : portals){
|
||||
if(portal != null){
|
||||
for (final SceneObject portal : portals) {
|
||||
if (portal != null) {
|
||||
portal.interact(SceneObjects.Option.FIRST);
|
||||
Time.sleep(new SleepCondition() {
|
||||
@Override
|
||||
@@ -45,7 +39,7 @@ public class BobsIsland implements Random {
|
||||
}, 10000);
|
||||
Time.sleep(1000);
|
||||
|
||||
if(center.distanceTo() > 24){
|
||||
if (center.distanceTo() > 24) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -61,4 +55,9 @@ public class BobsIsland implements Random {
|
||||
public String getServer() {
|
||||
return "pkhonor";
|
||||
}
|
||||
|
||||
@Override
|
||||
public RandomType getRandomType() {
|
||||
return RandomType.SCRIPT;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package org.parabot.randoms.pkhonor;
|
||||
|
||||
import org.parabot.environment.api.utils.Time;
|
||||
import org.parabot.environment.randoms.Random;
|
||||
import org.parabot.environment.randoms.RandomType;
|
||||
import org.parabot.environment.scripts.framework.SleepCondition;
|
||||
import org.parabot.environment.scripts.randoms.Random;
|
||||
import org.rev317.min.api.methods.Inventory;
|
||||
import org.rev317.min.api.methods.Npcs;
|
||||
import org.rev317.min.api.methods.Players;
|
||||
@@ -11,7 +12,7 @@ import org.rev317.min.api.wrappers.Npc;
|
||||
import org.rev317.min.api.wrappers.SceneObject;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA. User: Piet Jetse Date: 11-9-2014 Time: 22:22
|
||||
* @author Fryslan
|
||||
*/
|
||||
|
||||
public class Jail implements Random {
|
||||
@@ -45,7 +46,7 @@ public class Jail implements Random {
|
||||
if (!Inventory.isFull()) {
|
||||
if (rock != null) {
|
||||
if (Players.getMyPlayer().getAnimation() == -1) {
|
||||
rock.interact(0);
|
||||
rock.interact(SceneObjects.Option.MINE);
|
||||
Time.sleep(new SleepCondition() {
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
@@ -57,7 +58,7 @@ public class Jail implements Random {
|
||||
|
||||
//Inventory is full depositting ores
|
||||
} else {
|
||||
jailer.interact(0);
|
||||
jailer.interact(Npcs.Option.TALK_TO);
|
||||
|
||||
Time.sleep(new SleepCondition() {
|
||||
@Override
|
||||
@@ -70,7 +71,7 @@ public class Jail implements Random {
|
||||
|
||||
//getting Pickaxe
|
||||
} else {
|
||||
jailer.interact(0);
|
||||
jailer.interact(Npcs.Option.TALK_TO);
|
||||
Time.sleep(new SleepCondition() {
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
@@ -84,18 +85,18 @@ public class Jail implements Random {
|
||||
}
|
||||
}
|
||||
|
||||
private Npc getJailer(){
|
||||
for(Npc jailer : Npcs.getNearest(201)){
|
||||
if(jailer != null && jailer.getDef() != null){
|
||||
private Npc getJailer() {
|
||||
for (Npc jailer : Npcs.getNearest(201)) {
|
||||
if (jailer != null && jailer.getDef() != null) {
|
||||
return jailer;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private SceneObject getRock(){
|
||||
for(SceneObject rock : SceneObjects.getNearest(rocks)){
|
||||
if(rock != null){
|
||||
private SceneObject getRock() {
|
||||
for (SceneObject rock : SceneObjects.getNearest(rocks)) {
|
||||
if (rock != null) {
|
||||
return rock;
|
||||
}
|
||||
}
|
||||
@@ -111,4 +112,9 @@ public class Jail implements Random {
|
||||
public String getServer() {
|
||||
return "pkhonor";
|
||||
}
|
||||
|
||||
@Override
|
||||
public RandomType getRandomType() {
|
||||
return RandomType.SCRIPT;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
package org.parabot.randoms.pkhonor;
|
||||
|
||||
import org.parabot.environment.api.utils.Time;
|
||||
import org.parabot.environment.randoms.Random;
|
||||
import org.parabot.environment.randoms.RandomType;
|
||||
import org.parabot.environment.scripts.framework.SleepCondition;
|
||||
import org.parabot.environment.scripts.randoms.Random;
|
||||
import org.rev317.min.api.methods.Npcs;
|
||||
import org.rev317.min.api.methods.Players;
|
||||
import org.rev317.min.api.wrappers.Npc;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA. User: Piet Jetse Date: 12-9-2014 Time: 17:19
|
||||
* @author Fryslan
|
||||
*/
|
||||
public class MysteriousOldMan implements Random {
|
||||
|
||||
@@ -52,4 +53,9 @@ public class MysteriousOldMan implements Random {
|
||||
public String getServer() {
|
||||
return "pkhonor";
|
||||
}
|
||||
|
||||
@Override
|
||||
public RandomType getRandomType() {
|
||||
return RandomType.SCRIPT;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,15 @@
|
||||
package org.parabot.randoms.pkhonor;
|
||||
|
||||
import org.parabot.environment.api.utils.Time;
|
||||
import org.parabot.environment.randoms.Random;
|
||||
import org.parabot.environment.randoms.RandomType;
|
||||
import org.parabot.environment.scripts.framework.SleepCondition;
|
||||
import org.parabot.environment.scripts.randoms.Random;
|
||||
import org.rev317.min.api.methods.Npcs;
|
||||
import org.rev317.min.api.methods.Players;
|
||||
import org.rev317.min.api.wrappers.Npc;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA. User: Piet Jetse Date: 12-9-2014 Time: 16:13
|
||||
* @author Fryslan
|
||||
*/
|
||||
public class SandwichLady implements Random {
|
||||
|
||||
@@ -52,4 +53,9 @@ public class SandwichLady implements Random {
|
||||
public String getServer() {
|
||||
return "pkhonor";
|
||||
}
|
||||
|
||||
@Override
|
||||
public RandomType getRandomType() {
|
||||
return RandomType.SCRIPT;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,23 @@
|
||||
package org.parabot.randoms.pkhonor;
|
||||
|
||||
import org.parabot.environment.api.utils.Time;
|
||||
import org.parabot.environment.randoms.Random;
|
||||
import org.parabot.environment.randoms.RandomType;
|
||||
import org.parabot.environment.scripts.framework.SleepCondition;
|
||||
import org.parabot.environment.scripts.randoms.Random;
|
||||
import org.rev317.min.api.methods.Inventory;
|
||||
import org.rev317.min.api.wrappers.Item;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA. User: Piet Jetse Date: 11-9-2014 Time: 22:29
|
||||
* @author Fryslan
|
||||
*/
|
||||
public class TriangleSandwich implements Random {
|
||||
|
||||
Item item;
|
||||
private Item item;
|
||||
private final int id = 6963;
|
||||
|
||||
@Override
|
||||
public boolean activate() {
|
||||
for (Item i : Inventory.getItems(6963)) {
|
||||
for (Item i : Inventory.getItems(id)) {
|
||||
if (i != null) {
|
||||
this.item = i;
|
||||
return true;
|
||||
@@ -31,7 +33,7 @@ public class TriangleSandwich implements Random {
|
||||
Time.sleep(new SleepCondition() {
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return Inventory.getCount(6963) == 0;
|
||||
return Inventory.getCount(id) == 0;
|
||||
}
|
||||
}, 1500);
|
||||
}
|
||||
@@ -46,4 +48,9 @@ public class TriangleSandwich implements Random {
|
||||
public String getServer() {
|
||||
return "pkhonor";
|
||||
}
|
||||
|
||||
@Override
|
||||
public RandomType getRandomType() {
|
||||
return RandomType.SCRIPT;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user