mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2024-12-27 18:44:19 +00:00
Fix Improper Use of Event API (#3853)
* Fix Improper Use of Event API * Checkstyle OOOO
This commit is contained in:
parent
cb45867de8
commit
318df64e54
13 changed files with 130 additions and 23 deletions
|
@ -1,11 +1,13 @@
|
|||
package net.ess3.api.events;
|
||||
|
||||
import net.ess3.api.IUser;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Fired when a player's AFK status changes.
|
||||
*/
|
||||
public class AfkStatusChangeEvent extends StatusChangeEvent {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final Cause cause;
|
||||
|
||||
@Deprecated
|
||||
|
@ -22,6 +24,15 @@ public class AfkStatusChangeEvent extends StatusChangeEvent {
|
|||
return cause;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* The cause of the AFK status change.
|
||||
*/
|
||||
|
|
|
@ -1,12 +1,24 @@
|
|||
package net.ess3.api.events;
|
||||
|
||||
import net.ess3.api.IUser;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Fired when a player's flight status is toggled using /fly.
|
||||
*/
|
||||
public class FlyStatusChangeEvent extends StatusChangeEvent {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public FlyStatusChangeEvent(final IUser affected, final IUser controller, final boolean value) {
|
||||
super(affected, controller, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package net.ess3.api.events;
|
||||
|
||||
import net.ess3.api.IUser;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Fired when a user's god status is toggled.
|
||||
|
@ -9,7 +10,18 @@ import net.ess3.api.IUser;
|
|||
* and #getController methods are inverted.
|
||||
*/
|
||||
public class GodStatusChangeEvent extends StatusChangeEvent {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public GodStatusChangeEvent(final IUser affected, final IUser controller, final boolean value) {
|
||||
super(affected, controller, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,24 @@
|
|||
package net.ess3.api.events;
|
||||
|
||||
import net.ess3.api.IUser;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* This event is currently unused, and is retained for ABI compatibility and potential future implementation.
|
||||
*/
|
||||
public class IgnoreStatusChangeEvent extends StatusChangeEvent {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public IgnoreStatusChangeEvent(final IUser affected, final IUser controller, final boolean value) {
|
||||
super(affected, controller, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package net.ess3.api.events;
|
||||
|
||||
import net.ess3.api.IUser;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Fired when a player's jail status changes.
|
||||
|
@ -9,7 +10,18 @@ import net.ess3.api.IUser;
|
|||
* You <i>can</i>, however, access the player's current jail when they are about to be unjailed by calling {@link IUser#getJail()}.
|
||||
*/
|
||||
public class JailStatusChangeEvent extends StatusChangeEvent {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public JailStatusChangeEvent(final IUser affected, final IUser controller, final boolean value) {
|
||||
super(affected, controller, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package net.ess3.api.events;
|
||||
|
||||
import net.ess3.api.IUser;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
|
@ -8,6 +9,7 @@ import java.util.Optional;
|
|||
* Fired when a player's mute status is changed.
|
||||
*/
|
||||
public class MuteStatusChangeEvent extends StatusChangeEvent {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final Long timestamp;
|
||||
private final String reason;
|
||||
|
||||
|
@ -30,4 +32,13 @@ public class MuteStatusChangeEvent extends StatusChangeEvent {
|
|||
public String getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package net.ess3.api.events;
|
|||
|
||||
import net.ess3.api.IUser;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Fired when a player's nickname is changed.
|
||||
|
@ -9,6 +10,7 @@ import org.bukkit.event.Cancellable;
|
|||
* <b>WARNING: The values of {@link NickChangeEvent#getAffected()} and {@link NickChangeEvent#getController()} are inverted due to a long-standing implementation bug.</b>
|
||||
*/
|
||||
public class NickChangeEvent extends StateChangeEvent implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final String newValue;
|
||||
|
||||
public NickChangeEvent(final IUser affected, final IUser controller, final String value) {
|
||||
|
@ -41,4 +43,13 @@ public class NickChangeEvent extends StateChangeEvent implements Cancellable {
|
|||
public IUser getController() {
|
||||
return super.getController();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package net.ess3.api.events;
|
|||
|
||||
import com.earth2me.essentials.signs.EssentialsSign;
|
||||
import net.ess3.api.IUser;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Fired when an Essentials sign is broken.
|
||||
|
@ -9,7 +10,18 @@ import net.ess3.api.IUser;
|
|||
* This is primarily intended for use with EssentialsX's sign abstraction - external plugins should not listen on this event.
|
||||
*/
|
||||
public class SignBreakEvent extends SignEvent {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public SignBreakEvent(final EssentialsSign.ISign sign, final EssentialsSign essSign, final IUser user) {
|
||||
super(sign, essSign, user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package net.ess3.api.events;
|
|||
|
||||
import com.earth2me.essentials.signs.EssentialsSign;
|
||||
import net.ess3.api.IUser;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Fired when an Essentials sign is created.
|
||||
|
@ -9,7 +10,18 @@ import net.ess3.api.IUser;
|
|||
* This is primarily intended for use with EssentialsX's sign abstraction - external plugins should not listen on this event.
|
||||
*/
|
||||
public class SignCreateEvent extends SignEvent {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public SignCreateEvent(final EssentialsSign.ISign sign, final EssentialsSign essSign, final IUser user) {
|
||||
super(sign, essSign, user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,13 +6,11 @@ import net.ess3.api.IUser;
|
|||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* This handles common boilerplate for other SignEvent
|
||||
*/
|
||||
public class SignEvent extends Event implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
public abstract class SignEvent extends Event implements Cancellable {
|
||||
final ISign sign;
|
||||
final EssentialsSign essSign;
|
||||
final IUser user;
|
||||
|
@ -25,10 +23,6 @@ public class SignEvent extends Event implements Cancellable {
|
|||
this.user = user;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public ISign getSign() {
|
||||
return sign;
|
||||
}
|
||||
|
@ -41,11 +35,6 @@ public class SignEvent extends Event implements Cancellable {
|
|||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
|
|
|
@ -2,6 +2,7 @@ package net.ess3.api.events;
|
|||
|
||||
import com.earth2me.essentials.signs.EssentialsSign;
|
||||
import net.ess3.api.IUser;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Fired when an Essentials sign is interacted with.
|
||||
|
@ -9,7 +10,18 @@ import net.ess3.api.IUser;
|
|||
* This is primarily intended for use with EssentialsX's sign abstraction - external plugins should not listen on this event.
|
||||
*/
|
||||
public class SignInteractEvent extends SignEvent {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public SignInteractEvent(final EssentialsSign.ISign sign, final EssentialsSign essSign, final IUser user) {
|
||||
super(sign, essSign, user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,14 +3,12 @@ package net.ess3.api.events;
|
|||
import net.ess3.api.IUser;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* This handles common boilerplate for events for changes in state.
|
||||
* For boolean state, events should extend StatusChangeEvent instead.
|
||||
*/
|
||||
public abstract class StateChangeEvent extends Event implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
final IUser affected;
|
||||
final IUser controller;
|
||||
private boolean cancelled = false;
|
||||
|
@ -27,10 +25,6 @@ public abstract class StateChangeEvent extends Event implements Cancellable {
|
|||
this.controller = controller;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user who is affected by the state change.
|
||||
*
|
||||
|
@ -49,11 +43,6 @@ public abstract class StateChangeEvent extends Event implements Cancellable {
|
|||
return controller;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package net.ess3.api.events;
|
||||
|
||||
import net.ess3.api.IUser;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Fired when a player's vanish status changes due to the /vanish command.
|
||||
|
@ -9,7 +10,18 @@ import net.ess3.api.IUser;
|
|||
* check with {@link IUser#isVanished()}.
|
||||
*/
|
||||
public class VanishStatusChangeEvent extends StatusChangeEvent {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public VanishStatusChangeEvent(final IUser affected, final IUser controller, final boolean value) {
|
||||
super(affected, controller, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue