added replacement for system prinltn messages

This commit is contained in:
mohammed jasem alaajel 2020-12-25 21:43:20 +04:00 committed by Govindas
parent 61a4b16953
commit a387b94861
2 changed files with 17 additions and 5 deletions

View File

@ -10,6 +10,7 @@ import net.limework.rediskript.commands.CommandReloadRedis;
import net.limework.rediskript.events.RedisMessageEvent;
import net.limework.rediskript.managers.RedisController;
import net.limework.rediskript.skript.elements.*;
import org.bukkit.ChatColor;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.IOException;
@ -18,11 +19,21 @@ public class RediSkript extends JavaPlugin {
private RedisController redisController;
public void reloadRedis(){
public void reloadRedis() {
redisController.shutdown();
redisController = new RedisController(this);
}
public void sendLogs(String message) {
getLogger().info(
ChatColor.translateAlternateColorCodes('&', "&b[RediSkript]&e " + message)
);
}
public void sendErrorLogs(String message) {
getLogger().severe(
ChatColor.translateAlternateColorCodes('&', "&b[RediSkript]&c " + message)
);
}
public void registerSyntax() {
SkriptAddon addon = Skript.registerAddon(this);
@ -69,6 +80,7 @@ public class RediSkript extends JavaPlugin {
public void onDisable() {
if (redisController != null) redisController.shutdown();
}
public RedisController getRC() {
return redisController;
}

View File

@ -34,7 +34,7 @@ public class RedisController extends BinaryJedisPubSub implements Runnable {
private final AtomicBoolean isConnectionBroken;
private final RediSkript plugin;
private BukkitTask ConnectionTask;
private final BukkitTask ConnectionTask;
public RedisController(RediSkript plugin) {
@ -67,15 +67,15 @@ public class RedisController extends BinaryJedisPubSub implements Runnable {
if (!isConnectionBroken.get()) {
return;
}
System.out.println("connecting to redis!");
plugin.sendLogs("Connecting to redis......");
try (Jedis jedis = jedisPool.getResource()) {
isConnectionBroken.set(false);
System.out.println("connected to redis!");
plugin.sendLogs("&aConnection to redis has established!");
jedis.subscribe(this, channelsInByte);
} catch (Exception e) {
isConnectionBroken.set(true);
e.printStackTrace();
plugin.sendLogs("Connection has &kFAILED &cor Unable to connect to redis retrying to make connection...");
}
}