From 8061df9b5e0419e1157a353a95352537a1d91468 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 5 Sep 2020 13:56:56 +0200 Subject: [PATCH] [CI skip] More nullability annotations --- pom.xml | 14 ++++++----- .../api/events/AncientAltarCraftEvent.java | 8 ++++++ .../api/events/AndroidMineEvent.java | 8 ++++++ .../api/events/AutoDisenchantEvent.java | 11 +++++--- .../api/events/BlockPlacerPlaceEvent.java | 10 +++++++- .../api/events/ClimbingPickLaunchEvent.java | 20 +++++++++++---- .../events/GEOResourceGenerationEvent.java | 8 ++++++ .../api/events/MultiBlockInteractEvent.java | 9 +++++++ .../api/events/PlayerLanguageChangeEvent.java | 7 +++++- .../api/events/PlayerRightClickEvent.java | 25 +++++++++++++++---- .../api/events/ReactorExplodeEvent.java | 8 +++++- .../api/events/ResearchUnlockEvent.java | 11 +++++++- .../api/events/WaypointCreateEvent.java | 12 ++++++--- .../implementation/items/RadioactiveItem.java | 3 +++ .../items/SimpleSlimefunItem.java | 3 +++ .../implementation/items/VanillaItem.java | 3 +++ .../electric/AbstractEnergyProvider.java | 3 +++ .../items/electric/Capacitor.java | 5 ++++ .../items/electric/EnergyRegulator.java | 2 ++ .../items/electric/gadgets/Multimeter.java | 3 +++ .../items/electric/gadgets/SolarHelmet.java | 9 +++++-- .../electric/reactors/NetherStarReactor.java | 6 ++++- .../electric/reactors/NuclearReactor.java | 6 ++++- .../items/electric/reactors/Reactor.java | 1 + 24 files changed, 165 insertions(+), 30 deletions(-) diff --git a/pom.xml b/pom.xml index b7434980f..5a3da9e29 100644 --- a/pom.xml +++ b/pom.xml @@ -159,7 +159,7 @@ - + org.bstats @@ -294,13 +294,15 @@ provided - + - javax.annotation - javax.annotation-api - 1.3.2 + com.google.code.findbugs + jsr305 + 3.0.2 provided + + org.junit.jupiter junit-jupiter @@ -360,7 +362,7 @@ - + com.sk89q.worldedit worldedit-bukkit diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AncientAltarCraftEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AncientAltarCraftEvent.java index 0d8463bca..a71bb461b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AncientAltarCraftEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AncientAltarCraftEvent.java @@ -1,5 +1,8 @@ package io.github.thebusybiscuit.slimefun4.api.events; +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; + import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.Player; @@ -38,6 +41,7 @@ public class AncientAltarCraftEvent extends PlayerEvent implements Cancellable { * @param player * The {@link Player} that started the ritual. */ + @ParametersAreNonnullByDefault public AncientAltarCraftEvent(ItemStack output, Block block, Player player) { super(player); @@ -50,6 +54,7 @@ public class AncientAltarCraftEvent extends PlayerEvent implements Cancellable { * * @return the main altar's block {@link Block} */ + @Nonnull public Block getAltarBlock() { 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} */ + @Nonnull public ItemStack getItem() { return output; } @@ -87,10 +93,12 @@ public class AncientAltarCraftEvent extends PlayerEvent implements Cancellable { cancelled = cancel; } + @Nonnull public static HandlerList getHandlerList() { return handlers; } + @Nonnull @Override public HandlerList getHandlers() { return getHandlerList(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AndroidMineEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AndroidMineEvent.java index 0f28d6f07..66d3c2c15 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AndroidMineEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AndroidMineEvent.java @@ -1,5 +1,8 @@ package io.github.thebusybiscuit.slimefun4.api.events; +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; + import org.bukkit.block.Block; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; @@ -29,6 +32,7 @@ public class AndroidMineEvent extends Event implements Cancellable { * @param android * The {@link AndroidInstance} that triggered this {@link Event} */ + @ParametersAreNonnullByDefault public AndroidMineEvent(Block block, AndroidInstance android) { this.block = block; this.android = android; @@ -39,6 +43,7 @@ public class AndroidMineEvent extends Event implements Cancellable { * * @return the mined {@link Block} */ + @Nonnull public Block getBlock() { return block; } @@ -49,6 +54,7 @@ public class AndroidMineEvent extends Event implements Cancellable { * * @return the involved {@link AndroidInstance} */ + @Nonnull public AndroidInstance getAndroid() { return android; } @@ -63,10 +69,12 @@ public class AndroidMineEvent extends Event implements Cancellable { cancelled = cancel; } + @Nonnull public static HandlerList getHandlerList() { return handlers; } + @Nonnull @Override public HandlerList getHandlers() { return getHandlerList(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AutoDisenchantEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AutoDisenchantEvent.java index c3d38193b..6bba59cae 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AutoDisenchantEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AutoDisenchantEvent.java @@ -1,5 +1,7 @@ package io.github.thebusybiscuit.slimefun4.api.events; +import javax.annotation.Nonnull; + import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; @@ -21,7 +23,7 @@ public class AutoDisenchantEvent extends Event implements Cancellable { private final ItemStack item; private boolean cancelled; - public AutoDisenchantEvent(ItemStack item) { + public AutoDisenchantEvent(@Nonnull ItemStack item) { super(true); this.item = item; @@ -32,13 +34,14 @@ public class AutoDisenchantEvent extends Event implements Cancellable { * * @return The {@link ItemStack} that is being disenchanted */ + @Nonnull public ItemStack getItem() { - return this.item; + return item; } @Override public boolean isCancelled() { - return this.cancelled; + return cancelled; } @Override @@ -46,10 +49,12 @@ public class AutoDisenchantEvent extends Event implements Cancellable { this.cancelled = cancel; } + @Nonnull public static HandlerList getHandlerList() { return handlers; } + @Nonnull @Override public HandlerList getHandlers() { return getHandlerList(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/BlockPlacerPlaceEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/BlockPlacerPlaceEvent.java index b2e30f85c..1a129d96d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/BlockPlacerPlaceEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/BlockPlacerPlaceEvent.java @@ -1,5 +1,8 @@ package io.github.thebusybiscuit.slimefun4.api.events; +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; + import org.apache.commons.lang.Validate; import org.bukkit.block.Block; import org.bukkit.event.Cancellable; @@ -37,6 +40,7 @@ public class BlockPlacerPlaceEvent extends BlockEvent implements Cancellable { * @param block * The placed {@link Block} */ + @ParametersAreNonnullByDefault public BlockPlacerPlaceEvent(Block blockPlacer, ItemStack placedItem, Block block) { super(block); @@ -49,6 +53,7 @@ public class BlockPlacerPlaceEvent extends BlockEvent implements Cancellable { * * @return The {@link BlockPlacer} */ + @Nonnull public Block getBlockPlacer() { return blockPlacer; } @@ -58,6 +63,7 @@ public class BlockPlacerPlaceEvent extends BlockEvent implements Cancellable { * * @return The placed {@link ItemStack} */ + @Nonnull public ItemStack getItemStack() { return placedItem; } @@ -68,7 +74,7 @@ public class BlockPlacerPlaceEvent extends BlockEvent implements Cancellable { * @param item * 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!"); if (!locked) { @@ -101,10 +107,12 @@ public class BlockPlacerPlaceEvent extends BlockEvent implements Cancellable { locked = true; } + @Nonnull public static HandlerList getHandlerList() { return handlers; } + @Nonnull @Override public HandlerList getHandlers() { return getHandlerList(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ClimbingPickLaunchEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ClimbingPickLaunchEvent.java index 4900d4e94..e5bb91dc2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ClimbingPickLaunchEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ClimbingPickLaunchEvent.java @@ -1,5 +1,8 @@ package io.github.thebusybiscuit.slimefun4.api.events; +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; + import org.apache.commons.lang.Validate; import org.bukkit.block.Block; import org.bukkit.entity.Player; @@ -32,6 +35,7 @@ public class ClimbingPickLaunchEvent extends PlayerEvent implements Cancellable private boolean cancelled; + @ParametersAreNonnullByDefault public ClimbingPickLaunchEvent(Player player, Vector velocity, ClimbingPick pick, ItemStack itemStack, Block block) { super(player); @@ -47,6 +51,7 @@ public class ClimbingPickLaunchEvent extends PlayerEvent implements Cancellable * * @return The {@link Vector} of the applied velocity */ + @Nonnull public Vector getVelocity() { return velocity; } @@ -57,7 +62,7 @@ public class ClimbingPickLaunchEvent extends PlayerEvent implements Cancellable * @param velocity * The {@link Vector} velocity to apply */ - public void setVelocity(Vector velocity) { + public void setVelocity(@Nonnull Vector velocity) { Validate.notNull(velocity); this.velocity = velocity; } @@ -67,8 +72,9 @@ public class ClimbingPickLaunchEvent extends PlayerEvent implements Cancellable * * @return The {@link ClimbingPick} that was used */ + @Nonnull 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 */ + @Nonnull 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 */ + @Nonnull public Block getBlock() { - return this.block; + return block; } @Override public boolean isCancelled() { - return this.cancelled; + return cancelled; } @Override @@ -99,10 +107,12 @@ public class ClimbingPickLaunchEvent extends PlayerEvent implements Cancellable this.cancelled = cancel; } + @Nonnull public static HandlerList getHandlerList() { return handlers; } + @Nonnull @Override public HandlerList getHandlers() { return getHandlerList(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/GEOResourceGenerationEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/GEOResourceGenerationEvent.java index acfdf7936..9bcae84dc 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/GEOResourceGenerationEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/GEOResourceGenerationEvent.java @@ -1,5 +1,8 @@ package io.github.thebusybiscuit.slimefun4.api.events; +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; + import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.World; @@ -38,6 +41,7 @@ public class GEOResourceGenerationEvent extends Event { private int value; + @ParametersAreNonnullByDefault public GEOResourceGenerationEvent(World world, Biome biome, int x, int z, GEOResource resource, int value) { this.world = world; this.biome = biome; @@ -76,6 +80,7 @@ public class GEOResourceGenerationEvent extends Event { * * @return The affected {@link World} */ + @Nonnull public World getWorld() { return world; } @@ -85,6 +90,7 @@ public class GEOResourceGenerationEvent extends Event { * * @return The generated {@link GEOResource} */ + @Nonnull public GEOResource getResource() { return resource; } @@ -115,6 +121,7 @@ public class GEOResourceGenerationEvent extends Event { * * @return The {@link Environment} of this generation */ + @Nonnull public Environment getEnvironment() { return world.getEnvironment(); } @@ -125,6 +132,7 @@ public class GEOResourceGenerationEvent extends Event { * * @return The {@link Biome} of this generation */ + @Nonnull public Biome getBiome() { return biome; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/MultiBlockInteractEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/MultiBlockInteractEvent.java index fec7b8097..067aa5b18 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/MultiBlockInteractEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/MultiBlockInteractEvent.java @@ -1,5 +1,8 @@ package io.github.thebusybiscuit.slimefun4.api.events; +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; + import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; @@ -25,6 +28,7 @@ public class MultiBlockInteractEvent extends PlayerEvent implements Cancellable private final BlockFace clickedFace; private boolean cancelled; + @ParametersAreNonnullByDefault public MultiBlockInteractEvent(Player p, MultiBlock mb, Block clicked, BlockFace face) { super(p); this.multiBlock = mb; @@ -37,6 +41,7 @@ public class MultiBlockInteractEvent extends PlayerEvent implements Cancellable * * @return The {@link MultiBlock} of this {@link MultiBlockInteractEvent} */ + @Nonnull public MultiBlock getMultiBlock() { return multiBlock; } @@ -46,6 +51,7 @@ public class MultiBlockInteractEvent extends PlayerEvent implements Cancellable * * @return The {@link Block} that was clicked */ + @Nonnull public Block getClickedBlock() { return clickedBlock; } @@ -55,6 +61,7 @@ public class MultiBlockInteractEvent extends PlayerEvent implements Cancellable * * @return The {@link BlockFace} that was clicked */ + @Nonnull public BlockFace getClickedFace() { return clickedFace; } @@ -69,10 +76,12 @@ public class MultiBlockInteractEvent extends PlayerEvent implements Cancellable this.cancelled = cancel; } + @Nonnull public static HandlerList getHandlerList() { return handlers; } + @Nonnull @Override public HandlerList getHandlers() { return getHandlerList(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerLanguageChangeEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerLanguageChangeEvent.java index ca5b9c283..5f1397283 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerLanguageChangeEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerLanguageChangeEvent.java @@ -1,5 +1,7 @@ package io.github.thebusybiscuit.slimefun4.api.events; +import javax.annotation.Nonnull; + import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; @@ -24,7 +26,7 @@ public class PlayerLanguageChangeEvent extends Event { private final Language from; 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; this.from = from; this.to = to; @@ -36,6 +38,7 @@ public class PlayerLanguageChangeEvent extends Event { * * @return The {@link Player} who switched his {@link Language} */ + @Nonnull public Player getPlayer() { return player; } @@ -45,6 +48,7 @@ public class PlayerLanguageChangeEvent extends Event { * * @return The previous {@link Language} of our {@link Player} */ + @Nonnull public Language getPreviousLanguage() { return from; } @@ -54,6 +58,7 @@ public class PlayerLanguageChangeEvent extends Event { * * @return The new {@link Language} */ + @Nonnull public Language getNewLanguage() { return to; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerRightClickEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerRightClickEvent.java index e7580179e..d4375feae 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerRightClickEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerRightClickEvent.java @@ -2,6 +2,9 @@ package io.github.thebusybiscuit.slimefun4.api.events; import java.util.Optional; +import javax.annotation.Nonnull; + +import org.apache.commons.lang.Validate; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -35,7 +38,7 @@ public class PlayerRightClickEvent extends Event { private Result itemResult = Result.DEFAULT; private Result blockResult = Result.DEFAULT; - public PlayerRightClickEvent(PlayerInteractEvent e) { + public PlayerRightClickEvent(@Nonnull PlayerInteractEvent e) { event = e; player = e.getPlayer(); clickedBlock = Optional.ofNullable(e.getClickedBlock()); @@ -50,10 +53,12 @@ public class PlayerRightClickEvent extends Event { } } + @Nonnull public PlayerInteractEvent getInteractEvent() { return event; } + @Nonnull public Player getPlayer() { return player; } @@ -65,6 +70,7 @@ public class PlayerRightClickEvent extends Event { * * @return The {@link ItemStack} that the {@link Player} right clicked with */ + @Nonnull public ItemStack getItem() { return itemStack.orElse(new ItemStack(Material.AIR)); } @@ -75,20 +81,23 @@ public class PlayerRightClickEvent extends Event { * * @return The hand used in this {@link Event} */ + @Nonnull public EquipmentSlot getHand() { return hand; } + @Nonnull public Optional getClickedBlock() { return clickedBlock; } + @Nonnull public BlockFace getClickedFace() { return face; } + @Nonnull public Optional getSlimefunItem() { - if (!slimefunItem.isComputed()) { if (itemStack.isPresent()) { slimefunItem.compute(SlimefunItem.getByItem(itemStack.get())); @@ -101,8 +110,8 @@ public class PlayerRightClickEvent extends Event { return slimefunItem.getAsOptional(); } + @Nonnull public Optional getSlimefunBlock() { - if (!slimefunBlock.isComputed()) { if (clickedBlock.isPresent()) { slimefunBlock.compute(BlockStorage.check(clickedBlock.get())); @@ -120,26 +129,32 @@ public class PlayerRightClickEvent extends Event { blockResult = Result.DENY; } + @Nonnull public Result useItem() { return itemResult; } + @Nonnull public Result useBlock() { return blockResult; } - public void setUseItem(Result result) { + public void setUseItem(@Nonnull Result result) { + Validate.notNull(result, "Result cannot be null"); itemResult = result; } - public void setUseBlock(Result result) { + public void setUseBlock(@Nonnull Result result) { + Validate.notNull(result, "Result cannot be null"); blockResult = result; } + @Nonnull public static HandlerList getHandlerList() { return handlers; } + @Nonnull @Override public HandlerList getHandlers() { return getHandlerList(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ReactorExplodeEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ReactorExplodeEvent.java index 4a2af108a..75ed924ce 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ReactorExplodeEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ReactorExplodeEvent.java @@ -1,5 +1,7 @@ package io.github.thebusybiscuit.slimefun4.api.events; +import javax.annotation.Nonnull; + import org.apache.commons.lang.Validate; import org.bukkit.Location; import org.bukkit.event.Event; @@ -21,7 +23,7 @@ public class ReactorExplodeEvent extends Event { private final Location location; 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(reactor, "A Reactor cannot be null"); @@ -34,6 +36,7 @@ public class ReactorExplodeEvent extends Event { * * @return The {@link Location} of this explosion */ + @Nonnull public Location getLocation() { return location; } @@ -43,14 +46,17 @@ public class ReactorExplodeEvent extends Event { * * @return The {@link SlimefunItem} instance */ + @Nonnull public Reactor getReactor() { return reactor; } + @Nonnull public static HandlerList getHandlerList() { return handlers; } + @Nonnull @Override public HandlerList getHandlers() { return getHandlerList(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ResearchUnlockEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ResearchUnlockEvent.java index 53a3e74e3..5840ab50b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ResearchUnlockEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ResearchUnlockEvent.java @@ -1,5 +1,8 @@ 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.event.Cancellable; import org.bukkit.event.Event; @@ -23,15 +26,19 @@ public class ResearchUnlockEvent extends Event implements Cancellable { private final Research research; 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.research = research; } + @Nonnull public Player getPlayer() { return player; } + @Nonnull public Research getResearch() { return research; } @@ -46,10 +53,12 @@ public class ResearchUnlockEvent extends Event implements Cancellable { this.cancelled = cancel; } + @Nonnull public static HandlerList getHandlerList() { return handlers; } + @Nonnull @Override public HandlerList getHandlers() { return getHandlerList(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/WaypointCreateEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/WaypointCreateEvent.java index 8f2866331..4253f7983 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/WaypointCreateEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/WaypointCreateEvent.java @@ -1,5 +1,7 @@ package io.github.thebusybiscuit.slimefun4.api.events; +import javax.annotation.Nonnull; + import org.apache.commons.lang.Validate; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -32,7 +34,7 @@ public class WaypointCreateEvent extends PlayerEvent implements Cancellable { private final boolean deathpoint; private boolean cancelled; - public WaypointCreateEvent(Player player, String name, Location location) { + public WaypointCreateEvent(@Nonnull Player player, @Nonnull String name, @Nonnull Location location) { super(player); 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 */ + @Nonnull public Location getLocation() { return location; } @@ -59,7 +62,7 @@ public class WaypointCreateEvent extends PlayerEvent implements Cancellable { * @param loc * 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!"); this.location = loc; } @@ -69,6 +72,7 @@ public class WaypointCreateEvent extends PlayerEvent implements Cancellable { * * @return The name of this waypoint */ + @Nonnull public String getName() { return name; } @@ -79,7 +83,7 @@ public class WaypointCreateEvent extends PlayerEvent implements Cancellable { * @param name * 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!"); this.name = name; } @@ -104,10 +108,12 @@ public class WaypointCreateEvent extends PlayerEvent implements Cancellable { this.cancelled = cancel; } + @Nonnull public static HandlerList getHandlerList() { return handlers; } + @Nonnull @Override public HandlerList getHandlers() { return getHandlerList(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/RadioactiveItem.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/RadioactiveItem.java index 158b3101d..cd1fbe091 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/RadioactiveItem.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/RadioactiveItem.java @@ -1,6 +1,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.items; import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.inventory.ItemStack; @@ -45,6 +46,7 @@ public class RadioactiveItem extends SlimefunItem implements Radioactive, NotPla * @param recipe * The recipe of how to craft this {@link SlimefunItem} */ + @ParametersAreNonnullByDefault public RadioactiveItem(Category category, Radioactivity radioactivity, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { this(category, radioactivity, item, recipeType, recipe, null); } @@ -65,6 +67,7 @@ public class RadioactiveItem extends SlimefunItem implements Radioactive, NotPla * @param recipeOutput * The recipe output */ + @ParametersAreNonnullByDefault public RadioactiveItem(Category category, Radioactivity radioactivity, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) { super(category, item, recipeType, recipe, recipeOutput); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/SimpleSlimefunItem.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/SimpleSlimefunItem.java index cdafede2d..35fbcfe83 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/SimpleSlimefunItem.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/SimpleSlimefunItem.java @@ -1,6 +1,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.items; import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.inventory.ItemStack; @@ -29,10 +30,12 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; */ public abstract class SimpleSlimefunItem extends SlimefunItem { + @ParametersAreNonnullByDefault public SimpleSlimefunItem(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); } + @ParametersAreNonnullByDefault public SimpleSlimefunItem(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) { super(category, item, recipeType, recipe, recipeOutput); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/VanillaItem.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/VanillaItem.java index 72ff25c18..166a9b371 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/VanillaItem.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/VanillaItem.java @@ -1,5 +1,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.items; +import javax.annotation.ParametersAreNonnullByDefault; + import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.slimefun4.api.items.ItemState; @@ -38,6 +40,7 @@ public class VanillaItem extends SlimefunItem { * @param recipe * the recipe to obtain this {@link VanillaItem} */ + @ParametersAreNonnullByDefault public VanillaItem(Category category, ItemStack item, String id, RecipeType recipeType, ItemStack[] recipe) { super(category, item, id, recipeType, recipe); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/AbstractEnergyProvider.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/AbstractEnergyProvider.java index 530a565f3..cc16f0db6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/AbstractEnergyProvider.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/AbstractEnergyProvider.java @@ -6,6 +6,7 @@ import java.util.List; import java.util.Set; import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; @@ -40,6 +41,7 @@ public abstract class AbstractEnergyProvider extends SlimefunItem implements Inv protected final Set fuelTypes = new HashSet<>(); + @ParametersAreNonnullByDefault protected AbstractEnergyProvider(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); } @@ -81,6 +83,7 @@ public abstract class AbstractEnergyProvider extends SlimefunItem implements Inv protected abstract void registerDefaultFuelTypes(); @Override + @Nonnull public EnergyNetComponentType getEnergyComponentType() { return EnergyNetComponentType.GENERATOR; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/Capacitor.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/Capacitor.java index 5baf17b85..96049b9c0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/Capacitor.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/Capacitor.java @@ -1,5 +1,8 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric; +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; + import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent; @@ -26,6 +29,7 @@ public class Capacitor extends SlimefunItem implements EnergyNetComponent { private final int capacity; + @ParametersAreNonnullByDefault public Capacitor(Category category, int capacity, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); @@ -33,6 +37,7 @@ public class Capacitor extends SlimefunItem implements EnergyNetComponent { } @Override + @Nonnull public EnergyNetComponentType getEnergyComponentType() { return EnergyNetComponentType.CAPACITOR; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/EnergyRegulator.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/EnergyRegulator.java index d0415f6ae..abd0e4876 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/EnergyRegulator.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/EnergyRegulator.java @@ -1,6 +1,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric; import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.block.Block; import org.bukkit.event.block.BlockPlaceEvent; @@ -29,6 +30,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; */ public class EnergyRegulator extends SlimefunItem { + @ParametersAreNonnullByDefault public EnergyRegulator(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/Multimeter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/Multimeter.java index eed867d0c..77c91ce0d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/Multimeter.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/Multimeter.java @@ -2,6 +2,8 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets import java.util.Optional; +import javax.annotation.ParametersAreNonnullByDefault; + import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -28,6 +30,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; */ public class Multimeter extends SimpleSlimefunItem { + @ParametersAreNonnullByDefault public Multimeter(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/SolarHelmet.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/SolarHelmet.java index fb19075ca..a236e8512 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/SolarHelmet.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/SolarHelmet.java @@ -1,5 +1,9 @@ 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.inventory.ItemStack; @@ -27,6 +31,7 @@ public class SolarHelmet extends SlimefunItem { private final ItemSetting charge; + @ParametersAreNonnullByDefault public SolarHelmet(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, double defaultChargingLevel) { super(category, item, recipeType, recipe); @@ -45,7 +50,7 @@ public class SolarHelmet extends SlimefunItem { * @param p * 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().getChestplate()); recharge(p.getInventory().getLeggings()); @@ -54,7 +59,7 @@ public class SolarHelmet extends SlimefunItem { recharge(p.getInventory().getItemInOffHand()); } - private void recharge(ItemStack item) { + private void recharge(@Nullable ItemStack item) { SlimefunItem sfItem = SlimefunItem.getByItem(item); if (sfItem instanceof Rechargeable) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/NetherStarReactor.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/NetherStarReactor.java index ba589eb84..c8324f23f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/NetherStarReactor.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/NetherStarReactor.java @@ -1,5 +1,8 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors; +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; + import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.ArmorStand; @@ -28,6 +31,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; */ public abstract class NetherStarReactor extends Reactor { + @ParametersAreNonnullByDefault public NetherStarReactor(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); } @@ -38,7 +42,7 @@ public abstract class NetherStarReactor extends Reactor { } @Override - public void extraTick(Location l) { + public void extraTick(@Nonnull Location l) { Slimefun.runSync(() -> { ArmorStand hologram = ReactorHologram.getArmorStand(l, true); for (Entity entity : hologram.getNearbyEntities(5, 5, 5)) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/NuclearReactor.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/NuclearReactor.java index 5797c94f5..42a417605 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/NuclearReactor.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/NuclearReactor.java @@ -1,5 +1,8 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors; +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; + import org.bukkit.Location; import org.bukkit.inventory.ItemStack; @@ -22,6 +25,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; */ public abstract class NuclearReactor extends Reactor { + @ParametersAreNonnullByDefault public NuclearReactor(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); } @@ -49,7 +53,7 @@ public abstract class NuclearReactor extends Reactor { } @Override - public void extraTick(Location l) { + public void extraTick(@Nonnull Location l) { // This machine does not need to perform anything while ticking // The Nether Star Reactor uses this method to generate the Wither Effect } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/Reactor.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/Reactor.java index fa2f253b9..8a5ba74bb 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/Reactor.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/Reactor.java @@ -76,6 +76,7 @@ public abstract class Reactor extends AbstractEnergyProvider { private final Set explosionsQueue = new HashSet<>(); + @ParametersAreNonnullByDefault public Reactor(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe);