Search in sources :

Example 1 with NodeSub

use of org.powerbot.bot.rt6.client.NodeSub 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

Graphics (java.awt.Graphics)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 AbstractBot (org.powerbot.bot.AbstractBot)1 EventDispatcher (org.powerbot.bot.EventDispatcher)1 Client (org.powerbot.bot.rt6.client.Client)1 MessageEntry (org.powerbot.bot.rt6.client.MessageEntry)1 NodeSub (org.powerbot.bot.rt6.client.NodeSub)1 NodeSubQueue (org.powerbot.bot.rt6.client.NodeSubQueue)1 MessageEvent (org.powerbot.script.MessageEvent)1 PaintListener (org.powerbot.script.PaintListener)1