From 477cad548702528c538b518b4fffa33b148963a0 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 29 May 2021 00:40:32 +0200 Subject: [PATCH] Fixed #3085 --- CHANGELOG.md | 1 + .../core/machines/MachineProcessor.java | 15 ++++-------- .../electric/machines/ElectricDustWasher.java | 24 +++++++++++-------- .../electric/machines/ElectricOreGrinder.java | 3 +++ .../operations/CraftingOperation.java | 8 +++---- .../operations/MiningOperation.java | 2 +- 6 files changed, 27 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 971746ac7..9aba1345f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ * Fixed #3075 * Fixed recipe types showing missing string message * Fixed #3084 +* Fixed #3085 ## Release Candidate 23 (19 May 2021) https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#23 diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/machines/MachineProcessor.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/machines/MachineProcessor.java index a9a1bc5e3..5d192ee74 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/machines/MachineProcessor.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/machines/MachineProcessor.java @@ -55,8 +55,7 @@ public class MachineProcessor { * * @return The owner / holder */ - @Nonnull - public MachineProcessHolder getOwner() { + public @Nonnull MachineProcessHolder getOwner() { return owner; } @@ -66,8 +65,7 @@ public class MachineProcessor { * * @return The progress bar icon or null */ - @Nullable - public ItemStack getProgressBar() { + public @Nullable ItemStack getProgressBar() { return progressBar; } @@ -144,8 +142,7 @@ public class MachineProcessor { * * @return The current {@link MachineOperation} or null. */ - @Nullable - public T getOperation(@Nonnull Location loc) { + public @Nullable T getOperation(@Nonnull Location loc) { Validate.notNull(loc, "The location cannot be null"); return getOperation(new BlockPosition(loc)); @@ -159,8 +156,7 @@ public class MachineProcessor { * * @return The current {@link MachineOperation} or null. */ - @Nullable - public T getOperation(@Nonnull Block b) { + public @Nullable T getOperation(@Nonnull Block b) { Validate.notNull(b, "The Block cannot be null"); return getOperation(new BlockPosition(b)); @@ -176,8 +172,7 @@ public class MachineProcessor { * * @return The current {@link MachineOperation} or null. */ - @Nullable - public T getOperation(@Nonnull BlockPosition pos) { + public @Nullable T getOperation(@Nonnull BlockPosition pos) { Validate.notNull(pos, "The BlockPosition must not be null"); return machines.get(pos); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricDustWasher.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricDustWasher.java index 9d349b87f..d1e0bb0d6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricDustWasher.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricDustWasher.java @@ -1,5 +1,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; +import javax.annotation.ParametersAreNonnullByDefault; + import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -14,24 +16,26 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecip import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; +/** + * The {@link ElectricDustWasher} serves as an electrical {@link OreWasher}. + * + * @author TheBusyBiscuit + * + * @see OreWasher + * + */ public class ElectricDustWasher extends AContainer { - private OreWasher oreWasher; + private final OreWasher oreWasher = SlimefunItems.ORE_WASHER.getItem(OreWasher.class); private final boolean legacyMode; + @ParametersAreNonnullByDefault public ElectricDustWasher(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); legacyMode = SlimefunPlugin.getCfg().getBoolean("options.legacy-dust-washer"); } - @Override - public void preRegister() { - super.preRegister(); - - oreWasher = (OreWasher) SlimefunItems.ORE_WASHER.getItem(); - } - @Override public ItemStack getProgressBar() { return new ItemStack(Material.GOLDEN_SHOVEL); @@ -46,14 +50,14 @@ public class ElectricDustWasher extends AContainer { } ItemStack dust = oreWasher.getRandomDust(); - MachineRecipe recipe = new MachineRecipe(4 / getSpeed(), new ItemStack[0], new ItemStack[] { dust }); + MachineRecipe recipe = new MachineRecipe(4 / getSpeed(), new ItemStack[] { SlimefunItems.SIFTED_ORE }, new ItemStack[] { dust }); if (!legacyMode || menu.fits(recipe.getOutput()[0], getOutputSlots())) { menu.consumeItem(slot); return recipe; } } else if (SlimefunUtils.isItemSimilar(menu.getItemInSlot(slot), SlimefunItems.PULVERIZED_ORE, true)) { - MachineRecipe recipe = new MachineRecipe(4 / getSpeed(), new ItemStack[0], new ItemStack[] { SlimefunItems.PURE_ORE_CLUSTER }); + MachineRecipe recipe = new MachineRecipe(4 / getSpeed(), new ItemStack[] { SlimefunItems.PULVERIZED_ORE }, new ItemStack[] { SlimefunItems.PURE_ORE_CLUSTER }); if (menu.fits(recipe.getOutput()[0], getOutputSlots())) { menu.consumeItem(slot); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricOreGrinder.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricOreGrinder.java index 2a8675258..fde1aaf18 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricOreGrinder.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricOreGrinder.java @@ -1,5 +1,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; +import javax.annotation.ParametersAreNonnullByDefault; + import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -12,6 +14,7 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; public class ElectricOreGrinder extends AContainer implements RecipeDisplayItem, NotHopperable { + @ParametersAreNonnullByDefault public ElectricOreGrinder(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/operations/CraftingOperation.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/operations/CraftingOperation.java index 123e90538..fee609aca 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/operations/CraftingOperation.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/operations/CraftingOperation.java @@ -29,7 +29,7 @@ public class CraftingOperation implements MachineOperation { public CraftingOperation(@Nonnull ItemStack[] ingredients, @Nonnull ItemStack[] results, int totalTicks) { Validate.notEmpty(ingredients, "The Ingredients array cannot be empty or null"); Validate.notEmpty(results, "The results array cannot be empty or null"); - Validate.isTrue(totalTicks > 0, "The amount of total ticks must be a positive integer"); + Validate.isTrue(totalTicks >= 0, "The amount of total ticks must be a positive integer or zero, received: " + totalTicks); this.ingredients = ingredients; this.results = results; @@ -42,13 +42,11 @@ public class CraftingOperation implements MachineOperation { currentTicks += num; } - @Nonnull - public ItemStack[] getIngredients() { + public @Nonnull ItemStack[] getIngredients() { return ingredients; } - @Nonnull - public ItemStack[] getResults() { + public @Nonnull ItemStack[] getResults() { return results; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/operations/MiningOperation.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/operations/MiningOperation.java index 9ed542609..fca4dd8f2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/operations/MiningOperation.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/operations/MiningOperation.java @@ -27,7 +27,7 @@ public class MiningOperation implements MachineOperation { public MiningOperation(@Nonnull ItemStack result, int totalTicks) { Validate.notNull(result, "The result cannot be null"); - Validate.isTrue(totalTicks > 0, "The amount of total ticks must be a positive integer"); + Validate.isTrue(totalTicks >= 0, "The amount of total ticks must be a positive integer or zero, received: " + totalTicks); this.result = result; this.totalTicks = totalTicks;