mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-04 22:16:22 +00:00
Add console log when redis starts up
This commit is contained in:
1 parent
1334e1a1ae
commit
4328c57222
1 file changed
+7
-2
@@ -2,7 +2,6 @@ package me.william278.huskhomes2.data.message.redis;
|
||||
|
||||
import me.william278.huskhomes2.HuskHomes;
|
||||
import me.william278.huskhomes2.data.message.CrossServerMessageHandler;
|
||||
import me.william278.huskhomes2.data.message.pluginmessage.PluginMessage;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import redis.clients.jedis.Jedis;
|
||||
@@ -13,6 +12,7 @@ import java.util.Collections;
|
||||
|
||||
public class RedisReceiver {
|
||||
|
||||
private static final HuskHomes plugin = HuskHomes.getInstance();
|
||||
public static final String REDIS_CHANNEL = "HuskHomes";
|
||||
|
||||
private static Player getRandomReceiver() {
|
||||
@@ -31,6 +31,8 @@ public class RedisReceiver {
|
||||
jedis.auth(jedisPassword);
|
||||
}
|
||||
jedis.connect();
|
||||
if (jedis.isConnected()) {
|
||||
plugin.getLogger().info("Enabled Redis listener successfully!");
|
||||
new Thread(() -> jedis.subscribe(new JedisPubSub() {
|
||||
@Override
|
||||
public void onMessage(String channel, String message) {
|
||||
@@ -71,7 +73,7 @@ public class RedisReceiver {
|
||||
if (target.split("-")[1].equalsIgnoreCase(HuskHomes.getSettings().getServerID())) {
|
||||
receiver = getRandomReceiver();
|
||||
} else {
|
||||
return; // The message was targeting another server
|
||||
return; // The message was targeting another server; ignore
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,5 +89,8 @@ public class RedisReceiver {
|
||||
CrossServerMessageHandler.handlePluginMessage(new RedisMessage(clusterID, receiver.getName(), messageType, messageData), receiver);
|
||||
}
|
||||
}, REDIS_CHANNEL), "Redis Subscriber").start();
|
||||
} else {
|
||||
plugin.getLogger().severe("Failed to initialize the redis listener!");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user