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

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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;
}

View File

@ -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();

View File

@ -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;
}

View File

@ -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<Block> getClickedBlock() {
return clickedBlock;
}
@Nonnull
public BlockFace getClickedFace() {
return face;
}
@Nonnull
public Optional<SlimefunItem> 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<SlimefunItem> 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();

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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);

View File

@ -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<T extends ItemHandler> 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);
}

View File

@ -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);

View File

@ -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<MachineFuel> 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;
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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<ItemUseHandler> {
@ParametersAreNonnullByDefault
public Multimeter(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe);
}

View File

@ -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<Double> 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) {

View File

@ -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)) {

View File

@ -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
}

View File

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