Make on redis message a synchronous event for thread-safety
This commit is contained in:
parent
0c20becfa1
commit
f80d9b36e7
@ -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;
|
||||||
|
@ -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();
|
||||||
|
Loading…
Reference in New Issue
Block a user