diff --git a/src/main/java/city/norain/slimefun4/utils/LangUtil.java b/src/main/java/city/norain/slimefun4/utils/LangUtil.java
deleted file mode 100644
index 2a1bc3e323..0000000000
--- a/src/main/java/city/norain/slimefun4/utils/LangUtil.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package city.norain.slimefun4.utils;
-
-import io.papermc.lib.PaperLib;
-import javax.annotation.Nonnull;
-import org.bukkit.plugin.Plugin;
-
-/**
- * LangUtil
- *
- * 将部分无法直接汉化的方法提取出来
- *
- * @author StarWishsama
- */
-public class LangUtil {
- /**
- * 推荐你使用 Paper 服务端
- *
- * @param plugin
- */
- public static void suggestPaper(@Nonnull Plugin plugin) {
- if (PaperLib.isPaper()) {
- return;
- }
- final var benefitsProperty = "paperlib.shown-benefits";
- final var pluginName = plugin.getDescription().getName();
- final var logger = plugin.getLogger();
- logger.warning("====================================================");
- logger.warning(" " + pluginName + " 在 Paper 上会工作地更好 ");
- logger.warning(" 推荐你使用 Paper 运行" + pluginName + " ");
- if (System.getProperty(benefitsProperty) == null) {
- System.setProperty(benefitsProperty, "1");
- logger.warning(" ");
- logger.warning(" Paper 能提供显著性能优化, 且更安全,");
- logger.warning(" 以及 Bug 修复和部分新特性");
- logger.warning(" 提升服主的服务器体验.");
- logger.warning(" ");
- logger.warning(" Paper 内置了 Timings v2. 相比 v1 版本");
- logger.warning(" 能够更显著地诊断服务器卡顿原因.");
- logger.warning(" ");
- logger.warning(" 你原有的插件在更换后大部分都能正常使用.");
- logger.warning(" 如果遇到问题, Paper 社区很乐意帮助你解决你的问题.");
- logger.warning(" ");
- logger.warning(" 加入 Paper 社区 @ https://papermc.io");
- }
- logger.warning("====================================================");
- }
-}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java
index e6f7c1c64d..19de1f9ed7 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java
@@ -2,7 +2,6 @@
import city.norain.slimefun4.SlimefunExtended;
import city.norain.slimefun4.timings.SQLProfiler;
-import city.norain.slimefun4.utils.LangUtil;
import com.xzavier0722.mc.plugin.slimefun4.chat.PlayerChatCatcher;
import com.xzavier0722.mc.plugin.slimefun4.storage.migrator.BlockStorageMigrator;
import com.xzavier0722.mc.plugin.slimefun4.storage.migrator.PlayerProfileMigrator;
@@ -237,8 +236,6 @@ private void onPluginStart() {
// Check if Paper (<3) is installed
if (PaperLib.isPaper()) {
logger.log(Level.INFO, "检测到你正在使用 Paper 服务端! 性能优化已应用.");
- } else {
- LangUtil.suggestPaper(this);
}
// Check if CS-CoreLib is installed (it is no longer needed)
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/CheatSheetSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/CheatSheetSlimefunGuide.java
index 446fdcae1e..a3a0dbb359 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/CheatSheetSlimefunGuide.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/CheatSheetSlimefunGuide.java
@@ -43,6 +43,7 @@ public CheatSheetSlimefunGuide() {
*
* @return a {@link List} of visible {@link ItemGroup} instances
*/
+ @Nonnull
@Override
protected List getVisibleItemGroups(@Nonnull Player p, @Nonnull PlayerProfile profile) {
List groups = new LinkedList<>();
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java
index b92bab37ac..2e1f7e8d07 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java
@@ -165,7 +165,7 @@ public void openMainMenu(PlayerProfile profile, int page) {
menu.addMenuClickHandler(46, (pl, slot, item, action) -> {
int next = page - 1;
- if (next != page && next > 0) {
+ if (next > 0) {
openMainMenu(profile, next);
}
@@ -176,7 +176,7 @@ public void openMainMenu(PlayerProfile profile, int page) {
menu.addMenuClickHandler(52, (pl, slot, item, action) -> {
int next = page + 1;
- if (next != page && next <= pages) {
+ if (next <= pages) {
openMainMenu(profile, next);
}
@@ -251,7 +251,7 @@ public void openItemGroup(PlayerProfile profile, ItemGroup itemGroup, int page)
menu.addMenuClickHandler(46, (pl, slot, item, action) -> {
int next = page - 1;
- if (next != page && next > 0) {
+ if (next > 0) {
openItemGroup(profile, itemGroup, next);
}
@@ -262,7 +262,7 @@ public void openItemGroup(PlayerProfile profile, ItemGroup itemGroup, int page)
menu.addMenuClickHandler(52, (pl, slot, item, action) -> {
int next = page + 1;
- if (next != page && next <= pages) {
+ if (next <= pages) {
openItemGroup(profile, itemGroup, next);
}
@@ -439,7 +439,7 @@ private boolean isItemGroupAccessible(Player p, SlimefunItem slimefunItem) {
@ParametersAreNonnullByDefault
private boolean isSearchFilterApplicable(SlimefunItem slimefunItem, String searchTerm) {
String itemName = ChatColor.stripColor(slimefunItem.getItemName()).toLowerCase(Locale.ROOT);
- return !itemName.isEmpty() && (itemName.equals(searchTerm) || itemName.contains(searchTerm));
+ return !itemName.isEmpty() && itemName.contains(searchTerm);
}
@Override
@@ -447,7 +447,7 @@ private boolean isSearchFilterApplicable(SlimefunItem slimefunItem, String searc
public void displayItem(PlayerProfile profile, ItemStack item, int index, boolean addToHistory) {
Player p = profile.getPlayer();
- if (p == null || item == null || item.getType() == Material.AIR) {
+ if (p == null || item.getType() == Material.AIR) {
return;
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/handlers/SimpleBlockBreakHandler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/handlers/SimpleBlockBreakHandler.java
index 0070bda7fd..48ac29125e 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/handlers/SimpleBlockBreakHandler.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/handlers/SimpleBlockBreakHandler.java
@@ -39,7 +39,7 @@ protected SimpleBlockBreakHandler() {
public abstract void onBlockBreak(@Nonnull Block b);
@Override
- public void onPlayerBreak(BlockBreakEvent e, ItemStack item, List drops) {
+ public void onPlayerBreak(BlockBreakEvent e, @Nonnull ItemStack item, @Nonnull List drops) {
onBlockBreak(e.getBlock());
}
@@ -49,7 +49,7 @@ public void onAndroidBreak(AndroidMineEvent e) {
}
@Override
- public void onExplode(Block b, List drops) {
+ public void onExplode(@Nonnull Block b, @Nonnull List drops) {
onBlockBreak(b);
}
}
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 86f380a5e3..588658b3fb 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
@@ -18,7 +18,7 @@
* A quick and easy implementation of {@link SlimefunItem} that also implements the
* interface {@link Radioactive}.
* This implementation is {@link NotPlaceable}!
- *
+ *
* Simply specify a level of {@link Radioactivity} in the constructor.
*
* @author TheBusyBiscuit
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 899dca241c..eea7c7c588 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
@@ -14,7 +14,7 @@
/**
* This is basically a quickstart class for your very first {@link SlimefunItem}.
* This class easily allows you to add one {@link ItemHandler} to your {@link SlimefunItem}.
- *
+ *
* You could use an {@link ItemUseHandler} for example to give your {@link SlimefunItem}
* very basic right-click functionalities.
*
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 3d652598cd..05ffb8c9ea 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
@@ -14,7 +14,7 @@
* When a {@link VanillaItem} gets disabled, its {@link ItemState} goes on {@code State.VANILLA} which
* automatically
* replace it in the recipes by its vanilla equivalent.
- *
+ *
* A {@link VanillaItem} is also automatically useable in workbenches.
*
* @author TheBusyBiscuit
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/AltarRecipe.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/AltarRecipe.java
index 2a1a7ce8b2..c8beaa38bc 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/AltarRecipe.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/AltarRecipe.java
@@ -2,8 +2,11 @@
import java.util.ArrayList;
import java.util.List;
+
+import lombok.Getter;
import org.bukkit.inventory.ItemStack;
+@Getter
public class AltarRecipe {
private final ItemStack catalyst;
@@ -27,18 +30,6 @@ public AltarRecipe(List input, ItemStack output) {
this.output = output;
}
- public ItemStack getCatalyst() {
- return this.catalyst;
- }
-
- public ItemStack getOutput() {
- return this.output;
- }
-
- public List getInput() {
- return this.input;
- }
-
@Override
public boolean equals(Object obj) {
if (obj instanceof AltarRecipe ar) {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidInstance.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidInstance.java
index 95bd7d1044..9865e9d2e7 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidInstance.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidInstance.java
@@ -1,9 +1,11 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.androids;
+import lombok.Getter;
import org.bukkit.block.Block;
public class AndroidInstance {
+ @Getter
private final ProgrammableAndroid android;
private final Block b;
@@ -12,10 +14,6 @@ public AndroidInstance(ProgrammableAndroid android, Block b) {
this.b = b;
}
- public ProgrammableAndroid getAndroid() {
- return android;
- }
-
public Block getBlock() {
return b;
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidInterface.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidInterface.java
index e2f3ca4ec6..cc7de6945d 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidInterface.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidInterface.java
@@ -6,6 +6,8 @@
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockDispenseHandler;
import io.github.thebusybiscuit.slimefun4.implementation.handlers.VanillaInventoryDropHandler;
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
+
+import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.block.Dispenser;
import org.bukkit.inventory.ItemStack;
@@ -28,6 +30,7 @@ public AndroidInterface(ItemGroup itemGroup, SlimefunItemStack item, RecipeType
addItemHandler(new VanillaInventoryDropHandler<>(Dispenser.class));
}
+ @Nonnull
@Override
public BlockDispenseHandler getItemHandler() {
return (e, d, block, machine) -> e.setCancelled(true);
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidType.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidType.java
index b32366e2e0..189e40456d 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidType.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidType.java
@@ -26,10 +26,6 @@ public enum AndroidType {
*/
FARMER,
- /**
- * The {@link AdvancedFarmerAndroid} is an extension of the {@link FarmerAndroid},
- * it can also harvest plants from ExoticGarden.
- */
ADVANCED_FARMER,
/**
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/WoodcutterAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/WoodcutterAndroid.java
index aa8600d7fd..5426c1b003 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/WoodcutterAndroid.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/WoodcutterAndroid.java
@@ -155,7 +155,7 @@ private void replant(@Nonnull Block block) {
}
}
- if (saplingType != null && soilRequirement != null) {
+ if (saplingType != null) {
if (soilRequirement.test(block.getRelative(BlockFace.DOWN).getType())) {
// Replant the block
block.setType(saplingType);
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/menu/AndroidShareMenu.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/menu/AndroidShareMenu.java
index cf7e67925d..a17030d0da 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/menu/AndroidShareMenu.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/menu/AndroidShareMenu.java
@@ -209,7 +209,7 @@ private static void removePlayer(Player owner, OfflinePlayer p, Block android, L
Optional trustUsers = getSharedUserData(b.getState());
// Checks for old Android
- if (!trustUsers.isPresent()) {
+ if (trustUsers.isEmpty()) {
List emptyUsers = new ArrayList<>();
setSharedUserData(b.getState(), String.valueOf(emptyUsers));
return emptyUsers;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/AbstractAutoCrafter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/AbstractAutoCrafter.java
index 2c38c9e156..6268030e37 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/AbstractAutoCrafter.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/AbstractAutoCrafter.java
@@ -71,8 +71,6 @@
*/
public abstract class AbstractAutoCrafter extends SlimefunItem implements EnergyNetComponent {
- private final String WIKI_PAGE = "Auto-Crafter";
-
private final Map recipeCache;
/**
@@ -142,6 +140,7 @@ public void onPlayerBreak(BlockBreakEvent e, ItemStack item, List dro
@Override
public void postRegister() {
+ String WIKI_PAGE = "Auto-Crafter";
addWikiPage(WIKI_PAGE);
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/AbstractRecipe.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/AbstractRecipe.java
index 6af98b76ae..a29fc80d44 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/AbstractRecipe.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/AbstractRecipe.java
@@ -9,6 +9,8 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
+
+import lombok.Getter;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
import org.apache.commons.lang.Validate;
import org.bukkit.inventory.ItemStack;
@@ -43,7 +45,14 @@ public abstract class AbstractRecipe {
/**
* Whether this recipe is enabled.
+ * -- GETTER --
+ * This returns whether or not this recipe has been enabled.
+ * A disabled recipe will not be crafted.
+ *
+ * @return Whether this recipe is enabled
+
*/
+ @Getter
private boolean enabled = true;
/**
@@ -85,16 +94,6 @@ public ItemStack getResult() {
return result;
}
- /**
- * This returns whether or not this recipe has been enabled.
- * A disabled recipe will not be crafted.
- *
- * @return Whether this recipe is enabled
- */
- public boolean isEnabled() {
- return enabled;
- }
-
/**
* This method enables or disables this recipe.
* A disabled recipe will not be crafted.
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/SlimefunAutoCrafter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/SlimefunAutoCrafter.java
index 3a9210f64a..c1587cb33b 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/SlimefunAutoCrafter.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/SlimefunAutoCrafter.java
@@ -116,7 +116,6 @@ protected void updateRecipe(@Nonnull Block b, @Nonnull Player p) {
menu.open(p);
SoundEffect.AUTO_CRAFTER_UPDATE_RECIPE.playAt(b);
- ;
if (!task.isEmpty()) {
task.start(menu.toInventory());
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/VanillaRecipe.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/VanillaRecipe.java
index 7a55904faa..1a4cf6c5ce 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/VanillaRecipe.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/VanillaRecipe.java
@@ -8,6 +8,8 @@
import java.util.List;
import java.util.function.Predicate;
import javax.annotation.Nonnull;
+
+import lombok.Getter;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
import org.apache.commons.lang.Validate;
import org.bukkit.Keyed;
@@ -30,6 +32,7 @@
class VanillaRecipe extends AbstractRecipe {
private final int[] slots = {11, 12, 13, 20, 21, 22, 29, 30, 31};
+ @Getter
private final Recipe recipe;
VanillaRecipe(@Nonnull ShapelessRecipe recipe) {
@@ -44,10 +47,6 @@ class VanillaRecipe extends AbstractRecipe {
this.recipe = recipe;
}
- public Recipe getRecipe() {
- return recipe;
- }
-
@Nonnull
private static Collection> getChoices(@Nonnull ShapedRecipe recipe) {
List> choices = new ArrayList<>();
@@ -65,11 +64,6 @@ private static Collection> getChoices(@Nonnull ShapedRecipe
return choices;
}
- @Nonnull
- private static RecipeChoice[] getShape(@Nonnull Recipe recipe) {
- return Slimefun.getMinecraftRecipeService().getRecipeShape(recipe);
- }
-
@Override
public void show(@Nonnull ChestMenu menu, @Nonnull AsyncRecipeChoiceTask task) {
Validate.notNull(menu, "The ChestMenu cannot be null!");
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/SlimefunBackpack.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/SlimefunBackpack.java
index 0f796ce875..bd932f75fb 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/SlimefunBackpack.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/SlimefunBackpack.java
@@ -15,6 +15,8 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
+
+import lombok.Getter;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
@@ -29,7 +31,14 @@
* @see PlayerBackpack
*
*/
+@Getter
public class SlimefunBackpack extends SimpleSlimefunItem implements DistinctiveItem {
+ /**
+ * -- GETTER --
+ * This returns the size of this
+ * .
+ *
+ */
private final int size;
@ParametersAreNonnullByDefault
@@ -40,15 +49,6 @@ public SlimefunBackpack(
this.size = size;
}
- /**
- * This returns the size of this {@link SlimefunBackpack}.
- *
- * @return The size of this backpack
- */
- public int getSize() {
- return size;
- }
-
/**
* This method returns whether a given {@link ItemStack} is allowed to be stored
* in this {@link SlimefunBackpack}.
@@ -70,6 +70,7 @@ public boolean isItemAllowed(@Nonnull ItemStack item, @Nullable SlimefunItem ite
return !(itemAsSlimefunItem instanceof SlimefunBackpack);
}
+ @Nonnull
@Override
public ItemUseHandler getItemHandler() {
return e -> {
@@ -82,9 +83,7 @@ public ItemUseHandler getItemHandler() {
BackpackListener listener = Slimefun.getBackpackListener();
- if (listener != null) {
- listener.openBackpack(e.getPlayer(), e.getItem(), this);
- }
+ listener.openBackpack(e.getPlayer(), e.getItem(), this);
};
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Composter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Composter.java
index 60c9c193ba..f1a5d6fd09 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Composter.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Composter.java
@@ -67,6 +67,7 @@ private List getMachineRecipes() {
return items;
}
+ @Nonnull
@Override
public BlockUseHandler getItemHandler() {
return e -> {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Crucible.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Crucible.java
index bad87638fa..2c62dbd5ec 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Crucible.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Crucible.java
@@ -106,6 +106,7 @@ private List getMachineRecipes() {
return items;
}
+ @Nonnull
@Override
public BlockUseHandler getItemHandler() {
return e -> {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/EnhancedFurnace.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/EnhancedFurnace.java
index 0faf95fda3..1e5c29f0b6 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/EnhancedFurnace.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/EnhancedFurnace.java
@@ -70,6 +70,7 @@ public int getRandomOutputAmount() {
return 1 + bonus;
}
+ @Nonnull
@Override
public BlockTicker getItemHandler() {
return new BlockTicker() {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/RainbowBlock.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/RainbowBlock.java
index 24a42412ed..b809bcbd75 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/RainbowBlock.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/RainbowBlock.java
@@ -5,6 +5,8 @@
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.core.handlers.RainbowTickHandler;
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
+
+import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
@@ -32,6 +34,7 @@ public RainbowBlock(
this.ticker = ticker;
}
+ @Nonnull
@Override
public RainbowTickHandler getItemHandler() {
return ticker;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/RepairedSpawner.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/RepairedSpawner.java
index 63c2e19eab..88a398f15b 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/RepairedSpawner.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/RepairedSpawner.java
@@ -67,9 +67,9 @@ public void onBlockPlacerPlace(BlockPlacerPlaceEvent e) {
@ParametersAreNonnullByDefault
private void onPlace(ItemStack item, BlockEvent e) {
- /**
- * This may no longer be needed at some point but for legacy items
- * we still need to set the spawned EntityType manually
+ /*
+ This may no longer be needed at some point but for legacy items
+ we still need to set the spawned EntityType manually
*/
if (e.getBlock().getType() == Material.SPAWNER) {
getEntityType(item).ifPresent(entity -> {
@@ -85,9 +85,9 @@ private void onPlace(ItemStack item, BlockEvent e) {
@Nonnull
@Override
public Collection getDrops() {
- /**
- * There should be no drops by default since drops are handled
- * by the Pickaxe of Containment exclusively.
+ /*
+ There should be no drops by default since drops are handled
+ by the Pickaxe of Containment exclusively.
*/
return new ArrayList<>();
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/UnplaceableBlock.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/UnplaceableBlock.java
index 5957402a7e..946ce2469f 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/UnplaceableBlock.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/UnplaceableBlock.java
@@ -8,6 +8,8 @@
import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable;
import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
+
+import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.inventory.ItemStack;
@@ -39,6 +41,7 @@ public UnplaceableBlock(
super(itemGroup, item, recipeType, recipe, recipeOutput);
}
+ @Nonnull
@Override
public ItemUseHandler getItemHandler() {
return PlayerRightClickEvent::cancel;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractCargoNode.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractCargoNode.java
index 658463d30f..5ce585caca 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractCargoNode.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractCargoNode.java
@@ -74,6 +74,7 @@ public int[] getSlotsAccessedByItemTransport(ItemTransportFlow flow) {
};
}
+ @Nonnull
@Override
public BlockPlaceHandler getItemHandler() {
return new BlockPlaceHandler(false) {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoConnectorNode.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoConnectorNode.java
index 821214896c..750ae537fb 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoConnectorNode.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoConnectorNode.java
@@ -39,7 +39,7 @@ public CargoConnectorNode(
@Override
public @Nonnull BlockUseHandler getItemHandler() {
return e -> {
- if (!e.getClickedBlock().isPresent()) {
+ if (e.getClickedBlock().isEmpty()) {
return;
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoManager.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoManager.java
index 967f2e4a27..e1e798d0bc 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoManager.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoManager.java
@@ -2,7 +2,6 @@
import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData;
import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils;
-import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent;
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
@@ -13,15 +12,16 @@
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler;
import io.github.thebusybiscuit.slimefun4.core.networks.cargo.CargoNet;
import io.github.thebusybiscuit.slimefun4.implementation.handlers.SimpleBlockBreakHandler;
-import java.util.Optional;
-import javax.annotation.Nonnull;
-import javax.annotation.ParametersAreNonnullByDefault;
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker;
import org.bukkit.ChatColor;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
+import javax.annotation.Nonnull;
+import javax.annotation.ParametersAreNonnullByDefault;
+import java.util.Optional;
+
public class CargoManager extends SlimefunItem implements HologramOwner, NotRotatable {
@ParametersAreNonnullByDefault
@@ -57,24 +57,20 @@ public boolean isSynchronized() {
return false;
}
},
- new BlockUseHandler() {
-
- @Override
- public void onRightClick(PlayerRightClickEvent e) {
- Optional block = e.getClickedBlock();
+ (BlockUseHandler) e -> {
+ Optional block = e.getClickedBlock();
- if (block.isPresent()) {
- Player p = e.getPlayer();
- Block b = block.get();
+ if (block.isPresent()) {
+ Player p = e.getPlayer();
+ Block b = block.get();
- var blockData = StorageCacheUtils.getBlock(b.getLocation());
- if (blockData.getData("visualizer") == null) {
- blockData.setData("visualizer", "disabled");
- p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c货运网络可视化: " + "&4\u2718"));
- } else {
- blockData.removeData("visualizer");
- p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c货运网络可视化: " + "&2\u2714"));
- }
+ var blockData = StorageCacheUtils.getBlock(b.getLocation());
+ if (blockData.getData("visualizer") == null) {
+ blockData.setData("visualizer", "disabled");
+ p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c货运网络可视化: " + "&4\u2718"));
+ } else {
+ blockData.removeData("visualizer");
+ p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c货运网络可视化: " + "&2\u2714"));
}
}
});
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/ReactorAccessPort.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/ReactorAccessPort.java
index 4804124441..d093c476cb 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/ReactorAccessPort.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/ReactorAccessPort.java
@@ -74,12 +74,8 @@ public void newInstance(BlockMenu menu, Block b) {
INFO_SLOT,
new CustomItemStack(Material.GREEN_WOOL, "&7反应堆", "", "&6已检测到反应堆", "", "&7> 点击打开反应堆界面"));
menu.addMenuClickHandler(INFO_SLOT, (p, slot, item, action) -> {
- if (reactor != null) {
- reactor.open(p);
- }
-
+ reactor.open(p);
newInstance(menu, b);
-
return false;
});
} else {
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 ff5b686001..c56eb4fc05 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
@@ -94,11 +94,13 @@ public Set getFuelTypes() {
return fuelTypes;
}
+ @Nonnull
@Override
public String getLabelLocalPath() {
return "guide.tooltips.recipes.generator";
}
+ @Nonnull
@Override
public List getDisplayRecipes() {
List list = new ArrayList<>();
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/EnergyConnector.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/EnergyConnector.java
index 3793dae395..de906a0d96 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/EnergyConnector.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/EnergyConnector.java
@@ -41,7 +41,7 @@ public EnergyConnector(
@Override
public @Nonnull BlockUseHandler getItemHandler() {
return e -> {
- if (!e.getClickedBlock().isPresent()) {
+ if (e.getClickedBlock().isEmpty()) {
return;
}
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 fd79a39c8e..dee5cf47fc 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
@@ -54,7 +54,7 @@ private BlockPlaceHandler onPlace() {
return new BlockPlaceHandler(false) {
@Override
- public void onPlayerPlace(BlockPlaceEvent e) {
+ public void onPlayerPlace(@Nonnull BlockPlaceEvent e) {
updateHologram(e.getBlock(), "&7连接中...");
}
};
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/JetBoots.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/JetBoots.java
index a5cf62254c..2170c90e41 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/JetBoots.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/JetBoots.java
@@ -7,6 +7,8 @@
import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable;
import io.github.thebusybiscuit.slimefun4.implementation.tasks.player.JetBootsTask;
import javax.annotation.ParametersAreNonnullByDefault;
+
+import lombok.Getter;
import org.bukkit.inventory.ItemStack;
/**
@@ -21,6 +23,7 @@
*/
public class JetBoots extends SlimefunItem implements Rechargeable {
+ @Getter
private final double speed;
private final float capacity;
@@ -32,10 +35,6 @@ public JetBoots(ItemGroup itemGroup, SlimefunItemStack item, ItemStack[] recipe,
this.capacity = capacity;
}
- public double getSpeed() {
- return speed;
- }
-
@Override
public float getMaxItemCharge(ItemStack item) {
return capacity;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/Jetpack.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/Jetpack.java
index a93adb198b..f590f82fea 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/Jetpack.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/Jetpack.java
@@ -7,6 +7,8 @@
import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable;
import io.github.thebusybiscuit.slimefun4.implementation.tasks.player.JetpackTask;
import javax.annotation.ParametersAreNonnullByDefault;
+
+import lombok.Getter;
import org.bukkit.inventory.ItemStack;
/**
@@ -21,6 +23,7 @@
*/
public class Jetpack extends SlimefunItem implements Rechargeable {
+ @Getter
private final double thrust;
private final float capacity;
@@ -32,10 +35,6 @@ public Jetpack(ItemGroup itemGroup, SlimefunItemStack item, ItemStack[] recipe,
this.capacity = capacity;
}
- public double getThrust() {
- return thrust;
- }
-
@Override
public float getMaxItemCharge(ItemStack item) {
return capacity;
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 1472e3a2ad..6a458762a3 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
@@ -11,6 +11,7 @@
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
import java.util.Optional;
+import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@@ -32,6 +33,7 @@ public Multimeter(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipe
super(itemGroup, item, recipeType, recipe);
}
+ @Nonnull
@Override
public ItemUseHandler getItemHandler() {
return e -> {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/BioGenerator.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/BioGenerator.java
index db1bbd8ec5..ded4cfcf1a 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/BioGenerator.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/BioGenerator.java
@@ -6,6 +6,8 @@
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
+
+import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel;
@@ -96,6 +98,7 @@ protected void registerDefaultFuelTypes() {
}
}
+ @Nonnull
@Override
public ItemStack getProgressBar() {
return new ItemStack(Material.GOLDEN_HOE);
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/CombustionGenerator.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/CombustionGenerator.java
index e3704158e7..4c0a8998da 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/CombustionGenerator.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/CombustionGenerator.java
@@ -5,6 +5,8 @@
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.core.attributes.NotDiagonallyRotatable;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
+
+import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel;
@@ -24,6 +26,7 @@ protected void registerDefaultFuelTypes() {
registerFuel(new MachineFuel(90, SlimefunItems.FUEL_BUCKET));
}
+ @Nonnull
@Override
public ItemStack getProgressBar() {
return new ItemStack(Material.FLINT_AND_STEEL);
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/LavaGenerator.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/LavaGenerator.java
index 965ff85d61..2dfd48c2c4 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/LavaGenerator.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/LavaGenerator.java
@@ -4,6 +4,8 @@
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.core.attributes.NotDiagonallyRotatable;
+
+import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel;
@@ -22,6 +24,7 @@ protected void registerDefaultFuelTypes() {
registerFuel(new MachineFuel(40, new ItemStack(Material.LAVA_BUCKET)));
}
+ @Nonnull
@Override
public ItemStack getProgressBar() {
return new ItemStack(Material.FLINT_AND_STEEL);
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/MagnesiumGenerator.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/MagnesiumGenerator.java
index ea3a4852cc..209156ce90 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/MagnesiumGenerator.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/MagnesiumGenerator.java
@@ -5,6 +5,8 @@
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.core.attributes.NotDiagonallyRotatable;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
+
+import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel;
@@ -23,6 +25,7 @@ protected void registerDefaultFuelTypes() {
registerFuel(new MachineFuel(20, SlimefunItems.MAGNESIUM_SALT));
}
+ @Nonnull
@Override
public ItemStack getProgressBar() {
return new ItemStack(Material.FLINT_AND_STEEL);
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/SolarGenerator.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/SolarGenerator.java
index 45c475bc02..8725ff6bb0 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/SolarGenerator.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/SolarGenerator.java
@@ -11,6 +11,8 @@
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler;
import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNet;
import javax.annotation.ParametersAreNonnullByDefault;
+
+import lombok.Getter;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.World.Environment;
@@ -33,7 +35,21 @@ public class SolarGenerator extends SlimefunItem implements EnergyNetProvider {
private final ItemSetting useNightEnergyInOtherDimensions =
new ItemSetting<>(this, "other-dimensions-use-night-energy", false);
+ /**
+ * -- GETTER --
+ * This method returns the amount of energy that this
+ * produces during the day.
+ *
+ */
+ @Getter
private final int dayEnergy;
+ /**
+ * -- GETTER --
+ * This method returns the amount of energy that this
+ * produces during the night.
+ *
+ */
+ @Getter
private final int nightEnergy;
private final int capacity;
@@ -66,26 +82,6 @@ public SolarGenerator(
this(itemGroup, dayEnergy, nightEnergy, item, recipeType, recipe, 0);
}
- /**
- * This method returns the amount of energy that this {@link SolarGenerator}
- * produces during the day.
- *
- * @return The amount of energy generated at daylight
- */
- public int getDayEnergy() {
- return dayEnergy;
- }
-
- /**
- * This method returns the amount of energy that this {@link SolarGenerator}
- * produces during the night.
- *
- * @return The amount of energy generated at night time
- */
- public int getNightEnergy() {
- return nightEnergy;
- }
-
@Override
public int getCapacity() {
return capacity;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoAnvil.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoAnvil.java
index 075783a9c4..3e76efb3c8 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoAnvil.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoAnvil.java
@@ -13,6 +13,8 @@
import org.bukkit.inventory.meta.Damageable;
import org.bukkit.inventory.meta.ItemMeta;
+import javax.annotation.Nonnull;
+
/**
* The {@link AutoAnvil} is an electric machine which can repair any {@link ItemStack} using
* Duct tape.
@@ -36,6 +38,7 @@ public ItemStack getProgressBar() {
return new ItemStack(Material.IRON_PICKAXE);
}
+ @Nonnull
@Override
public String getMachineIdentifier() {
return "AUTO_ANVIL";
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricSmeltery.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricSmeltery.java
index 8cdf004605..559c974c86 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricSmeltery.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricSmeltery.java
@@ -10,12 +10,6 @@
import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.Smeltery;
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.LinkedList;
-import java.util.List;
-import javax.annotation.Nonnull;
-import javax.annotation.ParametersAreNonnullByDefault;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.AdvancedMenuClickHandler;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
@@ -28,6 +22,12 @@
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack;
+import javax.annotation.Nonnull;
+import javax.annotation.ParametersAreNonnullByDefault;
+import java.util.Comparator;
+import java.util.LinkedList;
+import java.util.List;
+
/**
* The {@link ElectricSmeltery} is an electric version of the standard {@link Smeltery}.
*
@@ -89,7 +89,7 @@ public int[] getSlotsAccessedByItemTransport(DirtyChestMenu menu, ItemTransportF
// All slots with that item are already full
return new int[0];
} else {
- Collections.sort(slots, compareSlots(menu));
+ slots.sort(compareSlots(menu));
int[] array = new int[slots.size()];
for (int i = 0; i < slots.size(); i++) {
@@ -135,7 +135,7 @@ public boolean onClick(Player p, int slot, ItemStack cursor, ClickAction action)
@Override
public boolean onClick(
InventoryClickEvent e, Player p, int slot, ItemStack cursor, ClickAction action) {
- return cursor == null || cursor.getType() == null || cursor.getType() == Material.AIR;
+ return cursor == null || cursor.getType() == Material.AIR;
}
});
}
@@ -153,7 +153,7 @@ public int[] getInputSlots() {
@Override
public int[] getOutputSlots() {
- return new int[] {24, 25};
+ return super.getOutputSlots();
}
@Override
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java
index 641454af49..89b3931ea7 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java
@@ -72,7 +72,7 @@ private BlockBreakHandler onBreak() {
return new SimpleBlockBreakHandler() {
@Override
- public void onBlockBreak(Block b) {
+ public void onBlockBreak(@Nonnull Block b) {
BlockMenu inv = StorageCacheUtils.getMenu(b.getLocation());
if (inv != null) {
@@ -106,7 +106,7 @@ public boolean onClick(Player p, int slot, ItemStack cursor, ClickAction action)
@Override
public boolean onClick(
InventoryClickEvent e, Player p, int slot, ItemStack cursor, ClickAction action) {
- return cursor == null || cursor.getType() == null || cursor.getType() == Material.AIR;
+ return cursor == null || cursor.getType() == Material.AIR;
}
});
}
@@ -253,6 +253,7 @@ private boolean isSource(@Nonnull Block block) {
return false;
}
+ @Nonnull
@Override
public BlockTicker getItemHandler() {
return new BlockTicker() {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FoodFabricator.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FoodFabricator.java
index 6b67abdfdb..541707e21c 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FoodFabricator.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FoodFabricator.java
@@ -9,6 +9,8 @@
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
+import javax.annotation.Nonnull;
+
public class FoodFabricator extends AContainer {
public FoodFabricator(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
@@ -57,6 +59,7 @@ protected void registerDefaultRecipes() {
});
}
+ @Nonnull
@Override
public String getMachineIdentifier() {
return "FOOD_FABRICATOR";
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/HeatedPressureChamber.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/HeatedPressureChamber.java
index 763befef9c..7111602cb7 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/HeatedPressureChamber.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/HeatedPressureChamber.java
@@ -65,7 +65,7 @@ public int[] getSlotsAccessedByItemTransport(DirtyChestMenu menu, ItemTransportF
if (slots.isEmpty()) {
return getInputSlots();
} else {
- Collections.sort(slots, compareSlots(menu));
+ slots.sort(compareSlots(menu));
int[] array = new int[slots.size()];
for (int i = 0; i < slots.size(); i++) {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/accelerators/AbstractGrowthAccelerator.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/accelerators/AbstractGrowthAccelerator.java
index e039d1e5fb..ffc7a9355e 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/accelerators/AbstractGrowthAccelerator.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/accelerators/AbstractGrowthAccelerator.java
@@ -40,7 +40,7 @@ private BlockBreakHandler onBreak() {
return new SimpleBlockBreakHandler() {
@Override
- public void onBlockBreak(Block b) {
+ public void onBlockBreak(@Nonnull Block b) {
BlockMenu inv = StorageCacheUtils.getMenu(b.getLocation());
if (inv != null) {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/enchanting/AutoEnchanter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/enchanting/AutoEnchanter.java
index a72166cc12..f869e5d5f9 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/enchanting/AutoEnchanter.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/enchanting/AutoEnchanter.java
@@ -121,17 +121,6 @@ protected MachineRecipe enchant(BlockMenu menu, ItemStack target, ItemStack ench
enchantments.entrySet().removeIf(e -> target.getEnchantmentLevel(e.getKey()) >= e.getValue());
}
- /*
- * When maxEnchants is set to -1 it will be ignored. When it's set to 0 it will not allow any enchants to go
- * on an item. When maxEnchants is set to any other value it will allow that many enchants to go on the item.
- */
- int preExistingEnchants = 0;
- for (Map.Entry entry : target.getEnchantments().entrySet()) {
- if (meta.hasEnchant(entry.getKey())) {
- preExistingEnchants++;
- }
- }
-
// Check if we found any valid enchantments
if (!enchantments.isEmpty()) {
ItemStack enchantedItem = target.clone();
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/enchanting/BookBinder.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/enchanting/BookBinder.java
index 07cf5628d5..b641c8f18a 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/enchanting/BookBinder.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/enchanting/BookBinder.java
@@ -55,7 +55,7 @@ protected MachineRecipe findNextRecipe(BlockMenu menu) {
combineEnchantments(storedItemEnchantments, storedTargetEnchantments);
// Just return if no enchantments exist. This shouldn't ever happen. :NotLikeThis:
- if (enchantments.size() > 0) {
+ if (!enchantments.isEmpty()) {
if (hasIllegalEnchants(storedItemEnchantments) || hasIllegalEnchants(storedTargetEnchantments)) {
return null;
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/AbstractEntityAssembler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/AbstractEntityAssembler.java
index f5fbfbb590..7a1f9a4381 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/AbstractEntityAssembler.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/AbstractEntityAssembler.java
@@ -100,7 +100,7 @@ public int[] getSlotsAccessedByItemTransport(ItemTransportFlow flow) {
@Override
public int[] getSlotsAccessedByItemTransport(DirtyChestMenu menu, ItemTransportFlow flow, ItemStack item) {
- if (flow == ItemTransportFlow.INSERT && item != null) {
+ if (flow == ItemTransportFlow.INSERT) {
if (item.getType() == getBody().getType()) {
return bodySlots;
}
@@ -175,7 +175,6 @@ private void updateBlockInventory(BlockMenu menu, Block b) {
});
}
- val = null;
double offset =
(blockData == null || (val = blockData.getData(KEY_OFFSET)) == null) ? 3.0F : Double.parseDouble(val);
@@ -193,6 +192,7 @@ private void updateBlockInventory(BlockMenu menu, Block b) {
});
}
+ @Nonnull
@Override
public BlockTicker getItemHandler() {
return new BlockTicker() {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/AutoBreeder.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/AutoBreeder.java
index 7e179df6bd..bb00e9d0dd 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/AutoBreeder.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/AutoBreeder.java
@@ -50,7 +50,7 @@ private ItemHandler onBreak() {
return new SimpleBlockBreakHandler() {
@Override
- public void onBlockBreak(Block b) {
+ public void onBlockBreak(@Nonnull Block b) {
BlockMenu inv = StorageCacheUtils.getMenu(b.getLocation());
if (inv != null) {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/ExpCollector.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/ExpCollector.java
index 8b9b5c0887..f317f04ef3 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/ExpCollector.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/ExpCollector.java
@@ -72,7 +72,7 @@ private ItemHandler onBreak() {
return new SimpleBlockBreakHandler() {
@Override
- public void onBlockBreak(Block b) {
+ public void onBlockBreak(@Nonnull Block b) {
BlockMenu inv = StorageCacheUtils.getMenu(b.getLocation());
if (inv != null) {
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 ded6c39f47..6c18634501 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
@@ -55,11 +55,13 @@ public ItemStack getCoolant() {
return SlimefunItems.NETHER_ICE_COOLANT_CELL;
}
+ @Nonnull
@Override
public ItemStack getFuelIcon() {
return new ItemStack(Material.NETHER_STAR);
}
+ @Nonnull
@Override
public ItemStack getProgressBar() {
return new ItemStack(Material.NETHER_STAR);
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 1487b5e7c3..a377d4965f 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
@@ -35,6 +35,7 @@ protected void registerDefaultFuelTypes() {
registerFuel(new MachineFuel(1500, SlimefunItems.BOOSTED_URANIUM, null));
}
+ @Nonnull
@Override
public ItemStack getProgressBar() {
return SlimefunItems.LAVA_CRYSTAL;
@@ -45,6 +46,7 @@ public ItemStack getCoolant() {
return SlimefunItems.REACTOR_COOLANT_CELL;
}
+ @Nonnull
@Override
public ItemStack getFuelIcon() {
return SlimefunItems.URANIUM;
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 11af55925c..a58ed20111 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
@@ -338,7 +338,7 @@ public int[] getOutputSlots() {
}
@Override
- public int getGeneratedOutput(Location l, SlimefunBlockData data) {
+ public int getGeneratedOutput(@Nonnull Location l, @Nonnull SlimefunBlockData data) {
BlockMenu inv = StorageCacheUtils.getMenu(l);
BlockMenu accessPort = getAccessPort(inv, l);
FuelOperation operation = processor.getOperation(l);
@@ -393,7 +393,7 @@ private int generateEnergy(
}
@Override
- public boolean willExplode(Location l, SlimefunBlockData data) {
+ public boolean willExplode(@Nonnull Location l, @Nonnull SlimefunBlockData data) {
boolean explosion = explosionsQueue.contains(l);
if (explosion) {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/elevator/ElevatorFloor.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/elevator/ElevatorFloor.java
index 45a7697586..ac74afaae8 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/elevator/ElevatorFloor.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/elevator/ElevatorFloor.java
@@ -1,6 +1,8 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.elevator;
import javax.annotation.Nonnull;
+
+import lombok.Getter;
import org.apache.commons.lang.Validate;
import org.bukkit.Location;
import org.bukkit.block.Block;
@@ -12,7 +14,7 @@
*
* @author TheBusyBiscuit
*/
-class ElevatorFloor {
+public class ElevatorFloor {
/**
* The name of this floor.
@@ -21,7 +23,14 @@ class ElevatorFloor {
/**
* The floor number.
+ * -- GETTER --
+ * This returns the number of this floor.
+ * The lowest floor will have the number 0 and it
+ * increments from there.
+ *
+
*/
+ @Getter
private final int number;
/**
@@ -73,14 +82,4 @@ public int getAltitude() {
return location.getBlockY();
}
- /**
- * This returns the number of this floor.
- * The lowest floor will have the number 0 and it
- * increments from there.
- *
- * @return The number of this floor.
- */
- public int getNumber() {
- return number;
- }
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/elevator/ElevatorPlate.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/elevator/ElevatorPlate.java
index 903f0a0eb5..544a8fd251 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/elevator/ElevatorPlate.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/elevator/ElevatorPlate.java
@@ -76,7 +76,7 @@ public ElevatorPlate(
return new BlockPlaceHandler(false) {
@Override
- public void onPlayerPlace(BlockPlaceEvent e) {
+ public void onPlayerPlace(@Nonnull BlockPlaceEvent e) {
var blockData = StorageCacheUtils.getBlock(e.getBlock().getLocation());
blockData.setData(DATA_KEY, ChatColor.WHITE + "一楼");
blockData.setData("owner", e.getPlayer().getUniqueId().toString());
@@ -255,7 +255,7 @@ private void teleport(Player player, ElevatorFloor floor) {
player.getEyeLocation().getPitch());
PaperLib.teleportAsync(player, destination).thenAccept(teleported -> {
- if (teleported.booleanValue()) {
+ if (teleported) {
player.sendTitle(ChatColor.WHITE + ChatColors.color(floor.getName()), null, 20, 60, 20);
}
});
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/FortuneCookie.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/FortuneCookie.java
index 10bc73ccd6..c98bfcc7e7 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/FortuneCookie.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/FortuneCookie.java
@@ -11,6 +11,7 @@
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
+import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@@ -30,6 +31,7 @@ public FortuneCookie(ItemGroup itemGroup, SlimefunItemStack item, RecipeType rec
super(itemGroup, item, recipeType, recipe);
}
+ @Nonnull
@Override
public ItemConsumptionHandler getItemHandler() {
return (e, p, item) -> {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/HeavyCream.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/HeavyCream.java
index e8f233c228..47513a3dfa 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/HeavyCream.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/HeavyCream.java
@@ -36,7 +36,7 @@ public ItemUseHandler getItemHandler() {
return e -> {
Optional block = e.getClickedBlock();
- if (!block.isPresent() || !block.get().getType().isInteractable()) {
+ if (block.isEmpty() || !block.get().getType().isInteractable()) {
e.cancel();
}
};
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/Juice.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/Juice.java
index 7684590810..4cf7712ac6 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/Juice.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/Juice.java
@@ -11,6 +11,7 @@
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
import java.util.ArrayList;
import java.util.List;
+import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Material;
@@ -58,6 +59,7 @@ public Juice(
}
}
+ @Nonnull
@Override
public ItemConsumptionHandler getItemHandler() {
return (e, p, item) -> {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/MeatJerky.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/MeatJerky.java
index 3b28d59887..025f762981 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/MeatJerky.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/MeatJerky.java
@@ -7,6 +7,8 @@
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.core.handlers.ItemConsumptionHandler;
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
+
+import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.inventory.ItemStack;
@@ -31,6 +33,7 @@ public MeatJerky(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeT
addItemSetting(saturation);
}
+ @Nonnull
@Override
public ItemConsumptionHandler getItemHandler() {
return (e, p, item) -> p.setSaturation(p.getSaturation() + saturation.getValue());
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/MonsterJerky.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/MonsterJerky.java
index a157482dab..fe53350488 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/MonsterJerky.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/MonsterJerky.java
@@ -6,6 +6,8 @@
import io.github.thebusybiscuit.slimefun4.core.handlers.ItemConsumptionHandler;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
+
+import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
@@ -26,6 +28,7 @@ public MonsterJerky(ItemGroup itemGroup, SlimefunItemStack item, RecipeType reci
super(itemGroup, item, recipeType, recipe);
}
+ @Nonnull
@Override
public ItemConsumptionHandler getItemHandler() {
return (e, p, item) -> Slimefun.runSync(
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOMiner.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOMiner.java
index 38e3f193c6..82adfc1c1f 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOMiner.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOMiner.java
@@ -200,7 +200,7 @@ private BlockPlaceHandler onBlockPlace() {
return new BlockPlaceHandler(false) {
@Override
- public void onPlayerPlace(BlockPlaceEvent e) {
+ public void onPlayerPlace(@Nonnull BlockPlaceEvent e) {
updateHologram(e.getBlock(), "&7待机中...");
}
};
@@ -255,6 +255,7 @@ public List getDisplayRecipes() {
return "guide.tooltips.recipes.miner";
}
+ @Nonnull
@Override
public EnergyNetComponentType getEnergyComponentType() {
return EnergyNetComponentType.CONSUMER;
@@ -283,7 +284,7 @@ public boolean onClick(Player p, int slot, ItemStack cursor, ClickAction action)
@Override
public boolean onClick(
InventoryClickEvent e, Player p, int slot, ItemStack cursor, ClickAction action) {
- return cursor == null || cursor.getType() == null || cursor.getType() == Material.AIR;
+ return cursor == null || cursor.getType() == Material.AIR;
}
});
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOScanner.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOScanner.java
index ac5ccaec46..3e2ab3af7f 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOScanner.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOScanner.java
@@ -9,6 +9,7 @@
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import java.util.Optional;
+import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Location;
import org.bukkit.block.Block;
@@ -21,6 +22,7 @@ public GEOScanner(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipe
super(itemGroup, item, recipeType, recipe);
}
+ @Nonnull
@Override
public BlockUseHandler getItemHandler() {
return e -> {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/OilPump.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/OilPump.java
index 6b5d9b0545..1e6afe5e2b 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/OilPump.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/OilPump.java
@@ -13,6 +13,7 @@
import java.util.Arrays;
import java.util.List;
import java.util.OptionalInt;
+import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe;
@@ -55,10 +56,10 @@ public boolean canOpen(Block b, Player p) {
return false;
}
- if (!Slimefun.getGPSNetwork()
+ if (Slimefun.getGPSNetwork()
.getResourceManager()
.getSupplies(oil, b.getWorld(), b.getX() >> 4, b.getZ() >> 4)
- .isPresent()) {
+ .isEmpty()) {
Slimefun.getLocalization().sendMessage(p, "gps.geo.scan-required", true);
return false;
}
@@ -77,11 +78,13 @@ public int[] getSlotsAccessedByItemTransport(ItemTransportFlow flow) {
};
}
+ @Nonnull
@Override
public List getDisplayRecipes() {
return Arrays.asList(emptyBucket, SlimefunItems.OIL_BUCKET);
}
+ @Nonnull
@Override
public String getMachineIdentifier() {
return "OIL_PUMP";
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/PortableGEOScanner.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/PortableGEOScanner.java
index 148aa83d52..a466cb8bce 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/PortableGEOScanner.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/PortableGEOScanner.java
@@ -7,6 +7,7 @@
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import java.util.Optional;
+import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.block.Block;
import org.bukkit.inventory.ItemStack;
@@ -18,6 +19,7 @@ public PortableGEOScanner(ItemGroup itemGroup, SlimefunItemStack item, RecipeTyp
super(itemGroup, item, recipeType, recipe);
}
+ @Nonnull
@Override
public ItemUseHandler getItemHandler() {
return e -> {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSControlPanel.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSControlPanel.java
index ea0cd06f6a..3ce9973e02 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSControlPanel.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSControlPanel.java
@@ -9,6 +9,7 @@
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import java.util.Optional;
+import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Location;
import org.bukkit.block.Block;
@@ -22,6 +23,7 @@ public GPSControlPanel(ItemGroup itemGroup, SlimefunItemStack item, RecipeType r
super(itemGroup, item, recipeType, recipe);
}
+ @Nonnull
@Override
public BlockUseHandler getItemHandler() {
return e -> {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSMarkerTool.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSMarkerTool.java
index 524925f724..67fb8246c4 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSMarkerTool.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSMarkerTool.java
@@ -8,6 +8,8 @@
import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
+
+import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Location;
import org.bukkit.block.Block;
@@ -27,6 +29,7 @@ public GPSMarkerTool(ItemGroup itemGroup, SlimefunItemStack item, RecipeType rec
super(itemGroup, item, recipeType, recipe);
}
+ @Nonnull
@Override
public ItemUseHandler getItemHandler() {
return e -> {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSTransmitter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSTransmitter.java
index eb8603509c..93c984ea1e 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSTransmitter.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSTransmitter.java
@@ -48,7 +48,7 @@ private BlockPlaceHandler onPlace() {
return new BlockPlaceHandler(false) {
@Override
- public void onPlayerPlace(BlockPlaceEvent e) {
+ public void onPlayerPlace(@Nonnull BlockPlaceEvent e) {
StorageCacheUtils.setData(
e.getBlock().getLocation(),
"owner",
@@ -62,7 +62,7 @@ private BlockBreakHandler onBreak() {
return new BlockBreakHandler(false, false) {
@Override
- public void onPlayerBreak(BlockBreakEvent e, ItemStack item, List drops) {
+ public void onPlayerBreak(@Nonnull BlockBreakEvent e, @Nonnull ItemStack item, @Nonnull List drops) {
Location l = e.getBlock().getLocation();
UUID owner = UUID.fromString(StorageCacheUtils.getData(l, "owner"));
Slimefun.getGPSNetwork().updateTransmitter(l, owner, false);
@@ -74,6 +74,7 @@ public void onPlayerBreak(BlockBreakEvent e, ItemStack item, List dro
public abstract int getEnergyConsumption();
+ @Nonnull
@Override
public BlockTicker getItemHandler() {
return new BlockTicker() {
@@ -98,6 +99,7 @@ public boolean isSynchronized() {
};
}
+ @Nonnull
@Override
public EnergyNetComponentType getEnergyComponentType() {
return EnergyNetComponentType.CONSUMER;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/InfernalBonemeal.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/InfernalBonemeal.java
index 99d98ccd85..c9885a1113 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/InfernalBonemeal.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/InfernalBonemeal.java
@@ -7,6 +7,7 @@
import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import java.util.Optional;
+import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Effect;
import org.bukkit.GameMode;
@@ -35,6 +36,7 @@ public InfernalBonemeal(
super(itemGroup, item, recipeType, recipe, recipeOutput);
}
+ @Nonnull
@Override
public ItemUseHandler getItemHandler() {
return e -> {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/TelepositionScroll.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/TelepositionScroll.java
index 8dd1844172..784c6fff37 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/TelepositionScroll.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/TelepositionScroll.java
@@ -8,6 +8,8 @@
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
+
+import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Location;
import org.bukkit.entity.ArmorStand;
@@ -34,6 +36,7 @@ public TelepositionScroll(ItemGroup itemGroup, SlimefunItemStack item, RecipeTyp
addItemSetting(radius);
}
+ @Nonnull
@Override
public ItemUseHandler getItemHandler() {
return e -> {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/runes/EnchantmentRune.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/runes/EnchantmentRune.java
index 994bfd39b2..4da10dd23c 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/runes/EnchantmentRune.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/runes/EnchantmentRune.java
@@ -63,6 +63,7 @@ public EnchantmentRune(ItemGroup itemGroup, SlimefunItemStack item, RecipeType r
}
}
+ @Nonnull
@Override
public ItemDropHandler getItemHandler() {
return (e, p, item) -> {
@@ -187,16 +188,9 @@ private int getRandomlevel(@Nonnull Enchantment enchantment) {
private void removeIllegalEnchantments(
@Nonnull ItemStack target, @Nonnull List potentialEnchantments) {
for (Enchantment enchantment : target.getEnchantments().keySet()) {
- Iterator iterator = potentialEnchantments.iterator();
- while (iterator.hasNext()) {
- Enchantment possibleEnchantment = iterator.next();
-
- // Duplicate or conflict
- if (possibleEnchantment.equals(enchantment) || possibleEnchantment.conflictsWith(enchantment)) {
- iterator.remove();
- }
- }
+ // Duplicate or conflict
+ potentialEnchantments.removeIf(possibleEnchantment -> possibleEnchantment.equals(enchantment) || possibleEnchantment.conflictsWith(enchantment));
}
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/staves/WaterStaff.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/staves/WaterStaff.java
index 74bd04165f..49a0de8ed2 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/staves/WaterStaff.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/staves/WaterStaff.java
@@ -7,6 +7,8 @@
import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
+
+import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@@ -25,6 +27,7 @@ public WaterStaff(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipe
super(itemGroup, item, recipeType, recipe);
}
+ @Nonnull
@Override
public ItemUseHandler getItemHandler() {
return e -> {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/MagicianTalisman.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/MagicianTalisman.java
index 52f8038ec8..86934be93e 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/MagicianTalisman.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/MagicianTalisman.java
@@ -4,21 +4,21 @@
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.implementation.settings.TalismanEnchantment;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.ThreadLocalRandom;
-import java.util.logging.Level;
-import java.util.stream.Collectors;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-import javax.annotation.ParametersAreNonnullByDefault;
import org.apache.commons.lang.Validate;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import javax.annotation.ParametersAreNonnullByDefault;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.logging.Level;
+
/**
* The {@link MagicianTalisman} is a special kind of {@link Talisman} which awards a {@link Player}
* with an extra {@link Enchantment} when they enchant their {@link ItemStack}.
@@ -65,7 +65,7 @@ public MagicianTalisman(SlimefunItemStack item, ItemStack[] recipe) {
Level.SEVERE,
x,
() -> "The following Exception was thrown when initializing the settings for "
- + toString());
+ + this);
}
}
@@ -92,7 +92,7 @@ public MagicianTalisman(SlimefunItemStack item, ItemStack[] recipe) {
|| e.getEnchantment().canEnchantItem(item))
.filter(e -> hasConflicts(existingEnchantments, e))
.filter(TalismanEnchantment::getValue)
- .collect(Collectors.toList());
+ .toList();
// @formatter:on
return enabled.isEmpty()
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/Talisman.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/Talisman.java
index 8bde02a420..7369a995ff 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/Talisman.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/Talisman.java
@@ -18,6 +18,8 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
+
+import lombok.Getter;
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@@ -46,9 +48,24 @@ public class Talisman extends SlimefunItem {
private final SlimefunItemStack enderTalisman;
protected final String suffix;
+ /**
+ * -- GETTER --
+ * This returns whether the
+ * will be consumed upon use.
+ *
+ */
+ @Getter
protected final boolean consumable;
protected final boolean cancel;
protected final PotionEffect[] effects;
+ /**
+ * -- GETTER --
+ * This returns the chance of this
+ * activating.
+ * The chance will be between 1 and 100.
+ *
+ */
+ @Getter
protected final int chance;
@ParametersAreNonnullByDefault
@@ -122,25 +139,6 @@ protected Talisman(
}
}
- /**
- * This returns whether the {@link Talisman} will be consumed upon use.
- *
- * @return Whether this {@link Talisman} is consumed on use.
- */
- public boolean isConsumable() {
- return consumable;
- }
-
- /**
- * This returns the chance of this {@link Talisman} activating.
- * The chance will be between 1 and 100.
- *
- * @return The chance of this {@link Talisman} activating.
- */
- public int getChance() {
- return chance;
- }
-
@Nonnull
public PotionEffect[] getEffects() {
return effects;
@@ -262,9 +260,7 @@ private static void consumeItem(Inventory inv, Talisman talisman, ItemStack tali
if (talisman.isConsumable()) {
ItemStack[] contents = inv.getContents();
- for (int i = 0; i < contents.length; i++) {
- ItemStack item = contents[i];
-
+ for (ItemStack item : contents) {
if (SlimefunUtils.isItemSimilar(item, talismanItem, true, false)) {
ItemUtils.consumeItem(item, false);
return;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Bandage.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Bandage.java
index f0f708e655..8d0b43ce67 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Bandage.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Bandage.java
@@ -6,6 +6,8 @@
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
+
+import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Effect;
import org.bukkit.GameMode;
@@ -40,6 +42,7 @@ public Bandage(
this.healingLevel = healingLevel;
}
+ @Nonnull
@Override
public ItemUseHandler getItemHandler() {
return e -> {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Medicine.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Medicine.java
index dedd69e768..ec0c4fbe9b 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Medicine.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Medicine.java
@@ -5,6 +5,8 @@
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.core.handlers.ItemConsumptionHandler;
import io.github.thebusybiscuit.slimefun4.utils.RadiationUtils;
+
+import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.inventory.ItemStack;
@@ -15,6 +17,7 @@ public Medicine(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeTy
super(itemGroup, 8, item, recipeType, recipe);
}
+ @Nonnull
@Override
public ItemConsumptionHandler getItemHandler() {
return (e, p, item) -> {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/BasicCircuitBoard.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/BasicCircuitBoard.java
index 824d4dee79..3dc289f549 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/BasicCircuitBoard.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/BasicCircuitBoard.java
@@ -10,6 +10,8 @@
import io.github.thebusybiscuit.slimefun4.core.attributes.RandomMobDrop;
import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
+
+import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.entity.IronGolem;
import org.bukkit.inventory.ItemStack;
@@ -44,6 +46,7 @@ public boolean isDroppedFromGolems() {
return dropSetting.getValue();
}
+ @Nonnull
@Override
public ItemUseHandler getItemHandler() {
return PlayerRightClickEvent::cancel;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/GoldIngot.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/GoldIngot.java
index 4c43b81d50..81f160db48 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/GoldIngot.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/GoldIngot.java
@@ -6,6 +6,8 @@
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.Smeltery;
import javax.annotation.ParametersAreNonnullByDefault;
+
+import lombok.Getter;
import org.apache.commons.lang.Validate;
import org.bukkit.inventory.ItemStack;
@@ -20,10 +22,25 @@
* @see Smeltery
*
*/
+@Getter
public class GoldIngot extends SlimefunItem {
/**
* The carat rating.
+ * -- GETTER --
+ * This returns the carat rating of this
+ * .
+ *
+ * The purity of the
+ * is measured in carat (1-24).
+ *
+ * 24k = 100% gold.
+ * 18k = 75% gold.
+ * 12k = 50% gold.
+ *
+ * and so on...
+ *
+
*/
private final int caratRating;
@@ -37,22 +54,4 @@ public GoldIngot(
this.caratRating = caratRating;
}
- /**
- * This returns the carat rating of this {@link GoldIngot}.
- *
- * The purity of the {@link GoldIngot} is measured in carat (1-24).
- *
- *
- * 24k = 100% gold.
- * 18k = 75% gold.
- * 12k = 50% gold.
- *
- *
- * and so on...
- *
- * @return The carat rating of this {@link GoldIngot}
- */
- public int getCaratRating() {
- return caratRating;
- }
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/MakeshiftSmeltery.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/MakeshiftSmeltery.java
index e85dd3ee98..b7cbf2b0d5 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/MakeshiftSmeltery.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/MakeshiftSmeltery.java
@@ -5,6 +5,7 @@
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
import java.util.ArrayList;
import java.util.List;
+import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Effect;
import org.bukkit.Material;
@@ -44,6 +45,7 @@ public MakeshiftSmeltery(ItemGroup itemGroup, SlimefunItemStack item) {
BlockFace.DOWN);
}
+ @Nonnull
@Override
public List getDisplayRecipes() {
List items = new ArrayList<>();
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreCrusher.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreCrusher.java
index 91020690ee..4ebdd235e8 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreCrusher.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreCrusher.java
@@ -183,6 +183,7 @@ public void postRegister() {
}
}
+ @Nonnull
@Override
public List getDisplayRecipes() {
return recipes.stream().map(items -> items[0]).collect(Collectors.toList());
@@ -225,7 +226,7 @@ public void onInteract(Player p, Block b) {
}
}
- private class DoubleOreSetting extends ItemSetting {
+ private static class DoubleOreSetting extends ItemSetting {
private final ItemStack coal = new ItemStack(Material.COAL, 1);
private final ItemStack lapis = new ItemStack(Material.LAPIS_LAZULI, 7);
@@ -260,7 +261,7 @@ private void apply(boolean value) {
}
@Override
- public void update(Boolean newValue) {
+ public void update(@Nonnull Boolean newValue) {
super.update(newValue);
apply(newValue);
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Smeltery.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Smeltery.java
index 828e7d2747..3fff0b5644 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Smeltery.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Smeltery.java
@@ -73,6 +73,7 @@ protected void registerDefaultRecipes(@Nonnull List recipes) {
recipes.add(new ItemStack(Material.IRON_INGOT));
}
+ @Nonnull
@Override
public List getDisplayRecipes() {
List items = new ArrayList<>();
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/teleporter/PersonalActivationPlate.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/teleporter/PersonalActivationPlate.java
index cd84f8ae05..79a4b7174a 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/teleporter/PersonalActivationPlate.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/teleporter/PersonalActivationPlate.java
@@ -36,7 +36,7 @@ private BlockPlaceHandler onPlace() {
return new BlockPlaceHandler(false) {
@Override
- public void onPlayerPlace(BlockPlaceEvent e) {
+ public void onPlayerPlace(@Nonnull BlockPlaceEvent e) {
StorageCacheUtils.setData(
e.getBlock().getLocation(),
"owner",
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/teleporter/Teleporter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/teleporter/Teleporter.java
index d2bc6e6372..8029fbb159 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/teleporter/Teleporter.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/teleporter/Teleporter.java
@@ -9,6 +9,8 @@
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler;
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
+
+import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockPlaceEvent;
@@ -31,12 +33,13 @@ public Teleporter(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipe
super(itemGroup, item, recipeType, recipe);
}
+ @Nonnull
@Override
public BlockPlaceHandler getItemHandler() {
return new BlockPlaceHandler(false) {
@Override
- public void onPlayerPlace(BlockPlaceEvent e) {
+ public void onPlayerPlace(@Nonnull BlockPlaceEvent e) {
StorageCacheUtils.setData(
e.getBlock().getLocation(),
"owner",
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ClimbingPick.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ClimbingPick.java
index 666e960546..c93c5f46b4 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ClimbingPick.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ClimbingPick.java
@@ -1,6 +1,5 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.tools;
-import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
import io.github.thebusybiscuit.slimefun4.api.events.ClimbingPickLaunchEvent;
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
@@ -13,18 +12,6 @@
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import io.github.thebusybiscuit.slimefun4.implementation.settings.ClimbableSurface;
import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.EnumMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-import java.util.concurrent.ThreadLocalRandom;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-import javax.annotation.ParametersAreNonnullByDefault;
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
@@ -38,6 +25,19 @@
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import javax.annotation.ParametersAreNonnullByDefault;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.EnumMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import java.util.concurrent.ThreadLocalRandom;
+
/**
* The {@link ClimbingPick} launches you 1 block upwards when you right click
* on a ice {@link Block}.
@@ -154,10 +154,11 @@ public double getClimbingSpeed(@Nonnull ItemStack item, @Nonnull Material type)
return speed;
}
+ @Nonnull
@Override
public ItemUseHandler getItemHandler() {
return e -> {
- if (!e.getClickedBlock().isPresent()) {
+ if (e.getClickedBlock().isEmpty()) {
return;
}
@@ -246,8 +247,6 @@ public boolean isDamageable() {
@ParametersAreNonnullByDefault
private void playAnimation(Player p, Block b, EquipmentSlot hand) {
- MinecraftVersion version = Slimefun.getMinecraftVersion();
-
p.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType());
if (hand == EquipmentSlot.HAND) {
@@ -257,6 +256,7 @@ private void playAnimation(Player p, Block b, EquipmentSlot hand) {
}
}
+ @Nonnull
@Override
public List getDisplayRecipes() {
List display = new ArrayList<>();
@@ -268,6 +268,7 @@ public List getDisplayRecipes() {
return display;
}
+ @Nonnull
@Override
public String getLabelLocalPath() {
return "guide.tooltips.recipes.climbing-pick";
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveShovel.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveShovel.java
index b840f75225..263d4f62d3 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveShovel.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveShovel.java
@@ -30,7 +30,7 @@ public ExplosiveShovel(ItemGroup itemGroup, SlimefunItemStack item, RecipeType r
}
@Override
- protected boolean canBreak(@Nonnull Player p, Block b) {
+ protected boolean canBreak(@Nonnull Player p, @Nonnull Block b) {
return SlimefunTag.EXPLOSIVE_SHOVEL_BLOCKS.isTagged(b.getType())
&& Slimefun.getProtectionManager().hasPermission(p, b.getLocation(), Interaction.BREAK_BLOCK);
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SeismicAxe.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SeismicAxe.java
index b30ba00f68..eeb74e3f65 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SeismicAxe.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SeismicAxe.java
@@ -53,6 +53,7 @@ public SeismicAxe(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipe
super(itemGroup, item, recipeType, recipe);
}
+ @Nonnull
@Override
public ItemUseHandler getItemHandler() {
return e -> {
@@ -71,7 +72,7 @@ public ItemUseHandler getItemHandler() {
Block blockAbove = ground.getRelative(BlockFace.UP);
if (blockAbove.getType().isAir()) {
- createJumpingBlock(ground, blockAbove, i);
+ createJumpingBlock(ground, i);
}
for (Entity n : ground.getChunk().getEntities()) {
@@ -94,7 +95,7 @@ && canReach(p.getLocation(), n.getLocation(), groundLocation)
}
@ParametersAreNonnullByDefault
- private void createJumpingBlock(Block ground, Block blockAbove, int index) {
+ private void createJumpingBlock(Block ground, int index) {
Location loc = ground.getRelative(BlockFace.UP).getLocation().add(0.5, 0.0, 0.5);
FallingBlock block = ground.getWorld().spawnFallingBlock(loc, ground.getBlockData());
block.setDropItem(false);
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SwordOfBeheading.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SwordOfBeheading.java
index 62b6f2fcec..907107e82f 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SwordOfBeheading.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SwordOfBeheading.java
@@ -11,6 +11,7 @@
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
+import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Material;
import org.bukkit.entity.Creeper;
@@ -30,7 +31,7 @@
* {@link Monster}.
* Additionally, you can also obtain the head of a {@link Player} by killing them too.
* This sword also allows you to have a higher chance of getting the skull of a {@link WitherSkeleton} too.
- *
+ *
* All chances are managed by an {@link ItemSetting} and can be configured.
*
* @author TheBusyBiscuit
@@ -53,6 +54,7 @@ public SwordOfBeheading(ItemGroup itemGroup, SlimefunItemStack item, RecipeType
addItemSetting(chanceZombie, chanceSkeleton, chanceWitherSkeleton, chanceCreeper, chancePiglin, chancePlayer);
}
+ @Nonnull
@Override
public EntityKillHandler getItemHandler() {
return (e, entity, killer, item) -> {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/integrations/ClearLagIntegration.java b/src/main/java/io/github/thebusybiscuit/slimefun4/integrations/ClearLagIntegration.java
index c061cc4a75..86b33bd13f 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/integrations/ClearLagIntegration.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/integrations/ClearLagIntegration.java
@@ -32,14 +32,6 @@ public void register() {
@EventHandler
public void onEntityRemove(EntityRemoveEvent e) {
- Iterator iterator = e.getEntityList().iterator();
-
- while (iterator.hasNext()) {
- Entity n = iterator.next();
-
- if (n instanceof Item item && SlimefunUtils.hasNoPickupFlag(item)) {
- iterator.remove();
- }
- }
+ e.getEntityList().removeIf(n -> n instanceof Item item && SlimefunUtils.hasNoPickupFlag(item));
}
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/storage/data/PlayerData.java b/src/main/java/io/github/thebusybiscuit/slimefun4/storage/data/PlayerData.java
index a5f3b6ca23..ef54257a1b 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/storage/data/PlayerData.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/storage/data/PlayerData.java
@@ -9,6 +9,8 @@
import java.util.Map;
import java.util.Set;
import javax.annotation.Nonnull;
+
+import lombok.Getter;
import org.apache.commons.lang.Validate;
/**
@@ -20,8 +22,10 @@
@Beta
public class PlayerData {
+ @Getter
private final Set researches = new HashSet<>();
private final Map backpacks = new HashMap<>();
+ @Getter
private final Set waypoints = new HashSet<>();
public PlayerData(Set researches, Map backpacks, Set waypoints) {
@@ -30,10 +34,6 @@ public PlayerData(Set researches, Map backpac
this.waypoints.addAll(waypoints);
}
- public Set getResearches() {
- return researches;
- }
-
public void addResearch(@Nonnull Research research) {
Validate.notNull(research, "Cannot add a 'null' research!");
researches.add(research);
@@ -64,10 +64,6 @@ public void removeBackpack(@Nonnull PlayerBackpack backpack) {
backpacks.remove(backpack.getId());
}
- public Set getWaypoints() {
- return waypoints;
- }
-
public void addWaypoint(@Nonnull Waypoint waypoint) {
Validate.notNull(waypoint, "Cannot add a 'null' waypoint!");
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChestMenuUtils.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChestMenuUtils.java
index 3709512b87..4dc5527bd5 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChestMenuUtils.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChestMenuUtils.java
@@ -183,9 +183,7 @@ public static void updateProgressbar(
builder.append("&7");
- for (int i = 0; i < rest; i++) {
- builder.append(':');
- }
+ builder.append(":".repeat(Math.max(0, rest)));
builder.append(" - ").append(percentage).append('%');
return ChatColors.color(builder.toString());
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java
index ecb2160c64..0a45bd9867 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java
@@ -20,6 +20,7 @@
import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientPedestal;
import io.github.thebusybiscuit.slimefun4.implementation.tasks.CapacitorTextureUpdateTask;
import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper;
+
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Base64;
@@ -29,6 +30,7 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
+
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Location;
@@ -59,14 +61,14 @@ public final class SlimefunUtils {
private static final String NO_PICKUP_METADATA = "no_pickup";
private static final String SOULBOUND_LORE = ChatColor.GRAY + "灵魂绑定";
- private SlimefunUtils() {}
+ private SlimefunUtils() {
+ }
/**
* This method quickly returns whether an {@link Item} was marked as "no_pickup" by
* a Slimefun device.
*
- * @param item
- * The {@link Item} to query
+ * @param item The {@link Item} to query
* @return Whether the {@link Item} is excluded from being picked up
*/
public static boolean hasNoPickupFlag(@Nonnull Item item) {
@@ -77,10 +79,8 @@ public static boolean hasNoPickupFlag(@Nonnull Item item) {
* This will prevent the given {@link Item} from being picked up.
* This is useful for display items which the {@link AncientPedestal} uses.
*
- * @param item
- * The {@link Item} to prevent from being picked up
- * @param context
- * The context in which this {@link Item} was flagged
+ * @param item The {@link Item} to prevent from being picked up
+ * @param context The context in which this {@link Item} was flagged
*/
public static void markAsNoPickup(@Nonnull Item item, @Nonnull String context) {
item.setMetadata(NO_PICKUP_METADATA, new FixedMetadataValue(Slimefun.instance(), context));
@@ -95,8 +95,7 @@ public static void markAsNoPickup(@Nonnull Item item, @Nonnull String context) {
/**
* This method checks whether the given {@link ItemStack} is considered {@link Soulbound}.
*
- * @param item
- * The {@link ItemStack} to check for
+ * @param item The {@link ItemStack} to check for
* @return Whether the given item is soulbound
*/
public static boolean isSoulbound(@Nullable ItemStack item) {
@@ -110,11 +109,9 @@ public static boolean isSoulbound(@Nullable ItemStack item) {
* If the provided item is {@link Soulbound} through the {@link SlimefunItems#SOULBOUND_RUNE}, then this
* method will also check that the {@link SlimefunItems#SOULBOUND_RUNE} is enabled in the provided {@link World}
*
- * @param item
- * The {@link ItemStack} to check for
- * @param world
- * The {@link World} to check if the {@link SlimefunItem} is enabled in if applicable.
- * If {@code null} then this will not do a world check.
+ * @param item The {@link ItemStack} to check for
+ * @param world The {@link World} to check if the {@link SlimefunItem} is enabled in if applicable.
+ * If {@code null} then this will not do a world check.
* @return Whether the given item is soulbound
*/
public static boolean isSoulbound(@Nullable ItemStack item, @Nullable World world) {
@@ -123,9 +120,9 @@ public static boolean isSoulbound(@Nullable ItemStack item, @Nullable World worl
SlimefunItem rune = SlimefunItems.SOULBOUND_RUNE.getItem();
if (rune != null
- && !rune.isDisabled()
- && (world == null || !rune.isDisabledIn(world))
- && hasSoulboundFlag(meta)) {
+ && !rune.isDisabled()
+ && (world == null || !rune.isDisabledIn(world))
+ && hasSoulboundFlag(meta)) {
return true;
}
@@ -162,11 +159,8 @@ private static boolean hasSoulboundFlag(@Nullable ItemMeta meta) {
* by {@link #isSoulbound(ItemStack)}.
* If false is passed, this property will be removed.
*
- * @param item
- * The {@link ItemStack} you want to add/remove Soulbound from.
- * @param makeSoulbound
- * If the item should be soulbound.
- *
+ * @param item The {@link ItemStack} you want to add/remove Soulbound from.
+ * @param makeSoulbound If the item should be soulbound.
* @see #isSoulbound(ItemStack)
*/
public static void setSoulbound(@Nullable ItemStack item, boolean makeSoulbound) {
@@ -205,9 +199,7 @@ public static void setSoulbound(@Nullable ItemStack item, boolean makeSoulbound)
/**
* This method checks whether the given {@link ItemStack} is radioactive.
*
- * @param item
- * The {@link ItemStack} to check
- *
+ * @param item The {@link ItemStack} to check
* @return Whether this {@link ItemStack} is radioactive or not
*/
public static boolean isRadioactive(@Nullable ItemStack item) {
@@ -218,9 +210,7 @@ public static boolean isRadioactive(@Nullable ItemStack item) {
* This method returns an {@link ItemStack} for the given texture.
* The result will be a Player Head with this texture.
*
- * @param texture
- * The texture for this head (base64 or hash)
- *
+ * @param texture The texture for this head (base64 or hash)
* @return An {@link ItemStack} with this Head texture
*/
public static @Nonnull ItemStack getCustomHead(@Nonnull String texture) {
@@ -234,10 +224,10 @@ public static boolean isRadioactive(@Nullable ItemStack item) {
if (CommonPatterns.HEXADECIMAL.matcher(texture).matches()) {
base64 = Base64.getEncoder()
- .encodeToString(("{\"textures\":{\"SKIN\":{\"url\":\"http://textures.minecraft.net/texture/"
- + texture
- + "\"}}}")
- .getBytes(StandardCharsets.UTF_8));
+ .encodeToString(("{\"textures\":{\"SKIN\":{\"url\":\"http://textures.minecraft.net/texture/"
+ + texture
+ + "\"}}}")
+ .getBytes(StandardCharsets.UTF_8));
}
PlayerSkin skin = PlayerSkin.fromBase64(base64);
@@ -272,35 +262,35 @@ public static boolean isItemSimilar(@Nullable ItemStack item, @Nullable ItemStac
}
public static boolean isItemSimilar(
- @Nullable ItemStack item, @Nullable ItemStack sfitem, boolean checkLore, boolean checkAmount) {
+ @Nullable ItemStack item, @Nullable ItemStack sfitem, boolean checkLore, boolean checkAmount) {
return isItemSimilar(item, sfitem, checkLore, checkAmount, true, true);
}
public static boolean isItemSimilar(
- @Nullable ItemStack item,
- @Nullable ItemStack sfitem,
- boolean checkLore,
- boolean checkAmount,
- boolean checkDistinctiveItem) {
+ @Nullable ItemStack item,
+ @Nullable ItemStack sfitem,
+ boolean checkLore,
+ boolean checkAmount,
+ boolean checkDistinctiveItem) {
return isItemSimilar(item, sfitem, checkLore, checkAmount, checkDistinctiveItem, true);
}
public static boolean isItemSimilar(
- @Nullable ItemStack item,
- @Nullable ItemStack sfitem,
- boolean checkLore,
- boolean checkAmount,
- boolean checkDistinctiveItem,
- boolean checkCustomModelData) {
+ @Nullable ItemStack item,
+ @Nullable ItemStack sfitem,
+ boolean checkLore,
+ boolean checkAmount,
+ boolean checkDistinctiveItem,
+ boolean checkCustomModelData) {
if (item == null) {
return sfitem == null;
} else if (sfitem == null
- || item.getType() != sfitem.getType()
- || checkAmount && item.getAmount() < sfitem.getAmount()) {
+ || item.getType() != sfitem.getType()
+ || checkAmount && item.getAmount() < sfitem.getAmount()) {
return false;
} else if (checkDistinctiveItem
- && sfitem instanceof SlimefunItemStack stackOne
- && item instanceof SlimefunItemStack stackTwo) {
+ && sfitem instanceof SlimefunItemStack stackOne
+ && item instanceof SlimefunItemStack stackTwo) {
if (stackOne.getItemId().equals(stackTwo.getItemId())) {
/*
* PR #3417
@@ -348,16 +338,14 @@ public static boolean isItemSimilar(
* Slimefun items may be ItemStackWrapper's in the context of cargo
* so let's try to do an ID comparison before meta comparison
*/
- Debug.log(TestCase.CARGO_INPUT_TESTING, " sfitem is ItemStackWrapper - possible SF Item: {}", sfitem);
-
- ItemMeta possibleSfItemMeta = sfitem.getItemMeta();
- String id = Slimefun.getItemDataService().getItemData(itemMeta).orElse(null);
- String possibleItemId = Slimefun.getItemDataService()
- .getItemData(possibleSfItemMeta)
- .orElse(null);
+ ;
+ ItemMeta sfItemMeta = sfitem.getItemMeta();
+ String possibleItemId = Slimefun.getItemDataService().getItemData(itemMeta).orElse(null);
+ String sfItemId = Slimefun.getItemDataService()
+ .getItemData(sfItemMeta).get();
// Prioritize SlimefunItem id comparison over ItemMeta comparison
- if (id != null && id.equals(possibleItemId)) {
- Debug.log(TestCase.CARGO_INPUT_TESTING, " Item IDs matched!");
+ if (possibleItemId != null && possibleItemId.equals(sfItemId)) {
+ Debug.log(TestCase.CARGO_INPUT_TESTING, " SlimefunItem IDs matched!");
/*
* PR #3417
@@ -365,29 +353,22 @@ public static boolean isItemSimilar(
* Some items can't rely on just IDs matching and will implement Distinctive Item
* in which case we want to use the method provided to compare
*/
- Optional optionalDistinctive = getDistinctiveItem(id);
+ Optional optionalDistinctive = getDistinctiveItem(possibleItemId);
if (optionalDistinctive.isPresent()) {
- return optionalDistinctive.get().canStack(possibleSfItemMeta, itemMeta);
+ return optionalDistinctive.get().canStack(sfItemMeta, itemMeta);
}
return true;
- } else {
- Debug.log(
- TestCase.CARGO_INPUT_TESTING,
- " Item IDs don't match, checking meta {} == {} (lore: {})",
- itemMeta,
- possibleSfItemMeta,
- checkLore);
- return equalsItemMeta(itemMeta, possibleSfItemMeta, checkLore, checkCustomModelData);
}
+ return false;
} else if (sfitem.hasItemMeta()) {
ItemMeta sfItemMeta = sfitem.getItemMeta();
Debug.log(
- TestCase.CARGO_INPUT_TESTING,
- " Comparing meta (vanilla items?) - {} == {} (lore: {})",
- itemMeta,
- sfItemMeta,
- checkLore);
- return equalsItemMeta(itemMeta, sfItemMeta, checkLore, checkCustomModelData);
+ TestCase.CARGO_INPUT_TESTING,
+ " Comparing meta (vanilla items?) - {} == {} (lore: {})",
+ itemMeta,
+ sfItemMeta,
+ checkLore);
+ return equalsItemMeta(itemMeta, sfItemMeta, checkLore, !checkCustomModelData);
} else {
return false;
}
@@ -405,22 +386,22 @@ public static boolean isItemSimilar(
}
private static boolean equalsItemMeta(
- @Nonnull ItemMeta itemMeta, @Nonnull ItemMetaSnapshot itemMetaSnapshot, boolean checkLore) {
+ @Nonnull ItemMeta itemMeta, @Nonnull ItemMetaSnapshot itemMetaSnapshot, boolean checkLore) {
return equalsItemMeta(itemMeta, itemMetaSnapshot, checkLore, true);
}
private static boolean equalsItemMeta(
- @Nonnull ItemMeta itemMeta,
- @Nonnull ItemMetaSnapshot itemMetaSnapshot,
- boolean checkLore,
- boolean bypassCustomModelCheck) {
+ @Nonnull ItemMeta itemMeta,
+ @Nonnull ItemMetaSnapshot itemMetaSnapshot,
+ boolean checkLore,
+ boolean bypassCustomModelCheck) {
Optional displayName = itemMetaSnapshot.getDisplayName();
if (itemMeta.hasDisplayName() != displayName.isPresent()) {
return false;
} else if (itemMeta.hasDisplayName()
- && displayName.isPresent()
- && !itemMeta.getDisplayName().equals(displayName.get())) {
+ && displayName.isPresent()
+ && !itemMeta.getDisplayName().equals(displayName.get())) {
return false;
} else if (checkLore) {
Optional> itemLore = itemMetaSnapshot.getLore();
@@ -439,28 +420,24 @@ private static boolean equalsItemMeta(
// Fixes #3133: name and lore are not enough
OptionalInt itemCustomModelData = itemMetaSnapshot.getCustomModelData();
if (itemMeta.hasCustomModelData()
- && itemCustomModelData.isPresent()
- && itemMeta.getCustomModelData() != itemCustomModelData.getAsInt()) {
+ && itemCustomModelData.isPresent()
+ && itemMeta.getCustomModelData() != itemCustomModelData.getAsInt()) {
return false;
} else {
return itemMeta.hasCustomModelData() == itemCustomModelData.isPresent();
}
}
- private static boolean equalsItemMeta(@Nonnull ItemMeta itemMeta, @Nonnull ItemMeta sfitemMeta, boolean checkLore) {
- return equalsItemMeta(itemMeta, sfitemMeta, checkLore, true);
- }
-
private static boolean equalsItemMeta(
- @Nonnull ItemMeta itemMeta,
- @Nonnull ItemMeta sfitemMeta,
- boolean checkLore,
- boolean bypassCustomModelCheck) {
+ @Nonnull ItemMeta itemMeta,
+ @Nonnull ItemMeta sfitemMeta,
+ boolean checkLore,
+ boolean bypassCustomModelCheck) {
if (itemMeta.hasDisplayName() != sfitemMeta.hasDisplayName()) {
return false;
} else if (itemMeta.hasDisplayName()
- && sfitemMeta.hasDisplayName()
- && !itemMeta.getDisplayName().equals(sfitemMeta.getDisplayName())) {
+ && sfitemMeta.hasDisplayName()
+ && !itemMeta.getDisplayName().equals(sfitemMeta.getDisplayName())) {
return false;
} else if (checkLore) {
boolean hasItemMetaLore = itemMeta.hasLore();
@@ -480,14 +457,15 @@ private static boolean equalsItemMeta(
boolean hasItemMetaCustomModelData = itemMeta.hasCustomModelData();
boolean hasSfItemMetaCustomModelData = sfitemMeta.hasCustomModelData();
if (hasItemMetaCustomModelData
- && hasSfItemMetaCustomModelData
- && itemMeta.getCustomModelData() != sfitemMeta.getCustomModelData()) {
+ && hasSfItemMetaCustomModelData
+ && itemMeta.getCustomModelData() != sfitemMeta.getCustomModelData()) {
return false;
} else if (hasItemMetaCustomModelData != hasSfItemMetaCustomModelData) {
return false;
}
}
+
if (itemMeta instanceof PotionMeta && sfitemMeta instanceof PotionMeta) {
return ((PotionMeta) itemMeta).getBasePotionData().equals(((PotionMeta) sfitemMeta).getBasePotionData());
}
@@ -499,11 +477,8 @@ private static boolean equalsItemMeta(
* This checks if the two provided lores are equal.
* This method will ignore any lines such as the soulbound one.
*
- * @param lore1
- * The first lore
- * @param lore2
- * The second lore
- *
+ * @param lore1 The first lore
+ * @param lore2 The second lore
* @return Whether the two lores are equal
*/
public static boolean equalsLore(@Nonnull List lore1, @Nonnull List lore2) {
@@ -558,13 +533,9 @@ public static void updateCapacitorTexture(@Nonnull Location l, int charge, int c
*
* If you already have an instance of {@link SlimefunItem}, please use {@link SlimefunItem#canUse(Player, boolean)}.
*
- * @param p
- * The {@link Player}
- * @param item
- * The {@link ItemStack} to check
- * @param sendMessage
- * Whether to send a message response to the {@link Player}
- *
+ * @param p The {@link Player}
+ * @param item The {@link ItemStack} to check
+ * @param sendMessage Whether to send a message response to the {@link Player}
* @return Whether the {@link Player} is able to use that item.
*/
public static boolean canPlayerUseItem(@Nonnull Player p, @Nullable ItemStack item, boolean sendMessage) {
@@ -584,22 +555,16 @@ public static boolean canPlayerUseItem(@Nonnull Player p, @Nullable ItemStack it
* This method automatically calls a {@link SlimefunItemSpawnEvent} to allow
* other plugins to catch the item being dropped.
*
- * @param loc
- * The {@link Location} where to drop the item
- * @param item
- * The {@link ItemStack} to drop
- * @param reason
- * The {@link ItemSpawnReason} why the item is being dropped
- * @param addRandomOffset
- * Whether a random offset should be added (see {@link World#dropItemNaturally(Location, ItemStack)})
- * @param player
- * The player that caused this {@link SlimefunItemSpawnEvent}
- *
+ * @param loc The {@link Location} where to drop the item
+ * @param item The {@link ItemStack} to drop
+ * @param reason The {@link ItemSpawnReason} why the item is being dropped
+ * @param addRandomOffset Whether a random offset should be added (see {@link World#dropItemNaturally(Location, ItemStack)})
+ * @param player The player that caused this {@link SlimefunItemSpawnEvent}
* @return The dropped {@link Item} (or null if the {@link SlimefunItemSpawnEvent} was cancelled)
*/
@ParametersAreNonnullByDefault
public static @Nullable Item spawnItem(
- Location loc, ItemStack item, ItemSpawnReason reason, boolean addRandomOffset, @Nullable Player player) {
+ Location loc, ItemStack item, ItemSpawnReason reason, boolean addRandomOffset, @Nullable Player player) {
SlimefunItemSpawnEvent event = new SlimefunItemSpawnEvent(player, loc, item, reason);
Slimefun.instance().getServer().getPluginManager().callEvent(event);
@@ -621,20 +586,15 @@ public static boolean canPlayerUseItem(@Nonnull Player p, @Nullable ItemStack it
* This method automatically calls a {@link SlimefunItemSpawnEvent} to allow
* other plugins to catch the item being dropped.
*
- * @param loc
- * The {@link Location} where to drop the item
- * @param item
- * The {@link ItemStack} to drop
- * @param reason
- * The {@link ItemSpawnReason} why the item is being dropped
- * @param addRandomOffset
- * Whether a random offset should be added (see {@link World#dropItemNaturally(Location, ItemStack)})
- *
+ * @param loc The {@link Location} where to drop the item
+ * @param item The {@link ItemStack} to drop
+ * @param reason The {@link ItemSpawnReason} why the item is being dropped
+ * @param addRandomOffset Whether a random offset should be added (see {@link World#dropItemNaturally(Location, ItemStack)})
* @return The dropped {@link Item} (or null if the {@link SlimefunItemSpawnEvent} was cancelled)
*/
@ParametersAreNonnullByDefault
public static @Nullable Item spawnItem(
- Location loc, ItemStack item, ItemSpawnReason reason, boolean addRandomOffset) {
+ Location loc, ItemStack item, ItemSpawnReason reason, boolean addRandomOffset) {
return spawnItem(loc, item, reason, addRandomOffset, null);
}
@@ -643,13 +603,9 @@ public static boolean canPlayerUseItem(@Nonnull Player p, @Nullable ItemStack it
* This method automatically calls a {@link SlimefunItemSpawnEvent} to allow
* other plugins to catch the item being dropped.
*
- * @param loc
- * The {@link Location} where to drop the item
- * @param item
- * The {@link ItemStack} to drop
- * @param reason
- * The {@link ItemSpawnReason} why the item is being dropped
- *
+ * @param loc The {@link Location} where to drop the item
+ * @param item The {@link ItemStack} to drop
+ * @param reason The {@link ItemSpawnReason} why the item is being dropped
* @return The dropped {@link Item} (or null if the {@link SlimefunItemSpawnEvent} was cancelled)
*/
@ParametersAreNonnullByDefault
@@ -662,9 +618,7 @@ public static boolean canPlayerUseItem(@Nonnull Player p, @Nullable ItemStack it
* If the MC version is 1.16 or above
* this will call {@link Inventory#isEmpty()} (Which calls MC code resulting in a faster method).
*
- * @param inventory
- * The {@link Inventory} to check.
- *
+ * @param inventory The {@link Inventory} to check.
* @return True if the inventory is empty and false otherwise
*/
public static boolean isInventoryEmpty(@Nonnull Inventory inventory) {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/biomes/BiomeMap.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/biomes/BiomeMap.java
index 71a6d111e1..2f1804f155 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/biomes/BiomeMap.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/biomes/BiomeMap.java
@@ -133,7 +133,7 @@ public boolean remove(@Nonnull Biome biome) {
*/
@Override
public String toString() {
- return "BiomeMap " + dataMap.toString();
+ return "BiomeMap " + dataMap;
}
@ParametersAreNonnullByDefault
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/biomes/BiomeMapParser.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/biomes/BiomeMapParser.java
index 07ecfcd17b..79623d0e9a 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/biomes/BiomeMapParser.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/biomes/BiomeMapParser.java
@@ -95,7 +95,7 @@ public boolean isLenient() {
public void read(@Nonnull String json) throws BiomeMapException {
Validate.notNull(json, "The JSON string should not be null!");
- JsonArray root = null;
+ JsonArray root;
try {
root = JsonUtils.parseString(json).getAsJsonArray();
@@ -119,7 +119,7 @@ public void read(@Nonnull JsonArray json) throws BiomeMapException {
} else {
throw new BiomeMapException(
key,
- "Unexpected array element: " + element.getClass().getSimpleName() + " - " + element.toString());
+ "Unexpected array element: " + element.getClass().getSimpleName() + " - " + element);
}
}
}
@@ -185,7 +185,7 @@ private void readEntry(@Nonnull JsonObject entry) throws BiomeMapException {
} else {
throw new BiomeMapException(
key,
- "Unexpected array element: " + element.getClass().getSimpleName() + " - " + element.toString());
+ "Unexpected array element: " + element.getClass().getSimpleName() + " - " + element);
}
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/ItemStackWrapper.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/ItemStackWrapper.java
index c8d2a9e79d..27b08ed530 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/ItemStackWrapper.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/ItemStackWrapper.java
@@ -12,7 +12,7 @@
/**
* This {@link ItemStack}, which is not intended for actual usage, caches its {@link ItemMeta}.
* This significantly speeds up any {@link ItemStack} comparisons a lot.
- *
+ *
* You cannot invoke {@link #equals(Object)}, {@link #hashCode()} or any of its setter on an
* {@link ItemStackWrapper}.
* Please be very careful when using this.
@@ -79,13 +79,14 @@ public int hashCode() {
throw new UnsupportedOperationException(ERROR_MESSAGE);
}
+ @Nonnull
@Override
public ItemStack clone() {
throw new UnsupportedOperationException(ERROR_MESSAGE);
}
@Override
- public void setType(Material type) {
+ public void setType(@Nonnull Material type) {
throw new UnsupportedOperationException(ERROR_MESSAGE);
}
@@ -100,7 +101,7 @@ public boolean setItemMeta(ItemMeta itemMeta) {
}
@Override
- public void addUnsafeEnchantment(Enchantment ench, int level) {
+ public void addUnsafeEnchantment(@Nonnull Enchantment ench, int level) {
throw new UnsupportedOperationException(ERROR_MESSAGE);
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java
index ea71dab799..8e48622e9c 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java
@@ -326,7 +326,7 @@ public void reload() throws TagMisconfigurationException {
/**
* This method reloads every single {@link SlimefunTag} from the resources directory.
* It is equivalent to running {@link #reload()} on every single {@link SlimefunTag} manually.
- *
+ *
* Do keep in mind though that any misconfigured {@link SlimefunTag} will abort the entire
* method and throw a {@link TagMisconfigurationException}. So one faulty {@link SlimefunTag}
* will stop the reloading process.
@@ -393,7 +393,7 @@ public boolean isEmpty() {
/**
* This returns a {@link Set} of {@link Tag Tags} which are children of this {@link SlimefunTag},
* these can be other {@link SlimefunTag SlimefunTags} or regular {@link Tag Tags}.
- *
+ *
* The returned {@link Set} is immutable
*
* @return An immutable {@link Set} of all sub tags.
diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java
index e3f78a6129..07c0c6d37d 100644
--- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java
+++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java
@@ -71,7 +71,7 @@ protected BlockBreakHandler onBlockBreak() {
return new SimpleBlockBreakHandler() {
@Override
- public void onBlockBreak(Block b) {
+ public void onBlockBreak(@Nonnull Block b) {
BlockMenu inv = StorageCacheUtils.getMenu(b.getLocation());
if (inv != null) {
diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java
index d312bf2db9..3f3078787e 100644
--- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java
+++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java
@@ -93,7 +93,7 @@ protected BlockBreakHandler onBlockBreak() {
return new SimpleBlockBreakHandler() {
@Override
- public void onBlockBreak(Block b) {
+ public void onBlockBreak(@Nonnull Block b) {
BlockMenu inv = StorageCacheUtils.getMenu(b.getLocation());
if (inv != null) {