Search in sources :

Example 1 with BukkitScriptEvent

use of com.denizenscript.denizen.events.BukkitScriptEvent in project Denizen-For-Bukkit by DenizenScript.

the class ListPingScriptEvent method syncFire.

public void syncFire(ServerListPingEvent event) {
    this.event = event;
    if (!Bukkit.isPrimaryThread()) {
        BukkitScriptEvent altEvent = (BukkitScriptEvent) clone();
        Future future = Bukkit.getScheduler().callSyncMethod(Denizen.getInstance(), () -> {
            altEvent.fire();
            return null;
        });
        try {
            future.get(5, TimeUnit.SECONDS);
        } catch (Throwable ex) {
            Debug.echoError(ex);
        }
        return;
    }
    fire(event);
}
Also used : Future(java.util.concurrent.Future) BukkitScriptEvent(com.denizenscript.denizen.events.BukkitScriptEvent)

Aggregations

BukkitScriptEvent (com.denizenscript.denizen.events.BukkitScriptEvent)1 Future (java.util.concurrent.Future)1