Always fire events synchronously, fixes #366

This commit is contained in:
HappyPikachu 2018-04-14 22:04:44 -04:00
parent ce485ae1ea
commit a7838b8184
2 changed files with 9 additions and 14 deletions

View File

@ -230,19 +230,7 @@ public class Event {
}
if (commands.isEmpty() == false) {
for (String s : commands) {
if (!Bukkit.isPrimaryThread()) {
new BukkitRunnable() {
@Override
public void run() {
quester.plugin.getServer().dispatchCommand(quester.plugin.getServer().getConsoleSender(), s.replaceAll("<player>", quester.getPlayer().getName()));
}
}.runTask(this.plugin);
} else {
quester.plugin.getServer().dispatchCommand(quester.plugin.getServer().getConsoleSender(), s.replaceAll("<player>", quester.getPlayer().getName()));
}
quester.plugin.getServer().dispatchCommand(quester.plugin.getServer().getConsoleSender(), s.replaceAll("<player>", quester.getPlayer().getName()));
}
}
if (potionEffects.isEmpty() == false) {

View File

@ -59,6 +59,7 @@ import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerShearEntityEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.projectiles.ProjectileSource;
import org.bukkit.scheduler.BukkitRunnable;
import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
@ -307,7 +308,13 @@ public class PlayerListener implements Listener {
for (String s : currentStage.chatEvents.keySet()) {
if (s.equalsIgnoreCase(chat)) {
if (quester.getQuestData(quest).eventFired.get(s) == null || quester.getQuestData(quest).eventFired.get(s) == false) {
currentStage.chatEvents.get(s).fire(quester, quest);
new BukkitRunnable() {
@Override
public void run() {
currentStage.chatEvents.get(s).fire(quester, quest);
}
}.runTask(this.plugin);
quester.getQuestData(quest).eventFired.put(s, true);
}
}