[ci skip] spotlessApply with the new settings

This commit is contained in:
Raven Szewczyk committed 2023-01-29 11:36:41 +00:00
1 parent 6b208b98bc
commit a309488cdf
214 files changed
+9283 -9265

No files matched your search

+65 -64
View File
@@ -1,7 +1,6 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
* To change this license header, choose License Headers in Project Properties. To change this template file, choose
* Tools | Templates and open the template in the editor.
*/
package minetweaker.util;
@@ -13,79 +12,81 @@ import minetweaker.api.event.IEventHandle;
* @author Stan
*/
public class EventList<T> {
private EventNode first = null;
private EventNode last = null;
public void clear() {
first = last = null;
}
private EventNode first = null;
private EventNode last = null;
public IEventHandle add(IEventHandler<T> handler) {
EventNode node = new EventNode(handler, last, null);
public void clear() {
first = last = null;
}
synchronized (this) {
if (first == null) {
first = node;
}
if (last != null) {
last.next = node;
}
last = node;
}
public IEventHandle add(IEventHandler<T> handler) {
EventNode node = new EventNode(handler, last, null);
return node;
}
synchronized (this) {
if (first == null) {
first = node;
}
if (last != null) {
last.next = node;
}
last = node;
}
public boolean hasHandlers() {
return first != null;
}
return node;
}
public boolean isEmpty() {
return first == null;
}
public boolean hasHandlers() {
return first != null;
}
public void publish(T event) {
EventNode current = null;
public boolean isEmpty() {
return first == null;
}
synchronized (this) {
current = first;
}
public void publish(T event) {
EventNode current = null;
while (current != null) {
current.handler.handle(event);
synchronized (this) {
current = first;
}
synchronized (this) {
current = current.next;
}
}
}
while (current != null) {
current.handler.handle(event);
private class EventNode implements IEventHandle {
private final IEventHandler<T> handler;
private EventNode next;
private EventNode prev;
synchronized (this) {
current = current.next;
}
}
}
public EventNode(IEventHandler<T> handler, EventNode prev, EventNode next) {
this.handler = handler;
this.prev = prev;
this.next = next;
}
private class EventNode implements IEventHandle {
@Override
public void close() {
synchronized (EventList.this) {
if (prev == null) {
first = next;
} else {
prev.next = next;
}
private final IEventHandler<T> handler;
private EventNode next;
private EventNode prev;
if (next == null) {
last = prev;
} else {
next.prev = 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) {
if (prev == null) {
first = next;
} else {
prev.next = next;
}
if (next == null) {
last = prev;
} else {
next.prev = prev;
}
}
}
}
}