Make all events async when not on primary thread

Fixes #2566, fixes #2556, fixes #2545.
This commit is contained in:
md678685 2019-05-26 12:08:58 +01:00
parent 5deb1de555
commit 4201e6ef85
5 changed files with 10 additions and 5 deletions

View file

@ -6,6 +6,6 @@ import org.bukkit.Bukkit;
public class AfkStatusChangeEvent extends StatusChangeEvent {
public AfkStatusChangeEvent(IUser affected, boolean value) {
super(!Bukkit.getServer().isPrimaryThread(), affected, affected, value);
super(affected, affected, value);
}
}

View file

@ -3,6 +3,7 @@ package net.ess3.api.events;
import com.earth2me.essentials.signs.EssentialsSign;
import com.earth2me.essentials.signs.EssentialsSign.ISign;
import net.ess3.api.IUser;
import org.bukkit.Bukkit;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
@ -19,7 +20,7 @@ public class SignEvent extends Event implements Cancellable {
IUser user;
public SignEvent(final ISign sign, final EssentialsSign essSign, final IUser user) {
super();
super(!Bukkit.getServer().isPrimaryThread());
this.sign = sign;
this.essSign = essSign;
this.user = user;

View file

@ -1,6 +1,7 @@
package net.ess3.api.events;
import net.ess3.api.IUser;
import org.bukkit.Bukkit;
import org.bukkit.event.Cancellable;
@ -11,8 +12,7 @@ public class StatusChangeEvent extends StateChangeEvent implements Cancellable {
private boolean newValue;
public StatusChangeEvent(IUser affected, IUser controller, boolean value) {
super(affected, controller);
this.newValue = value;
this(!Bukkit.getServer().isPrimaryThread(), affected, controller, value);
}
public StatusChangeEvent(boolean isAsync, IUser affected, IUser controller, boolean value) {

View file

@ -2,6 +2,7 @@ package net.ess3.api.events;
import com.google.common.base.Preconditions;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
@ -16,6 +17,7 @@ public class UserBalanceUpdateEvent extends Event {
private BigDecimal balance;
public UserBalanceUpdateEvent(Player player, BigDecimal originalBalance, BigDecimal balance) {
super(!Bukkit.getServer().isPrimaryThread());
this.player = player;
this.originalBalance = originalBalance;
this.balance = balance;

View file

@ -2,6 +2,7 @@ package net.ess3.api.events;
import com.earth2me.essentials.Trade;
import net.ess3.api.IUser;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
@ -18,7 +19,8 @@ public class UserWarpEvent extends Event implements Cancellable {
private boolean cancelled = false;
public UserWarpEvent(IUser user, String warp, Trade trade){
public UserWarpEvent(IUser user, String warp, Trade trade) {
super(!Bukkit.getServer().isPrimaryThread());
this.user = user;
this.warp = warp;
this.trade = trade;