Search in sources :

Example 81 with Client

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;
}
Also used : Player(org.powerbot.bot.rt6.client.Player) ArrayList(java.util.ArrayList) Client(org.powerbot.bot.rt6.client.Client)

Example 82 with Client

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;
}
Also used : ArrayList(java.util.ArrayList) Client(org.powerbot.bot.rt6.client.Client) ProjectileNode(org.powerbot.bot.rt6.client.ProjectileNode) Projectile(org.powerbot.bot.rt6.client.Projectile)

Example 83 with Client

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;
}
Also used : Skill(org.powerbot.bot.rt6.client.Skill) PlayerFacade(org.powerbot.bot.rt6.client.PlayerFacade) Client(org.powerbot.bot.rt6.client.Client)

Example 84 with Client

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();
            }
        }
    });
}
Also used : Graphics(java.awt.Graphics) EventDispatcher(org.powerbot.bot.EventDispatcher) PaintListener(org.powerbot.script.PaintListener) MessageEvent(org.powerbot.script.MessageEvent) NodeSubQueue(org.powerbot.bot.rt6.client.NodeSubQueue) MessageEntry(org.powerbot.bot.rt6.client.MessageEntry) AtomicReference(java.util.concurrent.atomic.AtomicReference) Client(org.powerbot.bot.rt6.client.Client) NodeSub(org.powerbot.bot.rt6.client.NodeSub) AbstractBot(org.powerbot.bot.AbstractBot)

Aggregations

Client (org.powerbot.bot.rt4.client.Client)36 Client (org.powerbot.bot.rt6.client.Client)33 Point (java.awt.Point)25 ArrayList (java.util.ArrayList)13 Client (org.orcid.jaxb.model.v3.dev1.client.Client)11 Test (org.junit.Test)8 Tile (org.powerbot.script.Tile)8 ClientDetailsEntity (org.orcid.persistence.jpa.entities.ClientDetailsEntity)6 HashSet (java.util.HashSet)5 Rectangle (java.awt.Rectangle)4 Reflector (org.powerbot.bot.Reflector)4 Condition (org.powerbot.script.Condition)4 Client (client.Client)3 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)3 ClientRedirectUri (org.orcid.jaxb.model.v3.dev1.client.ClientRedirectUri)3 Graphics (java.awt.Graphics)2 LinkedList (java.util.LinkedList)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 ScopePathType (org.orcid.jaxb.model.message.ScopePathType)2