mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-22 09:08:01 +01: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
@ -1,11 +1,13 @@
|
|||||||
package net.ess3.api.events;
|
package net.ess3.api.events;
|
||||||
|
|
||||||
import net.ess3.api.IUser;
|
import net.ess3.api.IUser;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fired when a player's AFK status changes.
|
* Fired when a player's AFK status changes.
|
||||||
*/
|
*/
|
||||||
public class AfkStatusChangeEvent extends StatusChangeEvent {
|
public class AfkStatusChangeEvent extends StatusChangeEvent {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
private final Cause cause;
|
private final Cause cause;
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@ -22,6 +24,15 @@ public class AfkStatusChangeEvent extends StatusChangeEvent {
|
|||||||
return cause;
|
return cause;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The cause of the AFK status change.
|
* The cause of the AFK status change.
|
||||||
*/
|
*/
|
||||||
|
@ -1,12 +1,24 @@
|
|||||||
package net.ess3.api.events;
|
package net.ess3.api.events;
|
||||||
|
|
||||||
import net.ess3.api.IUser;
|
import net.ess3.api.IUser;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fired when a player's flight status is toggled using /fly.
|
* Fired when a player's flight status is toggled using /fly.
|
||||||
*/
|
*/
|
||||||
public class FlyStatusChangeEvent extends StatusChangeEvent {
|
public class FlyStatusChangeEvent extends StatusChangeEvent {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
public FlyStatusChangeEvent(final IUser affected, final IUser controller, final boolean value) {
|
public FlyStatusChangeEvent(final IUser affected, final IUser controller, final boolean value) {
|
||||||
super(affected, controller, 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;
|
package net.ess3.api.events;
|
||||||
|
|
||||||
import net.ess3.api.IUser;
|
import net.ess3.api.IUser;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fired when a user's god status is toggled.
|
* Fired when a user's god status is toggled.
|
||||||
@ -9,7 +10,18 @@ import net.ess3.api.IUser;
|
|||||||
* and #getController methods are inverted.
|
* and #getController methods are inverted.
|
||||||
*/
|
*/
|
||||||
public class GodStatusChangeEvent extends StatusChangeEvent {
|
public class GodStatusChangeEvent extends StatusChangeEvent {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
public GodStatusChangeEvent(final IUser affected, final IUser controller, final boolean value) {
|
public GodStatusChangeEvent(final IUser affected, final IUser controller, final boolean value) {
|
||||||
super(affected, controller, 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;
|
package net.ess3.api.events;
|
||||||
|
|
||||||
import net.ess3.api.IUser;
|
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.
|
* This event is currently unused, and is retained for ABI compatibility and potential future implementation.
|
||||||
*/
|
*/
|
||||||
public class IgnoreStatusChangeEvent extends StatusChangeEvent {
|
public class IgnoreStatusChangeEvent extends StatusChangeEvent {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
public IgnoreStatusChangeEvent(final IUser affected, final IUser controller, final boolean value) {
|
public IgnoreStatusChangeEvent(final IUser affected, final IUser controller, final boolean value) {
|
||||||
super(affected, controller, 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;
|
package net.ess3.api.events;
|
||||||
|
|
||||||
import net.ess3.api.IUser;
|
import net.ess3.api.IUser;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fired when a player's jail status changes.
|
* 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()}.
|
* 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 {
|
public class JailStatusChangeEvent extends StatusChangeEvent {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
public JailStatusChangeEvent(final IUser affected, final IUser controller, final boolean value) {
|
public JailStatusChangeEvent(final IUser affected, final IUser controller, final boolean value) {
|
||||||
super(affected, controller, 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;
|
package net.ess3.api.events;
|
||||||
|
|
||||||
import net.ess3.api.IUser;
|
import net.ess3.api.IUser;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@ -8,6 +9,7 @@ import java.util.Optional;
|
|||||||
* Fired when a player's mute status is changed.
|
* Fired when a player's mute status is changed.
|
||||||
*/
|
*/
|
||||||
public class MuteStatusChangeEvent extends StatusChangeEvent {
|
public class MuteStatusChangeEvent extends StatusChangeEvent {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
private final Long timestamp;
|
private final Long timestamp;
|
||||||
private final String reason;
|
private final String reason;
|
||||||
|
|
||||||
@ -30,4 +32,13 @@ public class MuteStatusChangeEvent extends StatusChangeEvent {
|
|||||||
public String getReason() {
|
public String getReason() {
|
||||||
return reason;
|
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 net.ess3.api.IUser;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fired when a player's nickname is changed.
|
* 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>
|
* <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 {
|
public class NickChangeEvent extends StateChangeEvent implements Cancellable {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
private final String newValue;
|
private final String newValue;
|
||||||
|
|
||||||
public NickChangeEvent(final IUser affected, final IUser controller, final String value) {
|
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() {
|
public IUser getController() {
|
||||||
return super.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 com.earth2me.essentials.signs.EssentialsSign;
|
||||||
import net.ess3.api.IUser;
|
import net.ess3.api.IUser;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fired when an Essentials sign is broken.
|
* 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.
|
* This is primarily intended for use with EssentialsX's sign abstraction - external plugins should not listen on this event.
|
||||||
*/
|
*/
|
||||||
public class SignBreakEvent extends SignEvent {
|
public class SignBreakEvent extends SignEvent {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
public SignBreakEvent(final EssentialsSign.ISign sign, final EssentialsSign essSign, final IUser user) {
|
public SignBreakEvent(final EssentialsSign.ISign sign, final EssentialsSign essSign, final IUser user) {
|
||||||
super(sign, essSign, 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 com.earth2me.essentials.signs.EssentialsSign;
|
||||||
import net.ess3.api.IUser;
|
import net.ess3.api.IUser;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fired when an Essentials sign is created.
|
* 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.
|
* This is primarily intended for use with EssentialsX's sign abstraction - external plugins should not listen on this event.
|
||||||
*/
|
*/
|
||||||
public class SignCreateEvent extends SignEvent {
|
public class SignCreateEvent extends SignEvent {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
public SignCreateEvent(final EssentialsSign.ISign sign, final EssentialsSign essSign, final IUser user) {
|
public SignCreateEvent(final EssentialsSign.ISign sign, final EssentialsSign essSign, final IUser user) {
|
||||||
super(sign, essSign, 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.Bukkit;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This handles common boilerplate for other SignEvent
|
* This handles common boilerplate for other SignEvent
|
||||||
*/
|
*/
|
||||||
public class SignEvent extends Event implements Cancellable {
|
public abstract class SignEvent extends Event implements Cancellable {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
final ISign sign;
|
final ISign sign;
|
||||||
final EssentialsSign essSign;
|
final EssentialsSign essSign;
|
||||||
final IUser user;
|
final IUser user;
|
||||||
@ -25,10 +23,6 @@ public class SignEvent extends Event implements Cancellable {
|
|||||||
this.user = user;
|
this.user = user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ISign getSign() {
|
public ISign getSign() {
|
||||||
return sign;
|
return sign;
|
||||||
}
|
}
|
||||||
@ -41,11 +35,6 @@ public class SignEvent extends Event implements Cancellable {
|
|||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public HandlerList getHandlers() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return cancelled;
|
return cancelled;
|
||||||
|
@ -2,6 +2,7 @@ package net.ess3.api.events;
|
|||||||
|
|
||||||
import com.earth2me.essentials.signs.EssentialsSign;
|
import com.earth2me.essentials.signs.EssentialsSign;
|
||||||
import net.ess3.api.IUser;
|
import net.ess3.api.IUser;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fired when an Essentials sign is interacted with.
|
* 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.
|
* This is primarily intended for use with EssentialsX's sign abstraction - external plugins should not listen on this event.
|
||||||
*/
|
*/
|
||||||
public class SignInteractEvent extends SignEvent {
|
public class SignInteractEvent extends SignEvent {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
public SignInteractEvent(final EssentialsSign.ISign sign, final EssentialsSign essSign, final IUser user) {
|
public SignInteractEvent(final EssentialsSign.ISign sign, final EssentialsSign essSign, final IUser user) {
|
||||||
super(sign, essSign, 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 net.ess3.api.IUser;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This handles common boilerplate for events for changes in state.
|
* This handles common boilerplate for events for changes in state.
|
||||||
* For boolean state, events should extend StatusChangeEvent instead.
|
* For boolean state, events should extend StatusChangeEvent instead.
|
||||||
*/
|
*/
|
||||||
public abstract class StateChangeEvent extends Event implements Cancellable {
|
public abstract class StateChangeEvent extends Event implements Cancellable {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
final IUser affected;
|
final IUser affected;
|
||||||
final IUser controller;
|
final IUser controller;
|
||||||
private boolean cancelled = false;
|
private boolean cancelled = false;
|
||||||
@ -27,10 +25,6 @@ public abstract class StateChangeEvent extends Event implements Cancellable {
|
|||||||
this.controller = controller;
|
this.controller = controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the user who is affected by the state change.
|
* Get the user who is affected by the state change.
|
||||||
*
|
*
|
||||||
@ -49,11 +43,6 @@ public abstract class StateChangeEvent extends Event implements Cancellable {
|
|||||||
return controller;
|
return controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public HandlerList getHandlers() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return cancelled;
|
return cancelled;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package net.ess3.api.events;
|
package net.ess3.api.events;
|
||||||
|
|
||||||
import net.ess3.api.IUser;
|
import net.ess3.api.IUser;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fired when a player's vanish status changes due to the /vanish command.
|
* 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()}.
|
* check with {@link IUser#isVanished()}.
|
||||||
*/
|
*/
|
||||||
public class VanishStatusChangeEvent extends StatusChangeEvent {
|
public class VanishStatusChangeEvent extends StatusChangeEvent {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
public VanishStatusChangeEvent(final IUser affected, final IUser controller, final boolean value) {
|
public VanishStatusChangeEvent(final IUser affected, final IUser controller, final boolean value) {
|
||||||
super(affected, controller, value);
|
super(affected, controller, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user