100 lines
2.9 KiB
Java
100 lines
2.9 KiB
Java
package io.reisub.dreambot.util.tasks.kitten;
|
|
|
|
import io.reisub.dreambot.util.CNPC;
|
|
import io.reisub.dreambot.util.Constants;
|
|
import io.reisub.dreambot.util.TaskNodeParent;
|
|
import org.dreambot.api.methods.container.impl.Inventory;
|
|
import org.dreambot.api.methods.filter.Filter;
|
|
import org.dreambot.api.script.ScriptManager;
|
|
import org.dreambot.api.script.listener.ChatListener;
|
|
import org.dreambot.api.wrappers.interactive.NPC;
|
|
import org.dreambot.api.wrappers.items.Item;
|
|
import org.dreambot.api.wrappers.widgets.message.Message;
|
|
|
|
import javax.annotation.Nullable;
|
|
import java.util.Locale;
|
|
|
|
public class KittenTask extends TaskNodeParent {
|
|
private boolean hungry, attention;
|
|
|
|
public final Filter<Item> fishItemFilter = item -> {
|
|
for (String fishName : Constants.KITTEN_FISH_NAMES) {
|
|
String rawFishName = "Raw " + fishName.toLowerCase(Locale.ROOT);
|
|
|
|
if (item.getName().equals(fishName) || item.getName().equals(rawFishName)) {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
};
|
|
|
|
@Nullable
|
|
public static KittenTask getInstance() {
|
|
KittenTask task = null;
|
|
|
|
if (Inventory.contains(Constants.KITTEN_INVENTORY)) {
|
|
Inventory.drop(Constants.KITTEN_INVENTORY);
|
|
|
|
task = new KittenTask();
|
|
}
|
|
|
|
NPC kitten = CNPC.getNPCInteractingWithPlayer(Constants.KITTEN);
|
|
NPC cat = CNPC.getNPCInteractingWithPlayer(Constants.CAT);
|
|
|
|
if (kitten != null || cat != null) {
|
|
task = new KittenTask();
|
|
}
|
|
|
|
if (task != null) {
|
|
task.setChildren(
|
|
new CutFoodForKitten(task),
|
|
new FeedKitten(task),
|
|
new InteractKitten(task),
|
|
new PickupCat()
|
|
);
|
|
}
|
|
|
|
return task;
|
|
}
|
|
|
|
private KittenTask() {
|
|
ScriptManager.getScriptManager().addListener(new ChatListener() {
|
|
@Override
|
|
public void onMessage(Message message) {
|
|
if (message.getMessage().contains(Constants.KITTEN_WANTS_ATTENTION_MSG)) {
|
|
setAttention(true);
|
|
}
|
|
|
|
if (message.getMessage().contains(Constants.KITTEN_WAS_STROKED_MSG)) {
|
|
setAttention(false);
|
|
}
|
|
|
|
if (message.getMessage().contains(Constants.KITTEN_IS_HUNGRY_MSG)) {
|
|
setHungry(true);
|
|
}
|
|
|
|
if (message.getMessage().contains(Constants.KITTEN_HAS_EATEN_MSG)) {
|
|
setHungry(false);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
public void setHungry(boolean hungry) {
|
|
this.hungry = hungry;
|
|
}
|
|
|
|
public boolean isHungry() {
|
|
return hungry;
|
|
}
|
|
|
|
public void setAttention(boolean attention) {
|
|
this.attention = attention;
|
|
}
|
|
|
|
public boolean wantsAttention() {
|
|
return attention;
|
|
}
|
|
}
|