From f80d9b36e7ef4718991812dda21e2e10c5cb27c9 Mon Sep 17 00:00:00 2001 From: Govindass Date: Sat, 24 Oct 2020 15:19:10 +0300 Subject: [PATCH] Make on redis message a synchronous event for thread-safety --- src/main/java/net/limework/core/events/RedisMessageEvent.java | 2 +- src/main/java/net/limework/core/managers/RedisManager.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/limework/core/events/RedisMessageEvent.java b/src/main/java/net/limework/core/events/RedisMessageEvent.java index dfaa32f..e51b11c 100644 --- a/src/main/java/net/limework/core/events/RedisMessageEvent.java +++ b/src/main/java/net/limework/core/events/RedisMessageEvent.java @@ -12,7 +12,7 @@ public class RedisMessageEvent extends Event { private long date; public RedisMessageEvent(String channelName , String message, long date) { - super(true); + super(false); this.channelName = channelName; this.message = message; this.date = date; diff --git a/src/main/java/net/limework/core/managers/RedisManager.java b/src/main/java/net/limework/core/managers/RedisManager.java index 78429e3..ff1d2d8 100644 --- a/src/main/java/net/limework/core/managers/RedisManager.java +++ b/src/main/java/net/limework/core/managers/RedisManager.java @@ -130,8 +130,7 @@ public class RedisManager extends BinaryJedisPubSub implements Runnable { JSONObject j = new JSONObject(receivedMessage); //System.out.println("Message got from channel: "+channel +" and the Message: " +json.toString()); RedisMessageEvent event = new RedisMessageEvent(channelString, j.getString("Message"), j.getLong("Date")); - - plugin.getServer().getPluginManager().callEvent(event); + Bukkit.getScheduler().runTask(plugin, () -> plugin.getServer().getPluginManager().callEvent(event)); } } catch (Exception e) { e.printStackTrace();