From 6f02caebdfa155573276650694414265f56de61d Mon Sep 17 00:00:00 2001 From: Andrew Wong <42793301+md5sha256@users.noreply.github.com> Date: Sun, 10 Nov 2024 06:24:23 +1100 Subject: [PATCH] Updates usages of CustomItemStack (#4253) Co-authored-by: Daniel Walsh --- pom.xml | 10 ++-- .../slimefun4/api/geo/ResourceManager.java | 26 ++++----- .../slimefun4/api/gps/GPSNetwork.java | 52 +++++++++--------- .../api/gps/TeleportationManager.java | 14 ++--- .../slimefun4/api/items/ItemGroup.java | 54 +++++++++---------- .../api/items/groups/NestedItemGroup.java | 6 +-- .../slimefun4/api/recipes/RecipeType.java | 12 ++--- .../commands/subcommands/GiveCommand.java | 2 +- .../core/guide/options/ContributorsMenu.java | 4 +- .../core/guide/options/FireworksOption.java | 2 +- .../options/LearningAnimationOption.java | 2 +- .../guide/options/PlayerLanguageOption.java | 8 +-- .../guide/options/SlimefunGuideSettings.java | 46 +++++++--------- .../localization/SlimefunLocalization.java | 4 +- .../implementation/SlimefunItems.java | 26 ++++----- .../guide/SurvivalSlimefunGuide.java | 24 ++++----- .../items/altar/AncientPedestal.java | 20 +++---- .../items/androids/AndroidFuelSource.java | 6 +-- .../items/androids/ProgrammableAndroid.java | 36 ++++++------- .../implementation/items/androids/Script.java | 28 +++++----- .../autocrafters/AbstractAutoCrafter.java | 50 ++++++++--------- .../autocrafters/SlimefunAutoCrafter.java | 6 +-- .../autocrafters/VanillaAutoCrafter.java | 6 +-- .../items/blocks/HologramProjector.java | 10 ++-- .../items/cargo/AbstractCargoNode.java | 10 ++-- .../items/cargo/AbstractFilterNode.java | 16 +++--- .../items/cargo/CargoInputNode.java | 8 +-- .../items/cargo/CargoOutputNode.java | 2 +- .../items/cargo/ReactorAccessPort.java | 18 +++---- .../implementation/items/cargo/TrashCan.java | 4 +- .../items/electric/machines/CarbonPress.java | 2 +- .../electric/machines/ElectricPress.java | 8 +-- .../electric/machines/ElectricSmeltery.java | 4 +- .../machines/HeatedPressureChamber.java | 6 +-- .../AbstractGrowthAccelerator.java | 2 +- .../AbstractEnchantmentMachine.java | 2 +- .../entities/AbstractEntityAssembler.java | 20 +++---- .../machines/entities/AutoBreeder.java | 2 +- .../machines/entities/ExpCollector.java | 4 +- .../machines/entities/IronGolemAssembler.java | 10 ++-- .../machines/entities/ProduceCollector.java | 10 ++-- .../machines/entities/WitherAssembler.java | 10 ++-- .../items/electric/reactors/Reactor.java | 42 +++++++-------- .../items/elevator/ElevatorPlate.java | 14 ++--- .../implementation/items/geo/GEOMiner.java | 26 ++++----- .../magical/talismans/EnderTalisman.java | 4 +- .../items/magical/talismans/Talisman.java | 12 ++--- .../items/multiblocks/ArmorForge.java | 2 +- .../items/multiblocks/Compressor.java | 2 +- .../items/multiblocks/GrindStone.java | 2 +- .../items/multiblocks/Juicer.java | 6 +-- .../items/multiblocks/MagicWorkbench.java | 2 +- .../items/multiblocks/MakeshiftSmeltery.java | 6 +-- .../items/multiblocks/OreCrusher.java | 4 +- .../items/multiblocks/PressureChamber.java | 2 +- .../items/multiblocks/Smeltery.java | 6 +-- .../multiblocks/miner/IndustrialMiner.java | 22 ++++---- .../items/tools/PickaxeOfVeinMining.java | 4 +- .../listeners/AncientAltarListener.java | 6 +-- .../listeners/TalismanListener.java | 14 ++--- .../setup/DefaultItemGroups.java | 50 ++++++++--------- .../implementation/setup/RickFlexGroup.java | 4 +- .../setup/SlimefunItemSetup.java | 4 +- .../slimefun4/utils/ChestMenuUtils.java | 14 ++--- .../utils/itemstack/ColoredFireworkStar.java | 43 +++++---------- .../abstractItems/AContainer.java | 36 ++++++------- .../abstractItems/AGenerator.java | 16 +++--- .../api/inventory/DirtyChestMenu.java | 4 +- .../settings/TestDoubleRangeSetting.java | 8 +-- .../api/items/settings/TestEnumSetting.java | 6 +-- .../items/settings/TestIntRangeSetting.java | 8 +-- .../api/items/settings/TestItemSettings.java | 8 +-- .../settings/TestMaterialTagSetting.java | 6 +-- .../api/profiles/TestGuideHistory.java | 4 +- .../core/guide/TestGuideOpening.java | 6 +-- .../core/multiblocks/TestMultiBlocks.java | 14 ++--- .../core/researching/TestResearches.java | 8 +-- .../core/services/TestPermissionsService.java | 12 ++--- .../items/TestSlimefunItem.java | 32 +++++------ .../autocrafters/TestAbstractRecipe.java | 6 +-- .../items/autocrafters/TestAutoCrafter.java | 12 ++--- .../listeners/TestAnvilListener.java | 2 +- .../listeners/TestBackpackListener.java | 8 +-- .../listeners/TestBrewingStandListener.java | 2 +- .../listeners/TestCargoNodeListener.java | 4 +- .../TestCartographyTableListener.java | 2 +- .../listeners/TestCauldronListener.java | 4 +- .../listeners/TestCoolerListener.java | 2 +- .../listeners/TestCraftingTableListener.java | 6 +-- .../listeners/TestGrindstoneListener.java | 2 +- .../listeners/TestIronGolemListener.java | 2 +- .../listeners/TestItemPickupListener.java | 8 +-- .../listeners/TestMultiblockListener.java | 2 +- .../listeners/TestPiglinListener.java | 4 +- .../listeners/TestSmithingTableListener.java | 6 +-- .../listeners/TestSoulboundListener.java | 4 +- .../TestVillagerTradingListener.java | 2 +- .../registration/TestItemGroups.java | 36 ++++++------- .../registration/TestItemHandlers.java | 8 +-- .../registration/TestRechargeableItems.java | 12 ++--- .../TestSlimefunItemRegistration.java | 14 ++--- .../slimefun4/test/TestUtilities.java | 8 +-- .../slimefun4/utils/TestItemStackWrapper.java | 10 ++-- .../slimefun4/utils/TestSoulboundItem.java | 6 +-- 104 files changed, 598 insertions(+), 625 deletions(-) diff --git a/pom.xml b/pom.xml index be95bc63b9..1836031548 100644 --- a/pom.xml +++ b/pom.xml @@ -355,9 +355,9 @@ - com.github.baked-libs.dough + com.github.Slimefun.dough dough-api - f8ff25187d + cb22e71335 compile @@ -395,9 +395,9 @@ - com.github.MockBukkit - MockBukkit - v3.130.2 + com.github.seeseemelk + MockBukkit-v1.21 + 3.133.2 test diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/ResourceManager.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/ResourceManager.java index ce4fea9b02..e88ec4e15e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/ResourceManager.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/ResourceManager.java @@ -38,9 +38,9 @@ /** * The {@link ResourceManager} is responsible for registering and managing a {@link GEOResource}. * You have to use the {@link ResourceManager} if you want to generate or consume a {@link GEOResource} too. - * + * * @author TheBusyBiscuit - * + * * @see GEOResource * @see GEOMiner * @see GEOScanner @@ -53,7 +53,7 @@ public class ResourceManager { /** * This will create a new {@link ResourceManager}. - * + * * @param plugin * Our {@link Slimefun} instance */ @@ -64,7 +64,7 @@ public ResourceManager(@Nonnull Slimefun plugin) { /** * This method registers the given {@link GEOResource}. * It may never be called directly, use {@link GEOResource#register()} instead. - * + * * @param resource * The {@link GEOResource} to register */ @@ -93,7 +93,7 @@ void register(@Nonnull GEOResource resource) { * This method returns the amount of a certain {@link GEOResource} found in a given {@link Chunk}. * The result is an {@link OptionalInt} which will be empty if this {@link GEOResource} * has not been generated at that {@link Location} yet. - * + * * @param resource * The {@link GEOResource} to query * @param world @@ -102,7 +102,7 @@ void register(@Nonnull GEOResource resource) { * The {@link Chunk} x coordinate * @param z * The {@link Chunk} z coordinate - * + * * @return An {@link OptionalInt}, either empty or containing the amount of the given {@link GEOResource} */ public @Nonnull OptionalInt getSupplies(@Nonnull GEOResource resource, @Nonnull World world, int x, int z) { @@ -121,7 +121,7 @@ void register(@Nonnull GEOResource resource) { /** * This method will set the supplies in a given {@link Chunk} to the specified value. - * + * * @param resource * The {@link GEOResource} * @param world @@ -147,7 +147,7 @@ public void setSupplies(@Nonnull GEOResource resource, @Nonnull World world, int *

* This method will invoke {@link #setSupplies(GEOResource, World, int, int, int)} and also calls a * {@link GEOResourceGenerationEvent}. - * + * * @param resource * The {@link GEOResource} to generate * @param world @@ -156,7 +156,7 @@ public void setSupplies(@Nonnull GEOResource resource, @Nonnull World world, int * The x coordinate of that {@link Chunk} * @param z * The z coordinate of that {@link Chunk} - * + * * @return The new supply value */ private int generate(@Nonnull GEOResource resource, @Nonnull World world, int x, int y, int z) { @@ -199,11 +199,11 @@ private int generate(@Nonnull GEOResource resource, @Nonnull World world, int x, /** * This method will start a geo-scan at the given {@link Block} and display the result * of that scan to the given {@link Player}. - * + * * Note that scans are always per {@link Chunk}, not per {@link Block}, the {@link Block} * parameter only determines the {@link Location} that was clicked but it will still scan * the entire {@link Chunk}. - * + * * @param p * The {@link Player} who requested these results * @param block @@ -227,7 +227,7 @@ public void scan(@Nonnull Player p, @Nonnull Block block, int page) { menu.addItem(slot, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler()); } - menu.addItem(4, new CustomItemStack(HeadTexture.MINECRAFT_CHUNK.getAsItemStack(), ChatColor.YELLOW + Slimefun.getLocalization().getResourceString(p, "tooltips.chunk"), "", "&8\u21E8 &7" + Slimefun.getLocalization().getResourceString(p, "tooltips.world") + ": " + block.getWorld().getName(), "&8\u21E8 &7X: " + x + " Z: " + z), ChestMenuUtils.getEmptyClickHandler()); + menu.addItem(4, CustomItemStack.create(HeadTexture.MINECRAFT_CHUNK.getAsItemStack(), ChatColor.YELLOW + Slimefun.getLocalization().getResourceString(p, "tooltips.chunk"), "", "&8\u21E8 &7" + Slimefun.getLocalization().getResourceString(p, "tooltips.world") + ": " + block.getWorld().getName(), "&8\u21E8 &7X: " + x + " Z: " + z), ChestMenuUtils.getEmptyClickHandler()); List resources = new ArrayList<>(Slimefun.getRegistry().getGEOResources().values()); resources.sort(Comparator.comparing(a -> a.getName(p).toLowerCase(Locale.ROOT))); @@ -240,7 +240,7 @@ public void scan(@Nonnull Player p, @Nonnull Block block, int page) { int supplies = optional.orElseGet(() -> generate(resource, block.getWorld(), x, block.getY(), z)); String suffix = Slimefun.getLocalization().getResourceString(p, ChatUtils.checkPlurality("tooltips.unit", supplies)); - ItemStack item = new CustomItemStack(resource.getItem(), "&f" + resource.getName(p), "&8\u21E8 &e" + supplies + ' ' + suffix); + ItemStack item = CustomItemStack.create(resource.getItem(), "&f" + resource.getName(p), "&8\u21E8 &e" + supplies + ' ' + suffix); if (supplies > 1) { item.setAmount(Math.min(supplies, item.getMaxStackSize())); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/GPSNetwork.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/GPSNetwork.java index 47574fb2ca..8acc16b8e4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/GPSNetwork.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/GPSNetwork.java @@ -44,9 +44,9 @@ * The {@link GPSNetwork} is a manager class for all {@link GPSTransmitter Transmitters} and waypoints. * There can only be one instance of this class per {@link Server}. * It is also responsible for teleportation and resource management. - * + * * @author TheBusyBiscuit - * + * * @see TeleportationManager * @see ResourceManager * @@ -64,7 +64,7 @@ public class GPSNetwork { /** * This constructs a new {@link GPSNetwork}. * Note that this network is per {@link Server} and not per {@link Player}. - * + * * @param plugin * Our {@link Slimefun} instance */ @@ -74,7 +74,7 @@ public GPSNetwork(@Nonnull Slimefun plugin) { /** * This method updates the status of a {@link GPSTransmitter}. - * + * * @param l * The {@link Location} of the {@link GPSTransmitter} * @param uuid @@ -96,10 +96,10 @@ public void updateTransmitter(@Nonnull Location l, @Nonnull UUID uuid, boolean o * This method calculates the GPS complexity for the given {@link UUID}. * The complexity is determined by the Y level of each {@link GPSTransmitter} * multiplied by the multiplier of that transmitter. - * + * * @param uuid * The {@link UUID} who to calculate it for - * + * * @return The network complexity for that {@link UUID} */ public int getNetworkComplexity(@Nonnull UUID uuid) { @@ -124,10 +124,10 @@ public int getNetworkComplexity(@Nonnull UUID uuid) { /** * This method returns the amount of {@link GPSTransmitter Transmitters} for the * given {@link UUID}. - * + * * @param uuid * The {@link UUID} who these transmitters belong to - * + * * @return The amount of transmitters */ public int countTransmitters(@Nonnull UUID uuid) { @@ -138,7 +138,7 @@ public int countTransmitters(@Nonnull UUID uuid) { /** * This method opens the {@link GPSTransmitter} control panel to the given * {@link Player}. - * + * * @param p * The {@link Player} */ @@ -149,7 +149,7 @@ public void openTransmitterControlPanel(@Nonnull Player p) { menu.addItem(slot, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler()); } - menu.addItem(2, new CustomItemStack(SlimefunItems.GPS_TRANSMITTER, im -> { + menu.addItem(2, CustomItemStack.create(SlimefunItems.GPS_TRANSMITTER, im -> { im.setDisplayName(ChatColor.GRAY + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.transmitters")); im.setLore(null); })); @@ -157,10 +157,10 @@ public void openTransmitterControlPanel(@Nonnull Player p) { menu.addMenuClickHandler(2, ChestMenuUtils.getEmptyClickHandler()); int complexity = getNetworkComplexity(p.getUniqueId()); - menu.addItem(4, new CustomItemStack(SlimefunItems.GPS_CONTROL_PANEL, "&7Network Info", "", "&8\u21E8 &7Status: " + getStatusText(p, complexity), "&8\u21E8 &7Complexity: &f" + complexity)); + menu.addItem(4, CustomItemStack.create(SlimefunItems.GPS_CONTROL_PANEL, "&7Network Info", "", "&8\u21E8 &7Status: " + getStatusText(p, complexity), "&8\u21E8 &7Complexity: &f" + complexity)); menu.addMenuClickHandler(4, ChestMenuUtils.getEmptyClickHandler()); - menu.addItem(6, new CustomItemStack(HeadTexture.GLOBE_OVERWORLD.getAsItemStack(), "&7" + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.waypoints"), "", ChatColor.GRAY + "\u21E8 " + Slimefun.getLocalization().getMessage(p, "guide.tooltips.open-itemgroup"))); + menu.addItem(6, CustomItemStack.create(HeadTexture.GLOBE_OVERWORLD.getAsItemStack(), "&7" + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.waypoints"), "", ChatColor.GRAY + "\u21E8 " + Slimefun.getLocalization().getMessage(p, "guide.tooltips.open-itemgroup"))); menu.addMenuClickHandler(6, (pl, slot, item, action) -> { openWaypointControlPanel(pl); return false; @@ -177,7 +177,7 @@ public void openTransmitterControlPanel(@Nonnull Player p) { if (sfi instanceof GPSTransmitter transmitter) { int slot = inventory[index]; - menu.addItem(slot, new CustomItemStack(SlimefunItems.GPS_TRANSMITTER, "&bGPS Transmitter", "&8\u21E8 &7World: &f" + l.getWorld().getName(), "&8\u21E8 &7X: &f" + l.getX(), "&8\u21E8 &7Y: &f" + l.getY(), "&8\u21E8 &7Z: &f" + l.getZ(), "", "&8\u21E8 &7Signal Strength: &f" + transmitter.getMultiplier(l.getBlockY()), "&8\u21E8 &7Ping: &f" + NumberUtils.roundDecimalNumber(1000D / l.getY()) + "ms")); + menu.addItem(slot, CustomItemStack.create(SlimefunItems.GPS_TRANSMITTER, "&bGPS Transmitter", "&8\u21E8 &7World: &f" + l.getWorld().getName(), "&8\u21E8 &7X: &f" + l.getX(), "&8\u21E8 &7Y: &f" + l.getY(), "&8\u21E8 &7Z: &f" + l.getZ(), "", "&8\u21E8 &7Signal Strength: &f" + transmitter.getMultiplier(l.getBlockY()), "&8\u21E8 &7Ping: &f" + NumberUtils.roundDecimalNumber(1000D / l.getY()) + "ms")); menu.addMenuClickHandler(slot, ChestMenuUtils.getEmptyClickHandler()); index++; @@ -192,14 +192,14 @@ public void openTransmitterControlPanel(@Nonnull Player p) { * The icon is dependent on the {@link Environment} of the waypoint's {@link World}. * However if the name of this waypoint indicates that this is actually a deathmarker * then a different texture will be used. - * + * * Otherwise it will return a globe, a nether or end sphere according to the {@link Environment}. - * + * * @param name * The name of a waypoint * @param environment * The {@link Environment} of the waypoint's {@link World} - * + * * @return An icon for this waypoint */ @ParametersAreNonnullByDefault @@ -232,17 +232,17 @@ public void openWaypointControlPanel(@Nonnull Player p) { menu.addItem(slot, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler()); } - menu.addItem(2, new CustomItemStack(SlimefunItems.GPS_TRANSMITTER, "&7" + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.transmitters"), "", ChatColor.GRAY + "\u21E8 " + Slimefun.getLocalization().getMessage(p, "guide.tooltips.open-itemgroup"))); + menu.addItem(2, CustomItemStack.create(SlimefunItems.GPS_TRANSMITTER, "&7" + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.transmitters"), "", ChatColor.GRAY + "\u21E8 " + Slimefun.getLocalization().getMessage(p, "guide.tooltips.open-itemgroup"))); menu.addMenuClickHandler(2, (pl, slot, item, action) -> { openTransmitterControlPanel(pl); return false; }); int complexity = getNetworkComplexity(p.getUniqueId()); - menu.addItem(4, new CustomItemStack(SlimefunItems.GPS_CONTROL_PANEL, "&7Network Info", "", "&8\u21E8 &7Status: " + (complexity > 0 ? "&2&lONLINE" : "&4&lOFFLINE"), "&8\u21E8 &7Complexity: &f" + complexity)); + menu.addItem(4, CustomItemStack.create(SlimefunItems.GPS_CONTROL_PANEL, "&7Network Info", "", "&8\u21E8 &7Status: " + (complexity > 0 ? "&2&lONLINE" : "&4&lOFFLINE"), "&8\u21E8 &7Complexity: &f" + complexity)); menu.addMenuClickHandler(4, ChestMenuUtils.getEmptyClickHandler()); - menu.addItem(6, new CustomItemStack(HeadTexture.GLOBE_OVERWORLD.getAsItemStack(), "&7" + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.waypoints"))); + menu.addItem(6, CustomItemStack.create(HeadTexture.GLOBE_OVERWORLD.getAsItemStack(), "&7" + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.waypoints"))); menu.addMenuClickHandler(6, ChestMenuUtils.getEmptyClickHandler()); int index = 0; @@ -254,7 +254,7 @@ public void openWaypointControlPanel(@Nonnull Player p) { int slot = inventory[index]; Location l = waypoint.getLocation(); - menu.addItem(slot, new CustomItemStack(waypoint.getIcon(), waypoint.getName().replace("player:death ", ""), "&8\u21E8 &7World: &f" + l.getWorld().getName(), "&8\u21E8 &7X: &f" + l.getX(), "&8\u21E8 &7Y: &f" + l.getY(), "&8\u21E8 &7Z: &f" + l.getZ(), "", "&8\u21E8 &cClick to delete")); + menu.addItem(slot, CustomItemStack.create(waypoint.getIcon(), waypoint.getName().replace("player:death ", ""), "&8\u21E8 &7World: &f" + l.getWorld().getName(), "&8\u21E8 &7X: &f" + l.getX(), "&8\u21E8 &7Y: &f" + l.getY(), "&8\u21E8 &7Z: &f" + l.getZ(), "", "&8\u21E8 &cClick to delete")); menu.addMenuClickHandler(slot, (pl, s, item, action) -> { profile.removeWaypoint(waypoint); SoundEffect.GPS_NETWORK_OPEN_PANEL_SOUND.playFor(p); @@ -273,7 +273,7 @@ public void openWaypointControlPanel(@Nonnull Player p) { /** * This method will prompt the given {@link Player} to enter a name for a waypoint. * After entering the name, it will be added to his waypoint list. - * + * * @param p * The {@link Player} who should get a new waypoint * @param l @@ -298,7 +298,7 @@ public void createWaypoint(@Nonnull Player p, @Nonnull Location l) { /** * This method adds a new waypoint with the given name and {@link Location} for that {@link Player}. - * + * * @param p * The {@link Player} to get the new waypoint * @param name @@ -343,10 +343,10 @@ public void addWaypoint(@Nonnull Player p, @Nonnull String name, @Nonnull Locati /** * This method returns a {@link Set} of {@link Location Locations} for all {@link GPSTransmitter Transmitters} * owned by the given {@link UUID}. - * + * * @param uuid * The {@link UUID} owning those transmitters - * + * * @return A {@link Set} with all {@link Location Locations} of transmitters for this {@link UUID} */ @Nonnull @@ -357,7 +357,7 @@ public Set getTransmitters(@Nonnull UUID uuid) { /** * This returns the {@link TeleportationManager} for this {@link GPSNetwork}. * It is responsible for all actions that relate to the {@link Teleporter}. - * + * * @return The {@link TeleportationManager} for this {@link GPSNetwork} */ @Nonnull @@ -368,7 +368,7 @@ public TeleportationManager getTeleportationManager() { /** * This returns the {@link ResourceManager} for this {@link GPSNetwork}. * Use this to access {@link GEOResource GEOResources}. - * + * * @return The {@link ResourceManager} for this {@link GPSNetwork} */ @Nonnull diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/TeleportationManager.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/TeleportationManager.java index 6f65962024..40035920ba 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/TeleportationManager.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/TeleportationManager.java @@ -34,9 +34,9 @@ /** * The {@link TeleportationManager} handles the process of teleportation for a {@link Player} * who is using a {@link Teleporter}. - * + * * @author TheBusyBiscuit - * + * * @see GPSNetwork * @see Teleporter * @@ -79,7 +79,7 @@ public void openTeleporterGUI(Player p, UUID ownerUUID, Block b, int complexity) menu.addItem(slot, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler()); } - menu.addItem(4, new CustomItemStack(HeadTexture.GLOBE_OVERWORLD.getAsItemStack(), ChatColor.YELLOW + Slimefun.getLocalization().getMessage(p, "machines.TELEPORTER.gui.title"))); + menu.addItem(4, CustomItemStack.create(HeadTexture.GLOBE_OVERWORLD.getAsItemStack(), ChatColor.YELLOW + Slimefun.getLocalization().getMessage(p, "machines.TELEPORTER.gui.title"))); menu.addMenuClickHandler(4, ChestMenuUtils.getEmptyClickHandler()); Location source = new Location(b.getWorld(), b.getX() + 0.5D, b.getY() + 2D, b.getZ() + 0.5D); @@ -107,7 +107,7 @@ public void openTeleporterGUI(Player p, UUID ownerUUID, Block b, int complexity) }; // @formatter:on - menu.addItem(slot, new CustomItemStack(waypoint.getIcon(), waypoint.getName().replace("player:death ", ""), lore)); + menu.addItem(slot, CustomItemStack.create(waypoint.getIcon(), waypoint.getName().replace("player:death ", ""), lore)); menu.addMenuClickHandler(slot, (pl, s, item, action) -> { pl.closeInventory(); teleport(pl.getUniqueId(), complexity, source, l, false); @@ -136,21 +136,21 @@ public void teleport(UUID uuid, int complexity, Location source, Location destin * to the destination {@link Location}, given the specified complexity. *

* The returned time will be measured in 500ms intervals. - * + * *

    *
  • A returned time of {@literal 100} will mean 50,000ms (50s) of real-life time.
  • *
  • A returned time of {@literal 10} will mean 5,000ms (5s) of real-life time.
  • *
  • A returned time of {@literal 2} will mean 1,000ms (1s) of real-life time.
  • *
  • and so on...
  • *
- * + * * @param complexity * The complexity of the {@link GPSNetwork} * @param source * The source {@link Location} * @param destination * The destination {@link Location} - * + * * @return The amount of time the teleportation will take */ public int getTeleportationTime(int complexity, @Nonnull Location source, @Nonnull Location destination) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemGroup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemGroup.java index 81b8f331f6..8524c6a7e7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemGroup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemGroup.java @@ -30,12 +30,12 @@ /** * Represents an item group, which structure * multiple {@link SlimefunItem} in the {@link SlimefunGuide}. - * + * * @author TheBusyBiscuit * * @see LockedItemGroup * @see SeasonalItemGroup - * + * */ public class ItemGroup implements Keyed { @@ -51,7 +51,7 @@ public class ItemGroup implements Keyed { * Constructs a new {@link ItemGroup} with the given {@link NamespacedKey} as an identifier * and the given {@link ItemStack} as its display item. * The tier is set to a default value of {@code 3}. - * + * * @param key * The {@link NamespacedKey} that is used to identify this {@link ItemGroup} * @param item @@ -65,7 +65,7 @@ public ItemGroup(NamespacedKey key, ItemStack item) { /** * Constructs a new {@link ItemGroup} with the given {@link NamespacedKey} as an identifier * and the given {@link ItemStack} as its display item. - * + * * @param key * The {@link NamespacedKey} that is used to identify this {@link ItemGroup} * @param item @@ -101,7 +101,7 @@ public ItemGroup(NamespacedKey key, ItemStack item, int tier) { *

* By default, an {@link ItemGroup} is automatically registered when * a {@link SlimefunItem} was added to it. - * + * * @param addon * The {@link SlimefunAddon} that wants to register this {@link ItemGroup} */ @@ -121,7 +121,7 @@ public void register(@Nonnull SlimefunAddon addon) { /** * This method returns whether this {@link ItemGroup} has been registered yet. * More specifically: Whether {@link #register(SlimefunAddon)} was called or not. - * + * * @return Whether this {@link ItemGroup} has been registered */ public boolean isRegistered() { @@ -131,7 +131,7 @@ public boolean isRegistered() { /** * Returns the tier of this {@link ItemGroup}. * The tier determines the position of this {@link ItemGroup} in the {@link SlimefunGuide}. - * + * * @return the tier of this {@link ItemGroup} */ public int getTier() { @@ -141,7 +141,7 @@ public int getTier() { /** * This sets the tier of this {@link ItemGroup}. * The tier determines the position of this {@link ItemGroup} in the {@link SlimefunGuide}. - * + * * @param tier * The tier for this {@link ItemGroup} */ @@ -165,7 +165,7 @@ private void sortCategoriesByTier() { /** * This returns the {@link SlimefunAddon} which has registered this {@link ItemGroup}. * Or null if it has not been registered yet. - * + * * @return The {@link SlimefunAddon} or null if unregistered */ public final @Nullable SlimefunAddon getAddon() { @@ -174,7 +174,7 @@ private void sortCategoriesByTier() { /** * Adds the given {@link SlimefunItem} to this {@link ItemGroup}. - * + * * @param item * the {@link SlimefunItem} that should be added to this {@link ItemGroup} */ @@ -195,7 +195,7 @@ public void add(@Nonnull SlimefunItem item) { /** * Removes the given {@link SlimefunItem} from this {@link ItemGroup}. - * + * * @param item * the {@link SlimefunItem} that should be removed from this {@link ItemGroup} */ @@ -207,14 +207,14 @@ public void remove(@Nonnull SlimefunItem item) { /** * This method returns a localized display item of this {@link ItemGroup} * for the specified {@link Player}. - * + * * @param p * The Player to create this {@link ItemStack} for - * + * * @return A localized display item for this {@link ItemGroup} */ public @Nonnull ItemStack getItem(@Nonnull Player p) { - return new CustomItemStack(item, meta -> { + return CustomItemStack.create(item, meta -> { String name = Slimefun.getLocalization().getItemGroupName(p, getKey()); if (name == null) { @@ -234,7 +234,7 @@ public void remove(@Nonnull SlimefunItem item) { /** * This method makes Walshy happy. * It adds a way to get the name of a {@link ItemGroup} without localization nor coloring. - * + * * @return The unlocalized name of this {@link ItemGroup} */ public @Nonnull String getUnlocalizedName() { @@ -244,10 +244,10 @@ public void remove(@Nonnull SlimefunItem item) { /** * This returns the localized display name of this {@link ItemGroup} for the given {@link Player}. * The method will fall back to {@link #getUnlocalizedName()} if no translation was found. - * + * * @param p * The {@link Player} who to translate the name for - * + * * @return The localized name of this {@link ItemGroup} */ public @Nonnull String getDisplayName(@Nonnull Player p) { @@ -262,7 +262,7 @@ public void remove(@Nonnull SlimefunItem item) { /** * Returns all instances of {@link SlimefunItem} bound to this {@link ItemGroup}. - * + * * @return the list of SlimefunItems bound to this {@link ItemGroup} */ public @Nonnull List getItems() { @@ -271,10 +271,10 @@ public void remove(@Nonnull SlimefunItem item) { /** * This method returns whether a given {@link SlimefunItem} exists in this {@link ItemGroup}. - * + * * @param item * The {@link SlimefunItem} to find - * + * * @return Whether the given {@link SlimefunItem} was found in this {@link ItemGroup} */ public boolean contains(@Nullable SlimefunItem item) { @@ -286,10 +286,10 @@ public boolean contains(@Nullable SlimefunItem item) { * by the given {@link Player}. If an {@link ItemGroup} is not accessible, * it will not show up in the {@link SlimefunGuide} nor will items from this * {@link ItemGroup} show up in the guide search. - * + * * @param p * The {@link Player} to check for - * + * * @return Whether this {@link ItemGroup} is accessible by the given {@link Player} */ public boolean isAccessible(@Nonnull Player p) { @@ -302,10 +302,10 @@ public boolean isAccessible(@Nonnull Player p) { * be visible. This includes {@link ItemGroup ItemGroups} where every {@link SlimefunItem} * is disabled. If an {@link ItemGroup} is not accessible by the {@link Player}, * see {@link #isAccessible(Player)}, this method will also return false. - * + * * @param p * The {@link Player} to check for - * + * * @return Whether this {@link ItemGroup} is visible to the given {@link Player} */ public boolean isVisible(@Nonnull Player p) { @@ -372,12 +372,12 @@ public String toString() { /** * This method checks whether this {@link ItemGroup} will be hidden for the specified * {@link Player}. - * + * * Categories are hidden if all of their items have been disabled. - * + * * @param p * The {@link Player} to check for - * + * * @return Whether this {@link ItemGroup} will be hidden to the given {@link Player} */ @Deprecated diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/NestedItemGroup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/NestedItemGroup.java index 9a928c8be1..0d99f7347e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/NestedItemGroup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/NestedItemGroup.java @@ -41,7 +41,7 @@ public NestedItemGroup(NamespacedKey key, ItemStack item, int tier) { /** * This will add the given {@link SubItemGroup} to this {@link NestedItemGroup}. - * + * * @param group * The {@link SubItemGroup} to add. */ @@ -53,7 +53,7 @@ public void addSubGroup(@Nonnull SubItemGroup group) { /** * This will remove the given {@link SubItemGroup} from this {@link NestedItemGroup} (if present). - * + * * @param group * The {@link SubItemGroup} to remove. */ @@ -90,7 +90,7 @@ private void openGuide(Player p, PlayerProfile profile, SlimefunGuideMode mode, menu.addMenuOpeningHandler(SoundEffect.GUIDE_BUTTON_CLICK_SOUND::playFor); guide.createHeader(p, profile, menu); - menu.addItem(1, new CustomItemStack(ChestMenuUtils.getBackButton(p, "", ChatColor.GRAY + Slimefun.getLocalization().getMessage(p, "guide.back.guide")))); + menu.addItem(1, ChestMenuUtils.getBackButton(p, "", ChatColor.GRAY + Slimefun.getLocalization().getMessage(p, "guide.back.guide"))); menu.addMenuClickHandler(1, (pl, s, is, action) -> { SlimefunGuide.openMainMenu(profile, mode, history.getMainMenuPage()); return false; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/recipes/RecipeType.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/recipes/RecipeType.java index e22c947b67..9b02cc0fde 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/recipes/RecipeType.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/recipes/RecipeType.java @@ -34,7 +34,7 @@ // TODO: Remove this class and rewrite the recipe system public class RecipeType implements Keyed { - public static final RecipeType MULTIBLOCK = new RecipeType(new NamespacedKey(Slimefun.instance(), "multiblock"), new CustomItemStack(Material.BRICKS, "&bMultiBlock", "", "&a&oBuild it in the World")); + public static final RecipeType MULTIBLOCK = new RecipeType(new NamespacedKey(Slimefun.instance(), "multiblock"), CustomItemStack.create(Material.BRICKS, "&bMultiBlock", "", "&a&oBuild it in the World")); public static final RecipeType ARMOR_FORGE = new RecipeType(new NamespacedKey(Slimefun.instance(), "armor_forge"), SlimefunItems.ARMOR_FORGE, "", "&a&oCraft it in an Armor Forge"); public static final RecipeType GRIND_STONE = new RecipeType(new NamespacedKey(Slimefun.instance(), "grind_stone"), SlimefunItems.GRIND_STONE, "", "&a&oGrind it using the Grind Stone"); public static final RecipeType SMELTERY = new RecipeType(new NamespacedKey(Slimefun.instance(), "smeltery"), SlimefunItems.SMELTERY, "", "&a&oSmelt it using a Smeltery"); @@ -53,9 +53,9 @@ public class RecipeType implements Keyed { altar.getRecipes().add(altarRecipe); }); - public static final RecipeType MOB_DROP = new RecipeType(new NamespacedKey(Slimefun.instance(), "mob_drop"), new CustomItemStack(Material.IRON_SWORD, "&bMob Drop"), RecipeType::registerMobDrop, "", "&rKill the specified Mob to obtain this Item"); - public static final RecipeType BARTER_DROP = new RecipeType(new NamespacedKey(Slimefun.instance(), "barter_drop"), new CustomItemStack(Material.GOLD_INGOT, "&bBarter Drop"), RecipeType::registerBarterDrop, "&aBarter with piglins for a chance", "&ato obtain this item"); - public static final RecipeType INTERACT = new RecipeType(new NamespacedKey(Slimefun.instance(), "interact"), new CustomItemStack(Material.PLAYER_HEAD, "&bInteract", "", "&a&oRight click with this item")); + public static final RecipeType MOB_DROP = new RecipeType(new NamespacedKey(Slimefun.instance(), "mob_drop"), CustomItemStack.create(Material.IRON_SWORD, "&bMob Drop"), RecipeType::registerMobDrop, "", "&rKill the specified Mob to obtain this Item"); + public static final RecipeType BARTER_DROP = new RecipeType(new NamespacedKey(Slimefun.instance(), "barter_drop"), CustomItemStack.create(Material.GOLD_INGOT, "&bBarter Drop"), RecipeType::registerBarterDrop, "&aBarter with piglins for a chance", "&ato obtain this item"); + public static final RecipeType INTERACT = new RecipeType(new NamespacedKey(Slimefun.instance(), "interact"), CustomItemStack.create(Material.PLAYER_HEAD, "&bInteract", "", "&a&oRight click with this item")); public static final RecipeType HEATED_PRESSURE_CHAMBER = new RecipeType(new NamespacedKey(Slimefun.instance(), "heated_pressure_chamber"), SlimefunItems.HEATED_PRESSURE_CHAMBER); public static final RecipeType FOOD_FABRICATOR = new RecipeType(new NamespacedKey(Slimefun.instance(), "food_fabricator"), SlimefunItems.FOOD_FABRICATOR); @@ -95,7 +95,7 @@ public RecipeType(NamespacedKey key, SlimefunItemStack slimefunItem, String... l } public RecipeType(NamespacedKey key, ItemStack item, BiConsumer callback, String... lore) { - this.item = new CustomItemStack(item, null, lore); + this.item = CustomItemStack.create(item, null, lore); this.key = key; this.consumer = callback; @@ -230,4 +230,4 @@ public static ItemStack getRecipeOutputList(MultiBlockMachine machine, ItemStack List recipes = machine.getRecipes(); return recipes.get((recipes.indexOf(input) + 1))[0]; } -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GiveCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GiveCommand.java index 5d56959e84..cdf67f5bab 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GiveCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GiveCommand.java @@ -65,7 +65,7 @@ private void giveItem(CommandSender sender, Player p, SlimefunItem sfItem, Strin if (amount > 0) { Slimefun.getLocalization().sendMessage(p, "messages.given-item", true, msg -> msg.replace(PLACEHOLDER_ITEM, sfItem.getItemName()).replace(PLACEHOLDER_AMOUNT, String.valueOf(amount))); - Map excess = p.getInventory().addItem(new CustomItemStack(sfItem.getItem(), amount)); + Map excess = p.getInventory().addItem(CustomItemStack.create(sfItem.getItem(), amount)); if (Slimefun.getCfg().getBoolean("options.drop-excess-sf-give-items") && !excess.isEmpty()) { for (ItemStack is : excess.values()) { p.getWorld().dropItem(p.getLocation(), is); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/ContributorsMenu.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/ContributorsMenu.java index 93e8d89a35..06d06c3379 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/ContributorsMenu.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/ContributorsMenu.java @@ -24,7 +24,7 @@ /** * This menu shows a list of every {@link Contributor} to this project. - * + * * @author TheBusyBiscuit * */ @@ -40,7 +40,7 @@ public static void open(Player p, int page) { ChestMenuUtils.drawBackground(menu, 0, 2, 3, 4, 5, 6, 7, 8, 45, 47, 48, 49, 50, 51, 53); - menu.addItem(1, new CustomItemStack(ChestMenuUtils.getBackButton(p, "", "&7" + Slimefun.getLocalization().getMessage(p, "guide.back.settings")))); + menu.addItem(1, ChestMenuUtils.getBackButton(p, "", "&7" + Slimefun.getLocalization().getMessage(p, "guide.back.settings"))); menu.addMenuClickHandler(1, (pl, slot, item, action) -> { SlimefunGuideSettings.openSettings(pl, p.getInventory().getItemInMainHand()); return false; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/FireworksOption.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/FireworksOption.java index 64f48a0656..d16b85a170 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/FireworksOption.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/FireworksOption.java @@ -38,7 +38,7 @@ public Optional getDisplayItem(Player p, ItemStack guide) { lore.add(""); lore.add("&7\u21E8 " + Slimefun.getLocalization().getMessage(p, "guide.options.fireworks." + optionState + ".click")); - ItemStack item = new CustomItemStack(Material.FIREWORK_ROCKET, lore); + ItemStack item = CustomItemStack.create(Material.FIREWORK_ROCKET, lore); return Optional.of(item); } else { return Optional.empty(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/LearningAnimationOption.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/LearningAnimationOption.java index 5d694c896c..ee62bbbf07 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/LearningAnimationOption.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/LearningAnimationOption.java @@ -51,7 +51,7 @@ public Optional getDisplayItem(@Nonnull Player p, @Nonnull ItemStack lore.add(""); lore.add("&7\u21E8 " + Slimefun.getLocalization().getMessage(p, "guide.options.learning-animation." + optionState + ".click")); - ItemStack item = new CustomItemStack(enabled ? Material.MAP : Material.PAPER, lore); + ItemStack item = CustomItemStack.create(enabled ? Material.MAP : Material.PAPER, lore); return Optional.of(item); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/PlayerLanguageOption.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/PlayerLanguageOption.java index 7a4779ff59..8633f17a54 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/PlayerLanguageOption.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/PlayerLanguageOption.java @@ -49,7 +49,7 @@ public Optional getDisplayItem(Player p, ItemStack guide) { lore.add(""); lore.add("&7\u21E8 &e" + Slimefun.getLocalization().getMessage(p, "guide.languages.change")); - ItemStack item = new CustomItemStack(language.getItem(), "&7" + Slimefun.getLocalization().getMessage(p, "guide.languages.selected-language") + " &a" + languageName, lore.toArray(new String[0])); + ItemStack item = CustomItemStack.create(language.getItem(), "&7" + Slimefun.getLocalization().getMessage(p, "guide.languages.selected-language") + " &a" + languageName, lore.toArray(new String[0])); return Optional.of(item); } else { return Optional.empty(); @@ -88,7 +88,7 @@ private void openLanguageSelection(Player p, ItemStack guide) { return false; }); } else if (i == 7) { - menu.addItem(7, new CustomItemStack(SlimefunUtils.getCustomHead(HeadTexture.ADD_NEW_LANGUAGE.getTexture()), Slimefun.getLocalization().getMessage(p, "guide.languages.translations.name"), "", "&7\u21E8 &e" + Slimefun.getLocalization().getMessage(p, "guide.languages.translations.lore")), (pl, slot, item, action) -> { + menu.addItem(7, CustomItemStack.create(SlimefunUtils.getCustomHead(HeadTexture.ADD_NEW_LANGUAGE.getTexture()), Slimefun.getLocalization().getMessage(p, "guide.languages.translations.name"), "", "&7\u21E8 &e" + Slimefun.getLocalization().getMessage(p, "guide.languages.translations.lore")), (pl, slot, item, action) -> { ChatUtils.sendURL(pl, "https://github.com/Slimefun/Slimefun4/wiki/Translating-Slimefun"); pl.closeInventory(); return false; @@ -101,7 +101,7 @@ private void openLanguageSelection(Player p, ItemStack guide) { Language defaultLanguage = Slimefun.getLocalization().getDefaultLanguage(); String defaultLanguageString = Slimefun.getLocalization().getMessage(p, "languages.default"); - menu.addItem(9, new CustomItemStack(defaultLanguage.getItem(), ChatColor.GRAY + defaultLanguageString + ChatColor.DARK_GRAY + " (" + defaultLanguage.getName(p) + ")", "", "&7\u21E8 &e" + Slimefun.getLocalization().getMessage(p, "guide.languages.select-default")), (pl, i, item, action) -> { + menu.addItem(9, CustomItemStack.create(defaultLanguage.getItem(), ChatColor.GRAY + defaultLanguageString + ChatColor.DARK_GRAY + " (" + defaultLanguage.getName(p) + ")", "", "&7\u21E8 &e" + Slimefun.getLocalization().getMessage(p, "guide.languages.select-default")), (pl, i, item, action) -> { Slimefun.instance().getServer().getPluginManager().callEvent(new PlayerLanguageChangeEvent(pl, Slimefun.getLocalization().getLanguage(pl), defaultLanguage)); setSelectedOption(pl, guide, null); @@ -114,7 +114,7 @@ private void openLanguageSelection(Player p, ItemStack guide) { int slot = 10; for (Language language : Slimefun.getLocalization().getLanguages()) { - menu.addItem(slot, new CustomItemStack(language.getItem(), ChatColor.GREEN + language.getName(p), "&b" + language.getTranslationProgress() + '%', "", "&7\u21E8 &e" + Slimefun.getLocalization().getMessage(p, "guide.languages.select")), (pl, i, item, action) -> { + menu.addItem(slot, CustomItemStack.create(language.getItem(), ChatColor.GREEN + language.getName(p), "&b" + language.getTranslationProgress() + '%', "", "&7\u21E8 &e" + Slimefun.getLocalization().getMessage(p, "guide.languages.select")), (pl, i, item, action) -> { Slimefun.instance().getServer().getPluginManager().callEvent(new PlayerLanguageChangeEvent(pl, Slimefun.getLocalization().getLanguage(pl), language)); setSelectedOption(pl, guide, language.getId()); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideSettings.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideSettings.java index 6761a9c19c..a1e310e4fc 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideSettings.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideSettings.java @@ -32,11 +32,11 @@ /** * This static utility class offers various methods that provide access to the * Settings menu of our {@link SlimefunGuide}. - * + * * This menu is used to allow a {@link Player} to change things such as the {@link Language}. - * + * * @author TheBusyBiscuit - * + * * @see SlimefunGuide * */ @@ -78,11 +78,10 @@ private static void addHeader(Player p, ChestMenu menu, ItemStack guide) { LocalizationService locale = Slimefun.getLocalization(); // @formatter:off - menu.addItem(0, new CustomItemStack(SlimefunGuide.getItem(SlimefunGuideMode.SURVIVAL_MODE), + menu.addItem(0, CustomItemStack.create(SlimefunGuide.getItem(SlimefunGuideMode.SURVIVAL_MODE), "&e\u21E6 " + locale.getMessage(p, "guide.back.title"), "", - "&7" + locale.getMessage(p, "guide.back.guide") - )); + "&7" + locale.getMessage(p, "guide.back.guide"))); // @formatter:on menu.addMenuClickHandler(0, (pl, slot, item, action) -> { @@ -99,10 +98,9 @@ private static void addHeader(Player p, ChestMenu menu, ItemStack guide) { contributorsLore.add("&7\u21E8 &e" + locale.getMessage(p, "guide.credits.open")); // @formatter:off - menu.addItem(2, new CustomItemStack(SlimefunUtils.getCustomHead("e952d2b3f351a6b0487cc59db31bf5f2641133e5ba0006b18576e996a0293e52"), + menu.addItem(2, CustomItemStack.create(SlimefunUtils.getCustomHead("e952d2b3f351a6b0487cc59db31bf5f2641133e5ba0006b18576e996a0293e52"), "&c" + locale.getMessage(p, "guide.title.credits"), - contributorsLore.toArray(new String[0]) - )); + contributorsLore.toArray(new String[0]))); // @formatter:on menu.addMenuClickHandler(2, (pl, slot, action, item) -> { @@ -111,7 +109,7 @@ private static void addHeader(Player p, ChestMenu menu, ItemStack guide) { }); // @formatter:off - menu.addItem(4, new CustomItemStack(Material.WRITABLE_BOOK, + menu.addItem(4, CustomItemStack.create(Material.WRITABLE_BOOK, ChatColor.GREEN + locale.getMessage(p, "guide.title.versions"), "&7&o" + locale.getMessage(p, "guide.tooltips.versions-notice"), "", @@ -122,7 +120,7 @@ private static void addHeader(Player p, ChestMenu menu, ItemStack guide) { // @formatter:on // @formatter:off - menu.addItem(6, new CustomItemStack(Material.COMPARATOR, + menu.addItem(6, CustomItemStack.create(Material.COMPARATOR, "&e" + locale.getMessage(p, "guide.title.source"), "", "&7Last Activity: &a" + NumberUtils.getElapsedTime(github.getLastUpdate()) + " ago", "&7Forks: &e" + github.getForks(), @@ -133,8 +131,7 @@ private static void addHeader(Player p, ChestMenu menu, ItemStack guide) { "&7&oand if you want to keep this Plugin alive,", "&7&othen please consider contributing to it", "", - "&7\u21E8 &eClick to go to GitHub" - )); + "&7\u21E8 &eClick to go to GitHub")); // @formatter:on menu.addMenuClickHandler(6, (pl, slot, item, action) -> { @@ -144,15 +141,14 @@ private static void addHeader(Player p, ChestMenu menu, ItemStack guide) { }); // @formatter:off - menu.addItem(8, new CustomItemStack(Material.KNOWLEDGE_BOOK, + menu.addItem(8, CustomItemStack.create(Material.KNOWLEDGE_BOOK, "&3" + locale.getMessage(p, "guide.title.wiki"), "", "&7Do you need help with an Item or machine?", "&7You cannot figure out what to do?", "&7Check out our community-maintained Wiki", "&7and become one of our Editors!", "", - "&7\u21E8 &eClick to go to the official Slimefun Wiki" - )); + "&7\u21E8 &eClick to go to the official Slimefun Wiki")); // @formatter:on menu.addMenuClickHandler(8, (pl, slot, item, action) -> { @@ -162,7 +158,7 @@ private static void addHeader(Player p, ChestMenu menu, ItemStack guide) { }); // @formatter:off - menu.addItem(47, new CustomItemStack(Material.BOOKSHELF, + menu.addItem(47, CustomItemStack.create(Material.BOOKSHELF, "&3" + locale.getMessage(p, "guide.title.addons"), "", "&7Slimefun is huge. But its addons are what makes", @@ -171,8 +167,7 @@ private static void addHeader(Player p, ChestMenu menu, ItemStack guide) { "", "&7Installed on this Server: &b" + Slimefun.getInstalledAddons().size(), "", - "&7\u21E8 &eClick to see all available addons for Slimefun4" - )); + "&7\u21E8 &eClick to see all available addons for Slimefun4")); // @formatter:on menu.addMenuClickHandler(47, (pl, slot, item, action) -> { @@ -183,7 +178,7 @@ private static void addHeader(Player p, ChestMenu menu, ItemStack guide) { if (Slimefun.getUpdater().getBranch().isOfficial()) { // @formatter:off - menu.addItem(49, new CustomItemStack(Material.REDSTONE_TORCH, + menu.addItem(49, CustomItemStack.create(Material.REDSTONE_TORCH, "&4" + locale.getMessage(p, "guide.title.bugs"), "", "&7&oBug reports have to be made in English!", @@ -191,8 +186,7 @@ private static void addHeader(Player p, ChestMenu menu, ItemStack guide) { "&7Open Issues: &a" + github.getOpenIssues(), "&7Pending Pull Requests: &a" + github.getPendingPullRequests(), "", - "&7\u21E8 &eClick to go to the Slimefun4 Bug Tracker" - )); + "&7\u21E8 &eClick to go to the Slimefun4 Bug Tracker")); // @formatter:on menu.addMenuClickHandler(49, (pl, slot, item, action) -> { @@ -204,7 +198,7 @@ private static void addHeader(Player p, ChestMenu menu, ItemStack guide) { menu.addItem(49, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler()); } - menu.addItem(51, new CustomItemStack(Material.TOTEM_OF_UNDYING, ChatColor.RED + locale.getMessage(p, "guide.work-in-progress")), (pl, slot, item, action) -> { + menu.addItem(51, CustomItemStack.create(Material.TOTEM_OF_UNDYING, ChatColor.RED + locale.getMessage(p, "guide.work-in-progress")), (pl, slot, item, action) -> { // Add something here return false; }); @@ -233,10 +227,10 @@ private static void addConfigurableOptions(Player p, ChestMenu menu, ItemStack g * This method checks if the given {@link Player} has enabled the {@link FireworksOption} * in their {@link SlimefunGuide}. * If they enabled this setting, they will see fireworks when they unlock a {@link Research}. - * + * * @param p * The {@link Player} - * + * * @return Whether this {@link Player} wants to see fireworks when unlocking a {@link Research} */ public static boolean hasFireworksEnabled(@Nonnull Player p) { @@ -271,7 +265,7 @@ public static boolean hasLearningAnimationEnabled(@Nonnull Player p) { * Type of the {@link SlimefunGuideOption} * @param * Type of the {@link SlimefunGuideOption} value - * + * * @return The value of given {@link SlimefunGuideOption} */ @Nonnull diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/SlimefunLocalization.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/SlimefunLocalization.java index 893e3baf21..a146a9f620 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/SlimefunLocalization.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/SlimefunLocalization.java @@ -68,7 +68,7 @@ protected void save() { * This returns the chat prefix for our messages. * Every message (unless explicitly omitted) will have this * prefix prepended. - * + * * @return The chat prefix */ public @Nonnull String getChatPrefix() { @@ -321,7 +321,7 @@ protected void loadEmbeddedLanguages() { Language language = getLanguage(p); NamespacedKey key = recipeType.getKey(); - return new CustomItemStack(item, meta -> { + return CustomItemStack.create(item, meta -> { String displayName = getStringOrNull(language, LanguageFile.RECIPES, key.getNamespace() + "." + key.getKey() + ".name"); // Set the display name if possible, else keep the default item name. diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java index d3adb16e0b..62bc4d59e9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java @@ -640,19 +640,19 @@ private SlimefunItems() {} public static final SlimefunItemStack SOULBOUND_BOOTS = new SlimefunItemStack("SOULBOUND_BOOTS", Material.DIAMOND_BOOTS, "&cSoulbound Boots"); /* Runes */ - public static final SlimefunItemStack BLANK_RUNE = new SlimefunItemStack("BLANK_RUNE", new ColoredFireworkStar(Color.BLACK, "&8Blank Rune")); - - public static final SlimefunItemStack AIR_RUNE = new SlimefunItemStack("ANCIENT_RUNE_AIR", new ColoredFireworkStar(Color.AQUA, "&7Ancient Rune &8&l[&b&lAir&8&l]")); - public static final SlimefunItemStack WATER_RUNE = new SlimefunItemStack("ANCIENT_RUNE_WATER", new ColoredFireworkStar(Color.BLUE, "&7Ancient Rune &8&l[&1&lWater&8&l]")); - public static final SlimefunItemStack FIRE_RUNE = new SlimefunItemStack("ANCIENT_RUNE_FIRE", new ColoredFireworkStar(Color.RED, "&7Ancient Rune &8&l[&4&lFire&8&l]")); - public static final SlimefunItemStack EARTH_RUNE = new SlimefunItemStack("ANCIENT_RUNE_EARTH", new ColoredFireworkStar(Color.fromRGB(112, 47, 7), "&7Ancient Rune &8&l[&c&lEarth&8&l]")); - public static final SlimefunItemStack ENDER_RUNE = new SlimefunItemStack("ANCIENT_RUNE_ENDER", new ColoredFireworkStar(Color.PURPLE, "&7Ancient Rune &8&l[&5&lEnder&8&l]")); - - public static final SlimefunItemStack RAINBOW_RUNE = new SlimefunItemStack("ANCIENT_RUNE_RAINBOW", new ColoredFireworkStar(Color.FUCHSIA, "&7Ancient Rune &8&l[&d&lRainbow&8&l]")); - public static final SlimefunItemStack LIGHTNING_RUNE = new SlimefunItemStack("ANCIENT_RUNE_LIGHTNING", new ColoredFireworkStar(Color.fromRGB(255, 255, 95), "&7Ancient Rune &8&l[&e&lLightning&8&l]")); - public static final SlimefunItemStack SOULBOUND_RUNE = new SlimefunItemStack("ANCIENT_RUNE_SOULBOUND", new ColoredFireworkStar(Color.fromRGB(47, 0, 117), "&7Ancient Rune &8&l[&5&lSoulbound&8&l]", "&eDrop this rune onto a dropped item to", "&5bind ðat item to your soul.", " ", "&eIt is advised that you only use this rune", "&eon &6important &eitems.", " ", "&eItems bound to your soul won't drop on death.")); - public static final SlimefunItemStack ENCHANTMENT_RUNE = new SlimefunItemStack("ANCIENT_RUNE_ENCHANTMENT", new ColoredFireworkStar(Color.fromRGB(255, 217, 25), "&7Ancient Rune &8&l[&6&lEnchantment&8&l]", "&eDrop this rune onto a dropped item to", "&6enchant ðat item with a random enchantment.")); - public static final SlimefunItemStack VILLAGER_RUNE = new SlimefunItemStack("ANCIENT_RUNE_VILLAGERS", new ColoredFireworkStar(Color.fromRGB(160, 20, 5), "&7Ancient Rune &8&l[&4&lVillagers&8&l]", "&eRight click a villager to clear", "ðeir current job and trades.", "&eThe villager will start looking", "&efor a job again after some", "&etime has passed.")); + public static final SlimefunItemStack BLANK_RUNE = new SlimefunItemStack("BLANK_RUNE", ColoredFireworkStar.create(Color.BLACK, "&8Blank Rune")); + + public static final SlimefunItemStack AIR_RUNE = new SlimefunItemStack("ANCIENT_RUNE_AIR", ColoredFireworkStar.create(Color.AQUA, "&7Ancient Rune &8&l[&b&lAir&8&l]")); + public static final SlimefunItemStack WATER_RUNE = new SlimefunItemStack("ANCIENT_RUNE_WATER", ColoredFireworkStar.create(Color.BLUE, "&7Ancient Rune &8&l[&1&lWater&8&l]")); + public static final SlimefunItemStack FIRE_RUNE = new SlimefunItemStack("ANCIENT_RUNE_FIRE", ColoredFireworkStar.create(Color.RED, "&7Ancient Rune &8&l[&4&lFire&8&l]")); + public static final SlimefunItemStack EARTH_RUNE = new SlimefunItemStack("ANCIENT_RUNE_EARTH", ColoredFireworkStar.create(Color.fromRGB(112, 47, 7), "&7Ancient Rune &8&l[&c&lEarth&8&l]")); + public static final SlimefunItemStack ENDER_RUNE = new SlimefunItemStack("ANCIENT_RUNE_ENDER", ColoredFireworkStar.create(Color.PURPLE, "&7Ancient Rune &8&l[&5&lEnder&8&l]")); + + public static final SlimefunItemStack RAINBOW_RUNE = new SlimefunItemStack("ANCIENT_RUNE_RAINBOW", ColoredFireworkStar.create(Color.FUCHSIA, "&7Ancient Rune &8&l[&d&lRainbow&8&l]")); + public static final SlimefunItemStack LIGHTNING_RUNE = new SlimefunItemStack("ANCIENT_RUNE_LIGHTNING", ColoredFireworkStar.create(Color.fromRGB(255, 255, 95), "&7Ancient Rune &8&l[&e&lLightning&8&l]")); + public static final SlimefunItemStack SOULBOUND_RUNE = new SlimefunItemStack("ANCIENT_RUNE_SOULBOUND", ColoredFireworkStar.create(Color.fromRGB(47, 0, 117), "&7Ancient Rune &8&l[&5&lSoulbound&8&l]", "&eDrop this rune onto a dropped item to", "&5bind ðat item to your soul.", " ", "&eIt is advised that you only use this rune", "&eon &6important &eitems.", " ", "&eItems bound to your soul won't drop on death.")); + public static final SlimefunItemStack ENCHANTMENT_RUNE = new SlimefunItemStack("ANCIENT_RUNE_ENCHANTMENT", ColoredFireworkStar.create(Color.fromRGB(255, 217, 25), "&7Ancient Rune &8&l[&6&lEnchantment&8&l]", "&eDrop this rune onto a dropped item to", "&6enchant ðat item with a random enchantment.")); + public static final SlimefunItemStack VILLAGER_RUNE = new SlimefunItemStack("ANCIENT_RUNE_VILLAGERS", ColoredFireworkStar.create(Color.fromRGB(160, 20, 5), "&7Ancient Rune &8&l[&4&lVillagers&8&l]", "&eRight click a villager to clear", "ðeir current job and trades.", "&eThe villager will start looking", "&efor a job again after some", "&etime has passed.")); /* Electricity */ public static final SlimefunItemStack SOLAR_GENERATOR = new SlimefunItemStack("SOLAR_GENERATOR", Material.DAYLIGHT_DETECTOR, "&bSolar Generator", "", LoreBuilder.machine(MachineTier.BASIC, MachineType.GENERATOR), LoreBuilder.powerBuffer(0), LoreBuilder.powerPerSecond(4)); 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 83e43be65f..617816af07 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 @@ -59,7 +59,7 @@ * It uses an {@link Inventory} to display {@link SlimefunGuide} contents. * * @author TheBusyBiscuit - * + * * @see SlimefunGuide * @see SlimefunGuideImplementation * @see CheatSheetSlimefunGuide @@ -101,7 +101,7 @@ protected final boolean isSurvivalMode() { * The {@link Player} who opened his {@link SlimefunGuide} * @param profile * The {@link PlayerProfile} of the {@link Player} - * + * * @return a {@link List} of visible {@link ItemGroup} instances */ protected @Nonnull List getVisibleItemGroups(@Nonnull Player p, @Nonnull PlayerProfile profile) { @@ -209,7 +209,7 @@ private void showItemGroup(ChestMenu menu, Player p, PlayerProfile profile, Item lore.add(parent.getItem(p).getItemMeta().getDisplayName()); } - menu.addItem(index, new CustomItemStack(Material.BARRIER, "&4" + Slimefun.getLocalization().getMessage(p, "guide.locked") + " &7- &f" + group.getItem(p).getItemMeta().getDisplayName(), lore.toArray(new String[0]))); + menu.addItem(index, CustomItemStack.create(Material.BARRIER, "&4" + Slimefun.getLocalization().getMessage(p, "guide.locked") + " &7- &f" + group.getItem(p).getItemMeta().getDisplayName(), lore.toArray(new String[0]))); menu.addMenuClickHandler(index, ChestMenuUtils.getEmptyClickHandler()); } } @@ -287,10 +287,10 @@ private void displaySlimefunItem(ChestMenu menu, ItemGroup itemGroup, Player p, if (isSurvivalMode() && !hasPermission(p, sfitem)) { List message = Slimefun.getPermissionsService().getLore(sfitem); - menu.addItem(index, new CustomItemStack(ChestMenuUtils.getNoPermissionItem(), sfitem.getItemName(), message.toArray(new String[0]))); + menu.addItem(index, CustomItemStack.create(ChestMenuUtils.getNoPermissionItem(), sfitem.getItemName(), message.toArray(new String[0]))); menu.addMenuClickHandler(index, ChestMenuUtils.getEmptyClickHandler()); } else if (isSurvivalMode() && research != null && !profile.hasUnlocked(research)) { - menu.addItem(index, new CustomItemStack(ChestMenuUtils.getNotResearchedItem(), ChatColor.WHITE + ItemUtils.getItemName(sfitem.getItem()), "&4&l" + Slimefun.getLocalization().getMessage(p, "guide.locked"), "", "&a> Click to unlock", "", "&7Cost: &b" + research.getCost() + " Level(s)")); + menu.addItem(index, CustomItemStack.create(ChestMenuUtils.getNotResearchedItem(), ChatColor.WHITE + ItemUtils.getItemName(sfitem.getItem()), "&4&l" + Slimefun.getLocalization().getMessage(p, "guide.locked"), "", "&a> Click to unlock", "", "&7Cost: &b" + research.getCost() + " Level(s)")); menu.addMenuClickHandler(index, (pl, slot, item, action) -> { research.unlockFromGuide(this, p, profile, sfitem, itemGroup, page); return false; @@ -358,7 +358,7 @@ public void openSearch(PlayerProfile profile, String input, boolean addToHistory } if (!slimefunItem.isHidden() && isItemGroupAccessible(p, slimefunItem) && isSearchFilterApplicable(slimefunItem, searchTerm)) { - ItemStack itemstack = new CustomItemStack(slimefunItem.getItem(), meta -> { + ItemStack itemstack = CustomItemStack.create(slimefunItem.getItem(), meta -> { ItemGroup itemGroup = slimefunItem.getItemGroup(); meta.setLore(Arrays.asList("", ChatColor.DARK_GRAY + "\u21E8 " + ChatColor.WHITE + itemGroup.getDisplayName(p))); meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_ENCHANTS, VersionedItemFlag.HIDE_ADDITIONAL_TOOLTIP); @@ -442,7 +442,7 @@ private void showMinecraftRecipe(Recipe[] recipes, int index, ItemStack item, Pl recipeType = new RecipeType(optional.get()); result = recipe.getResult(); } else { - recipeItems = new ItemStack[] { null, null, null, null, new CustomItemStack(Material.BARRIER, "&4We are somehow unable to show you this Recipe :/"), null, null, null, null }; + recipeItems = new ItemStack[] { null, null, null, null, CustomItemStack.create(Material.BARRIER, "&4We are somehow unable to show you this Recipe :/"), null, null, null, null }; } ChestMenu menu = create(p); @@ -515,7 +515,7 @@ public void displayItem(PlayerProfile profile, SlimefunItem item, boolean addToH Optional wiki = item.getWikipage(); if (wiki.isPresent()) { - menu.addItem(8, new CustomItemStack(Material.KNOWLEDGE_BOOK, ChatColor.WHITE + Slimefun.getLocalization().getMessage(p, "guide.tooltips.wiki"), "", ChatColor.GRAY + "\u21E8 " + ChatColor.GREEN + Slimefun.getLocalization().getMessage(p, "guide.tooltips.open-itemgroup"))); + menu.addItem(8, CustomItemStack.create(Material.KNOWLEDGE_BOOK, ChatColor.WHITE + Slimefun.getLocalization().getMessage(p, "guide.tooltips.wiki"), "", ChatColor.GRAY + "\u21E8 " + ChatColor.GREEN + Slimefun.getLocalization().getMessage(p, "guide.tooltips.open-itemgroup"))); menu.addMenuClickHandler(8, (pl, slot, itemstack, action) -> { pl.closeInventory(); ChatUtils.sendURL(pl, wiki.get()); @@ -617,7 +617,7 @@ private void addBackButton(ChestMenu menu, int slot, Player p, PlayerProfile pro GuideHistory history = profile.getGuideHistory(); if (isSurvivalMode() && history.size() > 1) { - menu.addItem(slot, new CustomItemStack(ChestMenuUtils.getBackButton(p, "", "&fLeft Click: &7Go back to previous Page", "&fShift + left Click: &7Go back to Main Menu"))); + menu.addItem(slot, ChestMenuUtils.getBackButton(p, "", "&fLeft Click: &7Go back to previous Page", "&fShift + left Click: &7Go back to Main Menu")); menu.addMenuClickHandler(slot, (pl, s, is, action) -> { if (action.isShiftClicked()) { @@ -629,7 +629,7 @@ private void addBackButton(ChestMenu menu, int slot, Player p, PlayerProfile pro }); } else { - menu.addItem(slot, new CustomItemStack(ChestMenuUtils.getBackButton(p, "", ChatColor.GRAY + Slimefun.getLocalization().getMessage(p, "guide.back.guide")))); + menu.addItem(slot, ChestMenuUtils.getBackButton(p, "", ChatColor.GRAY + Slimefun.getLocalization().getMessage(p, "guide.back.guide"))); menu.addMenuClickHandler(slot, (pl, s, is, action) -> { openMainMenu(profile, profile.getGuideHistory().getMainMenuPage()); return false; @@ -647,7 +647,7 @@ private void addBackButton(ChestMenu menu, int slot, Player p, PlayerProfile pro } String lore = hasPermission(p, slimefunItem) ? "&fNeeds to be unlocked in " + slimefunItem.getItemGroup().getDisplayName(p) : "&fNo Permission"; - return slimefunItem.canUse(p, false) ? item : new CustomItemStack(Material.BARRIER, ItemUtils.getItemName(item), "&4&l" + Slimefun.getLocalization().getMessage(p, "guide.locked"), "", lore); + return slimefunItem.canUse(p, false) ? item : CustomItemStack.create(Material.BARRIER, ItemUtils.getItemName(item), "&4&l" + Slimefun.getLocalization().getMessage(p, "guide.locked"), "", lore); } else { return item; } @@ -662,7 +662,7 @@ private void displayRecipes(Player p, PlayerProfile profile, ChestMenu menu, Rec if (page == 0) { for (int i = 27; i < 36; i++) { - menu.replaceExistingItem(i, new CustomItemStack(ChestMenuUtils.getBackground(), sfItem.getRecipeSectionLabel(p))); + menu.replaceExistingItem(i, CustomItemStack.create(ChestMenuUtils.getBackground(), sfItem.getRecipeSectionLabel(p))); menu.addMenuClickHandler(i, ChestMenuUtils.getEmptyClickHandler()); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/AncientPedestal.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/AncientPedestal.java index bbf19d36d8..5d2548e0b8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/AncientPedestal.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/AncientPedestal.java @@ -40,11 +40,11 @@ * The {@link AncientPedestal} is a part of the {@link AncientAltar}. * You can place any {@link ItemStack} onto the {@link AncientPedestal} to provide it to * the altar as a crafting ingredient. - * + * * @author Redemption198 * @author TheBusyBiscuit * @author JustAHuman - * + * * @see AncientAltar * @see AncientAltarListener * @see AncientAltarTask @@ -68,7 +68,7 @@ public AncientPedestal(ItemGroup itemGroup, SlimefunItemStack item, RecipeType r public void onBlockBreak(@Nonnull Block b) { Optional entity = getPlacedItem(b); ArmorStand armorStand = getArmorStand(b, false); - + if (entity.isPresent()) { Item stack = entity.get(); @@ -78,7 +78,7 @@ public void onBlockBreak(@Nonnull Block b) { stack.remove(); } } - + if (armorStand != null && armorStand.isValid()) { armorStand.remove(); } @@ -102,21 +102,21 @@ public void onBlockBreak(@Nonnull Block b) { return Optional.empty(); } - + public @Nullable ArmorStand getArmorStand(@Nonnull Block pedestal, boolean createIfNoneExists) { Optional entity = getPlacedItem(pedestal); - + if (entity.isPresent() && entity.get().getVehicle() instanceof ArmorStand armorStand) { return armorStand; } - + Location l = pedestal.getLocation().add(0.5, 1.2, 0.5); for (Entity n : l.getWorld().getNearbyEntities(l, 0.5, 0.5, 0.5, this::testArmorStand)) { if (n instanceof ArmorStand armorStand) { return armorStand; } } - + return createIfNoneExists ? ArmorStandUtils.spawnArmorStand(l) : null; } @@ -129,7 +129,7 @@ public static boolean testItem(@Nullable Entity n) { return false; } } - + private boolean testArmorStand(@Nullable Entity n) { if (n instanceof ArmorStand && n.isValid()) { String customName = n.getCustomName(); @@ -157,7 +157,7 @@ private boolean testArmorStand(@Nullable Entity n) { public void placeItem(@Nonnull Player p, @Nonnull Block b) { ItemStack hand = p.getInventory().getItemInMainHand(); String displayName = ITEM_PREFIX + System.nanoTime(); - ItemStack displayItem = new CustomItemStack(hand, displayName); + ItemStack displayItem = CustomItemStack.create(hand, displayName); displayItem.setAmount(1); // Get the display name of the original Item in the Player's hand diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidFuelSource.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidFuelSource.java index 3fef5f5925..d2bdc34581 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidFuelSource.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidFuelSource.java @@ -9,7 +9,7 @@ /** * This enum covers all different fuel sources a {@link ProgrammableAndroid} can have. - * + * * @author TheBusyBiscuit * */ @@ -38,12 +38,12 @@ public enum AndroidFuelSource { /** * This returns a display {@link ItemStack} for this {@link AndroidFuelSource}. - * + * * @return An {@link ItemStack} to display */ @Nonnull public ItemStack getItem() { - return new CustomItemStack(HeadTexture.GENERATOR.getAsItemStack(), "&8\u21E9 &cFuel Input &8\u21E9", lore); + return CustomItemStack.create(HeadTexture.GENERATOR.getAsItemStack(), "&8\u21E9 &cFuel Input &8\u21E9", lore); } } 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 8db9826bc7..669327a9bf 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 @@ -102,7 +102,7 @@ public boolean canOpen(Block b, Player p) { @Override public void newInstance(BlockMenu menu, Block b) { - menu.replaceExistingItem(15, new CustomItemStack(HeadTexture.SCRIPT_START.getAsItemStack(), "&aStart/Continue")); + menu.replaceExistingItem(15, CustomItemStack.create(HeadTexture.SCRIPT_START.getAsItemStack(), "&aStart/Continue")); menu.addMenuClickHandler(15, (p, slot, item, action) -> { Slimefun.getLocalization().sendMessage(p, "android.started", true); BlockStorage.addBlockInfo(b, "paused", "false"); @@ -110,14 +110,14 @@ public void newInstance(BlockMenu menu, Block b) { return false; }); - menu.replaceExistingItem(17, new CustomItemStack(HeadTexture.SCRIPT_PAUSE.getAsItemStack(), "&4Pause")); + menu.replaceExistingItem(17, CustomItemStack.create(HeadTexture.SCRIPT_PAUSE.getAsItemStack(), "&4Pause")); menu.addMenuClickHandler(17, (p, slot, item, action) -> { BlockStorage.addBlockInfo(b, "paused", "true"); Slimefun.getLocalization().sendMessage(p, "android.stopped", true); return false; }); - menu.replaceExistingItem(16, new CustomItemStack(HeadTexture.ENERGY_REGULATOR.getAsItemStack(), "&bMemory Core", "", "&8\u21E8 &7Click to open the Script Editor")); + menu.replaceExistingItem(16, CustomItemStack.create(HeadTexture.ENERGY_REGULATOR.getAsItemStack(), "&bMemory Core", "", "&8\u21E8 &7Click to open the Script Editor")); menu.addMenuClickHandler(16, (p, slot, item, action) -> { BlockStorage.addBlockInfo(b, "paused", "true"); Slimefun.getLocalization().sendMessage(p, "android.stopped", true); @@ -189,7 +189,7 @@ public void onPlayerBreak(BlockBreakEvent e, ItemStack item, List dro /** * This returns the {@link AndroidType} that is associated with this {@link ProgrammableAndroid}. - * + * * @return The type of this {@link ProgrammableAndroid} */ public AndroidType getAndroidType() { @@ -199,7 +199,7 @@ public AndroidType getAndroidType() { /** * This returns the {@link AndroidFuelSource} for this {@link ProgrammableAndroid}. * It determines what kind of fuel is required to run it. - * + * * @return The required type of fuel */ public AndroidFuelSource getFuelSource() { @@ -236,7 +236,7 @@ public void openScript(Player p, Block b, String sourceCode) { ChestMenu menu = new ChestMenu(ChatColor.DARK_AQUA + Slimefun.getLocalization().getMessage(p, "android.scripts.editor")); menu.setEmptySlotsClickable(false); - menu.addItem(0, new CustomItemStack(Instruction.START.getItem(), Slimefun.getLocalization().getMessage(p, "android.scripts.instructions.START"), "", "&7\u21E8 &eLeft Click &7to return to the Android's interface")); + menu.addItem(0, CustomItemStack.create(Instruction.START.getItem(), Slimefun.getLocalization().getMessage(p, "android.scripts.instructions.START"), "", "&7\u21E8 &eLeft Click &7to return to the Android's interface")); menu.addMenuClickHandler(0, (pl, slot, item, action) -> { BlockMenu inv = BlockStorage.getInventory(b); // Fixes #2937 @@ -257,7 +257,7 @@ public void openScript(Player p, Block b, String sourceCode) { boolean hasFreeSlot = script.length < 54; if (hasFreeSlot) { - menu.addItem(i, new CustomItemStack(HeadTexture.SCRIPT_NEW.getAsItemStack(), "&7> Add new Command")); + menu.addItem(i, CustomItemStack.create(HeadTexture.SCRIPT_NEW.getAsItemStack(), "&7> Add new Command")); menu.addMenuClickHandler(i, (pl, slot, item, action) -> { editInstruction(pl, b, script, index); return false; @@ -265,7 +265,7 @@ public void openScript(Player p, Block b, String sourceCode) { } int slot = i + (hasFreeSlot ? 1 : 0); - menu.addItem(slot, new CustomItemStack(Instruction.REPEAT.getItem(), Slimefun.getLocalization().getMessage(p, "android.scripts.instructions.REPEAT"), "", "&7\u21E8 &eLeft Click &7to return to the Android's interface")); + menu.addItem(slot, CustomItemStack.create(Instruction.REPEAT.getItem(), Slimefun.getLocalization().getMessage(p, "android.scripts.instructions.REPEAT"), "", "&7\u21E8 &eLeft Click &7to return to the Android's interface")); menu.addMenuClickHandler(slot, (pl, s, item, action) -> { BlockMenu inv = BlockStorage.getInventory(b); // Fixes #2937 @@ -285,7 +285,7 @@ public void openScript(Player p, Block b, String sourceCode) { } ItemStack stack = instruction.getItem(); - menu.addItem(i, new CustomItemStack(stack, Slimefun.getLocalization().getMessage(p, "android.scripts.instructions." + instruction.name()), "", "&7\u21E8 &eLeft Click &7to edit", "&7\u21E8 &eRight Click &7to delete", "&7\u21E8 &eShift + Right Click &7to duplicate")); + menu.addItem(i, CustomItemStack.create(stack, Slimefun.getLocalization().getMessage(p, "android.scripts.instructions." + instruction.name()), "", "&7\u21E8 &eLeft Click &7to edit", "&7\u21E8 &eRight Click &7to delete", "&7\u21E8 &eShift + Right Click &7to duplicate")); menu.addMenuClickHandler(i, (pl, slot, item, action) -> { if (action.isRightClicked() && action.isShiftClicked()) { if (script.length == 54) { @@ -392,7 +392,7 @@ protected void openScriptDownloader(Player p, Block b, int page) { return false; }); - menu.addItem(48, new CustomItemStack(HeadTexture.SCRIPT_UP.getAsItemStack(), "&eUpload a Script", "", "&6Click &7to upload your Android's Script", "&7to the Server's database")); + menu.addItem(48, CustomItemStack.create(HeadTexture.SCRIPT_UP.getAsItemStack(), "&eUpload a Script", "", "&6Click &7to upload your Android's Script", "&7to the Server's database")); menu.addMenuClickHandler(48, (pl, slot, item, action) -> { uploadScript(pl, b, page); return false; @@ -410,7 +410,7 @@ protected void openScriptDownloader(Player p, Block b, int page) { return false; }); - menu.addItem(53, new CustomItemStack(HeadTexture.SCRIPT_LEFT.getAsItemStack(), "&6> Back", "", "&7Return to the Android's interface")); + menu.addItem(53, CustomItemStack.create(HeadTexture.SCRIPT_LEFT.getAsItemStack(), "&6> Back", "", "&7Return to the Android's interface")); menu.addMenuClickHandler(53, (pl, slot, item, action) -> { openScriptEditor(pl, b); return false; @@ -487,7 +487,7 @@ public void openScriptEditor(Player p, Block b) { ChestMenu menu = new ChestMenu(ChatColor.DARK_AQUA + Slimefun.getLocalization().getMessage(p, "android.scripts.editor")); menu.setEmptySlotsClickable(false); - menu.addItem(1, new CustomItemStack(HeadTexture.SCRIPT_FORWARD.getAsItemStack(), "&2> Edit Script", "", "&aEdits your current Script")); + menu.addItem(1, CustomItemStack.create(HeadTexture.SCRIPT_FORWARD.getAsItemStack(), "&2> Edit Script", "", "&aEdits your current Script")); menu.addMenuClickHandler(1, (pl, slot, item, action) -> { String script = BlockStorage.getLocationInfo(b.getLocation()).getString("script"); // Fixes #2937 @@ -504,19 +504,19 @@ public void openScriptEditor(Player p, Block b) { return false; }); - menu.addItem(3, new CustomItemStack(HeadTexture.SCRIPT_NEW.getAsItemStack(), "&4> Create new Script", "", "&cDeletes your current Script", "&cand creates a blank one")); + menu.addItem(3, CustomItemStack.create(HeadTexture.SCRIPT_NEW.getAsItemStack(), "&4> Create new Script", "", "&cDeletes your current Script", "&cand creates a blank one")); menu.addMenuClickHandler(3, (pl, slot, item, action) -> { openScript(pl, b, DEFAULT_SCRIPT); return false; }); - menu.addItem(5, new CustomItemStack(HeadTexture.SCRIPT_DOWN.getAsItemStack(), "&6> Download a Script", "", "&eDownload a Script from the Server", "&eYou can edit or simply use it")); + menu.addItem(5, CustomItemStack.create(HeadTexture.SCRIPT_DOWN.getAsItemStack(), "&6> Download a Script", "", "&eDownload a Script from the Server", "&eYou can edit or simply use it")); menu.addMenuClickHandler(5, (pl, slot, item, action) -> { openScriptDownloader(pl, b, 1); return false; }); - menu.addItem(8, new CustomItemStack(HeadTexture.SCRIPT_LEFT.getAsItemStack(), "&6> Back", "", "&7Return to the Android's interface")); + menu.addItem(8, CustomItemStack.create(HeadTexture.SCRIPT_LEFT.getAsItemStack(), "&6> Back", "", "&7Return to the Android's interface")); menu.addMenuClickHandler(8, (pl, slot, item, action) -> { BlockMenu inv = BlockStorage.getInventory(b); // Fixes #2937 @@ -553,7 +553,7 @@ protected void editInstruction(Player p, Block b, String[] script, int index) { ChestMenuUtils.drawBackground(menu, 0, 1, 2, 3, 4, 5, 6, 7, 8); menu.setEmptySlotsClickable(false); - menu.addItem(9, new CustomItemStack(HeadTexture.SCRIPT_PAUSE.getAsItemStack(), "&fDo nothing"), (pl, slot, item, action) -> { + menu.addItem(9, CustomItemStack.create(HeadTexture.SCRIPT_PAUSE.getAsItemStack(), "&fDo nothing"), (pl, slot, item, action) -> { String code = deleteInstruction(script, index); setScript(b.getLocation(), code); openScript(p, b, code); @@ -562,7 +562,7 @@ protected void editInstruction(Player p, Block b, String[] script, int index) { int i = 10; for (Instruction instruction : getValidScriptInstructions()) { - menu.addItem(i, new CustomItemStack(instruction.getItem(), Slimefun.getLocalization().getMessage(p, "android.scripts.instructions." + instruction.name())), (pl, slot, item, action) -> { + menu.addItem(i, CustomItemStack.create(instruction.getItem(), Slimefun.getLocalization().getMessage(p, "android.scripts.instructions." + instruction.name())), (pl, slot, item, action) -> { String code = addInstruction(script, index, instruction); setScript(b.getLocation(), code); openScript(p, b, code); @@ -808,7 +808,7 @@ private boolean insertFuel(BlockMenu menu, Inventory dispenser, int slot, ItemSt if (rest > 0) { int amount = newFuel.getAmount() > rest ? rest : newFuel.getAmount(); - menu.replaceExistingItem(43, new CustomItemStack(newFuel, currentFuel.getAmount() + amount)); + menu.replaceExistingItem(43, CustomItemStack.create(newFuel, currentFuel.getAmount() + amount)); ItemUtils.consumeItem(newFuel, amount, false); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Script.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Script.java index 652a75f9ba..bdb647b5cd 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Script.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Script.java @@ -27,7 +27,7 @@ /** * A {@link Script} represents runnable code for a {@link ProgrammableAndroid}. - * + * * @author TheBusyBiscuit * */ @@ -40,7 +40,7 @@ public final class Script { /** * This constructs a new {@link Script} from the given {@link Config}. - * + * * @param config * The {@link Config} */ @@ -64,7 +64,7 @@ private Script(@Nonnull Config config) { /** * This returns the name of this {@link Script}. - * + * * @return The name */ @Nonnull @@ -75,7 +75,7 @@ public String getName() { /** * This returns the author of this {@link Script}. * The author is the person who initially created and uploaded this {@link Script}. - * + * * @return The author of this {@link Script} */ @Nonnull @@ -87,7 +87,7 @@ public String getAuthor() { * This method returns the actual code of this {@link Script}. * It is basically a {@link String} describing the order of {@link Instruction Instructions} that * shall be executed. - * + * * @return The code for this {@link Script} */ @Nonnull @@ -98,10 +98,10 @@ public String getSourceCode() { /** * This method determines whether the given {@link OfflinePlayer} is the author of * this {@link Script}. - * + * * @param p * The {@link OfflinePlayer} to check for - * + * * @return Whether the given {@link OfflinePlayer} is the author of this {@link Script}. */ public boolean isAuthor(@Nonnull OfflinePlayer p) { @@ -111,10 +111,10 @@ public boolean isAuthor(@Nonnull OfflinePlayer p) { /** * This method checks whether a given {@link Player} is able to leave a rating for this {@link Script}. * A {@link Player} is unable to rate his own {@link Script} or a {@link Script} he already rated before. - * + * * @param p * The {@link Player} to check for - * + * * @return Whether the given {@link Player} is able to rate this {@link Script} */ public boolean canRate(@Nonnull Player p) { @@ -145,7 +145,7 @@ ItemStack getAsItemStack(@Nonnull ProgrammableAndroid android, @Nonnull Player p lore.add("&eShift + Right Click &fto leave a negative Rating"); } - return new CustomItemStack(android.getItem(), "&b" + getName(), lore.toArray(new String[0])); + return CustomItemStack.create(android.getItem(), "&b" + getName(), lore.toArray(new String[0])); } @Nonnull @@ -156,7 +156,7 @@ private String getScriptRatingPercentage() { /** * This method returns the amount of upvotes this {@link Script} has received. - * + * * @return The amount of upvotes */ public int getUpvotes() { @@ -165,7 +165,7 @@ public int getUpvotes() { /** * This method returns the amount of downvotes this {@link Script} has received. - * + * * @return The amount of downvotes */ public int getDownvotes() { @@ -174,7 +174,7 @@ public int getDownvotes() { /** * This returns how often this {@link Script} has been downloaded. - * + * * @return The amount of downloads for this {@link Script}. */ public int getDownloads() { @@ -184,7 +184,7 @@ public int getDownloads() { /** * This returns the "rating" of this {@link Script}. * This value is calculated from the up- and downvotes this {@link Script} received. - * + * * @return The rating for this {@link Script} */ public float getRating() { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/AbstractAutoCrafter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/AbstractAutoCrafter.java index b75d3c6643..4186291716 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/AbstractAutoCrafter.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/AbstractAutoCrafter.java @@ -52,9 +52,9 @@ /** * This is the abstract super class for our auto crafters. - * + * * @author TheBusyBiscuit - * + * * @see VanillaAutoCrafter * @see EnhancedAutoCrafter * @@ -117,7 +117,7 @@ public boolean isSynchronized() { *

* Do not call this method directly, see our {@link AutoCrafterListener} for the intended * use case. - * + * * @param b * The {@link Block} that was clicked * @param p @@ -153,7 +153,7 @@ public void onRightClick(Block b, Player p) { /** * This method performs one tick for the {@link AbstractAutoCrafter}. - * + * * @param b * The block for this {@link AbstractAutoCrafter} * @param data @@ -192,10 +192,10 @@ protected void tick(@Nonnull Block b, @Nonnull Config data) { * where the Auto Crafter could be placed upon. * Right now this only supports chests and a few select tile entities but it can change or * be overridden in the future. - * + * * @param block * The {@link Block} to check - * + * * @return Whether that {@link Block} has a valid {@link Inventory} */ protected boolean isValidInventory(@Nonnull Block block) { @@ -207,10 +207,10 @@ protected boolean isValidInventory(@Nonnull Block block) { /** * This method returns the currently selected {@link AbstractRecipe} for the given * {@link Block}. - * + * * @param b * The {@link Block} - * + * * @return The currently selected {@link AbstractRecipe} or null */ @Nullable @@ -220,7 +220,7 @@ protected boolean isValidInventory(@Nonnull Block block) { * This method is called when a {@link Player} right clicks the {@link AbstractAutoCrafter} * while holding the shift button. * Use it to choose the {@link AbstractRecipe}. - * + * * @param b * The {@link Block} which was clicked * @param p @@ -231,7 +231,7 @@ protected boolean isValidInventory(@Nonnull Block block) { /** * This method sets the selected {@link AbstractRecipe} for the given {@link Block}. * The recipe will be stored using the {@link PersistentDataAPI}. - * + * * @param b * The {@link Block} to store the data on * @param recipe @@ -264,7 +264,7 @@ protected void setSelectedRecipe(@Nonnull Block b, @Nullable AbstractRecipe reci /** * This shows the given {@link AbstractRecipe} to the {@link Player} in a preview window. - * + * * @param p * The {@link Player} * @param b @@ -286,7 +286,7 @@ protected void showRecipe(Player p, Block b, AbstractRecipe recipe) { ChestMenuUtils.drawBackground(menu, 45, 46, 47, 48, 50, 51, 52, 53); if (recipe.isEnabled()) { - menu.addItem(49, new CustomItemStack(Material.BARRIER, Slimefun.getLocalization().getMessages(p, "messages.auto-crafting.tooltips.enabled"))); + menu.addItem(49, CustomItemStack.create(Material.BARRIER, Slimefun.getLocalization().getMessages(p, "messages.auto-crafting.tooltips.enabled"))); menu.addMenuClickHandler(49, (pl, item, slot, action) -> { if (action.isRightClicked()) { deleteRecipe(pl, b); @@ -297,7 +297,7 @@ protected void showRecipe(Player p, Block b, AbstractRecipe recipe) { return false; }); } else { - menu.addItem(49, new CustomItemStack(HeadTexture.EXCLAMATION_MARK.getAsItemStack(), Slimefun.getLocalization().getMessages(p, "messages.auto-crafting.tooltips.disabled"))); + menu.addItem(49, CustomItemStack.create(HeadTexture.EXCLAMATION_MARK.getAsItemStack(), Slimefun.getLocalization().getMessages(p, "messages.auto-crafting.tooltips.disabled"))); menu.addMenuClickHandler(49, (pl, item, slot, action) -> { if (action.isRightClicked()) { deleteRecipe(pl, b); @@ -350,12 +350,12 @@ private void deleteRecipe(Player p, Block b) { /** * This method checks whether the given {@link Predicate} matches the provided {@link ItemStack}. - * + * * @param item * The {@link ItemStack} to check * @param predicate * The {@link Predicate} - * + * * @return Whether the {@link Predicate} matches the {@link ItemStack} */ @ParametersAreNonnullByDefault @@ -390,12 +390,12 @@ protected boolean matchesAny(Inventory inv, Map itemQuantities * the given {@link Inventory}. * This will consume items and add the result to the {@link Inventory}. * This method does not handle energy consumption. - * + * * @param inv * The {@link Inventory} to take resources from * @param recipe * The {@link AbstractRecipe} to craft - * + * * @return Whether this crafting operation was successful or not */ public boolean craft(@Nonnull Inventory inv, @Nonnull AbstractRecipe recipe) { @@ -461,10 +461,10 @@ public boolean craft(@Nonnull Inventory inv, @Nonnull AbstractRecipe recipe) { * However we cannot use this method as it is only available in the latest 1.16 snapshots * of Spigot, not even on earlier 1.16 builds... * But this gives us more control over the leftovers anyway! - * + * * @param item * The {@link ItemStack} that is being consumed - * + * * @return The leftover item or null if the item is fully consumed */ @Nullable @@ -484,7 +484,7 @@ private ItemStack getLeftoverItem(@Nonnull ItemStack item) { /** * This method returns the max amount of electricity this machine can hold. - * + * * @return The max amount of electricity this Block can store. */ @Override @@ -494,7 +494,7 @@ public int getCapacity() { /** * This method returns the amount of energy that is consumed per operation. - * + * * @return The rate of energy consumption */ public int getEnergyConsumption() { @@ -505,10 +505,10 @@ public int getEnergyConsumption() { * This sets the energy capacity for this machine. * This method must be called before registering the item * and only before registering. - * + * * @param capacity * The amount of energy this machine can store - * + * * @return This method will return the current instance of {@link AContainer}, so that it can be chained. */ @Nonnull @@ -525,10 +525,10 @@ public final AbstractAutoCrafter setCapacity(int capacity) { /** * This method sets the energy consumed by this machine per tick. - * + * * @param energyConsumption * The energy consumed per tick - * + * * @return This method will return the current instance of {@link AContainer}, so that it can be chained. */ @Nonnull diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/SlimefunAutoCrafter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/SlimefunAutoCrafter.java index 620e689b70..d6b730b981 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/SlimefunAutoCrafter.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/SlimefunAutoCrafter.java @@ -33,9 +33,9 @@ * {@link RecipeType}. * The concrete implementation for this can be seen in the {@link EnhancedAutoCrafter} but * it theoretically works for any {@link RecipeType}. - * + * * @author TheBusyBiscuit - * + * * @see EnhancedAutoCrafter * */ @@ -95,7 +95,7 @@ protected void updateRecipe(@Nonnull Block b, @Nonnull Player p) { ChestMenuUtils.drawBackground(menu, background); ChestMenuUtils.drawBackground(menu, 45, 46, 47, 48, 50, 51, 52, 53); - menu.addItem(49, new CustomItemStack(Material.CRAFTING_TABLE, ChatColor.GREEN + Slimefun.getLocalization().getMessage(p, "messages.auto-crafting.select"))); + menu.addItem(49, CustomItemStack.create(Material.CRAFTING_TABLE, ChatColor.GREEN + Slimefun.getLocalization().getMessage(p, "messages.auto-crafting.select"))); menu.addMenuClickHandler(49, (pl, stack, slot, action) -> { setSelectedRecipe(b, recipe); SoundEffect.AUTO_CRAFTER_UPDATE_RECIPE.playAt(b); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/VanillaAutoCrafter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/VanillaAutoCrafter.java index e9c9c962dc..5885d99aec 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/VanillaAutoCrafter.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/VanillaAutoCrafter.java @@ -43,9 +43,9 @@ * The {@link VanillaAutoCrafter} is an implementation of the {@link AbstractAutoCrafter}. * It can craft items that are crafted using a normal crafting table. * Only {@link ShapedRecipe} and {@link ShapelessRecipe} are therefore supported. - * + * * @author TheBusyBiscuit - * + * * @see AbstractAutoCrafter * @see EnhancedAutoCrafter * @see VanillaRecipe @@ -154,7 +154,7 @@ private void offerRecipe(Player p, Block b, List recipes, int index, Che AbstractRecipe recipe = AbstractRecipe.of(recipes.get(index)); - menu.replaceExistingItem(49, new CustomItemStack(Material.CRAFTING_TABLE, ChatColor.GREEN + Slimefun.getLocalization().getMessage(p, "messages.auto-crafting.select"))); + menu.replaceExistingItem(49, CustomItemStack.create(Material.CRAFTING_TABLE, ChatColor.GREEN + Slimefun.getLocalization().getMessage(p, "messages.auto-crafting.select"))); menu.addMenuClickHandler(49, (pl, slot, item, action) -> { setSelectedRecipe(b, recipe); pl.closeInventory(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/HologramProjector.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/HologramProjector.java index 21891d293a..640d0d375a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/HologramProjector.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/HologramProjector.java @@ -35,11 +35,11 @@ /** * The {@link HologramProjector} is a very simple block which allows the {@link Player} * to create a floating text that is completely configurable. - * + * * @author TheBusyBiscuit * @author Kry-Vosa * @author SoSeDiK - * + * * @see HologramOwner * @see HologramsService * @@ -97,7 +97,7 @@ public void onBlockBreak(@Nonnull Block b) { private void openEditor(@Nonnull Player p, @Nonnull Block projector) { ChestMenu menu = new ChestMenu(Slimefun.getLocalization().getMessage(p, "machines.HOLOGRAM_PROJECTOR.inventory-title")); - menu.addItem(0, new CustomItemStack(Material.NAME_TAG, "&7Text &e(Click to edit)", "", "&f" + ChatColors.color(BlockStorage.getLocationInfo(projector.getLocation(), "text")))); + menu.addItem(0, CustomItemStack.create(Material.NAME_TAG, "&7Text &e(Click to edit)", "", "&f" + ChatColors.color(BlockStorage.getLocationInfo(projector.getLocation(), "text")))); menu.addMenuClickHandler(0, (pl, slot, item, action) -> { pl.closeInventory(); Slimefun.getLocalization().sendMessage(pl, "machines.HOLOGRAM_PROJECTOR.enter-text", true); @@ -119,7 +119,7 @@ private void openEditor(@Nonnull Player p, @Nonnull Block projector) { return false; }); - menu.addItem(1, new CustomItemStack(Material.CLOCK, "&7Offset: &e" + NumberUtils.roundDecimalNumber(Double.valueOf(BlockStorage.getLocationInfo(projector.getLocation(), OFFSET_PARAMETER)) + 1.0D), "", "&fLeft Click: &7+0.1", "&fRight Click: &7-0.1")); + menu.addItem(1, CustomItemStack.create(Material.CLOCK, "&7Offset: &e" + NumberUtils.roundDecimalNumber(Double.valueOf(BlockStorage.getLocationInfo(projector.getLocation(), OFFSET_PARAMETER)) + 1.0D), "", "&fLeft Click: &7+0.1", "&fRight Click: &7-0.1")); menu.addMenuClickHandler(1, (pl, slot, item, action) -> { double offset = NumberUtils.reparseDouble(Double.valueOf(BlockStorage.getLocationInfo(projector.getLocation(), OFFSET_PARAMETER)) + (action.isRightClicked() ? -0.1F : 0.1F)); ArmorStand hologram = getArmorStand(projector, true); @@ -152,7 +152,7 @@ private static ArmorStand getArmorStand(@Nonnull Block projector, boolean create if (!createIfNoneExists) { return null; } - + return ArmorStandUtils.spawnArmorStand(l, nametag); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractCargoNode.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractCargoNode.java index b662a060c1..c335e7fc25 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractCargoNode.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractCargoNode.java @@ -32,7 +32,7 @@ /** * This abstract class is the super class of all cargo nodes. - * + * * @author TheBusyBiscuit * */ @@ -91,7 +91,7 @@ public void onPlayerPlace(BlockPlaceEvent e) { protected void addChannelSelector(Block b, BlockMenu menu, int slotPrev, int slotCurrent, int slotNext) { int channel = getSelectedChannel(b); - menu.replaceExistingItem(slotPrev, new CustomItemStack(HeadTexture.CARGO_ARROW_LEFT.getAsItemStack(), "&bPrevious Channel", "", "&e> Click to decrease the Channel ID by 1")); + menu.replaceExistingItem(slotPrev, CustomItemStack.create(HeadTexture.CARGO_ARROW_LEFT.getAsItemStack(), "&bPrevious Channel", "", "&e> Click to decrease the Channel ID by 1")); menu.addMenuClickHandler(slotPrev, (p, slot, item, action) -> { int newChannel = channel - 1; @@ -105,14 +105,14 @@ protected void addChannelSelector(Block b, BlockMenu menu, int slotPrev, int slo }); if (channel == 16) { - menu.replaceExistingItem(slotCurrent, new CustomItemStack(HeadTexture.CHEST_TERMINAL.getAsItemStack(), "&bChannel ID: &3" + (channel + 1))); + menu.replaceExistingItem(slotCurrent, CustomItemStack.create(HeadTexture.CHEST_TERMINAL.getAsItemStack(), "&bChannel ID: &3" + (channel + 1))); menu.addMenuClickHandler(slotCurrent, ChestMenuUtils.getEmptyClickHandler()); } else { - menu.replaceExistingItem(slotCurrent, new CustomItemStack(ColoredMaterial.WOOL.get(channel), "&bChannel ID: &3" + (channel + 1))); + menu.replaceExistingItem(slotCurrent, CustomItemStack.create(ColoredMaterial.WOOL.get(channel), "&bChannel ID: &3" + (channel + 1))); menu.addMenuClickHandler(slotCurrent, ChestMenuUtils.getEmptyClickHandler()); } - menu.replaceExistingItem(slotNext, new CustomItemStack(HeadTexture.CARGO_ARROW_RIGHT.getAsItemStack(), "&bNext Channel", "", "&e> Click to increase the Channel ID by 1")); + menu.replaceExistingItem(slotNext, CustomItemStack.create(HeadTexture.CARGO_ARROW_RIGHT.getAsItemStack(), "&bNext Channel", "", "&e> Click to increase the Channel ID by 1")); menu.addMenuClickHandler(slotNext, (p, slot, item, action) -> { int newChannel = channel + 1; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractFilterNode.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractFilterNode.java index d3197270bf..c28891e81a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractFilterNode.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractFilterNode.java @@ -25,9 +25,9 @@ /** * This abstract super class represents all filtered Cargo nodes. - * + * * @author TheBusyBiscuit - * + * * @see CargoInputNode * @see AdvancedCargoOutputNode * @@ -80,10 +80,10 @@ protected void onPlace(BlockPlaceEvent e) { @Override protected void createBorder(BlockMenuPreset preset) { for (int i : getBorder()) { - preset.addItem(i, new CustomItemStack(Material.CYAN_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(i, CustomItemStack.create(Material.CYAN_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); } - preset.addItem(2, new CustomItemStack(Material.PAPER, "&3Items", "", "&bPut in all Items you want to", "&bblacklist/whitelist"), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(2, CustomItemStack.create(Material.PAPER, "&3Items", "", "&bPut in all Items you want to", "&bblacklist/whitelist"), ChestMenuUtils.getEmptyClickHandler()); } @Override @@ -92,14 +92,14 @@ protected void updateBlockMenu(BlockMenu menu, Block b) { String filterType = BlockStorage.getLocationInfo(loc, FILTER_TYPE); if (!BlockStorage.hasBlockInfo(b) || filterType == null || filterType.equals("whitelist")) { - menu.replaceExistingItem(15, new CustomItemStack(Material.WHITE_WOOL, "&7Type: &rWhitelist", "", "&e> Click to change it to Blacklist")); + menu.replaceExistingItem(15, CustomItemStack.create(Material.WHITE_WOOL, "&7Type: &rWhitelist", "", "&e> Click to change it to Blacklist")); menu.addMenuClickHandler(15, (p, slot, item, action) -> { BlockStorage.addBlockInfo(b, FILTER_TYPE, "blacklist"); updateBlockMenu(menu, b); return false; }); } else { - menu.replaceExistingItem(15, new CustomItemStack(Material.BLACK_WOOL, "&7Type: &8Blacklist", "", "&e> Click to change it to Whitelist")); + menu.replaceExistingItem(15, CustomItemStack.create(Material.BLACK_WOOL, "&7Type: &8Blacklist", "", "&e> Click to change it to Whitelist")); menu.addMenuClickHandler(15, (p, slot, item, action) -> { BlockStorage.addBlockInfo(b, FILTER_TYPE, "whitelist"); updateBlockMenu(menu, b); @@ -110,14 +110,14 @@ protected void updateBlockMenu(BlockMenu menu, Block b) { String lore = BlockStorage.getLocationInfo(b.getLocation(), FILTER_LORE); if (!BlockStorage.hasBlockInfo(b) || lore == null || lore.equals(String.valueOf(true))) { - menu.replaceExistingItem(25, new CustomItemStack(Material.MAP, "&7Include Lore: &2\u2714", "", "&e> Click to toggle whether the Lore has to match")); + menu.replaceExistingItem(25, CustomItemStack.create(Material.MAP, "&7Include Lore: &2\u2714", "", "&e> Click to toggle whether the Lore has to match")); menu.addMenuClickHandler(25, (p, slot, item, action) -> { BlockStorage.addBlockInfo(b, FILTER_LORE, String.valueOf(false)); updateBlockMenu(menu, b); return false; }); } else { - menu.replaceExistingItem(25, new CustomItemStack(Material.MAP, "&7Include Lore: &4\u2718", "", "&e> Click to toggle whether the Lore has to match")); + menu.replaceExistingItem(25, CustomItemStack.create(Material.MAP, "&7Include Lore: &4\u2718", "", "&e> Click to toggle whether the Lore has to match")); menu.addMenuClickHandler(25, (p, slot, item, action) -> { BlockStorage.addBlockInfo(b, FILTER_LORE, String.valueOf(true)); updateBlockMenu(menu, b); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoInputNode.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoInputNode.java index d39557bf5d..fe32c6fe7d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoInputNode.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoInputNode.java @@ -47,14 +47,14 @@ protected void updateBlockMenu(BlockMenu menu, Block b) { String roundRobinMode = BlockStorage.getLocationInfo(b.getLocation(), ROUND_ROBIN_MODE); if (!BlockStorage.hasBlockInfo(b) || roundRobinMode == null || roundRobinMode.equals(String.valueOf(false))) { - menu.replaceExistingItem(24, new CustomItemStack(HeadTexture.ENERGY_REGULATOR.getAsItemStack(), "&7Round-Robin Mode: &4\u2718", "", "&e> Click to enable Round Robin Mode", "&e(Items will be equally distributed on the Channel)")); + menu.replaceExistingItem(24, CustomItemStack.create(HeadTexture.ENERGY_REGULATOR.getAsItemStack(), "&7Round-Robin Mode: &4\u2718", "", "&e> Click to enable Round Robin Mode", "&e(Items will be equally distributed on the Channel)")); menu.addMenuClickHandler(24, (p, slot, item, action) -> { BlockStorage.addBlockInfo(b, ROUND_ROBIN_MODE, String.valueOf(true)); updateBlockMenu(menu, b); return false; }); } else { - menu.replaceExistingItem(24, new CustomItemStack(HeadTexture.ENERGY_REGULATOR.getAsItemStack(), "&7Round-Robin Mode: &2\u2714", "", "&e> Click to disable Round Robin Mode", "&e(Items will be equally distributed on the Channel)")); + menu.replaceExistingItem(24, CustomItemStack.create(HeadTexture.ENERGY_REGULATOR.getAsItemStack(), "&7Round-Robin Mode: &2\u2714", "", "&e> Click to disable Round Robin Mode", "&e(Items will be equally distributed on the Channel)")); menu.addMenuClickHandler(24, (p, slot, item, action) -> { BlockStorage.addBlockInfo(b, ROUND_ROBIN_MODE, String.valueOf(false)); updateBlockMenu(menu, b); @@ -64,14 +64,14 @@ protected void updateBlockMenu(BlockMenu menu, Block b) { String smartFillNode = BlockStorage.getLocationInfo(b.getLocation(), SMART_FILL_MODE); if (!BlockStorage.hasBlockInfo(b) || smartFillNode == null || smartFillNode.equals(String.valueOf(false))) { - menu.replaceExistingItem(16, new CustomItemStack(Material.WRITABLE_BOOK, "&7\"Smart-Filling\" Mode: &4\u2718", "", "&e> Click to enable \"Smart-Filling\" Mode", "", "&fIn this mode, the Cargo node will attempt", "&fto keep a constant amount of items", "&fin the inventory. This is not perfect", "&fand will still fill in empty slots that", "&fcome before a stack of a configured item.")); + menu.replaceExistingItem(16, CustomItemStack.create(Material.WRITABLE_BOOK, "&7\"Smart-Filling\" Mode: &4\u2718", "", "&e> Click to enable \"Smart-Filling\" Mode", "", "&fIn this mode, the Cargo node will attempt", "&fto keep a constant amount of items", "&fin the inventory. This is not perfect", "&fand will still fill in empty slots that", "&fcome before a stack of a configured item.")); menu.addMenuClickHandler(16, (p, slot, item, action) -> { BlockStorage.addBlockInfo(b, SMART_FILL_MODE, String.valueOf(true)); updateBlockMenu(menu, b); return false; }); } else { - menu.replaceExistingItem(16, new CustomItemStack(Material.WRITTEN_BOOK, "&7\"Smart-Filling\" Mode: &2\u2714", "", "&e> Click to disable \"Smart-Filling\" Mode", "", "&fIn this mode, the Cargo node will attempt", "&fto keep a constant amount of items", "&fin the inventory. This is not perfect", "&fand will still fill in empty slots that", "&fcome before a stack of a configured item.")); + menu.replaceExistingItem(16, CustomItemStack.create(Material.WRITTEN_BOOK, "&7\"Smart-Filling\" Mode: &2\u2714", "", "&e> Click to disable \"Smart-Filling\" Mode", "", "&fIn this mode, the Cargo node will attempt", "&fto keep a constant amount of items", "&fin the inventory. This is not perfect", "&fand will still fill in empty slots that", "&fcome before a stack of a configured item.")); menu.addMenuClickHandler(16, (p, slot, item, action) -> { BlockStorage.addBlockInfo(b, SMART_FILL_MODE, String.valueOf(false)); updateBlockMenu(menu, b); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoOutputNode.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoOutputNode.java index c0c7f0efd0..d00de44ea7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoOutputNode.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoOutputNode.java @@ -39,7 +39,7 @@ protected void onPlace(BlockPlaceEvent e) { @Override protected void createBorder(BlockMenuPreset preset) { for (int i : BORDER) { - preset.addItem(i, new CustomItemStack(Material.CYAN_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(i, CustomItemStack.create(Material.CYAN_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/ReactorAccessPort.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/ReactorAccessPort.java index 241c1f00f7..df42149433 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/ReactorAccessPort.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/ReactorAccessPort.java @@ -35,7 +35,7 @@ * The {@link ReactorAccessPort} is a block which acts as an interface * between a {@link Reactor} and a {@link CargoNet}. * Any item placed into the port will get transferred to the {@link Reactor}. - * + * * @author TheBusyBiscuit * @author AlexLander123 * @@ -72,7 +72,7 @@ public void newInstance(BlockMenu menu, Block b) { BlockMenu reactor = getReactor(b.getLocation()); if (reactor != null) { - menu.replaceExistingItem(INFO_SLOT, new CustomItemStack(Material.GREEN_WOOL, "&7Reactor", "", "&6Detected", "", "&7> Click to view Reactor")); + menu.replaceExistingItem(INFO_SLOT, CustomItemStack.create(Material.GREEN_WOOL, "&7Reactor", "", "&6Detected", "", "&7> Click to view Reactor")); menu.addMenuClickHandler(INFO_SLOT, (p, slot, item, action) -> { if (reactor != null) { reactor.open(p); @@ -83,7 +83,7 @@ public void newInstance(BlockMenu menu, Block b) { return false; }); } else { - menu.replaceExistingItem(INFO_SLOT, new CustomItemStack(Material.RED_WOOL, "&7Reactor", "", "&cNot detected", "", "&7Reactor must be", "&7placed 3 blocks below", "&7the access port!")); + menu.replaceExistingItem(INFO_SLOT, CustomItemStack.create(Material.RED_WOOL, "&7Reactor", "", "&cNot detected", "", "&7Reactor must be", "&7placed 3 blocks below", "&7the access port!")); menu.addMenuClickHandler(INFO_SLOT, (p, slot, item, action) -> { newInstance(menu, b); return false; @@ -135,13 +135,13 @@ public void onBlockBreak(@Nonnull Block b) { private void constructMenu(@Nonnull BlockMenuPreset preset) { preset.drawBackground(ChestMenuUtils.getBackground(), background); - preset.drawBackground(new CustomItemStack(Material.LIME_STAINED_GLASS_PANE, " "), fuelBorder); - preset.drawBackground(new CustomItemStack(Material.CYAN_STAINED_GLASS_PANE, " "), inputBorder); - preset.drawBackground(new CustomItemStack(Material.GREEN_STAINED_GLASS_PANE, " "), outputBorder); + preset.drawBackground(CustomItemStack.create(Material.LIME_STAINED_GLASS_PANE, " "), fuelBorder); + preset.drawBackground(CustomItemStack.create(Material.CYAN_STAINED_GLASS_PANE, " "), inputBorder); + preset.drawBackground(CustomItemStack.create(Material.GREEN_STAINED_GLASS_PANE, " "), outputBorder); - preset.addItem(1, new CustomItemStack(SlimefunItems.URANIUM, "&7Fuel Slot", "", "&rThis Slot accepts radioactive Fuel such as:", "&2Uranium &ror &aNeptunium"), ChestMenuUtils.getEmptyClickHandler()); - preset.addItem(22, new CustomItemStack(SlimefunItems.PLUTONIUM, "&7Byproduct Slot", "", "&rThis Slot contains the Reactor's Byproduct", "&rsuch as &aNeptunium &ror &7Plutonium"), ChestMenuUtils.getEmptyClickHandler()); - preset.addItem(7, new CustomItemStack(SlimefunItems.REACTOR_COOLANT_CELL, "&bCoolant Slot", "", "&rThis Slot accepts Coolant Cells", "&4Without any Coolant Cells, your Reactor", "&4will explode"), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(1, CustomItemStack.create(SlimefunItems.URANIUM, "&7Fuel Slot", "", "&rThis Slot accepts radioactive Fuel such as:", "&2Uranium &ror &aNeptunium"), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(22, CustomItemStack.create(SlimefunItems.PLUTONIUM, "&7Byproduct Slot", "", "&rThis Slot contains the Reactor's Byproduct", "&rsuch as &aNeptunium &ror &7Plutonium"), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(7, CustomItemStack.create(SlimefunItems.REACTOR_COOLANT_CELL, "&bCoolant Slot", "", "&rThis Slot accepts Coolant Cells", "&4Without any Coolant Cells, your Reactor", "&4will explode"), ChestMenuUtils.getEmptyClickHandler()); } @Nonnull diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/TrashCan.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/TrashCan.java index bc5e86aef4..a61f8deb54 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/TrashCan.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/TrashCan.java @@ -23,14 +23,14 @@ /** * The {@link TrashCan} is a simple container which simply voids all * items that enter it. - * + * * @author TheBusyBiscuit * */ public class TrashCan extends SlimefunItem implements InventoryBlock { private final int[] border = { 0, 1, 2, 3, 5, 4, 6, 7, 8, 9, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }; - private final ItemStack background = new CustomItemStack(Material.RED_STAINED_GLASS_PANE, " "); + private final ItemStack background = CustomItemStack.create(Material.RED_STAINED_GLASS_PANE, " "); @ParametersAreNonnullByDefault public TrashCan(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/CarbonPress.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/CarbonPress.java index 4772b718d4..b1ddb9f8f5 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/CarbonPress.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/CarbonPress.java @@ -26,7 +26,7 @@ protected void registerDefaultRecipes() { registerRecipe(15, new ItemStack[] { new ItemStack(Material.CHARCOAL, 4) }, new ItemStack[] { new ItemStack(Material.COAL) }); registerRecipe(20, new ItemStack[] { new ItemStack(Material.COAL, 8) }, new ItemStack[] { SlimefunItems.CARBON }); registerRecipe(180, new ItemStack[] { new ItemStack(Material.COAL_BLOCK, 8) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.CARBON, 9) }); - registerRecipe(30, new ItemStack[] { new CustomItemStack(SlimefunItems.CARBON, 4) }, new ItemStack[] { SlimefunItems.COMPRESSED_CARBON }); + registerRecipe(30, new ItemStack[] { CustomItemStack.create(SlimefunItems.CARBON, 4) }, new ItemStack[] { SlimefunItems.COMPRESSED_CARBON }); registerRecipe(60, new ItemStack[] { SlimefunItems.CARBON_CHUNK, SlimefunItems.SYNTHETIC_DIAMOND }, new ItemStack[] { SlimefunItems.RAW_CARBONADO }); registerRecipe(60, new ItemStack[] { SlimefunItems.CARBON_CHUNK }, new ItemStack[] { SlimefunItems.SYNTHETIC_DIAMOND }); registerRecipe(90, new ItemStack[] { SlimefunItems.RAW_CARBONADO }, new ItemStack[] { SlimefunItems.CARBONADO }); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricPress.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricPress.java index b5cb6f2f4d..b4346708e8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricPress.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricPress.java @@ -19,7 +19,7 @@ /** * The {@link ElectricPress} is a pretty simple electrical machine. * It allows you to compact items into their block variant, e.g. 9 diamonds into a diamond block. - * + * * @author TheBusyBiscuit * */ @@ -44,15 +44,15 @@ protected void registerDefaultRecipes() { addRecipe(3, new ItemStack(Material.CLAY_BALL, 4), new ItemStack(Material.CLAY)); addRecipe(3, new ItemStack(Material.BRICK, 4), new ItemStack(Material.BRICKS)); - addRecipe(6, SlimefunItems.COPPER_INGOT, new CustomItemStack(SlimefunItems.COPPER_WIRE, 3)); + addRecipe(6, SlimefunItems.COPPER_INGOT, CustomItemStack.create(SlimefunItems.COPPER_WIRE, 3)); addRecipe(16, new SlimefunItemStack(SlimefunItems.STEEL_INGOT, 8), SlimefunItems.STEEL_PLATE); addRecipe(18, new SlimefunItemStack(SlimefunItems.REINFORCED_ALLOY_INGOT, 8), SlimefunItems.REINFORCED_PLATE); - addRecipe(8, new ItemStack(Material.NETHER_WART), new CustomItemStack(SlimefunItems.MAGIC_LUMP_1, 2)); + addRecipe(8, new ItemStack(Material.NETHER_WART), CustomItemStack.create(SlimefunItems.MAGIC_LUMP_1, 2)); addRecipe(10, new SlimefunItemStack(SlimefunItems.MAGIC_LUMP_1, 4), SlimefunItems.MAGIC_LUMP_2); addRecipe(12, new SlimefunItemStack(SlimefunItems.MAGIC_LUMP_2, 4), SlimefunItems.MAGIC_LUMP_3); - addRecipe(10, new ItemStack(Material.ENDER_EYE), new CustomItemStack(SlimefunItems.ENDER_LUMP_1, 2)); + addRecipe(10, new ItemStack(Material.ENDER_EYE), CustomItemStack.create(SlimefunItems.ENDER_LUMP_1, 2)); addRecipe(12, new SlimefunItemStack(SlimefunItems.ENDER_LUMP_1, 4), SlimefunItems.ENDER_LUMP_2); addRecipe(14, new SlimefunItemStack(SlimefunItems.ENDER_LUMP_2, 4), SlimefunItems.ENDER_LUMP_3); 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 2218339998..0f61a4e8c6 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 @@ -31,7 +31,7 @@ /** * The {@link ElectricSmeltery} is an electric version of the standard {@link Smeltery}. - * + * * @author TheBusyBiscuit * */ @@ -120,7 +120,7 @@ protected void constructMenu(BlockMenuPreset preset) { preset.addItem(i, ChestMenuUtils.getOutputSlotTexture(), ChestMenuUtils.getEmptyClickHandler()); } - preset.addItem(22, new CustomItemStack(Material.BLACK_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(22, CustomItemStack.create(Material.BLACK_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); for (int i : getOutputSlots()) { preset.addMenuClickHandler(i, ChestMenuUtils.getDefaultOutputHandler()); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/HeatedPressureChamber.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/HeatedPressureChamber.java index 97505f6dd8..c8510b937a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/HeatedPressureChamber.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/HeatedPressureChamber.java @@ -85,13 +85,13 @@ private Comparator compareSlots(DirtyChestMenu menu) { @Override protected void registerDefaultRecipes() { - registerRecipe(45, new ItemStack[] { SlimefunItems.OIL_BUCKET }, new ItemStack[] { new CustomItemStack(SlimefunItems.PLASTIC_SHEET, 8) }); + registerRecipe(45, new ItemStack[] { SlimefunItems.OIL_BUCKET }, new ItemStack[] { CustomItemStack.create(SlimefunItems.PLASTIC_SHEET, 8) }); registerRecipe(30, new ItemStack[] { SlimefunItems.GOLD_24K, SlimefunItems.URANIUM }, new ItemStack[] { SlimefunItems.BLISTERING_INGOT }); registerRecipe(30, new ItemStack[] { SlimefunItems.BLISTERING_INGOT, SlimefunItems.CARBONADO }, new ItemStack[] { SlimefunItems.BLISTERING_INGOT_2 }); registerRecipe(60, new ItemStack[] { SlimefunItems.BLISTERING_INGOT_2, new ItemStack(Material.NETHER_STAR) }, new ItemStack[] { SlimefunItems.BLISTERING_INGOT_3 }); registerRecipe(90, new ItemStack[] { SlimefunItems.PLUTONIUM, SlimefunItems.URANIUM }, new ItemStack[] { SlimefunItems.BOOSTED_URANIUM }); - registerRecipe(60, new ItemStack[] { SlimefunItems.NETHER_ICE, SlimefunItems.PLUTONIUM }, new ItemStack[] { new CustomItemStack(SlimefunItems.ENRICHED_NETHER_ICE, 4) }); - registerRecipe(45, new ItemStack[] { SlimefunItems.ENRICHED_NETHER_ICE }, new ItemStack[] { new CustomItemStack(SlimefunItems.NETHER_ICE_COOLANT_CELL, 8) }); + registerRecipe(60, new ItemStack[] { SlimefunItems.NETHER_ICE, SlimefunItems.PLUTONIUM }, new ItemStack[] { CustomItemStack.create(SlimefunItems.ENRICHED_NETHER_ICE, 4) }); + registerRecipe(45, new ItemStack[] { SlimefunItems.ENRICHED_NETHER_ICE }, new ItemStack[] { CustomItemStack.create(SlimefunItems.NETHER_ICE_COOLANT_CELL, 8) }); registerRecipe(8, new ItemStack[] { SlimefunItems.MAGNESIUM_DUST, SlimefunItems.SALT }, new ItemStack[] { SlimefunItems.MAGNESIUM_SALT }); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/accelerators/AbstractGrowthAccelerator.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/accelerators/AbstractGrowthAccelerator.java index 7136101287..8997df479e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/accelerators/AbstractGrowthAccelerator.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/accelerators/AbstractGrowthAccelerator.java @@ -54,7 +54,7 @@ public void onBlockBreak(Block b) { private void constructMenu(BlockMenuPreset preset) { for (int i : BORDER) { - preset.addItem(i, new CustomItemStack(Material.CYAN_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(i, CustomItemStack.create(Material.CYAN_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/enchanting/AbstractEnchantmentMachine.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/enchanting/AbstractEnchantmentMachine.java index 5497ddd588..9f4e03f481 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/enchanting/AbstractEnchantmentMachine.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/enchanting/AbstractEnchantmentMachine.java @@ -67,7 +67,7 @@ protected void showEnchantmentLevelWarning(@Nonnull BlockMenu menu) { String notice = ChatColors.color(Slimefun.getLocalization().getMessage("messages.above-limit-level")); notice = notice.replace("%level%", String.valueOf(levelLimit.getValue())); - ItemStack progressBar = new CustomItemStack(Material.BARRIER, " ", notice); + ItemStack progressBar = CustomItemStack.create(Material.BARRIER, " ", notice); menu.replaceExistingItem(22, progressBar); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/AbstractEntityAssembler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/AbstractEntityAssembler.java index 338c262da5..4c6be5dc3f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/AbstractEntityAssembler.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/AbstractEntityAssembler.java @@ -43,9 +43,9 @@ /** * This is an abstract super class for Entity Assemblers. - * + * * @author TheBusyBiscuit - * + * * @see WitherAssembler * @see IronGolemAssembler * @@ -75,8 +75,8 @@ protected AbstractEntityAssembler(ItemGroup itemGroup, SlimefunItemStack item, R @Override public void init() { drawBackground(border); - drawBackground(new CustomItemStack(getHeadBorder(), " "), headBorder); - drawBackground(new CustomItemStack(getBodyBorder(), " "), bodyBorder); + drawBackground(CustomItemStack.create(getHeadBorder(), " "), headBorder); + drawBackground(CustomItemStack.create(getBodyBorder(), " "), bodyBorder); constructMenu(this); } @@ -159,14 +159,14 @@ public void onPlayerBreak(BlockBreakEvent e, ItemStack item, List dro private void updateBlockInventory(BlockMenu menu, Block b) { if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), KEY_ENABLED) == null || BlockStorage.getLocationInfo(b.getLocation(), KEY_ENABLED).equals(String.valueOf(false))) { - menu.replaceExistingItem(22, new CustomItemStack(Material.GUNPOWDER, "&7Enabled: &4\u2718", "", "&e> Click to enable this Machine")); + menu.replaceExistingItem(22, CustomItemStack.create(Material.GUNPOWDER, "&7Enabled: &4\u2718", "", "&e> Click to enable this Machine")); menu.addMenuClickHandler(22, (p, slot, item, action) -> { BlockStorage.addBlockInfo(b, KEY_ENABLED, String.valueOf(true)); updateBlockInventory(menu, b); return false; }); } else { - menu.replaceExistingItem(22, new CustomItemStack(Material.REDSTONE, "&7Enabled: &2\u2714", "", "&e> Click to disable this Machine")); + menu.replaceExistingItem(22, CustomItemStack.create(Material.REDSTONE, "&7Enabled: &2\u2714", "", "&e> Click to disable this Machine")); menu.addMenuClickHandler(22, (p, slot, item, action) -> { BlockStorage.addBlockInfo(b, KEY_ENABLED, String.valueOf(false)); updateBlockInventory(menu, b); @@ -176,7 +176,7 @@ private void updateBlockInventory(BlockMenu menu, Block b) { double offset = (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), KEY_OFFSET) == null) ? 3.0F : Double.valueOf(BlockStorage.getLocationInfo(b.getLocation(), KEY_OFFSET)); - menu.replaceExistingItem(31, new CustomItemStack(Material.PISTON, "&7Offset: &3" + offset + " Block(s)", "", "&fLeft Click: &7+0.1", "&fRight Click: &7-0.1")); + menu.replaceExistingItem(31, CustomItemStack.create(Material.PISTON, "&7Offset: &3" + offset + " Block(s)", "", "&fLeft Click: &7+0.1", "&fRight Click: &7-0.1")); menu.addMenuClickHandler(31, (p, slot, item, action) -> { double offsetv = NumberUtils.reparseDouble(Double.valueOf(BlockStorage.getLocationInfo(b.getLocation(), KEY_OFFSET)) + (action.isRightClicked() ? -0.1F : 0.1F)); BlockStorage.addBlockInfo(b, KEY_OFFSET, String.valueOf(offsetv)); @@ -279,9 +279,9 @@ private void consumeResources(BlockMenu inv) { } protected void constructMenu(BlockMenuPreset preset) { - preset.addItem(1, new CustomItemStack(getHead(), "&7Head Slot", "", "&fThis Slot accepts the head type"), ChestMenuUtils.getEmptyClickHandler()); - preset.addItem(7, new CustomItemStack(getBody(), "&7Body Slot", "", "&fThis Slot accepts the body type"), ChestMenuUtils.getEmptyClickHandler()); - preset.addItem(13, new CustomItemStack(Material.CLOCK, "&7Cooldown: &b30 Seconds", "", "&fThis Machine takes up to half a Minute to operate", "&fso give it some Time!"), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(1, CustomItemStack.create(getHead(), "&7Head Slot", "", "&fThis Slot accepts the head type"), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(7, CustomItemStack.create(getBody(), "&7Body Slot", "", "&fThis Slot accepts the body type"), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(13, CustomItemStack.create(Material.CLOCK, "&7Cooldown: &b30 Seconds", "", "&fThis Machine takes up to half a Minute to operate", "&fso give it some Time!"), ChestMenuUtils.getEmptyClickHandler()); } @Override diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/AutoBreeder.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/AutoBreeder.java index e62fd7951d..e003483874 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/AutoBreeder.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/AutoBreeder.java @@ -65,7 +65,7 @@ public void onBlockBreak(Block b) { protected void constructMenu(BlockMenuPreset preset) { for (int i : border) { - preset.addItem(i, new CustomItemStack(new ItemStack(Material.CYAN_STAINED_GLASS_PANE), " "), (p, slot, item, action) -> false); + preset.addItem(i, CustomItemStack.create(new ItemStack(Material.CYAN_STAINED_GLASS_PANE), " "), (p, slot, item, action) -> false); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/ExpCollector.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/ExpCollector.java index 3a6cb6d857..45d9969e88 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/ExpCollector.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/ExpCollector.java @@ -36,7 +36,7 @@ /** * The {@link ExpCollector} is a machine which picks up any nearby {@link ExperienceOrb} * and produces a {@link KnowledgeFlask}. - * + * * @author TheBusyBiscuit * */ @@ -104,7 +104,7 @@ public int getCapacity() { protected void constructMenu(BlockMenuPreset preset) { for (int slot : border) { - preset.addItem(slot, new CustomItemStack(Material.PURPLE_STAINED_GLASS_PANE, " "), (p, s, item, action) -> false); + preset.addItem(slot, CustomItemStack.create(Material.PURPLE_STAINED_GLASS_PANE, " "), (p, s, item, action) -> false); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/IronGolemAssembler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/IronGolemAssembler.java index c38602e441..727dc342d1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/IronGolemAssembler.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/IronGolemAssembler.java @@ -20,9 +20,9 @@ /** * The {@link IronGolemAssembler} is an electrical machine that can automatically spawn * a {@link IronGolem} if the required ingredients have been provided. - * + * * @author TheBusyBiscuit - * + * * @see WitherAssembler * */ @@ -65,9 +65,9 @@ public Material getBodyBorder() { @Override protected void constructMenu(BlockMenuPreset preset) { - preset.addItem(1, new CustomItemStack(getHead(), "&7Pumpkin Slot", "", "&fThis Slot accepts Pumpkins"), ChestMenuUtils.getEmptyClickHandler()); - preset.addItem(7, new CustomItemStack(getBody(), "&7Iron Block Slot", "", "&fThis Slot accepts Iron Blocks"), ChestMenuUtils.getEmptyClickHandler()); - preset.addItem(13, new CustomItemStack(Material.CLOCK, "&7Cooldown: &b30 Seconds", "", "&fThis Machine takes up to half a Minute to operate", "&fso give it some Time!"), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(1, CustomItemStack.create(getHead(), "&7Pumpkin Slot", "", "&fThis Slot accepts Pumpkins"), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(7, CustomItemStack.create(getBody(), "&7Iron Block Slot", "", "&fThis Slot accepts Iron Blocks"), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(13, CustomItemStack.create(Material.CLOCK, "&7Cooldown: &b30 Seconds", "", "&fThis Machine takes up to half a Minute to operate", "&fso give it some Time!"), ChestMenuUtils.getEmptyClickHandler()); } @Override diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/ProduceCollector.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/ProduceCollector.java index 24ecf5d86d..e1d5e1f4e3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/ProduceCollector.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/ProduceCollector.java @@ -43,7 +43,7 @@ /** * The {@link ProduceCollector} allows you to collect produce from animals. * Providing it with a bucket and a nearby {@link Cow} will allow you to obtain milk. - * + * * @author TheBusyBiscuit * @author Walshy * @@ -85,7 +85,7 @@ protected void registerDefaultRecipes() { /** * This method adds a new {@link AnimalProduce} to this machine. - * + * * @param produce * The {@link AnimalProduce} to add */ @@ -116,15 +116,15 @@ public boolean isSynchronized() { public @Nonnull List getDisplayRecipes() { List displayRecipes = new ArrayList<>(); - displayRecipes.add(new CustomItemStack(Material.BUCKET, null, "&fRequires &bCow &fnearby")); + displayRecipes.add(CustomItemStack.create(Material.BUCKET, null, "&fRequires &bCow &fnearby")); displayRecipes.add(new ItemStack(Material.MILK_BUCKET)); if (Slimefun.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_17)) { - displayRecipes.add(new CustomItemStack(Material.BUCKET, null, "&fRequires &bGoat &fnearby")); + displayRecipes.add(CustomItemStack.create(Material.BUCKET, null, "&fRequires &bGoat &fnearby")); displayRecipes.add(new ItemStack(Material.MILK_BUCKET)); } - displayRecipes.add(new CustomItemStack(Material.BOWL, null, "&fRequires &bMooshroom &fnearby")); + displayRecipes.add(CustomItemStack.create(Material.BOWL, null, "&fRequires &bMooshroom &fnearby")); displayRecipes.add(new ItemStack(Material.MUSHROOM_STEW)); return displayRecipes; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/WitherAssembler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/WitherAssembler.java index cc2c336672..9ebb73f8b2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/WitherAssembler.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/WitherAssembler.java @@ -18,9 +18,9 @@ /** * The {@link WitherAssembler} is an electrical machine that can automatically spawn * a {@link Wither} if the required ingredients have been provided. - * + * * @author TheBusyBiscuit - * + * * @see IronGolemAssembler * */ @@ -63,9 +63,9 @@ public Material getBodyBorder() { @Override protected void constructMenu(BlockMenuPreset preset) { - preset.addItem(1, new CustomItemStack(getHead(), "&7Wither Skeleton Skull Slot", "", "&fThis Slot accepts Wither Skeleton Skulls"), ChestMenuUtils.getEmptyClickHandler()); - preset.addItem(7, new CustomItemStack(getBody(), "&7Soul Sand Slot", "", "&fThis Slot accepts Soul Sand"), ChestMenuUtils.getEmptyClickHandler()); - preset.addItem(13, new CustomItemStack(Material.CLOCK, "&7Cooldown: &b30 Seconds", "", "&fThis Machine takes up to half a Minute to operate", "&fso give it some Time!"), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(1, CustomItemStack.create(getHead(), "&7Wither Skeleton Skull Slot", "", "&fThis Slot accepts Wither Skeleton Skulls"), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(7, CustomItemStack.create(getBody(), "&7Soul Sand Slot", "", "&fThis Slot accepts Soul Sand"), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(13, CustomItemStack.create(Material.CLOCK, "&7Cooldown: &b30 Seconds", "", "&fThis Machine takes up to half a Minute to operate", "&fso give it some Time!"), ChestMenuUtils.getEmptyClickHandler()); } @Override diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/Reactor.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/Reactor.java index 47b524616f..e8a25b568d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/Reactor.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/Reactor.java @@ -50,11 +50,11 @@ /** * The abstract {@link Reactor} class is very similar to {@link AGenerator} but is * exclusively used for Reactors. - * + * * @author John000708 * @author AlexLander123 * @author TheBusyBiscuit - * + * * @see AGenerator * @see NuclearReactor * @see NetherStarReactor @@ -145,7 +145,7 @@ protected void updateInventory(@Nonnull BlockMenu menu, @Nonnull Block b) { switch (mode) { case GENERATOR: - menu.replaceExistingItem(4, new CustomItemStack(SlimefunItems.NUCLEAR_REACTOR, "&7Focus: &eElectricity", "", "&6Your Reactor will focus on Power Generation", "&6If your Energy Network doesn't need Power", "&6it will not produce any either", "", "&7\u21E8 Click to change the Focus to &eProduction")); + menu.replaceExistingItem(4, CustomItemStack.create(SlimefunItems.NUCLEAR_REACTOR, "&7Focus: &eElectricity", "", "&6Your Reactor will focus on Power Generation", "&6If your Energy Network doesn't need Power", "&6it will not produce any either", "", "&7\u21E8 Click to change the Focus to &eProduction")); menu.addMenuClickHandler(4, (p, slot, item, action) -> { BlockStorage.addBlockInfo(b, MODE, ReactorMode.PRODUCTION.toString()); updateInventory(menu, b); @@ -153,7 +153,7 @@ protected void updateInventory(@Nonnull BlockMenu menu, @Nonnull Block b) { }); break; case PRODUCTION: - menu.replaceExistingItem(4, new CustomItemStack(SlimefunItems.PLUTONIUM, "&7Focus: &eProduction", "", "&6Your Reactor will focus on producing goods", "&6If your Energy Network doesn't need Power", "&6it will continue to run and simply will", "&6not generate any Power in the mean time", "", "&7\u21E8 Click to change the Focus to &ePower Generation")); + menu.replaceExistingItem(4, CustomItemStack.create(SlimefunItems.PLUTONIUM, "&7Focus: &eProduction", "", "&6Your Reactor will focus on producing goods", "&6If your Energy Network doesn't need Power", "&6it will continue to run and simply will", "&6not generate any Power in the mean time", "", "&7\u21E8 Click to change the Focus to &ePower Generation")); menu.addMenuClickHandler(4, (p, slot, item, action) -> { BlockStorage.addBlockInfo(b, MODE, ReactorMode.GENERATOR.toString()); updateInventory(menu, b); @@ -167,7 +167,7 @@ protected void updateInventory(@Nonnull BlockMenu menu, @Nonnull Block b) { BlockMenu port = getAccessPort(b.getLocation()); if (port != null) { - menu.replaceExistingItem(INFO_SLOT, new CustomItemStack(Material.GREEN_WOOL, "&7Access Port", "", "&6Detected", "", "&7> Click to view Access Port")); + menu.replaceExistingItem(INFO_SLOT, CustomItemStack.create(Material.GREEN_WOOL, "&7Access Port", "", "&6Detected", "", "&7> Click to view Access Port")); menu.addMenuClickHandler(INFO_SLOT, (p, slot, item, action) -> { port.open(p); updateInventory(menu, b); @@ -175,7 +175,7 @@ protected void updateInventory(@Nonnull BlockMenu menu, @Nonnull Block b) { return false; }); } else { - menu.replaceExistingItem(INFO_SLOT, new CustomItemStack(Material.RED_WOOL, "&7Access Port", "", "&cNot detected", "", "&7Access Port must be", "&7placed 3 blocks above", "&7a reactor!")); + menu.replaceExistingItem(INFO_SLOT, CustomItemStack.create(Material.RED_WOOL, "&7Access Port", "", "&cNot detected", "", "&7Access Port must be", "&7placed 3 blocks above", "&7a reactor!")); menu.addMenuClickHandler(INFO_SLOT, (p, slot, item, action) -> { updateInventory(menu, b); menu.open(p); @@ -190,28 +190,28 @@ private void constructMenu(@Nonnull BlockMenuPreset preset) { } for (int i : border_1) { - preset.addItem(i, new CustomItemStack(Material.LIME_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(i, CustomItemStack.create(Material.LIME_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); } for (int i : border_3) { - preset.addItem(i, new CustomItemStack(Material.GREEN_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(i, CustomItemStack.create(Material.GREEN_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); } - preset.addItem(22, new CustomItemStack(Material.BLACK_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(22, CustomItemStack.create(Material.BLACK_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); - preset.addItem(1, new CustomItemStack(getFuelIcon(), "&7Fuel Slot", "", "&fThis Slot accepts radioactive Fuel such as:", "&2Uranium &for &aNeptunium"), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(1, CustomItemStack.create(getFuelIcon(), "&7Fuel Slot", "", "&fThis Slot accepts radioactive Fuel such as:", "&2Uranium &for &aNeptunium"), ChestMenuUtils.getEmptyClickHandler()); for (int i : border_2) { - preset.addItem(i, new CustomItemStack(Material.CYAN_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(i, CustomItemStack.create(Material.CYAN_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); } if (needsCooling()) { - preset.addItem(7, new CustomItemStack(getCoolant(), "&bCoolant Slot", "", "&fThis Slot accepts Coolant Cells", "&4Without any Coolant Cells, your Reactor", "&4will explode")); + preset.addItem(7, CustomItemStack.create(getCoolant(), "&bCoolant Slot", "", "&fThis Slot accepts Coolant Cells", "&4Without any Coolant Cells, your Reactor", "&4will explode")); } else { - preset.addItem(7, new CustomItemStack(Material.BARRIER, "&bCoolant Slot", "", "&fThis Slot accepts Coolant Cells")); + preset.addItem(7, CustomItemStack.create(Material.BARRIER, "&bCoolant Slot", "", "&fThis Slot accepts Coolant Cells")); for (int i : border_4) { - preset.addItem(i, new CustomItemStack(Material.BARRIER, "&cNo Coolant Required"), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(i, CustomItemStack.create(Material.BARRIER, "&cNo Coolant Required"), ChestMenuUtils.getEmptyClickHandler()); } } } @@ -232,7 +232,7 @@ protected ReactorMode getReactorMode(@Nonnull Location l) { /** * This method returns the {@link ItemStack} that is required to cool this {@link Reactor}. * If it returns null, then no cooling is required. - * + * * @return The {@link ItemStack} required to cool this {@link Reactor} */ @Nullable @@ -242,7 +242,7 @@ protected ReactorMode getReactorMode(@Nonnull Location l) { * This method returns the displayed icon above the fuel input slot. * It should reflect the {@link ItemStack} used to power the reactor. * This method does not determine the fuel input, only the icon. - * + * * @return The {@link ItemStack} used as the fuel icon for this {@link Reactor}. */ @Nonnull @@ -252,7 +252,7 @@ protected ReactorMode getReactorMode(@Nonnull Location l) { * This method returns whether this {@link Reactor} requires as some form of * coolant. * It is a not-null check performed on {@link #getCoolant()} - * + * * @return Whether this {@link Reactor} requires cooling */ protected final boolean needsCooling() { @@ -364,7 +364,7 @@ private void checkForWaterBlocks(Location l) { } private void createByproduct(@Nonnull Location l, @Nonnull BlockMenu inv, @Nullable BlockMenu accessPort, @Nonnull FuelOperation operation) { - inv.replaceExistingItem(22, new CustomItemStack(Material.BLACK_STAINED_GLASS_PANE, " ")); + inv.replaceExistingItem(22, CustomItemStack.create(Material.BLACK_STAINED_GLASS_PANE, " ")); ItemStack result = operation.getResult(); if (result != null) { @@ -401,7 +401,7 @@ private void burnNextFuel(Location l, BlockMenu inv, BlockMenu accessPort) { /** * This method cools the given {@link Reactor}. - * + * * @param reactor * The {@link Location} of this {@link Reactor} * @param menu @@ -410,7 +410,7 @@ private void burnNextFuel(Location l, BlockMenu inv, BlockMenu accessPort) { * The {@link ReactorAccessPort}, if available * @param operation * The {@link FuelOperation} of this {@link Reactor} - * + * * @return Whether the {@link Reactor} was successfully cooled, if not it should explode */ private boolean hasEnoughCoolant(@Nonnull Location reactor, @Nonnull BlockMenu menu, @Nullable BlockMenu accessPort, @Nonnull FuelOperation operation) { @@ -453,7 +453,7 @@ private float getPercentage(int time, int total) { private void restockFuel(BlockMenu menu, BlockMenu port) { for (int slot : getFuelSlots()) { for (MachineFuel fuelType : fuelTypes) { - if (fuelType.test(port.getItemInSlot(slot)) && menu.fits(new CustomItemStack(port.getItemInSlot(slot), 1), getFuelSlots())) { + if (fuelType.test(port.getItemInSlot(slot)) && menu.fits(CustomItemStack.create(port.getItemInSlot(slot), 1), getFuelSlots())) { port.replaceExistingItem(slot, menu.pushItem(port.getItemInSlot(slot), getFuelSlots())); return; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/elevator/ElevatorPlate.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/elevator/ElevatorPlate.java index e73e3633e0..44fde1a2b8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/elevator/ElevatorPlate.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/elevator/ElevatorPlate.java @@ -141,17 +141,13 @@ private void openFloorSelector(Block b, List floors, Player p, in // @formatter:off if (floor.getAltitude() == b.getY()) { - menu.addItem(i, new CustomItemStack( - Material.COMPASS, + menu.addItem(i, CustomItemStack.create(Material.COMPASS, ChatColor.GRAY.toString() + floor.getNumber() + ". " + ChatColor.BLACK + floor.getName(), - Slimefun.getLocalization().getMessage(p, "machines.ELEVATOR.current-floor") + ' ' + ChatColor.WHITE + floor.getName() - ), ChestMenuUtils.getEmptyClickHandler()); + Slimefun.getLocalization().getMessage(p, "machines.ELEVATOR.current-floor") + ' ' + ChatColor.WHITE + floor.getName()), ChestMenuUtils.getEmptyClickHandler()); } else { - menu.addItem(i, new CustomItemStack( - Material.PAPER, + menu.addItem(i, CustomItemStack.create(Material.PAPER, ChatColor.GRAY.toString() + floor.getNumber() + ". " + ChatColor.BLACK + floor.getName(), - Slimefun.getLocalization().getMessage(p, "machines.ELEVATOR.click-to-teleport") + ' ' + ChatColor.WHITE + floor.getName() - ), (player, slot, itemStack, clickAction) -> { + Slimefun.getLocalization().getMessage(p, "machines.ELEVATOR.click-to-teleport") + ' ' + ChatColor.WHITE + floor.getName()), (player, slot, itemStack, clickAction) -> { teleport(player, floor); return false; }); @@ -207,7 +203,7 @@ private void teleport(Player player, ElevatorFloor floor) { public void openEditor(Player p, Block b) { ChestMenu menu = new ChestMenu(Slimefun.getLocalization().getMessage(p, "machines.ELEVATOR.editor-title")); - menu.addItem(4, new CustomItemStack(Material.NAME_TAG, "&7Floor Name &e(Click to edit)", "", ChatColor.WHITE + ChatColors.color(BlockStorage.getLocationInfo(b.getLocation(), DATA_KEY)))); + menu.addItem(4, CustomItemStack.create(Material.NAME_TAG, "&7Floor Name &e(Click to edit)", "", ChatColor.WHITE + ChatColors.color(BlockStorage.getLocationInfo(b.getLocation(), DATA_KEY)))); menu.addMenuClickHandler(4, (pl, slot, item, action) -> { pl.closeInventory(); pl.sendMessage(""); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOMiner.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOMiner.java index d21815533b..f7975920ae 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOMiner.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOMiner.java @@ -44,7 +44,7 @@ /** * The {@link GEOMiner} is an electrical machine that allows you to obtain a {@link GEOResource}. - * + * * @author TheBusyBiscuit * * @see GEOResource @@ -79,7 +79,7 @@ public GEOMiner(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeTy /** * This method returns the max amount of electricity this machine can hold. - * + * * @return The max amount of electricity this Block can store. */ @Override @@ -89,7 +89,7 @@ public int getCapacity() { /** * This method returns the amount of energy that is consumed per operation. - * + * * @return The rate of energy consumption */ public int getEnergyConsumption() { @@ -100,7 +100,7 @@ public int getEnergyConsumption() { * This method returns the speed at which this machine will operate. * This can be implemented on an instantiation-level to create different tiers * of machines. - * + * * @return The speed of this machine */ public int getSpeed() { @@ -111,10 +111,10 @@ public int getSpeed() { * This sets the energy capacity for this machine. * This method must be called before registering the item * and only before registering. - * + * * @param capacity * The amount of energy this machine can store - * + * * @return This method will return the current instance of {@link GEOMiner}, so that can be chained. */ public final GEOMiner setCapacity(int capacity) { @@ -130,10 +130,10 @@ public final GEOMiner setCapacity(int capacity) { /** * This sets the speed of this machine. - * + * * @param speed * The speed multiplier for this machine, must be above zero - * + * * @return This method will return the current instance of {@link GEOMiner}, so that can be chained. */ public final GEOMiner setProcessingSpeed(int speed) { @@ -145,10 +145,10 @@ public final GEOMiner setProcessingSpeed(int speed) { /** * This method sets the energy consumed by this machine per tick. - * + * * @param energyConsumption * The energy consumed per tick - * + * * @return This method will return the current instance of {@link GEOMiner}, so that can be chained. */ public final GEOMiner setEnergyConsumption(int energyConsumption) { @@ -232,7 +232,7 @@ public List getDisplayRecipes() { for (GEOResource resource : Slimefun.getRegistry().getGEOResources().values()) { if (resource.isObtainableFromGEOMiner()) { - displayRecipes.add(new CustomItemStack(resource.getItem(), ChatColor.RESET + resource.getName())); + displayRecipes.add(CustomItemStack.create(resource.getItem(), ChatColor.RESET + resource.getName())); } } @@ -258,7 +258,7 @@ protected void constructMenu(@Nonnull BlockMenuPreset preset) { preset.addItem(i, ChestMenuUtils.getOutputSlotTexture(), ChestMenuUtils.getEmptyClickHandler()); } - preset.addItem(4, new CustomItemStack(Material.BLACK_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(4, CustomItemStack.create(Material.BLACK_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); for (int i : OUTPUT_SLOTS) { preset.addMenuClickHandler(i, ChestMenuUtils.getDefaultOutputHandler()); @@ -296,7 +296,7 @@ protected void tick(@Nonnull Block b) { removeCharge(b.getLocation(), getEnergyConsumption()); operation.addProgress(getSpeed()); } else { - inv.replaceExistingItem(4, new CustomItemStack(Material.BLACK_STAINED_GLASS_PANE, " ")); + inv.replaceExistingItem(4, CustomItemStack.create(Material.BLACK_STAINED_GLASS_PANE, " ")); inv.pushItem(operation.getResult(), OUTPUT_SLOTS); processor.endOperation(b); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/EnderTalisman.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/EnderTalisman.java index 0119c94882..f912d9f355 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/EnderTalisman.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/EnderTalisman.java @@ -15,13 +15,13 @@ /** * An {@link EnderTalisman} is a special version of {@link Talisman} * that works while it is in your {@link EnderChest}. - * + * * @author TheBusyBiscuit * */ class EnderTalisman extends Talisman { - private static final LockedItemGroup ENDER_TALISMANS_ITEMGROUP = new LockedItemGroup(new NamespacedKey(Slimefun.instance(), "ender_talismans"), new CustomItemStack(SlimefunItems.ENDER_TALISMAN, "&7Talismans - &aTier II"), 3, Talisman.TALISMANS_ITEMGROUP.getKey()); + private static final LockedItemGroup ENDER_TALISMANS_ITEMGROUP = new LockedItemGroup(new NamespacedKey(Slimefun.instance(), "ender_talismans"), CustomItemStack.create(SlimefunItems.ENDER_TALISMAN, "&7Talismans - &aTier II"), 3, Talisman.TALISMANS_ITEMGROUP.getKey()); @ParametersAreNonnullByDefault public EnderTalisman(Talisman parent, SlimefunItemStack item) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/Talisman.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/Talisman.java index 9f97f19892..cf8c76744e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/Talisman.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/Talisman.java @@ -40,7 +40,7 @@ public class Talisman extends SlimefunItem { - protected static final ItemGroup TALISMANS_ITEMGROUP = new ItemGroup(new NamespacedKey(Slimefun.instance(), "talismans"), new CustomItemStack(SlimefunItems.COMMON_TALISMAN, "&7Talismans - &aTier I"), 2); + protected static final ItemGroup TALISMANS_ITEMGROUP = new ItemGroup(new NamespacedKey(Slimefun.instance(), "talismans"), CustomItemStack.create(SlimefunItems.COMMON_TALISMAN, "&7Talismans - &aTier I"), 2); private static final String WIKI_PAGE = "Talismans"; private final SlimefunItemStack enderTalisman; @@ -68,7 +68,7 @@ public Talisman(SlimefunItemStack item, ItemStack[] recipe, boolean consumable, @ParametersAreNonnullByDefault protected Talisman(ItemGroup itemGroup, SlimefunItemStack item, ItemStack[] recipe, boolean consumable, boolean cancelEvent, @Nullable String messageSuffix, int chance, PotionEffect... effects) { - super(itemGroup, item, RecipeType.MAGIC_WORKBENCH, recipe, new CustomItemStack(item, consumable ? 4 : 1)); + super(itemGroup, item, RecipeType.MAGIC_WORKBENCH, recipe, CustomItemStack.create(item, consumable ? 4 : 1)); this.consumable = consumable; this.cancel = cancelEvent; @@ -95,7 +95,7 @@ protected Talisman(ItemGroup itemGroup, SlimefunItemStack item, ItemStack[] reci /** * This returns whether the {@link Talisman} will be consumed upon use. - * + * * @return Whether this {@link Talisman} is consumed on use. */ public boolean isConsumable() { @@ -105,7 +105,7 @@ public boolean isConsumable() { /** * This returns the chance of this {@link Talisman} activating. * The chance will be between 1 and 100. - * + * * @return The chance of this {@link Talisman} activating. */ public int getChance() { @@ -259,7 +259,7 @@ private static void cancelEvent(Event e, Talisman talisman) { * This returns whether the {@link Talisman} is silent. * A silent {@link Talisman} will not send a message to a {@link Player} * when activated. - * + * * @return Whether this {@link Talisman} is silent */ public boolean isSilent() { @@ -275,7 +275,7 @@ protected final String getMessageSuffix() { * This method sends the given {@link Player} the message of this {@link Talisman}. * Dependent on the selected config setting, the message will be sent via the actionbar * or in the chat window. - * + * * @param p * The {@link Player} who shall receive the message */ diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/ArmorForge.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/ArmorForge.java index 4ee70ac722..4a86c04ce3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/ArmorForge.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/ArmorForge.java @@ -29,7 +29,7 @@ public class ArmorForge extends AbstractCraftingTable { @ParametersAreNonnullByDefault public ArmorForge(ItemGroup itemGroup, SlimefunItemStack item) { - super(itemGroup, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.ANVIL), null, null, new CustomItemStack(Material.DISPENSER, "Dispenser (Facing up)"), null }, BlockFace.SELF); + super(itemGroup, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.ANVIL), null, null, CustomItemStack.create(Material.DISPENSER, "Dispenser (Facing up)"), null }, BlockFace.SELF); } @Override diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Compressor.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Compressor.java index f0b48882e6..15060416fb 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Compressor.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Compressor.java @@ -32,7 +32,7 @@ public class Compressor extends MultiBlockMachine { @ParametersAreNonnullByDefault public Compressor(ItemGroup itemGroup, SlimefunItemStack item) { - super(itemGroup, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.NETHER_BRICK_FENCE), null, new ItemStack(Material.PISTON), new CustomItemStack(Material.DISPENSER, "Dispenser (Facing up)"), new ItemStack(Material.PISTON) }, BlockFace.SELF); + super(itemGroup, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.NETHER_BRICK_FENCE), null, new ItemStack(Material.PISTON), CustomItemStack.create(Material.DISPENSER, "Dispenser (Facing up)"), new ItemStack(Material.PISTON) }, BlockFace.SELF); } @Override diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/GrindStone.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/GrindStone.java index f149093042..0d11f81681 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/GrindStone.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/GrindStone.java @@ -33,7 +33,7 @@ public class GrindStone extends MultiBlockMachine { @ParametersAreNonnullByDefault public GrindStone(ItemGroup itemGroup, SlimefunItemStack item) { - super(itemGroup, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.OAK_FENCE), null, null, new CustomItemStack(Material.DISPENSER, "Dispenser (Facing up)"), null }, BlockFace.SELF); + super(itemGroup, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.OAK_FENCE), null, null, CustomItemStack.create(Material.DISPENSER, "Dispenser (Facing up)"), null }, BlockFace.SELF); } @Override diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Juicer.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Juicer.java index a81c731434..da99ce748f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Juicer.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Juicer.java @@ -32,10 +32,10 @@ /** * The {@link Juicer} is a {@link MultiBlockMachine} which can be used to * craft {@link Juice}. - * + * * @author TheBusyBiscuit * @author Liruxo - * + * * @see Juice * */ @@ -43,7 +43,7 @@ public class Juicer extends MultiBlockMachine { @ParametersAreNonnullByDefault public Juicer(ItemGroup itemGroup, SlimefunItemStack item) { - super(itemGroup, item, new ItemStack[] { null, new ItemStack(Material.GLASS), null, null, new ItemStack(Material.NETHER_BRICK_FENCE), null, null, new CustomItemStack(Material.DISPENSER, "Dispenser (Facing up)"), null }, BlockFace.SELF); + super(itemGroup, item, new ItemStack[] { null, new ItemStack(Material.GLASS), null, null, new ItemStack(Material.NETHER_BRICK_FENCE), null, null, CustomItemStack.create(Material.DISPENSER, "Dispenser (Facing up)"), null }, BlockFace.SELF); } @Override diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/MagicWorkbench.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/MagicWorkbench.java index 25ce8cdcc8..cd2e0a86ec 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/MagicWorkbench.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/MagicWorkbench.java @@ -86,7 +86,7 @@ private void craft(Inventory inv, Block dispenser, Player p, Block b, ItemStack for (int j = 0; j < 9; j++) { if (inv.getContents()[j] != null && inv.getContents()[j].getType() != Material.AIR) { if (inv.getContents()[j].getAmount() > 1) { - inv.setItem(j, new CustomItemStack(inv.getContents()[j], inv.getContents()[j].getAmount() - 1)); + inv.setItem(j, CustomItemStack.create(inv.getContents()[j], inv.getContents()[j].getAmount() - 1)); } else { inv.setItem(j, null); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/MakeshiftSmeltery.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/MakeshiftSmeltery.java index a46b27f2d8..7405a0694c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/MakeshiftSmeltery.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/MakeshiftSmeltery.java @@ -20,9 +20,9 @@ /** * The {@link MakeshiftSmeltery} is a simpler version of the {@link Smeltery}. * Its functionality is very limited and it cannot be used to smelt alloys. - * + * * @author TheBusyBiscuit - * + * * @see Smeltery * */ @@ -30,7 +30,7 @@ public class MakeshiftSmeltery extends AbstractSmeltery { @ParametersAreNonnullByDefault public MakeshiftSmeltery(ItemGroup itemGroup, SlimefunItemStack item) { - super(itemGroup, item, new ItemStack[] { null, new ItemStack(Material.OAK_FENCE), null, new ItemStack(Material.BRICKS), new CustomItemStack(Material.DISPENSER, "Dispenser (Facing up)"), new ItemStack(Material.BRICKS), null, new ItemStack(Material.FLINT_AND_STEEL), null }, BlockFace.DOWN); + super(itemGroup, item, new ItemStack[] { null, new ItemStack(Material.OAK_FENCE), null, new ItemStack(Material.BRICKS), CustomItemStack.create(Material.DISPENSER, "Dispenser (Facing up)"), new ItemStack(Material.BRICKS), null, new ItemStack(Material.FLINT_AND_STEEL), null }, BlockFace.DOWN); } @Override diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreCrusher.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreCrusher.java index ea5141f099..f3e17ef0ec 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreCrusher.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreCrusher.java @@ -35,7 +35,7 @@ /** * The {@link OreCrusher} is a {@link MultiBlockMachine} which allows you to double ores * and crush some other {@link Material Materials} into various resources. - * + * * @author TheBusyBiscuit * */ @@ -45,7 +45,7 @@ public class OreCrusher extends MultiBlockMachine { @ParametersAreNonnullByDefault public OreCrusher(ItemGroup itemGroup, SlimefunItemStack item) { - super(itemGroup, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.NETHER_BRICK_FENCE), null, new ItemStack(Material.IRON_BARS), new CustomItemStack(Material.DISPENSER, "Dispenser (Facing up)"), new ItemStack(Material.IRON_BARS) }, BlockFace.SELF); + super(itemGroup, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.NETHER_BRICK_FENCE), null, new ItemStack(Material.IRON_BARS), CustomItemStack.create(Material.DISPENSER, "Dispenser (Facing up)"), new ItemStack(Material.IRON_BARS) }, BlockFace.SELF); addItemSetting(doubleOres); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/PressureChamber.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/PressureChamber.java index c8b75de5a3..50f42828bb 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/PressureChamber.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/PressureChamber.java @@ -32,7 +32,7 @@ public class PressureChamber extends MultiBlockMachine { @ParametersAreNonnullByDefault public PressureChamber(ItemGroup itemGroup, SlimefunItemStack item) { - super(itemGroup, item, new ItemStack[] { new ItemStack(Material.SMOOTH_STONE_SLAB), new CustomItemStack(Material.DISPENSER, "Dispenser (Facing down)"), new ItemStack(Material.SMOOTH_STONE_SLAB), new ItemStack(Material.PISTON), new ItemStack(Material.GLASS), new ItemStack(Material.PISTON), new ItemStack(Material.PISTON), new ItemStack(Material.CAULDRON), new ItemStack(Material.PISTON) }, BlockFace.UP); + super(itemGroup, item, new ItemStack[] { new ItemStack(Material.SMOOTH_STONE_SLAB), CustomItemStack.create(Material.DISPENSER, "Dispenser (Facing down)"), new ItemStack(Material.SMOOTH_STONE_SLAB), new ItemStack(Material.PISTON), new ItemStack(Material.GLASS), new ItemStack(Material.PISTON), new ItemStack(Material.PISTON), new ItemStack(Material.CAULDRON), new ItemStack(Material.PISTON) }, BlockFace.UP); } @Override diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Smeltery.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Smeltery.java index a55abe12ff..9e79ef97d3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Smeltery.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Smeltery.java @@ -30,7 +30,7 @@ * The {@link Smeltery} is an upgraded version of the {@link MakeshiftSmeltery} * with the additional capabilities to create {@link AlloyIngot}s and utilise an * {@link IgnitionChamber}. - * + * * @author TheBusyBiscuit * @author AtomicScience * @author Sfiguz7 @@ -38,7 +38,7 @@ * @author emanueljg * @author SoSeDiK * @author Redemption198 - * + * * @see AbstractSmeltery * @see MakeshiftSmeltery * @see IgnitionChamber @@ -50,7 +50,7 @@ public class Smeltery extends AbstractSmeltery { @ParametersAreNonnullByDefault public Smeltery(ItemGroup itemGroup, SlimefunItemStack item) { - super(itemGroup, item, new ItemStack[] { null, new ItemStack(Material.NETHER_BRICK_FENCE), null, new ItemStack(Material.NETHER_BRICKS), new CustomItemStack(Material.DISPENSER, "Dispenser (Facing up)"), new ItemStack(Material.NETHER_BRICKS), null, new ItemStack(Material.FLINT_AND_STEEL), null }, BlockFace.DOWN); + super(itemGroup, item, new ItemStack[] { null, new ItemStack(Material.NETHER_BRICK_FENCE), null, new ItemStack(Material.NETHER_BRICKS), CustomItemStack.create(Material.DISPENSER, "Dispenser (Facing up)"), new ItemStack(Material.NETHER_BRICKS), null, new ItemStack(Material.FLINT_AND_STEEL), null }, BlockFace.DOWN); addItemSetting(fireBreakingChance); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/IndustrialMiner.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/IndustrialMiner.java index 3ad9381c6c..77c61ff7b4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/IndustrialMiner.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/IndustrialMiner.java @@ -37,12 +37,12 @@ /** * The {@link IndustrialMiner} is a {@link MultiBlockMachine} that can mine any * ores it finds in a given range underneath where it was placed. - * + * * And for those of you who are wondering... yes this is the replacement for the * long-time deprecated Digital Miner. - * + * * @author TheBusyBiscuit - * + * * @see AdvancedIndustrialMiner * @see MiningTask * @@ -63,7 +63,7 @@ public IndustrialMiner(ItemGroup itemGroup, SlimefunItemStack item, Material bas // @formatter:off super(itemGroup, item, new ItemStack[] { null, null, null, - new CustomItemStack(Material.PISTON, "Piston (facing up)"), new ItemStack(Material.CHEST), new CustomItemStack(Material.PISTON, "Piston (facing up)"), + CustomItemStack.create(Material.PISTON, "Piston (facing up)"), new ItemStack(Material.CHEST), CustomItemStack.create(Material.PISTON, "Piston (facing up)"), new ItemStack(baseMaterial), new ItemStack(Material.BLAST_FURNACE), new ItemStack(baseMaterial) }, BlockFace.UP); // @formatter:on @@ -80,7 +80,7 @@ public IndustrialMiner(ItemGroup itemGroup, SlimefunItemStack item, Material bas /** * This returns whether this {@link IndustrialMiner} will output ores as they are. * Similar to the Silk Touch {@link Enchantment}. - * + * * @return Whether to treat ores with Silk Touch */ public boolean hasSilkTouch() { @@ -91,10 +91,10 @@ public boolean hasSilkTouch() { * This method returns the range of the {@link IndustrialMiner}. * The total area will be determined by the range multiplied by 2 plus the actual center * of the machine. - * + * * So a range of 3 will make the {@link IndustrialMiner} affect an area of 7x7 blocks. * 3 on all axis, plus the center of the machine itself. - * + * * @return The range of this {@link IndustrialMiner} */ public int getRange() { @@ -122,10 +122,10 @@ protected void registerDefaultFuelTypes() { /** * This method returns the outcome that mining certain ores yields. - * + * * @param material * The {@link Material} of the ore that was mined - * + * * @return The outcome when mining this ore */ public @Nonnull ItemStack getOutcome(@Nonnull Material material) { @@ -139,7 +139,7 @@ protected void registerDefaultFuelTypes() { /** * This registers a new fuel type for this {@link IndustrialMiner}. - * + * * @param ores * The amount of ores this allows you to mine * @param item @@ -207,7 +207,7 @@ public void onInteract(Player p, Block b) { * * @param block * The {@link Block} to check - * + * * @return Whether this {@link IndustrialMiner} is capable of mining this {@link Block} */ public boolean canMine(@Nonnull Block block) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfVeinMining.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfVeinMining.java index 4cae8ed99d..41a293a7f3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfVeinMining.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfVeinMining.java @@ -28,7 +28,7 @@ /** * The {@link PickaxeOfVeinMining} is a powerful tool which allows you to mine an entire vein of ores * at once. It even works with the fortune {@link Enchantment}. - * + * * @author TheBusyBiscuit * @author Linox * @@ -63,7 +63,7 @@ private void breakBlocks(Player p, List blocks, int fortune, ItemStack to b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(b.getType())); } else { for (ItemStack drop : b.getDrops(tool)) { - b.getWorld().dropItemNaturally(b.getLocation(), drop.getType().isBlock() ? drop : new CustomItemStack(drop, fortune)); + b.getWorld().dropItemNaturally(b.getLocation(), drop.getType().isBlock() ? drop : CustomItemStack.create(drop, fortune)); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java index bf06243d86..78c3afddfa 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java @@ -48,7 +48,7 @@ /** * This {@link Listener} is responsible for providing the core mechanics of the {@link AncientAltar} * and the {@link AncientPedestal}, it also handles the crafting of items using the Altar. - * + * * @author Redemption198 * @author TheBusyBiscuit * @@ -73,7 +73,7 @@ public AncientAltarListener(Slimefun plugin, AncientAltar altar, AncientPedestal /** * This returns all {@link AncientAltar Altars} that are currently in use. - * + * * @return A {@link Set} of every {@link AncientAltar} currently in use */ public @Nonnull Set getAltarsInUse() { @@ -179,7 +179,7 @@ private void useAltar(@Nonnull Block altar, @Nonnull Player p) { return; } - ItemStack catalyst = new CustomItemStack(p.getInventory().getItemInMainHand(), 1); + ItemStack catalyst = CustomItemStack.create(p.getInventory().getItemInMainHand(), 1); List pedestals = getPedestals(altar); if (!altars.contains(altar)) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java index 7a8b29c0df..893fb0ab75 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java @@ -55,13 +55,13 @@ /** * This {@link Listener} is responsible for handling any {@link Event} * that is required for activating a {@link Talisman}. - * + * * @author TheBusyBiscuit * @author StarWishsama * @author svr333 * @author martinbrom * @author Sfiguz7 - * + * * @see Talisman * */ @@ -124,7 +124,7 @@ private void onProjectileDamage(@Nonnull EntityDamageByEntityEvent e) { /** * This method is used for the {@link Talisman} of the whirlwind, it returns a copy * of a {@link Projectile} that was fired at a {@link Player}. - * + * * @param p * The {@link Player} who was hit * @param projectile @@ -210,7 +210,7 @@ private Collection getExtraDrops(LivingEntity entity, Collection { + return CustomItemStack.create(SEARCH_BUTTON, meta -> { meta.setDisplayName(ChatColors.color(Slimefun.getLocalization().getMessage(p, "guide.search.name"))); List lore = Arrays.asList("", ChatColor.GRAY + "\u21E8 " + Slimefun.getLocalization().getMessage(p, "guide.search.tooltip")); @@ -112,12 +112,12 @@ public boolean onClick(InventoryClickEvent e, Player p, int slot, ItemStack curs public static @Nonnull ItemStack getPreviousButton(@Nonnull Player p, int page, int pages) { if (pages == 1 || page == 1) { - return new CustomItemStack(PREV_BUTTON_INACTIVE, meta -> { + return CustomItemStack.create(PREV_BUTTON_INACTIVE, meta -> { meta.setDisplayName(ChatColor.DARK_GRAY + "\u21E6 " + Slimefun.getLocalization().getMessage(p, "guide.pages.previous")); meta.setLore(Arrays.asList("", ChatColor.GRAY + "(" + page + " / " + pages + ")")); }); } else { - return new CustomItemStack(PREV_BUTTON_ACTIVE, meta -> { + return CustomItemStack.create(PREV_BUTTON_ACTIVE, meta -> { meta.setDisplayName(ChatColor.WHITE + "\u21E6 " + Slimefun.getLocalization().getMessage(p, "guide.pages.previous")); meta.setLore(Arrays.asList("", ChatColor.GRAY + "(" + page + " / " + pages + ")")); }); @@ -126,12 +126,12 @@ public boolean onClick(InventoryClickEvent e, Player p, int slot, ItemStack curs public static @Nonnull ItemStack getNextButton(@Nonnull Player p, int page, int pages) { if (pages == 1 || page == pages) { - return new CustomItemStack(NEXT_BUTTON_INACTIVE, meta -> { + return CustomItemStack.create(NEXT_BUTTON_INACTIVE, meta -> { meta.setDisplayName(ChatColor.DARK_GRAY + Slimefun.getLocalization().getMessage(p, "guide.pages.next") + " \u21E8"); meta.setLore(Arrays.asList("", ChatColor.GRAY + "(" + page + " / " + pages + ")")); }); } else { - return new CustomItemStack(NEXT_BUTTON_ACTIVE, meta -> { + return CustomItemStack.create(NEXT_BUTTON_ACTIVE, meta -> { meta.setDisplayName(ChatColor.WHITE + Slimefun.getLocalization().getMessage(p, "guide.pages.next") + " \u21E8"); meta.setLore(Arrays.asList("", ChatColor.GRAY + "(" + page + " / " + pages + ")")); }); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/ColoredFireworkStar.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/ColoredFireworkStar.java index 063d91f8d1..36ccef1cb8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/ColoredFireworkStar.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/ColoredFireworkStar.java @@ -1,10 +1,7 @@ package io.github.thebusybiscuit.slimefun4.utils.itemstack; -import java.util.ArrayList; -import java.util.List; - -import javax.annotation.ParametersAreNonnullByDefault; - +import io.github.bakedlibs.dough.items.ItemStackEditor; +import io.github.thebusybiscuit.slimefun4.utils.compatibility.VersionedItemFlag; import org.bukkit.Color; import org.bukkit.FireworkEffect; import org.bukkit.FireworkEffect.Type; @@ -12,40 +9,26 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.FireworkEffectMeta; -import io.github.bakedlibs.dough.common.ChatColors; -import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.utils.compatibility.VersionedItemFlag; +import javax.annotation.ParametersAreNonnullByDefault; /** * This simple {@link ItemStack} implementation allows us to obtain * a colored {@code Material.FIREWORK_STAR} {@link ItemStack} quickly. - * + * * @author TheBusyBiscuit * */ -public class ColoredFireworkStar extends CustomItemStack { +public class ColoredFireworkStar { @ParametersAreNonnullByDefault - public ColoredFireworkStar(Color color, String name, String... lore) { - super(Material.FIREWORK_STAR, im -> { - if (name != null) { - im.setDisplayName(ChatColors.color(name)); - } - - ((FireworkEffectMeta) im).setEffect(FireworkEffect.builder().with(Type.BURST).withColor(color).build()); - - if (lore.length > 0) { - List lines = new ArrayList<>(); - - for (String line : lore) { - lines.add(ChatColors.color(line)); - } - - im.setLore(lines); - } - - im.addItemFlags(VersionedItemFlag.HIDE_ADDITIONAL_TOOLTIP); - }); + public static ItemStack create(Color color, String name, String... lore) { + FireworkEffect effect = FireworkEffect.builder().with(Type.BURST).withColor(color).build(); + return new ItemStackEditor(Material.FIREWORK_STAR) + .setDisplayName(name) + .setLore(lore) + .addFlags(VersionedItemFlag.HIDE_ADDITIONAL_TOOLTIP) + .andMetaConsumer(FireworkEffectMeta.class, meta -> meta.setEffect(effect)) + .create(); } } diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java index 04747b4f84..ffe11e9cdb 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java @@ -108,7 +108,7 @@ protected void constructMenu(BlockMenuPreset preset) { preset.addItem(i, ChestMenuUtils.getOutputSlotTexture(), ChestMenuUtils.getEmptyClickHandler()); } - preset.addItem(22, new CustomItemStack(Material.BLACK_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(22, CustomItemStack.create(Material.BLACK_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); for (int i : getOutputSlots()) { preset.addMenuClickHandler(i, ChestMenuUtils.getDefaultOutputHandler()); @@ -118,9 +118,9 @@ protected void constructMenu(BlockMenuPreset preset) { /** * This method returns the title that is used for the {@link Inventory} of an * {@link AContainer} that has been opened by a Player. - * + * * Override this method to set the title. - * + * * @return The title of the {@link Inventory} of this {@link AContainer} */ @Nonnull @@ -131,16 +131,16 @@ public String getInventoryTitle() { /** * This method returns the {@link ItemStack} that this {@link AContainer} will * use as a progress bar. - * + * * Override this method to set the progress bar. - * + * * @return The {@link ItemStack} to use as the progress bar */ public abstract ItemStack getProgressBar(); /** * This method returns the max amount of electricity this machine can hold. - * + * * @return The max amount of electricity this Block can store. */ @Override @@ -150,7 +150,7 @@ public int getCapacity() { /** * This method returns the amount of energy that is consumed per operation. - * + * * @return The rate of energy consumption */ public int getEnergyConsumption() { @@ -161,7 +161,7 @@ public int getEnergyConsumption() { * This method returns the speed at which this machine will operate. * This can be implemented on an instantiation-level to create different tiers * of machines. - * + * * @return The speed of this machine */ public int getSpeed() { @@ -172,10 +172,10 @@ public int getSpeed() { * This sets the energy capacity for this machine. * This method must be called before registering the item * and only before registering. - * + * * @param capacity * The amount of energy this machine can store - * + * * @return This method will return the current instance of {@link AContainer}, so that can be chained. */ public final AContainer setCapacity(int capacity) { @@ -191,10 +191,10 @@ public final AContainer setCapacity(int capacity) { /** * This sets the speed of this machine. - * + * * @param speed * The speed multiplier for this machine, must be above zero - * + * * @return This method will return the current instance of {@link AContainer}, so that can be chained. */ public final AContainer setProcessingSpeed(int speed) { @@ -206,10 +206,10 @@ public final AContainer setProcessingSpeed(int speed) { /** * This method sets the energy consumed by this machine per tick. - * + * * @param energyConsumption * The energy consumed per tick - * + * * @return This method will return the current instance of {@link AContainer}, so that can be chained. */ public final AContainer setEnergyConsumption(int energyConsumption) { @@ -251,13 +251,13 @@ public void register(@Nonnull SlimefunAddon addon) { /** * This method returns an internal identifier that is used to identify this {@link AContainer} * and its recipes. - * + * * When adding recipes to an {@link AContainer} we will use this identifier to * identify all instances of the same {@link AContainer}. * This way we can add the recipes to all instances of the same machine. - * + * * This method will be deprecated and replaced in the future - * + * * @return The identifier of this machine */ @Nonnull @@ -344,7 +344,7 @@ protected void tick(Block b) { processor.updateProgressBar(inv, 22, currentOperation); currentOperation.addProgress(1); } else { - inv.replaceExistingItem(22, new CustomItemStack(Material.BLACK_STAINED_GLASS_PANE, " ")); + inv.replaceExistingItem(22, CustomItemStack.create(Material.BLACK_STAINED_GLASS_PANE, " ")); for (ItemStack output : currentOperation.getResults()) { inv.pushItem(output.clone(), getOutputSlots()); diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java index db5555f6c9..f57fe651d3 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java @@ -122,7 +122,7 @@ private void constructMenu(BlockMenuPreset preset) { preset.addMenuClickHandler(i, ChestMenuUtils.getDefaultOutputHandler()); } - preset.addItem(22, new CustomItemStack(Material.BLACK_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(22, CustomItemStack.create(Material.BLACK_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); } @Override @@ -164,7 +164,7 @@ public int getGeneratedOutput(Location l, Config data) { inv.pushItem(new ItemStack(Material.BUCKET), getOutputSlots()); } - inv.replaceExistingItem(22, new CustomItemStack(Material.BLACK_STAINED_GLASS_PANE, " ")); + inv.replaceExistingItem(22, CustomItemStack.create(Material.BLACK_STAINED_GLASS_PANE, " ")); processor.endOperation(l); return 0; @@ -209,7 +209,7 @@ private MachineFuel findRecipe(BlockMenu menu, Map found) { /** * This method returns the max amount of electricity this machine can hold. - * + * * @return The max amount of electricity this Block can store. */ public int getCapacity() { @@ -218,7 +218,7 @@ public int getCapacity() { /** * This method returns the amount of energy that is consumed per operation. - * + * * @return The rate of energy consumption */ @Override @@ -230,10 +230,10 @@ public int getEnergyProduction() { * This sets the energy capacity for this machine. * This method must be called before registering the item * and only before registering. - * + * * @param capacity * The amount of energy this machine can store - * + * * @return This method will return the current instance of {@link AGenerator}, so that can be chained. */ public final AGenerator setCapacity(int capacity) { @@ -249,10 +249,10 @@ public final AGenerator setCapacity(int capacity) { /** * This method sets the energy produced by this machine per tick. - * + * * @param energyProduced * The energy produced per tick - * + * * @return This method will return the current instance of {@link AGenerator}, so that can be chained. */ public final AGenerator setEnergyProduction(int energyProduced) { diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/DirtyChestMenu.java b/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/DirtyChestMenu.java index bf7cfee93b..dd2bf8cd12 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/DirtyChestMenu.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/DirtyChestMenu.java @@ -33,7 +33,7 @@ public DirtyChestMenu(@Nonnull BlockMenuPreset preset) { /** * This method checks whether this {@link DirtyChestMenu} is currently viewed by a {@link Player}. - * + * * @return Whether anyone is currently viewing this {@link Inventory} */ public boolean hasViewer() { @@ -136,7 +136,7 @@ public ItemStack pushItem(ItemStack item, int... slots) { } if (amount > 0) { - return new CustomItemStack(item, amount); + return CustomItemStack.create(item, amount); } else { return null; } diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/api/items/settings/TestDoubleRangeSetting.java b/src/test/java/io/github/thebusybiscuit/slimefun4/api/items/settings/TestDoubleRangeSetting.java index de8e8b0179..d13d0db64b 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/api/items/settings/TestDoubleRangeSetting.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/api/items/settings/TestDoubleRangeSetting.java @@ -34,14 +34,14 @@ public static void unload() { @Test @DisplayName("Test Constructor validation") void testConstructorValidation() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "DOUBLE_RANGE_TEST_00", new CustomItemStack(Material.DIAMOND, "&cTest")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "DOUBLE_RANGE_TEST_00", CustomItemStack.create(Material.DIAMOND, "&cTest")); Assertions.assertThrows(IllegalArgumentException.class, () -> new DoubleRangeSetting(item, "test", min, -1.0, max)); } @Test @DisplayName("Test min and max getters") void testMinMaxGetters() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "DOUBLE_RANGE_TEST_0", new CustomItemStack(Material.DIAMOND, "&cTest")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "DOUBLE_RANGE_TEST_0", CustomItemStack.create(Material.DIAMOND, "&cTest")); DoubleRangeSetting setting = new DoubleRangeSetting(item, "test", min, 0.5, max); Assertions.assertEquals(min, setting.getMinimum()); @@ -51,7 +51,7 @@ void testMinMaxGetters() { @Test @DisplayName("Test illegal values") void testIllegalValues() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "DOUBLE_RANGE_TEST", new CustomItemStack(Material.DIAMOND, "&cTest")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "DOUBLE_RANGE_TEST", CustomItemStack.create(Material.DIAMOND, "&cTest")); DoubleRangeSetting setting = new DoubleRangeSetting(item, "test", min, 0.5, max); item.addItemSetting(setting); @@ -65,7 +65,7 @@ void testIllegalValues() { @Test @DisplayName("Test allowed value") void testAllowedValue() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "DOUBLE_RANGE_TEST_2", new CustomItemStack(Material.DIAMOND, "&cTest")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "DOUBLE_RANGE_TEST_2", CustomItemStack.create(Material.DIAMOND, "&cTest")); DoubleRangeSetting setting = new DoubleRangeSetting(item, "test", min, 0.25, max); item.addItemSetting(setting); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/api/items/settings/TestEnumSetting.java b/src/test/java/io/github/thebusybiscuit/slimefun4/api/items/settings/TestEnumSetting.java index 9b41cd8807..46df470c91 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/api/items/settings/TestEnumSetting.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/api/items/settings/TestEnumSetting.java @@ -32,7 +32,7 @@ public static void unload() { @Test @DisplayName("Test Enum Getters") void testEnumGetters() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MATERIAL_SETTING_TEST_0", new CustomItemStack(Material.DIAMOND, "&cTest")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MATERIAL_SETTING_TEST_0", CustomItemStack.create(Material.DIAMOND, "&cTest")); EnumSetting setting = new EnumSetting<>(item, "test", Material.class, Material.DIAMOND); Assertions.assertArrayEquals(Material.values(), setting.getAllowedValues()); } @@ -40,7 +40,7 @@ void testEnumGetters() { @Test @DisplayName("Test illegal values") void testIllegalValues() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "ENUM_SETTING_TEST", new CustomItemStack(Material.DIAMOND, "&cTest")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "ENUM_SETTING_TEST", CustomItemStack.create(Material.DIAMOND, "&cTest")); EnumSetting setting = new EnumSetting<>(item, "test", Material.class, Material.DIAMOND); item.addItemSetting(setting); @@ -53,7 +53,7 @@ void testIllegalValues() { @Test @DisplayName("Test allowed value") void testAllowedValue() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MATERIAL_SETTING_TEST_2", new CustomItemStack(Material.DIAMOND, "&cTest")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MATERIAL_SETTING_TEST_2", CustomItemStack.create(Material.DIAMOND, "&cTest")); EnumSetting setting = new EnumSetting<>(item, "test", Material.class, Material.DIAMOND); item.addItemSetting(setting); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/api/items/settings/TestIntRangeSetting.java b/src/test/java/io/github/thebusybiscuit/slimefun4/api/items/settings/TestIntRangeSetting.java index 24d644a45e..cfb12eb0fc 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/api/items/settings/TestIntRangeSetting.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/api/items/settings/TestIntRangeSetting.java @@ -34,14 +34,14 @@ public static void unload() { @Test @DisplayName("Test Constructor validation") void testConstructorValidation() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "INT_RANGE_TEST_00", new CustomItemStack(Material.DIAMOND, "&cTest")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "INT_RANGE_TEST_00", CustomItemStack.create(Material.DIAMOND, "&cTest")); Assertions.assertThrows(IllegalArgumentException.class, () -> new IntRangeSetting(item, "test", min, -50, max)); } @Test @DisplayName("Test min and max getters") void testMinMaxGetters() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "INT_RANGE_TEST_0", new CustomItemStack(Material.DIAMOND, "&cTest")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "INT_RANGE_TEST_0", CustomItemStack.create(Material.DIAMOND, "&cTest")); IntRangeSetting setting = new IntRangeSetting(item, "test", min, 1, max); Assertions.assertEquals(min, setting.getMinimum()); @@ -51,7 +51,7 @@ void testMinMaxGetters() { @Test @DisplayName("Test illegal values") void testIllegalValues() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "INT_RANGE_TEST", new CustomItemStack(Material.DIAMOND, "&cTest")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "INT_RANGE_TEST", CustomItemStack.create(Material.DIAMOND, "&cTest")); IntRangeSetting setting = new IntRangeSetting(item, "test", min, 1, max); item.addItemSetting(setting); @@ -65,7 +65,7 @@ void testIllegalValues() { @Test @DisplayName("Test allowed value") void testAllowedValue() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "INT_RANGE_TEST_2", new CustomItemStack(Material.DIAMOND, "&cTest")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "INT_RANGE_TEST_2", CustomItemStack.create(Material.DIAMOND, "&cTest")); IntRangeSetting setting = new IntRangeSetting(item, "test", min, 1, max); item.addItemSetting(setting); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/api/items/settings/TestItemSettings.java b/src/test/java/io/github/thebusybiscuit/slimefun4/api/items/settings/TestItemSettings.java index 47004780a0..0e043ed7f2 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/api/items/settings/TestItemSettings.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/api/items/settings/TestItemSettings.java @@ -35,7 +35,7 @@ public static void unload() { @Test @DisplayName("Test illegal Item Settings arguments") void testIllegalItemSettings() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "ITEM_SETTINGS_TEST", new CustomItemStack(Material.DIAMOND, "&cTest")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "ITEM_SETTINGS_TEST", CustomItemStack.create(Material.DIAMOND, "&cTest")); item.register(plugin); Assertions.assertThrows(IllegalArgumentException.class, () -> item.addItemSetting()); @@ -46,7 +46,7 @@ void testIllegalItemSettings() { @Test @DisplayName("Test adding an Item Setting") void testAddItemSetting() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "ITEM_SETTINGS_TEST_2", new CustomItemStack(Material.DIAMOND, "&cTest")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "ITEM_SETTINGS_TEST_2", CustomItemStack.create(Material.DIAMOND, "&cTest")); ItemSetting setting = new ItemSetting<>(item, "test", "Hello World"); Assertions.assertTrue(setting.isType(String.class)); @@ -69,7 +69,7 @@ void testAddItemSetting() { @Test @DisplayName("Test updating an Item Settings value") void testUpdateItemSetting() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "ITEM_SETTINGS_TEST_3", new CustomItemStack(Material.DIAMOND, "&cTest")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "ITEM_SETTINGS_TEST_3", CustomItemStack.create(Material.DIAMOND, "&cTest")); ItemSetting setting = new ItemSetting<>(item, "test", "Hello World"); item.addItemSetting(setting); @@ -86,7 +86,7 @@ void testUpdateItemSetting() { @Test @DisplayName("Test Item Settings double-registration") void testAlreadyExistingItemSetting() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "ITEM_SETTINGS_TEST", new CustomItemStack(Material.DIAMOND, "&cTest")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "ITEM_SETTINGS_TEST", CustomItemStack.create(Material.DIAMOND, "&cTest")); ItemSetting setting = new ItemSetting<>(item, "test", "Hello World"); item.addItemSetting(setting); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/api/items/settings/TestMaterialTagSetting.java b/src/test/java/io/github/thebusybiscuit/slimefun4/api/items/settings/TestMaterialTagSetting.java index 0154809ebe..a62928efec 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/api/items/settings/TestMaterialTagSetting.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/api/items/settings/TestMaterialTagSetting.java @@ -40,7 +40,7 @@ public static void unload() { @Test @DisplayName("Test Constructor") void testConstructorValidation() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MATERIAL_SETTING_TEST_0", new CustomItemStack(Material.DIAMOND, "&cTest")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MATERIAL_SETTING_TEST_0", CustomItemStack.create(Material.DIAMOND, "&cTest")); MaterialTagSetting setting = new MaterialTagSetting(item, "test", tag); Assertions.assertEquals(tag, setting.getDefaultTag()); } @@ -48,7 +48,7 @@ void testConstructorValidation() { @Test @DisplayName("Test illegal values") void testIllegalValues() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MATERIAL_SETTING_TEST", new CustomItemStack(Material.DIAMOND, "&cTest")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MATERIAL_SETTING_TEST", CustomItemStack.create(Material.DIAMOND, "&cTest")); MaterialTagSetting setting = new MaterialTagSetting(item, "test", tag); item.addItemSetting(setting); @@ -62,7 +62,7 @@ void testIllegalValues() { @Test @DisplayName("Test allowed value") void testAllowedValue() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MATERIAL_SETTING_TEST_2", new CustomItemStack(Material.DIAMOND, "&cTest")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MATERIAL_SETTING_TEST_2", CustomItemStack.create(Material.DIAMOND, "&cTest")); MaterialTagSetting setting = new MaterialTagSetting(item, "test", tag); item.addItemSetting(setting); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/api/profiles/TestGuideHistory.java b/src/test/java/io/github/thebusybiscuit/slimefun4/api/profiles/TestGuideHistory.java index fc8441b463..214cca3c0c 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/api/profiles/TestGuideHistory.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/api/profiles/TestGuideHistory.java @@ -88,7 +88,7 @@ void testSlimefunItem() throws InterruptedException { Assertions.assertEquals(0, history.size()); - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "HISTORIC_ITEM", new CustomItemStack(Material.DIORITE, "&4I am really running out of ideas for item names")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "HISTORIC_ITEM", CustomItemStack.create(Material.DIORITE, "&4I am really running out of ideas for item names")); history.add(item); Assertions.assertEquals(1, history.size()); @@ -120,7 +120,7 @@ void testItemGroup() throws InterruptedException { PlayerProfile profile = TestUtilities.awaitProfile(player); GuideHistory history = profile.getGuideHistory(); - ItemGroup itemGroup = new ItemGroup(new NamespacedKey(plugin, "itemgroup_guide_history"), new CustomItemStack(Material.BEDROCK, "&4Can't touch this")); + ItemGroup itemGroup = new ItemGroup(new NamespacedKey(plugin, "itemgroup_guide_history"), CustomItemStack.create(Material.BEDROCK, "&4Can't touch this")); Assertions.assertThrows(IllegalArgumentException.class, () -> history.add((ItemGroup) null, 1)); Assertions.assertThrows(IllegalArgumentException.class, () -> history.add(itemGroup, -20)); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/core/guide/TestGuideOpening.java b/src/test/java/io/github/thebusybiscuit/slimefun4/core/guide/TestGuideOpening.java index a8685b9736..b7a9a20d1c 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/core/guide/TestGuideOpening.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/core/guide/TestGuideOpening.java @@ -65,7 +65,7 @@ void testOpenMainMenu() throws InterruptedException { @Test @DisplayName("Test if an ItemGroup can be opened from the History") void testOpenItemGroup() throws InterruptedException { - ItemGroup itemGroup = new ItemGroup(new NamespacedKey(plugin, "history_itemgroup"), new CustomItemStack(Material.BLUE_TERRACOTTA, "&9Testy test")); + ItemGroup itemGroup = new ItemGroup(new NamespacedKey(plugin, "history_itemgroup"), CustomItemStack.create(Material.BLUE_TERRACOTTA, "&9Testy test")); SlimefunGuideImplementation guide = Mockito.mock(SlimefunGuideImplementation.class); PlayerProfile profile = prepare(guide, history -> history.add(itemGroup, 1)); @@ -75,7 +75,7 @@ void testOpenItemGroup() throws InterruptedException { @Test @DisplayName("Test if a SlimefunItem can be viewed from the History") void testOpenSlimefunItem() throws InterruptedException { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "OPEN_SLIMEFUN_ITEM", new CustomItemStack(Material.PRISMARINE_SHARD, "&5Some Shard I guess")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "OPEN_SLIMEFUN_ITEM", CustomItemStack.create(Material.PRISMARINE_SHARD, "&5Some Shard I guess")); SlimefunGuideImplementation guide = Mockito.mock(SlimefunGuideImplementation.class); PlayerProfile profile = prepare(guide, history -> history.add(item)); @@ -98,7 +98,7 @@ void testOpenSearch_withColoredSearchTerm() throws InterruptedException { String normalTerm = "iron"; String coloredTerm = ChatColor.DARK_PURPLE + "iron"; - SlimefunItem testItem = TestUtilities.mockSlimefunItem(plugin, "IRON_ITEM", new CustomItemStack(Material.IRON_INGOT, "iron item")); + SlimefunItem testItem = TestUtilities.mockSlimefunItem(plugin, "IRON_ITEM", CustomItemStack.create(Material.IRON_INGOT, "iron item")); testItem.register(plugin); Player player = server.addPlayer(); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/TestMultiBlocks.java b/src/test/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/TestMultiBlocks.java index e3d408e7e3..93fb5ef75f 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/TestMultiBlocks.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/TestMultiBlocks.java @@ -33,7 +33,7 @@ public static void unload() { @Test @DisplayName("Test Exceptions for invalid MultiBlock constructors") void testInvalidConstructors() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MULTIBLOCK_TEST", new CustomItemStack(Material.BRICK, "&5Multiblock Test")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MULTIBLOCK_TEST", CustomItemStack.create(Material.BRICK, "&5Multiblock Test")); Assertions.assertThrows(IllegalArgumentException.class, () -> new MultiBlock(null, null, null)); @@ -46,7 +46,7 @@ void testInvalidConstructors() { @Test @DisplayName("Test MultiBlock constructor") void testValidConstructor() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MULTIBLOCK_TEST", new CustomItemStack(Material.BRICK, "&5Multiblock Test")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MULTIBLOCK_TEST", CustomItemStack.create(Material.BRICK, "&5Multiblock Test")); MultiBlock multiblock = new MultiBlock(item, new Material[9], BlockFace.DOWN); Assertions.assertEquals(item, multiblock.getSlimefunItem()); @@ -57,7 +57,7 @@ void testValidConstructor() { @Test @DisplayName("Test symmetric MultiBlocks") void testSymmetry() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MULTIBLOCK_TEST", new CustomItemStack(Material.BRICK, "&5Multiblock Test")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MULTIBLOCK_TEST", CustomItemStack.create(Material.BRICK, "&5Multiblock Test")); MultiBlock multiblock = new MultiBlock(item, new Material[] { null, null, null, Material.DIAMOND_BLOCK, null, Material.DIAMOND_BLOCK, null, Material.DISPENSER, null }, BlockFace.DOWN); Assertions.assertTrue(multiblock.isSymmetric()); @@ -69,7 +69,7 @@ void testSymmetry() { @Test @DisplayName("Test equal MultiBlocks being equal") void testEqual() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MULTIBLOCK_TEST", new CustomItemStack(Material.BRICK, "&5Multiblock Test")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MULTIBLOCK_TEST", CustomItemStack.create(Material.BRICK, "&5Multiblock Test")); MultiBlock multiblock = new MultiBlock(item, new Material[] { Material.BIRCH_WOOD, Material.BIRCH_WOOD, Material.BIRCH_WOOD, null, Material.CRAFTING_TABLE, null, Material.BIRCH_WOOD, Material.DISPENSER, Material.BIRCH_WOOD }, BlockFace.DOWN); MultiBlock multiblock2 = new MultiBlock(item, new Material[] { Material.BIRCH_WOOD, Material.BIRCH_WOOD, Material.BIRCH_WOOD, null, Material.CRAFTING_TABLE, null, Material.BIRCH_WOOD, Material.DISPENSER, Material.BIRCH_WOOD }, BlockFace.DOWN); @@ -80,7 +80,7 @@ void testEqual() { @Test @DisplayName("Test equal MultiBlocks with Tags but different Materials being equal") void testEqualWithTags() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MULTIBLOCK_TEST", new CustomItemStack(Material.BRICK, "&5Multiblock Test")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MULTIBLOCK_TEST", CustomItemStack.create(Material.BRICK, "&5Multiblock Test")); // The wooden fences are different but the structure should still match. MultiBlock multiblock = new MultiBlock(item, new Material[] { Material.OAK_FENCE, Material.OAK_FENCE, Material.OAK_FENCE, null, Material.CRAFTING_TABLE, null, Material.BIRCH_WOOD, Material.DISPENSER, Material.BIRCH_WOOD }, BlockFace.DOWN); @@ -92,7 +92,7 @@ void testEqualWithTags() { @Test @DisplayName("Test MultiBlocks with moving pistons still being equal") void testEqualWithMovingPistons() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "PISTON_MULTIBLOCK_TEST", new CustomItemStack(Material.BRICK, "&5Multiblock Test")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "PISTON_MULTIBLOCK_TEST", CustomItemStack.create(Material.BRICK, "&5Multiblock Test")); // Some Pistons are moving but that should not interefere with the Multiblock MultiBlock multiblock = new MultiBlock(item, new Material[] { Material.PISTON, Material.MOVING_PISTON, Material.PISTON, null, Material.CRAFTING_TABLE, null, Material.PISTON, Material.STONE, Material.PISTON }, BlockFace.DOWN); @@ -106,7 +106,7 @@ void testEqualWithMovingPistons() { @Test @DisplayName("Test different MultiBlocks not being equal") void testNotEqual() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MULTIBLOCK_TEST", new CustomItemStack(Material.BRICK, "&5Multiblock Test")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MULTIBLOCK_TEST", CustomItemStack.create(Material.BRICK, "&5Multiblock Test")); MultiBlock multiblock = new MultiBlock(item, new Material[] { Material.BIRCH_WOOD, Material.BIRCH_WOOD, Material.BIRCH_WOOD, null, Material.CRAFTING_TABLE, null, Material.BIRCH_WOOD, Material.DISPENSER, Material.BIRCH_WOOD }, BlockFace.DOWN); MultiBlock multiblock2 = new MultiBlock(item, new Material[] { Material.BIRCH_WOOD, Material.BIRCH_WOOD, Material.BIRCH_WOOD, null, Material.EMERALD_BLOCK, null, Material.BIRCH_WOOD, Material.DISPENSER, Material.BIRCH_WOOD }, BlockFace.DOWN); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/core/researching/TestResearches.java b/src/test/java/io/github/thebusybiscuit/slimefun4/core/researching/TestResearches.java index fd8a5864e1..21bb2b2f3e 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/core/researching/TestResearches.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/core/researching/TestResearches.java @@ -78,7 +78,7 @@ void testResearchCost() { void testResearchRegistration() { NamespacedKey key = new NamespacedKey(plugin, "test_research"); Research research = new Research(key, 1, "Test", 100); - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "RESEARCH_TEST", new CustomItemStack(Material.TORCH, "&bResearch Test")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "RESEARCH_TEST", CustomItemStack.create(Material.TORCH, "&bResearch Test")); research.addItems(item, null); research.register(); @@ -98,7 +98,7 @@ void testResearchRegistration() { void testDisabledResearch() { NamespacedKey key = new NamespacedKey(plugin, "disabled_research"); Research research = new Research(key, 2, "Test", 100); - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "RESEARCH_TEST", new CustomItemStack(Material.TORCH, "&bResearch Test")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "RESEARCH_TEST", CustomItemStack.create(Material.TORCH, "&bResearch Test")); research.addItems(item); Slimefun.getRegistry().setResearchingEnabled(true); @@ -127,7 +127,7 @@ void testResearchGloballyDisabled() { void testAddItems() { NamespacedKey key = new NamespacedKey(plugin, "add_items_to_research"); Research research = new Research(key, 17, "Test", 100); - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "RESEARCH_ITEMS_TEST", new CustomItemStack(Material.LAPIS_LAZULI, "&9Adding items is fun")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "RESEARCH_ITEMS_TEST", CustomItemStack.create(Material.LAPIS_LAZULI, "&9Adding items is fun")); item.register(plugin); research.addItems(item.getItem(), null); @@ -199,7 +199,7 @@ void testPreCanUnlockResearchEvent() throws InterruptedException { SlimefunGuideImplementation guide = Mockito.mock(SlimefunGuideImplementation.class); Player player = server.addPlayer(); PlayerProfile profile = TestUtilities.awaitProfile(player); - SlimefunItem sfItem = TestUtilities.mockSlimefunItem(plugin, "RESEARCH_TEST", new CustomItemStack(Material.TORCH, "&bResearch Test")); + SlimefunItem sfItem = TestUtilities.mockSlimefunItem(plugin, "RESEARCH_TEST", CustomItemStack.create(Material.TORCH, "&bResearch Test")); research.unlockFromGuide(guide, player, profile, sfItem, sfItem.getItemGroup(), 0); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/core/services/TestPermissionsService.java b/src/test/java/io/github/thebusybiscuit/slimefun4/core/services/TestPermissionsService.java index c5d692ebc4..0c0bf143e3 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/core/services/TestPermissionsService.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/core/services/TestPermissionsService.java @@ -44,7 +44,7 @@ public static void unload() { @ValueSource(booleans = { false, true }) void testDefaultPermission(boolean registered) { PermissionsService service = new PermissionsService(plugin); - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "PERMISSIONS_TEST", new CustomItemStack(Material.EMERALD, "&bBad omen")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "PERMISSIONS_TEST", CustomItemStack.create(Material.EMERALD, "&bBad omen")); if (registered) { service.register(Arrays.asList(item), false); @@ -58,7 +58,7 @@ void testDefaultPermission(boolean registered) { @DisplayName("Test if a permission node can be set") void testSetPermission() { PermissionsService service = new PermissionsService(plugin); - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "PERMISSIONS_TEST", new CustomItemStack(Material.EMERALD, "&bBad omen")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "PERMISSIONS_TEST", CustomItemStack.create(Material.EMERALD, "&bBad omen")); Assertions.assertThrows(IllegalArgumentException.class, () -> service.setPermission(null, null)); @@ -80,7 +80,7 @@ void testSetPermission() { void testHasPermissionTrue() { PermissionsService service = new PermissionsService(plugin); Player player = server.addPlayer(); - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "PERMISSIONS_TEST", new CustomItemStack(Material.EMERALD, "&bBad omen")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "PERMISSIONS_TEST", CustomItemStack.create(Material.EMERALD, "&bBad omen")); Assertions.assertTrue(service.hasPermission(player, null)); Assertions.assertTrue(service.hasPermission(player, item)); @@ -94,7 +94,7 @@ void testHasPermissionTrue() { void testHasPermissionFalse() { PermissionsService service = new PermissionsService(plugin); Player player = server.addPlayer(); - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "PERMISSIONS_TEST", new CustomItemStack(Material.EMERALD, "&bBad omen")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "PERMISSIONS_TEST", CustomItemStack.create(Material.EMERALD, "&bBad omen")); service.setPermission(item, "slimefun.tests"); Assertions.assertFalse(service.hasPermission(player, item)); @@ -106,7 +106,7 @@ void testHasPermissionOp() { PermissionsService service = new PermissionsService(plugin); Player player = server.addPlayer(); player.setOp(true); - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "PERMISSIONS_TEST", new CustomItemStack(Material.EMERALD, "&bBad omen")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "PERMISSIONS_TEST", CustomItemStack.create(Material.EMERALD, "&bBad omen")); Permission permission = new Permission("slimefun.unit.tests.op", PermissionDefault.OP); @@ -119,7 +119,7 @@ void testHasPermissionOp() { void testHasPermissionSet() { PermissionsService service = new PermissionsService(plugin); Player player = server.addPlayer(); - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "PERMISSIONS_TEST", new CustomItemStack(Material.EMERALD, "&bBad omen")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "PERMISSIONS_TEST", CustomItemStack.create(Material.EMERALD, "&bBad omen")); String permission = "slimefun.unit.tests.permission"; player.addAttachment(plugin, permission, true); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/TestSlimefunItem.java b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/TestSlimefunItem.java index c2f07b5b99..657fe39109 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/TestSlimefunItem.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/TestSlimefunItem.java @@ -39,7 +39,7 @@ public static void unload() { @Test @DisplayName("Test wiki pages getting assigned correctly") void testWikiPages() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "WIKI_ITEM", new CustomItemStack(Material.BOOK, "&cTest")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "WIKI_ITEM", CustomItemStack.create(Material.BOOK, "&cTest")); item.register(plugin); Assertions.assertFalse(item.getWikipage().isPresent()); @@ -57,7 +57,7 @@ void testWikiPages() { @Test @DisplayName("Test SlimefunItem registering Recipes properly") void testRecipe() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "RECIPE_TEST", new CustomItemStack(Material.DIAMOND, "&dAnother one bites the test")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "RECIPE_TEST", CustomItemStack.create(Material.DIAMOND, "&dAnother one bites the test")); ItemStack[] recipe = { null, new ItemStack(Material.DIAMOND), null, null, new ItemStack(Material.DIAMOND), null, null, new ItemStack(Material.DIAMOND), null }; item.setRecipe(recipe); @@ -73,7 +73,7 @@ void testRecipe() { @Test @DisplayName("Test Recipe outputs being handled correctly") void testRecipeOutput() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "RECIPE_OUTPUT_TEST", new CustomItemStack(Material.DIAMOND, "&cTest")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "RECIPE_OUTPUT_TEST", CustomItemStack.create(Material.DIAMOND, "&cTest")); item.register(plugin); Assertions.assertEquals(item.getItem(), item.getRecipeOutput()); @@ -89,7 +89,7 @@ void testRecipeOutput() { @Test @DisplayName("Test Recipe Types being handled properly") void testRecipeType() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "RECIPE_TYPE_TEST", new CustomItemStack(Material.DIAMOND, "&cTest")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "RECIPE_TYPE_TEST", CustomItemStack.create(Material.DIAMOND, "&cTest")); item.register(plugin); Assertions.assertNotNull(item.getRecipeType()); @@ -106,18 +106,18 @@ void testRecipeType() { @Test @DisplayName("Test SlimefunItem#isItem(...)") void testIsItem() { - ItemStack item = new CustomItemStack(Material.BEACON, "&cItem Test"); + ItemStack item = CustomItemStack.create(Material.BEACON, "&cItem Test"); String id = "IS_ITEM_TEST"; - SlimefunItem sfItem = TestUtilities.mockSlimefunItem(plugin, id, new CustomItemStack(Material.BEACON, "&cItem Test")); + SlimefunItem sfItem = TestUtilities.mockSlimefunItem(plugin, id, CustomItemStack.create(Material.BEACON, "&cItem Test")); sfItem.register(plugin); Assertions.assertTrue(sfItem.isItem(sfItem.getItem())); Assertions.assertFalse(sfItem.isItem(null)); Assertions.assertFalse(sfItem.isItem(new ItemStack(Material.BEACON))); - Assertions.assertFalse(sfItem.isItem(new CustomItemStack(Material.REDSTONE, "&cTest"))); + Assertions.assertFalse(sfItem.isItem(CustomItemStack.create(Material.REDSTONE, "&cTest"))); Assertions.assertFalse(sfItem.isItem(item)); - Assertions.assertFalse(sfItem.isItem(new CustomItemStack(Material.BEACON, "&cItem Test"))); + Assertions.assertFalse(sfItem.isItem(CustomItemStack.create(Material.BEACON, "&cItem Test"))); Assertions.assertEquals(sfItem, SlimefunItem.getByItem(new SlimefunItemStack(sfItem.getId(), item))); } @@ -125,7 +125,7 @@ void testIsItem() { @Test @DisplayName("Test WrongItemStackException") void testWrongItemStackException() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "WRONG_ITEMSTACK_EXCEPTION", new CustomItemStack(Material.NETHER_STAR, "&4Do not modify me")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "WRONG_ITEMSTACK_EXCEPTION", CustomItemStack.create(Material.NETHER_STAR, "&4Do not modify me")); item.register(plugin); item.load(); @@ -136,16 +136,16 @@ void testWrongItemStackException() { @Test @DisplayName("Test UnregisteredItemException") void testUnregisteredItemException() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "UNREGISTERED_ITEM_EXCEPTION", new CustomItemStack(Material.NETHER_STAR, "&4Do not modify me")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "UNREGISTERED_ITEM_EXCEPTION", CustomItemStack.create(Material.NETHER_STAR, "&4Do not modify me")); Assertions.assertThrows(UnregisteredItemException.class, () -> item.getAddon()); } @Test @DisplayName("Test SlimefunItem#equals(...)") void testEquals() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "EQUALS_TEST", new CustomItemStack(Material.LANTERN, "&6We are equal")); - SlimefunItem item2 = TestUtilities.mockSlimefunItem(plugin, "EQUALS_TEST", new CustomItemStack(Material.LANTERN, "&6We are equal")); - SlimefunItem differentItem = TestUtilities.mockSlimefunItem(plugin, "I_AM_DIFFERENT", new CustomItemStack(Material.LANTERN, "&6We are equal")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "EQUALS_TEST", CustomItemStack.create(Material.LANTERN, "&6We are equal")); + SlimefunItem item2 = TestUtilities.mockSlimefunItem(plugin, "EQUALS_TEST", CustomItemStack.create(Material.LANTERN, "&6We are equal")); + SlimefunItem differentItem = TestUtilities.mockSlimefunItem(plugin, "I_AM_DIFFERENT", CustomItemStack.create(Material.LANTERN, "&6We are equal")); Assertions.assertEquals(item, item2); Assertions.assertNotEquals(item, differentItem); @@ -155,9 +155,9 @@ void testEquals() { @Test @DisplayName("Test SlimefunItem#hashCode()") void testHashCode() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "EQUALS_TEST", new CustomItemStack(Material.LANTERN, "&6We are equal")); - SlimefunItem item2 = TestUtilities.mockSlimefunItem(plugin, "EQUALS_TEST", new CustomItemStack(Material.LANTERN, "&6We are equal")); - SlimefunItem differentItem = TestUtilities.mockSlimefunItem(plugin, "I_AM_DIFFERENT", new CustomItemStack(Material.LANTERN, "&6We are equal")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "EQUALS_TEST", CustomItemStack.create(Material.LANTERN, "&6We are equal")); + SlimefunItem item2 = TestUtilities.mockSlimefunItem(plugin, "EQUALS_TEST", CustomItemStack.create(Material.LANTERN, "&6We are equal")); + SlimefunItem differentItem = TestUtilities.mockSlimefunItem(plugin, "I_AM_DIFFERENT", CustomItemStack.create(Material.LANTERN, "&6We are equal")); Assertions.assertEquals(item.hashCode(), item2.hashCode()); Assertions.assertNotEquals(item.hashCode(), differentItem.hashCode()); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/TestAbstractRecipe.java b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/TestAbstractRecipe.java index 3ff2381f4b..2fa377c86e 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/TestAbstractRecipe.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/TestAbstractRecipe.java @@ -42,7 +42,7 @@ public static void unload() { @DisplayName("Test ShapelessRecipe as AbstractRecipe") void testShapelessRecipe() { NamespacedKey key = new NamespacedKey(plugin, "shapeless_recipe_test"); - ItemStack result = new CustomItemStack(Material.DIAMOND, "&6Special Diamond :o"); + ItemStack result = CustomItemStack.create(Material.DIAMOND, "&6Special Diamond :o"); ShapelessRecipe recipe = new ShapelessRecipe(key, result); recipe.addIngredient(new MaterialChoice(Material.IRON_NUGGET, Material.GOLD_NUGGET)); @@ -59,7 +59,7 @@ void testShapelessRecipe() { @DisplayName("Test ShapedRecipe as AbstractRecipe") void testShapedRecipe() { NamespacedKey key = new NamespacedKey(plugin, "shaped_recipe_test"); - ItemStack result = new CustomItemStack(Material.EMERALD, "&6Special Emerald :o"); + ItemStack result = CustomItemStack.create(Material.EMERALD, "&6Special Emerald :o"); ShapedRecipe recipe = new ShapedRecipe(key, result); recipe.shape("OXO", " X ", "OXO"); @@ -80,7 +80,7 @@ void testShapedRecipe() { @DisplayName("Test invalid recipes as AbstractRecipe") void testInvalidRecipes() { NamespacedKey key = new NamespacedKey(plugin, "furnace_recipe_test"); - ItemStack result = new CustomItemStack(Material.COAL, "&6Special Coal :o"); + ItemStack result = CustomItemStack.create(Material.COAL, "&6Special Coal :o"); FurnaceRecipe recipe = new FurnaceRecipe(key, result, Material.COAL, 1, 1); Assertions.assertNull(AbstractRecipe.of(recipe)); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/TestAutoCrafter.java b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/TestAutoCrafter.java index ac40d14416..bf15c79d46 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/TestAutoCrafter.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/TestAutoCrafter.java @@ -44,7 +44,7 @@ public static void unload() { @DisplayName("Test crafting a valid ShapelessRecipe") void testValidShapelessRecipe() { NamespacedKey key = new NamespacedKey(plugin, "shapeless_recipe_test"); - ItemStack result = new CustomItemStack(Material.DIAMOND, "&6Special Diamond :o"); + ItemStack result = CustomItemStack.create(Material.DIAMOND, "&6Special Diamond :o"); ShapelessRecipe recipe = new ShapelessRecipe(key, result); recipe.addIngredient(new MaterialChoice(Material.IRON_NUGGET, Material.GOLD_NUGGET)); @@ -71,7 +71,7 @@ void testValidShapelessRecipe() { @DisplayName("Test crafting a valid ShapelessRecipe") void testDisabledRecipe() { NamespacedKey key = new NamespacedKey(plugin, "disabled_recipe_test"); - ItemStack result = new CustomItemStack(Material.DIAMOND, "&bAmazing Diamond :o"); + ItemStack result = CustomItemStack.create(Material.DIAMOND, "&bAmazing Diamond :o"); ShapelessRecipe recipe = new ShapelessRecipe(key, result); recipe.addIngredient(new MaterialChoice(Material.GOLD_NUGGET)); @@ -100,7 +100,7 @@ void testDisabledRecipe() { @DisplayName("Test resource leftovers when crafting") void testResourceLeftovers() { NamespacedKey key = new NamespacedKey(plugin, "resource_leftovers_test"); - ItemStack result = new CustomItemStack(Material.DIAMOND, "&9Diamond. Nuff said."); + ItemStack result = CustomItemStack.create(Material.DIAMOND, "&9Diamond. Nuff said."); ShapelessRecipe recipe = new ShapelessRecipe(key, result); recipe.addIngredient(new MaterialChoice(Material.HONEY_BOTTLE)); recipe.addIngredient(new MaterialChoice(Material.HONEY_BOTTLE)); @@ -123,7 +123,7 @@ void testResourceLeftovers() { @DisplayName("Test crafting an invalid ShapelessRecipe") void testInvalidShapelessRecipe() { NamespacedKey key = new NamespacedKey(plugin, "shapeless_recipe_test"); - ItemStack result = new CustomItemStack(Material.DIAMOND, "&6Special Diamond :o"); + ItemStack result = CustomItemStack.create(Material.DIAMOND, "&6Special Diamond :o"); ShapelessRecipe recipe = new ShapelessRecipe(key, result); recipe.addIngredient(Material.IRON_NUGGET); @@ -142,7 +142,7 @@ void testInvalidShapelessRecipe() { @DisplayName("Test crafting a ShapelessRecipe with a SlimefunItem") void ShapelessRecipeWithSlimefunItem() { NamespacedKey key = new NamespacedKey(plugin, "shapeless_recipe_test"); - ItemStack result = new CustomItemStack(Material.DIAMOND, "&6Special Diamond :o"); + ItemStack result = CustomItemStack.create(Material.DIAMOND, "&6Special Diamond :o"); ShapelessRecipe recipe = new ShapelessRecipe(key, result); recipe.addIngredient(Material.BAMBOO); @@ -173,7 +173,7 @@ void ShapelessRecipeWithSlimefunItem() { @DisplayName("Test crafting with a full Inventory") void testFullInventory() { NamespacedKey key = new NamespacedKey(plugin, "shapeless_recipe_test"); - ItemStack result = new CustomItemStack(Material.DIAMOND, "&6Special Diamond :o"); + ItemStack result = CustomItemStack.create(Material.DIAMOND, "&6Special Diamond :o"); ShapelessRecipe recipe = new ShapelessRecipe(key, result); recipe.addIngredient(Material.IRON_NUGGET); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestAnvilListener.java b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestAnvilListener.java index cf57add8ac..52fc8fad5e 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestAnvilListener.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestAnvilListener.java @@ -62,7 +62,7 @@ void testAnvilWithoutSlimefunItems() { @Test void testAnvilWithSlimefunItem() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MOCKED_IRON_SWORD", new CustomItemStack(Material.IRON_SWORD, "&6Mock")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MOCKED_IRON_SWORD", CustomItemStack.create(Material.IRON_SWORD, "&6Mock")); item.register(plugin); InventoryClickEvent event = mockAnvilEvent(item.getItem()); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestBackpackListener.java b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestBackpackListener.java index d6c6217112..006c4a5d7b 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestBackpackListener.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestBackpackListener.java @@ -84,7 +84,7 @@ private PlayerBackpack openMockBackpack(Player player, String id, int size) thro PlayerBackpack backpack = profile.createBackpack(size); listener.setBackpackId(player, item, 2, backpack.getId()); - ItemGroup itemGroup = new ItemGroup(new NamespacedKey(plugin, "test_backpacks"), new CustomItemStack(Material.CHEST, "&4Test Backpacks")); + ItemGroup itemGroup = new ItemGroup(new NamespacedKey(plugin, "test_backpacks"), CustomItemStack.create(Material.CHEST, "&4Test Backpacks")); SlimefunBackpack slimefunBackpack = new SlimefunBackpack(size, itemGroup, item, RecipeType.NULL, new ItemStack[9]); slimefunBackpack.register(plugin); @@ -100,15 +100,15 @@ void testIllegalSetId() { Assertions.assertThrows(IllegalArgumentException.class, () -> listener.setBackpackId(null, null, 1, 1)); Assertions.assertThrows(IllegalArgumentException.class, () -> listener.setBackpackId(player, null, 1, 1)); Assertions.assertThrows(IllegalArgumentException.class, () -> listener.setBackpackId(player, new ItemStack(Material.REDSTONE), 1, 1)); - Assertions.assertThrows(IllegalArgumentException.class, () -> listener.setBackpackId(player, new CustomItemStack(Material.REDSTONE, "Hi", "lore"), 1, 1)); - Assertions.assertThrows(IllegalArgumentException.class, () -> listener.setBackpackId(player, new CustomItemStack(Material.REDSTONE, "Hi", "lore", "no id"), 1, 1)); + Assertions.assertThrows(IllegalArgumentException.class, () -> listener.setBackpackId(player, CustomItemStack.create(Material.REDSTONE, "Hi", "lore"), 1, 1)); + Assertions.assertThrows(IllegalArgumentException.class, () -> listener.setBackpackId(player, CustomItemStack.create(Material.REDSTONE, "Hi", "lore", "no id"), 1, 1)); } @Test @DisplayName("Test if backpack id is properly applied to the lore") void testSetId() throws InterruptedException { Player player = server.addPlayer(); - ItemStack item = new CustomItemStack(Material.CHEST, "&cA mocked Backpack", "", "&7Size: &e" + BACKPACK_SIZE, "&7ID: ", "", "&7&eRight Click&7 to open"); + ItemStack item = CustomItemStack.create(Material.CHEST, "&cA mocked Backpack", "", "&7Size: &e" + BACKPACK_SIZE, "&7ID: ", "", "&7&eRight Click&7 to open"); PlayerProfile profile = TestUtilities.awaitProfile(player); int id = profile.createBackpack(BACKPACK_SIZE).getId(); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestBrewingStandListener.java b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestBrewingStandListener.java index 7a78612680..660656cd07 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestBrewingStandListener.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestBrewingStandListener.java @@ -67,7 +67,7 @@ void testBrewingWithoutSlimefunItems() { @Test void testBrewingWithSlimefunItem() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MOCK_POWDER", new CustomItemStack(Material.BLAZE_POWDER, "&6Magic Mock Powder")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MOCK_POWDER", CustomItemStack.create(Material.BLAZE_POWDER, "&6Magic Mock Powder")); item.register(plugin); InventoryClickEvent event = mockBrewingEvent(item.getItem()); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestCargoNodeListener.java b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestCargoNodeListener.java index 0951dce2ca..739affb127 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestCargoNodeListener.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestCargoNodeListener.java @@ -68,7 +68,7 @@ void testInvalidSidePlacement() { Block against = b.getRelative(BlockFace.DOWN); ItemGroup itemGroup = TestUtilities.getItemGroup(plugin, "cargo_test"); - SlimefunItemStack item = new SlimefunItemStack("MOCK_CARGO_NODE", new CustomItemStack(Material.PLAYER_HEAD, "&4Cargo node!")); + SlimefunItemStack item = new SlimefunItemStack("MOCK_CARGO_NODE", CustomItemStack.create(Material.PLAYER_HEAD, "&4Cargo node!")); CargoInputNode node = new CargoInputNode(itemGroup, item, RecipeType.NULL, new ItemStack[9], null); node.register(plugin); @@ -87,7 +87,7 @@ void testGrassPlacement() { b.setType(Material.GRASS_BLOCK); ItemGroup itemGroup = TestUtilities.getItemGroup(plugin, "cargo_test"); - SlimefunItemStack item = new SlimefunItemStack("MOCK_CARGO_NODE_2", new CustomItemStack(Material.PLAYER_HEAD, "&4Cargo node!")); + SlimefunItemStack item = new SlimefunItemStack("MOCK_CARGO_NODE_2", CustomItemStack.create(Material.PLAYER_HEAD, "&4Cargo node!")); CargoInputNode node = new CargoInputNode(itemGroup, item, RecipeType.NULL, new ItemStack[9], null); node.register(plugin); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestCartographyTableListener.java b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestCartographyTableListener.java index 892fd5b4ad..b872c45341 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestCartographyTableListener.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestCartographyTableListener.java @@ -56,7 +56,7 @@ private InventoryClickEvent mockCartographyTableEvent(ItemStack item) { @Test void testCartographyTableWithSlimefunItem() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MOCKED_PAPER", new CustomItemStack(Material.PAPER, "&6Mock")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MOCKED_PAPER", CustomItemStack.create(Material.PAPER, "&6Mock")); item.register(plugin); InventoryClickEvent event = mockCartographyTableEvent(item.getItem()); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestCauldronListener.java b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestCauldronListener.java index fd39063195..c3072d162e 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestCauldronListener.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestCauldronListener.java @@ -77,7 +77,7 @@ void testCauldronWithNormalLeatherArmor() { @Test @DisplayName("Test Cauldron working as normal with non-leather slimefun items") void testCauldronWithSlimefunItem() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "CAULDRON_TEST_MOCK", new CustomItemStack(Material.GOLDEN_APPLE, "&6Mock")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "CAULDRON_TEST_MOCK", CustomItemStack.create(Material.GOLDEN_APPLE, "&6Mock")); item.register(plugin); PlayerInteractEvent event = mockCauldronEvent(item.getItem()); @@ -87,7 +87,7 @@ void testCauldronWithSlimefunItem() { @Test @DisplayName("Test Cauldron being cancelled with slimefun leather armor") void testCauldronWithSlimefunLeatherArmor() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "CAULDRON_TEST_MOCK_LEATHER", new CustomItemStack(Material.LEATHER_BOOTS, "&6Mock Leather Armor")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "CAULDRON_TEST_MOCK_LEATHER", CustomItemStack.create(Material.LEATHER_BOOTS, "&6Mock Leather Armor")); item.register(plugin); PlayerInteractEvent event = mockCauldronEvent(item.getItem()); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestCoolerListener.java b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestCoolerListener.java index e606840cbc..2793b76e11 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestCoolerListener.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestCoolerListener.java @@ -41,7 +41,7 @@ public static void load() { server = MockBukkit.mock(); Slimefun plugin = MockBukkit.load(Slimefun.class); - ItemGroup itemGroup = new ItemGroup(new NamespacedKey(plugin, "cooler_test"), new CustomItemStack(Material.SNOWBALL, "Mr. Freeze")); + ItemGroup itemGroup = new ItemGroup(new NamespacedKey(plugin, "cooler_test"), CustomItemStack.create(Material.SNOWBALL, "Mr. Freeze")); SlimefunItemStack item = new SlimefunItemStack("TEST_COOLER", Material.SNOWBALL, "&6Test Cooler", "", "&7ID: "); cooler = new Cooler(18, itemGroup, item, RecipeType.NULL, new ItemStack[9]); cooler.register(plugin); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestCraftingTableListener.java b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestCraftingTableListener.java index 5819ad3a32..e78d3f00fd 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestCraftingTableListener.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestCraftingTableListener.java @@ -93,7 +93,7 @@ void testCraftEventWithoutSlimefunItems() { @Test void testCraftEventWithSlimefunItem() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MOCK_DIAMOND", new CustomItemStack(Material.DIAMOND, "&cMock Diamond")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MOCK_DIAMOND", CustomItemStack.create(Material.DIAMOND, "&cMock Diamond")); item.register(plugin); CraftItemEvent event = mockCraftingEvent(item.getItem()); @@ -102,7 +102,7 @@ void testCraftEventWithSlimefunItem() { @Test void testCraftEventWithChangingSlimefunItem() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "CHANGING_ITEM", new CustomItemStack(Material.DIAMOND, "&dChanging Diamond")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "CHANGING_ITEM", CustomItemStack.create(Material.DIAMOND, "&dChanging Diamond")); item.register(plugin); item.setUseableInWorkbench(true); @@ -131,7 +131,7 @@ void testPreCraftEventWithoutSlimefunItems() { @Test void testPreCraftEventWithSlimefunItem() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MOCK_DIAMOND2", new CustomItemStack(Material.DIAMOND, "&cMock Diamond")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MOCK_DIAMOND2", CustomItemStack.create(Material.DIAMOND, "&cMock Diamond")); item.register(plugin); PrepareItemCraftEvent event = mockPreCraftingEvent(item.getItem()); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestGrindstoneListener.java b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestGrindstoneListener.java index ff604beb04..fa62fca496 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestGrindstoneListener.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestGrindstoneListener.java @@ -66,7 +66,7 @@ void testGrindStoneWithoutSlimefunItems() { @Test void testGrindStoneWithSlimefunItem() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "ENCHANTED_MOCK_BOOK", new CustomItemStack(Material.ENCHANTED_BOOK, "&6Mock")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "ENCHANTED_MOCK_BOOK", CustomItemStack.create(Material.ENCHANTED_BOOK, "&6Mock")); item.register(plugin); InventoryClickEvent event = mockGrindStoneEvent(item.getItem()); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestIronGolemListener.java b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestIronGolemListener.java index b536f6b00a..2877ee683b 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestIronGolemListener.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestIronGolemListener.java @@ -78,7 +78,7 @@ void testWithIron() { @Test @DisplayName("Test Iron Golem Healing with Slimefun Items being cancelled") void testWithSlimefunIron() { - SlimefunItem slimefunItem = TestUtilities.mockSlimefunItem(plugin, "SLIMEFUN_IRON", new CustomItemStack(Material.IRON_INGOT, "&cSlimefun Iron")); + SlimefunItem slimefunItem = TestUtilities.mockSlimefunItem(plugin, "SLIMEFUN_IRON", CustomItemStack.create(Material.IRON_INGOT, "&cSlimefun Iron")); slimefunItem.register(plugin); // The Event should be cancelled, we do not wanna use Slimefun Items for this diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestItemPickupListener.java b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestItemPickupListener.java index 8af24cd9b0..b5f35bccfa 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestItemPickupListener.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestItemPickupListener.java @@ -83,9 +83,9 @@ void testAltarProbeForEntities(boolean flag) { ItemStack stack; if (flag) { - stack = new CustomItemStack(Material.DIAMOND, AncientPedestal.ITEM_PREFIX + System.nanoTime()); + stack = CustomItemStack.create(Material.DIAMOND, AncientPedestal.ITEM_PREFIX + System.nanoTime()); } else { - stack = new CustomItemStack(Material.DIAMOND, "&5Just a normal named diamond"); + stack = CustomItemStack.create(Material.DIAMOND, "&5Just a normal named diamond"); } AtomicBoolean removed = new AtomicBoolean(false); @@ -111,9 +111,9 @@ void testAltarProbeForInventories(boolean flag) { ItemStack stack; if (flag) { - stack = new CustomItemStack(Material.DIAMOND, AncientPedestal.ITEM_PREFIX + System.nanoTime()); + stack = CustomItemStack.create(Material.DIAMOND, AncientPedestal.ITEM_PREFIX + System.nanoTime()); } else { - stack = new CustomItemStack(Material.DIAMOND, "&5Just a normal named diamond"); + stack = CustomItemStack.create(Material.DIAMOND, "&5Just a normal named diamond"); } AtomicBoolean removed = new AtomicBoolean(false); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestMultiblockListener.java b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestMultiblockListener.java index 55f9a5e5b6..e0420d1645 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestMultiblockListener.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestMultiblockListener.java @@ -37,7 +37,7 @@ public static void load() { server = MockBukkit.mock(); plugin = MockBukkit.load(Slimefun.class); listener = new MultiBlockListener(plugin); - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MULTIBLOCK_LISTENER_TEST", new CustomItemStack(Material.DIAMOND, "&9Some multiblock item")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MULTIBLOCK_LISTENER_TEST", CustomItemStack.create(Material.DIAMOND, "&9Some multiblock item")); multiblock = new MultiBlock(item, new Material[] { null, Material.EMERALD_BLOCK, null, null, Material.DIAMOND_BLOCK, null, null, Material.LAPIS_BLOCK, null }, BlockFace.SELF); Slimefun.getRegistry().getMultiBlocks().add(multiblock); } diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestPiglinListener.java b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestPiglinListener.java index d9e2b1fb87..2c912148cf 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestPiglinListener.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestPiglinListener.java @@ -81,7 +81,7 @@ void testPiglinPickup() { @Test void testPiglinPickupWithSlimefunItem() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "PIGLIN_PICKUP_MOCK", new CustomItemStack(Material.GOLD_INGOT, "&6Piglin Bait")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "PIGLIN_PICKUP_MOCK", CustomItemStack.create(Material.GOLD_INGOT, "&6Piglin Bait")); item.register(plugin); EntityPickupItemEvent event = createPickupEvent(item.getItem()); @@ -100,7 +100,7 @@ void testPiglinInteract(EquipmentSlot hand) { @ParameterizedTest @EnumSource(value = EquipmentSlot.class, names = { "HAND", "OFF_HAND" }) void testPiglinInteractWithSlimefunItem(EquipmentSlot hand) { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "PIGLIN_GIVE_" + hand.name(), new CustomItemStack(Material.GOLD_INGOT, "&6Piglin Bait")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "PIGLIN_GIVE_" + hand.name(), CustomItemStack.create(Material.GOLD_INGOT, "&6Piglin Bait")); item.register(plugin); PlayerInteractEntityEvent event = createInteractEvent(hand, item.getItem()); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestSmithingTableListener.java b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestSmithingTableListener.java index 3c57ed5060..4c02f5864b 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestSmithingTableListener.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestSmithingTableListener.java @@ -46,9 +46,9 @@ public static void load() { Slimefun plugin = MockBukkit.load(Slimefun.class); listener = new SmithingTableListener(plugin); - slimefunTool = TestUtilities.mockSlimefunItem(plugin, "MOCK_DIAMOND_SWORD", new CustomItemStack(Material.DIAMOND_SWORD, "&6Mock")); - slimefunIngot = TestUtilities.mockSlimefunItem(plugin, "MOCK_NETHERITE_INGOT", new CustomItemStack(Material.NETHERITE_INGOT, "&6Mock")); - usableSlimefunIngot = TestUtilities.mockSlimefunItem(plugin, "MOCK_NETHERITE_INGOT_USABLE", new CustomItemStack(Material.NETHERITE_INGOT, "&6Mock")); + slimefunTool = TestUtilities.mockSlimefunItem(plugin, "MOCK_DIAMOND_SWORD", CustomItemStack.create(Material.DIAMOND_SWORD, "&6Mock")); + slimefunIngot = TestUtilities.mockSlimefunItem(plugin, "MOCK_NETHERITE_INGOT", CustomItemStack.create(Material.NETHERITE_INGOT, "&6Mock")); + usableSlimefunIngot = TestUtilities.mockSlimefunItem(plugin, "MOCK_NETHERITE_INGOT_USABLE", CustomItemStack.create(Material.NETHERITE_INGOT, "&6Mock")); usableSlimefunIngot.setUseableInWorkbench(true); vanillaTool = TestUtilities.mockVanillaItem(plugin, Material.DIAMOND_SWORD, true); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestSoulboundListener.java b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestSoulboundListener.java index ad0e2fc916..d9b0e7ae65 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestSoulboundListener.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestSoulboundListener.java @@ -44,7 +44,7 @@ public static void unload() { @DisplayName("Test if the soulbound item is dropped or not") void testItemDrop(boolean soulbound) { PlayerMock player = server.addPlayer(); - ItemStack item = new CustomItemStack(Material.DIAMOND_SWORD, "&4Cool Sword"); + ItemStack item = CustomItemStack.create(Material.DIAMOND_SWORD, "&4Cool Sword"); SlimefunUtils.setSoulbound(item, soulbound); player.getInventory().setItem(6, item); player.setHealth(0); @@ -83,7 +83,7 @@ void testItemDropIfItemDisabled(boolean enabled) { @DisplayName("Test if soulbound item is returned to player") void testItemRecover(boolean soulbound) { PlayerMock player = server.addPlayer(); - ItemStack item = new CustomItemStack(Material.DIAMOND_SWORD, "&4Cool Sword"); + ItemStack item = CustomItemStack.create(Material.DIAMOND_SWORD, "&4Cool Sword"); SlimefunUtils.setSoulbound(item, soulbound); player.getInventory().setItem(6, item); player.setHealth(0); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestVillagerTradingListener.java b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestVillagerTradingListener.java index da15c02de0..4dc145ba9c 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestVillagerTradingListener.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestVillagerTradingListener.java @@ -68,7 +68,7 @@ void testTradingWithoutSlimefunItems() { @Test void testTradingWithSlimefunItem() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MOCKED_FAKE_EMERALD", new CustomItemStack(Material.EMERALD, "&aFake Emerald")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MOCKED_FAKE_EMERALD", CustomItemStack.create(Material.EMERALD, "&aFake Emerald")); item.register(plugin); InventoryClickEvent event = mockClickEvent(item.getItem()); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/registration/TestItemGroups.java b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/registration/TestItemGroups.java index d290992ff9..bdaa4a1d25 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/registration/TestItemGroups.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/registration/TestItemGroups.java @@ -49,7 +49,7 @@ public static void unload() { @Test @DisplayName("Test the Getters for ItemGroup") void testItemGroupGetters() { - ItemGroup itemGroup = new ItemGroup(new NamespacedKey(plugin, "getter_test"), new CustomItemStack(Material.DIAMOND_AXE, "&6Testing")); + ItemGroup itemGroup = new ItemGroup(new NamespacedKey(plugin, "getter_test"), CustomItemStack.create(Material.DIAMOND_AXE, "&6Testing")); Assertions.assertEquals(3, itemGroup.getTier()); Assertions.assertEquals(new NamespacedKey(Slimefun.instance(), "getter_test"), itemGroup.getKey()); @@ -64,8 +64,8 @@ void testItemGroupGetters() { @Test @DisplayName("Test adding an item to a ItemGroup") void testAddItem() { - ItemGroup itemGroup = new ItemGroup(new NamespacedKey(plugin, "items_test"), new CustomItemStack(Material.DIAMOND_AXE, "&6Testing")); - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "ITEM_GROUPS_TEST_ITEM", new CustomItemStack(Material.BAMBOO, "&6Test Bamboo")); + ItemGroup itemGroup = new ItemGroup(new NamespacedKey(plugin, "items_test"), CustomItemStack.create(Material.DIAMOND_AXE, "&6Testing")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "ITEM_GROUPS_TEST_ITEM", CustomItemStack.create(Material.BAMBOO, "&6Test Bamboo")); item.setItemGroup(itemGroup); item.register(plugin); item.load(); @@ -89,7 +89,7 @@ void testHidden() { // Empty Item Groups are also hidden Assertions.assertFalse(group.isVisible(player)); - SlimefunItem disabledItem = TestUtilities.mockSlimefunItem(plugin, "DISABLED_ITEM_GROUP_ITEM", new CustomItemStack(Material.BEETROOT, "&4Disabled")); + SlimefunItem disabledItem = TestUtilities.mockSlimefunItem(plugin, "DISABLED_ITEM_GROUP_ITEM", CustomItemStack.create(Material.BEETROOT, "&4Disabled")); Slimefun.getItemCfg().setValue("DISABLED_ITEM_GROUP_ITEM.enabled", false); disabledItem.setItemGroup(group); disabledItem.register(plugin); @@ -98,7 +98,7 @@ void testHidden() { // A disabled Item should also make the ItemGroup hide Assertions.assertFalse(group.isVisible(player)); - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "ITEM_GROUP_HIDDEN_TEST", new CustomItemStack(Material.BAMBOO, "&6Test Bamboo")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "ITEM_GROUP_HIDDEN_TEST", CustomItemStack.create(Material.BAMBOO, "&6Test Bamboo")); item.setItemGroup(group); item.setHidden(true); item.register(plugin); @@ -114,7 +114,7 @@ void testHidden() { @Test @DisplayName("Test ItemGroup#contains") void testContains() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "ITEM_GROUP_TEST_ITEM_2", new CustomItemStack(Material.BOW, "&6Test Bow")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "ITEM_GROUP_TEST_ITEM_2", CustomItemStack.create(Material.BOW, "&6Test Bow")); item.register(plugin); item.load(); @@ -130,14 +130,14 @@ void testContains() { @Test @DisplayName("Test LockedItemGroup parental locking") void testLockedItemGroupsParents() { - Assertions.assertThrows(IllegalArgumentException.class, () -> new LockedItemGroup(new NamespacedKey(plugin, "locked"), new CustomItemStack(Material.GOLD_NUGGET, "&6Locked Test"), (NamespacedKey) null)); + Assertions.assertThrows(IllegalArgumentException.class, () -> new LockedItemGroup(new NamespacedKey(plugin, "locked"), CustomItemStack.create(Material.GOLD_NUGGET, "&6Locked Test"), (NamespacedKey) null)); - ItemGroup group = new ItemGroup(new NamespacedKey(plugin, "unlocked"), new CustomItemStack(Material.EMERALD, "&5I am SHERlocked")); + ItemGroup group = new ItemGroup(new NamespacedKey(plugin, "unlocked"), CustomItemStack.create(Material.EMERALD, "&5I am SHERlocked")); group.register(plugin); - ItemGroup unregistered = new ItemGroup(new NamespacedKey(plugin, "unregistered"), new CustomItemStack(Material.EMERALD, "&5I am unregistered")); + ItemGroup unregistered = new ItemGroup(new NamespacedKey(plugin, "unregistered"), CustomItemStack.create(Material.EMERALD, "&5I am unregistered")); - LockedItemGroup locked = new LockedItemGroup(new NamespacedKey(plugin, "locked"), new CustomItemStack(Material.GOLD_NUGGET, "&6Locked Test"), group.getKey(), unregistered.getKey()); + LockedItemGroup locked = new LockedItemGroup(new NamespacedKey(plugin, "locked"), CustomItemStack.create(Material.GOLD_NUGGET, "&6Locked Test"), group.getKey(), unregistered.getKey()); locked.register(plugin); Assertions.assertTrue(locked.getParents().contains(group)); @@ -159,18 +159,18 @@ void testLockedItemGroupsUnlocking() throws InterruptedException { Player player = server.addPlayer(); PlayerProfile profile = TestUtilities.awaitProfile(player); - Assertions.assertThrows(IllegalArgumentException.class, () -> new LockedItemGroup(new NamespacedKey(plugin, "locked"), new CustomItemStack(Material.GOLD_NUGGET, "&6Locked Test"), (NamespacedKey) null)); + Assertions.assertThrows(IllegalArgumentException.class, () -> new LockedItemGroup(new NamespacedKey(plugin, "locked"), CustomItemStack.create(Material.GOLD_NUGGET, "&6Locked Test"), (NamespacedKey) null)); - ItemGroup group = new ItemGroup(new NamespacedKey(plugin, "parent"), new CustomItemStack(Material.EMERALD, "&5I am SHERlocked")); + ItemGroup group = new ItemGroup(new NamespacedKey(plugin, "parent"), CustomItemStack.create(Material.EMERALD, "&5I am SHERlocked")); group.register(plugin); - LockedItemGroup locked = new LockedItemGroup(new NamespacedKey(plugin, "locked2"), new CustomItemStack(Material.GOLD_NUGGET, "&6Locked Test"), group.getKey()); + LockedItemGroup locked = new LockedItemGroup(new NamespacedKey(plugin, "locked2"), CustomItemStack.create(Material.GOLD_NUGGET, "&6Locked Test"), group.getKey()); locked.register(plugin); // No Items, so it should be unlocked Assertions.assertTrue(locked.hasUnlocked(player, profile)); - SlimefunItem item = new SlimefunItem(group, new SlimefunItemStack("LOCKED_ITEMGROUP_TEST", new CustomItemStack(Material.LANTERN, "&6Test Item for locked categories")), RecipeType.NULL, new ItemStack[9]); + SlimefunItem item = new SlimefunItem(group, new SlimefunItemStack("LOCKED_ITEMGROUP_TEST", CustomItemStack.create(Material.LANTERN, "&6Test Item for locked categories")), RecipeType.NULL, new ItemStack[9]); item.register(plugin); item.load(); @@ -192,8 +192,8 @@ void testLockedItemGroupsUnlocking() throws InterruptedException { void ItemGroups() { // ItemGroup with current Month Month month = LocalDate.now().getMonth(); - SeasonalItemGroup group = new SeasonalItemGroup(new NamespacedKey(plugin, "seasonal"), month, 1, new CustomItemStack(Material.NETHER_STAR, "&cSeasonal Test")); - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "SEASONAL_ITEM", new CustomItemStack(Material.NETHER_STAR, "&dSeasonal Test Star")); + SeasonalItemGroup group = new SeasonalItemGroup(new NamespacedKey(plugin, "seasonal"), month, 1, CustomItemStack.create(Material.NETHER_STAR, "&cSeasonal Test")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "SEASONAL_ITEM", CustomItemStack.create(Material.NETHER_STAR, "&dSeasonal Test Star")); item.setItemGroup(group); item.register(plugin); item.load(); @@ -204,14 +204,14 @@ void ItemGroups() { Assertions.assertTrue(group.isVisible(player)); // ItemGroup with future Month - SeasonalItemGroup itemGroup2 = new SeasonalItemGroup(group.getKey(), month.plus(6), 1, new CustomItemStack(Material.MILK_BUCKET, "&dSeasonal Test")); + SeasonalItemGroup itemGroup2 = new SeasonalItemGroup(group.getKey(), month.plus(6), 1, CustomItemStack.create(Material.MILK_BUCKET, "&dSeasonal Test")); Assertions.assertFalse(itemGroup2.isVisible(player)); } @Test @DisplayName("Test the FlexItemGroup") void testFlexItemGroup() { - FlexItemGroup group = new FlexItemGroup(new NamespacedKey(plugin, "flex"), new CustomItemStack(Material.REDSTONE, "&4Weird flex but ok")) { + FlexItemGroup group = new FlexItemGroup(new NamespacedKey(plugin, "flex"), CustomItemStack.create(Material.REDSTONE, "&4Weird flex but ok")) { @Override public void open(Player p, PlayerProfile profile, SlimefunGuideMode layout) { diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/registration/TestItemHandlers.java b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/registration/TestItemHandlers.java index 4df0b505b9..945c1082aa 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/registration/TestItemHandlers.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/registration/TestItemHandlers.java @@ -39,7 +39,7 @@ public static void unload() { @Test @DisplayName("Test validation for Item Handlers") void testIllegalItemHandlers() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "ITEM_HANDLER_TEST", new CustomItemStack(Material.DIAMOND, "&cTest")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "ITEM_HANDLER_TEST", CustomItemStack.create(Material.DIAMOND, "&cTest")); item.register(plugin); Assertions.assertThrows(IllegalArgumentException.class, () -> item.addItemHandler()); @@ -50,7 +50,7 @@ void testIllegalItemHandlers() { @Test @DisplayName("Test calling an ItemHandler") void testItemHandler() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "ITEM_HANDLER_TEST_2", new CustomItemStack(Material.DIAMOND, "&cTest")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "ITEM_HANDLER_TEST_2", CustomItemStack.create(Material.DIAMOND, "&cTest")); MockItemHandler handler = new MockItemHandler(); item.addItemHandler(handler); @@ -72,12 +72,12 @@ void testItemHandler() { @DisplayName("Test validation for BowShootHandler") void testBowShootHandler() { BowShootHandler handler = (e, n) -> {}; - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "NOT_A_BOW", new CustomItemStack(Material.KELP, "&bNot a bow!")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "NOT_A_BOW", CustomItemStack.create(Material.KELP, "&bNot a bow!")); Optional exception = handler.validate(item); Assertions.assertTrue(exception.isPresent()); - SlimefunItem bow = TestUtilities.mockSlimefunItem(plugin, "A_BOW", new CustomItemStack(Material.BOW, "&bA bow!")); + SlimefunItem bow = TestUtilities.mockSlimefunItem(plugin, "A_BOW", CustomItemStack.create(Material.BOW, "&bA bow!")); Optional exception2 = handler.validate(bow); Assertions.assertFalse(exception2.isPresent()); } diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/registration/TestRechargeableItems.java b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/registration/TestRechargeableItems.java index 59938126f5..9dbde56faf 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/registration/TestRechargeableItems.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/registration/TestRechargeableItems.java @@ -55,7 +55,7 @@ void testInvalidItems() { @Test void testSetItemCharge() { Rechargeable rechargeable = mock("CHARGING_TEST", 10); - ItemStack item = new CustomItemStack(Material.REDSTONE_ORE, "&4Chargeable Item", "", LoreBuilder.powerCharged(0, 10)); + ItemStack item = CustomItemStack.create(Material.REDSTONE_ORE, "&4Chargeable Item", "", LoreBuilder.powerCharged(0, 10)); Assertions.assertEquals(0, rechargeable.getItemCharge(item)); @@ -69,7 +69,7 @@ void testSetItemCharge() { @Test void testItemChargeBounds() { Rechargeable rechargeable = mock("CHARGING_BOUNDS_TEST", 10); - ItemStack item = new CustomItemStack(Material.REDSTONE_BLOCK, "&4Chargeable Item with bounds", "", LoreBuilder.powerCharged(0, 10)); + ItemStack item = CustomItemStack.create(Material.REDSTONE_BLOCK, "&4Chargeable Item with bounds", "", LoreBuilder.powerCharged(0, 10)); Assertions.assertThrows(IllegalArgumentException.class, () -> rechargeable.setItemCharge(item, -1)); Assertions.assertThrows(IllegalArgumentException.class, () -> rechargeable.setItemCharge(item, -0.01F)); @@ -83,7 +83,7 @@ void testItemChargeBounds() { @Test void testAddItemCharge() { Rechargeable rechargeable = mock("CHARGING_BOUNDS_TEST", 10); - ItemStack item = new CustomItemStack(Material.REDSTONE_BLOCK, "&4Chargeable Item with additions", "", LoreBuilder.powerCharged(0, 10)); + ItemStack item = CustomItemStack.create(Material.REDSTONE_BLOCK, "&4Chargeable Item with additions", "", LoreBuilder.powerCharged(0, 10)); Assertions.assertTrue(rechargeable.addItemCharge(item, 10)); Assertions.assertEquals(10, rechargeable.getItemCharge(item)); @@ -94,7 +94,7 @@ void testAddItemCharge() { @Test void testAddItemChargeWithoutLore() { Rechargeable rechargeable = mock("CHARGING_NO_LORE_TEST", 10); - ItemStack item = new CustomItemStack(Material.REDSTONE_BLOCK, "&4Chargeable Item with no lore"); + ItemStack item = CustomItemStack.create(Material.REDSTONE_BLOCK, "&4Chargeable Item with no lore"); Assertions.assertEquals(0, rechargeable.getItemCharge(item)); @@ -108,7 +108,7 @@ void testAddItemChargeWithoutLore() { @Test void testRemoveItemCharge() { Rechargeable rechargeable = mock("CHARGING_BOUNDS_TEST", 10); - ItemStack item = new CustomItemStack(Material.REDSTONE_BLOCK, "&4Chargeable Item with removal", "", LoreBuilder.powerCharged(0, 10)); + ItemStack item = CustomItemStack.create(Material.REDSTONE_BLOCK, "&4Chargeable Item with removal", "", LoreBuilder.powerCharged(0, 10)); Assertions.assertFalse(rechargeable.removeItemCharge(item, 1)); @@ -122,7 +122,7 @@ void testRemoveItemCharge() { private RechargeableMock mock(String id, float capacity) { ItemGroup itemGroup = TestUtilities.getItemGroup(plugin, "rechargeable"); - return new RechargeableMock(itemGroup, new SlimefunItemStack(id, new CustomItemStack(Material.REDSTONE_LAMP, "&3" + id)), capacity); + return new RechargeableMock(itemGroup, new SlimefunItemStack(id, CustomItemStack.create(Material.REDSTONE_LAMP, "&3" + id)), capacity); } private class RechargeableMock extends SlimefunItem implements Rechargeable { diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/registration/TestSlimefunItemRegistration.java b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/registration/TestSlimefunItemRegistration.java index 1c0d4c24d9..577bbd0318 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/registration/TestSlimefunItemRegistration.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/registration/TestSlimefunItemRegistration.java @@ -38,7 +38,7 @@ public static void unload() { @DisplayName("Test SlimefunItem registering properly") void testSuccessfulRegistration() { String id = "TEST_ITEM"; - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, id, new CustomItemStack(Material.DIAMOND, "&cTest")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, id, CustomItemStack.create(Material.DIAMOND, "&cTest")); Assertions.assertEquals(ItemState.UNREGISTERED, item.getState()); @@ -53,7 +53,7 @@ void testSuccessfulRegistration() { @Test @DisplayName("Test disabled SlimefunItem being disabled") void testDisabledItem() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "DISABLED_ITEM", new CustomItemStack(Material.DIAMOND, "&cTest")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "DISABLED_ITEM", CustomItemStack.create(Material.DIAMOND, "&cTest")); Slimefun.getItemCfg().setValue("DISABLED_ITEM.enabled", false); item.register(plugin); @@ -75,10 +75,10 @@ void testVanillaItemFallback() { @Test @DisplayName("Test id conflicts being handled with an exception") void testIdConflict() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "DUPLICATE_ID", new CustomItemStack(Material.DIAMOND, "&cTest")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "DUPLICATE_ID", CustomItemStack.create(Material.DIAMOND, "&cTest")); item.register(plugin); - SlimefunItem item2 = TestUtilities.mockSlimefunItem(plugin, "DUPLICATE_ID", new CustomItemStack(Material.DIAMOND, "&cTest")); + SlimefunItem item2 = TestUtilities.mockSlimefunItem(plugin, "DUPLICATE_ID", CustomItemStack.create(Material.DIAMOND, "&cTest")); Assertions.assertThrows(IdConflictException.class, () -> item2.register(plugin)); Assertions.assertEquals(ItemState.ENABLED, item.getState()); @@ -88,7 +88,7 @@ void testIdConflict() { @Test @DisplayName("Test ItemGroup registration when registering an item") void testItemGroupRegistration() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "ITEMGROUP_TEST", new CustomItemStack(Material.DIAMOND, "&cTest")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "ITEMGROUP_TEST", CustomItemStack.create(Material.DIAMOND, "&cTest")); item.register(plugin); item.load(); @@ -96,7 +96,7 @@ void testItemGroupRegistration() { Assertions.assertThrows(IllegalArgumentException.class, () -> item.setItemGroup(null)); ItemGroup itemGroup = item.getItemGroup(); - ItemGroup itemGroup2 = new ItemGroup(new NamespacedKey(plugin, "test2"), new CustomItemStack(Material.OBSIDIAN, "&6Test 2")); + ItemGroup itemGroup2 = new ItemGroup(new NamespacedKey(plugin, "test2"), CustomItemStack.create(Material.OBSIDIAN, "&6Test 2")); Assertions.assertTrue(itemGroup.contains(item)); Assertions.assertFalse(itemGroup2.contains(item)); @@ -111,7 +111,7 @@ void testItemGroupRegistration() { @Test @DisplayName("Test hidden items being hidden") void testHiddenItem() { - SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "HIDDEN_TEST", new CustomItemStack(Material.DIAMOND, "&cTest")); + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "HIDDEN_TEST", CustomItemStack.create(Material.DIAMOND, "&cTest")); item.setHidden(true); item.register(plugin); item.load(); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/test/TestUtilities.java b/src/test/java/io/github/thebusybiscuit/slimefun4/test/TestUtilities.java index edd6a458af..a46d933d54 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/test/TestUtilities.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/test/TestUtilities.java @@ -57,19 +57,19 @@ private TestUtilities() {} @ParametersAreNonnullByDefault public static @Nonnull ItemGroup getItemGroup(Plugin plugin, String name) { - return new ItemGroup(new NamespacedKey(plugin, name), new CustomItemStack(Material.NETHER_STAR, "&4Test ItemGroup")); + return new ItemGroup(new NamespacedKey(plugin, name), CustomItemStack.create(Material.NETHER_STAR, "&4Test ItemGroup")); } @ParametersAreNonnullByDefault public static @Nonnull SlimefunItem mockSlimefunItem(Plugin plugin, String id, ItemStack item) { - ItemGroup itemGroup = new ItemGroup(new NamespacedKey(plugin, "test"), new CustomItemStack(Material.EMERALD, "&4Test ItemGroup")); + ItemGroup itemGroup = new ItemGroup(new NamespacedKey(plugin, "test"), CustomItemStack.create(Material.EMERALD, "&4Test ItemGroup")); return new MockSlimefunItem(itemGroup, item, id); } @ParametersAreNonnullByDefault public static @Nonnull VanillaItem mockVanillaItem(Plugin plugin, Material type, boolean enabled) { - ItemGroup itemGroup = new ItemGroup(new NamespacedKey(plugin, "test"), new CustomItemStack(Material.EMERALD, "&4Test ItemGroup")); + ItemGroup itemGroup = new ItemGroup(new NamespacedKey(plugin, "test"), CustomItemStack.create(Material.EMERALD, "&4Test ItemGroup")); VanillaItem item = new VanillaItem(itemGroup, new ItemStack(type), type.name(), RecipeType.NULL, new ItemStack[9]); Slimefun.getItemCfg().setValue(type.name() + ".enabled", enabled); return item; @@ -105,7 +105,7 @@ public static World createWorld(ServerMock server) { Slimefun.getRegistry().getWorlds().put(world.getName(), new BlockStorage(world)); return world; } - + public static Block placeSlimefunBlock(ServerMock server, ItemStack item, World world, Player player) { int x = TestUtilities.randomInt(); int z = TestUtilities.randomInt(); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestItemStackWrapper.java b/src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestItemStackWrapper.java index 510584bbfc..76aaa5b944 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestItemStackWrapper.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestItemStackWrapper.java @@ -35,7 +35,7 @@ public static void unload() { @Test @DisplayName("Test if an ItemStackWrappers can be compared properly (With ItemMeta)") void testEqualityWithItemMeta() { - ItemStack item = new CustomItemStack(Material.LAVA_BUCKET, "&4SuperHot.exe", "", "&6Hello"); + ItemStack item = CustomItemStack.create(Material.LAVA_BUCKET, "&4SuperHot.exe", "", "&6Hello"); ItemStackWrapper wrapper = ItemStackWrapper.wrap(item); Assertions.assertEquals(item.getType(), wrapper.getType()); @@ -59,7 +59,7 @@ void testEqualityWithoutItemMeta() { @Test @DisplayName("Test if an ItemStackWrapper is immutable") void testImmutability() { - ItemStack item = new CustomItemStack(Material.LAVA_BUCKET, "&4SuperHot.exe", "", "&6Hello"); + ItemStack item = CustomItemStack.create(Material.LAVA_BUCKET, "&4SuperHot.exe", "", "&6Hello"); ItemStackWrapper wrapper = ItemStackWrapper.wrap(item); Assertions.assertThrows(UnsupportedOperationException.class, () -> wrapper.setType(Material.BEDROCK)); @@ -76,7 +76,7 @@ void testImmutability() { void testWrapperChecking() { Assertions.assertThrows(IllegalArgumentException.class, () -> ItemStackWrapper.wrap(null)); Assertions.assertThrows(IllegalArgumentException.class, () -> ItemStackWrapper.forceWrap(null)); - ItemStack item = new CustomItemStack(Material.IRON_INGOT, "A Name", "line 1", "line2"); + ItemStack item = CustomItemStack.create(Material.IRON_INGOT, "A Name", "line 1", "line2"); ItemStackWrapper wrapper = ItemStackWrapper.wrap(item); ItemStackWrapper secondWrap = ItemStackWrapper.wrap(wrapper); // We want to check that the wrapper returned is of reference equality @@ -90,7 +90,7 @@ void testWrapperChecking() { @Test @DisplayName("Test wrapping an ItemStack Array") void testWrapArray() { - ItemStack[] items = { new ItemStack(Material.DIAMOND), null, new ItemStack(Material.EMERALD), new CustomItemStack(Material.REDSTONE, "&4Firey thing", "with lore :o") }; + ItemStack[] items = { new ItemStack(Material.DIAMOND), null, new ItemStack(Material.EMERALD), CustomItemStack.create(Material.REDSTONE, "&4Firey thing", "with lore :o") }; ItemStackWrapper[] wrappers = ItemStackWrapper.wrapArray(items); Assertions.assertEquals(items.length, wrappers.length); @@ -111,7 +111,7 @@ void testWrapArray() { @Test @DisplayName("Test wrapping an ItemStack List") void testWrapList() { - List items = Arrays.asList(new ItemStack(Material.DIAMOND), null, new ItemStack(Material.EMERALD), new CustomItemStack(Material.REDSTONE, "&4Firey thing", "with lore :o")); + List items = Arrays.asList(new ItemStack(Material.DIAMOND), null, new ItemStack(Material.EMERALD), CustomItemStack.create(Material.REDSTONE, "&4Firey thing", "with lore :o")); List wrappers = ItemStackWrapper.wrapList(items); Assertions.assertEquals(items.size(), wrappers.size()); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestSoulboundItem.java b/src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestSoulboundItem.java index 9720494842..391fd6c2e0 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestSoulboundItem.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestSoulboundItem.java @@ -49,7 +49,7 @@ void testNullAndAir() { @Test @DisplayName("Test whether an Item can be marked as soulbound") void testSetSoulbound() { - ItemStack item = new CustomItemStack(Material.DIAMOND, "&cI wanna be soulbound!"); + ItemStack item = CustomItemStack.create(Material.DIAMOND, "&cI wanna be soulbound!"); Assertions.assertFalse(SlimefunUtils.isSoulbound(item)); @@ -65,7 +65,7 @@ void testSetSoulbound() { @Test @DisplayName("Make sure that marking an item as soulbound twice has no effect") void testDoubleCalls() { - ItemStack item = new CustomItemStack(Material.DIAMOND, "&cI wanna be soulbound!"); + ItemStack item = CustomItemStack.create(Material.DIAMOND, "&cI wanna be soulbound!"); SlimefunUtils.setSoulbound(item, true); SlimefunUtils.setSoulbound(item, true); @@ -83,7 +83,7 @@ void testDoubleCalls() { @Test @DisplayName("Test that soulbound Slimefun Items are soulbound") void testSoulboundSlimefunItem() { - SlimefunItem item = new SoulboundMock(new ItemGroup(new NamespacedKey(plugin, "soulbound_itemgroup"), new CustomItemStack(Material.REDSTONE, "&4Walshrus forever"))); + SlimefunItem item = new SoulboundMock(new ItemGroup(new NamespacedKey(plugin, "soulbound_itemgroup"), CustomItemStack.create(Material.REDSTONE, "&4Walshrus forever"))); item.register(plugin); Assertions.assertTrue(SlimefunUtils.isSoulbound(item.getItem()));