Skip to content

Commit

Permalink
protect against error when tag timings is enabled on 1.13 with the re…
Browse files Browse the repository at this point in the history
…ceives message event active

oddly specific error circumstance time!
  • Loading branch information
mcmonkey4eva committed Sep 4, 2019
1 parent a0bf19b commit fdd33a0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Expand Up @@ -376,10 +376,17 @@ public boolean allowedToWebget() {
return Settings.allowWebget();
}

public static Thread tagThread = null;

public static boolean isSafeThread() {
return Bukkit.isPrimaryThread() || Thread.currentThread().equals(tagThread);
}

@Override
public void preTagExecute() {
try {
NMSHandler.getInstance().disableAsyncCatcher();
tagThread = Thread.currentThread();
}
catch (Throwable e) {
Debug.echoError("Running not-Spigot?!");
Expand Down
@@ -1,5 +1,6 @@
package com.denizenscript.denizen.utilities.packets;

import com.denizenscript.denizen.DenizenCoreImplementation;
import com.denizenscript.denizen.nms.interfaces.packets.*;
import com.denizenscript.denizen.utilities.debugging.Debug;
import com.denizenscript.denizen.events.player.PlayerReceivesMessageScriptEvent;
Expand Down Expand Up @@ -105,7 +106,7 @@ else if (event.rawJsonModified) {
return false;
}
});
if (Bukkit.isPrimaryThread()) {
if (DenizenCoreImplementation.isSafeThread()) {
futureTask.run();
}
else {
Expand Down

0 comments on commit fdd33a0

Please sign in to comment.