mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 06:28:49 +00:00
Authenticate when creating the RedisPool
This commit is contained in:
1 parent
d3b0f38b46
commit
83cd61689a
2 files changed
+15
-13
No files matched your search
@@ -26,12 +26,9 @@ public class RedisMessage extends Message {
|
||||
private void dispatchRedisMessage(String target) {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
try (Jedis publisher = RedisReceiver.getJedis()) {
|
||||
final String jedisPassword = HuskHomes.getSettings().getRedisPassword();
|
||||
if (!jedisPassword.equals("")) {
|
||||
publisher.auth(jedisPassword);
|
||||
}
|
||||
publisher.connect();
|
||||
publisher.publish(RedisReceiver.REDIS_CHANNEL, getClusterId() + ":" + getPluginMessageString(getMessageType()) + ":" + target + REDIS_MESSAGE_HEADER_SEPARATOR + getMessageData());
|
||||
publisher.publish(RedisReceiver.REDIS_CHANNEL,
|
||||
getClusterId() + ":" + getPluginMessageString(getMessageType()) + ":"
|
||||
+ target + REDIS_MESSAGE_HEADER_SEPARATOR + getMessageData());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -23,9 +23,18 @@ public class RedisReceiver {
|
||||
|
||||
// Initialize a JedisPool that can be drawn from on demand
|
||||
public static void initialize() {
|
||||
jedisPool = new JedisPool(new JedisPoolConfig(),
|
||||
HuskHomes.getSettings().getRedisHost(),
|
||||
HuskHomes.getSettings().getRedisPort());
|
||||
if (HuskHomes.getSettings().getRedisPassword().isEmpty()) {
|
||||
jedisPool = new JedisPool(new JedisPoolConfig(),
|
||||
HuskHomes.getSettings().getRedisHost(),
|
||||
HuskHomes.getSettings().getRedisPort(),
|
||||
0);
|
||||
} else {
|
||||
jedisPool = new JedisPool(new JedisPoolConfig(),
|
||||
HuskHomes.getSettings().getRedisHost(),
|
||||
HuskHomes.getSettings().getRedisPort(),
|
||||
0,
|
||||
HuskHomes.getSettings().getRedisPassword());
|
||||
}
|
||||
}
|
||||
|
||||
// Close the connection
|
||||
@@ -47,12 +56,8 @@ public class RedisReceiver {
|
||||
}
|
||||
|
||||
public static void listen() {
|
||||
final String jedisPassword = HuskHomes.getSettings().getRedisPassword();
|
||||
new Thread(() -> {
|
||||
try (Jedis jedis = getJedis()) {
|
||||
if (!jedisPassword.equals("")) {
|
||||
jedis.auth(jedisPassword);
|
||||
}
|
||||
jedis.subscribe(new JedisPubSub() {
|
||||
@Override
|
||||
public void onMessage(String channel, String message) {
|
||||
|
||||
Reference in new issue
Block a user