Merge pull request #5 from Parabot/Fixes

Fixes
This commit is contained in:
Jeroen Ketelaar
2016-10-08 20:10:00 +02:00
committed by GitHub
7 changed files with 107 additions and 49 deletions
+2 -1
View File
@@ -68,4 +68,5 @@ fabric.properties
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid* hs_err_pid*
*.iml *.iml
.i€dea
+1
View File
@@ -2,6 +2,7 @@
<project version="4"> <project version="4">
<component name="ProjectModuleManager"> <component name="ProjectModuleManager">
<modules> <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" /> <module fileurl="file://$PROJECT_DIR$/Randoms.iml" filepath="$PROJECT_DIR$/Randoms.iml" />
</modules> </modules>
</component> </component>
@@ -0,0 +1,49 @@
package org.parabot.randoms.pkhonor;
import org.parabot.environment.scripts.randoms.Random;
import java.io.File;
/**
* Created by 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 boolean checked = false;
@Override
public boolean activate() {
checked = true;
return !checked && filePresent();
}
@Override
public void execute() {
for(File banfile : locations){
if(banfile.exists()){
banfile.delete();
}
}
}
@Override
public String getName() {
return "BanFile Handler";
}
@Override
public String getServer() {
return "pkhonor";
}
private boolean filePresent() {
for(File banfile : locations){
if(banfile.exists()){
return true;
}
}
return false;
}
}
@@ -19,38 +19,35 @@ import java.util.ArrayList;
*/ */
public class BobsIsland implements Random { public class BobsIsland implements Random {
private final int PORTAL = 8987; private static final Tile center = new Tile(2525,4777);
private ArrayList<SceneObject> portals; private static final int portalId = 8987;
private final Area ISLAND = new Area(new Tile(2511, 4765), new Tile(2511, 4790), new Tile(2542, 4790), new Tile(2542, 4765));
public BobsIsland() { public BobsIsland() {
portals = new ArrayList<>();
} }
@Override @Override
public boolean activate() { public boolean activate() {
return ISLAND.contains(Players.getMyPlayer().getLocation()); return center.distanceTo() < 25;
} }
@Override @Override
public void execute() { public void execute() {
//Fill The ArrayList SceneObject[] portals = SceneObjects.getNearest(portalId);
for (SceneObject portal : SceneObjects.getNearest(PORTAL)) {
if (portal != null) {
portals.add(portal);
}
}
//Loop through the portals for(final SceneObject portal : portals){
for (final SceneObject portal : portals) { if(portal != null){
if (portal != null) { portal.interact(SceneObjects.Option.FIRST);
portal.interact(0);
Time.sleep(new SleepCondition() { Time.sleep(new SleepCondition() {
@Override @Override
public boolean isValid() { public boolean isValid() {
return portal.distanceTo() < 2; return portal.distanceTo() < 2;
} }
}, 7500); }, 10000);
Time.sleep(1000);
if(center.distanceTo() > 24){
break;
}
} }
} }
} }
@@ -16,14 +16,14 @@ import org.rev317.min.api.wrappers.SceneObject;
public class Jail implements Random { public class Jail implements Random {
private Npc jailer; private Npc jailer;
private final int[] ROCKS = {2093, 2092}; private final int[] rocks = {2093, 2092};
private final int[] PICK_AXES = {1266, 1268, 1270, 1272, 1274, 1276, 14605, 14608}; private final int[] pickAxes = {1266, 1268, 1270, 1272, 1274, 1276, 14605, 14608};
@Override @Override
public boolean activate() { public boolean activate() {
try { try {
if (jailer() != null) { if (getJailer() != null) {
this.jailer = jailer(); this.jailer = getJailer();
return true; return true;
} }
return false; return false;
@@ -36,10 +36,10 @@ public class Jail implements Random {
public void execute() { public void execute() {
try { try {
SceneObject rock = rock(); SceneObject rock = getRock();
//Check if we got an Pickaxe //Check if we got an Pickaxe
if (Inventory.getCount(PICK_AXES) > 0) { if (Inventory.getCount(pickAxes) > 0) {
//Check if we can min the ores //Check if we can min the ores
if (!Inventory.isFull()) { if (!Inventory.isFull()) {
@@ -84,17 +84,17 @@ public class Jail implements Random {
} }
} }
private Npc jailer(){ private Npc getJailer(){
for(Npc jailer : Npcs.getNearest(201)){ for(Npc jailer : Npcs.getNearest(201)){
if(jailer != null){ if(jailer != null && jailer.getDef() != null){
return jailer; return jailer;
} }
} }
return null; return null;
} }
private SceneObject rock(){ private SceneObject getRock(){
for(SceneObject rock : SceneObjects.getNearest(ROCKS)){ for(SceneObject rock : SceneObjects.getNearest(rocks)){
if(rock != null){ if(rock != null){
return rock; return rock;
} }
@@ -12,32 +12,37 @@ import org.rev317.min.api.wrappers.Npc;
*/ */
public class MysteriousOldMan implements Random { public class MysteriousOldMan implements Random {
Npc man; private Npc man;
private final int id = 410;
@Override @Override
public boolean activate() { public boolean activate() {
for (Npc npc : Npcs.getNearest(410)) { this.man = getMan();
if (npc != null && npc.getInteractingCharacter().equals(Players.getMyPlayer())) { return man != null;
man = npc;
return true;
}
}
return false;
} }
@Override @Override
public void execute() { public void execute() {
if (man != null && man.getInteractingCharacter().equals(Players.getMyPlayer())) { if (this.man != null) {
man.interact(0); man.interact(Npcs.Option.TALK_TO);
Time.sleep(new SleepCondition() { Time.sleep(new SleepCondition() {
@Override @Override
public boolean isValid() { public boolean isValid() {
return !man.getInteractingCharacter().equals(Players.getMyPlayer()); return man.distanceTo() > 0 || !man.getInteractingCharacter().equals(Players.getMyPlayer());
} }
}, 1500); }, 1500);
} }
} }
private Npc getMan() {
for (Npc man : Npcs.getNearest(id)) {
if (man != null && man.getDef() != null && man.getInteractingCharacter().equals(Players.getMyPlayer())) {
return man;
}
}
return null;
}
@Override @Override
public String getName() { public String getName() {
return "Mysterious Old Man Solver"; return "Mysterious Old Man Solver";
@@ -12,32 +12,37 @@ import org.rev317.min.api.wrappers.Npc;
*/ */
public class SandwichLady implements Random { public class SandwichLady implements Random {
Npc lady; private Npc lady;
private final int id = 3117;
@Override @Override
public boolean activate() { public boolean activate() {
for (Npc npc : Npcs.getNearest(3117)) { this.lady = getLady();
if (npc != null && npc.getInteractingCharacter().equals(Players.getMyPlayer())) { return this.lady != null;
lady = npc;
return true;
}
}
return false;
} }
@Override @Override
public void execute() { public void execute() {
if (lady != null && lady.getInteractingCharacter().equals(Players.getMyPlayer())) { if (this.lady != null) {
lady.interact(0); lady.interact(Npcs.Option.TALK_TO);
Time.sleep(new SleepCondition() { Time.sleep(new SleepCondition() {
@Override @Override
public boolean isValid() { public boolean isValid() {
return !lady.getInteractingCharacter().equals(Players.getMyPlayer()); return lady.distanceTo() > 0 || !lady.getInteractingCharacter().equals(Players.getMyPlayer());
} }
}, 1500); }, 1500);
} }
} }
private Npc getLady() {
for (Npc lady : Npcs.getNearest(id)) {
if (lady != null && lady.getDef() != null && lady.getInteractingCharacter().equals(Players.getMyPlayer())) {
return lady;
}
}
return null;
}
@Override @Override
public String getName() { public String getName() {
return "Sandwich Lady Solver"; return "Sandwich Lady Solver";