Fix issue with loading tracks with configurate

This commit is contained in:
Luck 2017-11-20 15:14:44 +00:00
parent cd0184970a
commit b3e78c6dc1
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
22 changed files with 53 additions and 47 deletions

View File

@ -218,7 +218,7 @@ public class LPSubscriptionMap extends HashMap<String, Map<Permissible, Boolean>
return ret != null ? Maps.immutableEntry(p, ret) : null;
})
.filter(Objects::nonNull)
.collect(ImmutableCollectors.toImmutableSet());
.collect(ImmutableCollectors.toSet());
}
@Override

View File

@ -51,8 +51,8 @@ public class AssignmentRule {
this.hasTrueExpression = AssignmentExpression.compile(hasTrueExpression);
this.hasFalseExpression = AssignmentExpression.compile(hasFalseExpression);
this.lacksExpression = AssignmentExpression.compile(lacksExpression);
this.toGive = toGive.stream().map(s -> LegacyNodeFactory.fromSerializedNode(s, true)).collect(ImmutableCollectors.toImmutableList());;
this.toTake = toTake.stream().map(s -> LegacyNodeFactory.fromSerializedNode(s, true)).collect(ImmutableCollectors.toImmutableList());
this.toGive = toGive.stream().map(s -> LegacyNodeFactory.fromSerializedNode(s, true)).collect(ImmutableCollectors.toList());;
this.toTake = toTake.stream().map(s -> LegacyNodeFactory.fromSerializedNode(s, true)).collect(ImmutableCollectors.toList());
this.setPrimaryGroup = setPrimaryGroup;
}

View File

