mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2024-11-22 20:28:00 +00:00
Perform some code tweaks and fix some spelling.
This commit is contained in:
parent
b5328c758b
commit
21710fcd8e
@ -76,11 +76,11 @@ public class DataManager implements Listener {
|
|||||||
}, 1, 1, TimeUnit.MINUTES);
|
}, 1, 1, TimeUnit.MINUTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <K, V> InternalCache<K, V> createCache() {
|
private static <K, V> InternalCache<K, V> createCache() {
|
||||||
return new InternalCache<>();
|
return new InternalCache<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <K, V> InternalCache<K, V> createCache(long entryWriteExpiry) {
|
private static <K, V> InternalCache<K, V> createCache(long entryWriteExpiry) {
|
||||||
return new InternalCache<>(entryWriteExpiry);
|
return new InternalCache<>(entryWriteExpiry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ public final class RedisBungee extends Plugin {
|
|||||||
@Getter
|
@Getter
|
||||||
private static OkHttpClient httpClient;
|
private static OkHttpClient httpClient;
|
||||||
private List<String> serverIds;
|
private List<String> serverIds;
|
||||||
private AtomicInteger nagAboutServers = new AtomicInteger();
|
private final AtomicInteger nagAboutServers = new AtomicInteger();
|
||||||
private ScheduledTask integrityCheck;
|
private ScheduledTask integrityCheck;
|
||||||
private ScheduledTask heartbeatTask;
|
private ScheduledTask heartbeatTask;
|
||||||
private boolean usingLua;
|
private boolean usingLua;
|
||||||
@ -107,7 +107,7 @@ public final class RedisBungee extends Plugin {
|
|||||||
return serverIds;
|
return serverIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<String> getCurrentServerIds() {
|
private List<String> getCurrentServerIds() {
|
||||||
try (Jedis jedis = pool.getResource()) {
|
try (Jedis jedis = pool.getResource()) {
|
||||||
int nag = nagAboutServers.decrementAndGet();
|
int nag = nagAboutServers.decrementAndGet();
|
||||||
if (nag <= 0) {
|
if (nag <= 0) {
|
||||||
@ -193,21 +193,21 @@ public final class RedisBungee extends Plugin {
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Set<UUID> getLocalPlayers() {
|
private Set<UUID> getLocalPlayers() {
|
||||||
ImmutableSet.Builder<UUID> setBuilder = ImmutableSet.builder();
|
ImmutableSet.Builder<UUID> setBuilder = ImmutableSet.builder();
|
||||||
for (ProxiedPlayer pp : getProxy().getPlayers())
|
for (ProxiedPlayer pp : getProxy().getPlayers())
|
||||||
setBuilder = setBuilder.add(pp.getUniqueId());
|
setBuilder = setBuilder.add(pp.getUniqueId());
|
||||||
return setBuilder.build();
|
return setBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
final Collection<String> getLocalPlayersAsUuidStrings() {
|
private Collection<String> getLocalPlayersAsUuidStrings() {
|
||||||
return Collections2.transform(getLocalPlayers(), Functions.toStringFunction());
|
return Collections2.transform(getLocalPlayers(), Functions.toStringFunction());
|
||||||
}
|
}
|
||||||
|
|
||||||
final Set<UUID> getPlayers() {
|
final Set<UUID> getPlayers() {
|
||||||
ImmutableSet.Builder<UUID> setBuilder = ImmutableSet.builder();
|
ImmutableSet.Builder<UUID> setBuilder = ImmutableSet.builder();
|
||||||
if (pool != null) {
|
if (pool != null) {
|
||||||
try (Jedis rsc = pool.getResource();) {
|
try (Jedis rsc = pool.getResource()) {
|
||||||
List<String> keys = new ArrayList<>();
|
List<String> keys = new ArrayList<>();
|
||||||
for (String i : getServerIds()) {
|
for (String i : getServerIds()) {
|
||||||
keys.add("proxy:" + i + ":usersOnline");
|
keys.add("proxy:" + i + ":usersOnline");
|
||||||
@ -454,12 +454,12 @@ public final class RedisBungee extends Plugin {
|
|||||||
crashFile.delete();
|
crashFile.delete();
|
||||||
} else if (rsc.hexists("heartbeats", serverId)) {
|
} else if (rsc.hexists("heartbeats", serverId)) {
|
||||||
try {
|
try {
|
||||||
Long value = Long.valueOf(rsc.hget("heartbeats", serverId));
|
long value = Long.parseLong(rsc.hget("heartbeats", serverId));
|
||||||
if (value != null && System.currentTimeMillis() < value + 20000) {
|
if (System.currentTimeMillis() < value + 20000) {
|
||||||
getLogger().severe("You have launched a possible impostor BungeeCord instance. Another instance is already running.");
|
getLogger().severe("You have launched a possible impostor BungeeCord instance. Another instance is already running.");
|
||||||
getLogger().severe("For data consistency reasons, RedisBungee will now disable itself.");
|
getLogger().severe("For data consistency reasons, RedisBungee will now disable itself.");
|
||||||
getLogger().severe("If this instance is coming up from a crash, create a file in your RedisBungee plugins directory with the name 'restarted_from_crash.txt' and RedisBungee will not perform this check.");
|
getLogger().severe("If this instance is coming up from a crash, create a file in your RedisBungee plugins directory with the name 'restarted_from_crash.txt' and RedisBungee will not perform this check.");
|
||||||
throw new RuntimeException("Possible imposter instance!");
|
throw new RuntimeException("Possible impostor instance!");
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException ignored) {
|
} catch (NumberFormatException ignored) {
|
||||||
}
|
}
|
||||||
@ -523,7 +523,7 @@ public final class RedisBungee extends Plugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class JedisPubSubHandler extends JedisPubSub {
|
private class JedisPubSubHandler extends JedisPubSub {
|
||||||
@Override
|
@Override
|
||||||
public void onMessage(final String s, final String s2) {
|
public void onMessage(final String s, final String s2) {
|
||||||
if (s2.trim().length() == 0) return;
|
if (s2.trim().length() == 0) return;
|
||||||
|
@ -51,7 +51,7 @@ public class UUIDFetcher implements Callable<Map<String, UUID>> {
|
|||||||
@Setter
|
@Setter
|
||||||
private static OkHttpClient httpClient;
|
private static OkHttpClient httpClient;
|
||||||
|
|
||||||
public UUIDFetcher(List<String> names, boolean rateLimiting) {
|
private UUIDFetcher(List<String> names, boolean rateLimiting) {
|
||||||
this.names = ImmutableList.copyOf(names);
|
this.names = ImmutableList.copyOf(names);
|
||||||
this.rateLimiting = rateLimiting;
|
this.rateLimiting = rateLimiting;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user