forked from Limework/RediSkript
Check if error will occure when redis fails
This commit is contained in:
@@ -6,6 +6,7 @@ import org.bukkit.ChatColor;
|
||||
import org.json.JSONObject;
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisPubSub;
|
||||
import redis.clients.jedis.exceptions.JedisConnectionException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -17,7 +18,17 @@ public class RedisSub extends JedisPubSub {
|
||||
this.j = j;
|
||||
String[] ss = channels.toArray(new String[0]);
|
||||
plugin.getServer().getScheduler().runTaskAsynchronously(plugin,
|
||||
() -> this.j.subscribe(this, ss));
|
||||
() -> {
|
||||
|
||||
try{
|
||||
this.j.subscribe(this, ss);
|
||||
} catch (JedisConnectionException je){
|
||||
this.unSubAndCloseConnection();
|
||||
Bukkit.broadcastMessage("Redis Went down!");
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.event.Event;
|
||||
import org.json.JSONObject;
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.exceptions.JedisConnectionException;
|
||||
|
||||
public class EffSendMessage extends Effect {
|
||||
//"hi"
|
||||
@@ -34,7 +35,11 @@ public class EffSendMessage extends Effect {
|
||||
return;
|
||||
}
|
||||
plugin.getJedisExecutionService().execute(() -> {
|
||||
Jedis j = plugin.getJedisPool().getResource();
|
||||
Jedis j;
|
||||
try {j = plugin.getJedisPool().getResource();}catch (JedisConnectionException e){
|
||||
Bukkit.broadcastMessage("Redis is down!!! dont send messages");
|
||||
return;
|
||||
}
|
||||
JSONObject json = new JSONObject();
|
||||
try {
|
||||
json.put("Message", message);
|
||||
|
||||
Reference in New Issue
Block a user