1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-19 19:25:48 +00:00

[CI skip] More nullability annotations

This commit is contained in:
TheBusyBiscuit 2020-09-05 13:56:56 +02:00
parent 5f897de0b0
commit 8061df9b5e
24 changed files with 165 additions and 30 deletions

14
pom.xml
View File

@ -159,7 +159,7 @@
<configuration> <configuration>
<!-- Shade bStats and CS-CoreLib2 into the output jar --> <!-- Shade dependencies into the output jar -->
<relocations> <relocations>
<relocation> <relocation>
<pattern>org.bstats</pattern> <pattern>org.bstats</pattern>
@ -294,13 +294,15 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- Development / Testing dependencies --> <!-- Development dependencies -->
<dependency> <dependency>
<groupId>javax.annotation</groupId> <groupId>com.google.code.findbugs</groupId>
<artifactId>javax.annotation-api</artifactId> <artifactId>jsr305</artifactId>
<version>1.3.2</version> <version>3.0.2</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- Testing dependencies -->
<dependency> <dependency>
<groupId>org.junit.jupiter</groupId> <groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId> <artifactId>junit-jupiter</artifactId>
@ -360,7 +362,7 @@
</exclusions> </exclusions>
</dependency> </dependency>
<!-- Third party plugin integrations --> <!-- Third party plugin integrations / soft dependencies -->
<dependency> <dependency>
<groupId>com.sk89q.worldedit</groupId> <groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-bukkit</artifactId> <artifactId>worldedit-bukkit</artifactId>

View File