@ -241,7 +241,7 @@ public class ConfigKeys {
* The configured group weightings
*/
public static final ConfigKey<Map<String, Integer>> GROUP_WEIGHTS = AbstractKey.of(c -> {
return c.getMap("group-weight", ImmutableMap.of()).entrySet().stream().collect(ImmutableCollectors.toImmutableMap(
return c.getMap("group-weight", ImmutableMap.of()).entrySet().stream().collect(ImmutableCollectors.toMap(
e -> e.getKey().toLowerCase(),
e -> {
try {
@ -352,7 +352,7 @@ public class ConfigKeys {
List<String> take = ImmutableList.copyOf(c.getList("default-assignments." + name + ".take", ImmutableList.of()));
String pg = c.getString("default-assignments." + name + ".set-primary-group", null);
return new AssignmentRule(hasTrue, hasFalse, lacks, give, take, pg);
}).collect(ImmutableCollectors.toImmutableList());
}).collect(ImmutableCollectors.toList());
});
/**

View File

@ -50,7 +50,7 @@ public final class SimpleMetaStack implements MetaStack {
this.targetType = targetType;
this.entries = definition.getElements().stream()
.map(element -> new SimpleMetaStackEntry(this, element, targetType))
.collect(ImmutableCollectors.toImmutableList());
.collect(ImmutableCollectors.toList());
}
@Override

View File

@ -110,7 +110,7 @@ public class StandardStackElements {
.map(s -> parseFromString(plugin, s))
.filter(Optional::isPresent)
.map(Optional::get)
.collect(ImmutableCollectors.toImmutableList());
.collect(ImmutableCollectors.toList());
}
/**

View File

@ -68,7 +68,7 @@ public class StorageFactory {
Set<String> neededTypes = new HashSet<>();
neededTypes.addAll(types.values());
return neededTypes.stream().map(StorageType::parse).collect(ImmutableCollectors.toImmutableSet());
return neededTypes.stream().map(StorageType::parse).collect(ImmutableCollectors.toSet());
} else {
String method = plugin.getConfiguration().get(ConfigKeys.STORAGE_METHOD);
StorageType type = StorageType.parse(method);

View File

@ -29,7 +29,6 @@ import lombok.Getter;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.common.reflect.TypeToken;
import me.lucko.luckperms.api.HeldPermission;
import me.lucko.luckperms.api.LogEntry;
@ -53,6 +52,7 @@ import me.lucko.luckperms.common.references.UserIdentifier;
import me.lucko.luckperms.common.storage.dao.AbstractDao;
import me.lucko.luckperms.common.storage.dao.legacy.LegacyJsonMigration;
import me.lucko.luckperms.common.storage.dao.legacy.LegacyYamlMigration;
import me.lucko.luckperms.common.utils.ImmutableCollectors;
import ninja.leaping.configurate.ConfigurationNode;
import ninja.leaping.configurate.SimpleConfigurationNode;
@ -628,7 +628,10 @@ public abstract class ConfigurateDao extends AbstractDao {
ConfigurationNode object = readFile(StorageLocation.TRACK, name);
if (object != null) {
List<String> groups = object.getNode("groups").getList(TypeToken.of(String.class));
List<String> groups = object.getNode("groups").getChildrenList().stream()
.map(ConfigurationNode::getString)
.collect(ImmutableCollectors.toList());
track.setGroups(groups);
} else {
ConfigurationNode data = SimpleConfigurationNode.root();
@ -664,7 +667,10 @@ public abstract class ConfigurateDao extends AbstractDao {
track.getIoLock().lock();
}
List<String> groups = object.getNode("groups").getList(TypeToken.of(String.class));
List<String> groups = object.getNode("groups").getChildrenList().stream()
.map(ConfigurationNode::getString)
.collect(ImmutableCollectors.toList());
track.setGroups(groups);
} catch (Exception e) {

View File

@ -51,17 +51,17 @@ public class ImmutableCollectors {
ImmutableSet.Builder::build
);
public static <T> Collector<T, ImmutableList.Builder<T>, ImmutableList<T>> toImmutableList() {
public static <T> Collector<T, ImmutableList.Builder<T>, ImmutableList<T>> toList() {
//noinspection unchecked
return (Collector) LIST;
}
public static <T> Collector<T, ImmutableSet.Builder<T>, ImmutableSet<T>> toImmutableSet() {
public static <T> Collector<T, ImmutableSet.Builder<T>, ImmutableSet<T>> toSet() {
//noinspection unchecked
return (Collector) SET;
}
public static <T, K, V> Collector<T, ImmutableMap.Builder<K, V>, ImmutableMap<K, V>> toImmutableMap(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valueMapper) {
public static <T, K, V> Collector<T, ImmutableMap.Builder<K, V>, ImmutableMap<K, V>> toMap(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valueMapper) {
return Collector.of(
ImmutableMap.Builder<K, V>::new,
(r, t) -> r.put(keyMapper.apply(t), valueMapper.apply(t)),

View File

@ -62,7 +62,7 @@ public class PermissionDescriptionProxy implements PermissionDescription {
@Override
public Map<Subject, Boolean> getAssignedSubjects(String s) {
return handle.getAssignedSubjects(s).entrySet().stream()
.collect(ImmutableCollectors.toImmutableMap(
.collect(ImmutableCollectors.toMap(
e -> new SubjectProxy(service, e.getKey().toReference()),
Map.Entry::getValue
));

View File

@ -70,7 +70,7 @@ public class PermissionServiceProxy implements PermissionService {
@Override
public Map<String, SubjectCollection> getKnownSubjects() {
return handle.getLoadedCollections().entrySet().stream()
.collect(ImmutableCollectors.toImmutableMap(
.collect(ImmutableCollectors.toMap(
Map.Entry::getKey,
e -> e.getValue().sponge()
));
@ -93,7 +93,7 @@ public class PermissionServiceProxy implements PermissionService {
@Override
public Collection<PermissionDescription> getDescriptions() {
return handle.getDescriptions().stream().map(LPPermissionDescription::sponge).collect(ImmutableCollectors.toImmutableSet());
return handle.getDescriptions().stream().map(LPPermissionDescription::sponge).collect(ImmutableCollectors.toSet());
}
@Override

View File

@ -72,7 +72,7 @@ public class SubjectCollectionProxy implements SubjectCollection {
return (List) handle.getAllIdentifiers()
.thenApply(ids -> ids.stream()
.map(s -> new SubjectProxy(service, service.newSubjectReference(getIdentifier(), s)))
.collect(ImmutableCollectors.toImmutableList())
.collect(ImmutableCollectors.toList())
).join();
}
@ -81,7 +81,7 @@ public class SubjectCollectionProxy implements SubjectCollection {
// again, these methods will lazily load subjects.
return (Map) handle.getAllWithPermission(s)
.thenApply(map -> map.entrySet().stream()
.collect(ImmutableCollectors.toImmutableMap(
.collect(ImmutableCollectors.toMap(
e -> new SubjectProxy(service, e.getKey()),
Map.Entry::getValue
))
@ -92,7 +92,7 @@ public class SubjectCollectionProxy implements SubjectCollection {
public Map<Subject, Boolean> getAllWithPermission(Set<Context> set, String s) {
return (Map) handle.getAllWithPermission(CompatibilityUtil.convertContexts(set), s)
.thenApply(map -> map.entrySet().stream()
.collect(ImmutableCollectors.toImmutableMap(
.collect(ImmutableCollectors.toMap(
e -> new SubjectProxy(service, e.getKey()),
Map.Entry::getValue
))

View File

@ -59,7 +59,7 @@ public class SubjectDataProxy implements SubjectData {
public Map<Set<Context>, Map<String, Boolean>> getAllPermissions() {
return (Map) getHandle().thenApply(handle -> {
return handle.getAllPermissions().entrySet().stream()
.collect(ImmutableCollectors.toImmutableMap(
.collect(ImmutableCollectors.toMap(
e -> CompatibilityUtil.convertContexts(e.getKey()),
Map.Entry::getValue
));
@ -96,11 +96,11 @@ public class SubjectDataProxy implements SubjectData {
@Override
public Map<Set<Context>, List<Subject>> getAllParents() {
return (Map) getHandle().thenApply(handle -> handle.getAllParents().entrySet().stream()
.collect(ImmutableCollectors.toImmutableMap(
.collect(ImmutableCollectors.toMap(
e -> CompatibilityUtil.convertContexts(e.getKey()),
e -> e.getValue().stream()
.map(s -> new SubjectProxy(service, s))
.collect(ImmutableCollectors.toImmutableList())
.collect(ImmutableCollectors.toList())
)
)).join();
}
@ -109,7 +109,7 @@ public class SubjectDataProxy implements SubjectData {
public List<Subject> getParents(Set<Context> contexts) {
return (List) getHandle().thenApply(handle -> handle.getParents(CompatibilityUtil.convertContexts(contexts)).stream()
.map(s -> new SubjectProxy(service, s))
.collect(ImmutableCollectors.toImmutableList())).join();
.collect(ImmutableCollectors.toList())).join();
}
@Override
@ -151,7 +151,7 @@ public class SubjectDataProxy implements SubjectData {
@Override
public Map<Set<Context>, Map<String, String>> getAllOptions() {
return (Map) getHandle().thenApply(handle -> handle.getAllOptions().entrySet().stream()
.collect(ImmutableCollectors.toImmutableMap(
.collect(ImmutableCollectors.toMap(
e -> CompatibilityUtil.convertContexts(e.getKey()),
Map.Entry::getValue
))).join();

View File

@ -117,14 +117,14 @@ public class SubjectProxy implements Subject {
public List<Subject> getParents() {
return (List) getHandle().thenApply(handle -> handle.getParents(ImmutableContextSet.empty()).stream()
.map(s -> new SubjectProxy(service, s))
.collect(ImmutableCollectors.toImmutableList())).join();
.collect(ImmutableCollectors.toList())).join();
}
@Override
public List<Subject> getParents(Set<Context> contexts) {
return (List) getHandle().thenApply(handle -> handle.getParents(CompatibilityUtil.convertContexts(contexts)).stream()
.map(s -> new SubjectProxy(service, s))
.collect(ImmutableCollectors.toImmutableList())).join();
.collect(ImmutableCollectors.toList())).join();
}
@Override

View File

@ -64,7 +64,7 @@ public class PermissionDescriptionProxy implements PermissionDescription {
@Override
public Map<Subject, Boolean> getAssignedSubjects(String s) {
return handle.getAssignedSubjects(s).entrySet().stream()
.collect(ImmutableCollectors.toImmutableMap(
.collect(ImmutableCollectors.toMap(
e -> new SubjectProxy(service, e.getKey().toReference()),
Map.Entry::getValue
));

View File

@ -92,7 +92,7 @@ public class PermissionServiceProxy implements PermissionService {
@Override
public Map<String, SubjectCollection> getLoadedCollections() {
return handle.getLoadedCollections().entrySet().stream()
.collect(ImmutableCollectors.toImmutableMap(
.collect(ImmutableCollectors.toMap(
Map.Entry::getKey,
e -> e.getValue().sponge()
));
@ -125,7 +125,7 @@ public class PermissionServiceProxy implements PermissionService {
@Override
public Collection<PermissionDescription> getDescriptions() {
return handle.getDescriptions().stream().map(LPPermissionDescription::sponge).collect(ImmutableCollectors.toImmutableSet());
return handle.getDescriptions().stream().map(LPPermissionDescription::sponge).collect(ImmutableCollectors.toSet());
}
@Override

View File

@ -76,12 +76,12 @@ public class SubjectCollectionProxy implements SubjectCollection {
@Override
public CompletableFuture<Map<String, Subject>> loadSubjects(Set<String> set) {
return handle.loadSubjects(set).thenApply(subs -> subs.stream().collect(ImmutableCollectors.toImmutableMap(LPSubject::getIdentifier, LPSubject::sponge)));
return handle.loadSubjects(set).thenApply(subs -> subs.stream().collect(ImmutableCollectors.toMap(LPSubject::getIdentifier, LPSubject::sponge)));
}
@Override
public Collection<Subject> getLoadedSubjects() {
return handle.getLoadedSubjects().stream().map(LPSubject::sponge).collect(ImmutableCollectors.toImmutableSet());
return handle.getLoadedSubjects().stream().map(LPSubject::sponge).collect(ImmutableCollectors.toSet());
}
@Override
@ -107,7 +107,7 @@ public class SubjectCollectionProxy implements SubjectCollection {
@Override
public Map<Subject, Boolean> getLoadedWithPermission(String s) {
return handle.getLoadedWithPermission(s).entrySet().stream()
.collect(ImmutableCollectors.toImmutableMap(
.collect(ImmutableCollectors.toMap(
sub -> sub.getKey().sponge(),
Map.Entry::getValue
));
@ -116,7 +116,7 @@ public class SubjectCollectionProxy implements SubjectCollection {
@Override
public Map<Subject, Boolean> getLoadedWithPermission(Set<Context> set, String s) {
return handle.getLoadedWithPermission(CompatibilityUtil.convertContexts(set), s).entrySet().stream()
.collect(ImmutableCollectors.toImmutableMap(
.collect(ImmutableCollectors.toMap(
sub -> sub.getKey().sponge(),
Map.Entry::getValue
));

View File

@ -60,7 +60,7 @@ public class SubjectDataProxy implements SubjectData {
@Override
public Map<Set<Context>, Map<String, Boolean>> getAllPermissions() {
return (Map) getHandle().thenApply(handle -> handle.getAllPermissions().entrySet().stream()
.collect(ImmutableCollectors.toImmutableMap(
.collect(ImmutableCollectors.toMap(
e -> CompatibilityUtil.convertContexts(e.getKey()),
Map.Entry::getValue
))).join();
@ -93,7 +93,7 @@ public class SubjectDataProxy implements SubjectData {
@Override
public Map<Set<Context>, List<org.spongepowered.api.service.permission.SubjectReference>> getAllParents() {
return (Map) getHandle().thenApply(handle -> handle.getAllParents().entrySet().stream()
.collect(ImmutableCollectors.toImmutableMap(
.collect(ImmutableCollectors.toMap(
e -> CompatibilityUtil.convertContexts(e.getKey()),
Map.Entry::getValue
))).join();
@ -127,7 +127,7 @@ public class SubjectDataProxy implements SubjectData {
@Override
public Map<Set<Context>, Map<String, String>> getAllOptions() {
return (Map) getHandle().thenApply(handle -> handle.getAllOptions().entrySet().stream()
.collect(ImmutableCollectors.toImmutableMap(
.collect(ImmutableCollectors.toMap(
e -> CompatibilityUtil.convertContexts(e.getKey()),
Map.Entry::getValue
))).join();

View File

@ -53,7 +53,7 @@ public class CompatibilityUtil {
private static final LoadingCache<ImmutableContextSet, ImmutableSet<Context>> LP_TO_SPONGE_CACHE = Caffeine.newBuilder()
.expireAfterAccess(10, TimeUnit.MINUTES)
.build(set -> set.toSet().stream().map(e -> new Context(e.getKey(), e.getValue())).collect(ImmutableCollectors.toImmutableSet()));
.build(set -> set.toSet().stream().map(e -> new Context(e.getKey(), e.getValue())).collect(ImmutableCollectors.toSet()));
public static ImmutableContextSet convertContexts(@NonNull Set<Context> contexts) {
return SPONGE_TO_LP_CACHE.get(ImmutableSet.copyOf(contexts));

View File

@ -222,7 +222,7 @@ public class SpongeMainCommand extends Command<Void, LPSubjectData> {
}
public List<Command<LPSubjectData, ?>> getSubCommands() {
return subCommands.values().stream().flatMap(List::stream).collect(ImmutableCollectors.toImmutableList());
return subCommands.values().stream().flatMap(List::stream).collect(ImmutableCollectors.toList());
}
@Override

View File

@ -221,7 +221,7 @@ public class SpongeGroupManager implements GroupManager, LPSubjectCollection {
@Override
public ImmutableCollection<LPSubject> getLoadedSubjects() {
return getAll().values().stream().map(SpongeGroup::sponge).collect(ImmutableCollectors.toImmutableSet());
return getAll().values().stream().map(SpongeGroup::sponge).collect(ImmutableCollectors.toSet());
}
@Override
@ -267,7 +267,7 @@ public class SpongeGroupManager implements GroupManager, LPSubjectCollection {
.map(SpongeGroup::sponge)
.map(sub -> Maps.immutableEntry(sub, sub.getPermissionValue(ImmutableContextSet.empty(), permission)))
.filter(pair -> pair.getValue() != Tristate.UNDEFINED)
.collect(ImmutableCollectors.toImmutableMap(Map.Entry::getKey, sub -> sub.getValue().asBoolean()));
.collect(ImmutableCollectors.toMap(Map.Entry::getKey, sub -> sub.getValue().asBoolean()));
}
@Override
@ -276,7 +276,7 @@ public class SpongeGroupManager implements GroupManager, LPSubjectCollection {
.map(SpongeGroup::sponge)
.map(sub -> Maps.immutableEntry(sub, sub.getPermissionValue(contexts, permission)))
.filter(pair -> pair.getValue() != Tristate.UNDEFINED)
.collect(ImmutableCollectors.toImmutableMap(Map.Entry::getKey, sub -> sub.getValue().asBoolean()));
.collect(ImmutableCollectors.toMap(Map.Entry::getKey, sub -> sub.getValue().asBoolean()));
}
@Override

View File

@ -311,7 +311,7 @@ public class SpongeUserManager implements UserManager, LPSubjectCollection {
@Override
public ImmutableCollection<LPSubject> getLoadedSubjects() {
return getAll().values().stream().map(SpongeUser::sponge).collect(ImmutableCollectors.toImmutableSet());
return getAll().values().stream().map(SpongeUser::sponge).collect(ImmutableCollectors.toSet());
}
@Override
@ -364,7 +364,7 @@ public class SpongeUserManager implements UserManager, LPSubjectCollection {
.map(SpongeUser::sponge)
.map(sub -> Maps.immutableEntry(sub, sub.getPermissionValue(ImmutableContextSet.empty(), permission)))
.filter(pair -> pair.getValue() != Tristate.UNDEFINED)
.collect(ImmutableCollectors.toImmutableMap(Map.Entry::getKey, sub -> sub.getValue().asBoolean()));
.collect(ImmutableCollectors.toMap(Map.Entry::getKey, sub -> sub.getValue().asBoolean()));
}
@Override
@ -373,7 +373,7 @@ public class SpongeUserManager implements UserManager, LPSubjectCollection {
.map(SpongeUser::sponge)
.map(sub -> Maps.immutableEntry(sub, sub.getPermissionValue(contexts, permission)))
.filter(pair -> pair.getValue() != Tristate.UNDEFINED)
.collect(ImmutableCollectors.toImmutableMap(Map.Entry::getKey, sub -> sub.getValue().asBoolean()));
.collect(ImmutableCollectors.toMap(Map.Entry::getKey, sub -> sub.getValue().asBoolean()));
}
@Override

View File

@ -130,13 +130,13 @@ public class PersistedCollection implements LPSubjectCollection {
@Override
public CompletableFuture<ImmutableMap<SubjectReference, Boolean>> getAllWithPermission(String permission) {
return CompletableFuture.completedFuture(getLoadedWithPermission(permission).entrySet().stream()
.collect(ImmutableCollectors.toImmutableMap(e -> e.getKey().toReference(), Map.Entry::getValue)));
.collect(ImmutableCollectors.toMap(e -> e.getKey().toReference(), Map.Entry::getValue)));
}
@Override
public CompletableFuture<ImmutableMap<SubjectReference, Boolean>> getAllWithPermission(ImmutableContextSet contexts, String permission) {
return CompletableFuture.completedFuture(getLoadedWithPermission(contexts, permission).entrySet().stream()
.collect(ImmutableCollectors.toImmutableMap(e -> e.getKey().toReference(), Map.Entry::getValue)));
.collect(ImmutableCollectors.toMap(e -> e.getKey().toReference(), Map.Entry::getValue)));
}
@Override