From 527dfb2b796504b770413ff07f6fbff7107feacd Mon Sep 17 00:00:00 2001 From: CURVX Date: Thu, 12 Nov 2020 22:20:36 +0530 Subject: [PATCH 01/20] Been a while --- .../implementation/SlimefunPlugin.java | 2 ++ .../items/electric/machines/AutoBrewer.java | 3 +- .../items/electric/machines/AutoDrier.java | 3 +- .../electric/machines/ElectricFurnace.java | 3 +- .../machines/ElectricIngotPulverizer.java | 3 +- .../electric/machines/ElectricOreGrinder.java | 3 +- .../electric/machines/ElectricSmeltery.java | 3 +- .../listeners/crafting/HopperListener.java | 36 +++++++++++++++++++ .../abstractItems/VanillaContainer.java | 17 +++++++++ 9 files changed, 67 insertions(+), 6 deletions(-) create mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/HopperListener.java create mode 100644 src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/VanillaContainer.java diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java index f0c5efa8a..c6ae714e6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java @@ -98,6 +98,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.Cart import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.CauldronListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.CraftingTableListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.GrindstoneListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.HopperListener; import io.github.thebusybiscuit.slimefun4.implementation.resources.GEOResourcesSetup; import io.github.thebusybiscuit.slimefun4.implementation.setup.PostSetup; import io.github.thebusybiscuit.slimefun4.implementation.setup.ResearchSetup; @@ -475,6 +476,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { new CauldronListener(this); new GrindstoneListener(this); new CartographyTableListener(this); + new HopperListener(this); if (minecraftVersion.isAtLeast(MinecraftVersion.MINECRAFT_1_15)) { new BeeListener(this); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBrewer.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBrewer.java index 627fe50a9..c9f0d05da 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBrewer.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBrewer.java @@ -5,6 +5,7 @@ import java.util.Map; import javax.annotation.Nonnull; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.VanillaContainer; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.PotionMeta; @@ -26,7 +27,7 @@ import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; * @author Linox * */ -public class AutoBrewer extends AContainer { +public class AutoBrewer extends VanillaContainer { private static final Map potionRecipes = new EnumMap<>(Material.class); private static final Map fermentations = new EnumMap<>(PotionType.class); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDrier.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDrier.java index 9273af6b4..188399887 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDrier.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDrier.java @@ -3,6 +3,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machine import java.util.ArrayList; import java.util.List; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.VanillaContainer; import org.bukkit.Material; import org.bukkit.Tag; import org.bukkit.inventory.ItemStack; @@ -22,7 +23,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; * @author Linox * */ -public class AutoDrier extends AContainer implements RecipeDisplayItem { +public class AutoDrier extends VanillaContainer implements RecipeDisplayItem { private List recipeList; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricFurnace.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricFurnace.java index 8d70af663..0becc3e37 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricFurnace.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricFurnace.java @@ -1,5 +1,6 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.VanillaContainer; import org.bukkit.Material; import org.bukkit.inventory.FurnaceRecipe; import org.bukkit.inventory.ItemStack; @@ -12,7 +13,7 @@ import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; -public class ElectricFurnace extends AContainer { +public class ElectricFurnace extends VanillaContainer { public ElectricFurnace(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricIngotPulverizer.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricIngotPulverizer.java index 1fe511565..d50e3fe7b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricIngotPulverizer.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricIngotPulverizer.java @@ -3,6 +3,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machine import java.util.ArrayList; import java.util.List; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.VanillaContainer; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -23,7 +24,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; * @see ElectricIngotFactory * */ -public class ElectricIngotPulverizer extends AContainer implements RecipeDisplayItem { +public class ElectricIngotPulverizer extends VanillaContainer implements RecipeDisplayItem { public ElectricIngotPulverizer(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricOreGrinder.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricOreGrinder.java index 50187ea92..953795a2f 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,6 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.VanillaContainer; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -9,7 +10,7 @@ import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; -public class ElectricOreGrinder extends AContainer implements RecipeDisplayItem { +public class ElectricOreGrinder extends VanillaContainer implements RecipeDisplayItem { 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/items/electric/machines/ElectricSmeltery.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricSmeltery.java index 4848b0514..a5f5eb43f 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 @@ -5,6 +5,7 @@ import java.util.Comparator; import java.util.LinkedList; import java.util.List; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.VanillaContainer; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.Player; @@ -35,7 +36,7 @@ import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow; * @author TheBusyBiscuit * */ -public class ElectricSmeltery extends AContainer { +public class ElectricSmeltery extends VanillaContainer { private static final int[] border = { 4, 5, 6, 7, 8, 13, 31, 40, 41, 42, 43, 44 }; private static final int[] inputBorder = { 0, 1, 2, 3, 9, 12, 18, 21, 27, 30, 36, 37, 38, 39 }; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/HopperListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/HopperListener.java new file mode 100644 index 000000000..fd12aa234 --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/HopperListener.java @@ -0,0 +1,36 @@ +package io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting; + +import javax.annotation.Nonnull; + +import org.bukkit.Location; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.InventoryMoveItemEvent; +import org.bukkit.event.inventory.InventoryType; + +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.VanillaContainer; +import me.mrCookieSlime.Slimefun.api.BlockStorage; + +/** + * This {@link Listener} prevents item from being transferred to a + * {@link VanillaContainer} using a hopper. + * + */ + +public class HopperListener implements SlimefunCraftingListener { + + public HopperListener(@Nonnull SlimefunPlugin plugin) { + plugin.getServer().getPluginManager().registerEvents(this, plugin); + } + + @EventHandler + public void fromHopper(InventoryMoveItemEvent e) { + Location loc = e.getDestination().getLocation(); + if (e.getSource().getType() == InventoryType.HOPPER && loc != null && BlockStorage.hasBlockInfo(loc)) { + if (BlockStorage.check(loc.getBlock()) instanceof VanillaContainer) { + e.setCancelled(true); + } + } + } +} diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/VanillaContainer.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/VanillaContainer.java new file mode 100644 index 000000000..aef1de788 --- /dev/null +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/VanillaContainer.java @@ -0,0 +1,17 @@ +package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems; + +import javax.annotation.ParametersAreNonnullByDefault; + +import org.bukkit.inventory.ItemStack; + +import me.mrCookieSlime.Slimefun.Lists.RecipeType; +import me.mrCookieSlime.Slimefun.Objects.Category; +import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; + +public abstract class VanillaContainer extends AContainer { + + @ParametersAreNonnullByDefault + public VanillaContainer(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { + super(category, item, recipeType, recipe); + } +} \ No newline at end of file From 7f385cdc8d7c7202dbd9aa0fa2b8d3aa26695083 Mon Sep 17 00:00:00 2001 From: CURVX Date: Sat, 21 Nov 2020 22:17:55 +0530 Subject: [PATCH 02/20] Formatting changes --- .../AbstractVanillaBlockInventory.java | 39 +++++++++++++++++++ .../items/electric/machines/AutoBrewer.java | 5 +-- .../items/electric/machines/AutoDrier.java | 4 +- .../electric/machines/ElectricFurnace.java | 5 +-- .../machines/ElectricIngotPulverizer.java | 4 +- .../electric/machines/ElectricOreGrinder.java | 5 +-- .../electric/machines/ElectricSmeltery.java | 5 +-- .../listeners/crafting/HopperListener.java | 12 +++--- .../abstractItems/VanillaContainer.java | 17 -------- 9 files changed, 57 insertions(+), 39 deletions(-) create mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/api/inventory/AbstractVanillaBlockInventory.java delete mode 100644 src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/VanillaContainer.java diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/inventory/AbstractVanillaBlockInventory.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/inventory/AbstractVanillaBlockInventory.java new file mode 100644 index 000000000..c4d3002f3 --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/inventory/AbstractVanillaBlockInventory.java @@ -0,0 +1,39 @@ +package io.github.thebusybiscuit.slimefun4.api.inventory; + +import javax.annotation.ParametersAreNonnullByDefault; + +import org.bukkit.inventory.ItemStack; + +import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.AutoBrewer; +import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.AutoDrier; +import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.ElectricFurnace; +import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.ElectricIngotPulverizer; +import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.ElectricOreGrinder; +import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.ElectricSmeltery; +import me.mrCookieSlime.Slimefun.Lists.RecipeType; +import me.mrCookieSlime.Slimefun.Objects.Category; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; +import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; + +/** + * The {@link AbstractVanillaBlockInventory} is an + * implementation of {@link AContainer} for machines that use + * a vanilla block inventory holder. + * + * @author CURVX + * + * @see AutoBrewer + * @see AutoDrier + * @see ElectricFurnace + * @see ElectricIngotPulverizer + * @see ElectricOreGrinder + * @see ElectricSmeltery + * + */ +public abstract class AbstractVanillaBlockInventory extends AContainer { + + @ParametersAreNonnullByDefault + public AbstractVanillaBlockInventory(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { + super(category, item, recipeType, recipe); + } +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBrewer.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBrewer.java index c9f0d05da..84c3620a4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBrewer.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBrewer.java @@ -5,7 +5,6 @@ import java.util.Map; import javax.annotation.Nonnull; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.VanillaContainer; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.PotionMeta; @@ -13,9 +12,9 @@ import org.bukkit.potion.PotionData; import org.bukkit.potion.PotionType; import io.github.thebusybiscuit.cscorelib2.inventory.InvUtils; +import io.github.thebusybiscuit.slimefun4.api.inventory.AbstractVanillaBlockInventory; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; @@ -27,7 +26,7 @@ import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; * @author Linox * */ -public class AutoBrewer extends VanillaContainer { +public class AutoBrewer extends AbstractVanillaBlockInventory { private static final Map potionRecipes = new EnumMap<>(Material.class); private static final Map fermentations = new EnumMap<>(PotionType.class); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDrier.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDrier.java index 188399887..7dff16a33 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDrier.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDrier.java @@ -3,7 +3,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machine import java.util.ArrayList; import java.util.List; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.VanillaContainer; +import io.github.thebusybiscuit.slimefun4.api.inventory.AbstractVanillaBlockInventory; import org.bukkit.Material; import org.bukkit.Tag; import org.bukkit.inventory.ItemStack; @@ -23,7 +23,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; * @author Linox * */ -public class AutoDrier extends VanillaContainer implements RecipeDisplayItem { +public class AutoDrier extends AbstractVanillaBlockInventory implements RecipeDisplayItem { private List recipeList; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricFurnace.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricFurnace.java index 0becc3e37..0c034149d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricFurnace.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricFurnace.java @@ -1,19 +1,18 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.VanillaContainer; import org.bukkit.Material; import org.bukkit.inventory.FurnaceRecipe; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.RecipeChoice; import org.bukkit.inventory.RecipeChoice.MaterialChoice; +import io.github.thebusybiscuit.slimefun4.api.inventory.AbstractVanillaBlockInventory; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; -public class ElectricFurnace extends VanillaContainer { +public class ElectricFurnace extends AbstractVanillaBlockInventory { public ElectricFurnace(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricIngotPulverizer.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricIngotPulverizer.java index d50e3fe7b..5b3ac2859 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricIngotPulverizer.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricIngotPulverizer.java @@ -3,7 +3,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machine import java.util.ArrayList; import java.util.List; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.VanillaContainer; +import io.github.thebusybiscuit.slimefun4.api.inventory.AbstractVanillaBlockInventory; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -24,7 +24,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; * @see ElectricIngotFactory * */ -public class ElectricIngotPulverizer extends VanillaContainer implements RecipeDisplayItem { +public class ElectricIngotPulverizer extends AbstractVanillaBlockInventory implements RecipeDisplayItem { public ElectricIngotPulverizer(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricOreGrinder.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricOreGrinder.java index 953795a2f..e28ec9a24 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,16 +1,15 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.VanillaContainer; +import io.github.thebusybiscuit.slimefun4.api.inventory.AbstractVanillaBlockInventory; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; -public class ElectricOreGrinder extends VanillaContainer implements RecipeDisplayItem { +public class ElectricOreGrinder extends AbstractVanillaBlockInventory implements RecipeDisplayItem { 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/items/electric/machines/ElectricSmeltery.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricSmeltery.java index a5f5eb43f..6c29a3337 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 @@ -5,7 +5,6 @@ import java.util.Comparator; import java.util.LinkedList; import java.util.List; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.VanillaContainer; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.Player; @@ -14,6 +13,7 @@ import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.cscorelib2.item.CustomItem; import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction; +import io.github.thebusybiscuit.slimefun4.api.inventory.AbstractVanillaBlockInventory; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.Smeltery; import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; @@ -22,7 +22,6 @@ import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.AdvancedMenu import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; @@ -36,7 +35,7 @@ import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow; * @author TheBusyBiscuit * */ -public class ElectricSmeltery extends VanillaContainer { +public class ElectricSmeltery extends AbstractVanillaBlockInventory { private static final int[] border = { 4, 5, 6, 7, 8, 13, 31, 40, 41, 42, 43, 44 }; private static final int[] inputBorder = { 0, 1, 2, 3, 9, 12, 18, 21, 27, 30, 36, 37, 38, 39 }; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/HopperListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/HopperListener.java index fd12aa234..5d62a2131 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/HopperListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/HopperListener.java @@ -2,6 +2,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting; import javax.annotation.Nonnull; +import io.github.thebusybiscuit.slimefun4.api.inventory.AbstractVanillaBlockInventory; import org.bukkit.Location; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -9,12 +10,13 @@ import org.bukkit.event.inventory.InventoryMoveItemEvent; import org.bukkit.event.inventory.InventoryType; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.VanillaContainer; import me.mrCookieSlime.Slimefun.api.BlockStorage; /** * This {@link Listener} prevents item from being transferred to a - * {@link VanillaContainer} using a hopper. + * {@link AbstractVanillaBlockInventory} using a hopper. + * + * @author CURVX * */ @@ -25,12 +27,10 @@ public class HopperListener implements SlimefunCraftingListener { } @EventHandler - public void fromHopper(InventoryMoveItemEvent e) { + public void onHopperInsert(InventoryMoveItemEvent e) { Location loc = e.getDestination().getLocation(); - if (e.getSource().getType() == InventoryType.HOPPER && loc != null && BlockStorage.hasBlockInfo(loc)) { - if (BlockStorage.check(loc.getBlock()) instanceof VanillaContainer) { + if (e.getSource().getType() == InventoryType.HOPPER && loc != null && BlockStorage.check(loc.getBlock()) instanceof AbstractVanillaBlockInventory) { e.setCancelled(true); - } } } } diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/VanillaContainer.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/VanillaContainer.java deleted file mode 100644 index aef1de788..000000000 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/VanillaContainer.java +++ /dev/null @@ -1,17 +0,0 @@ -package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems; - -import javax.annotation.ParametersAreNonnullByDefault; - -import org.bukkit.inventory.ItemStack; - -import me.mrCookieSlime.Slimefun.Lists.RecipeType; -import me.mrCookieSlime.Slimefun.Objects.Category; -import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; - -public abstract class VanillaContainer extends AContainer { - - @ParametersAreNonnullByDefault - public VanillaContainer(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { - super(category, item, recipeType, recipe); - } -} \ No newline at end of file From ef09b03af4a0da9a7336870a90c9b8fcd9464c4f Mon Sep 17 00:00:00 2001 From: CURVX Date: Sat, 21 Nov 2020 22:51:14 +0530 Subject: [PATCH 03/20] Blank line --- .../implementation/listeners/crafting/HopperListener.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/HopperListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/HopperListener.java index 5d62a2131..e43c56c7a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/HopperListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/HopperListener.java @@ -19,7 +19,6 @@ import me.mrCookieSlime.Slimefun.api.BlockStorage; * @author CURVX * */ - public class HopperListener implements SlimefunCraftingListener { public HopperListener(@Nonnull SlimefunPlugin plugin) { From 3f5fb7c7a70638b63bda68418af56920ffc6744b Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Tue, 12 Jan 2021 12:03:02 +0100 Subject: [PATCH 04/20] [Ci skip] Fixed javadocs and improved documentation --- pom.xml | 2 +- .../api/events/PlayerRightClickEvent.java | 10 +++--- .../slimefun4/core/SlimefunRegistry.java | 29 ++++++++++++---- .../slimefun4/core/guide/SlimefunGuide.java | 34 +++++++++++++------ .../core/services/github/Contributor.java | 4 +-- .../core/services/github/GitHubTask.java | 2 +- .../items/androids/ProgrammableAndroid.java | 1 + 7 files changed, 56 insertions(+), 26 deletions(-) diff --git a/pom.xml b/pom.xml index dba2fecb3..dd4b1f896 100644 --- a/pom.xml +++ b/pom.xml @@ -336,7 +336,7 @@ com.github.TheBusyBiscuit CS-CoreLib2 - 0.29 + 0.29.1 compile diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerRightClickEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerRightClickEvent.java index 4d09ebbed..f292df16e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerRightClickEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerRightClickEvent.java @@ -16,7 +16,7 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.cscorelib2.data.ComputedOptional; +import io.github.thebusybiscuit.cscorelib2.data.TriStateOptional; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.api.BlockStorage; @@ -46,8 +46,8 @@ public class PlayerRightClickEvent extends PlayerEvent { private final EquipmentSlot hand; private final BlockFace face; - private ComputedOptional slimefunItem = ComputedOptional.createNew(); - private ComputedOptional slimefunBlock = ComputedOptional.createNew(); + private TriStateOptional slimefunItem = TriStateOptional.createNew(); + private TriStateOptional slimefunBlock = TriStateOptional.createNew(); private Result itemResult; private Result blockResult; @@ -127,7 +127,7 @@ public class PlayerRightClickEvent extends PlayerEvent { if (itemStack.isPresent()) { slimefunItem.compute(SlimefunItem.getByItem(itemStack.get())); } else { - slimefunItem = ComputedOptional.empty(); + slimefunItem = TriStateOptional.empty(); } } @@ -140,7 +140,7 @@ public class PlayerRightClickEvent extends PlayerEvent { if (clickedBlock.isPresent()) { slimefunBlock.compute(BlockStorage.check(clickedBlock.get())); } else { - slimefunBlock = ComputedOptional.empty(); + slimefunBlock = TriStateOptional.empty(); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java index d2ae3524b..32ebf7f86 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java @@ -30,7 +30,6 @@ import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode; import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlock; import io.github.thebusybiscuit.slimefun4.core.researching.Research; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; - import io.github.thebusybiscuit.slimefun4.implementation.guide.CheatSheetSlimefunGuide; import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide; import me.mrCookieSlime.Slimefun.Objects.Category; @@ -82,7 +81,7 @@ public final class SlimefunRegistry { private final Map profiles = new ConcurrentHashMap<>(); private final Map worlds = new ConcurrentHashMap<>(); private final Map chunks = new HashMap<>(); - private final Map layouts = new EnumMap<>(SlimefunGuideMode.class); + private final Map guides = new EnumMap<>(SlimefunGuideMode.class); private final Map> mobDrops = new EnumMap<>(EntityType.class); private final Map blockMenuPresets = new HashMap<>(); @@ -99,8 +98,8 @@ public final class SlimefunRegistry { guideKey = new NamespacedKey(plugin, "slimefun_guide_mode"); boolean showVanillaRecipes = cfg.getBoolean("guide.show-vanilla-recipes"); - layouts.put(SlimefunGuideMode.SURVIVAL_MODE, new SurvivalSlimefunGuide(showVanillaRecipes)); - layouts.put(SlimefunGuideMode.CHEAT_MODE, new CheatSheetSlimefunGuide()); + guides.put(SlimefunGuideMode.SURVIVAL_MODE, new SurvivalSlimefunGuide(showVanillaRecipes)); + guides.put(SlimefunGuideMode.CHEAT_MODE, new CheatSheetSlimefunGuide()); researchRanks.addAll(cfg.getStringList("research-ranks")); @@ -199,8 +198,26 @@ public final class SlimefunRegistry { return multiblocks; } - public SlimefunGuideImplementation getGuideLayout(SlimefunGuideMode layout) { - return layouts.get(layout); + /** + * This returns the corresponding {@link SlimefunGuideImplementation} for a certain + * {@link SlimefunGuideMode}. + * + * @param mode + * The {@link SlimefunGuideMode} + * + * @return The corresponding {@link SlimefunGuideImplementation} + */ + @Nonnull + public SlimefunGuideImplementation getSlimefunGuide(@Nonnull SlimefunGuideMode mode) { + Validate.notNull(mode, "The Guide mode cannot be null"); + + SlimefunGuideImplementation guide = guides.get(mode); + + if (guide == null) { + throw new IllegalStateException("Slimefun Guide '" + mode + "' has no registered implementation."); + } + + return guide; } /** diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuide.java index 662320f53..370e9cff3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuide.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuide.java @@ -6,6 +6,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; +import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -14,6 +15,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide; import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun4.utils.itemstack.SlimefunGuideItem; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; @@ -33,7 +35,7 @@ public final class SlimefunGuide { @Nonnull public static ItemStack getItem(@Nonnull SlimefunGuideMode design) { - return SlimefunPlugin.getRegistry().getGuideLayout(design).getItem(); + return SlimefunPlugin.getRegistry().getSlimefunGuide(design).getItem(); } public static void openCheatMenu(@Nonnull Player p) { @@ -52,7 +54,7 @@ public final class SlimefunGuide { } } - public static void openGuide(@Nonnull Player p, @Nonnull SlimefunGuideMode layout) { + public static void openGuide(@Nonnull Player p, @Nonnull SlimefunGuideMode mode) { if (!SlimefunPlugin.getWorldSettingsService().isWorldEnabled(p.getWorld())) { return; } @@ -61,10 +63,10 @@ public final class SlimefunGuide { if (optional.isPresent()) { PlayerProfile profile = optional.get(); - SlimefunGuideImplementation guide = SlimefunPlugin.getRegistry().getGuideLayout(layout); + SlimefunGuideImplementation guide = SlimefunPlugin.getRegistry().getSlimefunGuide(mode); profile.getGuideHistory().openLastEntry(guide); } else { - openMainMenuAsync(p, layout, 1); + openMainMenuAsync(p, mode, 1); } } @@ -77,20 +79,20 @@ public final class SlimefunGuide { @ParametersAreNonnullByDefault public static void openMainMenu(PlayerProfile profile, SlimefunGuideMode layout, int selectedPage) { - SlimefunPlugin.getRegistry().getGuideLayout(layout).openMainMenu(profile, selectedPage); + SlimefunPlugin.getRegistry().getSlimefunGuide(layout).openMainMenu(profile, selectedPage); } @ParametersAreNonnullByDefault public static void openCategory(PlayerProfile profile, Category category, SlimefunGuideMode layout, int selectedPage) { - SlimefunPlugin.getRegistry().getGuideLayout(layout).openCategory(profile, category, selectedPage); + SlimefunPlugin.getRegistry().getSlimefunGuide(layout).openCategory(profile, category, selectedPage); } @ParametersAreNonnullByDefault public static void openSearch(PlayerProfile profile, String input, boolean survival, boolean addToHistory) { - SlimefunGuideImplementation layout = SlimefunPlugin.getRegistry().getGuideLayout(SlimefunGuideMode.SURVIVAL_MODE); + SlimefunGuideImplementation layout = SlimefunPlugin.getRegistry().getSlimefunGuide(SlimefunGuideMode.SURVIVAL_MODE); if (!survival) { - layout = SlimefunPlugin.getRegistry().getGuideLayout(SlimefunGuideMode.CHEAT_MODE); + layout = SlimefunPlugin.getRegistry().getSlimefunGuide(SlimefunGuideMode.CHEAT_MODE); } layout.openSearch(profile, input, addToHistory); @@ -98,17 +100,27 @@ public final class SlimefunGuide { @ParametersAreNonnullByDefault public static void displayItem(PlayerProfile profile, ItemStack item, boolean addToHistory) { - SlimefunPlugin.getRegistry().getGuideLayout(SlimefunGuideMode.SURVIVAL_MODE).displayItem(profile, item, 0, addToHistory); + SlimefunPlugin.getRegistry().getSlimefunGuide(SlimefunGuideMode.SURVIVAL_MODE).displayItem(profile, item, 0, addToHistory); } @ParametersAreNonnullByDefault public static void displayItem(PlayerProfile profile, SlimefunItem item, boolean addToHistory) { - SlimefunPlugin.getRegistry().getGuideLayout(SlimefunGuideMode.SURVIVAL_MODE).displayItem(profile, item, addToHistory); + SlimefunPlugin.getRegistry().getSlimefunGuide(SlimefunGuideMode.SURVIVAL_MODE).displayItem(profile, item, addToHistory); } + /** + * This method checks if a given {@link ItemStack} is a {@link SlimefunGuide}. + * + * @param item + * The {@link ItemStack} to check + * + * @return Whether this {@link ItemStack} represents a {@link SlimefunGuide} + */ public static boolean isGuideItem(@Nullable ItemStack item) { - if (item == null) { + if (item == null || item.getType() != Material.ENCHANTED_BOOK) { return false; + } else if (item instanceof SlimefunGuideItem) { + return true; } else { return SlimefunUtils.isItemSimilar(item, getItem(SlimefunGuideMode.SURVIVAL_MODE), true) || SlimefunUtils.isItemSimilar(item, getItem(SlimefunGuideMode.CHEAT_MODE), true); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/Contributor.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/Contributor.java index 47fe8ac88..130198a82 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/Contributor.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/Contributor.java @@ -15,7 +15,7 @@ import javax.annotation.Nullable; import org.apache.commons.lang.Validate; import org.bukkit.ChatColor; -import io.github.thebusybiscuit.cscorelib2.data.ComputedOptional; +import io.github.thebusybiscuit.cscorelib2.data.TriStateOptional; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; @@ -35,7 +35,7 @@ public class Contributor { private final String profileLink; private final ConcurrentMap contributions = new ConcurrentHashMap<>(); - private final ComputedOptional headTexture = ComputedOptional.createNew(); + private final TriStateOptional headTexture = TriStateOptional.createNew(); private Optional uuid = Optional.empty(); private boolean immutable = false; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubTask.java index 84b725496..cfc214538 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubTask.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubTask.java @@ -14,7 +14,7 @@ import javax.annotation.Nullable; import org.bukkit.Bukkit; import io.github.thebusybiscuit.cscorelib2.players.MinecraftAccount; -import io.github.thebusybiscuit.cscorelib2.players.MinecraftAccount.TooManyRequestsException; +import io.github.thebusybiscuit.cscorelib2.players.TooManyRequestsException; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; /** diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java index cd1bfd2bb..c44b3b358 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java @@ -843,6 +843,7 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock, } } + @ParametersAreNonnullByDefault protected void move(Block b, BlockFace face, Block block) { if (block.getY() > 0 && block.getY() < block.getWorld().getMaxHeight() && block.isEmpty()) { BlockData blockData = Material.PLAYER_HEAD.createBlockData(data -> { From b3b7a22ee93730348d2b485f13a0c658543d8afb Mon Sep 17 00:00:00 2001 From: CURVX Date: Tue, 12 Jan 2021 21:42:53 +0530 Subject: [PATCH 05/20] Changes req. by TTB --- .../AbstractVanillaBlockInventory.java | 39 ------------------- .../core/attributes/NotHopperable.java | 14 +++++++ .../implementation/SlimefunPlugin.java | 2 +- .../items/electric/machines/AutoBrewer.java | 5 ++- .../items/electric/machines/AutoDrier.java | 4 +- .../electric/machines/ElectricFurnace.java | 5 ++- .../machines/ElectricIngotPulverizer.java | 4 +- .../electric/machines/ElectricOreGrinder.java | 5 ++- .../electric/machines/ElectricSmeltery.java | 5 ++- .../{crafting => }/HopperListener.java | 13 ++++--- 10 files changed, 38 insertions(+), 58 deletions(-) delete mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/api/inventory/AbstractVanillaBlockInventory.java create mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotHopperable.java rename src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/{crafting => }/HopperListener.java (71%) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/inventory/AbstractVanillaBlockInventory.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/inventory/AbstractVanillaBlockInventory.java deleted file mode 100644 index c4d3002f3..000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/inventory/AbstractVanillaBlockInventory.java +++ /dev/null @@ -1,39 +0,0 @@ -package io.github.thebusybiscuit.slimefun4.api.inventory; - -import javax.annotation.ParametersAreNonnullByDefault; - -import org.bukkit.inventory.ItemStack; - -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.AutoBrewer; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.AutoDrier; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.ElectricFurnace; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.ElectricIngotPulverizer; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.ElectricOreGrinder; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.ElectricSmeltery; -import me.mrCookieSlime.Slimefun.Lists.RecipeType; -import me.mrCookieSlime.Slimefun.Objects.Category; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; -import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; - -/** - * The {@link AbstractVanillaBlockInventory} is an - * implementation of {@link AContainer} for machines that use - * a vanilla block inventory holder. - * - * @author CURVX - * - * @see AutoBrewer - * @see AutoDrier - * @see ElectricFurnace - * @see ElectricIngotPulverizer - * @see ElectricOreGrinder - * @see ElectricSmeltery - * - */ -public abstract class AbstractVanillaBlockInventory extends AContainer { - - @ParametersAreNonnullByDefault - public AbstractVanillaBlockInventory(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { - super(category, item, recipeType, recipe); - } -} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotHopperable.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotHopperable.java new file mode 100644 index 000000000..115c31e52 --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotHopperable.java @@ -0,0 +1,14 @@ +package io.github.thebusybiscuit.slimefun4.core.attributes; + +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; + +/** + * Implement this interface for any {@link AContainer} to prevent + * that {@link AContainer} from being hopperable. + * + * @author CURVX + * + */ +public interface NotHopperable { + +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java index f1dcdae3a..e955dd3f7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java @@ -75,6 +75,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.listeners.ExplosionsLis import io.github.thebusybiscuit.slimefun4.implementation.listeners.FireworksListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.GadgetsListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.GrapplingHookListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.HopperListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.IronGolemListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.ItemDropListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.ItemPickupListener; @@ -101,7 +102,6 @@ import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.Cart import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.CauldronListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.CraftingTableListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.GrindstoneListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.HopperListener; import io.github.thebusybiscuit.slimefun4.implementation.resources.GEOResourcesSetup; import io.github.thebusybiscuit.slimefun4.implementation.setup.PostSetup; import io.github.thebusybiscuit.slimefun4.implementation.setup.ResearchSetup; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBrewer.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBrewer.java index 84c3620a4..7bde48126 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBrewer.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBrewer.java @@ -5,6 +5,8 @@ import java.util.Map; import javax.annotation.Nonnull; +import io.github.thebusybiscuit.slimefun4.core.attributes.NotHopperable; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.PotionMeta; @@ -12,7 +14,6 @@ import org.bukkit.potion.PotionData; import org.bukkit.potion.PotionType; import io.github.thebusybiscuit.cscorelib2.inventory.InvUtils; -import io.github.thebusybiscuit.slimefun4.api.inventory.AbstractVanillaBlockInventory; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe; @@ -26,7 +27,7 @@ import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; * @author Linox * */ -public class AutoBrewer extends AbstractVanillaBlockInventory { +public class AutoBrewer extends AContainer implements NotHopperable { private static final Map potionRecipes = new EnumMap<>(Material.class); private static final Map fermentations = new EnumMap<>(PotionType.class); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDrier.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDrier.java index 7dff16a33..2b3353761 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDrier.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDrier.java @@ -3,7 +3,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machine import java.util.ArrayList; import java.util.List; -import io.github.thebusybiscuit.slimefun4.api.inventory.AbstractVanillaBlockInventory; +import io.github.thebusybiscuit.slimefun4.core.attributes.NotHopperable; import org.bukkit.Material; import org.bukkit.Tag; import org.bukkit.inventory.ItemStack; @@ -23,7 +23,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; * @author Linox * */ -public class AutoDrier extends AbstractVanillaBlockInventory implements RecipeDisplayItem { +public class AutoDrier extends AContainer implements RecipeDisplayItem, NotHopperable { private List recipeList; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricFurnace.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricFurnace.java index 0c034149d..7f1acdc64 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricFurnace.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricFurnace.java @@ -1,18 +1,19 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; +import io.github.thebusybiscuit.slimefun4.core.attributes.NotHopperable; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import org.bukkit.Material; import org.bukkit.inventory.FurnaceRecipe; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.RecipeChoice; import org.bukkit.inventory.RecipeChoice.MaterialChoice; -import io.github.thebusybiscuit.slimefun4.api.inventory.AbstractVanillaBlockInventory; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; -public class ElectricFurnace extends AbstractVanillaBlockInventory { +public class ElectricFurnace extends AContainer implements NotHopperable { public ElectricFurnace(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricIngotPulverizer.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricIngotPulverizer.java index 5b3ac2859..1689aa5f1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricIngotPulverizer.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricIngotPulverizer.java @@ -3,7 +3,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machine import java.util.ArrayList; import java.util.List; -import io.github.thebusybiscuit.slimefun4.api.inventory.AbstractVanillaBlockInventory; +import io.github.thebusybiscuit.slimefun4.core.attributes.NotHopperable; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -24,7 +24,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; * @see ElectricIngotFactory * */ -public class ElectricIngotPulverizer extends AbstractVanillaBlockInventory implements RecipeDisplayItem { +public class ElectricIngotPulverizer extends AContainer implements RecipeDisplayItem, NotHopperable { public ElectricIngotPulverizer(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricOreGrinder.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricOreGrinder.java index e28ec9a24..abe2a5a20 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,6 +1,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; -import io.github.thebusybiscuit.slimefun4.api.inventory.AbstractVanillaBlockInventory; +import io.github.thebusybiscuit.slimefun4.core.attributes.NotHopperable; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -9,7 +10,7 @@ import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; -public class ElectricOreGrinder extends AbstractVanillaBlockInventory implements RecipeDisplayItem { +public class ElectricOreGrinder extends AContainer implements RecipeDisplayItem, NotHopperable { 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/items/electric/machines/ElectricSmeltery.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricSmeltery.java index b9c8dbcc0..85f73e586 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 @@ -5,6 +5,8 @@ import java.util.Comparator; import java.util.LinkedList; import java.util.List; +import io.github.thebusybiscuit.slimefun4.core.attributes.NotHopperable; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.Player; @@ -13,7 +15,6 @@ import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.cscorelib2.item.CustomItem; import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction; -import io.github.thebusybiscuit.slimefun4.api.inventory.AbstractVanillaBlockInventory; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.Smeltery; import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; @@ -35,7 +36,7 @@ import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow; * @author TheBusyBiscuit * */ -public class ElectricSmeltery extends AbstractVanillaBlockInventory { +public class ElectricSmeltery extends AContainer implements NotHopperable { private static final int[] border = { 4, 5, 6, 7, 8, 13, 31, 40, 41, 42, 43, 44 }; private static final int[] inputBorder = { 0, 1, 2, 3, 9, 12, 18, 21, 27, 30, 36, 37, 38, 39 }; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/HopperListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/HopperListener.java similarity index 71% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/HopperListener.java rename to src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/HopperListener.java index e43c56c7a..b205c52fa 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/HopperListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/HopperListener.java @@ -1,25 +1,26 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting; +package io.github.thebusybiscuit.slimefun4.implementation.listeners; import javax.annotation.Nonnull; -import io.github.thebusybiscuit.slimefun4.api.inventory.AbstractVanillaBlockInventory; +import io.github.thebusybiscuit.slimefun4.core.attributes.NotHopperable; import org.bukkit.Location; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.inventory.InventoryMoveItemEvent; import org.bukkit.event.inventory.InventoryType; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import me.mrCookieSlime.Slimefun.api.BlockStorage; /** * This {@link Listener} prevents item from being transferred to a - * {@link AbstractVanillaBlockInventory} using a hopper. + * {@link AContainer} using a hopper. * * @author CURVX * */ -public class HopperListener implements SlimefunCraftingListener { +public class HopperListener implements Listener { public HopperListener(@Nonnull SlimefunPlugin plugin) { plugin.getServer().getPluginManager().registerEvents(this, plugin); @@ -28,8 +29,8 @@ public class HopperListener implements SlimefunCraftingListener { @EventHandler public void onHopperInsert(InventoryMoveItemEvent e) { Location loc = e.getDestination().getLocation(); - if (e.getSource().getType() == InventoryType.HOPPER && loc != null && BlockStorage.check(loc.getBlock()) instanceof AbstractVanillaBlockInventory) { - e.setCancelled(true); + if (e.getSource().getType() == InventoryType.HOPPER && loc != null && BlockStorage.check(loc.getBlock()) instanceof NotHopperable) { + e.setCancelled(true); } } } From f0e891134bc027e0f8ee6af557f68d0da33f878b Mon Sep 17 00:00:00 2001 From: CURVX Date: Tue, 12 Jan 2021 23:17:23 +0530 Subject: [PATCH 06/20] Cleaned imports --- .../items/electric/machines/AutoBrewer.java | 8 +++--- .../items/electric/machines/AutoDrier.java | 3 ++- .../electric/machines/ElectricFurnace.java | 4 +-- .../machines/ElectricIngotPulverizer.java | 2 +- .../electric/machines/ElectricOreGrinder.java | 2 +- .../electric/machines/ElectricSmeltery.java | 4 +-- .../listeners/HopperListener.java | 25 ++++++++++++++----- 7 files changed, 31 insertions(+), 17 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBrewer.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBrewer.java index 7bde48126..9436bbe1a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBrewer.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBrewer.java @@ -5,20 +5,20 @@ import java.util.Map; import javax.annotation.Nonnull; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotHopperable; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.potion.PotionData; import org.bukkit.potion.PotionType; +import io.github.thebusybiscuit.slimefun4.core.attributes.NotHopperable; import io.github.thebusybiscuit.cscorelib2.inventory.InvUtils; +import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe; -import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe; /** * diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDrier.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDrier.java index 2b3353761..1656c6195 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDrier.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDrier.java @@ -3,11 +3,12 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machine import java.util.ArrayList; import java.util.List; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotHopperable; + import org.bukkit.Material; import org.bukkit.Tag; import org.bukkit.inventory.ItemStack; +import io.github.thebusybiscuit.slimefun4.core.attributes.NotHopperable; import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; import me.mrCookieSlime.Slimefun.Lists.RecipeType; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricFurnace.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricFurnace.java index 7f1acdc64..ba2071cf6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricFurnace.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricFurnace.java @@ -1,7 +1,5 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotHopperable; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import org.bukkit.Material; import org.bukkit.inventory.FurnaceRecipe; import org.bukkit.inventory.ItemStack; @@ -9,9 +7,11 @@ import org.bukkit.inventory.RecipeChoice; import org.bukkit.inventory.RecipeChoice.MaterialChoice; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import io.github.thebusybiscuit.slimefun4.core.attributes.NotHopperable; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; public class ElectricFurnace extends AContainer implements NotHopperable { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricIngotPulverizer.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricIngotPulverizer.java index 1689aa5f1..1b9e51673 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricIngotPulverizer.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricIngotPulverizer.java @@ -3,10 +3,10 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machine import java.util.ArrayList; import java.util.List; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotHopperable; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; +import io.github.thebusybiscuit.slimefun4.core.attributes.NotHopperable; import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; import me.mrCookieSlime.Slimefun.Lists.RecipeType; 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 abe2a5a20..9860744fc 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,10 +1,10 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotHopperable; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; +import io.github.thebusybiscuit.slimefun4.core.attributes.NotHopperable; import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; 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 85f73e586..a0ce3cd4d 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 @@ -5,8 +5,6 @@ import java.util.Comparator; import java.util.LinkedList; import java.util.List; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotHopperable; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.Player; @@ -15,6 +13,7 @@ import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.cscorelib2.item.CustomItem; import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction; +import io.github.thebusybiscuit.slimefun4.core.attributes.NotHopperable; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.Smeltery; import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; @@ -29,6 +28,7 @@ import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; import me.mrCookieSlime.Slimefun.api.inventory.DirtyChestMenu; import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; /** * The {@link ElectricSmeltery} is an electric version of the standard {@link Smeltery}. diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/HopperListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/HopperListener.java index b205c52fa..54c6ebddf 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/HopperListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/HopperListener.java @@ -2,23 +2,36 @@ package io.github.thebusybiscuit.slimefun4.implementation.listeners; import javax.annotation.Nonnull; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotHopperable; import org.bukkit.Location; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.inventory.InventoryMoveItemEvent; import org.bukkit.event.inventory.InventoryType; + +import io.github.thebusybiscuit.slimefun4.core.attributes.NotHopperable; +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.AutoBrewer; +import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.AutoDrier; +import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.ElectricFurnace; +import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.ElectricIngotPulverizer; +import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.ElectricOreGrinder; +import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.ElectricSmeltery; +import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; -import me.mrCookieSlime.Slimefun.api.BlockStorage; - /** - * This {@link Listener} prevents item from being transferred to a - * {@link AContainer} using a hopper. + * This {@link Listener} prevents item from being transferred to + * and from {@link AContainer} using a hopper. * * @author CURVX * + * @see AutoBrewer + * @see AutoDrier + * @see ElectricFurnace + * @see ElectricIngotPulverizer + * @see ElectricOreGrinder + * @see ElectricSmeltery + * */ public class HopperListener implements Listener { From a0ab148a65c227a2ca81466e44b42b7179b1799d Mon Sep 17 00:00:00 2001 From: CURVX Date: Tue, 12 Jan 2021 23:42:19 +0530 Subject: [PATCH 07/20] Cleaned imports pt.2 --- .../implementation/items/electric/machines/AutoBrewer.java | 2 +- .../implementation/items/electric/machines/AutoDrier.java | 1 - .../items/electric/machines/ElectricOreGrinder.java | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBrewer.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBrewer.java index 9436bbe1a..9dcb2db78 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBrewer.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBrewer.java @@ -11,8 +11,8 @@ import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.potion.PotionData; import org.bukkit.potion.PotionType; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotHopperable; import io.github.thebusybiscuit.cscorelib2.inventory.InvUtils; +import io.github.thebusybiscuit.slimefun4.core.attributes.NotHopperable; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDrier.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDrier.java index 1656c6195..cea222eae 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDrier.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDrier.java @@ -3,7 +3,6 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machine import java.util.ArrayList; import java.util.List; - import org.bukkit.Material; import org.bukkit.Tag; import org.bukkit.inventory.ItemStack; 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 9860744fc..2a8675258 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,6 +1,5 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -9,6 +8,7 @@ import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; public class ElectricOreGrinder extends AContainer implements RecipeDisplayItem, NotHopperable { From ec8eed58f9c106e76dd3948c454306a0201ea103 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Tue, 12 Jan 2021 19:28:12 +0100 Subject: [PATCH 08/20] [CI skip] Refactoring --- pom.xml | 19 +- .../slimefun4/api/ErrorReport.java | 13 + .../api/events/AncientAltarCraftEvent.java | 4 +- .../api/items/settings/EnumSetting.java | 5 + .../slimefun4/core/SlimefunRegistry.java | 20 + .../core/categories/FlexCategory.java | 2 +- .../core/categories/LockedCategory.java | 3 +- .../commands/subcommands/GuideCommand.java | 2 +- .../commands/subcommands/SearchCommand.java | 3 +- .../slimefun4/core/guide/SlimefunGuide.java | 29 +- .../guide/SurvivalSlimefunGuide.java | 2 +- .../items/armor/StomperBoots.java | 3 +- .../items/electric/gadgets/MultiTool.java | 3 +- .../listeners/BlockListener.java | 13 +- .../listeners/SlimefunGuideListener.java | 2 +- .../slimefun4/utils/tags/SlimefunTag.java | 2 +- src/main/resources/wiki.json | 490 +++++++++--------- .../listeners/TestSlimefunGuideListener.java | 2 +- 18 files changed, 332 insertions(+), 285 deletions(-) diff --git a/pom.xml b/pom.xml index dd4b1f896..02a4dd503 100644 --- a/pom.xml +++ b/pom.xml @@ -9,10 +9,11 @@ - 4.8-UNOFFICIAL + 4.9-UNOFFICIAL 2013 jar + Slimefun is a Spigot/Paper plugin that simulates a modpack-like atmosphere by adding over 500 new items and recipes to your Minecraft Server. https://github.com/Slimefun/Slimefun4 @@ -33,11 +34,13 @@ target/site/jacoco/jacoco.xml + GitHub Issues https://github.com/Slimefun/Slimefun4/issues + GNU General Public License v3.0 @@ -46,6 +49,7 @@ + spigot-repo @@ -77,11 +81,13 @@ + ${project.basedir}/src/main/java ${project.basedir}/src/test/java clean package + ${project.name} v${project.version} @@ -104,6 +110,7 @@ org.apache.maven.plugins maven-source-plugin 3.2.1 + attach-sources @@ -119,6 +126,11 @@ org.apache.maven.plugins maven-surefire-plugin 3.0.0-M5 + + + org.junit.jupiter:junit-jupiter + false + @@ -137,6 +149,7 @@ prepare + prepare-agent @@ -145,6 +158,7 @@ report test + report @@ -159,8 +173,7 @@ 3.2.4 - - + io.github.thebusybiscuit.cscorelib2 diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java index 7dbffa628..8aa6f31c6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java @@ -35,6 +35,9 @@ import me.mrCookieSlime.Slimefun.api.BlockStorage; * an {@link ErrorReport} instead. * Error reports get saved in the plugin folder. * + * @param + * The type of {@link Throwable} which has spawned this {@link ErrorReport} + * * @author TheBusyBiscuit * */ @@ -222,6 +225,16 @@ public class ErrorReport { return newFile; } + /** + * This helper method wraps the given {@link Runnable} into a try-catch block. + * When an {@link Exception} occurs, a new {@link ErrorReport} will be generated using + * the provided {@link Function}. + * + * @param function + * The {@link Function} to generate a new {@link ErrorReport} + * @param runnable + * The code to execute + */ public static void tryCatch(@Nonnull Function> function, @Nonnull Runnable runnable) { try { runnable.run(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AncientAltarCraftEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AncientAltarCraftEvent.java index a71bb461b..2e282d966 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AncientAltarCraftEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AncientAltarCraftEvent.java @@ -34,10 +34,10 @@ public class AncientAltarCraftEvent extends PlayerEvent implements Cancellable { private boolean cancelled; /** - * @param block - * The altar {@link Block} * @param output * The {@link ItemStack} that would be dropped by the ritual + * @param block + * The altar {@link Block} * @param player * The {@link Player} that started the ritual. */ diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/EnumSetting.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/EnumSetting.java index d952286af..480c4afb8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/EnumSetting.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/EnumSetting.java @@ -12,6 +12,9 @@ import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; * This variation of {@link ItemSetting} allows you to allow {@link Enum} constants to be * used for {@link ItemSetting} validation. * + * @param + * The {@link Enum} type + * * @author TheBusyBiscuit * * @see ItemSetting @@ -41,6 +44,7 @@ public class EnumSetting> extends ItemSetting { * * @return An array of allowed {@link Enum} constants */ + @Nonnull public T[] getAllowedValues() { return enumClass.getEnumConstants(); } @@ -50,6 +54,7 @@ public class EnumSetting> extends ItemSetting { * * @return The value as an {@link Enum} constant */ + @Nonnull public T getAsEnumConstant() { return Enum.valueOf(enumClass, getValue()); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java index 32ebf7f86..c7133aa03 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java @@ -140,6 +140,7 @@ public final class SlimefunRegistry { automaticallyLoadItems = mode; } + @Nonnull public List getCategories() { return categories; } @@ -149,6 +150,7 @@ public final class SlimefunRegistry { * * @return A {@link List} containing every {@link SlimefunItem} */ + @Nonnull public List getAllSlimefunItems() { return slimefunItems; } @@ -158,18 +160,22 @@ public final class SlimefunRegistry { * * @return A {@link List} containing every enabled {@link SlimefunItem} */ + @Nonnull public List getEnabledSlimefunItems() { return enabledItems; } + @Nonnull public List getResearches() { return researches; } + @Nonnull public Set getCurrentlyResearchingPlayers() { return researchingPlayers; } + @Nonnull public List getResearchRanks() { return researchRanks; } @@ -194,6 +200,7 @@ public final class SlimefunRegistry { return researchFireworks; } + @Nonnull public List getMultiBlocks() { return multiblocks; } @@ -226,6 +233,7 @@ public final class SlimefunRegistry { * * @return The {@link Map} of custom mob drops */ + @Nonnull public Map> getMobDrops() { return mobDrops; } @@ -236,50 +244,62 @@ public final class SlimefunRegistry { * * @return A {@link Set} of bartering drops */ + @Nonnull public Set getBarteringDrops() { return barterDrops; } + @Nonnull public Set getRadioactiveItems() { return radioactive; } + @Nonnull public Set getTickerBlocks() { return tickers; } + @Nonnull public Map getSlimefunItemIds() { return slimefunIds; } + @Nonnull public Map getMenuPresets() { return blockMenuPresets; } + @Nonnull public Map getUniversalInventories() { return universalInventories; } + @Nonnull public Map getPlayerProfiles() { return profiles; } + @Nonnull public Map, Set> getPublicItemHandlers() { return globalItemHandlers; } + @Nonnull public Map getBlockHandlers() { return blockHandlers; } + @Nonnull public Map getWorlds() { return worlds; } + @Nonnull public Map getChunks() { return chunks; } + @Nonnull public KeyMap getGEOResources() { return geoResources; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/categories/FlexCategory.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/categories/FlexCategory.java index 896a23730..2d7d2994d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/categories/FlexCategory.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/categories/FlexCategory.java @@ -68,7 +68,7 @@ public abstract class FlexCategory extends Category { @Override public final boolean isHidden(@Nonnull Player p) { - /** + /* * We can stop this method right here. * We provide a custom method with more parameters for this. * See isVisible(...) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/categories/LockedCategory.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/categories/LockedCategory.java index e47732c79..7056eadcf 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/categories/LockedCategory.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/categories/LockedCategory.java @@ -149,12 +149,13 @@ public class LockedCategory extends Category { * The {@link Player} to check * @param profile * The {@link PlayerProfile} that belongs to the given {@link Player} + * * @return Whether the {@link Player} has fully completed all parent categories, otherwise false */ public boolean hasUnlocked(@Nonnull Player p, @Nonnull PlayerProfile profile) { for (Category category : parents) { for (SlimefunItem item : category.getItems()) { - /** + /* * Should probably be replaced with Slimefun.hasUnlocked(...) * However this will result in better performance because we don't * request the PlayerProfile everytime diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GuideCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GuideCommand.java index b25c96063..c0f6a1949 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GuideCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GuideCommand.java @@ -19,7 +19,7 @@ class GuideCommand extends SubCommand { public void onExecute(CommandSender sender, String[] args) { if (sender instanceof Player) { if (sender.hasPermission("slimefun.command.guide")) { - SlimefunGuideMode design = SlimefunGuide.getDefaultLayout(); + SlimefunGuideMode design = SlimefunGuide.getDefaultMode(); ((Player) sender).getInventory().addItem(SlimefunGuide.getItem(design).clone()); } else { SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SearchCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SearchCommand.java index af311645f..c52927221 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SearchCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SearchCommand.java @@ -9,6 +9,7 @@ import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; +import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; class SearchCommand extends SubCommand { @@ -23,7 +24,7 @@ class SearchCommand extends SubCommand { if (sender.hasPermission("slimefun.command.search")) { if (args.length > 1) { String query = String.join(" ", Arrays.copyOfRange(args, 1, args.length)); - PlayerProfile.get((Player) sender, profile -> SlimefunGuide.openSearch(profile, query, true, true)); + PlayerProfile.get((Player) sender, profile -> SlimefunGuide.openSearch(profile, query, SlimefunGuideMode.SURVIVAL_MODE, true)); } else { SlimefunPlugin.getLocalization().sendMessage(sender, "messages.usage", true, msg -> msg.replace("%usage%", "/sf search ")); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuide.java index 370e9cff3..779f634d1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuide.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuide.java @@ -71,31 +71,26 @@ public final class SlimefunGuide { } @ParametersAreNonnullByDefault - private static void openMainMenuAsync(Player player, SlimefunGuideMode layout, int selectedPage) { - if (!PlayerProfile.get(player, profile -> SlimefunPlugin.runSync(() -> openMainMenu(profile, layout, selectedPage)))) { + private static void openMainMenuAsync(Player player, SlimefunGuideMode mode, int selectedPage) { + if (!PlayerProfile.get(player, profile -> SlimefunPlugin.runSync(() -> openMainMenu(profile, mode, selectedPage)))) { SlimefunPlugin.getLocalization().sendMessage(player, "messages.opening-guide"); } } @ParametersAreNonnullByDefault - public static void openMainMenu(PlayerProfile profile, SlimefunGuideMode layout, int selectedPage) { - SlimefunPlugin.getRegistry().getSlimefunGuide(layout).openMainMenu(profile, selectedPage); + public static void openMainMenu(PlayerProfile profile, SlimefunGuideMode mode, int selectedPage) { + SlimefunPlugin.getRegistry().getSlimefunGuide(mode).openMainMenu(profile, selectedPage); } @ParametersAreNonnullByDefault - public static void openCategory(PlayerProfile profile, Category category, SlimefunGuideMode layout, int selectedPage) { - SlimefunPlugin.getRegistry().getSlimefunGuide(layout).openCategory(profile, category, selectedPage); + public static void openCategory(PlayerProfile profile, Category category, SlimefunGuideMode mode, int selectedPage) { + SlimefunPlugin.getRegistry().getSlimefunGuide(mode).openCategory(profile, category, selectedPage); } @ParametersAreNonnullByDefault - public static void openSearch(PlayerProfile profile, String input, boolean survival, boolean addToHistory) { - SlimefunGuideImplementation layout = SlimefunPlugin.getRegistry().getSlimefunGuide(SlimefunGuideMode.SURVIVAL_MODE); - - if (!survival) { - layout = SlimefunPlugin.getRegistry().getSlimefunGuide(SlimefunGuideMode.CHEAT_MODE); - } - - layout.openSearch(profile, input, addToHistory); + public static void openSearch(PlayerProfile profile, String input, SlimefunGuideMode mode, boolean addToHistory) { + SlimefunGuideImplementation guide = SlimefunPlugin.getRegistry().getSlimefunGuide(mode); + guide.openSearch(profile, input, addToHistory); } @ParametersAreNonnullByDefault @@ -127,13 +122,13 @@ public final class SlimefunGuide { } /** - * Get the default layout for the Slimefun guide. + * Get the default mode for the Slimefun guide. * Currently this is only {@link SlimefunGuideMode#SURVIVAL_MODE}. * - * @return The default {@link SlimefunGuideLayout}. + * @return The default {@link SlimefunGuideMode}. */ @Nonnull - public static SlimefunGuideMode getDefaultLayout() { + public static SlimefunGuideMode getDefaultMode() { return SlimefunGuideMode.SURVIVAL_MODE; } } 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 760fee545..2f8964939 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 @@ -570,7 +570,7 @@ public class SurvivalSlimefunGuide implements SlimefunGuideImplementation { pl.closeInventory(); SlimefunPlugin.getLocalization().sendMessage(pl, "guide.search.message"); - ChatInput.waitForPlayer(SlimefunPlugin.instance(), pl, msg -> SlimefunGuide.openSearch(profile, msg, isSurvivalMode(), isSurvivalMode())); + ChatInput.waitForPlayer(SlimefunPlugin.instance(), pl, msg -> SlimefunGuide.openSearch(profile, msg, getMode(), isSurvivalMode())); return false; }); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/StomperBoots.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/StomperBoots.java index da217cf57..3888d6506 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/StomperBoots.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/StomperBoots.java @@ -105,7 +105,6 @@ public class StomperBoots extends SlimefunItem { * @return If the entity can move. */ protected boolean canPush(@Nonnull Player player, @Nonnull LivingEntity entity) { - return entity.isValid() && !entity.getUniqueId().equals(player.getUniqueId()) - && entity.isCollidable() && entity.hasGravity(); + return entity.isValid() && !entity.getUniqueId().equals(player.getUniqueId()) && entity.isCollidable() && entity.hasGravity(); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/MultiTool.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/MultiTool.java index cba3f71cf..eae1b162b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/MultiTool.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/MultiTool.java @@ -52,8 +52,7 @@ public class MultiTool extends SlimefunItem implements Rechargeable { if (index >= modes.size()) { index = 0; } - } - while (index != i && !modes.get(index).isEnabled()); + } while (index != i && !modes.get(index).isEnabled()); return index; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java index 4b401f1bc..b14d02d8e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java @@ -67,12 +67,13 @@ public class BlockListener implements Listener { SlimefunItem sfItem = BlockStorage.check(block); if (sfItem != null) { - /* Temp fix for #2636 - for (ItemStack item : sfItem.getDrops()) { - if (item != null && !item.getType().isAir()) { - block.getWorld().dropItemNaturally(block.getLocation(), item); - } - } + /* + * Temp fix for #2636 + * for (ItemStack item : sfItem.getDrops()) { + * if (item != null && !item.getType().isAir()) { + * block.getWorld().dropItemNaturally(block.getLocation(), item); + * } + * } */ BlockStorage.clearBlockInfo(block); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java index 79c319c3b..97a64076f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java @@ -38,7 +38,7 @@ public class SlimefunGuideListener implements Listener { return; } - SlimefunGuideMode type = SlimefunGuide.getDefaultLayout(); + SlimefunGuideMode type = SlimefunGuide.getDefaultMode(); p.getInventory().addItem(SlimefunGuide.getItem(type).clone()); } } 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 1a7869875..855485681 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 @@ -62,7 +62,7 @@ public enum SlimefunTag implements Tag { * All command block variants */ COMMAND_BLOCKS, - + /** * All variants of Spawn Eggs */ diff --git a/src/main/resources/wiki.json b/src/main/resources/wiki.json index 7de89de83..789d340ca 100644 --- a/src/main/resources/wiki.json +++ b/src/main/resources/wiki.json @@ -1,247 +1,247 @@ { - "GOLD_PAN" : "Gold-Pan", - "SIFTED_ORE" : "Sifted-Ore", - "SMELTERY" : "Smeltery", - "DIET_COOKIE" : "Diet-Cookie", - "ENHANCED_CRAFTING_TABLE" : "Enhanced-Crafting-Table", - "FORTUNE_COOKIE" : "Fortune-Cookie", - "TABLE_SAW" : "Table-Saw", - "APPLE_JUICE" : "Juices", - "GOLDEN_APPLE_JUICE" : "Juices", - "CARROT_JUICE" : "Juices", - "MELON_JUICE" : "Juices", - "PUMPKIN_JUICE" : "Juices", - "SWEET_BERRY_JUICE" : "Juices", - "MAGIC_SUGAR" : "Magic-Sugar", - "MONSTER_JERKY" : "Monster-Jerky", - "OUTPUT_CHEST" : "Output-Chest", - "BEEF_JERKY" : "Meat-Jerky", - "PORK_JERKY" : "Meat-Jerky", - "CHICKEN_JERKY" : "Meat-Jerky", - "MUTTON_JERKY" : "Meat-Jerky", - "RABBIT_JERKY" : "Meat-Jerky", - "FISH_JERKY" : "Meat-Jerky", - "KELP_COOKIE" : "Kelp-Cookie", - "ANCIENT_ALTAR" : "Ancient-Altar", - "ANCIENT_PEDESTAL" : "Ancient-Pedestal", - "BLADE_OF_VAMPIRES" : "Blade-of-Vampires", - "BROKEN_SPAWNER" : "Broken-Spawner", - "REPAIRED_SPAWNER" : "Reinforced-Spawner", - "NETHER_GOLD_PAN" : "Nether-Gold-Pan", - "PICKAXE_OF_CONTAINMENT" : "Pickaxe-of-Containment", - "SEISMIC_AXE" : "Seismic-Axe", - "SMELTERS_PICKAXE" : "Smelter's-Pickaxe", - "MAGNET" : "Magnet", - "BASIC_CIRCUIT_BOARD" : "Circuit-Boards", - "ADVANCED_CIRCUIT_BOARD" : "Circuit-Boards", - "BATTERY" : "Battery", - "STEEL_THRUSTER" : "Steel-Thruster", - "POWER_CRYSTAL" : "Power-Crystal", - "SOLAR_PANEL" : "Solar-Panel", - "ELECTRO_MAGNET" : "Electromagnet", - "ELECTRIC_MOTOR" : "Electric-Motor", - "HEATING_COIL" : "Heating-Coil", - "COPPER_WIRE" : "Copper-Wire", - "HARDENED_GLASS" : "Hardened-Glass", - "COOLING_UNIT" : "Cooling-Unit", - "WITHER_PROOF_OBSIDIAN" : "Wither-Proof-Blocks", - "WITHER_PROOF_GLASS" : "Wither-Proof-Blocks", - "REACTOR_COOLANT_CELL" : "Coolant-Cells", - "NETHER_ICE_COOLANT_CELL" : "Coolant-Cells", - "IRON_DUST" : "Iron-Dust", - "GOLD_DUST" : "Gold-Dust", - "GOLD_4K" : "Gold-Ingot", - "GOLD_6K" : "Gold-Ingot", - "GOLD_8K" : "Gold-Ingot", - "GOLD_10K" : "Gold-Ingot", - "GOLD_12K" : "Gold-Ingot", - "GOLD_14K" : "Gold-Ingot", - "GOLD_16K" : "Gold-Ingot", - "GOLD_18K" : "Gold-Ingot", - "GOLD_20K" : "Gold-Ingot", - "GOLD_22K" : "Gold-Ingot", - "GOLD_24K" : "Gold-Ingot", - "ENERGY_REGULATOR" : "Energy-Regulator", - "SMALL_CAPACITOR" : "Energy-Capacitors", - "MEDIUM_CAPACITOR" : "Energy-Capacitors", - "BIG_CAPACITOR" : "Energy-Capacitors", - "LARGE_CAPACITOR" : "Energy-Capacitors", - "CARBONADO_EDGED_CAPACITOR" : "Energy-Capacitors", - "SOLAR_GENERATOR" : "Solar-Generator", - "SOLAR_GENERATOR_2" : "Solar-Generator", - "SOLAR_GENERATOR_3" : "Solar-Generator", - "SOLAR_GENERATOR_4" : "Solar-Generator", - "COAL_GENERATOR" : "Coal-Generator", - "COAL_GENERATOR_2" : "Coal-Generator", - "COBALT_PICKAXE" : "Cobalt-Pickaxe", - "EXPLOSIVE_PICKAXE" : "Explosive-Pickaxe", - "EXPLOSIVE_SHOVEL" : "Explosive-Shovel", - "GRAPPLING_HOOK" : "Grappling-Hook", - "HERCULES_PICKAXE" : "Hercules'-Pickaxe", - "LUMBER_AXE" : "Lumber-Axe", - "PICKAXE_OF_VEIN_MINING" : "Pickaxe-of-Vein-Mining", - "PICKAXE_OF_THE_SEEKER" : "Pickaxe-of-the-Seeker", - "CARGO_OUTPUT_ADVANCED" : "Advanced-Output-Node", - "CARGO_MANAGER" : "Cargo-Manager", - "CARGO_MOTOR" : "Cargo-Motor", - "CARGO_NODE" : "Connector-Node", - "CARGO_INPUT" : "Input-Node", - "CARGO_OUTPUT" : "Output-Node", - "TRASH_CAN" : "Trash-Can", - "ORE_WASHER" : "Ore-Washer", - "SCUBA_HELMET" : "Hazmat-Suit", - "HAZMAT_CHESTPLATE" : "Hazmat-Suit", - "HAZMAT_LEGGINGS" : "Hazmat-Suit", - "RUBBER_BOOTS" : "Hazmat-Suit", - "ARMOR_FORGE" : "Armor-Forge", - "AUTOMATED_PANNING_MACHINE" : "Automated-Panning-Machine", - "COMPRESSOR" : "Compressor", - "ORE_CRUSHER" : "Ore-Crusher", - "PRESSURE_CHAMBER" : "Pressure-Chamber", - "GRIND_STONE" : "Grind-Stone", - "MAGIC_WORKBENCH" : "Magic-Workbench", - "PORTABLE_CRAFTER" : "Portable-Crafter", - "PORTABLE_DUSTBIN" : "Portable-Dustbin", - "COOLER" : "Cooler", - "ALUMINUM_BRASS_INGOT" : "Aluminum-Brass-Ingot", - "ALUMINUM_BRONZE_INGOT" : "Aluminum-Bronze-Ingot", - "ALUMINUM_DUST" : "Aluminum-Dust", - "ALUMINUM_INGOT" : "Aluminum-Ingot", - "GLOWSTONE_HELMET" : "Magical-Armor", - "GLOWSTONE_CHESTPLATE" : "Magical-Armor", - "GLOWSTONE_LEGGINGS" : "Magical-Armor", - "GLOWSTONE_BOOTS" : "Magical-Armor", - "ENDER_HELMET" : "Magical-Armor", - "ENDER_CHESTPLATE" : "Magical-Armor", - "ENDER_LEGGINGS" : "Magical-Armor", - "ENDER_BOOTS" : "Magical-Armor", - "SLIME_HELMET" : "Magical-Armor", - "SLIME_CHESTPLATE" : "Magical-Armor", - "SLIME_LEGGINGS" : "Magical-Armor", - "SLIME_BOOTS" : "Magical-Armor", - "CACTUS_HELMET" : "Armor", - "CACTUS_CHESTPLATE" : "Armor", - "CACTUS_LEGGINGS" : "Armor", - "CACTUS_BOOTS" : "Armor", - "DAMASCUS_STEEL_HELMET" : "Armor", - "DAMASCUS_STEEL_CHESTPLATE" : "Armor", - "DAMASCUS_STEEL_LEGGINGS" : "Armor", - "DAMASCUS_STEEL_BOOTS" : "Armor", - "REINFORCED_ALLOY_HELMET" : "Armor", - "REINFORCED_ALLOY_CHESTPLATE" : "Armor", - "REINFORCED_ALLOY_LEGGINGS" : "Armor", - "REINFORCED_ALLOY_BOOTS" : "Armor", - "GILDED_IRON_HELMET" : "Armor", - "GILDED_IRON_CHESTPLATE" : "Armor", - "GILDED_IRON_LEGGINGS" : "Armor", - "GILDED_IRON_BOOTS" : "Armor", - "GOLD_12K_HELMET" : "Armor", - "GOLD_12K_CHESTPLATE" : "Armor", - "GOLD_12K_LEGGINGS" : "Armor", - "GOLD_12K_BOOTS" : "Armor", - "SLIME_STEEL_HELMET" : "Magical-Armor", - "SLIME_STEEL_CHESTPLATE" : "Magical-Armor", - "SLIME_STEEL_LEGGINGS" : "Magical-Armor", - "SLIME_STEEL_BOOTS" : "Magical-Armor", - "BILLON_INGOT" : "Billon-Ingot", - "BLOCK_PLACER" : "Block-Placer", - "EXPLOSIVE_BOW" : "Bows", - "ICY_BOW" : "Bows", - "BRASS_INGOT" : "Brass-Ingot", - "BRONZE_INGOT" : "Bronze-Ingot", - "CHRISTMAS_MILK" : "Christmas-Items", - "CHRISTMAS_CHOCOLATE_MILK" : "Christmas-Items", - "CHRISTMAS_EGG_NOG" : "Christmas-Items", - "CHRISTMAS_APPLE_CIDER" : "Christmas-Items", - "CHRISTMAS_COOKIE" : "Christmas-Items", - "CHRISTMAS_FRUIT_CAKE" : "Christmas-Items", - "CHRISTMAS_APPLE_PIE" : "Christmas-Items", - "CHRISTMAS_HOT_CHOCOLATE" : "Christmas-Items", - "CHRISTMAS_CAKE" : "Christmas-Items", - "CHRISTMAS_CARAMEL" : "Christmas-Items", - "CHRISTMAS_CARAMEL_APPLE" : "Christmas-Items", - "CHRISTMAS_CHOCOLATE_APPLE" : "Christmas-Items", - "CHRISTMAS_PRESENT" : "Christmas-Items", - "RAINBOW_WOOL_XMAS" : "Christmas-Seasonal-Category", - "RAINBOW_GLASS_XMAS" : "Christmas-Seasonal-Category", - "RAINBOW_CLAY_XMAS" : "Christmas-Seasonal-Category", - "RAINBOW_GLASS_PANE_XMAS" : "Christmas-Seasonal-Category", - "RAINBOW_CONCRETE_XMAS" : "Christmas-Seasonal-Category", - "RAINBOW_GLAZED_TERRACOTTA_XMAS" : "Christmas-Seasonal-Category", - "COBALT_INGOT" : "Cobalt-Ingot", - "COPPER_DUST" : "Copper-Dust", - "COPPER_INGOT" : "Copper-Ingot", - "CORINTHIAN_BRONZE_INGOT" : "Corinthian-Bronze-Ingot", - "DAMASCUS_STEEL_INGOT" : "Damascus-Steel-Ingot", - "DURALUMIN_INGOT" : "Duralumin-Ingot", - "ELEVATOR_PLATE" : "Elevator-Plate", - "ELYTRA_SCALE" : "Elytras", - "INFUSED_ELYTRA" : "Elytras", - "SOULBOUND_ELYTRA" : "Elytras", - "ENHANCED_FURNACE" : "Enhanced-Furnaces", - "ENHANCED_FURNACE_2" : "Enhanced-Furnaces", - "ENHANCED_FURNACE_3" : "Enhanced-Furnaces", - "ENHANCED_FURNACE_4" : "Enhanced-Furnaces", - "ENHANCED_FURNACE_5" : "Enhanced-Furnaces", - "ENHANCED_FURNACE_6" : "Enhanced-Furnaces", - "ENHANCED_FURNACE_7" : "Enhanced-Furnaces", - "ENHANCED_FURNACE_8" : "Enhanced-Furnaces", - "ENHANCED_FURNACE_9" : "Enhanced-Furnaces", - "ENHANCED_FURNACE_10" : "Enhanced-Furnaces", - "ENHANCED_FURNACE_11" : "Enhanced-Furnaces", - "REINFORCED_FURNACE" : "Enhanced-Furnaces", - "CARBONADO_EDGED_FURNACE" : "Enhanced-Furnaces", - "FERROSILICON" : "Ferrosilicon", - "GEO_MINER" : "GEO-Miner", - "GPS_ACTIVATION_DEVICE_SHARED" : "GPS-Activation-Device", - "GPS_ACTIVATION_DEVICE_PERSONAL" : "GPS-Activation-Device", - "GPS_CONTROL_PANEL" : "GPS-Control-Panel", - "GPS_EMERGENCY_TRANSMITTER" : "GPS-Emergency-Transmitter", - "GPS_GEO_SCANNER" : "GPS-Geo-Scanner", - "GPS_MARKER_TOOL" : "GPS-Marker-Tool", - "GPS_TELEPORTATION_MATRIX" : "GPS-Teleporter-Matrix", - "GPS_TELEPORTER_PYLON" : "GPS-Teleporter-Pylon", - "GPS_TRANSMITTER" : "GPS-Transmitter", - "GILDED_IRON" : "Gilded-Iron", - "HARDENED_METAL_INGOT" : "Hardened-Metal", - "LEAD_DUST" : "Lead-Dust", - "LEAD_INGOT" : "Lead-Ingot", - "MAGNESIUM_DUST" : "Magnesium-Dust", - "MAGNESIUM_INGOT" : "Magnesium-Ingot", - "NICKEL_INGOT" : "Nickel-Ingot", - "OIL_PUMP" : "Oil-Pump", - "PORTABLE_GEO_SCANNER" : "Portable-Geo-Scanner", - "RAINBOW_WOOL" : "Rainbow-Blocks", - "RAINBOW_GLASS" : "Rainbow-Blocks", - "RAINBOW_CLAY" : "Rainbow-Blocks", - "RAINBOW_GLASS_PANE" : "Rainbow-Blocks", - "RAINBOW_CONCRETE" : "Rainbow-Blocks", - "RAINBOW_GLAZED_TERRACOTTA" : "Rainbow-Blocks", - "REDSTONE_ALLOY" : "Redstone-Alloy-Ingot", - "REINFORCED_ALLOY_INGOT" : "Reinforced-Alloy-Ingot", - "SILVER_DUST" : "Silver-Dust", - "SILVER_INGOT" : "Silver-Ingot", - "SOLDER_INGOT" : "Solder-Ingot", - "SOULBOUND_HELMET" : "Soulbound-Armor", - "SOULBOUND_CHESTPLATE" : "Soulbound-Armor", - "SOULBOUND_LEGGINGS" : "Soulbound-Armor", - "SOULBOUND_BOOTS" : "Soulbound-Armor", - "ANCIENT_RUNE_SOULBOUND" : "Soulbound-Rune", - "SOULBOUND_SWORD" : "Soulbound-Weapons", - "SOULBOUND_BOW" : "Soulbound-Weapons", - "SOULBOUND_PICKAXE" : "Soulbound-Weapons", - "SOULBOUND_AXE" : "Soulbound-Weapons", - "SOULBOUND_SHOVEL" : "Soulbound-Weapons", - "SOULBOUND_HOE" : "Soulbound-Weapons", - "SOULBOUND_TRIDENT" : "Soulbound-Weapons", - "STEEL_INGOT" : "Steel-Ingot", - "SWORD_OF_BEHEADING" : "Sword-of-Beheading", - "COMMON_TALISMAN" : "Talismans", - "ENDER_TALISMAN" : "Talismans", - "TIN_DUST" : "Tin-Dust", - "TIN_INGOT" : "Tin-Ingot", - "GRANDMAS_WALKING_STICK" : "Walking-Sticks", - "GRANDPAS_WALKING_STICK" : "Walking-Sticks", - "ZINC_DUST" : "Zinc-Dust", - "ZINC_INGOT" : "Zinc-Ingot" + "GOLD_PAN" : "Gold-Pan", + "SIFTED_ORE" : "Sifted-Ore", + "SMELTERY" : "Smeltery", + "DIET_COOKIE" : "Diet-Cookie", + "ENHANCED_CRAFTING_TABLE" : "Enhanced-Crafting-Table", + "FORTUNE_COOKIE" : "Fortune-Cookie", + "TABLE_SAW" : "Table-Saw", + "APPLE_JUICE" : "Juices", + "GOLDEN_APPLE_JUICE" : "Juices", + "CARROT_JUICE" : "Juices", + "MELON_JUICE" : "Juices", + "PUMPKIN_JUICE" : "Juices", + "SWEET_BERRY_JUICE" : "Juices", + "MAGIC_SUGAR" : "Magic-Sugar", + "MONSTER_JERKY" : "Monster-Jerky", + "OUTPUT_CHEST" : "Output-Chest", + "BEEF_JERKY" : "Meat-Jerky", + "PORK_JERKY" : "Meat-Jerky", + "CHICKEN_JERKY" : "Meat-Jerky", + "MUTTON_JERKY" : "Meat-Jerky", + "RABBIT_JERKY" : "Meat-Jerky", + "FISH_JERKY" : "Meat-Jerky", + "KELP_COOKIE" : "Kelp-Cookie", + "ANCIENT_ALTAR" : "Ancient-Altar", + "ANCIENT_PEDESTAL" : "Ancient-Pedestal", + "BLADE_OF_VAMPIRES" : "Blade-of-Vampires", + "BROKEN_SPAWNER" : "Broken-Spawner", + "REPAIRED_SPAWNER" : "Reinforced-Spawner", + "NETHER_GOLD_PAN" : "Nether-Gold-Pan", + "PICKAXE_OF_CONTAINMENT" : "Pickaxe-of-Containment", + "SEISMIC_AXE" : "Seismic-Axe", + "SMELTERS_PICKAXE" : "Smelter's-Pickaxe", + "MAGNET" : "Magnet", + "BASIC_CIRCUIT_BOARD" : "Circuit-Boards", + "ADVANCED_CIRCUIT_BOARD" : "Circuit-Boards", + "BATTERY" : "Battery", + "STEEL_THRUSTER" : "Steel-Thruster", + "POWER_CRYSTAL" : "Power-Crystal", + "SOLAR_PANEL" : "Solar-Panel", + "ELECTRO_MAGNET" : "Electromagnet", + "ELECTRIC_MOTOR" : "Electric-Motor", + "HEATING_COIL" : "Heating-Coil", + "COPPER_WIRE" : "Copper-Wire", + "HARDENED_GLASS" : "Hardened-Glass", + "COOLING_UNIT" : "Cooling-Unit", + "WITHER_PROOF_OBSIDIAN" : "Wither-Proof-Blocks", + "WITHER_PROOF_GLASS" : "Wither-Proof-Blocks", + "REACTOR_COOLANT_CELL" : "Coolant-Cells", + "NETHER_ICE_COOLANT_CELL" : "Coolant-Cells", + "IRON_DUST" : "Iron-Dust", + "GOLD_DUST" : "Gold-Dust", + "GOLD_4K" : "Gold-Ingot", + "GOLD_6K" : "Gold-Ingot", + "GOLD_8K" : "Gold-Ingot", + "GOLD_10K" : "Gold-Ingot", + "GOLD_12K" : "Gold-Ingot", + "GOLD_14K" : "Gold-Ingot", + "GOLD_16K" : "Gold-Ingot", + "GOLD_18K" : "Gold-Ingot", + "GOLD_20K" : "Gold-Ingot", + "GOLD_22K" : "Gold-Ingot", + "GOLD_24K" : "Gold-Ingot", + "ENERGY_REGULATOR" : "Energy-Regulator", + "SMALL_CAPACITOR" : "Energy-Capacitors", + "MEDIUM_CAPACITOR" : "Energy-Capacitors", + "BIG_CAPACITOR" : "Energy-Capacitors", + "LARGE_CAPACITOR" : "Energy-Capacitors", + "CARBONADO_EDGED_CAPACITOR" : "Energy-Capacitors", + "SOLAR_GENERATOR" : "Solar-Generator", + "SOLAR_GENERATOR_2" : "Solar-Generator", + "SOLAR_GENERATOR_3" : "Solar-Generator", + "SOLAR_GENERATOR_4" : "Solar-Generator", + "COAL_GENERATOR" : "Coal-Generator", + "COAL_GENERATOR_2" : "Coal-Generator", + "COBALT_PICKAXE" : "Cobalt-Pickaxe", + "EXPLOSIVE_PICKAXE" : "Explosive-Pickaxe", + "EXPLOSIVE_SHOVEL" : "Explosive-Shovel", + "GRAPPLING_HOOK" : "Grappling-Hook", + "HERCULES_PICKAXE" : "Hercules'-Pickaxe", + "LUMBER_AXE" : "Lumber-Axe", + "PICKAXE_OF_VEIN_MINING" : "Pickaxe-of-Vein-Mining", + "PICKAXE_OF_THE_SEEKER" : "Pickaxe-of-the-Seeker", + "CARGO_OUTPUT_ADVANCED" : "Advanced-Output-Node", + "CARGO_MANAGER" : "Cargo-Manager", + "CARGO_MOTOR" : "Cargo-Motor", + "CARGO_NODE" : "Connector-Node", + "CARGO_INPUT" : "Input-Node", + "CARGO_OUTPUT" : "Output-Node", + "TRASH_CAN" : "Trash-Can", + "ORE_WASHER" : "Ore-Washer", + "SCUBA_HELMET" : "Hazmat-Suit", + "HAZMAT_CHESTPLATE" : "Hazmat-Suit", + "HAZMAT_LEGGINGS" : "Hazmat-Suit", + "RUBBER_BOOTS" : "Hazmat-Suit", + "ARMOR_FORGE" : "Armor-Forge", + "AUTOMATED_PANNING_MACHINE" : "Automated-Panning-Machine", + "COMPRESSOR" : "Compressor", + "ORE_CRUSHER" : "Ore-Crusher", + "PRESSURE_CHAMBER" : "Pressure-Chamber", + "GRIND_STONE" : "Grind-Stone", + "MAGIC_WORKBENCH" : "Magic-Workbench", + "PORTABLE_CRAFTER" : "Portable-Crafter", + "PORTABLE_DUSTBIN" : "Portable-Dustbin", + "COOLER" : "Cooler", + "ALUMINUM_BRASS_INGOT" : "Aluminum-Brass-Ingot", + "ALUMINUM_BRONZE_INGOT" : "Aluminum-Bronze-Ingot", + "ALUMINUM_DUST" : "Aluminum-Dust", + "ALUMINUM_INGOT" : "Aluminum-Ingot", + "GLOWSTONE_HELMET" : "Magical-Armor", + "GLOWSTONE_CHESTPLATE" : "Magical-Armor", + "GLOWSTONE_LEGGINGS" : "Magical-Armor", + "GLOWSTONE_BOOTS" : "Magical-Armor", + "ENDER_HELMET" : "Magical-Armor", + "ENDER_CHESTPLATE" : "Magical-Armor", + "ENDER_LEGGINGS" : "Magical-Armor", + "ENDER_BOOTS" : "Magical-Armor", + "SLIME_HELMET" : "Magical-Armor", + "SLIME_CHESTPLATE" : "Magical-Armor", + "SLIME_LEGGINGS" : "Magical-Armor", + "SLIME_BOOTS" : "Magical-Armor", + "CACTUS_HELMET" : "Armor", + "CACTUS_CHESTPLATE" : "Armor", + "CACTUS_LEGGINGS" : "Armor", + "CACTUS_BOOTS" : "Armor", + "DAMASCUS_STEEL_HELMET" : "Armor", + "DAMASCUS_STEEL_CHESTPLATE" : "Armor", + "DAMASCUS_STEEL_LEGGINGS" : "Armor", + "DAMASCUS_STEEL_BOOTS" : "Armor", + "REINFORCED_ALLOY_HELMET" : "Armor", + "REINFORCED_ALLOY_CHESTPLATE" : "Armor", + "REINFORCED_ALLOY_LEGGINGS" : "Armor", + "REINFORCED_ALLOY_BOOTS" : "Armor", + "GILDED_IRON_HELMET" : "Armor", + "GILDED_IRON_CHESTPLATE" : "Armor", + "GILDED_IRON_LEGGINGS" : "Armor", + "GILDED_IRON_BOOTS" : "Armor", + "GOLD_12K_HELMET" : "Armor", + "GOLD_12K_CHESTPLATE" : "Armor", + "GOLD_12K_LEGGINGS" : "Armor", + "GOLD_12K_BOOTS" : "Armor", + "SLIME_STEEL_HELMET" : "Magical-Armor", + "SLIME_STEEL_CHESTPLATE" : "Magical-Armor", + "SLIME_STEEL_LEGGINGS" : "Magical-Armor", + "SLIME_STEEL_BOOTS" : "Magical-Armor", + "BILLON_INGOT" : "Billon-Ingot", + "BLOCK_PLACER" : "Block-Placer", + "EXPLOSIVE_BOW" : "Bows", + "ICY_BOW" : "Bows", + "BRASS_INGOT" : "Brass-Ingot", + "BRONZE_INGOT" : "Bronze-Ingot", + "CHRISTMAS_MILK" : "Christmas-Items", + "CHRISTMAS_CHOCOLATE_MILK" : "Christmas-Items", + "CHRISTMAS_EGG_NOG" : "Christmas-Items", + "CHRISTMAS_APPLE_CIDER" : "Christmas-Items", + "CHRISTMAS_COOKIE" : "Christmas-Items", + "CHRISTMAS_FRUIT_CAKE" : "Christmas-Items", + "CHRISTMAS_APPLE_PIE" : "Christmas-Items", + "CHRISTMAS_HOT_CHOCOLATE" : "Christmas-Items", + "CHRISTMAS_CAKE" : "Christmas-Items", + "CHRISTMAS_CARAMEL" : "Christmas-Items", + "CHRISTMAS_CARAMEL_APPLE" : "Christmas-Items", + "CHRISTMAS_CHOCOLATE_APPLE" : "Christmas-Items", + "CHRISTMAS_PRESENT" : "Christmas-Items", + "RAINBOW_WOOL_XMAS" : "Christmas-Seasonal-Category", + "RAINBOW_GLASS_XMAS" : "Christmas-Seasonal-Category", + "RAINBOW_CLAY_XMAS" : "Christmas-Seasonal-Category", + "RAINBOW_GLASS_PANE_XMAS" : "Christmas-Seasonal-Category", + "RAINBOW_CONCRETE_XMAS" : "Christmas-Seasonal-Category", + "RAINBOW_GLAZED_TERRACOTTA_XMAS" : "Christmas-Seasonal-Category", + "COBALT_INGOT" : "Cobalt-Ingot", + "COPPER_DUST" : "Copper-Dust", + "COPPER_INGOT" : "Copper-Ingot", + "CORINTHIAN_BRONZE_INGOT" : "Corinthian-Bronze-Ingot", + "DAMASCUS_STEEL_INGOT" : "Damascus-Steel-Ingot", + "DURALUMIN_INGOT" : "Duralumin-Ingot", + "ELEVATOR_PLATE" : "Elevator-Plate", + "ELYTRA_SCALE" : "Elytras", + "INFUSED_ELYTRA" : "Elytras", + "SOULBOUND_ELYTRA" : "Elytras", + "ENHANCED_FURNACE" : "Enhanced-Furnaces", + "ENHANCED_FURNACE_2" : "Enhanced-Furnaces", + "ENHANCED_FURNACE_3" : "Enhanced-Furnaces", + "ENHANCED_FURNACE_4" : "Enhanced-Furnaces", + "ENHANCED_FURNACE_5" : "Enhanced-Furnaces", + "ENHANCED_FURNACE_6" : "Enhanced-Furnaces", + "ENHANCED_FURNACE_7" : "Enhanced-Furnaces", + "ENHANCED_FURNACE_8" : "Enhanced-Furnaces", + "ENHANCED_FURNACE_9" : "Enhanced-Furnaces", + "ENHANCED_FURNACE_10" : "Enhanced-Furnaces", + "ENHANCED_FURNACE_11" : "Enhanced-Furnaces", + "REINFORCED_FURNACE" : "Enhanced-Furnaces", + "CARBONADO_EDGED_FURNACE" : "Enhanced-Furnaces", + "FERROSILICON" : "Ferrosilicon", + "GEO_MINER" : "GEO-Miner", + "GPS_ACTIVATION_DEVICE_SHARED" : "GPS-Activation-Device", + "GPS_ACTIVATION_DEVICE_PERSONAL" : "GPS-Activation-Device", + "GPS_CONTROL_PANEL" : "GPS-Control-Panel", + "GPS_EMERGENCY_TRANSMITTER" : "GPS-Emergency-Transmitter", + "GPS_GEO_SCANNER" : "GPS-Geo-Scanner", + "GPS_MARKER_TOOL" : "GPS-Marker-Tool", + "GPS_TELEPORTATION_MATRIX" : "GPS-Teleporter-Matrix", + "GPS_TELEPORTER_PYLON" : "GPS-Teleporter-Pylon", + "GPS_TRANSMITTER" : "GPS-Transmitter", + "GILDED_IRON" : "Gilded-Iron", + "HARDENED_METAL_INGOT" : "Hardened-Metal", + "LEAD_DUST" : "Lead-Dust", + "LEAD_INGOT" : "Lead-Ingot", + "MAGNESIUM_DUST" : "Magnesium-Dust", + "MAGNESIUM_INGOT" : "Magnesium-Ingot", + "NICKEL_INGOT" : "Nickel-Ingot", + "OIL_PUMP" : "Oil-Pump", + "PORTABLE_GEO_SCANNER" : "Portable-Geo-Scanner", + "RAINBOW_WOOL" : "Rainbow-Blocks", + "RAINBOW_GLASS" : "Rainbow-Blocks", + "RAINBOW_CLAY" : "Rainbow-Blocks", + "RAINBOW_GLASS_PANE" : "Rainbow-Blocks", + "RAINBOW_CONCRETE" : "Rainbow-Blocks", + "RAINBOW_GLAZED_TERRACOTTA" : "Rainbow-Blocks", + "REDSTONE_ALLOY" : "Redstone-Alloy-Ingot", + "REINFORCED_ALLOY_INGOT" : "Reinforced-Alloy-Ingot", + "SILVER_DUST" : "Silver-Dust", + "SILVER_INGOT" : "Silver-Ingot", + "SOLDER_INGOT" : "Solder-Ingot", + "SOULBOUND_HELMET" : "Soulbound-Armor", + "SOULBOUND_CHESTPLATE" : "Soulbound-Armor", + "SOULBOUND_LEGGINGS" : "Soulbound-Armor", + "SOULBOUND_BOOTS" : "Soulbound-Armor", + "ANCIENT_RUNE_SOULBOUND" : "Soulbound-Rune", + "SOULBOUND_SWORD" : "Soulbound-Weapons", + "SOULBOUND_BOW" : "Soulbound-Weapons", + "SOULBOUND_PICKAXE" : "Soulbound-Weapons", + "SOULBOUND_AXE" : "Soulbound-Weapons", + "SOULBOUND_SHOVEL" : "Soulbound-Weapons", + "SOULBOUND_HOE" : "Soulbound-Weapons", + "SOULBOUND_TRIDENT" : "Soulbound-Weapons", + "STEEL_INGOT" : "Steel-Ingot", + "SWORD_OF_BEHEADING" : "Sword-of-Beheading", + "COMMON_TALISMAN" : "Talismans", + "ENDER_TALISMAN" : "Talismans", + "TIN_DUST" : "Tin-Dust", + "TIN_INGOT" : "Tin-Ingot", + "GRANDMAS_WALKING_STICK" : "Walking-Sticks", + "GRANDPAS_WALKING_STICK" : "Walking-Sticks", + "ZINC_DUST" : "Zinc-Dust", + "ZINC_INGOT" : "Zinc-Ingot" } diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestSlimefunGuideListener.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestSlimefunGuideListener.java index 91cee4018..7330fcbdc 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestSlimefunGuideListener.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestSlimefunGuideListener.java @@ -51,7 +51,7 @@ class TestSlimefunGuideListener { PlayerJoinEvent event = new PlayerJoinEvent(player, "CanIHazGuide has joined and wants sum guide"); listener.onJoin(event); - ItemStack guide = SlimefunGuide.getItem(SlimefunGuide.getDefaultLayout()); + ItemStack guide = SlimefunGuide.getItem(SlimefunGuide.getDefaultMode()); Assertions.assertEquals(!hasPlayedBefore && giveSlimefunGuide, hasSlimefunGuide(player, guide)); } From 7339a6ed4b5828bcbbc37f41410f4dacc4374aaf Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Wed, 13 Jan 2021 02:20:32 +0100 Subject: [PATCH 09/20] [CI skip] Refactoring --- .../slimefun4/api/MinecraftVersion.java | 36 ++++++++-------- .../slimefun4/api/SlimefunAddon.java | 18 -------- .../implementation/SlimefunPlugin.java | 41 +++++++++++-------- .../slimefun4/utils/HeadTexture.java | 2 - .../testing/tests/utils/TestHeadTextures.java | 2 +- .../tests/utils/TestMinecraftVersion.java | 9 ++-- 6 files changed, 49 insertions(+), 59 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/MinecraftVersion.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/MinecraftVersion.java index 73c3f855e..8090b4543 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/MinecraftVersion.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/MinecraftVersion.java @@ -6,6 +6,7 @@ import org.apache.commons.lang.Validate; import org.bukkit.Server; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import io.papermc.lib.PaperLib; /** * This enum holds all versions of Minecraft that we currently support. @@ -21,19 +22,19 @@ public enum MinecraftVersion { * This constant represents Minecraft (Java Edition) Version 1.14 * (The "Village & Pillage" Update) */ - MINECRAFT_1_14("1.14.x"), + MINECRAFT_1_14(14, "1.14.x"), /** * This constant represents Minecraft (Java Edition) Version 1.15 * (The "Buzzy Bees" Update) */ - MINECRAFT_1_15("1.15.x"), + MINECRAFT_1_15(15, "1.15.x"), /** * This constant represents Minecraft (Java Edition) Version 1.16 * (The "Nether Update") */ - MINECRAFT_1_16("1.16.x"), + MINECRAFT_1_16(16, "1.16.x"), /** * This constant represents an exceptional state in which we were unable @@ -51,7 +52,7 @@ public enum MinecraftVersion { private final String name; private final boolean virtual; - private final String prefix; + private final int majorVersion; /** * This constructs a new {@link MinecraftVersion} with the given name. @@ -61,8 +62,10 @@ public enum MinecraftVersion { * @param name * The display name of this {@link MinecraftVersion} */ - MinecraftVersion(@Nonnull String name) { - this(name, false); + MinecraftVersion(int majorVersion, @Nonnull String name) { + this.name = name; + this.majorVersion = majorVersion; + this.virtual = false; } /** @@ -77,8 +80,8 @@ public enum MinecraftVersion { */ MinecraftVersion(@Nonnull String name, boolean virtual) { this.name = name; + this.majorVersion = 0; this.virtual = virtual; - this.prefix = name().replace("MINECRAFT_", "v") + '_'; } /** @@ -105,18 +108,19 @@ public enum MinecraftVersion { } /** - * This method checks whether the given version matches with this + * This tests if the given minecraft version number matches with this * {@link MinecraftVersion}. + *

+ * You can obtain the version number by doing {@link PaperLib#getMinecraftVersion()}. + * It is equivalent to the "major" version + *

+ * Example: {@literal "1.13"} returns {@literal 13} * - * @param version - * The version to compare - * - * @return Whether the version matches with this one + * @param minecraftVersion + * @return */ - public boolean matches(@Nonnull String version) { - Validate.notNull(version, "The input version must not be null!"); - - return version.startsWith(prefix); + public boolean isMinecraftVersion(int minecraftVersion) { + return !isVirtual() && this.majorVersion == minecraftVersion; } /** diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunAddon.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunAddon.java index 610791493..39a402501 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunAddon.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunAddon.java @@ -1,21 +1,15 @@ package io.github.thebusybiscuit.slimefun4.api; -import java.util.Collection; -import java.util.Locale; import java.util.logging.Logger; -import java.util.stream.Collectors; import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.apache.commons.lang.Validate; -import org.bukkit.NamespacedKey; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.java.JavaPlugin; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; -import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; /** @@ -106,16 +100,4 @@ public interface SlimefunAddon { return description.getDepend().contains(dependency) || description.getSoftDepend().contains(dependency); } - /** - * This returns a {@link Collection} holding every {@link Category} that can be directly - * linked to this {@link SlimefunAddon} based on its {@link NamespacedKey}. - * - * @return A {@link Collection} of every {@link Category} from this addon - */ - @Nonnull - default Collection getCategories() { - String namespace = getJavaPlugin().getName().toLowerCase(Locale.ROOT); - return SlimefunPlugin.getRegistry().getCategories().stream().filter(cat -> cat.getKey().getNamespace().equals(namespace)).collect(Collectors.toList()); - } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java index 92d30ab5f..b2a49b7ba 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java @@ -21,6 +21,7 @@ import org.bukkit.Server; import org.bukkit.command.Command; import org.bukkit.entity.Player; import org.bukkit.event.Listener; +import org.bukkit.inventory.Recipe; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.java.JavaPlugin; @@ -29,7 +30,6 @@ import org.bukkit.scheduler.BukkitTask; import io.github.thebusybiscuit.cscorelib2.config.Config; import io.github.thebusybiscuit.cscorelib2.protection.ProtectionManager; -import io.github.thebusybiscuit.cscorelib2.reflection.ReflectionUtils; import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; import io.github.thebusybiscuit.slimefun4.api.exceptions.TagMisconfigurationException; @@ -502,13 +502,13 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { } // Now check the actual Version of Minecraft - String currentVersion = ReflectionUtils.getVersion(); + int version = PaperLib.getMinecraftVersion(); - if (currentVersion.startsWith("v")) { + if (version > 0) { // Check all supported versions of Minecraft - for (MinecraftVersion version : MinecraftVersion.valuesCache) { - if (version.matches(currentVersion)) { - minecraftVersion = version; + for (MinecraftVersion supportedVersion : MinecraftVersion.valuesCache) { + if (supportedVersion.isMinecraftVersion(version)) { + minecraftVersion = supportedVersion; return false; } } @@ -518,22 +518,22 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { getLogger().log(Level.SEVERE, "### Slimefun was not installed correctly!"); getLogger().log(Level.SEVERE, "### You are using the wrong version of Minecraft!"); getLogger().log(Level.SEVERE, "###"); - getLogger().log(Level.SEVERE, "### You are using Minecraft {0}", currentVersion); + getLogger().log(Level.SEVERE, "### You are using Minecraft 1.{0}.x", version); getLogger().log(Level.SEVERE, "### but Slimefun {0} requires you to be using", getDescription().getVersion()); getLogger().log(Level.SEVERE, "### Minecraft {0}", String.join(" / ", getSupportedVersions())); getLogger().log(Level.SEVERE, "#############################################"); return true; + } else { + getLogger().log(Level.WARNING, "We could not determine the version of Minecraft you were using? ({0})", Bukkit.getVersion()); + + /* + * If we are unsure about it, we will assume "supported". + * They could be using a non-Bukkit based Software which still + * might support Bukkit-based plugins. + * Use at your own risk in this case. + */ + return false; } - - getLogger().log(Level.WARNING, "We could not determine the version of Minecraft you were using ({0})", currentVersion); - - /* - * If we are unsure about it, we will assume "supported". - * They could be using a non-Bukkit based Software which still - * might support Bukkit-based plugins. - * Use at your own risk in this case. - */ - return false; } catch (Exception | LinkageError x) { getLogger().log(Level.SEVERE, x, () -> "Error: Could not determine Environment or version of Minecraft for Slimefun v" + getDescription().getVersion()); @@ -792,6 +792,13 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { return instance.local; } + /** + * This method returns out {@link MinecraftRecipeService} for Slimefun. + * This service is responsible for finding/identifying {@link Recipe Recipes} + * from vanilla Minecraft. + * + * @return Slimefun's {@link MinecraftRecipeService} instance + */ @Nonnull public static MinecraftRecipeService getMinecraftRecipeService() { validateInstance(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/HeadTexture.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/HeadTexture.java index ce1b5b7c7..4c041af0f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/HeadTexture.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/HeadTexture.java @@ -114,8 +114,6 @@ public enum HeadTexture { PIGLIN_HEAD("2882af1294a74023e6919a31d1a027310f2e142afb4667d230d155e7f21dbb41"), NECROTIC_SKULL("7953b6c68448e7e6b6bf8fb273d7203acd8e1be19e81481ead51f45de59a8"); - public static final HeadTexture[] valuesCache = values(); - private final String texture; private final UUID uuid; diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/utils/TestHeadTextures.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/utils/TestHeadTextures.java index 601d0d335..c320da673 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/utils/TestHeadTextures.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/utils/TestHeadTextures.java @@ -16,7 +16,7 @@ class TestHeadTextures { void testForDuplicates() { Set textures = new HashSet<>(); - for (HeadTexture head : HeadTexture.valuesCache) { + for (HeadTexture head : HeadTexture.values()) { String texture = head.getTexture(); Assertions.assertNotNull(texture); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/utils/TestMinecraftVersion.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/utils/TestMinecraftVersion.java index 1bdb43a44..ed1fa31d8 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/utils/TestMinecraftVersion.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/utils/TestMinecraftVersion.java @@ -11,12 +11,11 @@ class TestMinecraftVersion { @Test @DisplayName("Test if Minecraft versions match themselves") void testMatches() { - Assertions.assertTrue(MinecraftVersion.MINECRAFT_1_14.matches("v1_14_R2")); - Assertions.assertTrue(MinecraftVersion.MINECRAFT_1_15.matches("v1_15_R1")); + Assertions.assertTrue(MinecraftVersion.MINECRAFT_1_14.isMinecraftVersion(14)); + Assertions.assertTrue(MinecraftVersion.MINECRAFT_1_15.isMinecraftVersion(15)); - Assertions.assertFalse(MinecraftVersion.MINECRAFT_1_15.matches("v1_14_R2")); - Assertions.assertFalse(MinecraftVersion.MINECRAFT_1_14.matches("1.14.x")); - Assertions.assertThrows(IllegalArgumentException.class, () -> MinecraftVersion.MINECRAFT_1_14.matches(null)); + Assertions.assertFalse(MinecraftVersion.MINECRAFT_1_15.isMinecraftVersion(14)); + Assertions.assertFalse(MinecraftVersion.MINECRAFT_1_14.isMinecraftVersion(0)); } @Test From 889ffe48720365f37516f81493dfa0dfd30eb50e Mon Sep 17 00:00:00 2001 From: CURVX Date: Wed, 13 Jan 2021 10:31:45 +0530 Subject: [PATCH 10/20] Few minor changes --- .../slimefun4/core/attributes/NotHopperable.java | 2 +- .../implementation/listeners/HopperListener.java | 15 ++------------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotHopperable.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotHopperable.java index 115c31e52..5e284e569 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotHopperable.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotHopperable.java @@ -9,6 +9,6 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; * @author CURVX * */ -public interface NotHopperable { +public interface NotHopperable extends ItemAttribute { } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/HopperListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/HopperListener.java index 54c6ebddf..94c07556e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/HopperListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/HopperListener.java @@ -8,14 +8,8 @@ import org.bukkit.event.Listener; import org.bukkit.event.inventory.InventoryMoveItemEvent; import org.bukkit.event.inventory.InventoryType; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotHopperable; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.AutoBrewer; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.AutoDrier; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.ElectricFurnace; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.ElectricIngotPulverizer; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.ElectricOreGrinder; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.ElectricSmeltery; +import io.github.thebusybiscuit.slimefun4.core.attributes.NotHopperable; import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; @@ -25,12 +19,7 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; * * @author CURVX * - * @see AutoBrewer - * @see AutoDrier - * @see ElectricFurnace - * @see ElectricIngotPulverizer - * @see ElectricOreGrinder - * @see ElectricSmeltery + * @see NotHopperable * */ public class HopperListener implements Listener { From a69226dd76685eb65ad9d0b922add88534eb1496 Mon Sep 17 00:00:00 2001 From: Nameless Date: Wed, 13 Jan 2021 05:23:28 +0000 Subject: [PATCH 11/20] Translate messages_zh-CN.yml via GitLocalize --- .../resources/languages/messages_zh-CN.yml | 112 +++++++++--------- 1 file changed, 58 insertions(+), 54 deletions(-) diff --git a/src/main/resources/languages/messages_zh-CN.yml b/src/main/resources/languages/messages_zh-CN.yml index d49cafb64..2421eab20 100644 --- a/src/main/resources/languages/messages_zh-CN.yml +++ b/src/main/resources/languages/messages_zh-CN.yml @@ -1,12 +1,11 @@ --- commands: - help: 展示此帮助页面 - cheat: 使用作弊模式获取 Slimefun 的物品 - give: 给某人 Slimefun 物品 - guide: 给你自己一本 Slimefun 指南 - timings: 查看关于 Slimefun 的耗能信息 - teleporter: 查看其他玩家的公开传送点 - versions: 列出已安装的扩展插件 + help: 显示此帮助 + cheat: 直接拿取 Slimefun 物品 + give: 给予玩家 Slimefun 物品 + guide: 获取一本 Slimefun 指南书 + teleporter: 查看其他玩家的公共传送点 + versions: 显示 Slimefun 运行环境 search: 搜索 Slimefun 物品 open_guide: 使用命令打开 Slimefun 指南 stats: 查看玩家的统计数据 @@ -24,9 +23,14 @@ commands: description: 为你手持的物品充电 charge-success: 充电完成! not-rechargeable: 这个物品不能充电! + timings: + description: Slimefun 及其附属插件的性能报告 + please-wait: "&e请稍等一会...结果马上就来!" + verbose-player: "&4该标记不能对玩家使用!" + unknown-flag: "&4未知标记: &c%flag%" guide: search: - message: "&b你想要搜索什么?" + message: "&b今天要搜些什么?" name: "&7搜索..." tooltip: "&b单击搜索物品" inventory: '正在搜索: %item%' @@ -34,28 +38,28 @@ guide: - "&b你想要搜索什么?" - "&7将要搜索的物品的名字输入在聊天栏上" cheat: - no-multiblocks: "&4你不能在作弊模式下直接获得多方块结构的机器, 你必须自己建造!" + no-multiblocks: "&4你不能在作弊模式下获得多方块结构的机器, 必须按书中所示建造!" languages: - updated: "&a你的语言已设为: &b%lang%" + updated: "&a成功修改语言为: &b%lang%" translations: name: "&a少了些什么?" lore: 单击添加你自己的翻译 select: 单击选中此语言 select-default: 单击选中默认语言 selected-language: '目前使用的语言:' - change: 单击选择新的语言 + change: 单击选择要更改的语言 description: - - "&7现在你有了修改 Slimefun" - - "&7展示给你的文本语言选项了." - - "&7物品中的文本" - - "&7还不能够修改." + - "&7现在你可以修改 Slimefun" + - "&7展示的文本消息的语言了." + - "&7注意: 物品中的文本" + - "&7暂时无法修改." title: main: Slimefun 指南 - settings: 设置 & 关于 - languages: 选择你想要的语言 + settings: 设置 & 详情 + languages: 选择你想要更改的语言 credits: Slimefun4 贡献者 wiki: Slimefun4 维基 - addons: Slimefun4 扩展 + addons: Slimefun4 附属插件 bugs: 问题反馈 source: 源代码 versions: 安装的版本 @@ -67,8 +71,8 @@ guide: wiki: "&3Wiki 编辑者" resourcepack: "&c材质制作者" translator: "&9翻译者" - profile-link: 单击访问TA们的 Github 个人主页 - open: 单击查看我们的贡献者 + profile-link: 单击访问他们的 Github 个人主页 + open: 单击查看贡献者名单 description: - "&7Slimefun 是一个开源的项目" - "&7并且由玩家社区维护." @@ -84,7 +88,7 @@ guide: recipes: machine: 此机器可用的合成配方 miner: 此采矿机可以获得的资源 - generator: 可用的燃料种类 + generator: 可用的燃料类型 gold-pan: 你可以获得的资源 climbing-pick: 你可以攀爬的平面 back: @@ -96,14 +100,14 @@ guide: - 为了解锁这一类别 - 你需要先解锁以下 - 类别里的所有物品 - work-in-progress: 这个功能还没完全做完! + work-in-progress: 该功能暂未推出! messages: - not-researched: "&4你没有足够的学识来理解它" + not-researched: "&4你的知识还不足以理解这个物品" not-enough-xp: "&4你没有足够的经验来解锁这个研究" unlocked: '&b成功解锁研究 &7"%research%"' only-players: "&4这个指令只能在游戏内使用" unknown-player: "&4未知玩家: &c%player%" - no-permission: "&4你没有足够的权限做这个" + no-permission: "&4你没有足够的权限这么做" usage: "&4用法: &c%usage%" not-online: "&4%player% &c不在线" given-item: '&b你获得了 &a%amount% &7"%item%&7"' @@ -123,25 +127,25 @@ messages: angel: "&a&o你的护身符使你在信仰之跃时不受伤害" fire: "&a&o你的护身符使你免受火焰伤害" magician: "&a&o你的护身符赠送了你额外的附魔" - traveller: "&a&o你的护身符让你跑起来更快了" - warrior: "&a&o你的护身符使你在一段时间内变强了" + traveller: "&a&o你的护身符让你跑得更快了" + warrior: "&a&o你的护身符使你变强了" knight: "&a&o你的护身符给予了你 5 秒的生命恢复" - whirlwind: "&a&o你的护身符反弹了所有的弹射物" - wizard: "&a&o你的护身符使一个附魔的等级提高了, 同时其他附魔等级将会下降" + whirlwind: "&a&o你的护身符反弹了所有射向你的投掷物" + wizard: "&a&o你的护身符随机提高了一个附魔的等级, 但其他的附魔等级将会下降" caveman: "&a&o你的护身符给予了你急迫效果" soulbound-rune: - fail: "&c一次只能灵魂绑定一个物品." + fail: "&c灵魂一次只能绑定一个物品." success: "&a物品绑定成功! 在你死亡后此物品将不会掉落." research: - start: "&7古老的灵魂正向你诉说神秘的话语!" - progress: "&7你开始慢慢理解研究 &b%research% &e(%progress%)" + start: "&7古老的灵魂正向你低语其中的神秘!" + progress: "&7你逐渐开始理解研究 &b%research% &e(%progress%)" fire-extinguish: "&7你灭掉了身上的火" cannot-place: "&c你不能在这里放置方块!" - no-pvp: "&c你不能在这里 PVP!" + no-pvp: "&c你不能在这里攻击其他玩家!" radiation: "&4你已经暴露在致命的辐射之下! &c快把辐射物品丢掉或者穿上防化服!" opening-guide: "&b正在打开指南书, 请稍等..." opening-backpack: "&b正在打开背包, 请稍等...." - no-iron-golem-heal: "&c这不是铁锭. 你不能用这个治疗铁傀儡!" + no-iron-golem-heal: "&c这不是铁锭. 不能用来治疗铁傀儡!" link-prompt: "&e单击此处:" diet-cookie: "&e你感觉变轻了..." fortune-cookie: @@ -159,7 +163,7 @@ messages: - "&7要总是看着生活中光明的一面!" - "&7这一块其实是饼干而不是曲奇" - "&7霓虹灯亮起来了!" - piglin-barter: "&4你不能使用 Slimefun 的物品和猪灵以物换物" + piglin-barter: "&4你不能使用 Slimefun 的物品和猪灵易物" enchantment-rune: fail: "&c你不能附魔这个物品." no-enchantment: "&c无法找到此物品可用的附魔属性." @@ -167,21 +171,21 @@ messages: tape-measure: no-anchor: "&c在开始测量之前请先选定测量起点!" wrong-world: "&c你设置的起点似乎在另一个世界!" - distance: "&7已测量到距离, &e为: %distance%" + distance: "&7距离已测量, &e为: %distance%" anchor-set: "&a成功在 &e %anchor% &a设置了测量起点" multi-tool: mode-change: "&b%device% 的模式已切换为: &9%mode%" - not-shears: "&c多功能工具 (Multi Tool) 不能当成剪刀来用!" + not-shears: "&c多功能工具 (Multi Tool) 不能作为剪刀使用!" climbing-pick: dual-wielding: "&4你需要双手拿着攀岩镐才能使用!" - wrong-material: "&c你不能爬上这个平面. 查看指南书了解更多!" + wrong-material: "&c你不能爬上这个平面. 查看指南书了解详情!" invalid-item: "&4%item% &c不是一个有效的物品名!" invalid-amount: "&4%amount% &ci不是一个有效的数字 : 它必须大于 0!" invalid-research: "&4%research% &c不是一个有效的研究名!" - bee-suit-slow-fall: "&e你的蜂翅会让你安全且缓慢地回到地面" + bee-suit-slow-fall: "&e你的蜂翅将会让你安全缓降" mode-change: "&b%device% 的模式已切换为: &9%mode%" machines: - pattern-not-found: "&e抱歉, 你记错合成表了吧. 这不是一个正确的合成配方, 请检查发射器里放置物品的顺序." + pattern-not-found: "&e抱歉, 这不是正确的合成配方, 请检查发射器里放置物品的顺序." unknown-material: "&e抱歉, 我无法识别在发射器里的物品. 请按照合成配方放置物品." wrong-item: "&e抱歉, 我无法识别你右键的物品. 检查指南书看看哪些物品可以使用." full-inventory: "&e抱歉, 物品栏已经满了!" @@ -190,14 +194,14 @@ machines: ANCIENT_ALTAR: not-enough-pedestals: "&4古代基座不足. 目前已摆放的基座数: &c(%pedestals% / 8)" unknown-catalyst: "&4无效的催化剂! &c请按照合成配方正确摆放物品!" - unknown-recipe: "&4未知合成表! &c请使用正确的合成配方!" + unknown-recipe: "&4未知合成表! &c请按照合成配方正确摆放物品!" ANCIENT_PEDESTAL: obstructed: "&4基座被挡住了! &c把基座上面的东西移开!" HOLOGRAM_PROJECTOR: enter-text: "&7请写下想显示在全息文本上的话. &r(支持颜色代码)" inventory-title: 全息图像编辑器 ELEVATOR: - no-destinations: "&4找不到目的地" + no-destinations: "&4找不到上下楼" pick-a-floor: "&3- 选择一个楼层 -" current-floor: "&e你现在所在的楼层:" click-to-teleport: "&e单击 &7传送至楼层:" @@ -213,10 +217,10 @@ machines: tooltip: 单击传送 time: 预计时间 CARGO_NODES: - must-be-placed: "&4必须放置在箱子或机器上!" + must-be-placed: "&4货运节点必须放置在箱子或机器上!" GPS_CONTROL_PANEL: title: GPS - 控制面板 - transmitters: 信号发射器概览 + transmitters: 信号发射机详情 waypoints: 传送点列表 INDUSTRIAL_MINER: no-fuel: "&c你的工业矿机没有燃料了! 将燃料放入它上面的箱子里." @@ -225,7 +229,7 @@ machines: destroyed: "&c你的工业矿机被拆除了." already-running: "&c这个工业矿机正在运行!" full-chest: "&c你的工业矿机的箱子已经满了!" - no-permission: "&4你没有权限在此操作此工业矿机!" + no-permission: "&4你没有权限操作这台工业矿机!" finished: "&e你的工业矿机采矿已完成! 总共开采了 %ores% 个矿石!" anvil: not-working: "&4你不能在铁砧里使用 Slimefun 的物品" @@ -236,14 +240,14 @@ backpack: workbench: not-enhanced: "&4你不能在普通的工作台上使用 Slimefun 物品" gps: - deathpoint: "&4死亡地点 &7%date%" + deathpoint: "&4死亡点 &7%date%" waypoint: new: "&e给你的路径点起个名字吧 &7(支持彩色代码!)" added: "&a成功添加了新的传送点" max: "&4你已到达设置传送点个数的最大上限" - duplicate: "&4你已经创建了一个相同名字的传送点了: &f%waypoint%" + duplicate: "&4已经有相同名字的传送点了: &f%waypoint%" insufficient-complexity: - - "&4GPS网络复杂度不足: &c%complexity%" + - "&4GPS 网络复杂度不足: &c%complexity%" - "&4a) 你还没有设置一个 GPS 网络" - "&4b) 你的 GPS 网络复杂度不够, 多放置几个 GPS 信号发射机" geo: @@ -251,10 +255,10 @@ gps: inventory: no-access: "&4你没有权限使用这个方块" android: - started: "&7你的机器人开始运行脚本" - stopped: "&7你的机器人暂停运行了脚本" + started: "&7机器人正在依照脚本运行" + stopped: "&7机器人停止了运行" scripts: - already-uploaded: "&4这个脚本已经上传过了." + already-uploaded: "&4你已经上传过这个脚本了." instructions: START: "&2运行脚本" REPEAT: "&9重复运行脚本" @@ -278,8 +282,8 @@ android: CATCH_FISH: "&b钓鱼" FARM_FORWARD: "&b自动采收并补种作物" FARM_DOWN: "&b自动采收并补种下面的作物" - FARM_EXOTIC_FORWARD: "&b自动采收并补种作物 &7(支持异域花园植物)" - FARM_EXOTIC_DOWN: "&b自动采收并补种下面的作物 &7(支持异域花园植物)" + FARM_EXOTIC_FORWARD: "&b自动采收并补种所有作物" + FARM_EXOTIC_DOWN: "&b自动采收并补种下面的所有作物" INTERFACE_ITEMS: "&9将物品栏里的物品放入面前的容器" INTERFACE_FUEL: "&c从面前的容器中拿出燃料" enter-name: @@ -313,7 +317,6 @@ languages: zh-CN: 简体中文 (中国) el: 希腊语 he: 希伯来语 - pt: 葡萄牙语 (葡萄牙) ar: 阿拉伯语 af: 南非语 da: 丹麦语 @@ -325,6 +328,7 @@ languages: fa: 波斯语 th: 泰语 ro: 罗马尼亚语 + pt: 葡萄牙语 (葡萄牙) pt-BR: 葡萄牙语 (巴西) bg: 保加利亚语 ko: 韩语 @@ -341,6 +345,6 @@ villagers: cartography_table: not-working: "&4你不能在制图台中使用 Slimefun 物品!" cauldron: - no-discoloring: "&4你不能用炼药锅清洗 Slimefun 物品上的颜色" + no-discoloring: "&4你不能用炼药锅洗去 Slimefun 物品的颜色" miner: no-ores: "&e抱歉, 周围找不到矿石了!" From b0f576844321a29e6bfa9055a7b0f1f56ad8c301 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Wed, 13 Jan 2021 12:46:16 +0100 Subject: [PATCH 12/20] [CI skip] Removed a deprecated method --- .../me/mrCookieSlime/Slimefun/Objects/Category.java | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/Category.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/Category.java index 7f174deea..e2c7bdd99 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/Category.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/Category.java @@ -110,17 +110,6 @@ public class Category implements Keyed { Collections.sort(SlimefunPlugin.getRegistry().getCategories(), Comparator.comparingInt(Category::getTier)); } - /** - * Old way of registering categories, do not call this manually. - * - * @deprecated Please use {@link #register(SlimefunAddon)} instead. - */ - @Deprecated - public void register() { - SlimefunPlugin.getRegistry().getCategories().add(this); - Collections.sort(SlimefunPlugin.getRegistry().getCategories(), Comparator.comparingInt(Category::getTier)); - } - /** * This returns the {@link SlimefunAddon} which has registered this {@link Category}. * Or null if it has not been registered yet. From faa3219add30d8396dea9a2ac7b789ccab212208 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Wed, 13 Jan 2021 13:15:05 +0100 Subject: [PATCH 13/20] Added an additional item warning for illegal stack sizes --- .../Objects/SlimefunItem/SlimefunItem.java | 44 ++++++++++++++----- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SlimefunItem.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SlimefunItem.java index f1bfe75e5..6c82dd51a 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SlimefunItem.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SlimefunItem.java @@ -12,6 +12,7 @@ import java.util.logging.Logger; import javax.annotation.Nonnull; import javax.annotation.Nullable; +import javax.annotation.ParametersAreNonnullByDefault; import org.apache.commons.lang.Validate; import org.bukkit.Material; @@ -130,6 +131,7 @@ public class SlimefunItem implements Placeable { * @param recipe * An Array representing the recipe of this {@link SlimefunItem} */ + @ParametersAreNonnullByDefault public SlimefunItem(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { this(category, item, recipeType, recipe, null); } @@ -148,6 +150,7 @@ public class SlimefunItem implements Placeable { * @param recipeOutput * The result of crafting this item */ + @ParametersAreNonnullByDefault public SlimefunItem(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) { Validate.notNull(category, "'category' is not allowed to be null!"); Validate.notNull(item, "'item' is not allowed to be null!"); @@ -162,6 +165,7 @@ public class SlimefunItem implements Placeable { } // Previously deprecated constructor, now only for internal purposes + @ParametersAreNonnullByDefault protected SlimefunItem(Category category, ItemStack item, String id, RecipeType recipeType, ItemStack[] recipe) { Validate.notNull(category, "'category' is not allowed to be null!"); Validate.notNull(item, "'item' is not allowed to be null!"); @@ -371,7 +375,7 @@ public class SlimefunItem implements Placeable { * @return The {@link SlimefunAddon} that registered this {@link SlimefunItem} */ @Nonnull - public SlimefunAddon getAddon() { + public final SlimefunAddon getAddon() { if (addon == null) { throw new UnregisteredItemException(this); } @@ -482,6 +486,16 @@ public class SlimefunItem implements Placeable { // Send out deprecation warnings for any classes or interfaces checkForDeprecations(getClass()); + // Check for an illegal stack size + if (itemStackTemplate.getAmount() != 1) { + // @formatter:off + warn("This item has an illegal stack size: " + itemStackTemplate.getAmount() + + "An Item size of 1 is recommended. Please inform the autho of " + addon.getName() + + " to fix this. Crafting Results with amounts of higher should be handled" + + " via the recipeOutput parameter!"); + // @formatter:on + } + // Add it to the list of enabled items SlimefunPlugin.getRegistry().getEnabledSlimefunItems().add(this); @@ -501,13 +515,17 @@ public class SlimefunItem implements Placeable { if (exception.isPresent()) { throw exception.get(); } else { - // Make developers or at least Server admins aware that - // an Item is using a deprecated ItemHandler + /* + * Make developers or at least Server admins aware that an Item + * is using a deprecated ItemHandler + */ checkForDeprecations(handler.getClass()); } - // If this ItemHandler is "public" (not bound to this SlimefunItem), - // we add it to the list of public Item handlers + /* + * If this ItemHandler is "public" (not bound to this SlimefunItem), + * we add it to the list of public Item handlers + */ if (!handler.isPrivate()) { Set handlerset = getPublicItemHandlers(handler.getIdentifier()); handlerset.add(handler); @@ -563,15 +581,19 @@ public class SlimefunItem implements Placeable { */ private void checkForDeprecations(@Nullable Class c) { if (SlimefunPlugin.getUpdater().getBranch() == SlimefunBranch.DEVELOPMENT) { - // This method is currently way too spammy with all the restructuring going on... - // Since DEV builds are anyway under "development", things may be relocated. - // So we fire these only for stable versions, since devs should update then, so - // it's the perfect moment to tell them to act. + /* + * This method is currently way too spammy with all the restructuring going on... + * Since DEV builds are anyway under "development", things may be relocated. + * So we fire these only for stable versions, since devs should update then, so + * it's the perfect moment to tell them to act. + */ return; } - // We do not wanna throw an Exception here since this could also mean that - // we have reached the end of the Class hierarchy + /* + * We do not wanna throw an Exception here since this could also mean that. + * We have reached the end of the Class hierarchy + */ if (c != null) { // Check if this Class is deprecated if (c.isAnnotationPresent(Deprecated.class)) { From 6e27ea0ca1ed3e39159708985c1c38686e81b2ce Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Wed, 13 Jan 2021 13:48:56 +0100 Subject: [PATCH 14/20] [CI skip] Fixed javadocs --- .../thebusybiscuit/slimefun4/api/MinecraftVersion.java | 6 +++++- .../java/me/mrCookieSlime/Slimefun/Objects/Category.java | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/MinecraftVersion.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/MinecraftVersion.java index 8090b4543..17238d76d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/MinecraftVersion.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/MinecraftVersion.java @@ -59,6 +59,8 @@ public enum MinecraftVersion { * This constructor forces the {@link MinecraftVersion} to be real. * It must be a real version of Minecraft. * + * @param majorVersion + * The major version of minecraft as an {@link Integer} * @param name * The display name of this {@link MinecraftVersion} */ @@ -117,7 +119,9 @@ public enum MinecraftVersion { * Example: {@literal "1.13"} returns {@literal 13} * * @param minecraftVersion - * @return + * The {@link Integer} version to match + * + * @return Whether this {@link MinecraftVersion} matches the specified version id */ public boolean isMinecraftVersion(int minecraftVersion) { return !isVirtual() && this.majorVersion == minecraftVersion; diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/Category.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/Category.java index e2c7bdd99..cf95721f3 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/Category.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/Category.java @@ -268,7 +268,7 @@ public class Category implements Keyed { /** * This method returns whether this {@link Category} has been registered yet. - * More specifically: Whether {@link #register()} was called or not. + * More specifically: Whether {@link #register(SlimefunAddon)} was called or not. * * @return Whether this {@link Category} has been registered */ From f9a138b79c9ff2ba45218f9bf7933fc04c8413e2 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Wed, 13 Jan 2021 15:33:29 +0100 Subject: [PATCH 15/20] [CI skip] Added Triage workflow --- .github/TRIAGE_WORKFLOW.svg | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .github/TRIAGE_WORKFLOW.svg diff --git a/.github/TRIAGE_WORKFLOW.svg b/.github/TRIAGE_WORKFLOW.svg new file mode 100644 index 000000000..2bafce911 --- /dev/null +++ b/.github/TRIAGE_WORKFLOW.svg @@ -0,0 +1,3 @@ + + +
Yes
Yes
No
No
Related to
an addon?
Related to...
No
No
Yes
Yes
Using RC-version?
Using RC-versio...
Comment and tell them to update their version and their post
Comment and tell the...
Labels:
- invalid
Labels:...
Comment and post a
link to the correct bug tracker
Comment and post a...
Close Issue
Close Issue
Close Issue
Close Issue
Did they
update and respond?
Did they...
New Issue
New Issue
Reopen Issue
Reopen Issue
Set up a local test server and see if
you can reproduce the issue
Set up a local test...
No
No
Yes
Yes
Template
missing or
incomplete?
Template...
Comment and tell them to fill out the template correctly.
Comment and tell the...
Labels:
- invalid
Labels:...
Close Issue
Close Issue
Yes
Yes
No
No
Issue was
reproduced?
Issue was...
Labels:
- Bug Report
- Confirmed Bug
Labels:...
Labels:
- Bug Report
- Cannot reproduce
Labels:...
Comment and tell them that it could
not be reproduced
Comment and tell the...
Close Issue
Close Issue
Comment and give further context on how to reproduce it.

Examples:
- Video footage
- Screenshots
- Plugins list
- /sf versions
- Server log
Comment and give fur...
No
No
Yes
Yes
Is there
an open Issue
about it?
Is there...
Comment:
"Duplicate of #ISSUE"
Comment:...
Labels:
- Bug Report
- Duplicate
Labels:...
Close Issue
Close Issue
Viewer does not support full SVG 1.1
From 4494a3282629ef2c6f4ed71706c774032979eb58 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Wed, 13 Jan 2021 15:55:12 +0100 Subject: [PATCH 16/20] [CI skip] Updated diagram --- .github/TRIAGE_WORKFLOW.svg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/TRIAGE_WORKFLOW.svg b/.github/TRIAGE_WORKFLOW.svg index 2bafce911..d7284d8f7 100644 --- a/.github/TRIAGE_WORKFLOW.svg +++ b/.github/TRIAGE_WORKFLOW.svg @@ -1,3 +1,3 @@ -
Yes
Yes
No
No
Related to
an addon?
Related to...
No
No
Yes
Yes
Using RC-version?
Using RC-versio...
Comment and tell them to update their version and their post
Comment and tell the...
Labels:
- invalid
Labels:...
Comment and post a
link to the correct bug tracker
Comment and post a...
Close Issue
Close Issue
Close Issue
Close Issue
Did they
update and respond?
Did they...
New Issue
New Issue
Reopen Issue
Reopen Issue
Set up a local test server and see if
you can reproduce the issue
Set up a local test...
No
No
Yes
Yes
Template
missing or
incomplete?
Template...
Comment and tell them to fill out the template correctly.
Comment and tell the...
Labels:
- invalid
Labels:...
Close Issue
Close Issue
Yes
Yes
No
No
Issue was
reproduced?
Issue was...
Labels:
- Bug Report
- Confirmed Bug
Labels:...
Labels:
- Bug Report
- Cannot reproduce
Labels:...
Comment and tell them that it could
not be reproduced
Comment and tell the...
Close Issue
Close Issue
Comment and give further context on how to reproduce it.

Examples:
- Video footage
- Screenshots
- Plugins list
- /sf versions
- Server log
Comment and give fur...
No
No
Yes
Yes
Is there
an open Issue
about it?
Is there...
Comment:
"Duplicate of #ISSUE"
Comment:...
Labels:
- Bug Report
- Duplicate
Labels:...
Close Issue
Close Issue
Viewer does not support full SVG 1.1
+
Yes
Yes
No
No
Related to
an addon?
Related to...
No
No
Yes
Yes
Using RC-version?
Using RC-versio...
Comment and tell them to update their version and their post
Comment and tell the...
Labels:
- invalid
Labels:...
Comment and post a
link to the correct bug tracker
Comment and post a...
Close Issue
Close Issue
Close Issue
Close Issue
Yes
Yes
Did they
update and respond?
Did they...
New Issue
New Issue
Reopen Issue
Reopen Issue
Set up a local test server and see if
you can reproduce the issue
Set up a local test...
No
No
Yes
Yes
Template
missing or
incomplete?
Template...
Comment and tell them to fill out the template correctly.
Comment and tell the...
Labels:
- invalid
Labels:...
Close Issue
Close Issue
Yes
Yes
No
No
Issue was
reproduced?
Issue was...
Labels:
- Bug Report
- Confirmed Bug
Labels:...
Labels:
- Bug Report
- Cannot reproduce
Labels:...
Comment and tell them that it could
not be reproduced
Comment and tell the...
Close Issue
Close Issue
Comment and give further context on how to reproduce it.

Examples:
- Video footage
- Screenshots
- Plugins list
- /sf versions
- Server log
Comment and give fur...
No
No
Yes
Yes
Is there
an open Issue
about it?
Is there...
Comment:
"Duplicate of #ISSUE"
Comment:...
Labels:
- Bug Report
- Duplicate
Labels:...
Close Issue
Close Issue
Version 1.0.1
By: TheBusyBiscuit
13 Jan 2021
Version 1.0.1...
Viewer does not support full SVG 1.1
\ No newline at end of file From c53d87d0648f6a7dcb9136e28d1e1ebba4108044 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Wed, 13 Jan 2021 16:31:00 +0000 Subject: [PATCH 17/20] Update dependency com.github.LoneDev6:itemsadder-api to v2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 02a4dd503..c84ba0856 100644 --- a/pom.xml +++ b/pom.xml @@ -442,7 +442,7 @@ com.github.LoneDev6 itemsadder-api - 0.1.2 + 2.1.25 provided From d8004510e5a11e33ed90df804767ce69084fb70b Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Wed, 13 Jan 2021 19:48:30 +0100 Subject: [PATCH 18/20] Updated changelog (fixed two bugs) --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e694541bd..078db1883 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,8 @@ #### Fixes * Fixed elevator floor order +* Fixed #2449 +* Fixed #2511 ## Release Candidate 19 (11 Jan 2021) From 3fe60b91c7727619fd9bb5ced7bcbedc1e2705aa Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Wed, 13 Jan 2021 22:07:20 +0000 Subject: [PATCH 19/20] Update SuperKogito/URLs-checker action to v0.2.2 --- .github/workflows/url-checker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/url-checker.yml b/.github/workflows/url-checker.yml index 42483c750..39ec62fd4 100644 --- a/.github/workflows/url-checker.yml +++ b/.github/workflows/url-checker.yml @@ -13,7 +13,7 @@ jobs: steps: - name: URL-checker - uses: SuperKogito/URLs-checker@0.2.1 + uses: SuperKogito/URLs-checker@0.2.2 with: git_path: https://github.com/Slimefun/Slimefun4 file_types: .md,.java,.yml From 42631a116577c66367e807bdf8a0299370ba9739 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 14 Jan 2021 11:08:56 +0100 Subject: [PATCH 20/20] [CI skip] Removed URL checker --- .github/workflows/url-checker.yml | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 .github/workflows/url-checker.yml diff --git a/.github/workflows/url-checker.yml b/.github/workflows/url-checker.yml deleted file mode 100644 index 39ec62fd4..000000000 --- a/.github/workflows/url-checker.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: URL Validator - -on: - push: - branches: - - master - -jobs: - check: - - name: URL Checker - runs-on: ubuntu-latest - - steps: - - name: URL-checker - uses: SuperKogito/URLs-checker@0.2.2 - with: - git_path: https://github.com/Slimefun/Slimefun4 - file_types: .md,.java,.yml - print_all: false - retry_count: 2 - ## These URLs will always be correct, even if their services may be offline right now - white_listed_patterns: http://textures.minecraft.net/texture/,https://pastebin.com/,https://www.spigotmc.org/threads/spigot-bungeecord-1-16-1.447405/#post-3852349,https://gitlocalize.com/repo/3841