Make on redis message a synchronous event for thread-safety

This commit is contained in:
Govindass 2020-10-24 15:19:10 +03:00
parent 0c20becfa1
commit f80d9b36e7
2 changed files with 2 additions and 3 deletions

View File

@ -12,7 +12,7 @@ public class RedisMessageEvent extends Event {
private long date; private long date;
public RedisMessageEvent(String channelName , String message, long date) { public RedisMessageEvent(String channelName , String message, long date) {
super(true); super(false);
this.channelName = channelName; this.channelName = channelName;
this.message = message; this.message = message;
this.date = date; this.date = date;

View File

@ -130,8 +130,7 @@ public class RedisManager extends BinaryJedisPubSub implements Runnable {
JSONObject j = new JSONObject(receivedMessage); JSONObject j = new JSONObject(receivedMessage);
//System.out.println("Message got from channel: "+channel +" and the Message: " +json.toString()); //System.out.println("Message got from channel: "+channel +" and the Message: " +json.toString());
RedisMessageEvent event = new RedisMessageEvent(channelString, j.getString("Message"), j.getLong("Date")); RedisMessageEvent event = new RedisMessageEvent(channelString, j.getString("Message"), j.getLong("Date"));
Bukkit.getScheduler().runTask(plugin, () -> plugin.getServer().getPluginManager().callEvent(event));
plugin.getServer().getPluginManager().callEvent(event);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();