[CLASS UPDATE] Added and modified Methods

Made all methods Static and added #setActivePrayers and
#getActivePrayers
This commit is contained in:
Fryslan
2015-10-21 21:33:08 +02:00
parent 191e2acc89
commit 322596278a
@@ -3,6 +3,8 @@ package org.rev317.min.api.methods;
import org.parabot.environment.api.utils.Time;
import org.parabot.environment.scripts.framework.SleepCondition;
import java.util.ArrayList;
/**
* @author JKetelaar, Fryslan
* TODO Set the actual level requirements
@@ -12,8 +14,11 @@ public class Prayer {
public interface Book {
public int getSetting();
public int getAction();
public int getLevel();
public String getName();
}
@@ -172,11 +177,11 @@ public class Prayer {
}
public boolean isEnabled(Book book){
public static boolean isEnabled(Book book) {
return Game.getSetting(book.getSetting()) == 1;
}
public void enable(final Book book) {
public static void enable(final Book book) {
if (!isEnabled(book)) {
Menu.sendAction(169, -1, -1, book.getAction());
Time.sleep(new SleepCondition() {
@@ -188,7 +193,7 @@ public class Prayer {
}
}
public void disable(final Book book) {
public static void disable(final Book book) {
if (isEnabled(book)) {
Menu.sendAction(169, -1, -1, book.getAction());
Time.sleep(new SleepCondition() {
@@ -199,4 +204,34 @@ public class Prayer {
}, 1500);
}
}
public static Book[] getActivePrayers() {
ArrayList<Book> prayers = new ArrayList<>();
for (Book normal : Normal.values()) {
if (isEnabled(normal)) {
prayers.add(normal);
}
}
for (Book curse : Curse.values()) {
if (isEnabled(curse)) {
prayers.add(curse);
}
}
return prayers.toArray(new Book[prayers.size()]);
}
public static void setActivePrayers(Book[] prayers) {
for (Book book : prayers) {
for (Book normal : Normal.values()) {
if (!isEnabled(normal) && normal.equals(book)) {
enable(normal);
}
}
for (Book curse : Curse.values()) {
if (!isEnabled(curse) && curse.equals(book)) {
enable(curse);
}
}
}
}
}