From f6c4bbcdcefdcf79bfc90927bd2894f61821e9ac Mon Sep 17 00:00:00 2001 From: Govindass Date: Sat, 24 Oct 2020 12:32:40 +0300 Subject: [PATCH] Revert "fixed reload but not tested" This reverts commit a08ecd93b7341c515998b7f206831e4a5c3ec8bf. --- .../java/net/limework/core/RediSkript.java | 8 +++++-- .../limework/core/managers/RedisManager.java | 24 ++----------------- 2 files changed, 8 insertions(+), 24 deletions(-) diff --git a/src/main/java/net/limework/core/RediSkript.java b/src/main/java/net/limework/core/RediSkript.java index c25dc64..7c04f51 100644 --- a/src/main/java/net/limework/core/RediSkript.java +++ b/src/main/java/net/limework/core/RediSkript.java @@ -10,12 +10,16 @@ public class RediSkript extends JavaPlugin { //Redis manager private RedisManager rm; + public void startRedis(boolean reload) { + if (reload) { reloadConfig(); } + rm = new RedisManager(this); + rm.start(); + } @Override public void onEnable() { saveDefaultConfig(); if (getServer().getPluginManager().getPlugin("Skript") != null) { - rm = new RedisManager(this); - rm.start(); + startRedis(false); PluginCommand command = getServer().getPluginCommand("reloadredis"); assert command != null; diff --git a/src/main/java/net/limework/core/managers/RedisManager.java b/src/main/java/net/limework/core/managers/RedisManager.java index 67b7257..39a95d8 100644 --- a/src/main/java/net/limework/core/managers/RedisManager.java +++ b/src/main/java/net/limework/core/managers/RedisManager.java @@ -149,28 +149,8 @@ public class RedisManager extends BinaryJedisPubSub implements Runnable { } public void reload() { - plugin.reloadConfig(); - subscribeJedis.close(); - Configuration config = this.plugin.getConfig(); - JedisPoolConfig JConfig = new JedisPoolConfig(); - JConfig.setMaxTotal(config.getInt("Redis.MaxConnections")); - JConfig.setMaxIdle(config.getInt("Redis.MaxConnections")); - JConfig.setMinIdle(1); - JConfig.setBlockWhenExhausted(true); - this.jedisPool = new JedisPool(JConfig, - config.getString("Redis.Host"), - config.getInt("Redis.Port"), - config.getInt("Redis.TimeOut"), - config.getString("Redis.Password"), - config.getBoolean("Redis.useSSL")); - RedisService.shutdownNow(); - RedisService = Executors.newFixedThreadPool(config.getInt("Redis.Threads")); - try { - this.subscribeJedis = this.jedisPool.getResource(); - } catch (Exception ignored) { - } - this.channels = config.getStringList("Channels"); - encryption = new Encryption(config); + this.shutdown(); + plugin.startRedis(true); } public JedisPool getJedisPool() {