diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java index 5237b09858..585933d5e1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java @@ -18,6 +18,8 @@ import java.util.logging.Level; import java.util.stream.IntStream; import javax.annotation.ParametersAreNonnullByDefault; + +import lombok.Getter; import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -44,6 +46,7 @@ public class ErrorReport { private final SlimefunAddon addon; private final T throwable; + @Getter private File file; /** @@ -138,15 +141,6 @@ public ErrorReport(T throwable, SlimefunItem item) { }); } - /** - * This method returns the {@link File} this {@link ErrorReport} has been written to. - * - * @return The {@link File} for this {@link ErrorReport} - */ - public File getFile() { - return file; - } - /** * This returns the {@link Throwable} that was thrown. * @@ -169,7 +163,7 @@ private void print(Consumer printer) { this.file = getNewFile(); count.incrementAndGet(); - try (PrintStream stream = new PrintStream(file, StandardCharsets.UTF_8.name())) { + try (PrintStream stream = new PrintStream(file, StandardCharsets.UTF_8)) { stream.println(); stream.println("Error Generated: " + dateFormat.format(LocalDateTime.now())); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/MinecraftVersion.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/MinecraftVersion.java index fe500c7cec..e27daa26d4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/MinecraftVersion.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/MinecraftVersion.java @@ -2,6 +2,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import io.papermc.lib.PaperLib; +import lombok.Getter; import org.apache.commons.lang.Validate; import org.bukkit.Server; @@ -52,7 +53,9 @@ public enum MinecraftVersion { */ UNKNOWN("Unknown", true); + @Getter private final String name; + @Getter private final boolean virtual; private final int majorVersion; @@ -88,28 +91,6 @@ public enum MinecraftVersion { this.virtual = virtual; } - /** - * This returns the name of this {@link MinecraftVersion} in a readable format. - * - * @return The name of this {@link MinecraftVersion} - */ - public String getName() { - return name; - } - - /** - * This returns whether this {@link MinecraftVersion} is virtual or not. - * A virtual {@link MinecraftVersion} does not actually exist but is rather - * a state of the {@link Server} software used. - * Virtual {@link MinecraftVersion MinecraftVersions} include "UNKNOWN" and - * "UNIT TEST". - * - * @return Whether this {@link MinecraftVersion} is virtual or not - */ - public boolean isVirtual() { - return virtual; - } - /** * This tests if the given minecraft version number matches with this * {@link MinecraftVersion}. diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/Waypoint.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/Waypoint.java index 41d128642d..0318429c2c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/Waypoint.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/Waypoint.java @@ -7,6 +7,8 @@ import java.util.Objects; import java.util.UUID; import javax.annotation.ParametersAreNonnullByDefault; + +import lombok.Getter; import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -26,11 +28,37 @@ * @see Teleporter * */ +@Getter public class Waypoint { + /** + * -- GETTER -- + * This returns the owner's + * of the + * . + * + */ private final UUID ownerId; + /** + * -- GETTER -- + * This method returns the unique identifier for this + * . + * + */ private final String id; + /** + * -- GETTER -- + * This returns the name of this + * . + * + */ private final String name; + /** + * -- GETTER -- + * This returns the + * of this + * + */ private final Location location; /** @@ -78,16 +106,6 @@ public Waypoint(UUID ownerId, String id, Location loc, String name) { this.name = name; } - /** - * This returns the owner's {@link UUID} of the {@link Waypoint}. - * - * @return The corresponding owner's {@link UUID} - */ - - public UUID getOwnerId() { - return this.ownerId; - } - /** * This returns the owner of the {@link Waypoint}. * @@ -102,36 +120,6 @@ public PlayerProfile getOwner() { return PlayerProfile.find(Bukkit.getOfflinePlayer(ownerId)).orElse(null); } - /** - * This method returns the unique identifier for this {@link Waypoint}. - * - * @return The {@link Waypoint} id - */ - - public String getId() { - return id; - } - - /** - * This returns the name of this {@link Waypoint}. - * - * @return The name of this {@link Waypoint} - */ - - public String getName() { - return name; - } - - /** - * This returns the {@link Location} of this {@link Waypoint} - * - * @return The {@link Waypoint} {@link Location} - */ - - public Location getLocation() { - return location; - } - /** * This method returns whether this {@link Waypoint} is a Deathpoint. * @@ -166,11 +154,10 @@ public int hashCode() { */ @Override public boolean equals(Object obj) { - if (!(obj instanceof Waypoint)) { + if (!(obj instanceof Waypoint waypoint)) { return false; } - Waypoint waypoint = (Waypoint) obj; return this.ownerId.equals(waypoint.getOwnerId()) && id.equals(waypoint.getId()) && location.equals(waypoint.getLocation()) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/HashedArmorpiece.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/HashedArmorpiece.java index 0b2ba03ec5..b89b8a8391 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/HashedArmorpiece.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/HashedArmorpiece.java @@ -4,6 +4,8 @@ import io.github.thebusybiscuit.slimefun4.implementation.tasks.armor.SlimefunArmorTask; import java.util.Optional; import javax.annotation.Nullable; + +import lombok.Getter; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -26,6 +28,7 @@ public final class HashedArmorpiece { private int hash; + @Getter private Optional item; /** @@ -84,16 +87,6 @@ public boolean hasDiverged(@Nullable ItemStack stack) { } } - /** - * Returns the {@link SlimefunArmorPiece} that corresponds to this {@link HashedArmorpiece}, - * or an empty {@link Optional} - * - * @return An {@link Optional} describing the result - */ - public Optional getItem() { - return item; - } - @Override public String toString() { return "HashedArmorpiece {hash=" 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 5bfb4a406f..ed48627d0f 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 @@ -13,6 +13,8 @@ import java.util.List; import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; + +import lombok.Getter; import org.apache.commons.lang.Validate; import org.bukkit.ChatColor; import org.bukkit.Keyed; @@ -36,10 +38,13 @@ public class ItemGroup implements Keyed { private SlimefunAddon addon; + @Getter protected final List items = new ArrayList<>(); protected final NamespacedKey key; protected final ItemStack item; + @Getter protected int tier; + @Getter protected boolean crossAddonItemGroup = false; /** @@ -123,16 +128,6 @@ public boolean isRegistered() { return this.addon != null && Slimefun.getRegistry().getAllItemGroups().contains(this); } - /** - * 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() { - return tier; - } - /** * This sets the tier of this {@link ItemGroup}. * The tier determines the position of this {@link ItemGroup} in the {@link SlimefunGuide}. @@ -154,7 +149,7 @@ public void setTier(int tier) { */ private void sortCategoriesByTier() { List categories = Slimefun.getRegistry().getAllItemGroups(); - Collections.sort(categories, Comparator.comparingInt(ItemGroup::getTier)); + categories.sort(Comparator.comparingInt(ItemGroup::getTier)); } /** @@ -265,15 +260,6 @@ public String getDisplayName(Player p) { } } - /** - * Returns all instances of {@link SlimefunItem} bound to this {@link ItemGroup}. - * - * @return the list of SlimefunItems bound to this {@link ItemGroup} - */ - public List getItems() { - return items; - } - /** * This method returns whether a given {@link SlimefunItem} exists in this {@link ItemGroup}. * @@ -332,16 +318,6 @@ public boolean isVisible(Player p) { return false; } - /** - * Returns if items from other addons are allowed to be - * added to this {@link ItemGroup}. - * - * @return true if items from other addons are allowed to be added to this {@link ItemGroup}. - */ - public boolean isCrossAddonItemGroup() { - return crossAddonItemGroup; - } - /** * This method will set if this {@link ItemGroup} will * allow {@link SlimefunItem}s from other addons to diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSetting.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSetting.java index 854db3ade0..4c4b335f32 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSetting.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSetting.java @@ -2,25 +2,28 @@ import io.github.bakedlibs.dough.config.Config; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; + import java.util.List; import java.util.Objects; import javax.annotation.ParametersAreNonnullByDefault; + +import lombok.Getter; import org.apache.commons.lang.Validate; /** * This class represents a Setting for a {@link SlimefunItem} that can be modified via * the {@code Items.yml} {@link Config} file. * + * @param The type of data stored under this {@link ItemSetting} * @author TheBusyBiscuit - * - * @param - * The type of data stored under this {@link ItemSetting} */ public class ItemSetting { private final SlimefunItem item; + @Getter private final String key; + @Getter private final T defaultValue; private T value; @@ -77,15 +80,6 @@ public void update(T newValue) { // Feel free to override this as necessary. } - /** - * This returns the key of this {@link ItemSetting}. - * - * @return The key under which this setting is stored (relative to the {@link SlimefunItem}) - */ - public String getKey() { - return key; - } - /** * This returns the associated {@link SlimefunItem} for this {@link ItemSetting}. * @@ -102,7 +96,7 @@ protected SlimefunItem getItem() { */ public T getValue() { if (value != null) { - /** + /* * If the value has been initialized, return it immediately. */ return value; @@ -116,15 +110,6 @@ public T getValue() { } } - /** - * This returns the default value of this {@link ItemSetting}. - * - * @return The default value - */ - public T getDefaultValue() { - return defaultValue; - } - /** * This method checks if this {@link ItemSetting} stores the given data type. * @@ -160,7 +145,7 @@ public void reload() { Object configuredValue = Slimefun.getItemCfg().getValue(item.getId() + '.' + getKey()); if (defaultValue.getClass().isInstance(configuredValue) - || (configuredValue instanceof List && defaultValue instanceof List)) { + || (configuredValue instanceof List && defaultValue instanceof List)) { // We can do an unsafe cast here, we did an isInstance(...) check before! T newValue = (T) configuredValue; @@ -208,13 +193,13 @@ public void reload() { public String toString() { T currentValue = this.value != null ? this.value : defaultValue; return getClass().getSimpleName() - + " {" - + getKey() - + " = " - + currentValue - + " (default: " - + getDefaultValue() - + ")"; + + " {" + + getKey() + + " = " + + currentValue + + " (default: " + + getDefaultValue() + + ")"; } @Override @@ -224,8 +209,7 @@ public final int hashCode() { @Override public final boolean equals(Object obj) { - if (obj instanceof ItemSetting) { - ItemSetting setting = (ItemSetting) obj; + if (obj instanceof ItemSetting setting) { return Objects.equals(getKey(), setting.getKey()) && Objects.equals(getItem(), setting.getItem()); } else { return false; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSpawnReason.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSpawnReason.java index 5f3c0da814..f9d55b4570 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSpawnReason.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSpawnReason.java @@ -63,5 +63,5 @@ public enum ItemSpawnReason { /** * Other reasons we did not account for. */ - MISC; + MISC } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemState.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemState.java index 32f5f942a0..59e2104994 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemState.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemState.java @@ -29,5 +29,5 @@ public enum ItemState { * This {@link SlimefunItem} has fallen back to its vanilla behavior, because it is disabled and an instance of * {@link VanillaItem}. */ - VANILLA_FALLBACK; + VANILLA_FALLBACK } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItem.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItem.java index 9bdfb7375f..8360ce239d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItem.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItem.java @@ -56,10 +56,8 @@ * * @author TheBusyBiscuit * @author Poslovitch - * * @see SlimefunItemStack * @see SlimefunAddon - * */ public class SlimefunItem implements Placeable { @@ -83,11 +81,13 @@ public class SlimefunItem implements Placeable { /** * This is the state of this {@link SlimefunItem}. */ + @Getter private ItemState state = ItemState.UNREGISTERED; /** * This is the {@link ItemGroup} in which this {@link SlimefunItem} can be found. */ + @Getter private ItemGroup itemGroup; /** @@ -95,7 +95,9 @@ public class SlimefunItem implements Placeable { */ private Research research; + @Getter private ItemStack[] recipe; + @Getter private RecipeType recipeType; protected ItemStack recipeOutput; @@ -135,6 +137,7 @@ public class SlimefunItem implements Placeable { private Optional wikiURL = Optional.empty(); private final OptionalMap, ItemHandler> itemHandlers = new OptionalMap<>(HashMap::new); + @Getter private final Set> itemSettings = new HashSet<>(); /** @@ -221,19 +224,6 @@ public final String getId() { return id; } - /** - * This method returns the {@link ItemState} this {@link SlimefunItem} - * is currently in. This can be used to determine whether a {@link SlimefunItem} - * is enabled or disabled. - *

- * {@link VanillaItem} represents a special case here. - * - * @return The {@link ItemState} of this {@link SlimefunItem} - */ - public ItemState getState() { - return state; - } - /** * This returns the {@link ItemStack} of this {@link SlimefunItem}. * The {@link ItemStack} describes the look and feel of this {@link SlimefunItem}. @@ -244,35 +234,6 @@ public ItemStack getItem() { return itemStackTemplate; } - /** - * This returns the {@link ItemGroup} of our {@link SlimefunItem}, every {@link SlimefunItem} - * is associated with exactly one {@link ItemGroup}. - * - * @return The {@link ItemGroup} that this {@link SlimefunItem} belongs to - */ - public ItemGroup getItemGroup() { - return itemGroup; - } - - /** - * Retrieve the recipe for this {@link SlimefunItem}. - * - * @return An {@link ItemStack} array of 9 which represents the recipe for this {@link SlimefunItem} - */ - public ItemStack[] getRecipe() { - return recipe; - } - - /** - * This method returns the {@link RecipeType}. - * The {@link RecipeType} determines how this {@link SlimefunItem} is crafted. - * - * @return The {@link RecipeType} of this {@link SlimefunItem} - */ - public RecipeType getRecipeType() { - return recipeType; - } - /** * This method returns the result of crafting this {@link SlimefunItem} * @@ -303,15 +264,6 @@ public final boolean hasResearch() { return research != null; } - /** - * This returns a {@link Set} containing all instances of {@link ItemSetting} for this {@link SlimefunItem}. - * - * @return A {@link Set} of every {@link ItemSetting} for this {@link SlimefunItem} - */ - public Set> getItemSettings() { - return itemSettings; - } - /** * This method returns an {@link Optional} holding an {@link ItemSetting} with the given * key and data type. Or an empty {@link Optional} if this {@link SlimefunItem} has no such {@link ItemSetting}. @@ -505,7 +457,7 @@ public void register(SlimefunAddon addon) { load(); } } catch (Exception x) { - error("Registering " + toString() + " has failed!", x); + error("Registering " + this + " has failed!", x); } } @@ -621,8 +573,7 @@ protected boolean isItemStackImmutable() { /** * This method checks if the dependencies have been set up correctly. * - * @param addon - * The {@link SlimefunAddon} trying to register this {@link SlimefunItem} + * @param addon The {@link SlimefunAddon} trying to register this {@link SlimefunItem} */ private void checkDependencies(SlimefunAddon addon) { if (!addon.hasDependency("Slimefun")) { @@ -647,8 +598,7 @@ private void checkForConflicts() { *

* If a {@link Deprecated} element was found, a warning message will be printed. * - * @param c - * The {@link Class} from which to start this operation. + * @param c The {@link Class} from which to start this operation. */ private void checkForDeprecations(@Nullable Class c) { /* @@ -659,16 +609,16 @@ private void checkForDeprecations(@Nullable Class c) { // Check if this Class is deprecated if (c.isAnnotationPresent(Deprecated.class)) { warn("The inherited Class \"" - + c.getName() - + "\" has been deprecated. Check the documentation for more details!"); + + c.getName() + + "\" has been deprecated. Check the documentation for more details!"); } for (Class parent : c.getInterfaces()) { // Check if this Interface is deprecated if (parent.isAnnotationPresent(Deprecated.class)) { warn("The implemented Interface \"" - + parent.getName() - + "\" has been deprecated. Check the documentation for more details!"); + + parent.getName() + + "\" has been deprecated. Check the documentation for more details!"); } } @@ -682,8 +632,7 @@ private void checkForDeprecations(@Nullable Class c) { * You don't have to call this method if your {@link SlimefunItem} was linked to your {@link Research} * using {@link Research#addItems(SlimefunItem...)} * - * @param research - * The new {@link Research} for this {@link SlimefunItem}, or null + * @param research The new {@link Research} for this {@link SlimefunItem}, or null */ public void setResearch(@Nullable Research research) { if (this.research != null) { @@ -700,8 +649,7 @@ public void setResearch(@Nullable Research research) { /** * Sets the recipe for this {@link SlimefunItem}. * - * @param recipe - * The recipe for this {@link ItemStack} + * @param recipe The recipe for this {@link ItemStack} */ public void setRecipe(ItemStack[] recipe) { if (recipe == null || recipe.length != 9) { @@ -714,8 +662,7 @@ public void setRecipe(ItemStack[] recipe) { /** * Sets the {@link RecipeType} for this {@link SlimefunItem}. * - * @param type - * The {@link RecipeType} for this {@link SlimefunItem} + * @param type The {@link RecipeType} for this {@link SlimefunItem} */ public void setRecipeType(RecipeType type) { Validate.notNull(type, "The RecipeType is not allowed to be null!"); @@ -725,8 +672,7 @@ public void setRecipeType(RecipeType type) { /** * This sets the {@link ItemGroup} in which this {@link SlimefunItem} will be displayed. * - * @param itemGroup - * The new {@link ItemGroup} + * @param itemGroup The new {@link ItemGroup} */ public void setItemGroup(ItemGroup itemGroup) { Validate.notNull(itemGroup, "The ItemGroup is not allowed to be null!"); @@ -741,8 +687,7 @@ public void setItemGroup(ItemGroup itemGroup) { * This method will set the result of crafting this {@link SlimefunItem}. * If null is passed, then it will use the default item as the recipe result. * - * @param output - * The {@link ItemStack} that will be the result of crafting this {@link SlimefunItem} + * @param output The {@link ItemStack} that will be the result of crafting this {@link SlimefunItem} */ public void setRecipeOutput(@Nullable ItemStack output) { this.recipeOutput = output; @@ -752,9 +697,7 @@ public void setRecipeOutput(@Nullable ItemStack output) { * This sets whether or not this {@link SlimefunItem} is allowed to be * used in a normal Crafting Table. * - * @param useable - * Whether this {@link SlimefunItem} should be useable in a workbench - * + * @param useable Whether this {@link SlimefunItem} should be useable in a workbench * @return This instance of {@link SlimefunItem} */ public SlimefunItem setUseableInWorkbench(boolean useable) { @@ -767,9 +710,7 @@ public SlimefunItem setUseableInWorkbench(boolean useable) { * This method checks whether the provided {@link ItemStack} represents * this {@link SlimefunItem}. * - * @param item - * The {@link ItemStack} to compare - * + * @param item The {@link ItemStack} to compare * @return Whether the given {@link ItemStack} represents this {@link SlimefunItem} */ public boolean isItem(@Nullable ItemStack item) { @@ -808,8 +749,7 @@ public void load() { * This method will add any given {@link ItemHandler} to this {@link SlimefunItem}. * Note that this will not work after the {@link SlimefunItem} was registered. * - * @param handlers - * Any {@link ItemHandler} that should be added to this {@link SlimefunItem} + * @param handlers Any {@link ItemHandler} that should be added to this {@link SlimefunItem} */ public final void addItemHandler(ItemHandler... handlers) { Validate.notEmpty(handlers, "You cannot add zero handlers..."); @@ -837,8 +777,7 @@ public final void addItemHandler(ItemHandler... handlers) { * This method will add any given {@link ItemSetting} to this {@link SlimefunItem}. * Note that this will not work after the {@link SlimefunItem} was registered. * - * @param settings - * Any {@link ItemSetting} that should be added to this {@link SlimefunItem} + * @param settings Any {@link ItemSetting} that should be added to this {@link SlimefunItem} */ public final void addItemSetting(ItemSetting... settings) { Validate.notEmpty(settings, "You cannot add zero settings..."); @@ -896,8 +835,7 @@ public void postRegister() { * 返回非官方中文Wiki地址 * 下游应使用 {@link SlimefunItem#addWikiPage(String)} 来添加Wiki页面 * - * @param page - * The associated wiki page + * @param page The associated wiki page */ @Deprecated public final void addOfficialWikipage(String page) { @@ -928,9 +866,8 @@ public final void addWikiPage(String page) { * This method returns the wiki page that has been assigned to this item. * It will return null, if no wiki page was found. * - * @see SlimefunItem#addWikiPage(String) - * * @return This item's wiki page + * @see SlimefunItem#addWikiPage(String) */ public Optional getWikipage() { return wikiURL; @@ -969,13 +906,9 @@ public Collection getHandlers() { * This method calls every {@link ItemHandler} of the given {@link Class} * and performs the action as specified via the {@link Consumer}. * - * @param c - * The {@link Class} of the {@link ItemHandler} to call. - * @param callable - * A {@link Consumer} that is called for any found {@link ItemHandler}. - * @param - * The type of {@link ItemHandler} to call. - * + * @param c The {@link Class} of the {@link ItemHandler} to call. + * @param callable A {@link Consumer} that is called for any found {@link ItemHandler}. + * @param The type of {@link ItemHandler} to call. * @return Whether or not an {@link ItemHandler} was found. */ @ParametersAreNonnullByDefault @@ -986,7 +919,7 @@ public boolean callItemHandler(Class c, Consumer c try { callable.accept(c.cast(handler.get())); } catch (Exception | LinkageError x) { - error("Could not pass \"" + c.getSimpleName() + "\" for " + toString(), x); + error("Could not pass \"" + c.getSimpleName() + "\" for " + this, x); } return true; @@ -1001,13 +934,13 @@ public String toString() { return getClass().getSimpleName() + " - '" + id + "'"; } else { return getClass().getSimpleName() - + " - '" - + id - + "' (" - + addon.getName() - + " v" - + addon.getPluginVersion() - + ')'; + + " - '" + + id + + "' (" + + addon.getName() + + " v" + + addon.getPluginVersion() + + ')'; } } @@ -1026,8 +959,7 @@ public Collection getDrops(Player p) { * from this {@link SlimefunItem}, the message will be sent using the {@link Logger} * of the {@link SlimefunAddon} which registered this {@link SlimefunItem}. * - * @param message - * The message to send + * @param message The message to send */ @ParametersAreNonnullByDefault public void info(String message) { @@ -1042,14 +974,13 @@ public void info(String message) { * this {@link SlimefunItem}, the warning will be sent using the {@link Logger} * of the {@link SlimefunAddon} which registered this {@link SlimefunItem}. * - * @param message - * The message to send + * @param message The message to send */ @ParametersAreNonnullByDefault public void warn(String message) { Validate.notNull(addon, "Cannot send a warning for an unregistered item!"); - String msg = toString() + ": " + message; + String msg = this + ": " + message; addon.getLogger().log(Level.WARNING, msg); if (addon.getBugTrackerURL() != null) { @@ -1062,16 +993,14 @@ public void warn(String message) { * This will throw a {@link Throwable} to the console and signal that * this was caused by this {@link SlimefunItem}. * - * @param message - * The message to display alongside this Stacktrace - * @param throwable - * The {@link Throwable} to throw as a stacktrace. + * @param message The message to display alongside this Stacktrace + * @param throwable The {@link Throwable} to throw as a stacktrace. */ @ParametersAreNonnullByDefault public void error(String message, Throwable throwable) { Validate.notNull(addon, "Cannot send an error for an unregistered item!"); - addon.getLogger().log(Level.SEVERE, "Item \"{0}\" from {1} v{2} has caused an Error!", new Object[] { - id, addon.getName(), addon.getPluginVersion() + addon.getLogger().log(Level.SEVERE, "Item \"{0}\" from {1} v{2} has caused an Error!", new Object[]{ + id, addon.getName(), addon.getPluginVersion() }); if (addon.getBugTrackerURL() != null) { @@ -1086,8 +1015,7 @@ public void error(String message, Throwable throwable) { * This method informs the given {@link Player} that this {@link SlimefunItem} * will be removed soon. * - * @param player - * The {@link Player} to inform. + * @param player The {@link Player} to inform. */ @ParametersAreNonnullByDefault public void sendDeprecationWarning(Player player) { @@ -1105,15 +1033,12 @@ public void sendDeprecationWarning(Player player) { *

  • The {@link Player} has the required {@link Permission} (if present) *
  • The {@link Player} has unlocked the required {@link Research} (if present) * - * + *

    * If any of these conditions evaluate to false, then an optional message will be * sent to the {@link Player}. * - * @param p - * The {@link Player} to check - * @param sendMessage - * Whether to send that {@link Player} a message response. - * + * @param p The {@link Player} to check + * @param sendMessage Whether to send that {@link Player} a message response. * @return Whether this {@link Player} is able to use this {@link SlimefunItem}. */ public boolean canUse(Player p, boolean sendMessage) { @@ -1195,8 +1120,7 @@ public final int hashCode() { /** * Retrieve a {@link SlimefunItem} by its id. * - * @param id - * The id of the {@link SlimefunItem} + * @param id The id of the {@link SlimefunItem} * @return The {@link SlimefunItem} associated with that id. Null if non-existent */ public static @Nullable SlimefunItem getById(String id) { @@ -1206,8 +1130,7 @@ public final int hashCode() { /** * Retrieve a {@link Optional} {@link SlimefunItem} by its id. * - * @param id - * The id of the {@link SlimefunItem} + * @param id The id of the {@link SlimefunItem} * @return The {@link Optional} {@link SlimefunItem} associated with that id. Empty if non-existent */ public static Optional getOptionalById(String id) { @@ -1217,8 +1140,7 @@ public static Optional getOptionalById(String id) { /** * Retrieve a {@link SlimefunItem} from an {@link ItemStack}. * - * @param item - * The {@link ItemStack} to check + * @param item The {@link ItemStack} to check * @return The {@link SlimefunItem} associated with this {@link ItemStack} if present, otherwise null */ public static @Nullable SlimefunItem getByItem(@Nullable ItemStack item) { @@ -1239,8 +1161,7 @@ public static Optional getOptionalById(String id) { /** * Retrieve a {@link Optional} {@link SlimefunItem} from an {@link ItemStack}. * - * @param item - * The {@link ItemStack} to check + * @param item The {@link ItemStack} to check * @return The {@link Optional} {@link SlimefunItem} associated with this {@link ItemStack} if present, otherwise empty */ public static Optional getOptionalByItem(@Nullable ItemStack item) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItemStack.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItemStack.java index f0634a8c2e..69857ea431 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItemStack.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItemStack.java @@ -41,7 +41,7 @@ @SerializableAs("ItemStack") public class SlimefunItemStack extends ItemStack { - private String id; + private final String id; private ItemMetaSnapshot itemMetaSnapshot; private boolean locked = false; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/LockedItemGroup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/LockedItemGroup.java index b6f23f9b04..1effa2e4fe 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/LockedItemGroup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/LockedItemGroup.java @@ -11,6 +11,8 @@ import java.util.Set; import java.util.logging.Level; import javax.annotation.ParametersAreNonnullByDefault; + +import lombok.Getter; import org.apache.commons.lang.Validate; import org.bukkit.NamespacedKey; import org.bukkit.entity.Player; @@ -31,6 +33,7 @@ public class LockedItemGroup extends ItemGroup { private final NamespacedKey[] keys; + @Getter private final Set parents = new HashSet<>(); /** @@ -98,18 +101,6 @@ public void register(SlimefunAddon addon) { } } - /** - * Gets the list of parent item groups for this {@link LockedItemGroup}. - * - * @return the list of parent item groups - * - * @see #addParent(ItemGroup) - * @see #removeParent(ItemGroup) - */ - public Set getParents() { - return parents; - } - /** * Adds a parent {@link ItemGroup} to this {@link LockedItemGroup}. * 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 fe5804854f..977a8befb5 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 @@ -122,7 +122,7 @@ private void openGuide(Player p, PlayerProfile profile, SlimefunGuideMode mode, menu.addMenuClickHandler(46, (pl, slot, item, action) -> { int next = page - 1; - if (next != page && next > 0) { + if (next > 0) { openGuide(p, profile, mode, next); } @@ -133,7 +133,7 @@ private void openGuide(Player p, PlayerProfile profile, SlimefunGuideMode mode, menu.addMenuClickHandler(52, (pl, slot, item, action) -> { int next = page + 1; - if (next != page && next <= pages) { + if (next <= pages) { openGuide(p, profile, mode, next); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/SeasonalItemGroup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/SeasonalItemGroup.java index 252f9c9b65..1ee7cbd6e6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/SeasonalItemGroup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/SeasonalItemGroup.java @@ -4,6 +4,8 @@ import java.time.LocalDate; import java.time.Month; import javax.annotation.ParametersAreNonnullByDefault; + +import lombok.Getter; import org.apache.commons.lang.Validate; import org.bukkit.NamespacedKey; import org.bukkit.entity.Player; @@ -18,8 +20,16 @@ * @see ItemGroup * @see LockedItemGroup */ +@Getter public class SeasonalItemGroup extends ItemGroup { + /** + * -- GETTER -- + * This method returns the + * in which this + * will appear. + * + */ private final Month month; /** @@ -42,15 +52,6 @@ public SeasonalItemGroup(NamespacedKey key, Month month, int tier, ItemStack ite this.month = month; } - /** - * This method returns the {@link Month} in which this {@link SeasonalItemGroup} will appear. - * - * @return the {@link Month} in which this {@link SeasonalItemGroup} appears - */ - public Month getMonth() { - return month; - } - @Override public boolean isAccessible(Player p) { // Block this ItemGroup if the month differs diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/Network.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/Network.java index 9426606418..22e5a6cf74 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/Network.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/Network.java @@ -11,6 +11,8 @@ import java.util.Queue; import java.util.Set; import javax.annotation.Nullable; + +import lombok.Getter; import org.apache.commons.lang.Validate; import org.bukkit.Location; import org.bukkit.Particle; @@ -34,6 +36,7 @@ public abstract class Network { /** * The {@link Location} of the regulator of this {@link Network}. */ + @Getter protected Location regulator; private final Queue nodeQueue = new ArrayDeque<>(); @@ -229,16 +232,6 @@ public void display() { } } - /** - * This returns the {@link Location} of the regulator block for this {@link Network} - * - * @return The {@link Location} of our regulator - */ - - public Location getRegulator() { - return regulator; - } - /** * This method updates this {@link Network} and serves as the starting point * for any running operations. diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerBackpack.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerBackpack.java index 2123877d53..b81f62a4e7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerBackpack.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerBackpack.java @@ -14,6 +14,8 @@ import java.util.function.Consumer; import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; + +import lombok.Getter; import org.bukkit.Bukkit; import org.bukkit.NamespacedKey; import org.bukkit.OfflinePlayer; @@ -40,10 +42,14 @@ public class PlayerBackpack extends SlimefunInventoryHolder { private static final String COLORED_LORE_OWNER = ChatColors.color(LORE_OWNER); private static final NamespacedKey KEY_BACKPACK_UUID = new NamespacedKey(Slimefun.instance(), "B_UUID"); private static final NamespacedKey KEY_OWNER_UUID = new NamespacedKey(Slimefun.instance(), "OWNER_UUID"); + @Getter private final OfflinePlayer owner; private final UUID uuid; + @Getter private final int id; + @Getter private String name; + @Getter private int size; private boolean isInvalid = false; @@ -217,34 +223,6 @@ public PlayerBackpack( inventory.setContents(contents); } - /** - * This returns the id of this {@link PlayerBackpack} - * - * @return The id of this {@link PlayerBackpack} - */ - public int getId() { - return id; - } - - /** - * This method returns the {@link PlayerProfile} this {@link PlayerBackpack} belongs to - * - * @return The owning {@link PlayerProfile} - */ - - public OfflinePlayer getOwner() { - return owner; - } - - /** - * This returns the size of this {@link PlayerBackpack}. - * - * @return The size of this {@link PlayerBackpack} - */ - public int getSize() { - return size; - } - /** * This method returns the {@link Inventory} of this {@link PlayerBackpack} * @@ -296,10 +274,6 @@ public void setName(String name) { Slimefun.getDatabaseManager().getProfileDataController().saveBackpackInfo(this); } - public String getName() { - return name; - } - public void markInvalid() { isInvalid = true; InventoryUtil.closeInventory(this.inventory); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerProfile.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerProfile.java index 8d4c6c1a0c..b0f00e6bb1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerProfile.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerProfile.java @@ -27,6 +27,8 @@ import java.util.function.Consumer; import java.util.logging.Level; import javax.annotation.Nullable; + +import lombok.Getter; import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -49,16 +51,20 @@ */ public class PlayerProfile { + @Getter private final OfflinePlayer owner; private int backpackNum; private final Config waypointsFile; + @Getter private boolean dirty = false; private boolean isInvalid = false; + @Getter private boolean markedForDeletion = false; private final Set researches; private final List waypoints = new ArrayList<>(); + @Getter private final GuideHistory guideHistory = new GuideHistory(this); private final HashedArmorpiece[] armor = { @@ -97,12 +103,6 @@ private void loadWaypoint() { } } - /** - * This method provides a fast way to access the armor of a {@link Player}. - * It returns a cached version, represented by {@link HashedArmorpiece}. - * - * @return The cached armor for this {@link Player} - */ public HashedArmorpiece[] getArmor() { return armor; } @@ -116,25 +116,6 @@ public UUID getUUID() { return owner.getUniqueId(); } - /** - * This method returns whether the {@link Player} has logged off. - * If this is true, then the Profile can be removed from RAM. - * - * @return Whether the Profile is marked for deletion - */ - public boolean isMarkedForDeletion() { - return markedForDeletion; - } - - /** - * This method returns whether the Profile has unsaved changes - * - * @return Whether there are unsaved changes - */ - public boolean isDirty() { - return dirty; - } - /** * This method will save the Player's Researches and Backpacks to the hard drive */ @@ -359,16 +340,6 @@ public void sendStats(CommandSender sender) { return owner.getPlayer(); } - /** - * This returns the {@link GuideHistory} of this {@link Player}. - * It is basically that player's browsing history. - * - * @return The {@link GuideHistory} of this {@link Player} - */ - public GuideHistory getGuideHistory() { - return guideHistory; - } - public static boolean fromUUID(UUID uuid, Consumer callback) { return get(Bukkit.getOfflinePlayer(uuid), callback); } @@ -482,10 +453,6 @@ public String toString() { return "PlayerProfile {" + owner.getUniqueId() + "}"; } - public OfflinePlayer getOwner() { - return owner; - } - public void markInvalid() { isInvalid = true; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/Research.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/Research.java index 38950c3670..97da566eca 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/Research.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/Research.java @@ -18,6 +18,8 @@ import java.util.function.Consumer; import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; + +import lombok.Getter; import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -41,7 +43,9 @@ public class Research implements Keyed { private final int id; private final String name; private boolean enabled = true; + @Getter private int levelCost; + @Getter private double currencyCost; private final List items = new LinkedList<>(); @@ -170,15 +174,6 @@ public int getCost() { return levelCost; } - /** - * Gets the cost in XP levels to unlock this {@link Research}. - * - * @return The cost in XP levels for this {@link Research} - */ - public int getLevelCost() { - return levelCost; - } - /** * Sets the cost in XP levels to unlock this {@link Research}. * Deprecated, use {@link Research#setLevelCost(int)} instead. @@ -450,10 +445,6 @@ public String toString() { return "Research (" + getKey() + ')'; } - public double getCurrencyCost() { - return currencyCost; - } - public void setCurrencyCost(double currencyCost) { this.currencyCost = currencyCost; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java index d16b45e465..d41b8250ed 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java @@ -14,27 +14,19 @@ import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import io.github.thebusybiscuit.slimefun4.implementation.guide.CheatSheetSlimefunGuide; import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide; -import java.util.ArrayList; -import java.util.Collections; -import java.util.EnumMap; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; +import lombok.Getter; import me.mrCookieSlime.Slimefun.api.BlockInfoConfig; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; import org.apache.commons.lang.Validate; import org.bukkit.NamespacedKey; -import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Piglin; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; + /** * This class houses a lot of instances of {@link Map} and {@link List} that hold * various mappings and collections related to {@link SlimefunItem}. @@ -51,7 +43,9 @@ public final class SlimefunRegistry { private final List categories = new ArrayList<>(); private final List multiblocks = new LinkedList<>(); + @Getter private final List researches = new LinkedList<>(); + @Getter private final List researchRanks = new ArrayList<>(); private final Set researchingPlayers = Collections.synchronizedSet(new HashSet<>()); @@ -66,12 +60,15 @@ public final class SlimefunRegistry { private final KeyMap geoResources = new KeyMap<>(); private final Map profiles = new ConcurrentHashMap<>(); + @Getter private final Map chunks = new HashMap<>(); private final Map guides = new EnumMap<>(SlimefunGuideMode.class); + @Getter private final Map> mobDrops = new EnumMap<>(EntityType.class); private final Map blockMenuPresets = new HashMap<>(); + @Getter private final Map, Set> globalItemHandlers = new HashMap<>(); public void load(Slimefun plugin) { @@ -129,15 +126,6 @@ public List getEnabledSlimefunItems() { return enabledItems; } - /** - * This returns a {@link List} containing every enabled {@link Research}. - * - * @return A {@link List} containing every enabled {@link Research} - */ - - public List getResearches() { - return researches; - } /** * This method returns a {@link Set} containing the {@link UUID} of every @@ -151,10 +139,6 @@ public Set getCurrentlyResearchingPlayers() { return researchingPlayers; } - - public List getResearchRanks() { - return researchRanks; - } /** * This method returns a {@link List} of every enabled {@link MultiBlock}. @@ -192,17 +176,6 @@ public SlimefunGuideImplementation getSlimefunGuide(SlimefunGuideMode mode) { return guide; } - /** - * This returns a {@link Map} connecting the {@link EntityType} with a {@link Set} - * of {@link ItemStack ItemStacks} which would be dropped when an {@link Entity} of that type was killed. - * - * @return The {@link Map} of custom mob drops - */ - - public Map> getMobDrops() { - return mobDrops; - } - /** * This returns a {@link Set} of {@link ItemStack ItemStacks} which can be obtained by bartering * with {@link Piglin Piglins}. @@ -239,24 +212,14 @@ public Map getPlayerProfiles() { return profiles; } - - public Map, Set> getGlobalItemHandlers() { - return globalItemHandlers; - } - public Set getGlobalItemHandlers(Class identifier) { Validate.notNull(identifier, "The identifier for an ItemHandler cannot be null!"); return globalItemHandlers.computeIfAbsent(identifier, c -> new HashSet<>()); } - - public Map getChunks() { - return chunks; - } - public KeyMap getGEOResources() { return geoResources; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ProtectionType.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ProtectionType.java index 68f38bf5c3..b1f55dd1a7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ProtectionType.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ProtectionType.java @@ -25,5 +25,5 @@ public enum ProtectionType { /** * This damage type represents damage caused by flying into a wall with an elytra */ - FLYING_INTO_WALL; + FLYING_INTO_WALL } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Radioactivity.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Radioactivity.java index b79218f79a..6fa028c3c7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Radioactivity.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Radioactivity.java @@ -2,6 +2,8 @@ import io.github.thebusybiscuit.slimefun4.implementation.tasks.armor.RadiationTask; import javax.annotation.ParametersAreNonnullByDefault; + +import lombok.Getter; import org.bukkit.ChatColor; import org.bukkit.entity.Player; @@ -49,6 +51,7 @@ public enum Radioactivity { private final ChatColor color; private final String displayName; + @Getter private final int exposureModifier; @ParametersAreNonnullByDefault @@ -58,17 +61,6 @@ public enum Radioactivity { this.exposureModifier = exposureModifier; } - /** - * This method returns the amount of exposure applied - * to a player every run of the {@link RadiationTask} - * for this radiation level. - * - * @return The exposure amount applied per run. - */ - public int getExposureModifier() { - return exposureModifier; - } - public String getLore() { return ChatColor.GREEN + "\u2622" + ChatColor.GRAY + " 辐射等级: " + color + displayName; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/interactions/InteractionResult.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/interactions/InteractionResult.java index c23255905b..172d0428b3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/interactions/InteractionResult.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/interactions/InteractionResult.java @@ -1,6 +1,8 @@ package io.github.thebusybiscuit.slimefun4.core.attributes.interactions; import io.github.thebusybiscuit.slimefun4.core.attributes.ExternallyInteractable; +import lombok.Getter; + import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; @@ -9,6 +11,7 @@ */ public class InteractionResult { + @Getter private final boolean interactionSuccessful; private @Nullable String resultMessage; @@ -22,15 +25,6 @@ public InteractionResult(boolean successful) { this.interactionSuccessful = successful; } - /** - * Returns whether the interaction was successful or not. - * - * @return boolean denoting whether the interaction was successful or not. - */ - public boolean isInteractionSuccessful() { - return interactionSuccessful; - } - /** * Sets a custom result message for this interaction. * diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunCommand.java index 3cc875ed5a..46c3c491c2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunCommand.java @@ -8,6 +8,8 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; + +import lombok.Getter; import org.apache.commons.lang.Validate; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -25,8 +27,10 @@ public class SlimefunCommand implements CommandExecutor, Listener { private boolean registered = false; + @Getter private final Slimefun plugin; private final List commands = new LinkedList<>(); + @Getter private final Map commandUsage = new HashMap<>(); /** @@ -50,19 +54,6 @@ public void register() { commands.addAll(SlimefunSubCommands.getAllCommands(this)); } - public Slimefun getPlugin() { - return plugin; - } - - /** - * Returns a heatmap of how often certain commands are used. - * - * @return A {@link Map} holding the amount of times each command was run - */ - public Map getCommandUsage() { - return commandUsage; - } - @Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (args.length > 0) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunTabCompleter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunTabCompleter.java index 689c91dbc9..5c64173893 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunTabCompleter.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunTabCompleter.java @@ -86,7 +86,7 @@ public List onTabComplete(CommandSender sender, Command cmd, String labe */ private List createReturnList(List list, String string) { - if (string.length() == 0) { + if (string.isEmpty()) { return list; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/BlockDataCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/BlockDataCommand.java index 7c2c1160bf..ed7c126440 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/BlockDataCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/BlockDataCommand.java @@ -52,7 +52,7 @@ public void onExecute(CommandSender sender, String[] args) { Block target = player.getTargetBlockExact(8, FluidCollisionMode.NEVER); var blockData = StorageCacheUtils.getBlock(target.getLocation()); - if (target == null || target.getType().isAir() || blockData == null) { + if (target.getType().isAir() || blockData == null) { ChatUtils.sendMessage(player, "&c你需要看向一个 Slimefun 方块才能执行该指令!"); return; } @@ -96,14 +96,12 @@ public void onExecute(CommandSender sender, String[] args) { blockData.removeData(key); ChatUtils.sendMessage(player, "&a已移除该方块 &b%key% &a的值", msg -> msg.replace("%key%", key)); } - default -> { - Slimefun.getLocalization() - .sendMessage( - sender, - "messages.usage", - true, - msg -> msg.replace("%usage%", "/sf blockdata get/set/remove [value]")); - } + default -> Slimefun.getLocalization() + .sendMessage( + sender, + "messages.usage", + true, + msg -> msg.replace("%usage%", "/sf blockdata get/set/remove [value]")); } } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/VersionsCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/VersionsCommand.java index 1a7eb408f0..c59f296178 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/VersionsCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/VersionsCommand.java @@ -72,7 +72,11 @@ public void onExecute(CommandSender sender, String[] args) { // Add notice to warn those smart people builder.append("\n由 StarWishsama 汉化") .color(ChatColor.WHITE) - .append("\n请不要将此版本信息截图到 Discord/Github 反馈 Bug" + "\n优先到汉化页面反馈" + "\n") + .append(""" + + 请不要将此版本信息截图到 Discord/Github 反馈 Bug + 优先到汉化页面反馈 + """) .color(ChatColor.RED); if (Slimefun.getConfigManager().isBypassEnvironmentCheck()) { @@ -130,7 +134,7 @@ private void addPluginVersions(ComponentBuilder builder) { for (Plugin plugin : addons) { String version = plugin.getDescription().getVersion(); - HoverEvent hoverEvent = null; + HoverEvent hoverEvent; ClickEvent clickEvent = null; ChatColor primaryColor; ChatColor secondaryColor; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/debug/Debug.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/debug/Debug.java index c926333165..3851fa2824 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/debug/Debug.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/debug/Debug.java @@ -1,6 +1,8 @@ package io.github.thebusybiscuit.slimefun4.core.debug; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import lombok.Getter; + import java.util.ArrayList; import java.util.List; import java.util.logging.Level; @@ -16,6 +18,7 @@ */ public final class Debug { + @Getter private static final List testCase = new ArrayList<>(); private Debug() {} @@ -122,15 +125,6 @@ public static void addTestCase(@Nullable String test) { testCase.add(test); } - /** - * Get the current test case for this server or null if disabled - * - * @return The current test case to enable or null if disabled - */ - public static List getTestCase() { - return testCase; - } - public static boolean hasTestCase(TestCase tc) { return testCase.contains(tc.toString()); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/GuideEntry.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/GuideEntry.java index aa3b4d9f2d..a4718ee362 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/GuideEntry.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/GuideEntry.java @@ -1,9 +1,12 @@ package io.github.thebusybiscuit.slimefun4.core.guide; +import lombok.Getter; + class GuideEntry { private final T object; + @Getter private int page; GuideEntry(T object, int page) { @@ -16,10 +19,6 @@ public T getIndexedObject() { return object; } - public int getPage() { - return page; - } - public void setPage(int page) { this.page = page; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/GuideHistory.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/GuideHistory.java index 5fdb6e2f52..bee404e32c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/GuideHistory.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/GuideHistory.java @@ -6,6 +6,8 @@ import java.util.Deque; import java.util.LinkedList; import javax.annotation.Nullable; + +import lombok.Getter; import org.apache.commons.lang.Validate; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -24,6 +26,7 @@ public class GuideHistory { private final PlayerProfile profile; private final Deque> queue = new LinkedList<>(); + @Getter private int mainMenuPage = 1; /** @@ -56,15 +59,6 @@ public void setMainMenuPage(int page) { mainMenuPage = page; } - /** - * This returns the current main menu page of this {@link GuideHistory} - * - * @return The main menu page of this {@link GuideHistory} - */ - public int getMainMenuPage() { - return mainMenuPage; - } - /** * This method adds a {@link ItemGroup} to this {@link GuideHistory}. * Should the {@link ItemGroup} already be the last element in this {@link GuideHistory}, diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideMode.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideMode.java index 51066394fc..257df7ab04 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideMode.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideMode.java @@ -1,6 +1,7 @@ package io.github.thebusybiscuit.slimefun4.core.guide; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import lombok.Getter; /** * This enum holds the different designs a {@link SlimefunGuide} can have. @@ -12,6 +13,7 @@ * @see SlimefunGuideImplementation * */ +@Getter public enum SlimefunGuideMode { /** @@ -25,18 +27,15 @@ public enum SlimefunGuideMode { */ CHEAT_MODE("作弊模式"); + /** + * -- GETTER -- + * 获取指南书样式的显示名称 + * + */ private final String displayName; SlimefunGuideMode(String displayName) { this.displayName = displayName; } - /** - * 获取指南书样式的显示名称 - * - * @return 指南书样式的显示名称 - */ - public String getDisplayName() { - return displayName; - } } 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 53fd042e49..439a223efb 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 @@ -59,6 +59,6 @@ public Optional getSelectedOption(Player p, ItemStack guide) { @Override public void setSelectedOption(Player p, ItemStack guide, Boolean value) { - PersistentDataAPI.setByte(p, getKey(), value.booleanValue() ? (byte) 1 : (byte) 0); + PersistentDataAPI.setByte(p, getKey(), value ? (byte) 1 : (byte) 0); } } 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 7dc175502f..1dcec31a71 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 @@ -70,6 +70,6 @@ public Optional getSelectedOption(Player p, ItemStack guide) { @Override public void setSelectedOption(Player p, ItemStack guide, Boolean value) { - PersistentDataAPI.setByte(p, getKey(), (byte) (value.booleanValue() ? 1 : 0)); + PersistentDataAPI.setByte(p, getKey(), (byte) (value ? 1 : 0)); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/machines/MachineProcessor.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/machines/MachineProcessor.java index 9e9f78a3b1..239db4369e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/machines/MachineProcessor.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/machines/MachineProcessor.java @@ -7,6 +7,8 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import javax.annotation.Nullable; + +import lombok.Getter; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; @@ -30,6 +32,7 @@ public class MachineProcessor { private final Map machines = new ConcurrentHashMap<>(); + @Getter private final MachineProcessHolder owner; private ItemStack progressBar; @@ -46,16 +49,6 @@ public MachineProcessor(MachineProcessHolder owner) { this.owner = owner; } - /** - * This returns the owner of this {@link MachineProcessor}. - * - * @return The owner / holder - */ - - public MachineProcessHolder getOwner() { - return owner; - } - /** * This returns the progress bar icon for this {@link MachineProcessor} * or null if no progress bar was set. diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/MultiBlock.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/MultiBlock.java index 17a5892c1b..d8e7e67144 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/MultiBlock.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/MultiBlock.java @@ -88,12 +88,10 @@ public BlockFace getTriggerBlock() { @Override public boolean equals(Object obj) { - if (!(obj instanceof MultiBlock)) { + if (!(obj instanceof MultiBlock mb)) { return false; } - MultiBlock mb = (MultiBlock) obj; - if (trigger == mb.getTriggerBlock() && isSymmetric == mb.isSymmetric) { for (int i = 0; i < mb.getStructure().length; i++) { if (!compareBlocks(blocks[i], mb.getStructure()[i])) { @@ -109,7 +107,7 @@ public boolean equals(Object obj) { @Override public int hashCode() { - return Objects.hash(item.getId(), blocks, trigger, isSymmetric); + return Objects.hash(item.getId(), Arrays.hashCode(blocks), trigger, isSymmetric); } private boolean compareBlocks(Material a, @Nullable Material b) { @@ -128,9 +126,7 @@ private boolean compareBlocks(Material a, @Nullable Material b) { return a == Material.MOVING_PISTON; } - if (b != a) { - return false; - } + return b == a; } return true; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/MultiBlockMachine.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/MultiBlockMachine.java index ecee02f768..bf69362e1c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/MultiBlockMachine.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/MultiBlockMachine.java @@ -21,6 +21,8 @@ import java.util.Optional; import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; + +import lombok.Getter; import org.apache.commons.lang.Validate; import org.bukkit.Material; import org.bukkit.World; @@ -43,6 +45,7 @@ */ public abstract class MultiBlockMachine extends SlimefunItem implements NotPlaceable, RecipeDisplayItem { + @Getter protected final List recipes; protected final List displayRecipes; protected final MultiBlock multiblock; @@ -72,10 +75,6 @@ protected void registerDefaultRecipes(List recipes) { // Override this method to register some default recipes } - public List getRecipes() { - return recipes; - } - @Override public List getDisplayRecipes() { return displayRecipes; @@ -179,7 +178,7 @@ protected MultiBlockInteractionHandler getInteractionHandler() { * It's functionally the same as the old fit check for the dispenser, * only refactored. */ - if (!outputChest.isPresent() && InvUtils.fits(placeCheckerInv, product)) { + if (outputChest.isEmpty() && InvUtils.fits(placeCheckerInv, product)) { return dispInv; } else { return outputChest.orElse(null); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNetworkTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNetworkTask.java index e008392b9b..67fe2908d7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNetworkTask.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNetworkTask.java @@ -63,9 +63,9 @@ public void run() { long timestamp = System.nanoTime(); try { - /** - * All operations happen here: Everything gets iterated from the Input Nodes. - * (Apart from ChestTerminal Buses) + /* + All operations happen here: Everything gets iterated from the Input Nodes. + (Apart from ChestTerminal Buses) */ SlimefunItem inputNode = SlimefunItems.CARGO_INPUT_NODE.getItem(); for (Map.Entry entry : inputs.entrySet()) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoUtils.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoUtils.java index e2377f8bb0..81498ae6d1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoUtils.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoUtils.java @@ -383,7 +383,7 @@ && matchesFilter(network, node, wrapperInSlot)) { itemInSlot.setAmount(maxStackSize); return stack; } else { - itemInSlot.setAmount(Math.min(amount, maxStackSize)); + itemInSlot.setAmount(amount); return null; } } else if (smartFill) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemFilter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemFilter.java index d5911e0c4d..38ef915208 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemFilter.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemFilter.java @@ -14,6 +14,8 @@ import java.util.List; import java.util.Objects; import java.util.function.Predicate; + +import lombok.Getter; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import org.bukkit.Material; import org.bukkit.block.Block; @@ -54,7 +56,13 @@ class ItemFilter implements Predicate { /** * If an {@link ItemFilter} is marked as dirty / outdated, then it will be updated * on the next tick. + * -- GETTER -- + * Whether this + * is outdated and needs to be refreshed. + * + */ + @Getter private volatile boolean dirty = true; private volatile boolean isLoading = false; @@ -168,15 +176,6 @@ private void clear(boolean rejectOnMatch) { this.rejectOnMatch = rejectOnMatch; } - /** - * Whether this {@link ItemFilter} is outdated and needs to be refreshed. - * - * @return Whether the filter is outdated. - */ - public boolean isDirty() { - return this.dirty; - } - /** * This marks this {@link ItemFilter} as dirty / outdated. */ @@ -214,10 +213,7 @@ public boolean test(ItemStack item) { } } - if (potentialMatches == 0) { - // If there is no match, we can safely assume the default value - return rejectOnMatch; - } else { + if (potentialMatches != 0) { /* * If there is more than one potential match, create a wrapper to save * performance on the ItemMeta otherwise just use the item directly. @@ -240,7 +236,7 @@ public boolean test(ItemStack item) { } // If no particular item was matched, we fallback to our default value. - return rejectOnMatch; } + return rejectOnMatch; } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/EnergyNetComponentType.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/EnergyNetComponentType.java index 5623e80160..72432b6793 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/EnergyNetComponentType.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/EnergyNetComponentType.java @@ -47,5 +47,5 @@ public enum EnergyNetComponentType { * A fallback value to use when a {@link Block} cannot be classified as any of the * other options. */ - NONE; + NONE } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/AutoSavingService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/AutoSavingService.java index aac646cd50..da9f98a518 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/AutoSavingService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/AutoSavingService.java @@ -16,8 +16,6 @@ */ public class AutoSavingService { - private int interval; - /** * This method starts the {@link AutoSavingService} with the given interval. * @@ -27,7 +25,6 @@ public class AutoSavingService { * The interval in which to run this task */ public void start(Slimefun plugin, int interval) { - this.interval = interval; plugin.getServer().getScheduler().runTaskTimer(plugin, this::saveAllPlayers, 2000L, interval * 60L * 20L); plugin.getServer() diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BackupService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BackupService.java index 01fa0928cf..790243df30 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BackupService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BackupService.java @@ -111,13 +111,6 @@ private void addFile(ZipOutputStream output, File file, String path) throws IOEx output.closeEntry(); } - private void addDirectory(ZipOutputStream output, File directory, String zipPath) - throws IOException { - for (File file : directory.listFiles()) { - addFile(output, file, zipPath); - } - } - /** * This method will delete old backups. * diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BlockDataService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BlockDataService.java index 26da48ad73..8f538d94e7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BlockDataService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BlockDataService.java @@ -63,9 +63,9 @@ public void setBlockData(Block b, String value) { Validate.notNull(b, "The block cannot be null!"); Validate.notNull(value, "The value cannot be null!"); - /** - * Don't use PaperLib here, it seems to be quite buggy in block-placing scenarios - * and it would be too tedious to check for individual build versions to circumvent this. + /* + Don't use PaperLib here, it seems to be quite buggy in block-placing scenarios + and it would be too tedious to check for individual build versions to circumvent this. */ BlockState state = b.getState(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/CustomTextureService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/CustomTextureService.java index d3c837cb32..6d74f3bcfd 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/CustomTextureService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/CustomTextureService.java @@ -55,12 +55,13 @@ public CustomTextureService(Config config) { this.config = config; config.getConfiguration() .options() - .header("This file is used to assign items from Slimefun or any of its addons\n" - + "the 'CustomModelData' NBT tag. This can be used in conjunction with a custom" - + " resource pack\n" - + "to give items custom textures.\n" - + "0 means there is no data assigned to that item.\n\n" - + "There is no official Slimefun resource pack at the moment."); + .header(""" + This file is used to assign items from Slimefun or any of its addons + the 'CustomModelData' NBT tag. This can be used in conjunction with a custom resource pack + to give items custom textures. + 0 means there is no data assigned to that item. + + There is no official Slimefun resource pack at the moment."""); config.getConfiguration().options().copyHeader(true); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PermissionsService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PermissionsService.java index 3bb9c39d63..da9b54a123 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PermissionsService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PermissionsService.java @@ -34,13 +34,11 @@ public PermissionsService(Slimefun plugin) { // @formatter:off config.getConfiguration() .options() - .header("This file is used to assign permission nodes to items from Slimefun or any of its" - + " addons.\n" - + "To assign an item a certain permission node you simply have to set the" - + " 'permission' attribute\n" - + "to your desired permission node.\n" - + "You can also customize the text that is displayed when a Player does not have" - + " that permission."); + .header(""" +This file is used to assign permission nodes to items from Slimefun or any of its addons. +To assign an item a certain permission node you simply have to set the 'permission' attribute +to your desired permission node. +You can also customize the text that is displayed when a Player does not have that permission."""); // @formatter:on config.getConfiguration().options().copyHeader(true); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/holograms/HologramsService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/holograms/HologramsService.java index dbc435ff3f..49b6bfddd1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/holograms/HologramsService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/holograms/HologramsService.java @@ -3,14 +3,7 @@ import io.github.bakedlibs.dough.blocks.BlockPosition; import io.github.thebusybiscuit.slimefun4.core.attributes.HologramOwner; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.function.Consumer; -import java.util.logging.Level; -import javax.annotation.Nullable; -import javax.annotation.ParametersAreNonnullByDefault; +import lombok.Getter; import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -24,6 +17,14 @@ import org.bukkit.plugin.Plugin; import org.bukkit.util.Vector; +import javax.annotation.Nullable; +import javax.annotation.ParametersAreNonnullByDefault; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.function.Consumer; +import java.util.logging.Level; + /** * This service is responsible for handling holograms. * @@ -52,6 +53,7 @@ public class HologramsService { /** * The default hologram offset */ + @Getter private final Vector defaultOffset = new Vector(0.5, 0.75, 0.5); /** @@ -85,29 +87,12 @@ public void start() { plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, this::purge, PURGE_RATE, PURGE_RATE); } - /** - * This returns the default {@link Hologram} offset. - * - * @return The default offset - */ - - public Vector getDefaultOffset() { - return defaultOffset; - } - /** * This purges any expired {@link Hologram}. */ private void purge() { - Iterator iterator = cache.values().iterator(); - - while (iterator.hasNext()) { - Hologram hologram = iterator.next(); - if (hologram.hasExpired()) { - iterator.remove(); - } - } + cache.values().removeIf(Hologram::hasExpired); } /** diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Language.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Language.java index 06880eddf3..c3dae6e1cc 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Language.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Language.java @@ -1,20 +1,21 @@ package io.github.thebusybiscuit.slimefun4.core.services.localization; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; import io.github.thebusybiscuit.slimefun4.core.services.LocalizationService; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; -import java.util.Arrays; -import java.util.EnumMap; -import java.util.Locale; -import java.util.Map; -import javax.annotation.Nullable; +import lombok.Getter; import org.apache.commons.lang.Validate; import org.bukkit.Server; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import javax.annotation.Nullable; +import java.util.Arrays; +import java.util.EnumMap; +import java.util.Locale; +import java.util.Map; + /** * This Class represents a {@link Language} that Slimefun can recognize and use. * @@ -27,7 +28,23 @@ public final class Language { private final Map files = new EnumMap<>(LanguageFile.class); + /** + * -- GETTER -- + * This returns the identifier of this + * . + * + */ + @Getter private final String id; + /** + * -- GETTER -- + * This method returns the + * that is used to display this + * in the + * . + * + */ + @Getter private final ItemStack item; private double progress = -1; @@ -50,15 +67,6 @@ public Language(String id, String hash) { Slimefun.getItemTextureService().setTexture(item, "_UI_LANGUAGE_" + id.toUpperCase(Locale.ROOT)); } - /** - * This returns the identifier of this {@link Language}. - * - * @return The identifier of this {@link Language} - */ - public String getId() { - return id; - } - /** * This method returns the progress of translation for this {@link Language}. * The progress is determined by the amount of translated strings divided by the amount @@ -89,16 +97,6 @@ public void setFile(LanguageFile file, FileConfiguration config) { files.put(file, config); } - /** - * This method returns the {@link ItemStack} that is used to display this {@link Language} - * in the {@link SlimefunGuide}. - * - * @return The {@link ItemStack} used to display this {@link Language} - */ - public ItemStack getItem() { - return item; - } - /** * This method localizes the name of this {@link Language} in the selected {@link Language} * of the given {@link Player}. diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/LanguagePreset.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/LanguagePreset.java index a799b0e23b..ef7b41b699 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/LanguagePreset.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/LanguagePreset.java @@ -1,6 +1,8 @@ package io.github.thebusybiscuit.slimefun4.core.services.localization; import javax.annotation.ParametersAreNonnullByDefault; + +import lombok.Getter; import org.bukkit.inventory.ItemStack; /** @@ -64,6 +66,7 @@ public enum LanguagePreset { private final String id; private final boolean releaseReady; private final String textureHash; + @Getter private final TextDirection textDirection; @ParametersAreNonnullByDefault @@ -120,13 +123,4 @@ public String getTexture() { return textureHash; } - /** - * This returns the direction of text for - * this language. - * - * @return The direction of text for this language - */ - public TextDirection getTextDirection() { - return textDirection; - } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/PerformanceRating.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/PerformanceRating.java index 4bddd6666c..7d6471745e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/PerformanceRating.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/PerformanceRating.java @@ -2,6 +2,8 @@ import java.util.function.Predicate; import javax.annotation.Nullable; + +import lombok.Getter; import org.apache.commons.lang.Validate; import org.bukkit.ChatColor; @@ -28,6 +30,7 @@ public enum PerformanceRating implements Predicate { HURTFUL(ChatColor.DARK_RED, 500), BAD(ChatColor.DARK_RED, Float.MAX_VALUE); + @Getter private final ChatColor color; private final float threshold; @@ -47,8 +50,5 @@ public boolean test(@Nullable Float value) { return value <= threshold; } - - public ChatColor getColor() { - return color; - } + } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/ProfiledBlock.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/ProfiledBlock.java index eb7ea24cbe..9d5f0c1316 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/ProfiledBlock.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/ProfiledBlock.java @@ -4,6 +4,8 @@ import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import java.util.Objects; + +import lombok.Getter; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.block.Block; @@ -21,6 +23,7 @@ final class ProfiledBlock { * The {@link World} this {@link Block} is in. * It is fine to keep an actual reference here since this is a throwaway object anyway. */ + @Getter private final World world; /** @@ -77,10 +80,6 @@ private static long getLocationAsLong(int x, int y, int z) { return ((long) (x & 0x3FFFFFF) << 38) | ((long) (z & 0x3FFFFFF) << 12) | (long) (y & 0xFFF); } - - public World getWorld() { - return world; - } /** * Gets the x for this block. diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/SlimefunProfiler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/SlimefunProfiler.java index b42aab4332..91b19dbab7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/SlimefunProfiler.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/SlimefunProfiler.java @@ -57,7 +57,7 @@ public class SlimefunProfiler { * So we cannot simply wait until the next server tick for this. */ private final ExecutorService executor = - Executors.newFixedThreadPool(threadFactory.getThreadCount(), threadFactory); + Executors.newFixedThreadPool(threadFactory.threadCount(), threadFactory); /** * All possible values of {@link PerformanceRating}. diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/SlimefunThreadFactory.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/SlimefunThreadFactory.java index a4c804845c..699482cd2b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/SlimefunThreadFactory.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/SlimefunThreadFactory.java @@ -8,21 +8,16 @@ * and provides a naming convention for our {@link Thread Threads}. * * @author TheBusyBiscuit - * * @see SlimefunProfiler - * */ -final class SlimefunThreadFactory implements ThreadFactory { - - private final int threadCount; +record SlimefunThreadFactory(int threadCount) implements ThreadFactory { /** * This constructs a new {@link SlimefunThreadFactory} with the given {@link Thread} count. * * @param threadCount The amount of {@link Thread Threads} to provide to the {@link SlimefunProfiler} */ - SlimefunThreadFactory(int threadCount) { - this.threadCount = threadCount; + SlimefunThreadFactory { } /** @@ -31,7 +26,8 @@ final class SlimefunThreadFactory implements ThreadFactory { * * @return The {@link Thread} count */ - int getThreadCount() { + @Override + public int threadCount() { return threadCount; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/SoundConfiguration.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/SoundConfiguration.java index 776acc9740..b88d2778b0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/SoundConfiguration.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/SoundConfiguration.java @@ -1,6 +1,8 @@ package io.github.thebusybiscuit.slimefun4.core.services.sounds; +import lombok.Getter; + /** * This structure class holds configured values for a {@link SoundEffect}. * @@ -13,7 +15,9 @@ public class SoundConfiguration { private final String sound; + @Getter private final float volume; + @Getter private final float pitch; protected SoundConfiguration(String sound, float volume, float pitch) { @@ -26,11 +30,4 @@ public String getSoundId() { return sound; } - public float getVolume() { - return volume; - } - - public float getPitch() { - return pitch; - } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/SoundEffect.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/SoundEffect.java index 5e94577299..488b3cd311 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/SoundEffect.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/SoundEffect.java @@ -4,6 +4,8 @@ import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import java.util.logging.Level; import javax.annotation.Nullable; + +import lombok.Getter; import org.bukkit.Location; import org.bukkit.Sound; import org.bukkit.SoundCategory; @@ -104,19 +106,11 @@ public enum SoundEffect { WIND_STAFF_USE_SOUND(Sound.ENTITY_TNT_PRIMED, 1F, 1F); private final String defaultSound; + @Getter private final float defaultVolume; + @Getter private final float defaultPitch; - SoundEffect(String sound, float volume, float pitch) { - Preconditions.checkNotNull(sound, "The Sound id cannot be null!"); - Preconditions.checkArgument(volume >= 0, "The volume cannot be a negative number."); - Preconditions.checkArgument(pitch >= 0.5, "A pitch below 0.5 has no effect on the sound."); - - this.defaultSound = sound; - this.defaultVolume = volume; - this.defaultPitch = pitch; - } - SoundEffect(Sound sound, float volume, float pitch) { Preconditions.checkNotNull(sound, "The Sound id cannot be null!"); Preconditions.checkArgument(volume >= 0, "The volume cannot be a negative number."); @@ -190,21 +184,4 @@ public String getDefaultSoundId() { return defaultSound; } - /** - * This returns the default volume. - * - * @return The default volume. - */ - public float getDefaultVolume() { - return defaultVolume; - } - - /** - * This returns the default pitch. - * - * @return The default pitch. - */ - public float getDefaultPitch() { - return defaultPitch; - } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/SoundService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/SoundService.java index f140ea3021..1d77237067 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/SoundService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/SoundService.java @@ -32,9 +32,11 @@ public SoundService(Slimefun plugin) { // @formatter:off config.getConfiguration() .options() - .header("This file is used to assign the sounds which Slimefun will play.\n" - + "You can fully customize any sound you want and even change their pitch\n" - + "and volume. To disable a sound, simply set the volume to zero.\n"); + .header(""" +This file is used to assign the sounds which Slimefun will play. +You can fully customize any sound you want and even change their pitch +and volume. To disable a sound, simply set the volume to zero. +"""); // @formatter:on config.getConfiguration().options().copyHeader();