Adds nullability annotations among other things
Adds nullability annotations for all methods Fixes some nullability problems and inconsistencies Gets rid of RelativeBlockVector's inner class Changes RelativeBlockVector to a record Simplifies FromTheEndTeleportation's storage, and makes it into a minimal record Removes the putStringInList method Gets rid of some primitive list usage Fixes some incorrect method accessibility Removes some redundancy in PortalOption
This commit is contained in:
@@ -24,7 +24,7 @@ public class StargateAccessEvent extends StargatePlayerEvent {
|
||||
* @param portal <p>The portal involved in the event</p>
|
||||
* @param deny <p>Whether the stargate access should be denied</p>
|
||||
*/
|
||||
public StargateAccessEvent(Player player, Portal portal, boolean deny) {
|
||||
public StargateAccessEvent(@NotNull Player player, @NotNull Portal portal, boolean deny) {
|
||||
super(portal, player);
|
||||
|
||||
this.deny = deny;
|
||||
@@ -53,6 +53,7 @@ public class StargateAccessEvent extends StargatePlayerEvent {
|
||||
*
|
||||
* @return <p>A handler-list with all event handlers</p>
|
||||
*/
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
@@ -28,7 +28,8 @@ public class StargateActivateEvent extends StargatePlayerEvent {
|
||||
* @param destinations <p>The destinations available to the player using the portal</p>
|
||||
* @param destination <p>The currently selected destination</p>
|
||||
*/
|
||||
public StargateActivateEvent(Portal portal, Player player, List<String> destinations, String destination) {
|
||||
public StargateActivateEvent(@NotNull Portal portal, @NotNull Player player, @NotNull List<String> destinations,
|
||||
@NotNull String destination) {
|
||||
super(portal, player);
|
||||
|
||||
this.destinations = destinations;
|
||||
@@ -40,6 +41,7 @@ public class StargateActivateEvent extends StargatePlayerEvent {
|
||||
*
|
||||
* @return <p>The destinations available for the portal</p>
|
||||
*/
|
||||
@NotNull
|
||||
public List<String> getDestinations() {
|
||||
return destinations;
|
||||
}
|
||||
@@ -49,7 +51,7 @@ public class StargateActivateEvent extends StargatePlayerEvent {
|
||||
*
|
||||
* @param destinations <p>The new list of available destinations</p>
|
||||
*/
|
||||
public void setDestinations(List<String> destinations) {
|
||||
public void setDestinations(@NotNull List<String> destinations) {
|
||||
this.destinations = destinations;
|
||||
}
|
||||
|
||||
@@ -58,6 +60,7 @@ public class StargateActivateEvent extends StargatePlayerEvent {
|
||||
*
|
||||
* @return <p>The selected destination</p>
|
||||
*/
|
||||
@NotNull
|
||||
public String getDestination() {
|
||||
return destination;
|
||||
}
|
||||
@@ -67,7 +70,7 @@ public class StargateActivateEvent extends StargatePlayerEvent {
|
||||
*
|
||||
* @param destination <p>The new selected destination</p>
|
||||
*/
|
||||
public void setDestination(String destination) {
|
||||
public void setDestination(@NotNull String destination) {
|
||||
this.destination = destination;
|
||||
}
|
||||
|
||||
@@ -76,6 +79,7 @@ public class StargateActivateEvent extends StargatePlayerEvent {
|
||||
*
|
||||
* @return <p>A handler-list with all event handlers</p>
|
||||
*/
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
@@ -22,7 +22,7 @@ public class StargateCloseEvent extends StargateEvent {
|
||||
* @param portal <p>The portal to close</p>
|
||||
* @param force <p>Whether to force the gate to close, even if set as always-on</p>
|
||||
*/
|
||||
public StargateCloseEvent(Portal portal, boolean force) {
|
||||
public StargateCloseEvent(@NotNull Portal portal, boolean force) {
|
||||
super(portal);
|
||||
|
||||
this.force = force;
|
||||
@@ -51,6 +51,7 @@ public class StargateCloseEvent extends StargateEvent {
|
||||
*
|
||||
* @return <p>A handler-list with all event handlers</p>
|
||||
*/
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
@@ -29,7 +29,8 @@ public class StargateCreateEvent extends StargatePlayerEvent {
|
||||
* @param denyReason <p>The reason stargate creation was denied</p>
|
||||
* @param cost <p>The cost of creating the new star gate</p>
|
||||
*/
|
||||
public StargateCreateEvent(Player player, Portal portal, String[] lines, boolean deny, String denyReason, int cost) {
|
||||
public StargateCreateEvent(@NotNull Player player, @NotNull Portal portal, @NotNull String[] lines, boolean deny,
|
||||
@NotNull String denyReason, int cost) {
|
||||
super(portal, player);
|
||||
this.lines = lines;
|
||||
this.deny = deny;
|
||||
@@ -44,6 +45,7 @@ public class StargateCreateEvent extends StargatePlayerEvent {
|
||||
* @return <p>The text on the given line</p>
|
||||
* @throws IndexOutOfBoundsException <p>If given a line index less than zero or above three</p>
|
||||
*/
|
||||
@NotNull
|
||||
public String getLine(int index) throws IndexOutOfBoundsException {
|
||||
return lines[index];
|
||||
}
|
||||
@@ -71,6 +73,7 @@ public class StargateCreateEvent extends StargatePlayerEvent {
|
||||
*
|
||||
* @return <p>The reason the stargate creation was denied</p>
|
||||
*/
|
||||
@NotNull
|
||||
public String getDenyReason() {
|
||||
return denyReason;
|
||||
}
|
||||
@@ -80,7 +83,7 @@ public class StargateCreateEvent extends StargatePlayerEvent {
|
||||
*
|
||||
* @param denyReason <p>The new reason why the stargate creation was denied</p>
|
||||
*/
|
||||
public void setDenyReason(String denyReason) {
|
||||
public void setDenyReason(@NotNull String denyReason) {
|
||||
this.denyReason = denyReason;
|
||||
}
|
||||
|
||||
@@ -107,6 +110,7 @@ public class StargateCreateEvent extends StargatePlayerEvent {
|
||||
*
|
||||
* @return <p>A handler-list with all event handlers</p>
|
||||
*/
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
@@ -20,7 +20,7 @@ public class StargateDeactivateEvent extends StargateEvent {
|
||||
*
|
||||
* @param portal <p>The portal which was deactivated</p>
|
||||
*/
|
||||
public StargateDeactivateEvent(Portal portal) {
|
||||
public StargateDeactivateEvent(@NotNull Portal portal) {
|
||||
super(portal);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ public class StargateDeactivateEvent extends StargateEvent {
|
||||
*
|
||||
* @return <p>A handler-list with all event handlers</p>
|
||||
*/
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
@@ -27,7 +27,8 @@ public class StargateDestroyEvent extends StargatePlayerEvent {
|
||||
* @param denyMsg <p>The message to display if the event is denied</p>
|
||||
* @param cost <p>The cost of destroying the portal</p>
|
||||
*/
|
||||
public StargateDestroyEvent(Portal portal, Player player, boolean deny, String denyMsg, int cost) {
|
||||
public StargateDestroyEvent(@NotNull Portal portal, @NotNull Player player, boolean deny, @NotNull String denyMsg,
|
||||
int cost) {
|
||||
super(portal, player);
|
||||
this.deny = deny;
|
||||
this.denyReason = denyMsg;
|
||||
@@ -57,6 +58,7 @@ public class StargateDestroyEvent extends StargatePlayerEvent {
|
||||
*
|
||||
* @return <p>The reason the event was denied</p>
|
||||
*/
|
||||
@NotNull
|
||||
public String getDenyReason() {
|
||||
return denyReason;
|
||||
}
|
||||
@@ -66,7 +68,7 @@ public class StargateDestroyEvent extends StargatePlayerEvent {
|
||||
*
|
||||
* @param denyReason <p>The reason the event was denied</p>
|
||||
*/
|
||||
public void setDenyReason(String denyReason) {
|
||||
public void setDenyReason(@NotNull String denyReason) {
|
||||
this.denyReason = denyReason;
|
||||
}
|
||||
|
||||
@@ -93,6 +95,7 @@ public class StargateDestroyEvent extends StargatePlayerEvent {
|
||||
*
|
||||
* @return <p>A handler-list with all event handlers</p>
|
||||
*/
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
@@ -27,7 +27,8 @@ public class StargateEntityPortalEvent extends StargateEvent implements Stargate
|
||||
* @param destination <p>The destination the entity should exit from</p>
|
||||
* @param exit <p>The exit location of the destination portal the entity will be teleported to</p>
|
||||
*/
|
||||
public StargateEntityPortalEvent(Entity travellingEntity, Portal portal, Portal destination, Location exit) {
|
||||
public StargateEntityPortalEvent(@NotNull Entity travellingEntity, @NotNull Portal portal,
|
||||
@NotNull Portal destination, @NotNull Location exit) {
|
||||
super(portal);
|
||||
|
||||
this.travellingEntity = travellingEntity;
|
||||
@@ -40,6 +41,7 @@ public class StargateEntityPortalEvent extends StargateEvent implements Stargate
|
||||
*
|
||||
* @return <p>The non-player teleporting</p>
|
||||
*/
|
||||
@NotNull
|
||||
public Entity getEntity() {
|
||||
return travellingEntity;
|
||||
}
|
||||
@@ -49,6 +51,7 @@ public class StargateEntityPortalEvent extends StargateEvent implements Stargate
|
||||
*
|
||||
* @return <p>The destination portal</p>
|
||||
*/
|
||||
@NotNull
|
||||
public Portal getDestination() {
|
||||
return destination;
|
||||
}
|
||||
@@ -59,6 +62,7 @@ public class StargateEntityPortalEvent extends StargateEvent implements Stargate
|
||||
* @return <p>Location of the exit point</p>
|
||||
*/
|
||||
@Override
|
||||
@NotNull
|
||||
public Location getExit() {
|
||||
return exit;
|
||||
}
|
||||
@@ -68,7 +72,7 @@ public class StargateEntityPortalEvent extends StargateEvent implements Stargate
|
||||
*
|
||||
* @param location <p>The new location of the entity's exit point</p>
|
||||
*/
|
||||
public void setExit(Location location) {
|
||||
public void setExit(@NotNull Location location) {
|
||||
this.exit = location;
|
||||
}
|
||||
|
||||
@@ -77,6 +81,7 @@ public class StargateEntityPortalEvent extends StargateEvent implements Stargate
|
||||
*
|
||||
* @return <p>A handler-list with all event handlers</p>
|
||||
*/
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@ package net.knarcraft.stargate.event;
|
||||
import net.knarcraft.stargate.portal.Portal;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* An abstract event describing any stargate event
|
||||
@@ -18,7 +19,7 @@ public abstract class StargateEvent extends Event implements Cancellable {
|
||||
*
|
||||
* @param portal <p>The portal involved in this stargate event</p>
|
||||
*/
|
||||
StargateEvent(Portal portal) {
|
||||
StargateEvent(@NotNull Portal portal) {
|
||||
this.portal = portal;
|
||||
this.cancelled = false;
|
||||
}
|
||||
@@ -28,6 +29,7 @@ public abstract class StargateEvent extends Event implements Cancellable {
|
||||
*
|
||||
* @return <p>The portal involved in this stargate event</p>
|
||||
*/
|
||||
@NotNull
|
||||
public Portal getPortal() {
|
||||
return portal;
|
||||
}
|
||||
|
@@ -4,6 +4,7 @@ import net.knarcraft.stargate.portal.Portal;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* This event should be called whenever a player opens a stargate
|
||||
@@ -23,7 +24,7 @@ public class StargateOpenEvent extends StargatePlayerEvent {
|
||||
* @param portal <p>The opened portal</p>
|
||||
* @param force <p>Whether to force the portal open</p>
|
||||
*/
|
||||
public StargateOpenEvent(Player player, Portal portal, boolean force) {
|
||||
public StargateOpenEvent(@Nullable Player player, @NotNull Portal portal, boolean force) {
|
||||
super(portal, player);
|
||||
|
||||
this.force = force;
|
||||
@@ -52,6 +53,7 @@ public class StargateOpenEvent extends StargatePlayerEvent {
|
||||
*
|
||||
* @return <p>A handler-list with all event handlers</p>
|
||||
*/
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
@@ -2,6 +2,8 @@ package net.knarcraft.stargate.event;
|
||||
|
||||
import net.knarcraft.stargate.portal.Portal;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* An abstract event describing any stargate event where a player is involved
|
||||
@@ -16,7 +18,7 @@ public abstract class StargatePlayerEvent extends StargateEvent {
|
||||
*
|
||||
* @param portal <p>The portal involved in this stargate event</p>
|
||||
*/
|
||||
StargatePlayerEvent(Portal portal, Player player) {
|
||||
StargatePlayerEvent(@NotNull Portal portal, @Nullable Player player) {
|
||||
super(portal);
|
||||
this.player = player;
|
||||
}
|
||||
@@ -26,6 +28,7 @@ public abstract class StargatePlayerEvent extends StargateEvent {
|
||||
*
|
||||
* @return <p>The player creating the star gate</p>
|
||||
*/
|
||||
@Nullable
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
@@ -26,7 +26,8 @@ public class StargatePlayerPortalEvent extends StargatePlayerEvent implements St
|
||||
* @param destination <p>The destination the player should exit from</p>
|
||||
* @param exit <p>The exit location of the destination portal the user will be teleported to</p>
|
||||
*/
|
||||
public StargatePlayerPortalEvent(Player player, Portal portal, Portal destination, Location exit) {
|
||||
public StargatePlayerPortalEvent(@NotNull Player player, @NotNull Portal portal, @NotNull Portal destination,
|
||||
@NotNull Location exit) {
|
||||
super(portal, player);
|
||||
|
||||
this.destination = destination;
|
||||
@@ -38,6 +39,7 @@ public class StargatePlayerPortalEvent extends StargatePlayerEvent implements St
|
||||
*
|
||||
* @return <p>The destination portal</p>
|
||||
*/
|
||||
@NotNull
|
||||
public Portal getDestination() {
|
||||
return destination;
|
||||
}
|
||||
@@ -48,6 +50,7 @@ public class StargatePlayerPortalEvent extends StargatePlayerEvent implements St
|
||||
* @return <p>Location of the exit point</p>
|
||||
*/
|
||||
@Override
|
||||
@NotNull
|
||||
public Location getExit() {
|
||||
return exit;
|
||||
}
|
||||
@@ -57,7 +60,7 @@ public class StargatePlayerPortalEvent extends StargatePlayerEvent implements St
|
||||
*
|
||||
* @param location <p>The new location of the player's exit point</p>
|
||||
*/
|
||||
public void setExit(Location location) {
|
||||
public void setExit(@NotNull Location location) {
|
||||
this.exit = location;
|
||||
}
|
||||
|
||||
@@ -66,6 +69,7 @@ public class StargatePlayerPortalEvent extends StargatePlayerEvent implements St
|
||||
*
|
||||
* @return <p>A handler-list with all event handlers</p>
|
||||
*/
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@ package net.knarcraft.stargate.event;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* A generic teleportation event
|
||||
@@ -13,6 +14,7 @@ public interface StargateTeleportEvent extends Cancellable {
|
||||
*
|
||||
* @return <p>Location of the exit point</p>
|
||||
*/
|
||||
@NotNull
|
||||
Location getExit();
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user