Update RedisController.java

This commit is contained in:
mohammed jasem alaajel 2020-12-26 14:03:27 +04:00
parent bfb8ebc862
commit a96f9b3201

View File

@ -35,6 +35,7 @@ public class RedisController extends BinaryJedisPubSub implements Runnable {
private final AtomicBoolean isConnectionBroken; private final AtomicBoolean isConnectionBroken;
private final AtomicBoolean isConnecting; private final AtomicBoolean isConnecting;
private final RediSkript plugin; private final RediSkript plugin;
private final boolean debugMode = false; //todo: will be later in the config in future release.
private final BukkitTask ConnectionTask; private final BukkitTask ConnectionTask;
@ -79,9 +80,11 @@ public class RedisController extends BinaryJedisPubSub implements Runnable {
isConnecting.set(false); isConnecting.set(false);
isConnectionBroken.set(true); isConnectionBroken.set(true);
plugin.sendLogs("Connection has &kFAILED &cor Unable to connect to redis retrying to make connection..."); plugin.sendLogs("Connection has &kFAILED &cor Unable to connect to redis retrying to make connection...");
if (debugMode) {
e.printStackTrace(); e.printStackTrace();
} }
} }
}
public void shutdown() { public void shutdown() {
ConnectionTask.cancel(); ConnectionTask.cancel();
@ -89,6 +92,9 @@ public class RedisController extends BinaryJedisPubSub implements Runnable {
this.unsubscribe(); this.unsubscribe();
} catch (Exception e) { } catch (Exception e) {
plugin.sendErrorLogs("Something went wrong during unsubscribing..."); plugin.sendErrorLogs("Something went wrong during unsubscribing...");
if (debugMode) {
e.printStackTrace();
}
} }
jedisPool.close(); jedisPool.close();
@ -170,9 +176,11 @@ public class RedisController extends BinaryJedisPubSub implements Runnable {
} }
} }
} catch (Exception e) { } catch (Exception e) {
plugin.sendErrorLogs("&cI got a message that was empty from channel " + channelString + " please check your code that you used to send the message. Message content:");
if (debugMode) {
e.printStackTrace(); e.printStackTrace();
Bukkit.getLogger().warning(ChatColor.translateAlternateColorCodes('&', "&cI got a message that was empty from channel " + channelString + " please check your code that you used to send the message. Message content:")); plugin.sendErrorLogs(receivedMessage);
Bukkit.getLogger().warning(receivedMessage); }
} }
} }