misc tidying

This commit is contained in:
Luck 2018-10-07 19:48:20 +01:00
parent dac59966aa
commit f96518b8e4
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
6 changed files with 18 additions and 21 deletions

View File

@ -90,10 +90,5 @@ public class BungeeContextManager extends ContextManager<ProxiedPlayer> {
public Contexts getContexts() {
return this.contextsCache.get(this.key);
}
@Override
public ImmutableContextSet getContextSet() {
return getContexts().getContexts().makeImmutable();
}
}
}

View File

@ -44,16 +44,16 @@ public final class ContextSetConfigurateSerializer {
ConfigurationNode data = SimpleConfigurationNode.root();
Map<String, Collection<String>> map = contextSet.toMultimap().asMap();
map.forEach((k, v) -> {
List<String> values = new ArrayList<>(v);
for (Map.Entry<String, Collection<String>> entry : map.entrySet()) {
List<String> values = new ArrayList<>(entry.getValue());
int size = values.size();
if (size == 1) {
data.getNode(k).setValue(values.get(0));
data.getNode(entry.getKey()).setValue(values.get(0));
} else if (size > 1) {
data.getNode(k).setValue(values);
data.getNode(entry.getKey()).setValue(values);
}
});
}
return data;
}

View File

@ -47,20 +47,20 @@ public final class ContextSetJsonSerializer {
JsonObject data = new JsonObject();
Map<String, Collection<String>> map = contextSet.toMultimap().asMap();
map.forEach((k, v) -> {
List<String> values = new ArrayList<>(v);
for (Map.Entry<String, Collection<String>> entry : map.entrySet()) {
List<String> values = new ArrayList<>(entry.getValue());
int size = values.size();
if (size == 1) {
data.addProperty(k, values.get(0));
data.addProperty(entry.getKey(), values.get(0));
} else if (size > 1) {
JsonArray arr = new JsonArray();
for (String s : values) {
arr.add(new JsonPrimitive(s));
}
data.add(k, arr);
data.add(entry.getKey(), arr);
}
});
}
return data;
}

View File

@ -35,6 +35,8 @@ public interface ContextsSupplier {
Contexts getContexts();
ImmutableContextSet getContextSet();
default ImmutableContextSet getContextSet() {
return getContexts().getContexts().makeImmutable();
}
}

View File

@ -92,7 +92,7 @@ public class UserHousekeeper implements Runnable {
private final long duration;
private final TimeUnit unit;
private TimeoutSettings(long duration, TimeUnit unit) {
TimeoutSettings(long duration, TimeUnit unit) {
this.duration = duration;
this.unit = unit;
}

View File

@ -47,7 +47,7 @@ public class RedisMessenger implements Messenger {
private final IncomingMessageConsumer consumer;
private JedisPool jedisPool;
private LPSub sub;
private Subscription sub;
public RedisMessenger(LuckPermsPlugin plugin, IncomingMessageConsumer consumer) {
this.plugin = plugin;
@ -66,7 +66,7 @@ public class RedisMessenger implements Messenger {
}
this.plugin.getBootstrap().getScheduler().executeAsync(() -> {
this.sub = new LPSub(this);
this.sub = new Subscription(this);
try (Jedis jedis = this.jedisPool.getResource()) {
jedis.subscribe(this.sub, CHANNEL);
} catch (Exception e) {
@ -90,10 +90,10 @@ public class RedisMessenger implements Messenger {
this.jedisPool.destroy();
}
private static class LPSub extends JedisPubSub {
private static class Subscription extends JedisPubSub {
private final RedisMessenger parent;
public LPSub(RedisMessenger parent) {
private Subscription(RedisMessenger parent) {
this.parent = parent;
}