Find people wearing stuff. Note: doesn't work with ammo and rings.
Example code:
import java.util.List;
import org.osbot.rs07.api.def.ItemDefinition;
import org.osbot.rs07.api.model.Player;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import com.liverare.api.AppearanceAPI;
@ScriptManifest(author = "", info = "", logo = "", name = "Test", version = 0)
public class Test extends Script {
AppearanceAPI appearance;
@Override
public void onStart() throws InterruptedException {
appearance = new AppearanceAPI();
appearance.exchangeContext(bot);
}
@Override
public int onLoop() throws InterruptedException {
pesterRichPeopleForFreeStuff();
return 100;
}
private void pesterRichPeopleForFreeStuff() {
List<Player> richPeople = appearance.findPlayersWielding(Test::isExpensiveItem);
if (richPeople != null && !richPeople.isEmpty()) {
// rich people spotted!
// prepare for pestering
// in 3...
}
}
private static boolean isExpensiveItem(ItemDefinition itemDefinition) {
String itemName = itemDefinition.getName();
return itemName.equals("Twisted bow")
|| itemName.equals("3rd age longsword")
|| itemName.equals("3rd age pickaxe")
|| itemName.equals("3rd age axe")
|| itemName.equals("3rd age cloak")
|| itemName.equals("Elysian spirit shield")
|| itemName.equals("3rd age bow");
}
}
Methods:
public List<Player> findPlayersWielding(List<Player> players, Predicate<ItemDefinition> itemDefinitionFilter)
public List<Player> findPlayersWielding(Predicate<ItemDefinition> itemDefinitionFilter)
public Player findPlayerWielding(List<Player> players, Predicate<ItemDefinition> itemDefinitionFilter)
public Player findPlayerWielding(Predicate<ItemDefinition> itemDefinitionFilter)
public static boolean isDefined(Player player, Predicate<ItemDefinition> itemDefinitionFilter)
private static boolean isDefined(int[] appearance, Predicate<ItemDefinition> itemDefinitionFilter)
Source: