Fix issue with loading tracks with configurate

This commit is contained in:
Luck
2017-11-20 15:14:44 +00:00
Unverified
parent cd0184970a
commit b3e78c6dc1
22 changed files with 53 additions and 47 deletions
@@ -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;
}
@@ -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());
});
/**
@@ -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
@@ -110,7 +110,7 @@ public class StandardStackElements {
.map(s -> parseFromString(plugin, s))
.filter(Optional::isPresent)
.map(Optional::get)
.collect(ImmutableCollectors.toImmutableList());
.collect(ImmutableCollectors.toList());
}
/**
@@ -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);
@@ -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) {
@@ -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)),