3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-26 00:00:28 +01:00

synchronize all the things!

Dieser Commit ist enthalten in:
Myles 2016-03-09 14:12:50 +00:00
Ursprung 463327c2a7
Commit fed36c9487
2 geänderte Dateien mit 30 neuen und 29 gelöschten Zeilen

Datei anzeigen

@ -119,18 +119,19 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
final Object value = field.get(connection); final Object value = field.get(connection);
if (value instanceof List) { if (value instanceof List) {
// Inject the list // Inject the list
field.set(connection, new ListWrapper((List) value) { List wrapper = new ListWrapper((List) value) {
@Override @Override
public void handleAdd(Object o) { public synchronized void handleAdd(Object o) {
synchronized (value) { synchronized (this) {
if (o instanceof ChannelFuture) { if (o instanceof ChannelFuture) {
inject((ChannelFuture) o); inject((ChannelFuture) o);
} }
} }
} }
}); };
field.set(connection, wrapper);
// Iterate through current list // Iterate through current list
synchronized (value) { synchronized (wrapper) {
for (Object o : (List) value) { for (Object o : (List) value) {
if (o instanceof ChannelFuture) { if (o instanceof ChannelFuture) {
inject((ChannelFuture) o); inject((ChannelFuture) o);

Datei anzeigen

@ -15,43 +15,43 @@ public abstract class ListWrapper implements List {
public abstract void handleAdd(Object o); public abstract void handleAdd(Object o);
@Override @Override
public int size() { public synchronized int size() {
return this.list.size(); return this.list.size();
} }
@Override @Override
public boolean isEmpty() { public synchronized boolean isEmpty() {
return this.list.isEmpty(); return this.list.isEmpty();
} }
@Override @Override
public boolean contains(Object o) { public synchronized boolean contains(Object o) {
return this.list.contains(o); return this.list.contains(o);
} }
@Override @Override
public Iterator iterator() { public synchronized Iterator iterator() {
return this.list.iterator(); return this.list.iterator();
} }
@Override @Override
public Object[] toArray() { public synchronized Object[] toArray() {
return this.list.toArray(); return this.list.toArray();
} }
@Override @Override
public boolean add(Object o) { public synchronized boolean add(Object o) {
handleAdd(o); handleAdd(o);
return this.list.add(o); return this.list.add(o);
} }
@Override @Override
public boolean remove(Object o) { public synchronized boolean remove(Object o) {
return this.list.remove(o); return this.list.remove(o);
} }
@Override @Override
public boolean addAll(Collection c) { public synchronized boolean addAll(Collection c) {
for (Object o : c) { for (Object o : c) {
handleAdd(o); handleAdd(o);
} }
@ -59,7 +59,7 @@ public abstract class ListWrapper implements List {
} }
@Override @Override
public boolean addAll(int index, Collection c) { public synchronized boolean addAll(int index, Collection c) {
for (Object o : c) { for (Object o : c) {
handleAdd(o); handleAdd(o);
} }
@ -67,72 +67,72 @@ public abstract class ListWrapper implements List {
} }
@Override @Override
public void clear() { public synchronized void clear() {
this.list.clear(); this.list.clear();
} }
@Override @Override
public Object get(int index) { public synchronized Object get(int index) {
return this.list.get(index); return this.list.get(index);
} }
@Override @Override
public Object set(int index, Object element) { public synchronized Object set(int index, Object element) {
return this.list.set(index, element); return this.list.set(index, element);
} }
@Override @Override
public void add(int index, Object element) { public synchronized void add(int index, Object element) {
this.list.add(index, element); this.list.add(index, element);
} }
@Override @Override
public Object remove(int index) { public synchronized Object remove(int index) {
return this.list.remove(index); return this.list.remove(index);
} }
@Override @Override
public int indexOf(Object o) { public synchronized int indexOf(Object o) {
return this.list.indexOf(o); return this.list.indexOf(o);
} }
@Override @Override
public int lastIndexOf(Object o) { public synchronized int lastIndexOf(Object o) {
return this.list.lastIndexOf(o); return this.list.lastIndexOf(o);
} }
@Override @Override
public ListIterator listIterator() { public synchronized ListIterator listIterator() {
return this.list.listIterator(); return this.list.listIterator();
} }
@Override @Override
public ListIterator listIterator(int index) { public synchronized ListIterator listIterator(int index) {
return this.listIterator(index); return this.list.listIterator(index);
} }
@Override @Override
public List subList(int fromIndex, int toIndex) { public synchronized List subList(int fromIndex, int toIndex) {
return this.list.subList(fromIndex, toIndex); return this.list.subList(fromIndex, toIndex);
} }
@Override @Override
public boolean retainAll(Collection c) { public synchronized boolean retainAll(Collection c) {
return this.list.retainAll(c); return this.list.retainAll(c);
} }
@Override @Override
public boolean removeAll(Collection c) { public synchronized boolean removeAll(Collection c) {
return this.list.removeAll(c); return this.list.removeAll(c);
} }
@Override @Override
public boolean containsAll(Collection c) { public synchronized boolean containsAll(Collection c) {
return this.list.containsAll(c); return this.list.containsAll(c);
} }
@Override @Override
public Object[] toArray(Object[] a) { public synchronized Object[] toArray(Object[] a) {
return this.list.toArray(a); return this.list.toArray(a);
} }
} }