From 1955d1235b4eee613f31085ac3e3140edfcf8b97 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 3 Apr 2021 19:40:54 +0200 Subject: [PATCH] [CI skip] Refactoring --- .../implementation/items/misc/GoldIngot.java | 60 +++++++++++++++++++ .../setup/SlimefunItemSetup.java | 23 +++---- 2 files changed, 72 insertions(+), 11 deletions(-) create mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/GoldIngot.java 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 new file mode 100644 index 000000000..2a7b4dec9 --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/GoldIngot.java @@ -0,0 +1,60 @@ +package io.github.thebusybiscuit.slimefun4.implementation.items.misc; + +import javax.annotation.ParametersAreNonnullByDefault; + +import org.apache.commons.lang.Validate; +import org.bukkit.inventory.ItemStack; + +import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.Smeltery; +import me.mrCookieSlime.Slimefun.Lists.RecipeType; +import me.mrCookieSlime.Slimefun.Objects.Category; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; +import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; + +/** + * The {@link GoldIngot} from Slimefun is a simple resource which is divided into different + * levels of carat ratings. + *

+ * It can be obtained via gold dust and other gold ingots in a {@link Smeltery}. + * + * @author TheBusyBiscuit + * + * @see Smeltery + * + */ +public class GoldIngot extends SlimefunItem { + + /** + * The carat rating. + */ + private final int caratRating; + + @ParametersAreNonnullByDefault + public GoldIngot(Category category, int caratRating, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { + super(category, item, recipeType, recipe); + + Validate.isTrue(caratRating > 0, "Carat must be above zero."); + Validate.isTrue(caratRating < 24, "Carat cannot go above 24."); + this.caratRating = caratRating; + } + + /** + * This returns the carat rating of this {@link GoldIngot}. + *

+ * The purity of the {@link GoldIngot} is measured in carat. + * + *

+     * 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/setup/SlimefunItemSetup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java index 70bf2121a..d4016d5e6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java @@ -159,6 +159,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.medical.Splint; import io.github.thebusybiscuit.slimefun4.implementation.items.medical.Vitamins; import io.github.thebusybiscuit.slimefun4.implementation.items.misc.BasicCircuitBoard; import io.github.thebusybiscuit.slimefun4.implementation.items.misc.CoolantCell; +import io.github.thebusybiscuit.slimefun4.implementation.items.misc.GoldIngot; import io.github.thebusybiscuit.slimefun4.implementation.items.misc.OrganicFertilizer; import io.github.thebusybiscuit.slimefun4.implementation.items.misc.OrganicFood; import io.github.thebusybiscuit.slimefun4.implementation.items.misc.SteelThruster; @@ -717,47 +718,47 @@ public final class SlimefunItemSetup { new OreWasher(categories.basicMachines, SlimefunItems.ORE_WASHER).register(plugin); - new SlimefunItem(categories.resources, SlimefunItems.GOLD_24K, RecipeType.SMELTERY, + new GoldIngot(categories.resources, 24, SlimefunItems.GOLD_24K, RecipeType.SMELTERY, new ItemStack[] {SlimefunItems.GOLD_DUST, SlimefunItems.GOLD_22K, null, null, null, null, null, null, null}) .register(plugin); - new SlimefunItem(categories.resources, SlimefunItems.GOLD_22K, RecipeType.SMELTERY, + new GoldIngot(categories.resources, 22, SlimefunItems.GOLD_22K, RecipeType.SMELTERY, new ItemStack[] {SlimefunItems.GOLD_DUST, SlimefunItems.GOLD_20K, null, null, null, null, null, null, null}) .register(plugin); - new SlimefunItem(categories.resources, SlimefunItems.GOLD_20K, RecipeType.SMELTERY, + new GoldIngot(categories.resources, 20, SlimefunItems.GOLD_20K, RecipeType.SMELTERY, new ItemStack[] {SlimefunItems.GOLD_DUST, SlimefunItems.GOLD_18K, null, null, null, null, null, null, null}) .register(plugin); - new SlimefunItem(categories.resources, SlimefunItems.GOLD_18K, RecipeType.SMELTERY, + new GoldIngot(categories.resources, 18, SlimefunItems.GOLD_18K, RecipeType.SMELTERY, new ItemStack[] {SlimefunItems.GOLD_DUST, SlimefunItems.GOLD_16K, null, null, null, null, null, null, null}) .register(plugin); - new SlimefunItem(categories.resources, SlimefunItems.GOLD_16K, RecipeType.SMELTERY, + new GoldIngot(categories.resources, 16, SlimefunItems.GOLD_16K, RecipeType.SMELTERY, new ItemStack[] {SlimefunItems.GOLD_DUST, SlimefunItems.GOLD_14K, null, null, null, null, null, null, null}) .register(plugin); - new SlimefunItem(categories.resources, SlimefunItems.GOLD_14K, RecipeType.SMELTERY, + new GoldIngot(categories.resources, 14, SlimefunItems.GOLD_14K, RecipeType.SMELTERY, new ItemStack[] {SlimefunItems.GOLD_DUST, SlimefunItems.GOLD_12K, null, null, null, null, null, null, null}) .register(plugin); - new SlimefunItem(categories.resources, SlimefunItems.GOLD_12K, RecipeType.SMELTERY, + new GoldIngot(categories.resources, 12, SlimefunItems.GOLD_12K, RecipeType.SMELTERY, new ItemStack[] {SlimefunItems.GOLD_DUST, SlimefunItems.GOLD_10K, null, null, null, null, null, null, null}) .register(plugin); - new SlimefunItem(categories.resources, SlimefunItems.GOLD_10K, RecipeType.SMELTERY, + new GoldIngot(categories.resources, 10, SlimefunItems.GOLD_10K, RecipeType.SMELTERY, new ItemStack[] {SlimefunItems.GOLD_DUST, SlimefunItems.GOLD_8K, null, null, null, null, null, null, null}) .register(plugin); - new SlimefunItem(categories.resources, SlimefunItems.GOLD_8K, RecipeType.SMELTERY, + new GoldIngot(categories.resources, 8, SlimefunItems.GOLD_8K, RecipeType.SMELTERY, new ItemStack[] {SlimefunItems.GOLD_DUST, SlimefunItems.GOLD_6K, null, null, null, null, null, null, null}) .register(plugin); - new SlimefunItem(categories.resources, SlimefunItems.GOLD_6K, RecipeType.SMELTERY, + new GoldIngot(categories.resources, 6, SlimefunItems.GOLD_6K, RecipeType.SMELTERY, new ItemStack[] {SlimefunItems.GOLD_DUST, SlimefunItems.GOLD_4K, null, null, null, null, null, null, null}) .register(plugin); - new SlimefunItem(categories.resources, SlimefunItems.GOLD_4K, RecipeType.SMELTERY, + new GoldIngot(categories.resources, 4, SlimefunItems.GOLD_4K, RecipeType.SMELTERY, new ItemStack[] {SlimefunItems.GOLD_DUST, null, null, null, null, null, null, null, null}) .setUseableInWorkbench(true) .register(plugin);