fixed reload but not tested
This commit is contained in:
parent
c720433c60
commit
a08ecd93b7
@ -10,16 +10,12 @@ public class RediSkript extends JavaPlugin {
|
|||||||
//Redis manager
|
//Redis manager
|
||||||
private RedisManager rm;
|
private RedisManager rm;
|
||||||
|
|
||||||
public void startRedis(boolean reload) {
|
|
||||||
if (reload) { reloadConfig(); }
|
|
||||||
rm = new RedisManager(this);
|
|
||||||
rm.start();
|
|
||||||
}
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
saveDefaultConfig();
|
saveDefaultConfig();
|
||||||
if (getServer().getPluginManager().getPlugin("Skript") != null) {
|
if (getServer().getPluginManager().getPlugin("Skript") != null) {
|
||||||
startRedis(false);
|
rm = new RedisManager(this);
|
||||||
|
rm.start();
|
||||||
|
|
||||||
PluginCommand command = getServer().getPluginCommand("reloadredis");
|
PluginCommand command = getServer().getPluginCommand("reloadredis");
|
||||||
assert command != null;
|
assert command != null;
|
||||||
|
@ -149,8 +149,28 @@ public class RedisManager extends BinaryJedisPubSub implements Runnable {
|
|||||||
|
|
||||||
}
|
}
|
||||||
public void reload() {
|
public void reload() {
|
||||||
this.shutdown();
|
plugin.reloadConfig();
|
||||||
plugin.startRedis(true);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JedisPool getJedisPool() {
|
public JedisPool getJedisPool() {
|
||||||
|
Loading…
Reference in New Issue
Block a user