mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-23 19:16:37 +01:00
Fix startup on Nukkit (#2290)
This commit is contained in:
parent
918ea7503a
commit
c120fa6a4d
@ -71,7 +71,7 @@ public class DummyPermissibleBase extends PermissibleBase {
|
||||
try {
|
||||
ATTACHMENTS_FIELD.set(this, EmptyCollections.list());
|
||||
PERMISSIONS_FIELD.set(this, EmptyCollections.map());
|
||||
} catch (ReflectiveOperationException e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,9 @@ package me.lucko.luckperms.common.util;
|
||||
|
||||
import java.util.AbstractList;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.AbstractSet;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@ -39,6 +41,7 @@ public final class EmptyCollections {
|
||||
private EmptyCollections() {}
|
||||
|
||||
private static final EmptyList<?> LIST = new EmptyList<>();
|
||||
private static final EmptySet<?> SET = new EmptySet<>();
|
||||
private static final EmptyMap<?, ?> MAP = new EmptyMap<>();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@ -46,6 +49,11 @@ public final class EmptyCollections {
|
||||
return (List<E>) LIST;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <E> Set<E> set() {
|
||||
return (Set<E>) SET;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <K, V> Map<K, V> map() {
|
||||
return (Map<K, V>) MAP;
|
||||
@ -78,6 +86,23 @@ public final class EmptyCollections {
|
||||
}
|
||||
}
|
||||
|
||||
private static final class EmptySet<E> extends AbstractSet<E> {
|
||||
@Override
|
||||
public Iterator<E> iterator() {
|
||||
return Collections.emptyIterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(E e) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private static final class EmptyMap<K, V> extends AbstractMap<K, V> {
|
||||
@Override
|
||||
public Set<Entry<K, V>> entrySet() {
|
||||
|
@ -68,9 +68,9 @@ public class DummyPermissibleBase extends PermissibleBase {
|
||||
super(null);
|
||||
|
||||
try {
|
||||
ATTACHMENTS_FIELD.set(this, EmptyCollections.list());
|
||||
ATTACHMENTS_FIELD.set(this, EmptyCollections.set());
|
||||
PERMISSIONS_FIELD.set(this, EmptyCollections.map());
|
||||
} catch (ReflectiveOperationException e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user