2
0
mirror of https://github.com/proxiodev/RedisBungee.git synced 2025-04-20 01:27:07 +00:00

cleanup InitialUtils class and change how some logs are sent

This commit is contained in:
mohammed jasem alaajel 2023-04-25 10:58:39 +04:00
parent 7df33e3e6a
commit eac00e1cd2
No known key found for this signature in database

View File

@ -12,8 +12,6 @@ package com.imaginarycode.minecraft.redisbungee.api.tasks;
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin; import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
import com.imaginarycode.minecraft.redisbungee.api.util.RedisUtil; import com.imaginarycode.minecraft.redisbungee.api.util.RedisUtil;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.Protocol; import redis.clients.jedis.Protocol;
import redis.clients.jedis.UnifiedJedis; import redis.clients.jedis.UnifiedJedis;
@ -28,12 +26,11 @@ public class InitialUtils {
@Override @Override
public Void unifiedJedisTask(UnifiedJedis unifiedJedis) { public Void unifiedJedisTask(UnifiedJedis unifiedJedis) {
// This is more portable than INFO <section> // This is more portable than INFO <section>
String info = new String((byte[]) unifiedJedis.sendCommand(Protocol.Command.INFO)); String info = new String((byte[]) unifiedJedis.sendCommand(Protocol.Command.INFO));
for (String s : info.split("\r\n")) { for (String s : info.split("\r\n")) {
if (s.startsWith("redis_version:")) { if (s.startsWith("redis_version:")) {
String version = s.split(":")[1]; String version = s.split(":")[1];
plugin.logInfo(version + " <- redis version"); plugin.logInfo("Redis server version: " + version);
if (!RedisUtil.isRedisVersionRight(version)) { if (!RedisUtil.isRedisVersionRight(version)) {
plugin.logFatal("Your version of Redis (" + version + ") is not at least version 3.0 RedisBungee requires a newer version of Redis."); plugin.logFatal("Your version of Redis (" + version + ") is not at least version 3.0 RedisBungee requires a newer version of Redis.");
throw new RuntimeException("Unsupported Redis version detected"); throw new RuntimeException("Unsupported Redis version detected");
@ -62,7 +59,7 @@ public class InitialUtils {
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
plugin.logInfo("crash file was deleted"); plugin.logInfo("crash file was deleted continuing RedisBungee startup ");
} else if (unifiedJedis.hexists("heartbeats", plugin.getConfiguration().getProxyId())) { } else if (unifiedJedis.hexists("heartbeats", plugin.getConfiguration().getProxyId())) {
try { try {
long value = Long.parseLong(unifiedJedis.hget("heartbeats", plugin.getConfiguration().getProxyId())); long value = Long.parseLong(unifiedJedis.hget("heartbeats", plugin.getConfiguration().getProxyId()));
@ -81,7 +78,7 @@ public class InitialUtils {
} }
private static void logImposter(RedisBungeePlugin<?> plugin) { private static void logImposter(RedisBungeePlugin<?> plugin) {
plugin.logFatal("You have launched a possible impostor Velocity / Bungeecord instance. Another instance is already running."); plugin.logFatal("You have launched a possible impostor Velocity / Bungeecord instance. Another instance is already running.");
plugin.logFatal("For data consistency reasons, RedisBungee will now disable itself."); plugin.logFatal("For data consistency reasons, RedisBungee will now disable itself.");
plugin.logFatal("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."); plugin.logFatal("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.");
} }