prevent stupid stuff & remove unused classes
This commit is contained in:
parent
5b7f3abf0d
commit
750ca0e387
3 changed files with 3 additions and 48 deletions
|
@ -1,23 +0,0 @@
|
|||
package io.github.znetworkw.znpcservers.utility;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collector;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public final class GuavaCollectors {
|
||||
public static <E> Collector<E, ?, ImmutableList<E>> toImmutableList() {
|
||||
return Collectors.collectingAndThen(Collectors.toList(), ImmutableList::copyOf);
|
||||
}
|
||||
|
||||
public static <E> Collector<E, ?, ImmutableSet<E>> toImmutableSet() {
|
||||
return Collectors.collectingAndThen(Collectors.toSet(), ImmutableSet::copyOf);
|
||||
}
|
||||
|
||||
public static <T, K, V> Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(Function<? super T, ? extends K> keyFunction, Function<? super T, ? extends V> valueFunction) {
|
||||
return Collectors.collectingAndThen(Collectors.toMap(keyFunction, valueFunction), ImmutableMap::copyOf);
|
||||
}
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
package io.github.znetworkw.znpcservers.utility;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public final class ReflectionUtils {
|
||||
public static Field findFieldForClass(Object instance, Class<?> type) {
|
||||
for (Field field : instance.getClass().getDeclaredFields()) {
|
||||
if (field.getType() == type) {
|
||||
field.setAccessible(true);
|
||||
return field;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Field findFieldForClassAndSet(Object instance, Class<?> type, Object value) throws ReflectiveOperationException {
|
||||
Field field = findFieldForClass(instance, type);
|
||||
if (field == null)
|
||||
return null;
|
||||
field.set(instance, value);
|
||||
return field;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package lol.pyr.znpcsplus.npc;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -12,7 +13,7 @@ public class NPCRegistry {
|
|||
}
|
||||
|
||||
public static Collection<NPC> all() {
|
||||
return NPC._ALL_NPCS;
|
||||
return Collections.unmodifiableSet(NPC._ALL_NPCS);
|
||||
}
|
||||
|
||||
public static NPC getByEntityId(int id) {
|
||||
|
@ -20,7 +21,7 @@ public class NPCRegistry {
|
|||
}
|
||||
|
||||
public static Collection<String> ids() {
|
||||
return npcMap.keySet();
|
||||
return Collections.unmodifiableSet(npcMap.keySet());
|
||||
}
|
||||
|
||||
public static void register(String id, NPC npc) {
|
||||
|
|
Loading…
Reference in a new issue