Delombok 2/? - Removed @UtilityClas

This commit is contained in:
Auxilor
2021-11-10 18:39:30 +00:00
parent 3811b01e81
commit ec09dbddf4
15 changed files with 151 additions and 121 deletions

View File

@@ -1,6 +1,5 @@
package com.willfp.eco.core;
import lombok.experimental.UtilityClass;
import org.apache.commons.lang.Validate;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
@@ -10,20 +9,19 @@ import org.jetbrains.annotations.NotNull;
*
* @see Handler
*/
@UtilityClass
public class Eco {
public final class Eco {
/**
* Instance of eco handler.
*/
@ApiStatus.Internal
private Handler handler;
private static Handler handler;
/**
* Set the handler.
* @param handler The handler.
*/
@ApiStatus.Internal
public void setHandler(@NotNull final Handler handler) {
public static void setHandler(@NotNull final Handler handler) {
Validate.isTrue(Eco.handler == null, "Already initialized!");
Eco.handler = handler;
@@ -46,7 +44,11 @@ public class Eco {
* @return The handler.
*/
@ApiStatus.Internal
public Handler getHandler() {
public static Handler getHandler() {
return handler;
}
private Eco() {
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
}
}

View File

@@ -1,6 +1,5 @@
package com.willfp.eco.core.display;
import lombok.experimental.UtilityClass;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.ApiStatus;
@@ -10,8 +9,7 @@ import org.jetbrains.annotations.Nullable;
/**
* Utility class to manage client-side item display.
*/
@UtilityClass
public class Display {
public final class Display {
/**
* The prefix for client-side lore lines.
*/
@@ -28,7 +26,7 @@ public class Display {
* @param itemStack The item.
* @return The ItemStack.
*/
public ItemStack display(@NotNull final ItemStack itemStack) {
public static ItemStack display(@NotNull final ItemStack itemStack) {
return display(itemStack, null);
}
@@ -39,8 +37,8 @@ public class Display {
* @param player The player.
* @return The ItemStack.
*/
public ItemStack display(@NotNull final ItemStack itemStack,
@Nullable final Player player) {
public static ItemStack display(@NotNull final ItemStack itemStack,
@Nullable final Player player) {
return handler.display(itemStack, player);
}
@@ -50,7 +48,7 @@ public class Display {
* @param itemStack The item.
* @return The ItemStack.
*/
public ItemStack displayAndFinalize(@NotNull final ItemStack itemStack) {
public static ItemStack displayAndFinalize(@NotNull final ItemStack itemStack) {
return finalize(display(itemStack, null));
}
@@ -61,7 +59,7 @@ public class Display {
* @param player The player.
* @return The ItemStack.
*/
public ItemStack displayAndFinalize(@NotNull final ItemStack itemStack,
public static ItemStack displayAndFinalize(@NotNull final ItemStack itemStack,
@Nullable final Player player) {
return finalize(display(itemStack, player));
}
@@ -72,7 +70,7 @@ public class Display {
* @param itemStack The item.
* @return The ItemStack.
*/
public ItemStack revert(@NotNull final ItemStack itemStack) {
public static ItemStack revert(@NotNull final ItemStack itemStack) {
return handler.revert(itemStack);
}
@@ -82,7 +80,7 @@ public class Display {
* @param itemStack The item.
* @return The ItemStack.
*/
public ItemStack finalize(@NotNull final ItemStack itemStack) {
public static ItemStack finalize(@NotNull final ItemStack itemStack) {
return handler.finalize(itemStack);
}
@@ -92,7 +90,7 @@ public class Display {
* @param itemStack The item.
* @return The ItemStack.
*/
public ItemStack unfinalize(@NotNull final ItemStack itemStack) {
public static ItemStack unfinalize(@NotNull final ItemStack itemStack) {
return handler.unfinalize(itemStack);
}
@@ -102,7 +100,7 @@ public class Display {
* @param itemStack The item.
* @return If finalized.
*/
public boolean isFinalized(@NotNull final ItemStack itemStack) {
public static boolean isFinalized(@NotNull final ItemStack itemStack) {
return handler.isFinalized(itemStack);
}
@@ -111,7 +109,7 @@ public class Display {
*
* @param module The module.
*/
public void registerDisplayModule(@NotNull final DisplayModule module) {
public static void registerDisplayModule(@NotNull final DisplayModule module) {
handler.registerDisplayModule(module);
}
@@ -176,4 +174,8 @@ public class Display {
Display.handler = handler;
}
private Display() {
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
}
}

View File

@@ -1,6 +1,5 @@
package com.willfp.eco.core.integrations.afk;
import lombok.experimental.UtilityClass;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
@@ -10,20 +9,19 @@ import java.util.Set;
/**
* Class to handle afk integrations.
*/
@UtilityClass
public class AFKManager {
public final class AFKManager {
/**
* A set of all registered integrations.
*/
private final Set<AFKWrapper> registered = new HashSet<>();
private static final Set<AFKWrapper> REGISTERED = new HashSet<>();
/**
* Register a new integration.
*
* @param integration The integration to register.
*/
public void register(@NotNull final AFKWrapper integration) {
registered.add(integration);
public static void register(@NotNull final AFKWrapper integration) {
REGISTERED.add(integration);
}
/**
@@ -32,8 +30,8 @@ public class AFKManager {
* @param player The player.
* @return If afk.
*/
public boolean isAfk(@NotNull final Player player) {
for (AFKWrapper afkWrapper : registered) {
public static boolean isAfk(@NotNull final Player player) {
for (AFKWrapper afkWrapper : REGISTERED) {
if (afkWrapper.isAfk(player)) {
return true;
}
@@ -41,4 +39,8 @@ public class AFKManager {
return false;
}
private AFKManager() {
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
}
}

View File

@@ -1,7 +1,6 @@
package com.willfp.eco.core.integrations.anticheat;
import com.willfp.eco.core.EcoPlugin;
import lombok.experimental.UtilityClass;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.jetbrains.annotations.NotNull;
@@ -12,12 +11,11 @@ import java.util.Set;
/**
* Class to handle anticheat integrations.
*/
@UtilityClass
public class AnticheatManager {
public final class AnticheatManager {
/**
* A set of all registered anticheats.
*/
private final Set<AnticheatWrapper> anticheats = new HashSet<>();
private static final Set<AnticheatWrapper> ANTICHEATS = new HashSet<>();
/**
* Register a new anticheat.
@@ -25,12 +23,12 @@ public class AnticheatManager {
* @param plugin The plugin.
* @param anticheat The anticheat to register.
*/
public void register(@NotNull final EcoPlugin plugin,
public static void register(@NotNull final EcoPlugin plugin,
@NotNull final AnticheatWrapper anticheat) {
if (anticheat instanceof Listener) {
plugin.getEventManager().registerListener((Listener) anticheat);
}
anticheats.add(anticheat);
ANTICHEATS.add(anticheat);
}
/**
@@ -38,8 +36,8 @@ public class AnticheatManager {
*
* @param player The player to exempt.
*/
public void exemptPlayer(@NotNull final Player player) {
anticheats.forEach(anticheat -> anticheat.exempt(player));
public static void exemptPlayer(@NotNull final Player player) {
ANTICHEATS.forEach(anticheat -> anticheat.exempt(player));
}
/**
@@ -48,7 +46,11 @@ public class AnticheatManager {
*
* @param player The player to remove the exemption.
*/
public void unexemptPlayer(@NotNull final Player player) {
anticheats.forEach(anticheat -> anticheat.unexempt(player));
public static void unexemptPlayer(@NotNull final Player player) {
ANTICHEATS.forEach(anticheat -> anticheat.unexempt(player));
}
private AnticheatManager() {
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
}
}

View File

@@ -1,6 +1,5 @@
package com.willfp.eco.core.integrations.antigrief;
import lombok.experimental.UtilityClass;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.LivingEntity;
@@ -13,20 +12,19 @@ import java.util.Set;
/**
* Class to handle antigrief integrations.
*/
@UtilityClass
public class AntigriefManager {
public final class AntigriefManager {
/**
* Registered antigriefs.
*/
private final Set<AntigriefWrapper> registered = new HashSet<>();
private static final Set<AntigriefWrapper> REGISTERED = new HashSet<>();
/**
* Register a new AntiGrief/Land Management integration.
*
* @param antigrief The integration to register.
*/
public void register(@NotNull final AntigriefWrapper antigrief) {
registered.add(antigrief);
public static void register(@NotNull final AntigriefWrapper antigrief) {
REGISTERED.add(antigrief);
}
/**
@@ -34,9 +32,9 @@ public class AntigriefManager {
*
* @param antigrief The integration to unregister.
*/
public void unregister(@NotNull final AntigriefWrapper antigrief) {
registered.removeIf(it -> it.getPluginName().equalsIgnoreCase(antigrief.getPluginName()));
registered.remove(antigrief);
public static void unregister(@NotNull final AntigriefWrapper antigrief) {
REGISTERED.removeIf(it -> it.getPluginName().equalsIgnoreCase(antigrief.getPluginName()));
REGISTERED.remove(antigrief);
}
/**
@@ -46,9 +44,9 @@ public class AntigriefManager {
* @param block The block.
* @return If player can break block.
*/
public boolean canBreakBlock(@NotNull final Player player,
public static boolean canBreakBlock(@NotNull final Player player,
@NotNull final Block block) {
return registered.stream().allMatch(antigriefWrapper -> antigriefWrapper.canBreakBlock(player, block));
return REGISTERED.stream().allMatch(antigriefWrapper -> antigriefWrapper.canBreakBlock(player, block));
}
/**
@@ -58,9 +56,9 @@ public class AntigriefManager {
* @param location The location.
* @return If player can create explosion.
*/
public boolean canCreateExplosion(@NotNull final Player player,
public static boolean canCreateExplosion(@NotNull final Player player,
@NotNull final Location location) {
return registered.stream().allMatch(antigriefWrapper -> antigriefWrapper.canCreateExplosion(player, location));
return REGISTERED.stream().allMatch(antigriefWrapper -> antigriefWrapper.canCreateExplosion(player, location));
}
/**
@@ -70,9 +68,9 @@ public class AntigriefManager {
* @param block The block.
* @return If player can place block.
*/
public boolean canPlaceBlock(@NotNull final Player player,
public static boolean canPlaceBlock(@NotNull final Player player,
@NotNull final Block block) {
return registered.stream().allMatch(antigriefWrapper -> antigriefWrapper.canPlaceBlock(player, block));
return REGISTERED.stream().allMatch(antigriefWrapper -> antigriefWrapper.canPlaceBlock(player, block));
}
/**
@@ -82,8 +80,12 @@ public class AntigriefManager {
* @param victim The victim.
* @return If player can injure.
*/
public boolean canInjure(@NotNull final Player player,
public static boolean canInjure(@NotNull final Player player,
@NotNull final LivingEntity victim) {
return registered.stream().allMatch(antigriefWrapper -> antigriefWrapper.canInjure(player, victim));
return REGISTERED.stream().allMatch(antigriefWrapper -> antigriefWrapper.canInjure(player, victim));
}
private AntigriefManager() {
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
}
}

View File

@@ -1,6 +1,5 @@
package com.willfp.eco.core.integrations.customitems;
import lombok.experimental.UtilityClass;
import org.jetbrains.annotations.NotNull;
import java.util.HashSet;
@@ -9,20 +8,19 @@ import java.util.Set;
/**
* Class to handle custom item integrations.
*/
@UtilityClass
public class CustomItemsManager {
public final class CustomItemsManager {
/**
* A set of all registered integrations.
*/
private final Set<CustomItemsWrapper> registered = new HashSet<>();
private static final Set<CustomItemsWrapper> REGISTERED = new HashSet<>();
/**
* Register a new integration.
*
* @param integration The integration to register.
*/
public void register(@NotNull final CustomItemsWrapper integration) {
registered.add(integration);
public static void register(@NotNull final CustomItemsWrapper integration) {
REGISTERED.add(integration);
}
/**
@@ -30,9 +28,13 @@ public class CustomItemsManager {
*
* @see com.willfp.eco.core.items.Items
*/
public void registerAllItems() {
for (CustomItemsWrapper customItemsWrapper : registered) {
public static void registerAllItems() {
for (CustomItemsWrapper customItemsWrapper : REGISTERED) {
customItemsWrapper.registerAllItems();
}
}
private CustomItemsManager() {
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
}
}

View File

@@ -1,6 +1,5 @@
package com.willfp.eco.core.integrations.economy;
import lombok.experimental.UtilityClass;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;
@@ -10,19 +9,18 @@ import java.util.Set;
/**
* Class to handle economy.
*/
@UtilityClass
public class EconomyManager {
public final class EconomyManager {
/**
* A set of all registered integrations.
*/
private final Set<EconomyWrapper> registered = new HashSet<>();
private static final Set<EconomyWrapper> registered = new HashSet<>();
/**
* Register a new integration.
*
* @param integration The integration to register.
*/
public void register(@NotNull final EconomyWrapper integration) {
public static void register(@NotNull final EconomyWrapper integration) {
registered.add(integration);
}
@@ -31,7 +29,7 @@ public class EconomyManager {
*
* @return If any economy.
*/
public boolean hasRegistrations() {
public static boolean hasRegistrations() {
return !registered.isEmpty();
}
@@ -42,7 +40,7 @@ public class EconomyManager {
* @param amount The amount.
* @return If the player has the amount.
*/
public boolean hasAmount(@NotNull final OfflinePlayer player,
public static boolean hasAmount(@NotNull final OfflinePlayer player,
final double amount) {
for (EconomyWrapper wrapper : registered) {
return wrapper.hasAmount(player, amount);
@@ -58,7 +56,7 @@ public class EconomyManager {
* @param amount The amount to give.
* @return If the transaction was a success.
*/
public boolean giveMoney(@NotNull final OfflinePlayer player,
public static boolean giveMoney(@NotNull final OfflinePlayer player,
final double amount) {
for (EconomyWrapper wrapper : registered) {
return wrapper.giveMoney(player, amount);
@@ -74,7 +72,7 @@ public class EconomyManager {
* @param amount The amount to remove.
* @return If the transaction was a success.
*/
public boolean removeMoney(@NotNull final OfflinePlayer player,
public static boolean removeMoney(@NotNull final OfflinePlayer player,
final double amount) {
for (EconomyWrapper wrapper : registered) {
return wrapper.removeMoney(player, amount);
@@ -89,11 +87,15 @@ public class EconomyManager {
* @param player The player.
* @return The balance.
*/
public double getBalance(@NotNull final OfflinePlayer player) {
public static double getBalance(@NotNull final OfflinePlayer player) {
for (EconomyWrapper wrapper : registered) {
return wrapper.getBalance(player);
}
return 0;
}
private EconomyManager() {
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
}
}

View File

@@ -1,6 +1,5 @@
package com.willfp.eco.core.integrations.hologram;
import lombok.experimental.UtilityClass;
import org.bukkit.Location;
import org.jetbrains.annotations.NotNull;
@@ -11,19 +10,18 @@ import java.util.Set;
/**
* Class to handle hologram integrations.
*/
@UtilityClass
public class HologramManager {
public final class HologramManager {
/**
* A set of all registered integrations.
*/
private final Set<HologramWrapper> registered = new HashSet<>();
private static final Set<HologramWrapper> registered = new HashSet<>();
/**
* Register a new integration.
*
* @param integration The integration to register.
*/
public void register(@NotNull final HologramWrapper integration) {
public static void register(@NotNull final HologramWrapper integration) {
registered.add(integration);
}
@@ -34,7 +32,7 @@ public class HologramManager {
* @param contents The contents for the hologram.
* @return The hologram.
*/
public Hologram createHologram(@NotNull final Location location,
public static Hologram createHologram(@NotNull final Location location,
@NotNull final List<String> contents) {
for (HologramWrapper wrapper : registered) {
return wrapper.createHologram(location, contents);
@@ -42,4 +40,8 @@ public class HologramManager {
return new DummyHologram();
}
private HologramManager() {
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
}
}

View File

@@ -1,6 +1,5 @@
package com.willfp.eco.core.integrations.mcmmo;
import lombok.experimental.UtilityClass;
import org.bukkit.block.Block;
import org.bukkit.event.Event;
import org.jetbrains.annotations.NotNull;
@@ -11,19 +10,18 @@ import java.util.Set;
/**
* Class to handle mcmmo integrations.
*/
@UtilityClass
public class McmmoManager {
public final class McmmoManager {
/**
* A set of all registered integrations.
*/
private final Set<McmmoWrapper> registered = new HashSet<>();
private static final Set<McmmoWrapper> registered = new HashSet<>();
/**
* Register a new integration.
*
* @param integration The integration to register.
*/
public void register(@NotNull final McmmoWrapper integration) {
public static void register(@NotNull final McmmoWrapper integration) {
registered.add(integration);
}
@@ -33,7 +31,7 @@ public class McmmoManager {
* @param block The block.
* @return The bonus drop count.
*/
public int getBonusDropCount(@NotNull final Block block) {
public static int getBonusDropCount(@NotNull final Block block) {
for (McmmoWrapper mcmmoWrapper : registered) {
return mcmmoWrapper.getBonusDropCount(block);
}
@@ -46,10 +44,14 @@ public class McmmoManager {
* @param event The event to check.
* @return If the event is fake.
*/
public boolean isFake(@NotNull final Event event) {
public static boolean isFake(@NotNull final Event event) {
for (McmmoWrapper mcmmoWrapper : registered) {
return mcmmoWrapper.isFake(event);
}
return false;
}
private McmmoManager() {
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
}
}

View File

@@ -1,6 +1,5 @@
package com.willfp.eco.core.integrations.placeholder;
import lombok.experimental.UtilityClass;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -13,8 +12,7 @@ import java.util.Set;
/**
* Class to handle placeholder integrations.
*/
@UtilityClass
public class PlaceholderManager {
public final class PlaceholderManager {
/**
* All registered placeholders.
*/
@@ -81,4 +79,8 @@ public class PlaceholderManager {
}
return processed;
}
private PlaceholderManager() {
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
}
}

View File

@@ -1,6 +1,5 @@
package com.willfp.eco.core.integrations.shop;
import lombok.experimental.UtilityClass;
import org.jetbrains.annotations.NotNull;
import java.util.HashSet;
@@ -9,28 +8,31 @@ import java.util.Set;
/**
* Class to handle shop integrations.
*/
@UtilityClass
public class ShopManager {
public final class ShopManager {
/**
* A set of all registered integrations.
*/
private final Set<ShopWrapper> registered = new HashSet<>();
private static final Set<ShopWrapper> registered = new HashSet<>();
/**
* Register a new integration.
*
* @param integration The integration to register.
*/
public void register(@NotNull final ShopWrapper integration) {
public static void register(@NotNull final ShopWrapper integration) {
registered.add(integration);
}
/**
* Register eco item provider for shop plugins.
*/
public void registerEcoProvider() {
public static void registerEcoProvider() {
for (ShopWrapper shopWrapper : registered) {
shopWrapper.registerEcoProvider();
}
}
private ShopManager() {
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
}
}

View File

@@ -8,7 +8,6 @@ import com.willfp.eco.core.recipe.parts.ModifiedTestableItem;
import com.willfp.eco.core.recipe.parts.TestableStack;
import com.willfp.eco.util.NamespacedKeyUtils;
import com.willfp.eco.util.NumberUtils;
import lombok.experimental.UtilityClass;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.ItemStack;
@@ -28,7 +27,6 @@ import java.util.stream.Collectors;
/**
* Class to manage all custom and vanilla items.
*/
@UtilityClass
public final class Items {
/**
* All recipe parts.
@@ -51,7 +49,7 @@ public final class Items {
* @param key The key of the item.
* @param item The item.
*/
public void registerCustomItem(@NotNull final NamespacedKey key,
public static void registerCustomItem(@NotNull final NamespacedKey key,
@NotNull final TestableItem item) {
REGISTRY.put(key, item);
}
@@ -61,7 +59,7 @@ public final class Items {
*
* @param provider The provider.
*/
public void registerItemProvider(@NotNull final ItemProvider provider) {
public static void registerItemProvider(@NotNull final ItemProvider provider) {
PROVIDERS.put(provider.getNamespace(), provider);
}
@@ -70,7 +68,7 @@ public final class Items {
*
* @param parser The parser.
*/
public void registerArgParser(@NotNull final LookupArgParser parser) {
public static void registerArgParser(@NotNull final LookupArgParser parser) {
ARG_PARSERS.add(parser);
}
@@ -79,7 +77,7 @@ public final class Items {
*
* @param key The key of the recipe part.
*/
public void removeCustomItem(@NotNull final NamespacedKey key) {
public static void removeCustomItem(@NotNull final NamespacedKey key) {
REGISTRY.remove(key);
}
@@ -106,7 +104,7 @@ public final class Items {
* @param key The lookup string.
* @return The testable item, or an {@link EmptyTestableItem}.
*/
public TestableItem lookup(@NotNull final String key) {
public static TestableItem lookup(@NotNull final String key) {
if (key.contains("?")) {
String[] options = key.split("\\?");
for (String option : options) {
@@ -243,7 +241,7 @@ public final class Items {
* @param itemStack The itemStack to check.
* @return If is recipe.
*/
public boolean isCustomItem(@NotNull final ItemStack itemStack) {
public static boolean isCustomItem(@NotNull final ItemStack itemStack) {
for (TestableItem item : REGISTRY.values()) {
if (item.matches(itemStack)) {
return true;
@@ -259,7 +257,7 @@ public final class Items {
* @return The custom item, or null if not exists.
*/
@Nullable
public CustomItem getCustomItem(@NotNull final ItemStack itemStack) {
public static CustomItem getCustomItem(@NotNull final ItemStack itemStack) {
for (TestableItem item : REGISTRY.values()) {
if (item.matches(itemStack)) {
return getOrWrap(item);
@@ -273,7 +271,7 @@ public final class Items {
*
* @return A set of all items.
*/
public Set<CustomItem> getCustomItems() {
public static Set<CustomItem> getCustomItems() {
return REGISTRY.values().stream().map(Items::getOrWrap).collect(Collectors.toSet());
}
@@ -286,7 +284,7 @@ public final class Items {
* @param item The item.
* @return The CustomItem.
*/
public CustomItem getOrWrap(@NotNull final TestableItem item) {
public static CustomItem getOrWrap(@NotNull final TestableItem item) {
if (item instanceof CustomItem) {
return (CustomItem) item;
} else {
@@ -297,4 +295,8 @@ public final class Items {
);
}
}
private Items() {
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
}
}

View File

@@ -1,15 +1,17 @@
package com.willfp.eco.core.proxy;
import lombok.experimental.UtilityClass;
import org.bukkit.Bukkit;
/**
* Proxy / NMS constants.
*/
@UtilityClass
public class ProxyConstants {
public final class ProxyConstants {
/**
* The NMS version that the server is running on.
*/
public static final String NMS_VERSION = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
private ProxyConstants() {
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
}
}

View File

@@ -6,7 +6,6 @@ import com.willfp.eco.core.EcoPlugin;
import com.willfp.eco.core.items.Items;
import com.willfp.eco.core.recipe.recipes.CraftingRecipe;
import com.willfp.eco.core.recipe.recipes.ShapedCraftingRecipe;
import lombok.experimental.UtilityClass;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
@@ -17,9 +16,8 @@ import java.util.List;
/**
* Utility class to manage and register crafting recipes.
*/
@UtilityClass
@SuppressWarnings("deprecation")
public class Recipes {
public final class Recipes {
/**
* Registry of all recipes.
*/
@@ -31,7 +29,7 @@ public class Recipes {
*
* @param recipe The recipe.
*/
public void register(@NotNull final CraftingRecipe recipe) {
public static void register(@NotNull final CraftingRecipe recipe) {
RECIPES.forcePut(recipe.getKey(), recipe);
}
@@ -42,7 +40,7 @@ public class Recipes {
* @return The match, or null if not found.
*/
@Nullable
public CraftingRecipe getMatch(@NotNull final ItemStack[] matrix) {
public static CraftingRecipe getMatch(@NotNull final ItemStack[] matrix) {
return RECIPES.values().stream().filter(recipe -> recipe.test(matrix)).findFirst().orElse(null);
}
@@ -53,7 +51,7 @@ public class Recipes {
* @return The recipe, or null if not found.
*/
@Nullable
public CraftingRecipe getRecipe(@NotNull final NamespacedKey key) {
public static CraftingRecipe getRecipe(@NotNull final NamespacedKey key) {
CraftingRecipe recipe = RECIPES.get(key);
if (recipe != null) {
return recipe;
@@ -77,10 +75,10 @@ public class Recipes {
* @param recipeStrings The recipe.
* @return The recipe.
*/
public CraftingRecipe createAndRegisterRecipe(@NotNull final EcoPlugin plugin,
@NotNull final String key,
@NotNull final ItemStack output,
@NotNull final List<String> recipeStrings) {
public static CraftingRecipe createAndRegisterRecipe(@NotNull final EcoPlugin plugin,
@NotNull final String key,
@NotNull final ItemStack output,
@NotNull final List<String> recipeStrings) {
ShapedCraftingRecipe.Builder builder = ShapedCraftingRecipe.builder(plugin, key).setOutput(output);
for (int i = 0; i < 9; i++) {
@@ -92,4 +90,8 @@ public class Recipes {
return recipe;
}
private Recipes() {
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
}
}

View File

@@ -1,14 +1,12 @@
package com.willfp.eco.core.requirement;
import com.willfp.eco.core.Eco;
import lombok.experimental.UtilityClass;
import org.jetbrains.annotations.NotNull;
/**
* Contains methods and fields pertaining to requirements.
*/
@UtilityClass
public class Requirements {
public final class Requirements {
/**
* Requires a player to have a permission.
*/
@@ -38,4 +36,8 @@ public class Requirements {
public static Requirement getByID(@NotNull final String name) {
return Eco.getHandler().getRequirementFactory().create(name);
}
private Requirements() {
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
}
}