mirror of
https://github.com/2006-Scape/Parabot-Randoms.git
synced 2026-07-03 16:49:09 +00:00
Merge pull request #26 from Parabot/bugfix/trianglesandwich
[BUGFIX] Fixed a null pointer in the Triangle Sandwich random
This commit is contained in:
@@ -5,7 +5,6 @@ import org.parabot.environment.randoms.Random;
|
||||
import org.parabot.randoms.dreamscape.SerialBanAvoider;
|
||||
import org.parabot.randoms.elkoy.LogoutDisabler;
|
||||
import org.parabot.randoms.elkoy.MouseOnScreen;
|
||||
import org.parabot.randoms.elkoy.QuestionSolver;
|
||||
import org.parabot.randoms.pkhonor.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -23,7 +22,6 @@ public class Core {
|
||||
randoms.add(new SandwichLady());
|
||||
randoms.add(new MysteriousOldMan());
|
||||
randoms.add(new BobsIsland());
|
||||
randoms.add(new PacketBlockInterceptor());
|
||||
|
||||
// Dreamscape
|
||||
randoms.add(new SerialBanAvoider());
|
||||
|
||||
@@ -21,6 +21,7 @@ public class MouseOnScreen implements Random {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -39,7 +40,7 @@ public class MouseOnScreen implements Random {
|
||||
return RandomType.SCRIPT;
|
||||
}
|
||||
|
||||
private boolean onScreen(){
|
||||
private boolean onScreen() {
|
||||
Point loc = Mouse.getInstance().getPoint();
|
||||
return Context.getInstance().getApplet().contains(loc);
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@ public class QuestionSolver implements Random {
|
||||
} catch (MalformedURLException | UnsupportedEncodingException | ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ public class BanFile implements Random {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -30,7 +31,6 @@ public class BanFile implements Random {
|
||||
banfile.delete();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,6 +55,7 @@ public class BanFile implements Random {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,9 +16,6 @@ public class BobsIsland implements Random {
|
||||
private static final Tile center = new Tile(2525, 4777);
|
||||
private static final int portalId = 8987;
|
||||
|
||||
public BobsIsland() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean activate() {
|
||||
return center.distanceTo() < 25;
|
||||
|
||||
@@ -27,6 +27,7 @@ public class Jail implements Random {
|
||||
this.jailer = getJailer();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
@@ -91,6 +92,7 @@ public class Jail implements Random {
|
||||
return jailer;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -100,6 +102,7 @@ public class Jail implements Random {
|
||||
return rock;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ public class MysteriousOldMan implements Random {
|
||||
return man;
|
||||
}
|
||||
}
|
||||
|
||||
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 null;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,23 +17,28 @@ public class TriangleSandwich implements Random {
|
||||
|
||||
@Override
|
||||
public boolean activate() {
|
||||
for (Item i : Inventory.getItems(id)) {
|
||||
if (i != null) {
|
||||
this.item = i;
|
||||
return true;
|
||||
if (Inventory.getItems() != null) {
|
||||
for (Item i : Inventory.getItems(id)) {
|
||||
if (i != null) {
|
||||
this.item = i;
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
if (this.item != null) {
|
||||
final int sandwich = Inventory.getCount(id);
|
||||
item.drop();
|
||||
Time.sleep(new SleepCondition() {
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return Inventory.getCount(id) == 0;
|
||||
return Inventory.getCount(id) != sandwich;
|
||||
}
|
||||
}, 1500);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user