Search in sources :

Example 1 with MessageEntry

use of org.powerbot.bot.rt6.client.MessageEntry 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<Entry> previous = new AtomicReference<Entry>(null);

        @Override
        public void repaint(final Graphics graphics) {
            final Client client = ctx.client();
            if (client == null) {
                return;
            }
            final EntryList q = client.getLoggerEntries();
            final Entry s = q.getSentinel();
            Entry c = s.getNext();
            final Entry f = c;
            while (!s.equals(c) && !c.isNull() && !c.equals(previous.get())) {
                final MessageEntry m = new MessageEntry(c.reflector, c);
                e.dispatch(new MessageEvent(m));
                c = c.getNext();
            }
            previous.set(f);
        }
    });
}
Also used : Graphics(java.awt.Graphics) Entry(org.powerbot.bot.rt4.client.Entry) MessageEntry(org.powerbot.bot.rt4.client.MessageEntry) EventDispatcher(org.powerbot.bot.EventDispatcher) PaintListener(org.powerbot.script.PaintListener) MessageEvent(org.powerbot.script.MessageEvent) MessageEntry(org.powerbot.bot.rt4.client.MessageEntry) AtomicReference(java.util.concurrent.atomic.AtomicReference) EntryList(org.powerbot.bot.rt4.client.EntryList) Client(org.powerbot.bot.rt4.client.Client) AbstractBot(org.powerbot.bot.AbstractBot)

Example 2 with MessageEntry

use of org.powerbot.bot.rt6.client.MessageEntry 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)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 AbstractBot (org.powerbot.bot.AbstractBot)2 EventDispatcher (org.powerbot.bot.EventDispatcher)2 MessageEvent (org.powerbot.script.MessageEvent)2 PaintListener (org.powerbot.script.PaintListener)2 Client (org.powerbot.bot.rt4.client.Client)1 Entry (org.powerbot.bot.rt4.client.Entry)1 EntryList (org.powerbot.bot.rt4.client.EntryList)1 MessageEntry (org.powerbot.bot.rt4.client.MessageEntry)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