forked from Limework/RediSkript
added /reloadredis command
This commit is contained in:
parent
2e80b57a53
commit
542884dfe9
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>net.limework.core</groupId>
|
||||
<artifactId>LimeworkSpigotCore</artifactId>
|
||||
<version>1.0.2-SNAPSHOT</version>
|
||||
<version>1.0.3-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<build>
|
||||
|
@ -19,6 +19,7 @@ public class LimeworkSpigotCore extends JavaPlugin {
|
||||
public void onEnable() {
|
||||
saveDefaultConfig();
|
||||
rm = new RedisManager(this);
|
||||
getServer().getPluginCommand("reloadredis").setExecutor(rm);
|
||||
if (getServer().getPluginManager().getPlugin("Skript") != null) {
|
||||
new SkriptHook(this);
|
||||
} else {
|
||||
|
@ -3,10 +3,16 @@ package net.limework.core.managers;
|
||||
import net.limework.Data.Encryption;
|
||||
import net.limework.core.LimeworkSpigotCore;
|
||||
import net.limework.core.events.RedisMessageEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.Configuration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.cryptomator.siv.UnauthenticCiphertextException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.json.JSONObject;
|
||||
import redis.clients.jedis.BinaryJedis;
|
||||
import redis.clients.jedis.BinaryJedisPubSub;
|
||||
@ -19,7 +25,7 @@ import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class RedisManager extends BinaryJedisPubSub implements Runnable{
|
||||
public class RedisManager extends BinaryJedisPubSub implements Runnable, CommandExecutor {
|
||||
|
||||
private LimeworkSpigotCore plugin;
|
||||
|
||||
@ -27,7 +33,6 @@ public class RedisManager extends BinaryJedisPubSub implements Runnable{
|
||||
private ExecutorService RedisService;
|
||||
|
||||
|
||||
|
||||
//sub
|
||||
private BinaryJedis subscribeJedis;
|
||||
private List<String> channels;
|
||||
@ -51,13 +56,16 @@ public class RedisManager extends BinaryJedisPubSub implements Runnable{
|
||||
config.getString("Redis.Password"),
|
||||
config.getBoolean("Redis.useSSL"));
|
||||
RedisService = Executors.newFixedThreadPool(config.getInt("Redis.Threads"));
|
||||
try{this.subscribeJedis = this.jedisPool.getResource(); }catch (Exception ignored){}
|
||||
try {
|
||||
this.subscribeJedis = this.jedisPool.getResource();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
this.channels = config.getStringList("Channels");
|
||||
encryption = new Encryption(config);
|
||||
|
||||
}
|
||||
|
||||
public void start(){
|
||||
public void start() {
|
||||
this.RedisService.execute(this);
|
||||
}
|
||||
|
||||
@ -92,7 +100,9 @@ public class RedisManager extends BinaryJedisPubSub implements Runnable{
|
||||
|
||||
} catch (Exception e) {
|
||||
message("&e[Jedis] &cConnection to redis has failed! &ereconnecting...");
|
||||
if (this.subscribeJedis != null){this.subscribeJedis.close();}
|
||||
if (this.subscribeJedis != null) {
|
||||
this.subscribeJedis.close();
|
||||
}
|
||||
isRedisOnline.set(false);
|
||||
}
|
||||
try {
|
||||
@ -130,7 +140,7 @@ public class RedisManager extends BinaryJedisPubSub implements Runnable{
|
||||
|
||||
public void shutdown() {
|
||||
this.isShuttingDown.set(true);
|
||||
if (this.subscribeJedis != null){
|
||||
if (this.subscribeJedis != null) {
|
||||
this.unsubscribe();
|
||||
this.subscribeJedis.close();
|
||||
}
|
||||
@ -161,4 +171,15 @@ public class RedisManager extends BinaryJedisPubSub implements Runnable{
|
||||
public Encryption getEncryption() {
|
||||
return encryption;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String lable, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
sender.sendMessage(TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&'
|
||||
, "&c&lYou can not execute this command!!!!!!")));
|
||||
return true;
|
||||
}
|
||||
start();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -9,3 +9,6 @@ commands:
|
||||
control:
|
||||
description: "server control"
|
||||
permission: "admin.use"
|
||||
reloadredis:
|
||||
description: "server control"
|
||||
permission: "admin.use"
|
Loading…
Reference in New Issue
Block a user