net.minecraft.server.EntitySlice Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of chest-server Show documentation
Show all versions of chest-server Show documentation
A spigot fork to kotlin structure and news.
The newest version!
package net.minecraft.server;
import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import java.util.*;
public class EntitySlice extends AbstractSet {
private static final Set> a = Sets.newConcurrentHashSet(); // CraftBukkit
private final Map, List> b = Maps.newHashMap();
private final Set> c = Sets.newIdentityHashSet();
private final Class d;
private final List e = Lists.newArrayList();
public EntitySlice(Class oclass) {
this.d = oclass;
this.c.add(oclass);
this.b.put(oclass, this.e);
Iterator iterator = EntitySlice.a.iterator();
while (iterator.hasNext()) {
Class oclass1 = (Class) iterator.next();
this.a(oclass1);
}
}
protected void a(Class> oclass) {
EntitySlice.a.add(oclass);
Iterator iterator = this.e.iterator();
while (iterator.hasNext()) {
Object object = iterator.next();
if (oclass.isAssignableFrom(object.getClass())) {
this.a((T) object, oclass);
}
}
this.c.add(oclass);
}
protected Class> b(Class> oclass) {
if (this.d.isAssignableFrom(oclass)) {
if (!this.c.contains(oclass)) {
this.a(oclass);
}
return oclass;
} else {
throw new IllegalArgumentException("Don't know how to search for " + oclass);
}
}
public boolean add(T t0) {
Iterator iterator = this.c.iterator();
while (iterator.hasNext()) {
Class oclass = (Class) iterator.next();
if (oclass.isAssignableFrom(t0.getClass())) {
this.a(t0, oclass);
}
}
return true;
}
private void a(T t0, Class> oclass) {
List list = this.b.get(oclass);
if (list == null) {
this.b.put(oclass, Lists.newArrayList(t0));
} else {
list.add(t0);
}
}
public boolean remove(Object object) {
Object object1 = object;
boolean flag = false;
Iterator iterator = this.c.iterator();
while (iterator.hasNext()) {
Class oclass = (Class) iterator.next();
if (oclass.isAssignableFrom(object1.getClass())) {
List list = this.b.get(oclass);
if (list != null && list.remove(object1)) {
flag = true;
}
}
}
return flag;
}
public boolean contains(Object object) {
return Iterators.contains(this.c(object.getClass()).iterator(), object);
}
public Iterable c(final Class oclass) {
return (Iterable) () -> {
List list = EntitySlice.this.b.get(EntitySlice.this.b(oclass));
if (list == null) {
return Iterators.emptyIterator();
} else {
Iterator iterator = list.iterator();
return Iterators.filter(iterator, oclass);
}
};
}
public Iterator iterator() {
return this.e.isEmpty() ? Iterators.emptyIterator() : Iterators.unmodifiableIterator(this.e.iterator());
}
public int size() {
return this.e.size();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy