use of client.Client in project powerbot by powerbot.
the class Players method get.
/**
* Returns all the {@link org.powerbot.script.rt6.Player}s in the region.
*
* @return an array of all the loaded {@link org.powerbot.script.rt6.Player}s
*/
@Override
protected List<org.powerbot.script.rt6.Player> get() {
final List<org.powerbot.script.rt6.Player> players = new ArrayList<org.powerbot.script.rt6.Player>();
final Client client = ctx.client();
if (client == null) {
return players;
}
final int count = client.getPlayerCount();
final int[] keys = client.getPlayerIndices();
final Player[] arr = client.getPlayers();
if (keys == null || arr == null) {
return players;
}
for (int i = 0; i < Math.min(Math.min(keys.length, arr.length), count); i++) {
final int key = keys[i];
final Player player = arr[key];
if (!player.isNull()) {
players.add(new org.powerbot.script.rt6.Player(ctx, player));
}
}
return players;
}
use of client.Client in project powerbot by powerbot.
the class Projectiles method get.
/**
* {@inheritDoc}
*/
@Override
protected List<org.powerbot.script.rt6.Projectile> get() {
final List<org.powerbot.script.rt6.Projectile> items = new ArrayList<org.powerbot.script.rt6.Projectile>();
final Client client = ctx.client();
if (client == null) {
return items;
}
for (final ProjectileNode n : NodeQueue.get(client.getProjectileDeque(), ProjectileNode.class)) {
final Projectile p = n.getProjectile();
if (!p.isNull()) {
items.add(new org.powerbot.script.rt6.Projectile(ctx, p));
}
}
return items;
}
use of client.Client in project powerbot by powerbot.
the class Skills method levels.
public int[] levels() {
final Client client = ctx.client();
if (client == null) {
return new int[0];
}
final PlayerFacade info = client.getPlayerFacade();
final Skill[] skills;
if (info == null || (skills = info.getSkills()) == null) {
return new int[0];
}
final int[] levels = new int[skills.length];
for (int i = 0; i < skills.length; i++) {
final Skill s = skills[i];
if (!s.isNull()) {
levels[i] = s.getEffectiveLevel();
}
}
return levels;
}
use of client.Client in project powerbot by powerbot.
the class Chat method register.
public void register() {
if (!registered.compareAndSet(false, true)) {
return;
}
final EventDispatcher e = ((AbstractBot) ctx.bot()).dispatcher;
e.add(new PaintListener() {
private final AtomicReference<NodeSub> previous = new AtomicReference<NodeSub>(null);
@Override
public void repaint(final Graphics graphics) {
final Client client = ctx.client();
if (client == null) {
return;
}
final NodeSubQueue q = client.getLoggerEntries();
final NodeSub s = q.getSentinel();
NodeSub c = s.getNextSub();
if (previous.get() != null && !previous.get().isNull()) {
final NodeSub n = previous.get().getNextSub();
c = n.isNull() ? c : n;
}
while (!s.equals(c)) {
final MessageEntry m = new MessageEntry(c.reflector, c);
e.dispatch(new MessageEvent(m));
previous.set(c);
c = c.getNextSub();
}
}
});
}
Aggregations