@ -1,5 +1,8 @@
package io.github.thebusybiscuit.slimefun4.api.events; package io.github.thebusybiscuit.slimefun4.api.events;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -38,6 +41,7 @@ public class AncientAltarCraftEvent extends PlayerEvent implements Cancellable {
* @param player * @param player
* The {@link Player} that started the ritual. * The {@link Player} that started the ritual.
*/ */
@ParametersAreNonnullByDefault
public AncientAltarCraftEvent(ItemStack output, Block block, Player player) { public AncientAltarCraftEvent(ItemStack output, Block block, Player player) {
super(player); super(player);
@ -50,6 +54,7 @@ public class AncientAltarCraftEvent extends PlayerEvent implements Cancellable {
* *
* @return the main altar's block {@link Block} * @return the main altar's block {@link Block}
*/ */
@Nonnull
public Block getAltarBlock() { public Block getAltarBlock() {
return block; return block;
} }
@ -59,6 +64,7 @@ public class AncientAltarCraftEvent extends PlayerEvent implements Cancellable {
* *
* @return the {@link ItemStack} that would be dropped by the {@link AncientAltar} * @return the {@link ItemStack} that would be dropped by the {@link AncientAltar}
*/ */
@Nonnull
public ItemStack getItem() { public ItemStack getItem() {
return output; return output;
} }
@ -87,10 +93,12 @@ public class AncientAltarCraftEvent extends PlayerEvent implements Cancellable {
cancelled = cancel; cancelled = cancel;
} }
@Nonnull
public static HandlerList getHandlerList() { public static HandlerList getHandlerList() {
return handlers; return handlers;
} }
@Nonnull
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();

View File

@ -1,5 +1,8 @@
package io.github.thebusybiscuit.slimefun4.api.events; package io.github.thebusybiscuit.slimefun4.api.events;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.Event; import org.bukkit.event.Event;
@ -29,6 +32,7 @@ public class AndroidMineEvent extends Event implements Cancellable {
* @param android * @param android
* The {@link AndroidInstance} that triggered this {@link Event} * The {@link AndroidInstance} that triggered this {@link Event}
*/ */
@ParametersAreNonnullByDefault
public AndroidMineEvent(Block block, AndroidInstance android) { public AndroidMineEvent(Block block, AndroidInstance android) {
this.block = block; this.block = block;
this.android = android; this.android = android;
@ -39,6 +43,7 @@ public class AndroidMineEvent extends Event implements Cancellable {
* *
* @return the mined {@link Block} * @return the mined {@link Block}
*/ */
@Nonnull
public Block getBlock() { public Block getBlock() {
return block; return block;
} }
@ -49,6 +54,7 @@ public class AndroidMineEvent extends Event implements Cancellable {
* *
* @return the involved {@link AndroidInstance} * @return the involved {@link AndroidInstance}
*/ */
@Nonnull
public AndroidInstance getAndroid() { public AndroidInstance getAndroid() {
return android; return android;
} }
@ -63,10 +69,12 @@ public class AndroidMineEvent extends Event implements Cancellable {
cancelled = cancel; cancelled = cancel;
} }
@Nonnull
public static HandlerList getHandlerList() { public static HandlerList getHandlerList() {
return handlers; return handlers;
} }
@Nonnull
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();

View File

@ -1,5 +1,7 @@
package io.github.thebusybiscuit.slimefun4.api.events; package io.github.thebusybiscuit.slimefun4.api.events;
import javax.annotation.Nonnull;
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; import org.bukkit.event.HandlerList;
@ -21,7 +23,7 @@ public class AutoDisenchantEvent extends Event implements Cancellable {
private final ItemStack item; private final ItemStack item;
private boolean cancelled; private boolean cancelled;
public AutoDisenchantEvent(ItemStack item) { public AutoDisenchantEvent(@Nonnull ItemStack item) {
super(true); super(true);
this.item = item; this.item = item;
@ -32,13 +34,14 @@ public class AutoDisenchantEvent extends Event implements Cancellable {
* *
* @return The {@link ItemStack} that is being disenchanted * @return The {@link ItemStack} that is being disenchanted
*/ */
@Nonnull
public ItemStack getItem() { public ItemStack getItem() {
return this.item; return item;
} }
@Override @Override
public boolean isCancelled() { public boolean isCancelled() {
return this.cancelled; return cancelled;
} }
@Override @Override
@ -46,10 +49,12 @@ public class AutoDisenchantEvent extends Event implements Cancellable {
this.cancelled = cancel; this.cancelled = cancel;
} }
@Nonnull
public static HandlerList getHandlerList() { public static HandlerList getHandlerList() {
return handlers; return handlers;
} }
@Nonnull
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();

View File

@ -1,5 +1,8 @@
package io.github.thebusybiscuit.slimefun4.api.events; package io.github.thebusybiscuit.slimefun4.api.events;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
@ -37,6 +40,7 @@ public class BlockPlacerPlaceEvent extends BlockEvent implements Cancellable {
* @param block * @param block
* The placed {@link Block} * The placed {@link Block}
*/ */
@ParametersAreNonnullByDefault
public BlockPlacerPlaceEvent(Block blockPlacer, ItemStack placedItem, Block block) { public BlockPlacerPlaceEvent(Block blockPlacer, ItemStack placedItem, Block block) {
super(block); super(block);
@ -49,6 +53,7 @@ public class BlockPlacerPlaceEvent extends BlockEvent implements Cancellable {
* *
* @return The {@link BlockPlacer} * @return The {@link BlockPlacer}
*/ */
@Nonnull
public Block getBlockPlacer() { public Block getBlockPlacer() {
return blockPlacer; return blockPlacer;
} }
@ -58,6 +63,7 @@ public class BlockPlacerPlaceEvent extends BlockEvent implements Cancellable {
* *
* @return The placed {@link ItemStack} * @return The placed {@link ItemStack}
*/ */
@Nonnull
public ItemStack getItemStack() { public ItemStack getItemStack() {
return placedItem; return placedItem;
} }
@ -68,7 +74,7 @@ public class BlockPlacerPlaceEvent extends BlockEvent implements Cancellable {
* @param item * @param item
* The {@link ItemStack} to be placed * The {@link ItemStack} to be placed
*/ */
public void setItemStack(ItemStack item) { public void setItemStack(@Nonnull ItemStack item) {
Validate.notNull(item, "The ItemStack must not be null!"); Validate.notNull(item, "The ItemStack must not be null!");
if (!locked) { if (!locked) {
@ -101,10 +107,12 @@ public class BlockPlacerPlaceEvent extends BlockEvent implements Cancellable {
locked = true; locked = true;
} }
@Nonnull
public static HandlerList getHandlerList() { public static HandlerList getHandlerList() {
return handlers; return handlers;
} }
@Nonnull
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();

View File

@ -1,5 +1,8 @@
package io.github.thebusybiscuit.slimefun4.api.events; package io.github.thebusybiscuit.slimefun4.api.events;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -32,6 +35,7 @@ public class ClimbingPickLaunchEvent extends PlayerEvent implements Cancellable
private boolean cancelled; private boolean cancelled;
@ParametersAreNonnullByDefault
public ClimbingPickLaunchEvent(Player player, Vector velocity, ClimbingPick pick, ItemStack itemStack, Block block) { public ClimbingPickLaunchEvent(Player player, Vector velocity, ClimbingPick pick, ItemStack itemStack, Block block) {
super(player); super(player);
@ -47,6 +51,7 @@ public class ClimbingPickLaunchEvent extends PlayerEvent implements Cancellable
* *
* @return The {@link Vector} of the applied velocity * @return The {@link Vector} of the applied velocity
*/ */
@Nonnull
public Vector getVelocity() { public Vector getVelocity() {
return velocity; return velocity;
} }
@ -57,7 +62,7 @@ public class ClimbingPickLaunchEvent extends PlayerEvent implements Cancellable
* @param velocity * @param velocity
* The {@link Vector} velocity to apply * The {@link Vector} velocity to apply
*/ */
public void setVelocity(Vector velocity) { public void setVelocity(@Nonnull Vector velocity) {
Validate.notNull(velocity); Validate.notNull(velocity);
this.velocity = velocity; this.velocity = velocity;
} }
@ -67,8 +72,9 @@ public class ClimbingPickLaunchEvent extends PlayerEvent implements Cancellable
* *
* @return The {@link ClimbingPick} that was used * @return The {@link ClimbingPick} that was used
*/ */
@Nonnull
public ClimbingPick getPick() { public ClimbingPick getPick() {
return this.pick; return pick;
} }
/** /**
@ -76,8 +82,9 @@ public class ClimbingPickLaunchEvent extends PlayerEvent implements Cancellable
* *
* @return The {@link ItemStack} that was used * @return The {@link ItemStack} that was used
*/ */
@Nonnull
public ItemStack getItemStack() { public ItemStack getItemStack() {
return this.itemStack; return itemStack;
} }
/** /**
@ -85,13 +92,14 @@ public class ClimbingPickLaunchEvent extends PlayerEvent implements Cancellable
* *
* @return The {@link Block} that was climbed * @return The {@link Block} that was climbed
*/ */
@Nonnull
public Block getBlock() { public Block getBlock() {
return this.block; return block;
} }
@Override @Override
public boolean isCancelled() { public boolean isCancelled() {
return this.cancelled; return cancelled;
} }
@Override @Override
@ -99,10 +107,12 @@ public class ClimbingPickLaunchEvent extends PlayerEvent implements Cancellable
this.cancelled = cancel; this.cancelled = cancel;
} }
@Nonnull
public static HandlerList getHandlerList() { public static HandlerList getHandlerList() {
return handlers; return handlers;
} }
@Nonnull
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();

View File

@ -1,5 +1,8 @@
package io.github.thebusybiscuit.slimefun4.api.events; package io.github.thebusybiscuit.slimefun4.api.events;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
@ -38,6 +41,7 @@ public class GEOResourceGenerationEvent extends Event {
private int value; private int value;
@ParametersAreNonnullByDefault
public GEOResourceGenerationEvent(World world, Biome biome, int x, int z, GEOResource resource, int value) { public GEOResourceGenerationEvent(World world, Biome biome, int x, int z, GEOResource resource, int value) {
this.world = world; this.world = world;
this.biome = biome; this.biome = biome;
@ -76,6 +80,7 @@ public class GEOResourceGenerationEvent extends Event {
* *
* @return The affected {@link World} * @return The affected {@link World}
*/ */
@Nonnull
public World getWorld() { public World getWorld() {
return world; return world;
} }
@ -85,6 +90,7 @@ public class GEOResourceGenerationEvent extends Event {
* *
* @return The generated {@link GEOResource} * @return The generated {@link GEOResource}
*/ */
@Nonnull
public GEOResource getResource() { public GEOResource getResource() {
return resource; return resource;
} }
@ -115,6 +121,7 @@ public class GEOResourceGenerationEvent extends Event {
* *
* @return The {@link Environment} of this generation * @return The {@link Environment} of this generation
*/ */
@Nonnull
public Environment getEnvironment() { public Environment getEnvironment() {
return world.getEnvironment(); return world.getEnvironment();
} }
@ -125,6 +132,7 @@ public class GEOResourceGenerationEvent extends Event {
* *
* @return The {@link Biome} of this generation * @return The {@link Biome} of this generation
*/ */
@Nonnull
public Biome getBiome() { public Biome getBiome() {
return biome; return biome;
} }

View File

@ -1,5 +1,8 @@
package io.github.thebusybiscuit.slimefun4.api.events; package io.github.thebusybiscuit.slimefun4.api.events;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -25,6 +28,7 @@ public class MultiBlockInteractEvent extends PlayerEvent implements Cancellable
private final BlockFace clickedFace; private final BlockFace clickedFace;
private boolean cancelled; private boolean cancelled;
@ParametersAreNonnullByDefault
public MultiBlockInteractEvent(Player p, MultiBlock mb, Block clicked, BlockFace face) { public MultiBlockInteractEvent(Player p, MultiBlock mb, Block clicked, BlockFace face) {
super(p); super(p);
this.multiBlock = mb; this.multiBlock = mb;
@ -37,6 +41,7 @@ public class MultiBlockInteractEvent extends PlayerEvent implements Cancellable
* *
* @return The {@link MultiBlock} of this {@link MultiBlockInteractEvent} * @return The {@link MultiBlock} of this {@link MultiBlockInteractEvent}
*/ */
@Nonnull
public MultiBlock getMultiBlock() { public MultiBlock getMultiBlock() {
return multiBlock; return multiBlock;
} }
@ -46,6 +51,7 @@ public class MultiBlockInteractEvent extends PlayerEvent implements Cancellable
* *
* @return The {@link Block} that was clicked * @return The {@link Block} that was clicked
*/ */
@Nonnull
public Block getClickedBlock() { public Block getClickedBlock() {
return clickedBlock; return clickedBlock;
} }
@ -55,6 +61,7 @@ public class MultiBlockInteractEvent extends PlayerEvent implements Cancellable
* *
* @return The {@link BlockFace} that was clicked * @return The {@link BlockFace} that was clicked
*/ */
@Nonnull
public BlockFace getClickedFace() { public BlockFace getClickedFace() {
return clickedFace; return clickedFace;
} }
@ -69,10 +76,12 @@ public class MultiBlockInteractEvent extends PlayerEvent implements Cancellable
this.cancelled = cancel; this.cancelled = cancel;
} }
@Nonnull
public static HandlerList getHandlerList() { public static HandlerList getHandlerList() {
return handlers; return handlers;
} }
@Nonnull
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();

View File

@ -1,5 +1,7 @@
package io.github.thebusybiscuit.slimefun4.api.events; package io.github.thebusybiscuit.slimefun4.api.events;
import javax.annotation.Nonnull;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
@ -24,7 +26,7 @@ public class PlayerLanguageChangeEvent extends Event {
private final Language from; private final Language from;
private final Language to; private final Language to;
public PlayerLanguageChangeEvent(Player p, Language from, Language to) { public PlayerLanguageChangeEvent(@Nonnull Player p, @Nonnull Language from, @Nonnull Language to) {
player = p; player = p;
this.from = from; this.from = from;
this.to = to; this.to = to;
@ -36,6 +38,7 @@ public class PlayerLanguageChangeEvent extends Event {
* *
* @return The {@link Player} who switched his {@link Language} * @return The {@link Player} who switched his {@link Language}
*/ */
@Nonnull
public Player getPlayer() { public Player getPlayer() {
return player; return player;
} }
@ -45,6 +48,7 @@ public class PlayerLanguageChangeEvent extends Event {
* *
* @return The previous {@link Language} of our {@link Player} * @return The previous {@link Language} of our {@link Player}
*/ */
@Nonnull
public Language getPreviousLanguage() { public Language getPreviousLanguage() {
return from; return from;
} }
@ -54,6 +58,7 @@ public class PlayerLanguageChangeEvent extends Event {
* *
* @return The new {@link Language} * @return The new {@link Language}
*/ */
@Nonnull
public Language getNewLanguage() { public Language getNewLanguage() {
return to; return to;
} }

View File

@ -2,6 +2,9 @@ package io.github.thebusybiscuit.slimefun4.api.events;
import java.util.Optional; import java.util.Optional;
import javax.annotation.Nonnull;
import org.apache.commons.lang.Validate;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
@ -35,7 +38,7 @@ public class PlayerRightClickEvent extends Event {
private Result itemResult = Result.DEFAULT; private Result itemResult = Result.DEFAULT;
private Result blockResult = Result.DEFAULT; private Result blockResult = Result.DEFAULT;
public PlayerRightClickEvent(PlayerInteractEvent e) { public PlayerRightClickEvent(@Nonnull PlayerInteractEvent e) {
event = e; event = e;
player = e.getPlayer(); player = e.getPlayer();
clickedBlock = Optional.ofNullable(e.getClickedBlock()); clickedBlock = Optional.ofNullable(e.getClickedBlock());
@ -50,10 +53,12 @@ public class PlayerRightClickEvent extends Event {
} }
} }
@Nonnull
public PlayerInteractEvent getInteractEvent() { public PlayerInteractEvent getInteractEvent() {
return event; return event;
} }
@Nonnull
public Player getPlayer() { public Player getPlayer() {
return player; return player;
} }
@ -65,6 +70,7 @@ public class PlayerRightClickEvent extends Event {
* *
* @return The {@link ItemStack} that the {@link Player} right clicked with * @return The {@link ItemStack} that the {@link Player} right clicked with
*/ */
@Nonnull
public ItemStack getItem() { public ItemStack getItem() {
return itemStack.orElse(new ItemStack(Material.AIR)); return itemStack.orElse(new ItemStack(Material.AIR));
} }
@ -75,20 +81,23 @@ public class PlayerRightClickEvent extends Event {
* *
* @return The hand used in this {@link Event} * @return The hand used in this {@link Event}
*/ */
@Nonnull
public EquipmentSlot getHand() { public EquipmentSlot getHand() {
return hand; return hand;
} }
@Nonnull
public Optional<Block> getClickedBlock() { public Optional<Block> getClickedBlock() {
return clickedBlock; return clickedBlock;
} }
@Nonnull
public BlockFace getClickedFace() { public BlockFace getClickedFace() {
return face; return face;
} }
@Nonnull
public Optional<SlimefunItem> getSlimefunItem() { public Optional<SlimefunItem> getSlimefunItem() {
if (!slimefunItem.isComputed()) { if (!slimefunItem.isComputed()) {
if (itemStack.isPresent()) { if (itemStack.isPresent()) {
slimefunItem.compute(SlimefunItem.getByItem(itemStack.get())); slimefunItem.compute(SlimefunItem.getByItem(itemStack.get()));
@ -101,8 +110,8 @@ public class PlayerRightClickEvent extends Event {
return slimefunItem.getAsOptional(); return slimefunItem.getAsOptional();
} }
@Nonnull
public Optional<SlimefunItem> getSlimefunBlock() { public Optional<SlimefunItem> getSlimefunBlock() {
if (!slimefunBlock.isComputed()) { if (!slimefunBlock.isComputed()) {
if (clickedBlock.isPresent()) { if (clickedBlock.isPresent()) {
slimefunBlock.compute(BlockStorage.check(clickedBlock.get())); slimefunBlock.compute(BlockStorage.check(clickedBlock.get()));
@ -120,26 +129,32 @@ public class PlayerRightClickEvent extends Event {
blockResult = Result.DENY; blockResult = Result.DENY;
} }
@Nonnull
public Result useItem() { public Result useItem() {
return itemResult; return itemResult;
} }
@Nonnull
public Result useBlock() { public Result useBlock() {
return blockResult; return blockResult;
} }
public void setUseItem(Result result) { public void setUseItem(@Nonnull Result result) {
Validate.notNull(result, "Result cannot be null");
itemResult = result; itemResult = result;
} }
public void setUseBlock(Result result) { public void setUseBlock(@Nonnull Result result) {
Validate.notNull(result, "Result cannot be null");
blockResult = result; blockResult = result;
} }
@Nonnull
public static HandlerList getHandlerList() { public static HandlerList getHandlerList() {
return handlers; return handlers;
} }
@Nonnull
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();

View File

@ -1,5 +1,7 @@
package io.github.thebusybiscuit.slimefun4.api.events; package io.github.thebusybiscuit.slimefun4.api.events;
import javax.annotation.Nonnull;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.event.Event; import org.bukkit.event.Event;
@ -21,7 +23,7 @@ public class ReactorExplodeEvent extends Event {
private final Location location; private final Location location;
private final Reactor reactor; private final Reactor reactor;
public ReactorExplodeEvent(Location l, Reactor reactor) { public ReactorExplodeEvent(@Nonnull Location l, @Nonnull Reactor reactor) {
Validate.notNull(l, "A Location must be provided"); Validate.notNull(l, "A Location must be provided");
Validate.notNull(reactor, "A Reactor cannot be null"); Validate.notNull(reactor, "A Reactor cannot be null");
@ -34,6 +36,7 @@ public class ReactorExplodeEvent extends Event {
* *
* @return The {@link Location} of this explosion * @return The {@link Location} of this explosion
*/ */
@Nonnull
public Location getLocation() { public Location getLocation() {
return location; return location;
} }
@ -43,14 +46,17 @@ public class ReactorExplodeEvent extends Event {
* *
* @return The {@link SlimefunItem} instance * @return The {@link SlimefunItem} instance
*/ */
@Nonnull
public Reactor getReactor() { public Reactor getReactor() {
return reactor; return reactor;
} }
@Nonnull
public static HandlerList getHandlerList() { public static HandlerList getHandlerList() {
return handlers; return handlers;
} }
@Nonnull
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();

View File

@ -1,5 +1,8 @@
package io.github.thebusybiscuit.slimefun4.api.events; package io.github.thebusybiscuit.slimefun4.api.events;
import javax.annotation.Nonnull;
import org.apache.commons.lang.Validate;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.Event; import org.bukkit.event.Event;
@ -23,15 +26,19 @@ public class ResearchUnlockEvent extends Event implements Cancellable {
private final Research research; private final Research research;
private boolean cancelled; private boolean cancelled;
public ResearchUnlockEvent(Player p, Research research) { public ResearchUnlockEvent(@Nonnull Player p, @Nonnull Research research) {
Validate.notNull(p, "The Player cannot be null");
Validate.notNull(research, "Research cannot be null");
this.player = p; this.player = p;
this.research = research; this.research = research;
} }
@Nonnull
public Player getPlayer() { public Player getPlayer() {
return player; return player;
} }
@Nonnull
public Research getResearch() { public Research getResearch() {
return research; return research;
} }
@ -46,10 +53,12 @@ public class ResearchUnlockEvent extends Event implements Cancellable {
this.cancelled = cancel; this.cancelled = cancel;
} }
@Nonnull
public static HandlerList getHandlerList() { public static HandlerList getHandlerList() {
return handlers; return handlers;
} }
@Nonnull
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();

View File

@ -1,5 +1,7 @@
package io.github.thebusybiscuit.slimefun4.api.events; package io.github.thebusybiscuit.slimefun4.api.events;
import javax.annotation.Nonnull;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -32,7 +34,7 @@ public class WaypointCreateEvent extends PlayerEvent implements Cancellable {
private final boolean deathpoint; private final boolean deathpoint;
private boolean cancelled; private boolean cancelled;
public WaypointCreateEvent(Player player, String name, Location location) { public WaypointCreateEvent(@Nonnull Player player, @Nonnull String name, @Nonnull Location location) {
super(player); super(player);
Validate.notNull(location, "Location must not be null!"); Validate.notNull(location, "Location must not be null!");
@ -48,6 +50,7 @@ public class WaypointCreateEvent extends PlayerEvent implements Cancellable {
* *
* @return The {@link Location} of this waypoint * @return The {@link Location} of this waypoint
*/ */
@Nonnull
public Location getLocation() { public Location getLocation() {
return location; return location;
} }
@ -59,7 +62,7 @@ public class WaypointCreateEvent extends PlayerEvent implements Cancellable {
* @param loc * @param loc
* The {@link Location} to set * The {@link Location} to set
*/ */
public void setLocation(Location loc) { public void setLocation(@Nonnull Location loc) {
Validate.notNull(loc, "Cannot set the Location to null!"); Validate.notNull(loc, "Cannot set the Location to null!");
this.location = loc; this.location = loc;
} }
@ -69,6 +72,7 @@ public class WaypointCreateEvent extends PlayerEvent implements Cancellable {
* *
* @return The name of this waypoint * @return The name of this waypoint
*/ */
@Nonnull
public String getName() { public String getName() {
return name; return name;
} }
@ -79,7 +83,7 @@ public class WaypointCreateEvent extends PlayerEvent implements Cancellable {
* @param name * @param name
* The name for this waypoint * The name for this waypoint
*/ */
public void setName(String name) { public void setName(@Nonnull String name) {
Validate.notEmpty(name, "The name of a waypoint must not be empty!"); Validate.notEmpty(name, "The name of a waypoint must not be empty!");
this.name = name; this.name = name;
} }
@ -104,10 +108,12 @@ public class WaypointCreateEvent extends PlayerEvent implements Cancellable {
this.cancelled = cancel; this.cancelled = cancel;
} }
@Nonnull
public static HandlerList getHandlerList() { public static HandlerList getHandlerList() {
return handlers; return handlers;
} }
@Nonnull
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return getHandlerList(); return getHandlerList();

View File

@ -1,6 +1,7 @@
package io.github.thebusybiscuit.slimefun4.implementation.items; package io.github.thebusybiscuit.slimefun4.implementation.items;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -45,6 +46,7 @@ public class RadioactiveItem extends SlimefunItem implements Radioactive, NotPla
* @param recipe * @param recipe
* The recipe of how to craft this {@link SlimefunItem} * The recipe of how to craft this {@link SlimefunItem}
*/ */
@ParametersAreNonnullByDefault
public RadioactiveItem(Category category, Radioactivity radioactivity, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { public RadioactiveItem(Category category, Radioactivity radioactivity, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
this(category, radioactivity, item, recipeType, recipe, null); this(category, radioactivity, item, recipeType, recipe, null);
} }
@ -65,6 +67,7 @@ public class RadioactiveItem extends SlimefunItem implements Radioactive, NotPla
* @param recipeOutput * @param recipeOutput
* The recipe output * The recipe output
*/ */
@ParametersAreNonnullByDefault
public RadioactiveItem(Category category, Radioactivity radioactivity, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) { public RadioactiveItem(Category category, Radioactivity radioactivity, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) {
super(category, item, recipeType, recipe, recipeOutput); super(category, item, recipeType, recipe, recipeOutput);

View File

@ -1,6 +1,7 @@
package io.github.thebusybiscuit.slimefun4.implementation.items; package io.github.thebusybiscuit.slimefun4.implementation.items;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -29,10 +30,12 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
*/ */
public abstract class SimpleSlimefunItem<T extends ItemHandler> extends SlimefunItem { public abstract class SimpleSlimefunItem<T extends ItemHandler> extends SlimefunItem {
@ParametersAreNonnullByDefault
public SimpleSlimefunItem(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { public SimpleSlimefunItem(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe); super(category, item, recipeType, recipe);
} }
@ParametersAreNonnullByDefault
public SimpleSlimefunItem(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) { public SimpleSlimefunItem(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) {
super(category, item, recipeType, recipe, recipeOutput); super(category, item, recipeType, recipe, recipeOutput);
} }

View File

@ -1,5 +1,7 @@
package io.github.thebusybiscuit.slimefun4.implementation.items; package io.github.thebusybiscuit.slimefun4.implementation.items;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.api.items.ItemState; import io.github.thebusybiscuit.slimefun4.api.items.ItemState;
@ -38,6 +40,7 @@ public class VanillaItem extends SlimefunItem {
* @param recipe * @param recipe
* the recipe to obtain this {@link VanillaItem} * the recipe to obtain this {@link VanillaItem}
*/ */
@ParametersAreNonnullByDefault
public VanillaItem(Category category, ItemStack item, String id, RecipeType recipeType, ItemStack[] recipe) { public VanillaItem(Category category, ItemStack item, String id, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, id, recipeType, recipe); super(category, item, id, recipeType, recipe);

View File

@ -6,6 +6,7 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -40,6 +41,7 @@ public abstract class AbstractEnergyProvider extends SlimefunItem implements Inv
protected final Set<MachineFuel> fuelTypes = new HashSet<>(); protected final Set<MachineFuel> fuelTypes = new HashSet<>();
@ParametersAreNonnullByDefault
protected AbstractEnergyProvider(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { protected AbstractEnergyProvider(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe); super(category, item, recipeType, recipe);
} }
@ -81,6 +83,7 @@ public abstract class AbstractEnergyProvider extends SlimefunItem implements Inv
protected abstract void registerDefaultFuelTypes(); protected abstract void registerDefaultFuelTypes();
@Override @Override
@Nonnull
public EnergyNetComponentType getEnergyComponentType() { public EnergyNetComponentType getEnergyComponentType() {
return EnergyNetComponentType.GENERATOR; return EnergyNetComponentType.GENERATOR;
} }

View File

@ -1,5 +1,8 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.electric; package io.github.thebusybiscuit.slimefun4.implementation.items.electric;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent; import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent;
@ -26,6 +29,7 @@ public class Capacitor extends SlimefunItem implements EnergyNetComponent {
private final int capacity; private final int capacity;
@ParametersAreNonnullByDefault
public Capacitor(Category category, int capacity, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { public Capacitor(Category category, int capacity, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe); super(category, item, recipeType, recipe);
@ -33,6 +37,7 @@ public class Capacitor extends SlimefunItem implements EnergyNetComponent {
} }
@Override @Override
@Nonnull
public EnergyNetComponentType getEnergyComponentType() { public EnergyNetComponentType getEnergyComponentType() {
return EnergyNetComponentType.CAPACITOR; return EnergyNetComponentType.CAPACITOR;
} }

View File

@ -1,6 +1,7 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.electric; package io.github.thebusybiscuit.slimefun4.implementation.items.electric;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
@ -29,6 +30,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
*/ */
public class EnergyRegulator extends SlimefunItem { public class EnergyRegulator extends SlimefunItem {
@ParametersAreNonnullByDefault
public EnergyRegulator(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { public EnergyRegulator(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe); super(category, item, recipeType, recipe);

View File

@ -2,6 +2,8 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets
import java.util.Optional; import java.util.Optional;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -28,6 +30,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
*/ */
public class Multimeter extends SimpleSlimefunItem<ItemUseHandler> { public class Multimeter extends SimpleSlimefunItem<ItemUseHandler> {
@ParametersAreNonnullByDefault
public Multimeter(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { public Multimeter(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe); super(category, item, recipeType, recipe);
} }

View File

@ -1,5 +1,9 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets; package io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -27,6 +31,7 @@ public class SolarHelmet extends SlimefunItem {
private final ItemSetting<Double> charge; private final ItemSetting<Double> charge;
@ParametersAreNonnullByDefault
public SolarHelmet(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, double defaultChargingLevel) { public SolarHelmet(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, double defaultChargingLevel) {
super(category, item, recipeType, recipe); super(category, item, recipeType, recipe);
@ -45,7 +50,7 @@ public class SolarHelmet extends SlimefunItem {
* @param p * @param p
* The {@link Player} wearing this {@link SolarHelmet} * The {@link Player} wearing this {@link SolarHelmet}
*/ */
public void rechargeItems(Player p) { public void rechargeItems(@Nonnull Player p) {
recharge(p.getInventory().getHelmet()); recharge(p.getInventory().getHelmet());
recharge(p.getInventory().getChestplate()); recharge(p.getInventory().getChestplate());
recharge(p.getInventory().getLeggings()); recharge(p.getInventory().getLeggings());
@ -54,7 +59,7 @@ public class SolarHelmet extends SlimefunItem {
recharge(p.getInventory().getItemInOffHand()); recharge(p.getInventory().getItemInOffHand());
} }
private void recharge(ItemStack item) { private void recharge(@Nullable ItemStack item) {
SlimefunItem sfItem = SlimefunItem.getByItem(item); SlimefunItem sfItem = SlimefunItem.getByItem(item);
if (sfItem instanceof Rechargeable) { if (sfItem instanceof Rechargeable) {

View File

@ -1,5 +1,8 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors; package io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.ArmorStand; import org.bukkit.entity.ArmorStand;
@ -28,6 +31,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
*/ */
public abstract class NetherStarReactor extends Reactor { public abstract class NetherStarReactor extends Reactor {
@ParametersAreNonnullByDefault
public NetherStarReactor(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { public NetherStarReactor(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe); super(category, item, recipeType, recipe);
} }
@ -38,7 +42,7 @@ public abstract class NetherStarReactor extends Reactor {
} }
@Override @Override
public void extraTick(Location l) { public void extraTick(@Nonnull Location l) {
Slimefun.runSync(() -> { Slimefun.runSync(() -> {
ArmorStand hologram = ReactorHologram.getArmorStand(l, true); ArmorStand hologram = ReactorHologram.getArmorStand(l, true);
for (Entity entity : hologram.getNearbyEntities(5, 5, 5)) { for (Entity entity : hologram.getNearbyEntities(5, 5, 5)) {

View File

@ -1,5 +1,8 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors; package io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -22,6 +25,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
*/ */
public abstract class NuclearReactor extends Reactor { public abstract class NuclearReactor extends Reactor {
@ParametersAreNonnullByDefault
public NuclearReactor(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { public NuclearReactor(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe); super(category, item, recipeType, recipe);
} }
@ -49,7 +53,7 @@ public abstract class NuclearReactor extends Reactor {
} }
@Override @Override
public void extraTick(Location l) { public void extraTick(@Nonnull Location l) {
// This machine does not need to perform anything while ticking // This machine does not need to perform anything while ticking
// The Nether Star Reactor uses this method to generate the Wither Effect // The Nether Star Reactor uses this method to generate the Wither Effect
} }

View File

@ -76,6 +76,7 @@ public abstract class Reactor extends AbstractEnergyProvider {
private final Set<Location> explosionsQueue = new HashSet<>(); private final Set<Location> explosionsQueue = new HashSet<>();
@ParametersAreNonnullByDefault
public Reactor(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { public Reactor(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe); super(category, item, recipeType, recipe);