use of org.powerbot.bot.EventDispatcher 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);
}
});
}
use of org.powerbot.bot.EventDispatcher 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