mirror of
https://github.com/GTNewHorizons/CraftTweaker.git
synced 2026-11-24 22:04:23 +00:00
format all the things!
This commit is contained in:
1 parent
54ec75fd3d
commit
b36c6dade6
377 files changed
+6833
-6772
No files matched your search
@@ -15,15 +15,15 @@ import minetweaker.api.event.IEventHandle;
|
||||
public class EventList<T> {
|
||||
private EventNode first = null;
|
||||
private EventNode last = null;
|
||||
|
||||
|
||||
public void clear() {
|
||||
first = last = null;
|
||||
}
|
||||
|
||||
|
||||
public IEventHandle add(IEventHandler<T> handler) {
|
||||
EventNode node = new EventNode(handler, last, null);
|
||||
|
||||
synchronized(this) {
|
||||
|
||||
synchronized (this) {
|
||||
if (first == null) {
|
||||
first = node;
|
||||
}
|
||||
@@ -32,45 +32,45 @@ public class EventList<T> {
|
||||
}
|
||||
last = node;
|
||||
}
|
||||
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
public boolean hasHandlers() {
|
||||
return first != null;
|
||||
}
|
||||
|
||||
|
||||
public boolean isEmpty() {
|
||||
return first == null;
|
||||
}
|
||||
|
||||
|
||||
public void publish(T event) {
|
||||
EventNode current = null;
|
||||
|
||||
synchronized(this) {
|
||||
|
||||
synchronized (this) {
|
||||
current = first;
|
||||
}
|
||||
|
||||
|
||||
while (current != null) {
|
||||
current.handler.handle(event);
|
||||
|
||||
synchronized(this) {
|
||||
|
||||
synchronized (this) {
|
||||
current = current.next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class EventNode implements IEventHandle {
|
||||
private final IEventHandler<T> handler;
|
||||
private EventNode next;
|
||||
private EventNode prev;
|
||||
|
||||
|
||||
public EventNode(IEventHandler<T> handler, EventNode prev, EventNode next) {
|
||||
this.handler = handler;
|
||||
this.prev = prev;
|
||||
this.next = next;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
synchronized (EventList.this) {
|
||||
|
||||
Reference in new issue
Block a user