> function, @Nonnull Runnable runnable) {
try {
runnable.run();
} catch (Exception x) {
function.apply(x);
}
}
-
}
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 511df32ec3..05c2d84347 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/MinecraftVersion.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/MinecraftVersion.java
@@ -1,19 +1,17 @@
package io.github.thebusybiscuit.slimefun4.api;
+import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
+import io.papermc.lib.PaperLib;
import javax.annotation.Nonnull;
-
import org.apache.commons.lang.Validate;
import org.bukkit.Server;
-import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
-import io.papermc.lib.PaperLib;
-
/**
* This enum holds all versions of Minecraft that we currently support.
- *
+ *
* @author TheBusyBiscuit
* @author Walshy
- *
+ *
* @see Slimefun
*
*/
@@ -69,7 +67,7 @@ public enum MinecraftVersion {
* This constructs a new {@link MinecraftVersion} with the given name.
* This constructor forces the {@link MinecraftVersion} to be real.
* It must be a real version of Minecraft.
- *
+ *
* @param majorVersion
* The major version of minecraft as an {@link Integer}
* @param name
@@ -85,7 +83,7 @@ public enum MinecraftVersion {
* This constructs a new {@link MinecraftVersion} with the given name.
* A virtual {@link MinecraftVersion} (unknown or unit test) is not an actual
* version of Minecraft but rather a state of the {@link Server} software.
- *
+ *
* @param name
* The display name of this {@link MinecraftVersion}
* @param virtual
@@ -99,7 +97,7 @@ public enum MinecraftVersion {
/**
* This returns the name of this {@link MinecraftVersion} in a readable format.
- *
+ *
* @return The name of this {@link MinecraftVersion}
*/
public @Nonnull String getName() {
@@ -112,7 +110,7 @@ public enum MinecraftVersion {
* 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() {
@@ -127,10 +125,10 @@ public boolean isVirtual() {
* It is equivalent to the "major" version
*
* Example: {@literal "1.13"} returns {@literal 13}
- *
+ *
* @param minecraftVersion
* The {@link Integer} version to match
- *
+ *
* @return Whether this {@link MinecraftVersion} matches the specified version id
*/
public boolean isMinecraftVersion(int minecraftVersion) {
@@ -140,12 +138,12 @@ public boolean isMinecraftVersion(int minecraftVersion) {
/**
* This method checks whether this {@link MinecraftVersion} is newer or equal to
* the given {@link MinecraftVersion},
- *
+ *
* An unknown version will default to {@literal false}.
- *
+ *
* @param version
* The {@link MinecraftVersion} to compare
- *
+ *
* @return Whether this {@link MinecraftVersion} is newer or equal to the given {@link MinecraftVersion}
*/
public boolean isAtLeast(@Nonnull MinecraftVersion version) {
@@ -162,7 +160,7 @@ public boolean isAtLeast(@Nonnull MinecraftVersion version) {
* this will essentially always return true and result in a tautology.
* This is most definitely an oversight from us and should be fixed, therefore
* we will trigger an exception.
- *
+ *
* In order to not disrupt server operations, this exception is only thrown during
* unit tests since the oversight itself will be harmless.
*/
@@ -175,12 +173,12 @@ public boolean isAtLeast(@Nonnull MinecraftVersion version) {
/**
* This checks whether this {@link MinecraftVersion} is older than the specified {@link MinecraftVersion}.
- *
+ *
* An unknown version will default to {@literal true}.
- *
+ *
* @param version
* The {@link MinecraftVersion} to compare
- *
+ *
* @return Whether this {@link MinecraftVersion} is older than the given one
*/
public boolean isBefore(@Nonnull MinecraftVersion version) {
@@ -192,5 +190,4 @@ public boolean isBefore(@Nonnull MinecraftVersion version) {
return version.ordinal() > this.ordinal();
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunAddon.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunAddon.java
index fea457064e..376eafaa77 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunAddon.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunAddon.java
@@ -1,27 +1,24 @@
package io.github.thebusybiscuit.slimefun4.api;
+import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import java.util.logging.Logger;
-
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-
import org.apache.commons.lang.Validate;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;
-import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
-
/**
* This is a very basic interface that will be used to identify
* the {@link Plugin} that registered a {@link SlimefunItem}.
- *
+ *
* It will also contain some utility methods such as {@link SlimefunAddon#getBugTrackerURL()}
* to provide some context when bugs arise.
- *
+ *
* It is recommended to implement this interface if you are developing
* an Addon.
- *
+ *
* @author TheBusyBiscuit
* @author ybw0014
*
@@ -31,7 +28,7 @@ public interface SlimefunAddon {
/**
* This method returns the instance of {@link JavaPlugin} that this
* {@link SlimefunAddon} refers to.
- *
+ *
* @return The instance of your {@link JavaPlugin}
*/
@Nonnull
@@ -39,16 +36,15 @@ public interface SlimefunAddon {
/**
* This method returns a link to the Bug Tracker of this {@link SlimefunAddon}
- *
+ *
* @return The URL for this Plugin's Bug Tracker, or null
*/
- @Nullable
- String getBugTrackerURL();
+ @Nullable String getBugTrackerURL();
/**
* This method returns the name of this addon, it defaults to the name
* of the {@link JavaPlugin} provided by {@link SlimefunAddon#getJavaPlugin()}
- *
+ *
* @return The Name of this {@link SlimefunAddon}
*/
default @Nonnull String getName() {
@@ -58,7 +54,7 @@ public interface SlimefunAddon {
/**
* This method returns the version of this addon, it defaults to the version
* of the {@link JavaPlugin} provided by {@link SlimefunAddon#getJavaPlugin()}
- *
+ *
* @return The version of this {@link SlimefunAddon}
*/
default @Nonnull String getPluginVersion() {
@@ -68,7 +64,7 @@ public interface SlimefunAddon {
/**
* This method returns the {@link Logger} of this addon, it defaults to the {@link Logger}
* of the {@link JavaPlugin} provided by {@link SlimefunAddon#getJavaPlugin()}
- *
+ *
* @return The {@link Logger} of this {@link SlimefunAddon}
*/
default @Nonnull Logger getLogger() {
@@ -80,10 +76,10 @@ public interface SlimefunAddon {
* {@link SlimefunAddon}.
* It specifically checks whether the given String can be found in {@link PluginDescriptionFile#getDepend()}
* or {@link PluginDescriptionFile#getSoftDepend()}
- *
+ *
* @param dependency
* The dependency to check for
- *
+ *
* @return Whether this {@link SlimefunAddon} depends on the given {@link Plugin}
*/
default boolean hasDependency(@Nonnull String dependency) {
@@ -95,7 +91,8 @@ default boolean hasDependency(@Nonnull String dependency) {
}
PluginDescriptionFile description = getJavaPlugin().getDescription();
- return description.getDepend().contains(dependency) || description.getSoftDepend().contains(dependency);
+ return description.getDepend().contains(dependency)
+ || description.getSoftDepend().contains(dependency);
}
/**
@@ -106,5 +103,4 @@ default boolean hasDependency(@Nonnull String dependency) {
default @Nullable String getWikiURL() {
return null;
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunBranch.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunBranch.java
index 04aac77a5f..d6df008508 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunBranch.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunBranch.java
@@ -1,11 +1,9 @@
package io.github.thebusybiscuit.slimefun4.api;
+import io.github.bakedlibs.dough.common.CommonPatterns;
import javax.annotation.Nonnull;
-
import org.apache.commons.lang.Validate;
-import io.github.bakedlibs.dough.common.CommonPatterns;
-
/**
* This enum represents the branch this Slimefun build is on.
* development or stable, unofficial or even unknown.
@@ -46,14 +44,15 @@ public enum SlimefunBranch {
this.official = official;
if (!CommonPatterns.ASCII.matcher(name).matches()) {
- throw new IllegalStateException("The SlimefunBranch enum contains ILLEGAL CHARACTERS. DO NOT TRANSLATE THIS FILE.");
+ throw new IllegalStateException(
+ "The SlimefunBranch enum contains ILLEGAL CHARACTERS. DO NOT TRANSLATE THIS FILE.");
}
}
/**
* This returns the name of this {@link SlimefunBranch}. The name is just a more readable
* version of the enum constant.
- *
+ *
* @return The name of this {@link SlimefunBranch}
*/
public @Nonnull String getName() {
@@ -63,11 +62,10 @@ public enum SlimefunBranch {
/**
* This method returns whether this {@link SlimefunBranch} is considered official.
* Or whether it was unofficially modified.
- *
+ *
* @return Whether this branch is an official one.
*/
public boolean isOfficial() {
return official;
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AncientAltarCraftEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AncientAltarCraftEvent.java
index e7d0851bd8..1354bddf22 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AncientAltarCraftEvent.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AncientAltarCraftEvent.java
@@ -3,6 +3,8 @@
import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientAltar;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.AncientAltarListener;
import io.github.thebusybiscuit.slimefun4.implementation.tasks.AncientAltarTask;
+import javax.annotation.Nonnull;
+import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
@@ -12,9 +14,6 @@
import org.bukkit.event.player.PlayerEvent;
import org.bukkit.inventory.ItemStack;
-import javax.annotation.Nonnull;
-import javax.annotation.ParametersAreNonnullByDefault;
-
/**
* This {@link Event} is fired before an item is dropped by an {@link AncientAltar}.
* Cancelling this event will make the {@link AncientAltar} drop no item after the recipe is finished.
@@ -99,5 +98,4 @@ public static HandlerList getHandlerList() {
public HandlerList getHandlers() {
return getHandlerList();
}
-
-}
\ No newline at end of file
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AndroidFarmEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AndroidFarmEvent.java
index 7ca94d4c04..41d6fab59f 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AndroidFarmEvent.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AndroidFarmEvent.java
@@ -2,15 +2,14 @@
import io.github.thebusybiscuit.slimefun4.implementation.items.androids.AndroidInstance;
import io.github.thebusybiscuit.slimefun4.implementation.items.androids.FarmerAndroid;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import org.bukkit.block.Block;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
/**
* This {@link Event} is fired before a {@link FarmerAndroid} harvests a {@link Block}.
* If this {@link Event} is cancelled, the {@link Block} will not be harvested.
@@ -35,7 +34,8 @@ public class AndroidFarmEvent extends Event implements Cancellable {
* @param isAdvanced Whether this is an advanced farming action
* @param drop The item to be dropped or null
*/
- public AndroidFarmEvent(@Nonnull Block block, @Nonnull AndroidInstance android, boolean isAdvanced, @Nullable ItemStack drop) {
+ public AndroidFarmEvent(
+ @Nonnull Block block, @Nonnull AndroidInstance android, boolean isAdvanced, @Nullable ItemStack drop) {
this.block = block;
this.android = android;
this.isAdvanced = isAdvanced;
@@ -57,8 +57,7 @@ public Block getBlock() {
*
* @return The harvested item or null
*/
- @Nullable
- public ItemStack getDrop() {
+ @Nullable public ItemStack getDrop() {
return drop;
}
@@ -111,5 +110,4 @@ public static HandlerList getHandlerList() {
public HandlerList getHandlers() {
return getHandlerList();
}
-
-}
\ No newline at end of file
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AndroidMineEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AndroidMineEvent.java
index 42f6cc0200..9a74a2a474 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AndroidMineEvent.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AndroidMineEvent.java
@@ -2,14 +2,13 @@
import io.github.thebusybiscuit.slimefun4.implementation.items.androids.AndroidInstance;
import io.github.thebusybiscuit.slimefun4.implementation.items.androids.MinerAndroid;
+import javax.annotation.Nonnull;
+import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.block.Block;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
-import javax.annotation.Nonnull;
-import javax.annotation.ParametersAreNonnullByDefault;
-
/**
* This {@link Event} is fired before a {@link MinerAndroid} mines a {@link Block}.
* If this {@link Event} is cancelled, the {@link Block} will not be mined.
@@ -77,5 +76,4 @@ public static HandlerList getHandlerList() {
public HandlerList getHandlers() {
return getHandlerList();
}
-
-}
\ No newline at end of file
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncAutoEnchanterProcessEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncAutoEnchanterProcessEvent.java
index f1373e98f9..1cc1eaf6e2 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncAutoEnchanterProcessEvent.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncAutoEnchanterProcessEvent.java
@@ -1,17 +1,14 @@
package io.github.thebusybiscuit.slimefun4.api.events;
+import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.enchanting.AutoEnchanter;
import javax.annotation.Nonnull;
-
+import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
import org.apache.commons.lang.Validate;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
-import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.enchanting.AutoEnchanter;
-
-import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
-
/**
* An {@link Event} that is called whenever an {@link AutoEnchanter} is
* enchanting an {@link ItemStack}.
@@ -28,7 +25,8 @@ public class AsyncAutoEnchanterProcessEvent extends Event implements Cancellable
private boolean cancelled;
- public AsyncAutoEnchanterProcessEvent(@Nonnull ItemStack item, @Nonnull ItemStack enchantedBook, @Nonnull BlockMenu menu) {
+ public AsyncAutoEnchanterProcessEvent(
+ @Nonnull ItemStack item, @Nonnull ItemStack enchantedBook, @Nonnull BlockMenu menu) {
super(true);
Validate.notNull(item, "The item to enchant cannot be null!");
@@ -90,4 +88,4 @@ public boolean isCancelled() {
public void setCancelled(boolean cancel) {
this.cancelled = cancel;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncMachineOperationFinishEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncMachineOperationFinishEvent.java
index f71a7a7ce7..9a3a628e47 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncMachineOperationFinishEvent.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncMachineOperationFinishEvent.java
@@ -1,16 +1,14 @@
package io.github.thebusybiscuit.slimefun4.api.events;
+import io.github.bakedlibs.dough.blocks.BlockPosition;
+import io.github.thebusybiscuit.slimefun4.core.machines.MachineOperation;
+import io.github.thebusybiscuit.slimefun4.core.machines.MachineProcessor;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-
import org.bukkit.Bukkit;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
-import io.github.bakedlibs.dough.blocks.BlockPosition;
-import io.github.thebusybiscuit.slimefun4.core.machines.MachineOperation;
-import io.github.thebusybiscuit.slimefun4.core.machines.MachineProcessor;
-
/**
* This {@link Event} is fired whenever an {@link MachineProcessor} has completed a {@link MachineOperation}.
*
@@ -26,7 +24,8 @@ public class AsyncMachineOperationFinishEvent extends Event {
private final MachineProcessor> machineProcessor;
private final MachineOperation machineOperation;
- public AsyncMachineOperationFinishEvent(BlockPosition pos, MachineProcessor processor, T operation) {
+ public AsyncMachineOperationFinishEvent(
+ BlockPosition pos, MachineProcessor processor, T operation) {
super(!Bukkit.isPrimaryThread());
this.position = pos;
@@ -49,8 +48,7 @@ public BlockPosition getPosition() {
*
* @return The {@link MachineProcessor} instance of the machine
*/
- @Nullable
- public MachineProcessor> getProcessor() {
+ @Nullable public MachineProcessor> getProcessor() {
return machineProcessor;
}
@@ -59,8 +57,7 @@ public MachineProcessor> getProcessor() {
*
* @return The {@link MachineOperation} of the process
*/
- @Nullable
- public MachineOperation getOperation() {
+ @Nullable public MachineOperation getOperation() {
return machineOperation;
}
@@ -74,4 +71,4 @@ public static HandlerList getHandlerList() {
public HandlerList getHandlers() {
return getHandlerList();
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncProfileLoadEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncProfileLoadEvent.java
index 8525c4291e..e51be3b205 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncProfileLoadEvent.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncProfileLoadEvent.java
@@ -1,16 +1,13 @@
package io.github.thebusybiscuit.slimefun4.api.events;
+import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
import java.util.UUID;
-
import javax.annotation.Nonnull;
-
import org.apache.commons.lang.Validate;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
-import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
-
/**
* This {@link Event} is called when the {@link PlayerProfile} of a {@link Player}
* is loaded into memory.
@@ -72,4 +69,4 @@ public static HandlerList getHandlerList() {
public HandlerList getHandlers() {
return getHandlerList();
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AutoDisenchantEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AutoDisenchantEvent.java
index d4dfdf8a8e..d77d787cc1 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AutoDisenchantEvent.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AutoDisenchantEvent.java
@@ -1,13 +1,12 @@
package io.github.thebusybiscuit.slimefun4.api.events;
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.enchanting.AutoDisenchanter;
+import javax.annotation.Nonnull;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
-import javax.annotation.Nonnull;
-
/**
* An {@link Event} that is called whenever an {@link AutoDisenchanter} has
* disenchanted an {@link ItemStack}.
@@ -57,5 +56,4 @@ public static HandlerList getHandlerList() {
public HandlerList getHandlers() {
return getHandlerList();
}
-
-}
\ No newline at end of file
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AutoEnchantEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AutoEnchantEvent.java
index f4697a50d5..0ce7b14299 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AutoEnchantEvent.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AutoEnchantEvent.java
@@ -1,14 +1,12 @@
package io.github.thebusybiscuit.slimefun4.api.events;
+import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.enchanting.AutoEnchanter;
import javax.annotation.Nonnull;
-
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
-import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.enchanting.AutoEnchanter;
-
/**
* An {@link Event} that is called whenever an {@link AutoEnchanter} is trying to enchant
* an {@link ItemStack}.
@@ -60,5 +58,4 @@ public static HandlerList getHandlerList() {
public HandlerList getHandlers() {
return getHandlerList();
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/BlockPlacerPlaceEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/BlockPlacerPlaceEvent.java
index 4ea35c510d..0e288b52fb 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/BlockPlacerPlaceEvent.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/BlockPlacerPlaceEvent.java
@@ -1,8 +1,9 @@
package io.github.thebusybiscuit.slimefun4.api.events;
+import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
+import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.BlockPlacer;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
-
import org.apache.commons.lang.Validate;
import org.bukkit.block.Block;
import org.bukkit.event.Cancellable;
@@ -11,14 +12,11 @@
import org.bukkit.event.block.BlockEvent;
import org.bukkit.inventory.ItemStack;
-import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
-import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.BlockPlacer;
-
/**
* This {@link Event} is fired whenever a {@link BlockPlacer} wants to place a {@link Block}.
- *
+ *
* @author TheBusyBiscuit
- *
+ *
*/
public class BlockPlacerPlaceEvent extends BlockEvent implements Cancellable {
@@ -32,7 +30,7 @@ public class BlockPlacerPlaceEvent extends BlockEvent implements Cancellable {
/**
* This creates a new {@link BlockPlacerPlaceEvent}.
- *
+ *
* @param blockPlacer
* The {@link BlockPlacer}
* @param placedItem
@@ -60,7 +58,7 @@ public Block getBlockPlacer() {
/**
* This returns the placed {@link ItemStack}.
- *
+ *
* @return The placed {@link ItemStack}
*/
@Nonnull
@@ -70,7 +68,7 @@ public ItemStack getItemStack() {
/**
* This sets the placed {@link ItemStack}.
- *
+ *
* @param item
* The {@link ItemStack} to be placed
*/
@@ -80,7 +78,8 @@ public void setItemStack(@Nonnull ItemStack item) {
if (!locked) {
this.placedItem = item;
} else {
- SlimefunItem.getByItem(placedItem).warn("A BlockPlacerPlaceEvent cannot be modified from within a BlockPlaceHandler!");
+ SlimefunItem.getByItem(placedItem)
+ .warn("A BlockPlacerPlaceEvent cannot be modified from within a BlockPlaceHandler!");
}
}
@@ -94,7 +93,8 @@ public void setCancelled(boolean cancel) {
if (!locked) {
cancelled = cancel;
} else {
- SlimefunItem.getByItem(placedItem).warn("A BlockPlacerPlaceEvent cannot be modified from within a BlockPlaceHandler!");
+ SlimefunItem.getByItem(placedItem)
+ .warn("A BlockPlacerPlaceEvent cannot be modified from within a BlockPlaceHandler!");
}
}
@@ -115,5 +115,4 @@ public static HandlerList getHandlerList() {
public HandlerList getHandlers() {
return getHandlerList();
}
-
-}
\ No newline at end of file
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ClimbingPickLaunchEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ClimbingPickLaunchEvent.java
index b8b93ed4fc..06a8cff8fd 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ClimbingPickLaunchEvent.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ClimbingPickLaunchEvent.java
@@ -1,6 +1,8 @@
package io.github.thebusybiscuit.slimefun4.api.events;
import io.github.thebusybiscuit.slimefun4.implementation.items.tools.ClimbingPick;
+import javax.annotation.Nonnull;
+import javax.annotation.ParametersAreNonnullByDefault;
import org.apache.commons.lang.Validate;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
@@ -11,9 +13,6 @@
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
-import javax.annotation.Nonnull;
-import javax.annotation.ParametersAreNonnullByDefault;
-
/**
* An {@link Event} that is called whenever a {@link Player} has
* used a {@link ClimbingPick} on a climbable surface.
@@ -33,7 +32,8 @@ public class ClimbingPickLaunchEvent extends PlayerEvent implements Cancellable
private boolean cancelled;
@ParametersAreNonnullByDefault
- public ClimbingPickLaunchEvent(Player player, Vector velocity, ClimbingPick pick, ItemStack itemStack, Block block) {
+ public ClimbingPickLaunchEvent(
+ Player player, Vector velocity, ClimbingPick pick, ItemStack itemStack, Block block) {
super(player);
this.velocity = velocity;
@@ -114,4 +114,4 @@ public static HandlerList getHandlerList() {
public HandlerList getHandlers() {
return getHandlerList();
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/CoolerFeedPlayerEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/CoolerFeedPlayerEvent.java
index a4dd3910a3..ffae0a3a01 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/CoolerFeedPlayerEvent.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/CoolerFeedPlayerEvent.java
@@ -1,6 +1,8 @@
package io.github.thebusybiscuit.slimefun4.api.events;
import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.Cooler;
+import javax.annotation.Nonnull;
+import javax.annotation.ParametersAreNonnullByDefault;
import org.apache.commons.lang.Validate;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
@@ -11,9 +13,6 @@
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.potion.PotionEffect;
-import javax.annotation.Nonnull;
-import javax.annotation.ParametersAreNonnullByDefault;
-
/**
* This {@link Event} is called whenever a {@link Player} is
* fed through a {@link Cooler}.
@@ -106,4 +105,4 @@ public static HandlerList getHandlerList() {
public HandlerList getHandlers() {
return getHandlerList();
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ExplosiveToolBreakBlocksEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ExplosiveToolBreakBlocksEvent.java
index c4ecf687c6..0a3676197e 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ExplosiveToolBreakBlocksEvent.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ExplosiveToolBreakBlocksEvent.java
@@ -1,10 +1,9 @@
package io.github.thebusybiscuit.slimefun4.api.events;
+import io.github.thebusybiscuit.slimefun4.implementation.items.tools.ExplosiveTool;
import java.util.List;
-
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
-
import org.apache.commons.lang.Validate;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
@@ -14,8 +13,6 @@
import org.bukkit.event.player.PlayerEvent;
import org.bukkit.inventory.ItemStack;
-import io.github.thebusybiscuit.slimefun4.implementation.items.tools.ExplosiveTool;
-
/**
* This {@link Event} is called when an {@link ExplosiveTool} is used to break blocks.
*
@@ -35,7 +32,8 @@ public class ExplosiveToolBreakBlocksEvent extends PlayerEvent implements Cancel
private boolean cancelled;
@ParametersAreNonnullByDefault
- public ExplosiveToolBreakBlocksEvent(Player player, Block block, List blocks, ItemStack item, ExplosiveTool explosiveTool) {
+ public ExplosiveToolBreakBlocksEvent(
+ Player player, Block block, List blocks, ItemStack item, ExplosiveTool explosiveTool) {
super(player);
Validate.notNull(block, "The center block cannot be null!");
@@ -111,4 +109,4 @@ public static HandlerList getHandlerList() {
public HandlerList getHandlers() {
return getHandlerList();
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/GEOResourceGenerationEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/GEOResourceGenerationEvent.java
index 1b03fe6343..f0b2c60acb 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/GEOResourceGenerationEvent.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/GEOResourceGenerationEvent.java
@@ -3,6 +3,8 @@
import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource;
import io.github.thebusybiscuit.slimefun4.api.geo.ResourceManager;
import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOScanner;
+import javax.annotation.Nonnull;
+import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.World;
@@ -11,9 +13,6 @@
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
-import javax.annotation.Nonnull;
-import javax.annotation.ParametersAreNonnullByDefault;
-
/**
* This {@link Event} is fired whenever a {@link GEOResource} is being freshly generated.
* This only occurs when a {@link GEOScanner} queries the {@link Chunk} for a {@link GEOResource}
@@ -143,5 +142,4 @@ public static HandlerList getHandlerList() {
public HandlerList getHandlers() {
return getHandlerList();
}
-
-}
\ No newline at end of file
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/MultiBlockInteractEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/MultiBlockInteractEvent.java
index 30b3ad1242..1a8f85520e 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/MultiBlockInteractEvent.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/MultiBlockInteractEvent.java
@@ -1,6 +1,8 @@
package io.github.thebusybiscuit.slimefun4.api.events;
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlock;
+import javax.annotation.Nonnull;
+import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
@@ -9,9 +11,6 @@
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
-import javax.annotation.Nonnull;
-import javax.annotation.ParametersAreNonnullByDefault;
-
/**
* This {@link Event} is called when a {@link Player} interacts with a {@link MultiBlock}.
*
@@ -84,5 +83,4 @@ public static HandlerList getHandlerList() {
public HandlerList getHandlers() {
return getHandlerList();
}
-
-}
\ No newline at end of file
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerLanguageChangeEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerLanguageChangeEvent.java
index ab624060ec..373ce2f4b9 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerLanguageChangeEvent.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerLanguageChangeEvent.java
@@ -2,12 +2,11 @@
import io.github.thebusybiscuit.slimefun4.core.services.LocalizationService;
import io.github.thebusybiscuit.slimefun4.core.services.localization.Language;
+import javax.annotation.Nonnull;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
-import javax.annotation.Nonnull;
-
/**
* This {@link Event} gets called when a {@link Player} has switched their {@link Language}.
*
@@ -68,5 +67,4 @@ public static HandlerList getHandlerList() {
public HandlerList getHandlers() {
return getHandlerList();
}
-
-}
\ No newline at end of file
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerPreResearchEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerPreResearchEvent.java
index 1e0a618697..c8e2859cc4 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerPreResearchEvent.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerPreResearchEvent.java
@@ -1,19 +1,17 @@
package io.github.thebusybiscuit.slimefun4.api.events;
+import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
+import io.github.thebusybiscuit.slimefun4.api.researches.Research;
+import io.github.thebusybiscuit.slimefun4.implementation.guide.CheatSheetSlimefunGuide;
+import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
-
import org.apache.commons.lang.Validate;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
-import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
-import io.github.thebusybiscuit.slimefun4.api.researches.Research;
-import io.github.thebusybiscuit.slimefun4.implementation.guide.CheatSheetSlimefunGuide;
-import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide;
-
/**
* This {@link Event} is called whenever a {@link Player} clicks to unlock a {@link Research}.
* This is called before {@link Research#canUnlock(Player)}.
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerRightClickEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerRightClickEvent.java
index f6d613d3d9..92f03399c1 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerRightClickEvent.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerRightClickEvent.java
@@ -3,6 +3,8 @@
import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils;
import io.github.bakedlibs.dough.data.TriStateOptional;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
+import java.util.Optional;
+import javax.annotation.Nonnull;
import org.apache.commons.lang.Validate;
import org.bukkit.Material;
import org.bukkit.block.Block;
@@ -15,9 +17,6 @@
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
-import javax.annotation.Nonnull;
-import java.util.Optional;
-
/**
* The {@link PlayerRightClickEvent} is our custom version of the {@link PlayerInteractEvent}.
* But it is only triggered on right click.
@@ -25,7 +24,7 @@
* of the {@link ItemStack} and/or {@link Block} involved.
* This allows us (and addons) to efficiently check the used {@link SlimefunItem} without the need
* to do a heavy lookup or item comparison.
- *
+ *
* @author TheBusyBiscuit
*
*/
@@ -53,7 +52,7 @@ public class PlayerRightClickEvent extends PlayerEvent {
/**
* This constructs a new {@link PlayerRightClickEvent} based on the original {@link PlayerInteractEvent}.
* The {@link Result} of the original {@link PlayerInteractEvent} will be copied.
- *
+ *
* @param originalEvent
* The original {@link PlayerInteractEvent}
*/
@@ -68,7 +67,9 @@ public PlayerRightClickEvent(@Nonnull PlayerInteractEvent originalEvent) {
itemResult = originalEvent.useItemInHand();
blockResult = originalEvent.useInteractedBlock();
- if (originalEvent.getItem() == null || originalEvent.getItem().getType() == Material.AIR || originalEvent.getItem().getAmount() == 0) {
+ if (originalEvent.getItem() == null
+ || originalEvent.getItem().getType() == Material.AIR
+ || originalEvent.getItem().getAmount() == 0) {
itemStack = Optional.empty();
} else {
itemStack = Optional.of(originalEvent.getItem());
@@ -78,7 +79,7 @@ public PlayerRightClickEvent(@Nonnull PlayerInteractEvent originalEvent) {
/**
* This returns the original {@link PlayerInteractEvent} that triggered this
* {@link PlayerRightClickEvent}.
- *
+ *
* @return The original {@link PlayerInteractEvent}
*/
@Nonnull
@@ -90,7 +91,7 @@ public PlayerInteractEvent getInteractEvent() {
* This method returns the {@link ItemStack} that was held in the hand of the {@link Player}.
* It will never return null, should there be no {@link ItemStack} then it will return
* {@code new ItemStack(Material.AIR)}.
- *
+ *
* @return The {@link ItemStack} that the {@link Player} right clicked with
*/
@Nonnull
@@ -101,7 +102,7 @@ public ItemStack getItem() {
/**
* This returns the hand that was used in this interaction.
* Can either be {@code EquipmentSlot.HAND} or {@code EquipmentSlot.OFF_HAND}.
- *
+ *
* @return The hand used in this {@link Event}
*/
@Nonnull
@@ -136,7 +137,8 @@ public Optional getSlimefunItem() {
public Optional getSlimefunBlock() {
if (!slimefunBlock.isComputed()) {
if (clickedBlock.isPresent()) {
- slimefunBlock.compute(StorageCacheUtils.getSfItem(clickedBlock.get().getLocation()));
+ slimefunBlock.compute(
+ StorageCacheUtils.getSfItem(clickedBlock.get().getLocation()));
} else {
slimefunBlock = TriStateOptional.empty();
}
@@ -184,5 +186,4 @@ public static HandlerList getHandlerList() {
public HandlerList getHandlers() {
return getHandlerList();
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ReactorExplodeEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ReactorExplodeEvent.java
index 859a80935b..3948766f66 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ReactorExplodeEvent.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ReactorExplodeEvent.java
@@ -1,18 +1,16 @@
package io.github.thebusybiscuit.slimefun4.api.events;
+import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
+import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.Reactor;
import javax.annotation.Nonnull;
-
import org.apache.commons.lang.Validate;
import org.bukkit.Location;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
-import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
-import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.Reactor;
-
/**
* The {@link ReactorExplodeEvent} is called whenever a reactor explodes.
- *
+ *
* @author TheBusyBiscuit
*
*/
@@ -33,7 +31,7 @@ public ReactorExplodeEvent(@Nonnull Location l, @Nonnull Reactor reactor) {
/**
* This returns the {@link Location} where the reactor exploded.
- *
+ *
* @return The {@link Location} of this explosion
*/
@Nonnull
@@ -43,7 +41,7 @@ public Location getLocation() {
/**
* The {@link SlimefunItem} instance of the exploded reactor.
- *
+ *
* @return The {@link SlimefunItem} instance
*/
@Nonnull
@@ -61,5 +59,4 @@ public static HandlerList getHandlerList() {
public HandlerList getHandlers() {
return getHandlerList();
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ResearchUnlockEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ResearchUnlockEvent.java
index 59d097a2ad..4b73e2dad7 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ResearchUnlockEvent.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ResearchUnlockEvent.java
@@ -1,7 +1,7 @@
package io.github.thebusybiscuit.slimefun4.api.events;
+import io.github.thebusybiscuit.slimefun4.api.researches.Research;
import javax.annotation.Nonnull;
-
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@@ -9,13 +9,11 @@
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
-import io.github.thebusybiscuit.slimefun4.api.researches.Research;
-
/**
* This {@link Event} is called whenever a {@link Player} unlocks a {@link Research}.
- *
+ *
* @author TheBusyBiscuit
- *
+ *
* @see Research
*
*/
@@ -67,5 +65,4 @@ public static HandlerList getHandlerList() {
public HandlerList getHandlers() {
return getHandlerList();
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunBlockBreakEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunBlockBreakEvent.java
index 8554a69499..f354409671 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunBlockBreakEvent.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunBlockBreakEvent.java
@@ -1,21 +1,18 @@
package io.github.thebusybiscuit.slimefun4.api.events;
+import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
-
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
-import org.bukkit.event.block.BlockEvent;
import org.bukkit.inventory.ItemStack;
-import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
-
/**
* This {@link Event} is fired whenever a {@link SlimefunItem} placed as a {@link Block} in the world is broken.
- *
+ *
* @author J3fftw1
*/
public class SlimefunBlockBreakEvent extends Event implements Cancellable {
@@ -42,7 +39,7 @@ public class SlimefunBlockBreakEvent extends Event implements Cancellable {
@ParametersAreNonnullByDefault
public SlimefunBlockBreakEvent(Player player, ItemStack heldItem, Block blockBroken, SlimefunItem slimefunItem) {
super();
-
+
this.player = player;
this.heldItem = heldItem;
this.blockBroken = blockBroken;
@@ -51,7 +48,7 @@ public SlimefunBlockBreakEvent(Player player, ItemStack heldItem, Block blockBro
/**
* This gets the broken {@link Block}
- *
+ *
* @return The broken {@link Block}
*/
public @Nonnull Block getBlockBroken() {
@@ -60,7 +57,7 @@ public SlimefunBlockBreakEvent(Player player, ItemStack heldItem, Block blockBro
/**
* This gets the {@link SlimefunItem} being broken
- *
+ *
* @return The {@link SlimefunItem} being broken
*/
public @Nonnull SlimefunItem getSlimefunItem() {
@@ -69,7 +66,7 @@ public SlimefunBlockBreakEvent(Player player, ItemStack heldItem, Block blockBro
/**
* The {@link ItemStack} held by the {@link Player}
- *
+ *
* @return The held {@link ItemStack}
*/
public @Nonnull ItemStack getHeldItem() {
@@ -78,7 +75,7 @@ public SlimefunBlockBreakEvent(Player player, ItemStack heldItem, Block blockBro
/**
* This gets the {@link Player}
- *
+ *
* @return The {@link Player}
*/
public @Nonnull Player getPlayer() {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunBlockPlaceEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunBlockPlaceEvent.java
index 2978b9d77a..7627d20849 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunBlockPlaceEvent.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunBlockPlaceEvent.java
@@ -1,8 +1,8 @@
package io.github.thebusybiscuit.slimefun4.api.events;
+import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
-
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
@@ -10,11 +10,9 @@
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
-import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
-
/**
* This {@link Event} is fired whenever a {@link SlimefunItem} is placed as a {@link Block} in the world.
- *
+ *
* @author J3fftw1
*/
public class SlimefunBlockPlaceEvent extends Event implements Cancellable {
@@ -68,7 +66,7 @@ public SlimefunBlockPlaceEvent(Player player, ItemStack placedItem, Block blockP
/**
* This gets the placed {@link ItemStack}.
- *
+ *
* @return The placed {@link ItemStack}
*/
public @Nonnull ItemStack getItemStack() {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunGuideOpenEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunGuideOpenEvent.java
index ecf46a5311..0892beb063 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunGuideOpenEvent.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunGuideOpenEvent.java
@@ -1,7 +1,7 @@
package io.github.thebusybiscuit.slimefun4.api.events;
+import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode;
import javax.annotation.Nonnull;
-
import org.apache.commons.lang.Validate;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
@@ -9,11 +9,9 @@
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
-import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode;
-
/**
* This {@link Event} is called whenever a {@link Player} tries to open the Slimefun Guide book.
- *
+ *
* @author Linox
*
* @see SlimefunGuideMode
@@ -100,5 +98,4 @@ public static HandlerList getHandlerList() {
public HandlerList getHandlers() {
return getHandlerList();
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunItemSpawnEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunItemSpawnEvent.java
index f023a9c5ce..bd18a8d911 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunItemSpawnEvent.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunItemSpawnEvent.java
@@ -1,8 +1,8 @@
package io.github.thebusybiscuit.slimefun4.api.events;
+import io.github.thebusybiscuit.slimefun4.api.items.ItemSpawnReason;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
-
import org.apache.commons.lang.Validate;
import org.bukkit.Location;
import org.bukkit.event.Cancellable;
@@ -10,8 +10,6 @@
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
-import io.github.thebusybiscuit.slimefun4.api.items.ItemSpawnReason;
-
/**
* This {@link Event} is fired whenever slimefun drops an {@link ItemStack}.
* Creating a custom {@link Event} for this allows other plugins to provide
@@ -108,4 +106,4 @@ public void setCancelled(boolean cancelled) {
public @Nonnull HandlerList getHandlers() {
return getHandlerList();
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/WaypointCreateEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/WaypointCreateEvent.java
index 46aaadab81..4af2701619 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/WaypointCreateEvent.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/WaypointCreateEvent.java
@@ -3,6 +3,7 @@
import io.github.thebusybiscuit.slimefun4.api.gps.GPSNetwork;
import io.github.thebusybiscuit.slimefun4.api.gps.TeleportationManager;
import io.github.thebusybiscuit.slimefun4.api.gps.Waypoint;
+import javax.annotation.Nonnull;
import org.apache.commons.lang.Validate;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@@ -10,8 +11,6 @@
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
-import javax.annotation.Nonnull;
-
/**
* A {@link WaypointCreateEvent} is called when a {@link Player} creates a new waypoint.
* Either manually or through dying with an emergency transmitter.
@@ -116,5 +115,4 @@ public static HandlerList getHandlerList() {
public HandlerList getHandlers() {
return getHandlerList();
}
-
-}
\ No newline at end of file
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/package-info.java
index cb36d7d8c2..d239a33e2b 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/package-info.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/package-info.java
@@ -2,4 +2,4 @@
* This package contains all extensions of {@link org.bukkit.event.Event} that Slimefun provides
* and allows you to listen to.
*/
-package io.github.thebusybiscuit.slimefun4.api.events;
\ No newline at end of file
+package io.github.thebusybiscuit.slimefun4.api.events;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/BiomeMapException.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/BiomeMapException.java
index 8a116e283c..691b5ae55c 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/BiomeMapException.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/BiomeMapException.java
@@ -1,15 +1,13 @@
package io.github.thebusybiscuit.slimefun4.api.exceptions;
+import io.github.thebusybiscuit.slimefun4.utils.biomes.BiomeMap;
import javax.annotation.ParametersAreNonnullByDefault;
-
import org.bukkit.NamespacedKey;
-import io.github.thebusybiscuit.slimefun4.utils.biomes.BiomeMap;
-
/**
* A {@link BiomeMapException} is thrown whenever a {@link BiomeMap}
* contains illegal, invalid or unknown values.
- *
+ *
* @author TheBusyBiscuit
*
*/
@@ -20,7 +18,7 @@ public class BiomeMapException extends Exception {
/**
* This constructs a new {@link BiomeMapException} for the given
* {@link BiomeMap}'s {@link NamespacedKey} with the provided context.
- *
+ *
* @param key
* The {@link NamespacedKey} of our {@link BiomeMap}
* @param message
@@ -34,7 +32,7 @@ public BiomeMapException(NamespacedKey key, String message) {
/**
* This constructs a new {@link BiomeMapException} for the given
* {@link BiomeMap}'s {@link NamespacedKey} with the provided context.
- *
+ *
* @param key
* The {@link NamespacedKey} of our {@link BiomeMap}
* @param cause
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/IdConflictException.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/IdConflictException.java
index bc9b5b4fe0..f66eeec7ef 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/IdConflictException.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/IdConflictException.java
@@ -1,13 +1,12 @@
package io.github.thebusybiscuit.slimefun4.api.exceptions;
-import javax.annotation.ParametersAreNonnullByDefault;
-
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
+import javax.annotation.ParametersAreNonnullByDefault;
/**
* An {@link IdConflictException} is thrown whenever two Addons try to add
* a {@link SlimefunItem} with the same id.
- *
+ *
* @author TheBusyBiscuit
*
*/
@@ -17,7 +16,7 @@ public class IdConflictException extends RuntimeException {
/**
* Constructs a new {@link IdConflictException} with the given items.
- *
+ *
* @param item1
* The first {@link SlimefunItem} with this id
* @param item2
@@ -27,5 +26,4 @@ public class IdConflictException extends RuntimeException {
public IdConflictException(SlimefunItem item1, SlimefunItem item2) {
super("Two items have conflicting ids: " + item1.toString() + " and " + item2.toString());
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/IncompatibleItemHandlerException.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/IncompatibleItemHandlerException.java
index e80f23a505..7bb894c906 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/IncompatibleItemHandlerException.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/IncompatibleItemHandlerException.java
@@ -1,23 +1,21 @@
package io.github.thebusybiscuit.slimefun4.api.exceptions;
-import javax.annotation.ParametersAreNonnullByDefault;
-
-import org.bukkit.plugin.Plugin;
-
import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler;
+import javax.annotation.ParametersAreNonnullByDefault;
+import org.bukkit.plugin.Plugin;
/**
* An {@link IncompatibleItemHandlerException} is thrown whenever a {@link Plugin} tried
* to add an {@link ItemHandler} to a {@link SlimefunItem} despite the {@link SlimefunItem}
* not allowing an {@link ItemHandler} of that type to be added.
- *
+ *
* An example for this is the {@link BlockUseHandler}, it can only be added to blocks.
* So it will throw this exception when it is added to a non-block item.
- *
+ *
* @author TheBusyBiscuit
- *
+ *
* @see ItemHandler
* @see SlimefunItem
*
@@ -29,7 +27,7 @@ public class IncompatibleItemHandlerException extends RuntimeException {
/**
* Constructs a new {@link IncompatibleItemHandlerException} with the given {@link SlimefunItem} and
* {@link ItemHandler}
- *
+ *
* @param message
* The reason why they are incompatible
* @param item
@@ -39,7 +37,12 @@ public class IncompatibleItemHandlerException extends RuntimeException {
*/
@ParametersAreNonnullByDefault
public IncompatibleItemHandlerException(String message, SlimefunItem item, ItemHandler handler) {
- super("The item handler type: \"" + handler.getIdentifier().getSimpleName() + "\" is not compatible with " + item + " (" + message + ')');
+ super("The item handler type: \""
+ + handler.getIdentifier().getSimpleName()
+ + "\" is not compatible with "
+ + item
+ + " ("
+ + message
+ + ')');
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/MissingDependencyException.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/MissingDependencyException.java
index c3e94b5229..48c53f4746 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/MissingDependencyException.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/MissingDependencyException.java
@@ -1,7 +1,6 @@
package io.github.thebusybiscuit.slimefun4.api.exceptions;
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
-
import javax.annotation.ParametersAreNonnullByDefault;
/**
@@ -24,7 +23,10 @@ public class MissingDependencyException extends RuntimeException {
*/
@ParametersAreNonnullByDefault
public MissingDependencyException(SlimefunAddon addon, String dependency) {
- super("Slimefun Addon \"" + addon.getName() + "\" forgot to define \"" + dependency + "\" as a depend or softdepend inside the plugin.yml file");
+ super("Slimefun Addon \""
+ + addon.getName()
+ + "\" forgot to define \""
+ + dependency
+ + "\" as a depend or softdepend inside the plugin.yml file");
}
-
-}
\ No newline at end of file
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/PrematureCodeException.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/PrematureCodeException.java
index 6ee1df5a38..0d1d97143c 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/PrematureCodeException.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/PrematureCodeException.java
@@ -1,7 +1,6 @@
package io.github.thebusybiscuit.slimefun4.api.exceptions;
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
-
import javax.annotation.ParametersAreNonnullByDefault;
/**
@@ -24,5 +23,4 @@ public class PrematureCodeException extends RuntimeException {
public PrematureCodeException(String message) {
super("Slimefun code was invoked before Slimefun finished loading: " + message);
}
-
-}
\ No newline at end of file
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/TagMisconfigurationException.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/TagMisconfigurationException.java
index ab46ab9ec5..44e2cbaccb 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/TagMisconfigurationException.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/TagMisconfigurationException.java
@@ -1,9 +1,8 @@
package io.github.thebusybiscuit.slimefun4.api.exceptions;
import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
-import org.bukkit.NamespacedKey;
-
import javax.annotation.ParametersAreNonnullByDefault;
+import org.bukkit.NamespacedKey;
/**
* An {@link TagMisconfigurationException} is thrown whenever a {@link SlimefunTag}
@@ -38,5 +37,4 @@ public TagMisconfigurationException(NamespacedKey key, String message) {
public TagMisconfigurationException(NamespacedKey key, Throwable cause) {
super("Tag '" + key + "' has been misconfigured (" + cause.getMessage() + ')', cause);
}
-
-}
\ No newline at end of file
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/UnregisteredItemException.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/UnregisteredItemException.java
index 2d2549bf00..bc78b106c6 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/UnregisteredItemException.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/UnregisteredItemException.java
@@ -1,19 +1,17 @@
package io.github.thebusybiscuit.slimefun4.api.exceptions;
+import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import javax.annotation.ParametersAreNonnullByDefault;
-
import org.bukkit.plugin.Plugin;
-import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
-
/**
* An {@link UnregisteredItemException} is thrown whenever a {@link Plugin} tried to
* access a method prematurely from {@link SlimefunItem} that can only be called after the
* {@link SlimefunItem} was registered.
- *
+ *
* In other words... calling this method this early can not result in a logical output, making
* this an {@link Exception}.
- *
+ *
* @author TheBusyBiscuit
*
*/
@@ -23,7 +21,7 @@ public class UnregisteredItemException extends RuntimeException {
/**
* Constructs a new {@link UnregisteredItemException} with the given {@link SlimefunItem}
- *
+ *
* @param item
* The {@link SlimefunItem} that was affected by this
*/
@@ -31,5 +29,4 @@ public class UnregisteredItemException extends RuntimeException {
public UnregisteredItemException(SlimefunItem item) {
super(item.toString() + " has not been registered yet.");
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/WrongItemStackException.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/WrongItemStackException.java
index b3349ab98b..28180bef53 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/WrongItemStackException.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/WrongItemStackException.java
@@ -1,22 +1,20 @@
package io.github.thebusybiscuit.slimefun4.api.exceptions;
-import javax.annotation.ParametersAreNonnullByDefault;
-
-import org.bukkit.inventory.ItemStack;
-
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem;
+import javax.annotation.ParametersAreNonnullByDefault;
+import org.bukkit.inventory.ItemStack;
/**
* A {@link WrongItemStackException} is thrown when someone tries to alter an {@link ItemStack}
* but actually wanted to alter a different one.
- *
+ *
* If for example a {@link DamageableItem} accidentally damages the original {@link SlimefunItem}
* instead of the held {@link ItemStack}, this will be thrown.
- *
+ *
* @author TheBusyBiscuit
- *
+ *
* @see SlimefunItemStack
* @see SlimefunItem
*
@@ -34,5 +32,4 @@ public class WrongItemStackException extends RuntimeException {
public WrongItemStackException(String message) {
super("You probably wanted to alter a different ItemStack: " + message);
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/package-info.java
index da014fff27..d0548e35f1 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/package-info.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/package-info.java
@@ -2,4 +2,4 @@
* This package contains all different extensions of {@link java.lang.Exception} that Slimefun
* uses internally.
*/
-package io.github.thebusybiscuit.slimefun4.api.exceptions;
\ No newline at end of file
+package io.github.thebusybiscuit.slimefun4.api.exceptions;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/GEOResource.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/GEOResource.java
index 36aa5aee76..533108ee6c 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/GEOResource.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/GEOResource.java
@@ -1,7 +1,11 @@
package io.github.thebusybiscuit.slimefun4.api.geo;
+import io.github.thebusybiscuit.slimefun4.api.events.GEOResourceGenerationEvent;
+import io.github.thebusybiscuit.slimefun4.core.services.localization.Language;
+import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
+import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOMiner;
+import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOScanner;
import javax.annotation.Nonnull;
-
import org.bukkit.Chunk;
import org.bukkit.Keyed;
import org.bukkit.World;
@@ -10,23 +14,17 @@
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
-import io.github.thebusybiscuit.slimefun4.api.events.GEOResourceGenerationEvent;
-import io.github.thebusybiscuit.slimefun4.core.services.localization.Language;
-import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
-import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOMiner;
-import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOScanner;
-
/**
* A {@link GEOResource} is a virtual resource that can be thought of as world-gen.
* However it cannot be found in a {@link World}.
- *
+ *
* This resource only exists in memory and can be retrieved through a {@link GEOMiner}
* or similar devices.
- *
+ *
* A {@link GEOResource} can be detected via the {@link GEOScanner}.
- *
+ *
* @author TheBusyBiscuit
- *
+ *
* @see ResourceManager
* @see GEOMiner
* @see GEOScanner
@@ -37,26 +35,26 @@ public interface GEOResource extends Keyed {
/**
* Returns the default supply of this resource in that biome
- *
+ *
* @param environment
* The {@link Environment} this area is currently in (NORMAL / NETHER / THE_END)
* @param biome
* The {@link Biome} this area is currently in.
- *
+ *
* @return The default supply found in a {@link Chunk} with the given {@link Biome}
*/
int getDefaultSupply(@Nonnull Environment environment, @Nonnull Biome biome);
/**
* Returns how much the value may deviate from the default supply (positive only).
- *
+ *
* @return The deviation or spread of the supply
*/
int getMaxDeviation();
/**
* Returns the name of this resource (e.g. "Oil")
- *
+ *
* @return The name of this Resource
*/
@Nonnull
@@ -65,7 +63,7 @@ public interface GEOResource extends Keyed {
/**
* This {@link ItemStack} is used for display-purposes in the GEO Scanner.
* But will also determine the Output of the GEO Miner, if it is applicable for that.
- *
+ *
* @return The {@link ItemStack} version of this Resource.
*/
@Nonnull
@@ -74,7 +72,7 @@ public interface GEOResource extends Keyed {
/**
* Returns whether this Resource can be obtained using a GEO Miner.
* This will automatically add it to the GEO - Miner.
- *
+ *
* @return Whether you can get obtain this resource using a GEO Miner.
*/
boolean isObtainableFromGEOMiner();
@@ -89,15 +87,15 @@ default void register() {
/**
* This method returns a localized name for this {@link GEOResource} in the
* {@link Language} the given {@link Player} selected.
- *
+ *
* @param p
* The {@link Player} to localize the name for.
* @return The localized name for this {@link GEOResource}
*/
@Nonnull
default String getName(@Nonnull Player p) {
- String name = Slimefun.getLocalization().getResourceString(p, "resources." + getKey().getNamespace() + "." + getKey().getKey());
+ String name = Slimefun.getLocalization()
+ .getResourceString(p, "resources." + getKey().getNamespace() + "." + getKey().getKey());
return name == null ? getName() : name;
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/ResourceManager.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/ResourceManager.java
index dab7151f39..8d8701a429 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/ResourceManager.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/ResourceManager.java
@@ -13,6 +13,13 @@
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
import io.github.thebusybiscuit.slimefun4.utils.HeadTexture;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Locale;
+import java.util.OptionalInt;
+import java.util.concurrent.ThreadLocalRandom;
+import javax.annotation.Nonnull;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
@@ -25,20 +32,12 @@
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
-import javax.annotation.Nonnull;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Locale;
-import java.util.OptionalInt;
-import java.util.concurrent.ThreadLocalRandom;
-
/**
* The {@link ResourceManager} is responsible for registering and managing a {@link GEOResource}.
* You have to use the {@link ResourceManager} if you want to generate or consume a {@link GEOResource} too.
- *
+ *
* @author TheBusyBiscuit
- *
+ *
* @see GEOResource
* @see GEOMiner
* @see GEOScanner
@@ -46,12 +45,14 @@
*/
public class ResourceManager {
- private final int[] backgroundSlots = { 0, 1, 2, 3, 5, 6, 7, 8, 9, 17, 18, 26, 27, 35, 36, 44, 45, 46, 48, 49, 50, 52, 53 };
+ private final int[] backgroundSlots = {
+ 0, 1, 2, 3, 5, 6, 7, 8, 9, 17, 18, 26, 27, 35, 36, 44, 45, 46, 48, 49, 50, 52, 53
+ };
private final Config config;
/**
* This will create a new {@link ResourceManager}.
- *
+ *
* @param plugin
* Our {@link Slimefun} instance
*/
@@ -62,7 +63,7 @@ public ResourceManager(@Nonnull Slimefun plugin) {
/**
* This method registers the given {@link GEOResource}.
* It may never be called directly, use {@link GEOResource#register()} instead.
- *
+ *
* @param resource
* The {@link GEOResource} to register
*/
@@ -72,7 +73,8 @@ void register(@Nonnull GEOResource resource) {
// Resources may only be registered once
if (Slimefun.getRegistry().getGEOResources().containsKey(resource.getKey())) {
- throw new IllegalArgumentException("GEO-Resource \"" + resource.getKey() + "\" has already been registered!");
+ throw new IllegalArgumentException(
+ "GEO-Resource \"" + resource.getKey() + "\" has already been registered!");
}
String key = resource.getKey().getNamespace() + '.' + resource.getKey().getKey();
@@ -91,7 +93,7 @@ void register(@Nonnull GEOResource resource) {
* This method returns the amount of a certain {@link GEOResource} found in a given {@link Chunk}.
* The result is an {@link OptionalInt} which will be empty if this {@link GEOResource}
* has not been generated at that {@link Location} yet.
- *
+ *
* @param resource
* The {@link GEOResource} to query
* @param world
@@ -100,7 +102,7 @@ void register(@Nonnull GEOResource resource) {
* The {@link Chunk} x coordinate
* @param z
* The {@link Chunk} z coordinate
- *
+ *
* @return An {@link OptionalInt}, either empty or containing the amount of the given {@link GEOResource}
*/
public @Nonnull OptionalInt getSupplies(@Nonnull GEOResource resource, @Nonnull World world, int x, int z) {
@@ -147,7 +149,7 @@ public void onResultNotFound() {
/**
* This method will set the supplies in a given {@link Chunk} to the specified value.
- *
+ *
* @param resource
* The {@link GEOResource}
* @param world
@@ -164,12 +166,14 @@ public void setSupplies(@Nonnull GEOResource resource, @Nonnull World world, int
Validate.notNull(world, "World cannot be null");
String key = resource.getKey().toString().replace(':', '-');
- Slimefun.getDatabaseManager().getBlockDataController().getChunkDataAsync(world.getChunkAt(x, z), new IAsyncReadCallback<>() {
- @Override
- public void onResult(SlimefunChunkData result) {
- result.setData(key, String.valueOf(value));
- }
- });
+ Slimefun.getDatabaseManager()
+ .getBlockDataController()
+ .getChunkDataAsync(world.getChunkAt(x, z), new IAsyncReadCallback<>() {
+ @Override
+ public void onResult(SlimefunChunkData result) {
+ result.setData(key, String.valueOf(value));
+ }
+ });
}
/**
@@ -178,7 +182,7 @@ public void onResult(SlimefunChunkData result) {
*
* This method will invoke {@link #setSupplies(GEOResource, World, int, int, int)} and also calls a
* {@link GEOResourceGenerationEvent}.
- *
+ *
* @param resource
* The {@link GEOResource} to generate
* @param world
@@ -187,7 +191,7 @@ public void onResult(SlimefunChunkData result) {
* The x coordinate of that {@link Chunk}
* @param z
* The z coordinate of that {@link Chunk}
- *
+ *
* @return The new supply value
*/
private int generate(@Nonnull GEOResource resource, @Nonnull World world, int x, int y, int z) {
@@ -212,7 +216,9 @@ private int generate(@Nonnull GEOResource resource, @Nonnull World world, int x,
int max = resource.getMaxDeviation();
if (max <= 0) {
- throw new IllegalStateException("GEO Resource \"" + resource.getKey() + "\" was misconfigured! getMaxDeviation() must return a value higher than zero!");
+ throw new IllegalStateException("GEO Resource \""
+ + resource.getKey()
+ + "\" was misconfigured! getMaxDeviation() must return a value higher than zero!");
}
value += ThreadLocalRandom.current().nextInt(max);
@@ -230,11 +236,11 @@ private int generate(@Nonnull GEOResource resource, @Nonnull World world, int x,
/**
* This method will start a geo-scan at the given {@link Block} and display the result
* of that scan to the given {@link Player}.
- *
+ *
* Note that scans are always per {@link Chunk}, not per {@link Block}, the {@link Block}
* parameter only determines the {@link Location} that was clicked but it will still scan
* the entire {@link Chunk}.
- *
+ *
* @param p
* The {@link Player} who requested these results
* @param block
@@ -244,7 +250,8 @@ private int generate(@Nonnull GEOResource resource, @Nonnull World world, int x,
*/
public void scan(@Nonnull Player p, @Nonnull Block block, int page) {
if (Slimefun.getGPSNetwork().getNetworkComplexity(p.getUniqueId()) < 600) {
- Slimefun.getLocalization().sendMessages(p, "gps.insufficient-complexity", true, msg -> msg.replace("%complexity%", "600"));
+ Slimefun.getLocalization()
+ .sendMessages(p, "gps.insufficient-complexity", true, msg -> msg.replace("%complexity%", "600"));
return;
}
@@ -258,8 +265,20 @@ public void scan(@Nonnull Player p, @Nonnull Block block, int page) {
menu.addItem(slot, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler());
}
- menu.addItem(4, new CustomItemStack(HeadTexture.MINECRAFT_CHUNK.getAsItemStack(), ChatColor.YELLOW + Slimefun.getLocalization().getResourceString(p, "tooltips.chunk"), "", "&8\u21E8 &7" + Slimefun.getLocalization().getResourceString(p, "tooltips.world") + ": " + block.getWorld().getName(), "&8\u21E8 &7X: " + x + " Z: " + z), ChestMenuUtils.getEmptyClickHandler());
- List resources = new ArrayList<>(Slimefun.getRegistry().getGEOResources().values());
+ menu.addItem(
+ 4,
+ new CustomItemStack(
+ HeadTexture.MINECRAFT_CHUNK.getAsItemStack(),
+ ChatColor.YELLOW + Slimefun.getLocalization().getResourceString(p, "tooltips.chunk"),
+ "",
+ "&8\u21E8 &7"
+ + Slimefun.getLocalization().getResourceString(p, "tooltips.world")
+ + ": "
+ + block.getWorld().getName(),
+ "&8\u21E8 &7X: " + x + " Z: " + z),
+ ChestMenuUtils.getEmptyClickHandler());
+ List resources =
+ new ArrayList<>(Slimefun.getRegistry().getGEOResources().values());
resources.sort(Comparator.comparing(a -> a.getName(p).toLowerCase(Locale.ROOT)));
int index = 10;
@@ -269,9 +288,11 @@ public void scan(@Nonnull Player p, @Nonnull Block block, int page) {
GEOResource resource = resources.get(i);
OptionalInt optional = getSupplies(resource, block.getWorld(), x, z);
int supplies = optional.orElseGet(() -> generate(resource, block.getWorld(), x, block.getY(), z));
- String suffix = Slimefun.getLocalization().getResourceString(p, ChatUtils.checkPlurality("tooltips.unit", supplies));
+ String suffix = Slimefun.getLocalization()
+ .getResourceString(p, ChatUtils.checkPlurality("tooltips.unit", supplies));
- ItemStack item = new CustomItemStack(resource.getItem(), "&f" + resource.getName(p), "&8\u21E8 &e" + supplies + ' ' + suffix);
+ ItemStack item = new CustomItemStack(
+ resource.getItem(), "&f" + resource.getName(p), "&8\u21E8 &e" + supplies + ' ' + suffix);
if (supplies > 1) {
item.setAmount(Math.min(supplies, item.getMaxStackSize()));
@@ -305,5 +326,4 @@ public void scan(@Nonnull Player p, @Nonnull Block block, int page) {
menu.open(p);
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/package-info.java
index 15243da62f..e63979f86b 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/package-info.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/package-info.java
@@ -2,4 +2,4 @@
* This package contains classes that are centered around the
* {@link io.github.thebusybiscuit.slimefun4.api.geo.GEOResource} API.
*/
-package io.github.thebusybiscuit.slimefun4.api.geo;
\ No newline at end of file
+package io.github.thebusybiscuit.slimefun4.api.geo;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/GPSNetwork.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/GPSNetwork.java
index d3af361856..eeeaf77748 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/GPSNetwork.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/GPSNetwork.java
@@ -17,6 +17,14 @@
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
import io.github.thebusybiscuit.slimefun4.utils.HeadTexture;
import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import javax.annotation.Nonnull;
+import javax.annotation.ParametersAreNonnullByDefault;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
@@ -28,30 +36,24 @@
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
-import javax.annotation.Nonnull;
-import javax.annotation.ParametersAreNonnullByDefault;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-
/**
* The {@link GPSNetwork} is a manager class for all {@link GPSTransmitter Transmitters} and waypoints.
* There can only be one instance of this class per {@link Server}.
* It is also responsible for teleportation and resource management.
- *
+ *
* @author TheBusyBiscuit
- *
+ *
* @see TeleportationManager
* @see ResourceManager
*
*/
public class GPSNetwork {
- private final int[] border = { 0, 1, 3, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 26, 27, 35, 36, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53 };
- private final int[] inventory = { 19, 20, 21, 22, 23, 24, 25, 28, 29, 30, 31, 32, 33, 34, 37, 38, 39, 40, 41, 42, 43 };
+ private final int[] border = {
+ 0, 1, 3, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 26, 27, 35, 36, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53
+ };
+ private final int[] inventory = {19, 20, 21, 22, 23, 24, 25, 28, 29, 30, 31, 32, 33, 34, 37, 38, 39, 40, 41, 42, 43
+ };
private final Map> transmitters = new HashMap<>();
private final TeleportationManager teleportation = new TeleportationManager();
@@ -61,7 +63,7 @@ public class GPSNetwork {
/**
* This constructs a new {@link GPSNetwork}.
* Note that this network is per {@link Server} and not per {@link Player}.
- *
+ *
* @param plugin
* Our {@link Slimefun} instance
*/
@@ -71,7 +73,7 @@ public GPSNetwork(@Nonnull Slimefun plugin) {
/**
* This method updates the status of a {@link GPSTransmitter}.
- *
+ *
* @param l
* The {@link Location} of the {@link GPSTransmitter}
* @param uuid
@@ -93,10 +95,10 @@ public void updateTransmitter(@Nonnull Location l, @Nonnull UUID uuid, boolean o
* This method calculates the GPS complexity for the given {@link UUID}.
* The complexity is determined by the Y level of each {@link GPSTransmitter}
* multiplied by the multiplier of that transmitter.
- *
+ *
* @param uuid
* The {@link UUID} who to calculate it for
- *
+ *
* @return The network complexity for that {@link UUID}
*/
public int getNetworkComplexity(@Nonnull UUID uuid) {
@@ -121,10 +123,10 @@ public int getNetworkComplexity(@Nonnull UUID uuid) {
/**
* This method returns the amount of {@link GPSTransmitter Transmitters} for the
* given {@link UUID}.
- *
+ *
* @param uuid
* The {@link UUID} who these transmitters belong to
- *
+ *
* @return The amount of transmitters
*/
public int countTransmitters(@Nonnull UUID uuid) {
@@ -135,29 +137,46 @@ public int countTransmitters(@Nonnull UUID uuid) {
/**
* This method opens the {@link GPSTransmitter} control panel to the given
* {@link Player}.
- *
+ *
* @param p
* The {@link Player}
*/
public void openTransmitterControlPanel(@Nonnull Player p) {
- ChestMenu menu = new ChestMenu(ChatColor.BLUE + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.title"));
+ ChestMenu menu = new ChestMenu(
+ ChatColor.BLUE + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.title"));
for (int slot : border) {
menu.addItem(slot, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler());
}
menu.addItem(2, new CustomItemStack(SlimefunItems.GPS_TRANSMITTER, im -> {
- im.setDisplayName(ChatColor.GRAY + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.transmitters"));
+ im.setDisplayName(ChatColor.GRAY
+ + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.transmitters"));
im.setLore(null);
}));
menu.addMenuClickHandler(2, ChestMenuUtils.getEmptyClickHandler());
int complexity = getNetworkComplexity(p.getUniqueId());
- menu.addItem(4, new CustomItemStack(SlimefunItems.GPS_CONTROL_PANEL, "&7网络信息", "", "&8\u21E8 &7状态: " + getStatusText(p, complexity), "&8\u21E8 &7复杂度: &f" + complexity));
+ menu.addItem(
+ 4,
+ new CustomItemStack(
+ SlimefunItems.GPS_CONTROL_PANEL,
+ "&7网络信息",
+ "",
+ "&8\u21E8 &7状态: " + getStatusText(p, complexity),
+ "&8\u21E8 &7复杂度: &f" + complexity));
menu.addMenuClickHandler(4, ChestMenuUtils.getEmptyClickHandler());
- menu.addItem(6, new CustomItemStack(HeadTexture.GLOBE_OVERWORLD.getAsItemStack(), "&7" + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.waypoints"), "", ChatColor.GRAY + "\u21E8 " + Slimefun.getLocalization().getMessage(p, "guide.tooltips.open-itemgroup")));
+ menu.addItem(
+ 6,
+ new CustomItemStack(
+ HeadTexture.GLOBE_OVERWORLD.getAsItemStack(),
+ "&7" + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.waypoints"),
+ "",
+ ChatColor.GRAY
+ + "\u21E8 "
+ + Slimefun.getLocalization().getMessage(p, "guide.tooltips.open-itemgroup")));
menu.addMenuClickHandler(6, (pl, slot, item, action) -> {
openWaypointControlPanel(pl);
return false;
@@ -174,7 +193,18 @@ public void openTransmitterControlPanel(@Nonnull Player p) {
if (sfi instanceof GPSTransmitter transmitter) {
int slot = inventory[index];
- menu.addItem(slot, new CustomItemStack(SlimefunItems.GPS_TRANSMITTER, "&bGPS 发射器", "&8\u21E8 &7世界: &f" + l.getWorld().getName(), "&8\u21E8 &7X: &f" + l.getX(), "&8\u21E8 &7Y: &f" + l.getY(), "&8\u21E8 &7Z: &f" + l.getZ(), "", "&8\u21E8 &7信号强度: &f" + transmitter.getMultiplier(l.getBlockY()), "&8\u21E8 &7延迟: &f" + NumberUtils.roundDecimalNumber(1000D / l.getY()) + "ms"));
+ menu.addItem(
+ slot,
+ new CustomItemStack(
+ SlimefunItems.GPS_TRANSMITTER,
+ "&bGPS 发射器",
+ "&8\u21E8 &7世界: &f" + l.getWorld().getName(),
+ "&8\u21E8 &7X: &f" + l.getX(),
+ "&8\u21E8 &7Y: &f" + l.getY(),
+ "&8\u21E8 &7Z: &f" + l.getZ(),
+ "",
+ "&8\u21E8 &7信号强度: &f" + transmitter.getMultiplier(l.getBlockY()),
+ "&8\u21E8 &7延迟: &f" + NumberUtils.roundDecimalNumber(1000D / l.getY()) + "ms"));
menu.addMenuClickHandler(slot, ChestMenuUtils.getEmptyClickHandler());
index++;
@@ -189,14 +219,14 @@ public void openTransmitterControlPanel(@Nonnull Player p) {
* The icon is dependent on the {@link Environment} of the waypoint's {@link World}.
* However if the name of this waypoint indicates that this is actually a deathmarker
* then a different texture will be used.
- *
+ *
* Otherwise it will return a globe, a nether or end sphere according to the {@link Environment}.
- *
+ *
* @param name
* The name of a waypoint
* @param environment
* The {@link Environment} of the waypoint's {@link World}
- *
+ *
* @return An icon for this waypoint
*/
@ParametersAreNonnullByDefault
@@ -223,23 +253,43 @@ public void openTransmitterControlPanel(@Nonnull Player p) {
public void openWaypointControlPanel(@Nonnull Player p) {
PlayerProfile.get(p, profile -> {
- ChestMenu menu = new ChestMenu(ChatColor.BLUE + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.title"));
+ ChestMenu menu = new ChestMenu(
+ ChatColor.BLUE + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.title"));
for (int slot : border) {
menu.addItem(slot, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler());
}
- menu.addItem(2, new CustomItemStack(SlimefunItems.GPS_TRANSMITTER, "&7" + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.transmitters"), "", ChatColor.GRAY + "\u21E8 " + Slimefun.getLocalization().getMessage(p, "guide.tooltips.open-itemgroup")));
+ menu.addItem(
+ 2,
+ new CustomItemStack(
+ SlimefunItems.GPS_TRANSMITTER,
+ "&7" + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.transmitters"),
+ "",
+ ChatColor.GRAY
+ + "\u21E8 "
+ + Slimefun.getLocalization().getMessage(p, "guide.tooltips.open-itemgroup")));
menu.addMenuClickHandler(2, (pl, slot, item, action) -> {
openTransmitterControlPanel(pl);
return false;
});
int complexity = getNetworkComplexity(p.getUniqueId());
- menu.addItem(4, new CustomItemStack(SlimefunItems.GPS_CONTROL_PANEL, "&7网络信息", "", "&8\u21E8 &7状态: " + (complexity > 0 ? "&2&l在线" : "&4&l离线"), "&8\u21E8 &7复杂度: &f" + complexity));
+ menu.addItem(
+ 4,
+ new CustomItemStack(
+ SlimefunItems.GPS_CONTROL_PANEL,
+ "&7网络信息",
+ "",
+ "&8\u21E8 &7状态: " + (complexity > 0 ? "&2&l在线" : "&4&l离线"),
+ "&8\u21E8 &7复杂度: &f" + complexity));
menu.addMenuClickHandler(4, ChestMenuUtils.getEmptyClickHandler());
- menu.addItem(6, new CustomItemStack(HeadTexture.GLOBE_OVERWORLD.getAsItemStack(), "&7" + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.waypoints")));
+ menu.addItem(
+ 6,
+ new CustomItemStack(
+ HeadTexture.GLOBE_OVERWORLD.getAsItemStack(),
+ "&7" + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.waypoints")));
menu.addMenuClickHandler(6, ChestMenuUtils.getEmptyClickHandler());
int index = 0;
@@ -251,7 +301,17 @@ public void openWaypointControlPanel(@Nonnull Player p) {
int slot = inventory[index];
Location l = waypoint.getLocation();
- menu.addItem(slot, new CustomItemStack(waypoint.getIcon(), waypoint.getName().replace("player:death ", ""), "&8\u21E8 &7世界: &f" + l.getWorld().getName(), "&8\u21E8 &7X: &f" + l.getX(), "&8\u21E8 &7Y: &f" + l.getY(), "&8\u21E8 &7Z: &f" + l.getZ(), "", "&8\u21E8 &cClick to delete"));
+ menu.addItem(
+ slot,
+ new CustomItemStack(
+ waypoint.getIcon(),
+ waypoint.getName().replace("player:death ", ""),
+ "&8\u21E8 &7世界: &f" + l.getWorld().getName(),
+ "&8\u21E8 &7X: &f" + l.getX(),
+ "&8\u21E8 &7Y: &f" + l.getY(),
+ "&8\u21E8 &7Z: &f" + l.getZ(),
+ "",
+ "&8\u21E8 &cClick to delete"));
menu.addMenuClickHandler(slot, (pl, s, item, action) -> {
profile.removeWaypoint(waypoint);
SoundEffect.GPS_NETWORK_OPEN_PANEL_SOUND.playFor(p);
@@ -270,7 +330,7 @@ public void openWaypointControlPanel(@Nonnull Player p) {
/**
* This method will prompt the given {@link Player} to enter a name for a waypoint.
* After entering the name, it will be added to his waypoint list.
- *
+ *
* @param p
* The {@link Player} who should get a new waypoint
* @param l
@@ -295,7 +355,7 @@ public void createWaypoint(@Nonnull Player p, @Nonnull Location l) {
/**
* This method adds a new waypoint with the given name and {@link Location} for that {@link Player}.
- *
+ *
* @param p
* The {@link Player} to get the new waypoint
* @param name
@@ -319,11 +379,18 @@ public void addWaypoint(@Nonnull Player p, @Nonnull String name, @Nonnull Locati
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
- String id = ChatColor.stripColor(ChatColors.color(event.getName())).toUpperCase(Locale.ROOT).replace(' ', '_');
+ String id = ChatColor.stripColor(ChatColors.color(event.getName()))
+ .toUpperCase(Locale.ROOT)
+ .replace(' ', '_');
for (Waypoint wp : profile.getWaypoints()) {
if (wp.getId().equals(id)) {
- Slimefun.getLocalization().sendMessage(p, "gps.waypoint.duplicate", true, msg -> msg.replace("%waypoint%", event.getName()));
+ Slimefun.getLocalization()
+ .sendMessage(
+ p,
+ "gps.waypoint.duplicate",
+ true,
+ msg -> msg.replace("%waypoint%", event.getName()));
return;
}
}
@@ -340,10 +407,10 @@ public void addWaypoint(@Nonnull Player p, @Nonnull String name, @Nonnull Locati
/**
* This method returns a {@link Set} of {@link Location Locations} for all {@link GPSTransmitter Transmitters}
* owned by the given {@link UUID}.
- *
+ *
* @param uuid
* The {@link UUID} owning those transmitters
- *
+ *
* @return A {@link Set} with all {@link Location Locations} of transmitters for this {@link UUID}
*/
@Nonnull
@@ -354,7 +421,7 @@ public Set getTransmitters(@Nonnull UUID uuid) {
/**
* This returns the {@link TeleportationManager} for this {@link GPSNetwork}.
* It is responsible for all actions that relate to the {@link Teleporter}.
- *
+ *
* @return The {@link TeleportationManager} for this {@link GPSNetwork}
*/
@Nonnull
@@ -365,12 +432,11 @@ public TeleportationManager getTeleportationManager() {
/**
* This returns the {@link ResourceManager} for this {@link GPSNetwork}.
* Use this to access {@link GEOResource GEOResources}.
- *
+ *
* @return The {@link ResourceManager} for this {@link GPSNetwork}
*/
@Nonnull
public ResourceManager getResourceManager() {
return resourceManager;
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/TeleportationManager.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/TeleportationManager.java
index 449cc46855..afb6dc8977 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/TeleportationManager.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/TeleportationManager.java
@@ -1,13 +1,22 @@
package io.github.thebusybiscuit.slimefun4.api.gps;
+import io.github.bakedlibs.dough.common.ChatColors;
+import io.github.bakedlibs.dough.items.CustomItemStack;
+import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
+import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect;
+import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
+import io.github.thebusybiscuit.slimefun4.implementation.items.teleporter.Teleporter;
+import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
+import io.github.thebusybiscuit.slimefun4.utils.HeadTexture;
+import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
+import io.papermc.lib.PaperLib;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
-
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
-
+import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@@ -18,33 +27,25 @@
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
-import io.github.bakedlibs.dough.common.ChatColors;
-import io.github.bakedlibs.dough.items.CustomItemStack;
-import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
-import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect;
-import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
-import io.github.thebusybiscuit.slimefun4.implementation.items.teleporter.Teleporter;
-import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
-import io.github.thebusybiscuit.slimefun4.utils.HeadTexture;
-import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
-import io.papermc.lib.PaperLib;
-
-import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
-
/**
* The {@link TeleportationManager} handles the process of teleportation for a {@link Player}
* who is using a {@link Teleporter}.
- *
+ *
* @author TheBusyBiscuit
- *
+ *
* @see GPSNetwork
* @see Teleporter
*
*/
public final class TeleportationManager {
- private final int[] teleporterBorder = { 0, 1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 26, 27, 35, 36, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53 };
- private final int[] teleporterInventory = { 19, 20, 21, 22, 23, 24, 25, 28, 29, 30, 31, 32, 33, 34, 37, 38, 39, 40, 41, 42, 43 };
+ private final int[] teleporterBorder = {
+ 0, 1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 26, 27, 35, 36, 44, 45, 46, 47, 48, 49, 50, 51,
+ 52, 53
+ };
+ private final int[] teleporterInventory = {
+ 19, 20, 21, 22, 23, 24, 25, 28, 29, 30, 31, 32, 33, 34, 37, 38, 39, 40, 41, 42, 43
+ };
/**
* This {@link Set} holds the {@link UUID} of all Players that are
@@ -79,7 +80,12 @@ public void openTeleporterGUI(Player p, UUID ownerUUID, Block b, int complexity)
menu.addItem(slot, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler());
}
- menu.addItem(4, new CustomItemStack(HeadTexture.GLOBE_OVERWORLD.getAsItemStack(), ChatColor.YELLOW + Slimefun.getLocalization().getMessage(p, "machines.TELEPORTER.gui.title")));
+ menu.addItem(
+ 4,
+ new CustomItemStack(
+ HeadTexture.GLOBE_OVERWORLD.getAsItemStack(),
+ ChatColor.YELLOW
+ + Slimefun.getLocalization().getMessage(p, "machines.TELEPORTER.gui.title")));
menu.addMenuClickHandler(4, ChestMenuUtils.getEmptyClickHandler());
Location source = new Location(b.getWorld(), b.getX() + 0.5D, b.getY() + 2D, b.getZ() + 0.5D);
@@ -97,17 +103,27 @@ public void openTeleporterGUI(Player p, UUID ownerUUID, Block b, int complexity)
// @formatter:off
String[] lore = {
"",
- "&8\u21E8 &7" + Slimefun.getLocalization().getResourceString(p, "tooltips.world") + ": &f" + l.getWorld().getName(),
+ "&8\u21E8 &7"
+ + Slimefun.getLocalization().getResourceString(p, "tooltips.world")
+ + ": &f"
+ + l.getWorld().getName(),
"&8\u21E8 &7X: &f" + l.getX(),
"&8\u21E8 &7Y: &f" + l.getY(),
"&8\u21E8 &7Z: &f" + l.getZ(),
- "&8\u21E8 &7" + Slimefun.getLocalization().getMessage(p, "machines.TELEPORTER.gui.time") + ": &f" + time + "s",
+ "&8\u21E8 &7"
+ + Slimefun.getLocalization().getMessage(p, "machines.TELEPORTER.gui.time")
+ + ": &f"
+ + time
+ + "s",
"",
"&8\u21E8 &c" + Slimefun.getLocalization().getMessage(p, "machines.TELEPORTER.gui.tooltip")
};
// @formatter:on
- menu.addItem(slot, new CustomItemStack(waypoint.getIcon(), waypoint.getName().replace("player:death ", ""), lore));
+ menu.addItem(
+ slot,
+ new CustomItemStack(
+ waypoint.getIcon(), waypoint.getName().replace("player:death ", ""), lore));
menu.addMenuClickHandler(slot, (pl, s, item, action) -> {
pl.closeInventory();
teleport(pl.getUniqueId(), complexity, source, l, false);
@@ -136,21 +152,21 @@ public void teleport(UUID uuid, int complexity, Location source, Location destin
* to the destination {@link Location}, given the specified complexity.
*
* The returned time will be measured in 500ms intervals.
- *
+ *
*
* - A returned time of {@literal 100} will mean 50,000ms (50s) of real-life time.
* - A returned time of {@literal 10} will mean 5,000ms (5s) of real-life time.
* - A returned time of {@literal 2} will mean 1,000ms (1s) of real-life time.
* - and so on...
*
- *
+ *
* @param complexity
* The complexity of the {@link GPSNetwork}
* @param source
* The source {@link Location}
* @param destination
* The destination {@link Location}
- *
+ *
* @return The amount of time the teleportation will take
*/
public int getTeleportationTime(int complexity, @Nonnull Location source, @Nonnull Location destination) {
@@ -179,31 +195,52 @@ private int distanceSquared(Location source, Location destination) {
}
private boolean isValid(@Nullable Player p, @Nonnull Location source) {
- return p != null && p.isValid() && p.getWorld().getUID().equals(source.getWorld().getUID()) && p.getLocation().distanceSquared(source) < 2.0;
+ return p != null
+ && p.isValid()
+ && p.getWorld().getUID().equals(source.getWorld().getUID())
+ && p.getLocation().distanceSquared(source) < 2.0;
}
private void cancel(@Nonnull UUID uuid, @Nullable Player p) {
teleporterUsers.remove(uuid);
if (p != null) {
- p.sendTitle(ChatColors.color(Slimefun.getLocalization().getMessage(p, "machines.TELEPORTER.cancelled")), ChatColors.color("&c&k40&f&c%"), 20, 60, 20);
+ p.sendTitle(
+ ChatColors.color(Slimefun.getLocalization().getMessage(p, "machines.TELEPORTER.cancelled")),
+ ChatColors.color("&c&k40&f&c%"),
+ 20,
+ 60,
+ 20);
}
}
@ParametersAreNonnullByDefault
- private void updateProgress(UUID uuid, int speed, int progress, Location source, Location destination, boolean resistance) {
+ private void updateProgress(
+ UUID uuid, int speed, int progress, Location source, Location destination, boolean resistance) {
Player p = Bukkit.getPlayer(uuid);
if (isValid(p, source)) {
if (progress > 99) {
- p.sendTitle(ChatColors.color(Slimefun.getLocalization().getMessage(p, "machines.TELEPORTER.teleported")), ChatColors.color("&b100%"), 20, 60, 20);
- PaperLib.teleportAsync(p, destination).thenAccept(success -> onTeleport(p, destination, success, resistance));
+ p.sendTitle(
+ ChatColors.color(Slimefun.getLocalization().getMessage(p, "machines.TELEPORTER.teleported")),
+ ChatColors.color("&b100%"),
+ 20,
+ 60,
+ 20);
+ PaperLib.teleportAsync(p, destination)
+ .thenAccept(success -> onTeleport(p, destination, success, resistance));
} else {
- p.sendTitle(ChatColors.color(Slimefun.getLocalization().getMessage(p, "machines.TELEPORTER.teleporting")), ChatColors.color("&b" + progress + "%"), 0, 60, 0);
+ p.sendTitle(
+ ChatColors.color(Slimefun.getLocalization().getMessage(p, "machines.TELEPORTER.teleporting")),
+ ChatColors.color("&b" + progress + "%"),
+ 0,
+ 60,
+ 0);
source.getWorld().spawnParticle(Particle.PORTAL, source, progress * 2, 0.2F, 0.8F, 0.2F);
SoundEffect.TELEPORT_UPDATE_SOUND.playFor(p);
- Slimefun.runSync(() -> updateProgress(uuid, speed, progress + speed, source, destination, resistance), 10L);
+ Slimefun.runSync(
+ () -> updateProgress(uuid, speed, progress + speed, source, destination, resistance), 10L);
}
} else {
cancel(uuid, p);
@@ -225,7 +262,8 @@ private void onTeleport(Player p, Location destination, boolean success, boolean
}
// Spawn some particles for aesthetic reasons.
- Location loc = new Location(destination.getWorld(), destination.getX(), destination.getY() + 1, destination.getZ());
+ Location loc = new Location(
+ destination.getWorld(), destination.getX(), destination.getY() + 1, destination.getZ());
destination.getWorld().spawnParticle(Particle.PORTAL, loc, 200, 0.2F, 0.8F, 0.2F);
SoundEffect.TELEPORT_SOUND.playFor(p);
teleporterUsers.remove(p.getUniqueId());
@@ -238,5 +276,4 @@ private void onTeleport(Player p, Location destination, boolean success, boolean
}
});
}
-
}
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 13c8b42561..e7d3d24803 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
@@ -1,27 +1,24 @@
package io.github.thebusybiscuit.slimefun4.api.gps;
+import io.github.thebusybiscuit.slimefun4.api.events.WaypointCreateEvent;
+import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
+import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
+import io.github.thebusybiscuit.slimefun4.implementation.items.teleporter.Teleporter;
import java.util.Objects;
-
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
-
import org.apache.commons.lang.Validate;
import org.bukkit.Location;
import org.bukkit.World.Environment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
-import io.github.thebusybiscuit.slimefun4.api.events.WaypointCreateEvent;
-import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
-import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
-import io.github.thebusybiscuit.slimefun4.implementation.items.teleporter.Teleporter;
-
/**
* A {@link Waypoint} represents a named {@link Location} that was created by a {@link Player}.
* It can be used via a {@link Teleporter}.
- *
+ *
* @author TheBusyBiscuit
- *
+ *
* @see WaypointCreateEvent
* @see GPSNetwork
* @see TeleportationManager
@@ -37,7 +34,7 @@ public class Waypoint {
/**
* This constructs a new {@link Waypoint} object.
- *
+ *
* @param profile
* The owning {@link PlayerProfile}
* @param id
@@ -62,7 +59,7 @@ public Waypoint(PlayerProfile profile, String id, Location loc, String name) {
/**
* This returns the owner of the {@link Waypoint}.
- *
+ *
* @return The corresponding {@link PlayerProfile}
*/
@Nonnull
@@ -72,7 +69,7 @@ public PlayerProfile getOwner() {
/**
* This method returns the unique identifier for this {@link Waypoint}.
- *
+ *
* @return The {@link Waypoint} id
*/
@Nonnull
@@ -82,7 +79,7 @@ public String getId() {
/**
* This returns the name of this {@link Waypoint}.
- *
+ *
* @return The name of this {@link Waypoint}
*/
@Nonnull
@@ -92,7 +89,7 @@ public String getName() {
/**
* This returns the {@link Location} of this {@link Waypoint}
- *
+ *
* @return The {@link Waypoint} {@link Location}
*/
@Nonnull
@@ -102,7 +99,7 @@ public Location getLocation() {
/**
* This method returns whether this {@link Waypoint} is a Deathpoint.
- *
+ *
* @return Whether this is a Deathpoint
*/
public boolean isDeathpoint() {
@@ -113,7 +110,7 @@ public boolean isDeathpoint() {
* This method returns the {@link ItemStack} icon for this {@link Waypoint}.
* The icon is dependent on the {@link Environment} the {@link Waypoint} is in
* and whether it is a Deathpoint.
- *
+ *
* @return The {@link ItemStack} icon for this {@link Waypoint}
*/
@Nonnull
@@ -139,7 +136,9 @@ public boolean equals(Object obj) {
}
Waypoint waypoint = (Waypoint) obj;
- return profile.getUUID().equals(waypoint.getOwner().getUUID()) && id.equals(waypoint.getId()) && location.equals(waypoint.getLocation()) && name.equals(waypoint.getName());
+ return profile.getUUID().equals(waypoint.getOwner().getUUID())
+ && id.equals(waypoint.getId())
+ && location.equals(waypoint.getLocation())
+ && name.equals(waypoint.getName());
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/package-info.java
index 078403c9c2..f5bcb39ac8 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/package-info.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/package-info.java
@@ -2,4 +2,4 @@
* This package stores classes of the API that are related to the
* {@link io.github.thebusybiscuit.slimefun4.api.gps.GPSNetwork}.
*/
-package io.github.thebusybiscuit.slimefun4.api.gps;
\ No newline at end of file
+package io.github.thebusybiscuit.slimefun4.api.gps;
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 92a66e5a2f..cfe03cdc2f 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
@@ -1,27 +1,24 @@
package io.github.thebusybiscuit.slimefun4.api.items;
+import io.github.thebusybiscuit.slimefun4.implementation.items.armor.SlimefunArmorPiece;
+import io.github.thebusybiscuit.slimefun4.implementation.tasks.armor.SlimefunArmorTask;
import java.util.Optional;
-
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.Damageable;
import org.bukkit.inventory.meta.ItemMeta;
-import io.github.thebusybiscuit.slimefun4.implementation.items.armor.SlimefunArmorPiece;
-import io.github.thebusybiscuit.slimefun4.implementation.tasks.armor.SlimefunArmorTask;
-
/**
* This class serves as a way of checking whether a {@link Player} has changed their armor
* between ticks. We do that by storing the hash of their armor and a reference to the
* corresponding {@link SlimefunArmorPiece} if such a correlation exists.
- *
+ *
* This gives us a significant performance improvement as we only need to check for a
* {@link SlimefunArmorPiece} if the item diverged in the first place.
- *
+ *
* @author TheBusyBiscuit
*
* @see SlimefunArmorPiece
@@ -44,7 +41,7 @@ public HashedArmorpiece() {
/**
* This will update this {@link HashedArmorpiece} with the given {@link ItemStack}
* and the corresponding {@link SlimefunItem}
- *
+ *
* @param stack
* The new armorpiece to be stored in this {@link HashedArmorpiece}
* @param item
@@ -71,7 +68,7 @@ public void update(@Nullable ItemStack stack, @Nullable SlimefunItem item) {
/**
* This method checks whether the given {@link ItemStack} is no longer similar to the
* one represented by this {@link HashedArmorpiece}.
- *
+ *
* @param stack
* The {@link ItemStack} to compare
* @return Whether the {@link HashedArmorpiece} and the given {@link ItemStack} mismatch
@@ -91,7 +88,7 @@ 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 @Nonnull Optional getItem() {
@@ -100,7 +97,10 @@ public boolean hasDiverged(@Nullable ItemStack stack) {
@Override
public String toString() {
- return "HashedArmorpiece {hash=" + hash + ",item=" + item.map(SlimefunItem::getId).orElse("null") + '}';
+ return "HashedArmorpiece {hash="
+ + hash
+ + ",item="
+ + item.map(SlimefunItem::getId).orElse("null")
+ + '}';
}
-
}
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 0f70a46e6e..e543a24ce1 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
@@ -1,15 +1,19 @@
package io.github.thebusybiscuit.slimefun4.api.items;
+import io.github.bakedlibs.dough.items.CustomItemStack;
+import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
+import io.github.thebusybiscuit.slimefun4.api.items.groups.LockedItemGroup;
+import io.github.thebusybiscuit.slimefun4.api.items.groups.SeasonalItemGroup;
+import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
+import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
-
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
-
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Keyed;
@@ -19,22 +23,15 @@
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
-import io.github.bakedlibs.dough.items.CustomItemStack;
-import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
-import io.github.thebusybiscuit.slimefun4.api.items.groups.LockedItemGroup;
-import io.github.thebusybiscuit.slimefun4.api.items.groups.SeasonalItemGroup;
-import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
-import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
-
/**
* Represents an item group, which structure
* multiple {@link SlimefunItem} in the {@link SlimefunGuide}.
- *
+ *
* @author TheBusyBiscuit
*
* @see LockedItemGroup
* @see SeasonalItemGroup
- *
+ *
*/
public class ItemGroup implements Keyed {
@@ -50,7 +47,7 @@ public class ItemGroup implements Keyed {
* Constructs a new {@link ItemGroup} with the given {@link NamespacedKey} as an identifier
* and the given {@link ItemStack} as its display item.
* The tier is set to a default value of {@code 3}.
- *
+ *
* @param key
* The {@link NamespacedKey} that is used to identify this {@link ItemGroup}
* @param item
@@ -64,7 +61,7 @@ public ItemGroup(NamespacedKey key, ItemStack item) {
/**
* Constructs a new {@link ItemGroup} with the given {@link NamespacedKey} as an identifier
* and the given {@link ItemStack} as its display item.
- *
+ *
* @param key
* The {@link NamespacedKey} that is used to identify this {@link ItemGroup}
* @param item
@@ -100,7 +97,7 @@ public ItemGroup(NamespacedKey key, ItemStack item, int tier) {
*
* By default, an {@link ItemGroup} is automatically registered when
* a {@link SlimefunItem} was added to it.
- *
+ *
* @param addon
* The {@link SlimefunAddon} that wants to register this {@link ItemGroup}
*/
@@ -120,7 +117,7 @@ public void register(@Nonnull SlimefunAddon addon) {
/**
* This method returns whether this {@link ItemGroup} has been registered yet.
* More specifically: Whether {@link #register(SlimefunAddon)} was called or not.
- *
+ *
* @return Whether this {@link ItemGroup} has been registered
*/
public boolean isRegistered() {
@@ -130,7 +127,7 @@ public boolean isRegistered() {
/**
* Returns the tier of this {@link ItemGroup}.
* The tier determines the position of this {@link ItemGroup} in the {@link SlimefunGuide}.
- *
+ *
* @return the tier of this {@link ItemGroup}
*/
public int getTier() {
@@ -140,7 +137,7 @@ public int getTier() {
/**
* This sets the tier of this {@link ItemGroup}.
* The tier determines the position of this {@link ItemGroup} in the {@link SlimefunGuide}.
- *
+ *
* @param tier
* The tier for this {@link ItemGroup}
*/
@@ -164,7 +161,7 @@ private void sortCategoriesByTier() {
/**
* This returns the {@link SlimefunAddon} which has registered this {@link ItemGroup}.
* Or null if it has not been registered yet.
- *
+ *
* @return The {@link SlimefunAddon} or null if unregistered
*/
public final @Nullable SlimefunAddon getAddon() {
@@ -173,7 +170,7 @@ private void sortCategoriesByTier() {
/**
* Adds the given {@link SlimefunItem} to this {@link ItemGroup}.
- *
+ *
* @param item
* the {@link SlimefunItem} that should be added to this {@link ItemGroup}
*/
@@ -185,8 +182,13 @@ public void add(@Nonnull SlimefunItem item) {
return;
}
- if (isRegistered() && !isCrossAddonItemGroup() && !item.getAddon().getName().equals(this.addon.getName())) {
- item.warn("This item does not belong into ItemGroup " + this + " as that group belongs to " + this.addon.getName());
+ if (isRegistered()
+ && !isCrossAddonItemGroup()
+ && !item.getAddon().getName().equals(this.addon.getName())) {
+ item.warn("This item does not belong into ItemGroup "
+ + this
+ + " as that group belongs to "
+ + this.addon.getName());
}
items.add(item);
@@ -194,7 +196,7 @@ public void add(@Nonnull SlimefunItem item) {
/**
* Removes the given {@link SlimefunItem} from this {@link ItemGroup}.
- *
+ *
* @param item
* the {@link SlimefunItem} that should be removed from this {@link ItemGroup}
*/
@@ -206,10 +208,10 @@ public void remove(@Nonnull SlimefunItem item) {
/**
* This method returns a localized display item of this {@link ItemGroup}
* for the specified {@link Player}.
- *
+ *
* @param p
* The Player to create this {@link ItemStack} for
- *
+ *
* @return A localized display item for this {@link ItemGroup}
*/
public @Nonnull ItemStack getItem(@Nonnull Player p) {
@@ -226,14 +228,19 @@ public void remove(@Nonnull SlimefunItem item) {
meta.setDisplayName(ChatColor.YELLOW + name);
}
- meta.setLore(Arrays.asList("", ChatColor.GRAY + "\u21E8 " + ChatColor.GREEN + Slimefun.getLocalization().getMessage(p, "guide.tooltips.open-itemgroup")));
+ meta.setLore(Arrays.asList(
+ "",
+ ChatColor.GRAY
+ + "\u21E8 "
+ + ChatColor.GREEN
+ + Slimefun.getLocalization().getMessage(p, "guide.tooltips.open-itemgroup")));
});
}
/**
* This method makes Walshy happy.
* It adds a way to get the name of a {@link ItemGroup} without localization nor coloring.
- *
+ *
* @return The unlocalized name of this {@link ItemGroup}
*/
public @Nonnull String getUnlocalizedName() {
@@ -243,10 +250,10 @@ public void remove(@Nonnull SlimefunItem item) {
/**
* This returns the localized display name of this {@link ItemGroup} for the given {@link Player}.
* The method will fall back to {@link #getUnlocalizedName()} if no translation was found.
- *
+ *
* @param p
* The {@link Player} who to translate the name for
- *
+ *
* @return The localized name of this {@link ItemGroup}
*/
public @Nonnull String getDisplayName(@Nonnull Player p) {
@@ -261,7 +268,7 @@ public void remove(@Nonnull SlimefunItem item) {
/**
* Returns all instances of {@link SlimefunItem} bound to this {@link ItemGroup}.
- *
+ *
* @return the list of SlimefunItems bound to this {@link ItemGroup}
*/
public @Nonnull List getItems() {
@@ -270,10 +277,10 @@ public void remove(@Nonnull SlimefunItem item) {
/**
* This method returns whether a given {@link SlimefunItem} exists in this {@link ItemGroup}.
- *
+ *
* @param item
* The {@link SlimefunItem} to find
- *
+ *
* @return Whether the given {@link SlimefunItem} was found in this {@link ItemGroup}
*/
public boolean contains(@Nullable SlimefunItem item) {
@@ -285,10 +292,10 @@ public boolean contains(@Nullable SlimefunItem item) {
* by the given {@link Player}. If an {@link ItemGroup} is not accessible,
* it will not show up in the {@link SlimefunGuide} nor will items from this
* {@link ItemGroup} show up in the guide search.
- *
+ *
* @param p
* The {@link Player} to check for
- *
+ *
* @return Whether this {@link ItemGroup} is accessible by the given {@link Player}
*/
public boolean isAccessible(@Nonnull Player p) {
@@ -301,10 +308,10 @@ public boolean isAccessible(@Nonnull Player p) {
* be visible. This includes {@link ItemGroup ItemGroups} where every {@link SlimefunItem}
* is disabled. If an {@link ItemGroup} is not accessible by the {@link Player},
* see {@link #isAccessible(Player)}, this method will also return false.
- *
+ *
* @param p
* The {@link Player} to check for
- *
+ *
* @return Whether this {@link ItemGroup} is visible to the given {@link Player}
*/
public boolean isVisible(@Nonnull Player p) {
@@ -371,17 +378,16 @@ public String toString() {
/**
* This method checks whether this {@link ItemGroup} will be hidden for the specified
* {@link Player}.
- *
+ *
* Categories are hidden if all of their items have been disabled.
- *
+ *
* @param p
* The {@link Player} to check for
- *
+ *
* @return Whether this {@link ItemGroup} will be hidden to the given {@link Player}
*/
@Deprecated
public boolean isHidden(@Nonnull Player p) {
return !isVisible(p);
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemHandler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemHandler.java
index 251daefe14..d306fe7271 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemHandler.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemHandler.java
@@ -1,9 +1,5 @@
package io.github.thebusybiscuit.slimefun4.api.items;
-import java.util.Optional;
-
-import javax.annotation.Nonnull;
-
import io.github.thebusybiscuit.slimefun4.api.exceptions.IncompatibleItemHandlerException;
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler;
import io.github.thebusybiscuit.slimefun4.core.handlers.BowShootHandler;
@@ -11,11 +7,13 @@
import io.github.thebusybiscuit.slimefun4.core.handlers.EntityKillHandler;
import io.github.thebusybiscuit.slimefun4.core.handlers.ItemConsumptionHandler;
import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
+import java.util.Optional;
+import javax.annotation.Nonnull;
/**
* An {@link ItemHandler} represents a certain action that a {@link SlimefunItem}
* can perform.
- *
+ *
* @author TheBusyBiscuit
*
* @see ItemUseHandler
@@ -32,10 +30,10 @@ public interface ItemHandler {
* This method is used to check whether a given {@link SlimefunItem} is compatible
* with this {@link ItemHandler}, it will return an {@link IncompatibleItemHandlerException}
* if the items are not compatible.
- *
+ *
* @param item
* The {@link SlimefunItem} to validate
- *
+ *
* @return An {@link Optional} describing the result, it will contain an {@link IncompatibleItemHandlerException}
* should there be an issue
*/
@@ -47,7 +45,7 @@ default Optional validate(@Nonnull SlimefunIte
/**
* This method returns the identifier for this {@link ItemHandler}.
* We use a {@link Class} identifier to group Item Handlers together.
- *
+ *
* @return The {@link Class} identifier for this {@link ItemHandler}
*/
@Nonnull
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 bddcf03893..9d3199da24 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
@@ -1,20 +1,17 @@
package io.github.thebusybiscuit.slimefun4.api.items;
+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.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
-
import org.apache.commons.lang.Validate;
-import io.github.bakedlibs.dough.config.Config;
-import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
-
/**
* This class represents a Setting for a {@link SlimefunItem} that can be modified via
* the {@code Items.yml} {@link Config} file.
- *
+ *
* @author TheBusyBiscuit
*
* @param
@@ -31,7 +28,7 @@ public class ItemSetting {
/**
* This creates a new {@link ItemSetting} with the given key and default value
- *
+ *
* @param item
* The {@link SlimefunItem} this {@link ItemSetting} belongs to
* @param key
@@ -53,10 +50,10 @@ public ItemSetting(SlimefunItem item, String key, T defaultValue) {
/**
* This method checks if a given input would be valid as a value for this
* {@link ItemSetting}. You can override this method to implement your own checks.
- *
+ *
* @param input
* The input value to validate
- *
+ *
* @return Whether the given input was valid
*/
public boolean validateInput(T input) {
@@ -67,7 +64,7 @@ public boolean validateInput(T input) {
* This method updates this {@link ItemSetting} with the given value.
* Override this method to catch changes of a value.
* A value may never be null.
- *
+ *
* @param newValue
* The new value for this {@link ItemSetting}
*/
@@ -83,7 +80,7 @@ public void update(@Nonnull T newValue) {
/**
* This returns the key of this {@link ItemSetting}.
- *
+ *
* @return The key under which this setting is stored (relative to the {@link SlimefunItem})
*/
public @Nonnull String getKey() {
@@ -92,7 +89,7 @@ public void update(@Nonnull T newValue) {
/**
* This returns the associated {@link SlimefunItem} for this {@link ItemSetting}.
- *
+ *
* @return The associated {@link SlimefunItem}
*/
protected @Nonnull SlimefunItem getItem() {
@@ -101,7 +98,7 @@ public void update(@Nonnull T newValue) {
/**
* This returns the current value of this {@link ItemSetting}.
- *
+ *
* @return The current value
*/
public @Nonnull T getValue() {
@@ -128,7 +125,7 @@ public void update(@Nonnull T newValue) {
/**
* This returns the default value of this {@link ItemSetting}.
- *
+ *
* @return The default value
*/
public @Nonnull T getDefaultValue() {
@@ -137,10 +134,10 @@ public void update(@Nonnull T newValue) {
/**
* This method checks if this {@link ItemSetting} stores the given data type.
- *
+ *
* @param c
* The class of data type you want to compare
- *
+ *
* @return Whether this {@link ItemSetting} stores the given type
*/
public boolean isType(@Nonnull Class> c) {
@@ -150,7 +147,7 @@ public boolean isType(@Nonnull Class> c) {
/**
* This is an error message which should provide further context on what values
* are allowed.
- *
+ *
* @return An error message which is displayed when this {@link ItemSetting} is misconfigured.
*/
protected @Nonnull String getErrorMessage() {
@@ -160,7 +157,7 @@ public boolean isType(@Nonnull Class> c) {
/**
* This method is called by a {@link SlimefunItem} which wants to load its {@link ItemSetting}
* from the {@link Config} file.
- *
+ *
*/
@SuppressWarnings("unchecked")
public void reload() {
@@ -169,7 +166,8 @@ public void reload() {
Slimefun.getItemCfg().setDefaultValue(item.getId() + '.' + getKey(), getDefaultValue());
Object configuredValue = Slimefun.getItemCfg().getValue(item.getId() + '.' + getKey());
- if (defaultValue.getClass().isInstance(configuredValue) || (configuredValue instanceof List && defaultValue instanceof List)) {
+ if (defaultValue.getClass().isInstance(configuredValue)
+ || (configuredValue instanceof List && defaultValue instanceof List)) {
// We can do an unsafe cast here, we did an isInstance(...) check before!
T newValue = (T) configuredValue;
@@ -177,25 +175,38 @@ public void reload() {
this.value = newValue;
} else {
// @formatter:off
- item.warn(
- "发现在 Items.yml 中有无效的物品设置!" +
- "\n 在 \"" + item.getId() + "." + getKey() + "\"" +
- "\n " + configuredValue + " 不是一个有效值!" +
- "\n" + getErrorMessage()
- );
+ item.warn("发现在 Items.yml 中有无效的物品设置!"
+ + "\n 在 \""
+ + item.getId()
+ + "."
+ + getKey()
+ + "\""
+ + "\n "
+ + configuredValue
+ + " 不是一个有效值!"
+ + "\n"
+ + getErrorMessage());
// @formatter:on
}
} else {
this.value = defaultValue;
- String found = configuredValue == null ? "null" : configuredValue.getClass().getSimpleName();
+ String found = configuredValue == null
+ ? "null"
+ : configuredValue.getClass().getSimpleName();
// @formatter:off
- item.warn(
- "发现在 Items.yml 中有无效的物品设置!" +
- "\n请只设置有效的值." +
- "\n 在 \"" + item.getId() + "." + getKey() + "\"" +
- "\n 期望值为 \"" + defaultValue.getClass().getSimpleName() + "\" 但填写了: \"" + found + "\""
- );
+ item.warn("发现在 Items.yml 中有无效的物品设置!"
+ + "\n请只设置有效的值."
+ + "\n 在 \""
+ + item.getId()
+ + "."
+ + getKey()
+ + "\""
+ + "\n 期望值为 \""
+ + defaultValue.getClass().getSimpleName()
+ + "\" 但填写了: \""
+ + found
+ + "\"");
// @formatter:on
}
}
@@ -203,7 +214,14 @@ public void reload() {
@Override
public String toString() {
T currentValue = this.value != null ? this.value : defaultValue;
- return getClass().getSimpleName() + " {" + getKey() + " = " + currentValue + " (default: " + getDefaultValue() + ")";
+ return getClass().getSimpleName()
+ + " {"
+ + getKey()
+ + " = "
+ + currentValue
+ + " (default: "
+ + getDefaultValue()
+ + ")";
}
@Override
@@ -220,5 +238,4 @@ public final boolean equals(Object obj) {
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 e21bc31a14..5f3c0da814 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
@@ -1,8 +1,5 @@
package io.github.thebusybiscuit.slimefun4.api.items;
-import org.bukkit.block.Block;
-import org.bukkit.inventory.ItemStack;
-
import io.github.thebusybiscuit.slimefun4.api.events.SlimefunItemSpawnEvent;
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
import io.github.thebusybiscuit.slimefun4.core.networks.cargo.CargoNet;
@@ -11,6 +8,8 @@
import io.github.thebusybiscuit.slimefun4.implementation.items.seasonal.EasterEgg;
import io.github.thebusybiscuit.slimefun4.implementation.items.tools.GoldPan;
import io.github.thebusybiscuit.slimefun4.implementation.items.tools.PickaxeOfContainment;
+import org.bukkit.block.Block;
+import org.bukkit.inventory.ItemStack;
/**
* This enum holds the different reasons as to why we may need to spawn an item.
@@ -65,5 +64,4 @@ public enum ItemSpawnReason {
* Other reasons we did not account for.
*/
MISC;
-
-}
\ No newline at end of file
+}
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 0d5f132205..32f5f942a0 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
@@ -30,5 +30,4 @@ public enum ItemState {
* {@link VanillaItem}.
*/
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 a4a74e686c..95e908a81e 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
@@ -1,8 +1,6 @@
package io.github.thebusybiscuit.slimefun4.api.items;
import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData;
-import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils;
-import io.github.bakedlibs.dough.blocks.ChunkPosition;
import io.github.bakedlibs.dough.collections.OptionalMap;
import io.github.bakedlibs.dough.items.ItemUtils;
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
@@ -20,36 +18,27 @@
import io.github.thebusybiscuit.slimefun4.core.attributes.NotConfigurable;
import io.github.thebusybiscuit.slimefun4.core.attributes.Placeable;
import io.github.thebusybiscuit.slimefun4.core.attributes.Radioactive;
-import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable;
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
import io.github.thebusybiscuit.slimefun4.core.handlers.GlobalItemHandler;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem;
-import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.SlimefunBackpack;
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.enchanting.AutoDisenchanter;
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.enchanting.AutoEnchanter;
-import io.github.thebusybiscuit.slimefun4.implementation.tasks.TickerTask;
-import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
-import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper;
-
import java.text.MessageFormat;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
import java.util.HashSet;
-import java.util.Map;
import java.util.Optional;
import java.util.Set;
-import java.util.Collection;
-import java.util.Arrays;
-import java.util.HashMap;
import java.util.function.Consumer;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
-
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker;
import org.apache.commons.lang.Validate;
-import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.Player;
@@ -63,14 +52,16 @@
* This class defines the behaviours of the item, you can assign an {@link ItemHandler}
* to give the item functionality.
* In contrast to that the {@link SlimefunItemStack} defines the look and feel of the item.
- *
+ *
* Remember to call {@link #register(SlimefunAddon)} on your {@link SlimefunItem} for it
* to appear in the {@link SlimefunGuide}.
*
* @author TheBusyBiscuit
* @author Poslovitch
+ *
* @see SlimefunItemStack
* @see SlimefunAddon
+ *
*/
public class SlimefunItem implements Placeable {
@@ -126,10 +117,14 @@ public class SlimefunItem implements Placeable {
/**
* This creates a new {@link SlimefunItem} from the given arguments.
*
- * @param itemGroup The {@link ItemGroup} this {@link SlimefunItem} belongs to
- * @param item The {@link SlimefunItemStack} that describes the visual features of our {@link SlimefunItem}
- * @param recipeType the {@link RecipeType} that determines how this {@link SlimefunItem} is crafted
- * @param recipe An Array representing the recipe of this {@link SlimefunItem}
+ * @param itemGroup
+ * The {@link ItemGroup} this {@link SlimefunItem} belongs to
+ * @param item
+ * The {@link SlimefunItemStack} that describes the visual features of our {@link SlimefunItem}
+ * @param recipeType
+ * the {@link RecipeType} that determines how this {@link SlimefunItem} is crafted
+ * @param recipe
+ * An Array representing the recipe of this {@link SlimefunItem}
*/
@ParametersAreNonnullByDefault
public SlimefunItem(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
@@ -139,14 +134,24 @@ public SlimefunItem(ItemGroup itemGroup, SlimefunItemStack item, RecipeType reci
/**
* This creates a new {@link SlimefunItem} from the given arguments.
*
- * @param itemGroup The {@link ItemGroup} this {@link SlimefunItem} belongs to
- * @param item The {@link SlimefunItemStack} that describes the visual features of our {@link SlimefunItem}
- * @param recipeType the {@link RecipeType} that determines how this {@link SlimefunItem} is crafted
- * @param recipe An Array representing the recipe of this {@link SlimefunItem}
- * @param recipeOutput The result of crafting this item
+ * @param itemGroup
+ * The {@link ItemGroup} this {@link SlimefunItem} belongs to
+ * @param item
+ * The {@link SlimefunItemStack} that describes the visual features of our {@link SlimefunItem}
+ * @param recipeType
+ * the {@link RecipeType} that determines how this {@link SlimefunItem} is crafted
+ * @param recipe
+ * An Array representing the recipe of this {@link SlimefunItem}
+ * @param recipeOutput
+ * The result of crafting this item
*/
@ParametersAreNonnullByDefault
- public SlimefunItem(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, @Nullable ItemStack recipeOutput) {
+ public SlimefunItem(
+ ItemGroup itemGroup,
+ SlimefunItemStack item,
+ RecipeType recipeType,
+ ItemStack[] recipe,
+ @Nullable ItemStack recipeOutput) {
Validate.notNull(itemGroup, "'itemGroup' is not allowed to be null!");
Validate.notNull(item, "'item' is not allowed to be null!");
Validate.notNull(recipeType, "'recipeType' is not allowed to be null!");
@@ -187,7 +192,7 @@ protected SlimefunItem(ItemGroup itemGroup, ItemStack item, String id, RecipeTyp
* 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}
@@ -367,7 +372,9 @@ public boolean isDisabled() {
*/
public boolean isDisabledIn(@Nonnull World world) {
if (state == ItemState.UNREGISTERED) {
- error("isDisabled(World) cannot be called before registering the item", new UnregisteredItemException(this));
+ error(
+ "isDisabled(World) cannot be called before registering the item",
+ new UnregisteredItemException(this));
return false;
}
@@ -502,16 +509,9 @@ public void enable() {
Slimefun.getRegistry().getRadioactiveItems().add(this);
}
- // enable ticking block
- Slimefun.getRegistry().getTickerBlocks().add(getId());
-
state = ItemState.ENABLED;
Slimefun.getRegistry().getEnabledSlimefunItems().add(this);
-
- if (!hidden) {
- itemGroup.add(this);
- }
}
/**
@@ -528,10 +528,6 @@ public void disable() {
state = ItemState.DISABLED;
Slimefun.getRegistry().getEnabledSlimefunItems().remove(this);
-
- if (!hidden) {
- itemGroup.remove(this);
- }
}
/**
@@ -552,8 +548,10 @@ private final void onEnable() {
// Check for an illegal stack size
if (itemStackTemplate.getAmount() != 1) {
// @formatter:off
- warn("This item has an illegal stack size: " + itemStackTemplate.getAmount()
- + ". An Item size of 1 is recommended. Please inform the author(s) of " + addon.getName()
+ warn("This item has an illegal stack size: "
+ + itemStackTemplate.getAmount()
+ + ". An Item size of 1 is recommended. Please inform the author(s) of "
+ + addon.getName()
+ " to fix this. Crafting Results with amounts of higher should be handled"
+ " via the recipeOutput parameter!");
// @formatter:on
@@ -600,7 +598,7 @@ private void loadItemHandlers() {
/**
* This method returns whether the original {@link SlimefunItemStack} of this
* {@link SlimefunItem} is immutable.
- *
+ *
* If true
is returned, then any changes to the original {@link SlimefunItemStack}
* will be rejected with a {@link WrongItemStackException}.
* This ensures integrity so developers don't accidentally damage the wrong {@link ItemStack}.
@@ -614,7 +612,8 @@ 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(@Nonnull SlimefunAddon addon) {
if (!addon.hasDependency("Slimefun")) {
@@ -636,10 +635,11 @@ private void checkForConflicts() {
/**
* This method checks recursively for all {@link Class} parents to look for any {@link Deprecated}
* elements.
- *
+ *
* 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) {
if (Slimefun.getUpdater().getBranch() == SlimefunBranch.DEVELOPMENT) {
@@ -659,13 +659,17 @@ private void checkForDeprecations(@Nullable Class> c) {
if (c != null) {
// 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!");
+ warn("The inherited Class \""
+ + 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!");
+ warn("The implemented Interface \""
+ + parent.getName()
+ + "\" has been deprecated. Check the documentation for more details!");
}
}
@@ -679,7 +683,8 @@ 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) {
@@ -696,7 +701,8 @@ 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(@Nonnull ItemStack[] recipe) {
if (recipe == null || recipe.length != 9) {
@@ -709,7 +715,8 @@ public void setRecipe(@Nonnull 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(@Nonnull RecipeType type) {
Validate.notNull(type, "The RecipeType is not allowed to be null!");
@@ -719,7 +726,8 @@ public void setRecipeType(@Nonnull 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(@Nonnull ItemGroup itemGroup) {
Validate.notNull(itemGroup, "The ItemGroup is not allowed to be null!");
@@ -734,7 +742,8 @@ public void setItemGroup(@Nonnull 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;
@@ -743,11 +752,12 @@ public void setRecipeOutput(@Nullable ItemStack output) {
/**
* This method returns whether or not this {@link SlimefunItem} is allowed to
* be used in a Crafting Table.
- *
+ *
* Items of type {@link VanillaItem} may be used in workbenches for example.
*
- * @return Whether this {@link SlimefunItem} may be used in a Workbench.
* @see #setUseableInWorkbench(boolean)
+ *
+ * @return Whether this {@link SlimefunItem} may be used in a Workbench.
*/
public boolean isUseableInWorkbench() {
return useableInWorkbench;
@@ -757,7 +767,9 @@ public boolean isUseableInWorkbench() {
* 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 @Nonnull SlimefunItem setUseableInWorkbench(boolean useable) {
@@ -770,7 +782,9 @@ public boolean isUseableInWorkbench() {
* 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) {
@@ -809,7 +823,8 @@ 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...");
@@ -817,7 +832,8 @@ public final void addItemHandler(ItemHandler... handlers) {
// Make sure they are added before the item was registered.
if (state != ItemState.UNREGISTERED) {
- throw new UnsupportedOperationException("You cannot add an ItemHandler after the SlimefunItem was registered.");
+ throw new UnsupportedOperationException(
+ "You cannot add an ItemHandler after the SlimefunItem was registered.");
}
for (ItemHandler handler : handlers) {
@@ -836,18 +852,21 @@ 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...");
Validate.noNullElements(settings, "You cannot add any 'null' ItemSettings!");
if (state != ItemState.UNREGISTERED) {
- throw new UnsupportedOperationException("You cannot add an ItemSetting after the SlimefunItem was registered.");
+ throw new UnsupportedOperationException(
+ "You cannot add an ItemSetting after the SlimefunItem was registered.");
}
if (this instanceof NotConfigurable) {
- throw new UnsupportedOperationException("This Item has been marked as NotConfigurable and cannot accept Item Settings!");
+ throw new UnsupportedOperationException(
+ "This Item has been marked as NotConfigurable and cannot accept Item Settings!");
}
for (ItemSetting> setting : settings) {
@@ -855,7 +874,8 @@ public final void addItemSetting(ItemSetting>... settings) {
// Prevent two Item Settings with the same key
for (ItemSetting> existingSetting : itemSettings) {
if (existingSetting.getKey().equals(setting.getKey())) {
- throw new IllegalArgumentException("This Item has already an ItemSetting with this key: " + setting.getKey());
+ throw new IllegalArgumentException(
+ "This Item has already an ItemSetting with this key: " + setting.getKey());
}
}
@@ -887,11 +907,12 @@ public void postRegister() {
* This method will assign the given wiki page to this Item.
* Note that you only need to provide the page name itself,
* the URL to our wiki is prepended automatically.
- *
+ *
* 返回非官方中文Wiki地址
* 下游应使用 {@link SlimefunItem#addWikiPage(String)} 来添加Wiki页面
*
- * @param page The associated wiki page
+ * @param page
+ * The associated wiki page
*/
@Deprecated
public final void addOfficialWikipage(@Nonnull String page) {
@@ -922,8 +943,9 @@ public final void addWikiPage(@Nonnull 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.
*
- * @return This item's wiki page
* @see SlimefunItem#addWikiPage(String)
+ *
+ * @return This item's wiki page
*/
public @Nonnull Optional getWikipage() {
return wikiURL;
@@ -937,7 +959,9 @@ public final void addWikiPage(@Nonnull String page) {
*/
public final @Nonnull String getItemName() {
if (itemStackTemplate instanceof SlimefunItemStack) {
- Optional name = ((SlimefunItemStack) itemStackTemplate).getItemMetaSnapshot().getDisplayName();
+ Optional name = ((SlimefunItemStack) itemStackTemplate)
+ .getItemMetaSnapshot()
+ .getDisplayName();
if (name.isPresent()) {
return name.get();
@@ -960,9 +984,13 @@ public final void addWikiPage(@Nonnull String page) {
* 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
@@ -996,7 +1024,14 @@ public String toString() {
if (addon == null) {
return getClass().getSimpleName() + " - '" + id + "'";
} else {
- return getClass().getSimpleName() + " - '" + id + "' (" + addon.getName() + " v" + addon.getPluginVersion() + ')';
+ return getClass().getSimpleName()
+ + " - '"
+ + id
+ + "' ("
+ + addon.getName()
+ + " v"
+ + addon.getPluginVersion()
+ + ')';
}
}
@@ -1015,7 +1050,8 @@ public String toString() {
* 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) {
@@ -1030,7 +1066,8 @@ 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) {
@@ -1049,13 +1086,17 @@ 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) {
// We can prompt the server operator to report it to the addon's bug tracker
@@ -1074,7 +1115,8 @@ 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) {
@@ -1092,12 +1134,15 @@ 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(@Nonnull Player p, boolean sendMessage) {
@@ -1144,7 +1189,8 @@ public boolean canUse(@Nonnull Player p, boolean sendMessage) {
* required Research to use this SlimefunItem.
*/
if (sendMessage && !(this instanceof VanillaItem)) {
- Slimefun.getLocalization().sendMessage(p, "messages.not-researched", true, s -> s.replace("%item%", getItemName()));
+ Slimefun.getLocalization()
+ .sendMessage(p, "messages.not-researched", true, s -> s.replace("%item%", getItemName()));
}
return false;
@@ -1178,7 +1224,8 @@ 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(@Nonnull String id) {
@@ -1188,7 +1235,8 @@ public final int hashCode() {
/**
* 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) {
@@ -1216,4 +1264,4 @@ public final int hashCode() {
public boolean loadDataByDefault() {
return ticking;
}
-}
\ No newline at end of file
+}
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 5604cdcfa8..bc85e022f7 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
@@ -1,5 +1,14 @@
package io.github.thebusybiscuit.slimefun4.api.items;
+import io.github.bakedlibs.dough.common.CommonPatterns;
+import io.github.bakedlibs.dough.items.ItemMetaSnapshot;
+import io.github.bakedlibs.dough.skins.PlayerHead;
+import io.github.bakedlibs.dough.skins.PlayerSkin;
+import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
+import io.github.thebusybiscuit.slimefun4.api.exceptions.PrematureCodeException;
+import io.github.thebusybiscuit.slimefun4.api.exceptions.WrongItemStackException;
+import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
+import io.github.thebusybiscuit.slimefun4.utils.HeadTexture;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Base64;
@@ -7,10 +16,8 @@
import java.util.Locale;
import java.util.Optional;
import java.util.function.Consumer;
-
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Color;
@@ -23,20 +30,10 @@
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
-import io.github.bakedlibs.dough.common.CommonPatterns;
-import io.github.bakedlibs.dough.items.ItemMetaSnapshot;
-import io.github.bakedlibs.dough.skins.PlayerHead;
-import io.github.bakedlibs.dough.skins.PlayerSkin;
-import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
-import io.github.thebusybiscuit.slimefun4.api.exceptions.PrematureCodeException;
-import io.github.thebusybiscuit.slimefun4.api.exceptions.WrongItemStackException;
-import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
-import io.github.thebusybiscuit.slimefun4.utils.HeadTexture;
-
/**
* The {@link SlimefunItemStack} functions as the base for any
* {@link SlimefunItem}.
- *
+ *
* @author TheBusyBiscuit
* @author Walshy
*
@@ -53,10 +50,12 @@ public SlimefunItemStack(@Nonnull String id, @Nonnull ItemStack item) {
super(item);
Validate.notNull(id, "The Item id must never be null!");
- Validate.isTrue(id.equals(id.toUpperCase(Locale.ROOT)), "Slimefun Item Ids must be uppercase! (e.g. 'MY_ITEM_ID')");
+ Validate.isTrue(
+ id.equals(id.toUpperCase(Locale.ROOT)), "Slimefun Item Ids must be uppercase! (e.g. 'MY_ITEM_ID')");
if (Slimefun.instance() == null) {
- throw new PrematureCodeException("A SlimefunItemStack must never be be created before your Plugin was enabled.");
+ throw new PrematureCodeException(
+ "A SlimefunItemStack must never be be created before your Plugin was enabled.");
}
this.id = id;
@@ -81,7 +80,8 @@ public SlimefunItemStack(@Nonnull String id, @Nonnull Material type, @Nonnull Co
this(id, new ItemStack(type), consumer);
}
- public SlimefunItemStack(@Nonnull String id, @Nonnull Material type, @Nullable String name, @Nonnull Consumer consumer) {
+ public SlimefunItemStack(
+ @Nonnull String id, @Nonnull Material type, @Nullable String name, @Nonnull Consumer consumer) {
this(id, type, meta -> {
if (name != null) {
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
@@ -112,7 +112,8 @@ public SlimefunItemStack(@Nonnull String id, @Nonnull Material type, @Nullable S
this(id, new ItemStack(type), name, lore);
}
- public SlimefunItemStack(@Nonnull String id, @Nonnull Material type, @Nonnull Color color, @Nullable String name, String... lore) {
+ public SlimefunItemStack(
+ @Nonnull String id, @Nonnull Material type, @Nonnull Color color, @Nullable String name, String... lore) {
this(id, type, im -> {
if (name != null) {
im.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
@@ -138,7 +139,12 @@ public SlimefunItemStack(@Nonnull String id, @Nonnull Material type, @Nonnull Co
});
}
- public SlimefunItemStack(@Nonnull String id, @Nonnull Color color, @Nonnull PotionEffect effect, @Nullable String name, String... lore) {
+ public SlimefunItemStack(
+ @Nonnull String id,
+ @Nonnull Color color,
+ @Nonnull PotionEffect effect,
+ @Nullable String name,
+ String... lore) {
this(id, Material.POTION, im -> {
if (name != null) {
im.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
@@ -179,7 +185,8 @@ public SlimefunItemStack(@Nonnull String id, @Nonnull HeadTexture head, @Nullabl
this(id, head.getTexture(), name, lore);
}
- public SlimefunItemStack(@Nonnull String id, @Nonnull String texture, @Nullable String name, @Nonnull Consumer consumer) {
+ public SlimefunItemStack(
+ @Nonnull String id, @Nonnull String texture, @Nullable String name, @Nonnull Consumer consumer) {
this(id, getSkull(id, texture), meta -> {
if (name != null) {
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
@@ -198,7 +205,7 @@ public SlimefunItemStack(@Nonnull String id, @Nonnull String texture, @Nonnull C
/**
* Returns the id that was given to this {@link SlimefunItemStack}.
- *
+ *
* @return The {@link SlimefunItem} id for this {@link SlimefunItemStack}
*/
public final @Nonnull String getItemId() {
@@ -218,18 +225,17 @@ public SlimefunItemStack(@Nonnull String id, @Nonnull String texture, @Nonnull C
/**
* This method returns the associated {@link SlimefunItem} and casts it to the provided
* {@link Class}.
- *
+ *
* If no item was found or the found {@link SlimefunItem} is not of the requested type,
* the method will return null.
- *
+ *
* @param
* The type of {@link SlimefunItem} to cast this to
* @param type
* The {@link Class} of the target {@link SlimefunItem}
- *
+ *
* @return The {@link SlimefunItem} this {@link SlimefunItem} represents, casted to the given type
*/
-
public @Nullable T getItem(@Nonnull Class type) {
SlimefunItem item = getItem();
return type.isInstance(item) ? type.cast(item) : null;
@@ -298,10 +304,12 @@ public void lock() {
if (texture.startsWith("ey")) {
return texture;
} else if (CommonPatterns.HEXADECIMAL.matcher(texture).matches()) {
- String value = "{\"textures\":{\"SKIN\":{\"url\":\"http://textures.minecraft.net/texture/" + texture + "\"}}}";
+ String value =
+ "{\"textures\":{\"SKIN\":{\"url\":\"http://textures.minecraft.net/texture/" + texture + "\"}}}";
return Base64.getEncoder().encodeToString(value.getBytes(StandardCharsets.UTF_8));
} else {
- throw new IllegalArgumentException("The provided texture for Item \"" + id + "\" does not seem to be a valid texture String!");
+ throw new IllegalArgumentException(
+ "The provided texture for Item \"" + id + "\" does not seem to be a valid texture String!");
}
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/FlexItemGroup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/FlexItemGroup.java
index 92f137dcfc..98eb2214f9 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/FlexItemGroup.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/FlexItemGroup.java
@@ -1,26 +1,23 @@
package io.github.thebusybiscuit.slimefun4.api.items.groups;
+import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
+import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
+import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
+import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
+import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode;
import java.util.List;
-
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
-
import org.bukkit.NamespacedKey;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
-import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
-import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
-import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
-import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
-import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode;
-
/**
* A {@link FlexItemGroup} is a {@link ItemGroup} inside the {@link SlimefunGuide} that can
* be completely modified.
* It cannot hold any {@link SlimefunItem} but can be completely overridden
* to perform any action upon being opened.
- *
+ *
* @author TheBusyBiscuit
*
*/
@@ -49,14 +46,14 @@ public final boolean isVisible(@Nonnull Player p) {
/**
* This method returns whether this {@link FlexItemGroup} is visible under the given context.
* Implementing this method gives full flexibility over who can see the ItemGroup when and where.
- *
+ *
* @param p
* The {@link Player} who opened his {@link SlimefunGuide}
* @param profile
* The {@link PlayerProfile} of the {@link Player}
* @param layout
* The {@link SlimefunGuideMode} in which this {@link FlexItemGroup} is viewed
- *
+ *
* @return Whether to display this {@link FlexItemGroup}
*/
@ParametersAreNonnullByDefault
@@ -66,7 +63,7 @@ public final boolean isVisible(@Nonnull Player p) {
* This method is called when a {@link Player} opens this {@link FlexItemGroup}.
* This is an abstract method which needs to be implemented in order to determine what this
* {@link FlexItemGroup} should actually do as it cannot hold any items.
- *
+ *
* @param p
* The {@link Player} who wants to open this {@link FlexItemGroup}
* @param profile
@@ -95,5 +92,4 @@ public final boolean contains(SlimefunItem item) {
public final void remove(@Nonnull SlimefunItem item) {
throw new UnsupportedOperationException("A FlexItemGroup has no items, so there is nothing remove!");
}
-
}
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 826ddbf301..5787dbd80b 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
@@ -1,36 +1,33 @@
package io.github.thebusybiscuit.slimefun4.api.items.groups;
+import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
+import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
+import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
+import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
+import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
-
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
-
import org.apache.commons.lang.Validate;
import org.bukkit.NamespacedKey;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
-import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
-import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
-import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
-import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
-import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
-
/**
* Represents a {@link ItemGroup} that cannot be opened until the parent group(s)
* are fully unlocked.
*
* See {@link ItemGroup} for the complete documentation.
- *
+ *
* @author TheBusyBiscuit
- *
+ *
* @see ItemGroup
* @see SeasonalItemGroup
- *
+ *
*/
public class LockedItemGroup extends ItemGroup {
@@ -40,14 +37,14 @@ public class LockedItemGroup extends ItemGroup {
/**
* The basic constructor for a LockedItemGroup.
* Like {@link ItemGroup}, the default tier is automatically set to 3.
- *
+ *
* @param key
* A unique identifier for this group
* @param item
* The display item for this group
* @param parents
* The parent categories for this group
- *
+ *
*/
@ParametersAreNonnullByDefault
public LockedItemGroup(NamespacedKey key, ItemStack item, NamespacedKey... parents) {
@@ -56,7 +53,7 @@ public LockedItemGroup(NamespacedKey key, ItemStack item, NamespacedKey... paren
/**
* The constructor for a LockedItemGroup.
- *
+ *
* @param key
* A unique identifier for this group
* @param item
@@ -65,7 +62,7 @@ public LockedItemGroup(NamespacedKey key, ItemStack item, NamespacedKey... paren
* The tier of this group
* @param parents
* The parent categories for this group
- *
+ *
*/
@ParametersAreNonnullByDefault
public LockedItemGroup(NamespacedKey key, ItemStack item, int tier, NamespacedKey... parents) {
@@ -94,15 +91,19 @@ public void register(@Nonnull SlimefunAddon addon) {
}
for (NamespacedKey key : namespacedKeys) {
- Slimefun.logger().log(Level.INFO, "Parent \"{0}\" for LockedItemGroup \"{1}\" was not found, probably just disabled.", new Object[] { key, getKey() });
+ Slimefun.logger()
+ .log(
+ Level.INFO,
+ "Parent \"{0}\" for LockedItemGroup \"{1}\" was not found, probably just disabled.",
+ new Object[] {key, getKey()});
}
}
/**
* Gets the list of parent item groups for this {@link LockedItemGroup}.
- *
+ *
* @return the list of parent item groups
- *
+ *
* @see #addParent(ItemGroup)
* @see #removeParent(ItemGroup)
*/
@@ -112,7 +113,7 @@ public void register(@Nonnull SlimefunAddon addon) {
/**
* Adds a parent {@link ItemGroup} to this {@link LockedItemGroup}.
- *
+ *
* @param group
* The {@link ItemGroup} to add as a parent
*
@@ -121,7 +122,9 @@ public void register(@Nonnull SlimefunAddon addon) {
*/
public void addParent(ItemGroup group) {
if (group == this || group == null) {
- throw new IllegalArgumentException("ItemGroup '" + item.getItemMeta().getDisplayName() + "' cannot be a parent of itself or have a 'null' parent.");
+ throw new IllegalArgumentException("ItemGroup '"
+ + item.getItemMeta().getDisplayName()
+ + "' cannot be a parent of itself or have a 'null' parent.");
}
parents.add(group);
@@ -129,10 +132,10 @@ public void addParent(ItemGroup group) {
/**
* Removes a {@link ItemGroup} from the parents of this {@link LockedItemGroup}.
- *
+ *
* @param group
* The {@link ItemGroup} to remove from the parents of this {@link LockedItemGroup}
- *
+ *
* @see #getParents()
* @see #addParent(ItemGroup)
*/
@@ -142,12 +145,12 @@ public void removeParent(@Nonnull ItemGroup group) {
/**
* Checks if the {@link Player} has fully unlocked all parent categories.
- *
+ *
* @param p
* The {@link Player} to check
* @param profile
* The {@link PlayerProfile} that belongs to the given {@link Player}
- *
+ *
* @return Whether the {@link Player} has fully completed all parent categories, otherwise false
*/
public boolean hasUnlocked(@Nonnull Player p, @Nonnull PlayerProfile profile) {
@@ -157,7 +160,9 @@ public boolean hasUnlocked(@Nonnull Player p, @Nonnull PlayerProfile profile) {
for (ItemGroup parent : parents) {
for (SlimefunItem item : parent.getItems()) {
// Check if the Player has researched every item (if the item is enabled)
- if (!item.isDisabledIn(p.getWorld()) && item.hasResearch() && !profile.hasUnlocked(item.getResearch())) {
+ if (!item.isDisabledIn(p.getWorld())
+ && item.hasResearch()
+ && !profile.hasUnlocked(item.getResearch())) {
return false;
}
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/NestedItemGroup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/NestedItemGroup.java
index 9a928c8be1..a49d5316b6 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
@@ -1,17 +1,5 @@
package io.github.thebusybiscuit.slimefun4.api.items.groups;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.annotation.Nonnull;
-import javax.annotation.ParametersAreNonnullByDefault;
-
-import org.apache.commons.lang.Validate;
-import org.bukkit.ChatColor;
-import org.bukkit.NamespacedKey;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.ItemStack;
-
import io.github.bakedlibs.dough.items.CustomItemStack;
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
import io.github.thebusybiscuit.slimefun4.core.guide.GuideHistory;
@@ -21,8 +9,16 @@
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide;
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
-
+import java.util.ArrayList;
+import java.util.List;
+import javax.annotation.Nonnull;
+import javax.annotation.ParametersAreNonnullByDefault;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
+import org.apache.commons.lang.Validate;
+import org.bukkit.ChatColor;
+import org.bukkit.NamespacedKey;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
public class NestedItemGroup extends FlexItemGroup {
@@ -41,7 +37,7 @@ public NestedItemGroup(NamespacedKey key, ItemStack item, int tier) {
/**
* This will add the given {@link SubItemGroup} to this {@link NestedItemGroup}.
- *
+ *
* @param group
* The {@link SubItemGroup} to add.
*/
@@ -53,7 +49,7 @@ public void addSubGroup(@Nonnull SubItemGroup group) {
/**
* This will remove the given {@link SubItemGroup} from this {@link NestedItemGroup} (if present).
- *
+ *
* @param group
* The {@link SubItemGroup} to remove.
*/
@@ -84,13 +80,17 @@ private void openGuide(Player p, PlayerProfile profile, SlimefunGuideMode mode,
}
ChestMenu menu = new ChestMenu(Slimefun.getLocalization().getMessage(p, "guide.title.main"));
- SurvivalSlimefunGuide guide = (SurvivalSlimefunGuide) Slimefun.getRegistry().getSlimefunGuide(mode);
+ SurvivalSlimefunGuide guide =
+ (SurvivalSlimefunGuide) Slimefun.getRegistry().getSlimefunGuide(mode);
menu.setEmptySlotsClickable(false);
menu.addMenuOpeningHandler(SoundEffect.GUIDE_BUTTON_CLICK_SOUND::playFor);
guide.createHeader(p, profile, menu);
- menu.addItem(1, new CustomItemStack(ChestMenuUtils.getBackButton(p, "", ChatColor.GRAY + Slimefun.getLocalization().getMessage(p, "guide.back.guide"))));
+ menu.addItem(
+ 1,
+ new CustomItemStack(ChestMenuUtils.getBackButton(
+ p, "", ChatColor.GRAY + Slimefun.getLocalization().getMessage(p, "guide.back.guide"))));
menu.addMenuClickHandler(1, (pl, s, is, action) -> {
SlimefunGuide.openMainMenu(profile, mode, history.getMainMenuPage());
return false;
@@ -143,5 +143,4 @@ private void openGuide(Player p, PlayerProfile profile, SlimefunGuideMode mode,
menu.open(p);
}
-
}
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 c61212c265..bbfed63d87 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
@@ -1,24 +1,21 @@
package io.github.thebusybiscuit.slimefun4.api.items.groups;
+import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
import java.time.LocalDate;
import java.time.Month;
-
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
-
import org.apache.commons.lang.Validate;
import org.bukkit.NamespacedKey;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
-import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
-
/**
* Represents a {@link ItemGroup} that is only displayed in the Guide during
* a specified {@link Month}.
- *
+ *
* @author TheBusyBiscuit
- *
+ *
* @see ItemGroup
* @see LockedItemGroup
*/
@@ -28,7 +25,7 @@ public class SeasonalItemGroup extends ItemGroup {
/**
* The constructor for a {@link SeasonalItemGroup}.
- *
+ *
* @param key
* The {@link NamespacedKey} that is used to identify this {@link ItemGroup}
* @param month
@@ -48,7 +45,7 @@ public SeasonalItemGroup(NamespacedKey key, Month month, int tier, ItemStack ite
/**
* This method returns the {@link Month} in which this {@link SeasonalItemGroup} will appear.
- *
+ *
* @return the {@link Month} in which this {@link SeasonalItemGroup} appears
*/
public @Nonnull Month getMonth() {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/SubItemGroup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/SubItemGroup.java
index 35b5aef3d1..069bd639e3 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/SubItemGroup.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/SubItemGroup.java
@@ -1,17 +1,15 @@
package io.github.thebusybiscuit.slimefun4.api.items.groups;
+import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
+import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
+import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
-
import org.apache.commons.lang.Validate;
import org.bukkit.NamespacedKey;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
-import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
-import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
-import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
-
/**
* The {@link SubItemGroup} is a child {@link ItemGroup} of the
* {@link NestedItemGroup}.
@@ -94,5 +92,4 @@ public final void register(@Nonnull SlimefunAddon addon) {
parentItemGroup.register(addon);
}
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/package-info.java
index e95ee138f5..45620e4cab 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/package-info.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/package-info.java
@@ -1,4 +1,4 @@
/**
* This package contains a few {@link io.github.thebusybiscuit.slimefun4.api.items.ItemGroup} variations.
*/
-package io.github.thebusybiscuit.slimefun4.api.items.groups;
\ No newline at end of file
+package io.github.thebusybiscuit.slimefun4.api.items.groups;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/package-info.java
index fd1bd1c8d6..6e4a0a2d3a 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/package-info.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/package-info.java
@@ -3,4 +3,4 @@
* {@link io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem}, such as
* {@link io.github.thebusybiscuit.slimefun4.api.items.ItemSetting}
*/
-package io.github.thebusybiscuit.slimefun4.api.items;
\ No newline at end of file
+package io.github.thebusybiscuit.slimefun4.api.items;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/DoubleRangeSetting.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/DoubleRangeSetting.java
index 3caeb974b3..7fac2e6eb5 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/DoubleRangeSetting.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/DoubleRangeSetting.java
@@ -1,19 +1,17 @@
package io.github.thebusybiscuit.slimefun4.api.items.settings;
+import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
+import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
-
import org.apache.commons.lang.Validate;
-import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
-import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
-
/**
* This variation of {@link ItemSetting} allows you to define an {@link Double} range
* and enforces this range using the {@link #validateInput(Double)} method.
- *
+ *
* @author TheBusyBiscuit
- *
+ *
* @see ItemSetting
* @see IntRangeSetting
*
@@ -45,7 +43,7 @@ public boolean validateInput(Double input) {
/**
* This returns the minimum value of this {@link DoubleRangeSetting}.
- *
+ *
* @return The minimum value
*/
public final double getMinimum() {
@@ -54,11 +52,10 @@ public final double getMinimum() {
/**
* This returns the maximum value of this {@link DoubleRangeSetting}.
- *
+ *
* @return The maximum value
*/
public final double getMaximum() {
return max;
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/EnumSetting.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/EnumSetting.java
index 0b2405ec22..7327799184 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/EnumSetting.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/EnumSetting.java
@@ -1,14 +1,12 @@
package io.github.thebusybiscuit.slimefun4.api.items.settings;
+import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
+import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import java.util.Arrays;
import java.util.stream.Collectors;
-
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
-import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
-import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
-
/**
* This variation of {@link ItemSetting} allows you to allow {@link Enum} constants to be
* used for {@link ItemSetting} validation.
@@ -74,5 +72,4 @@ public boolean validateInput(String input) {
return false;
}
}
-
-}
\ No newline at end of file
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/IntRangeSetting.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/IntRangeSetting.java
index 58e5dc34bf..ea119c1aaa 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/IntRangeSetting.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/IntRangeSetting.java
@@ -1,19 +1,17 @@
package io.github.thebusybiscuit.slimefun4.api.items.settings;
+import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
+import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
-
import org.apache.commons.lang.Validate;
-import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
-import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
-
/**
* This variation of {@link ItemSetting} allows you to define an {@link Integer} range
* and enforces this range using the {@link #validateInput(Integer)} method.
- *
+ *
* @author TheBusyBiscuit
- *
+ *
* @see ItemSetting
* @see DoubleRangeSetting
*
@@ -45,7 +43,7 @@ public boolean validateInput(Integer input) {
/**
* This returns the minimum value of this {@link IntRangeSetting}.
- *
+ *
* @return The minimum value
*/
public final int getMinimum() {
@@ -54,11 +52,10 @@ public final int getMinimum() {
/**
* This returns the maximum value of this {@link IntRangeSetting}.
- *
+ *
* @return The maximum value
*/
public final int getMaximum() {
return max;
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/MaterialTagSetting.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/MaterialTagSetting.java
index 047f08d4d5..60fceecba3 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/MaterialTagSetting.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/MaterialTagSetting.java
@@ -1,26 +1,23 @@
package io.github.thebusybiscuit.slimefun4.api.items.settings;
+import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
+import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import java.util.List;
import java.util.stream.Collectors;
-
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
-
import org.bukkit.Material;
import org.bukkit.Tag;
-import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
-import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
-
/**
* This variation of {@link ItemSetting} allows you to define a default {@link Tag}.
* The {@link Tag} will be translated into a {@link String} {@link List} which the user
* can then configure as they wish.
- *
+ *
* It also validates all inputs to be a valid {@link Material}.
- *
+ *
* @author TheBusyBiscuit
- *
+ *
* @see ItemSetting
*
*/
@@ -37,7 +34,7 @@ public MaterialTagSetting(SlimefunItem item, String key, Tag defaultTa
/**
* This {@link Tag} holds the default values for this {@link MaterialTagSetting}.
- *
+ *
* @return The default {@link Tag}
*/
public @Nonnull Tag getDefaultTag() {
@@ -69,14 +66,13 @@ public boolean validateInput(List input) {
/**
* Internal method to turn a {@link Tag} into a {@link List} of {@link String Strings}.
- *
+ *
* @param tag
* Our {@link Tag}
- *
+ *
* @return The {@link String} {@link List}
*/
private static @Nonnull List getAsStringList(@Nonnull Tag tag) {
return tag.getValues().stream().map(Material::name).collect(Collectors.toList());
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/package-info.java
index 0a12d616c3..4881393d75 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/package-info.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/package-info.java
@@ -1,4 +1,4 @@
/**
* This package contains various sub classes of {@link io.github.thebusybiscuit.slimefun4.api.items.ItemSetting}.
*/
-package io.github.thebusybiscuit.slimefun4.api.items.settings;
\ No newline at end of file
+package io.github.thebusybiscuit.slimefun4.api.items.settings;
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 0007edd745..a787c2d628 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
@@ -82,8 +82,7 @@ protected Network(@Nonnull NetworkManager manager, @Nonnull Location regulator)
*
* @return The assigned type of {@link NetworkComponent} for this {@link Location}
*/
- @Nullable
- public abstract NetworkComponent classifyLocation(@Nonnull Location l);
+ @Nullable public abstract NetworkComponent classifyLocation(@Nonnull Location l);
/**
* This method is called whenever a {@link Location} in this {@link Network} changes
@@ -153,8 +152,7 @@ public boolean connectsTo(@Nonnull Location l) {
}
}
- @Nullable
- private NetworkComponent getCurrentClassification(@Nonnull Location l) {
+ @Nullable private NetworkComponent getCurrentClassification(@Nonnull Location l) {
if (regulatorNodes.contains(l)) {
return NetworkComponent.REGULATOR;
} else if (connectorNodes.contains(l)) {
@@ -176,7 +174,8 @@ private void discoverStep() {
NetworkComponent classification = classifyLocation(l);
if (classification != currentAssignment) {
- if (currentAssignment == NetworkComponent.REGULATOR || currentAssignment == NetworkComponent.CONNECTOR) {
+ if (currentAssignment == NetworkComponent.REGULATOR
+ || currentAssignment == NetworkComponent.CONNECTOR) {
// Requires a complete rebuild of the network, so we just throw the current one away.
manager.unregisterNetwork(this);
return;
@@ -248,4 +247,4 @@ public Location getRegulator() {
public void tick() {
discoverStep();
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/NetworkComponent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/NetworkComponent.java
index 1155171673..b5059f8bad 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/NetworkComponent.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/NetworkComponent.java
@@ -11,7 +11,7 @@
* @see NetworkManager
*/
public enum NetworkComponent {
-
- CONNECTOR, REGULATOR, TERMINUS
-
-}
\ No newline at end of file
+ CONNECTOR,
+ REGULATOR,
+ TERMINUS
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/NetworkVisualizer.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/NetworkVisualizer.java
index 058a459779..71abce5594 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/NetworkVisualizer.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/NetworkVisualizer.java
@@ -1,12 +1,11 @@
package io.github.thebusybiscuit.slimefun4.api.network;
+import javax.annotation.Nonnull;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Particle.DustOptions;
-import javax.annotation.Nonnull;
-
/**
* This class represents the visualizer task of a given {@link Network}.
*
@@ -50,7 +49,8 @@ public void run() {
* @param l The {@link Location} of our node
*/
private void spawnParticles(@Nonnull Location l) {
- l.getWorld().spawnParticle(Particle.REDSTONE, l.getX() + 0.5, l.getY() + 0.5, l.getZ() + 0.5, 1, 0, 0, 0, 1, options);
+ l.getWorld()
+ .spawnParticle(
+ Particle.REDSTONE, l.getX() + 0.5, l.getY() + 0.5, l.getZ() + 0.5, 1, 0, 0, 0, 1, options);
}
-
-}
\ No newline at end of file
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/package-info.java
index b2232cf176..41b286cb34 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/package-info.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/package-info.java
@@ -1,4 +1,4 @@
/**
* This package provides the API infrastructure for networks, such as the Cargo- or Energy net.
*/
-package io.github.thebusybiscuit.slimefun4.api.network;
\ No newline at end of file
+package io.github.thebusybiscuit.slimefun4.api.network;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/package-info.java
index 7929e334cc..6c6be23d5c 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/package-info.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/package-info.java
@@ -2,4 +2,4 @@
* This package contains a bunch of classes and sub-packages related to the interaction
* with Slimefun via an API.
*/
-package io.github.thebusybiscuit.slimefun4.api;
\ No newline at end of file
+package io.github.thebusybiscuit.slimefun4.api;
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 8fd52f558a..dba61470d2 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
@@ -27,10 +27,10 @@
/**
* This class represents the instance of a {@link SlimefunBackpack} that is ready to
* be opened.
- *
+ *
* It holds an actual {@link Inventory} and represents the backpack on the
* level of an individual {@link ItemStack} as opposed to the class {@link SlimefunBackpack}.
- *
+ *
* @author TheBusyBiscuit
*
* @see SlimefunBackpack
@@ -55,9 +55,9 @@ public static void getAsync(ItemStack item, Consumer callback, b
var bUuid = getBackpackUUID(item.getItemMeta());
if (bUuid.isPresent()) {
- Slimefun.getDatabaseManager().getProfileDataController().getBackpackAsync(
- bUuid.get(),
- new IAsyncReadCallback<>() {
+ Slimefun.getDatabaseManager()
+ .getProfileDataController()
+ .getBackpackAsync(bUuid.get(), new IAsyncReadCallback<>() {
@Override
public boolean runOnMainThread() {
return runCbOnMainThread;
@@ -67,8 +67,7 @@ public boolean runOnMainThread() {
public void onResult(PlayerBackpack result) {
callback.accept(result);
}
- }
- );
+ });
return;
}
@@ -90,25 +89,25 @@ public void onResult(PlayerBackpack result) {
if (id.isPresent()) {
int number = id.getAsInt();
- Slimefun.getDatabaseManager().getProfileDataController().getBackpackAsync(
- Bukkit.getOfflinePlayer(UUID.fromString(uuid)),
- number,
- new IAsyncReadCallback<>() {
- @Override
- public boolean runOnMainThread() {
- return runCbOnMainThread;
- }
-
- @Override
- public void onResult(PlayerBackpack result) {
- var meta = item.getItemMeta();
- meta.getPersistentDataContainer().set(KEY_BACKPACK_UUID, PersistentDataType.STRING, result.uuid.toString());
- item.setItemMeta(meta);
- // TODO: upgrade lore
- callback.accept(result);
- }
- }
- );
+ Slimefun.getDatabaseManager()
+ .getProfileDataController()
+ .getBackpackAsync(
+ Bukkit.getOfflinePlayer(UUID.fromString(uuid)), number, new IAsyncReadCallback<>() {
+ @Override
+ public boolean runOnMainThread() {
+ return runCbOnMainThread;
+ }
+
+ @Override
+ public void onResult(PlayerBackpack result) {
+ var meta = item.getItemMeta();
+ meta.getPersistentDataContainer()
+ .set(KEY_BACKPACK_UUID, PersistentDataType.STRING, result.uuid.toString());
+ item.setItemMeta(meta);
+ // TODO: upgrade lore
+ callback.accept(result);
+ }
+ });
}
}
@@ -134,7 +133,8 @@ public static OptionalInt getBackpackID(ItemMeta meta) {
for (String line : meta.getLore()) {
if (line.startsWith(ChatColors.color("&7ID: ")) && line.contains("#")) {
try {
- return OptionalInt.of(Integer.parseInt(CommonPatterns.HASH.split(line.replace(ChatColors.color("&7ID: "), ""))[1]));
+ return OptionalInt.of(Integer.parseInt(
+ CommonPatterns.HASH.split(line.replace(ChatColors.color("&7ID: "), ""))[1]));
} catch (NumberFormatException e) {
e.printStackTrace();
}
@@ -195,7 +195,8 @@ private static void setItem(ItemMeta meta, PlayerBackpack bp) {
}
@ParametersAreNonnullByDefault
- public PlayerBackpack(OfflinePlayer owner, UUID uuid, String name, int id, int size, @Nullable ItemStack[] contents) {
+ public PlayerBackpack(
+ OfflinePlayer owner, UUID uuid, String name, int id, int size, @Nullable ItemStack[] contents) {
if (size < 9 || size > 54 || size % 9 != 0) {
throw new IllegalArgumentException("Invalid size! Size must be one of: [9, 18, 27, 36, 45, 54]");
}
@@ -219,7 +220,7 @@ public PlayerBackpack(OfflinePlayer owner, UUID uuid, String name, int id, int s
/**
* This returns the id of this {@link PlayerBackpack}
- *
+ *
* @return The id of this {@link PlayerBackpack}
*/
public int getId() {
@@ -228,7 +229,7 @@ public int getId() {
/**
* This method returns the {@link PlayerProfile} this {@link PlayerBackpack} belongs to
- *
+ *
* @return The owning {@link PlayerProfile}
*/
@Nonnull
@@ -238,7 +239,7 @@ public OfflinePlayer getOwner() {
/**
* This returns the size of this {@link PlayerBackpack}.
- *
+ *
* @return The size of this {@link PlayerBackpack}
*/
public int getSize() {
@@ -272,7 +273,7 @@ public void open(Player p) {
/**
* This will change the current size of this Backpack to the specified size.
- *
+ *
* @param size
* The new size for this Backpack
*/
@@ -317,7 +318,8 @@ public boolean isInvalid() {
* @return new {@link Inventory}
*/
private Inventory newInv() {
- return Bukkit.createInventory(this, size, (name.isEmpty() ? "背包" : ChatColors.color(name + "&r")) + " [大小 " + size + "]");
+ return Bukkit.createInventory(
+ this, size, (name.isEmpty() ? "背包" : ChatColors.color(name + "&r")) + " [大小 " + size + "]");
}
private void updateInv() {
@@ -328,5 +330,4 @@ private void updateInv() {
this.inventory = inv;
setInventory(inv);
}
-
}
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 6f923c18bb..dad0f317fa 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
@@ -39,9 +39,9 @@
/**
* A class that can store a Player's {@link Research} progress for caching purposes.
* It also holds the backpacks of a {@link Player}.
- *
+ *
* @author TheBusyBiscuit
- *
+ *
* @see Research
* @see Waypoint
* @see HashedArmorpiece
@@ -61,7 +61,9 @@ public class PlayerProfile {
private final List waypoints = new ArrayList<>();
private final GuideHistory guideHistory = new GuideHistory(this);
- private final HashedArmorpiece[] armor = { new HashedArmorpiece(), new HashedArmorpiece(), new HashedArmorpiece(), new HashedArmorpiece() };
+ private final HashedArmorpiece[] armor = {
+ new HashedArmorpiece(), new HashedArmorpiece(), new HashedArmorpiece(), new HashedArmorpiece()
+ };
public PlayerProfile(@Nonnull OfflinePlayer p, int backpackNum) {
this(p, backpackNum, new HashSet<>());
@@ -79,13 +81,18 @@ public PlayerProfile(@Nonnull OfflinePlayer p, int backpackNum, Set re
private void loadWaypoint() {
for (String key : waypointsFile.getKeys()) {
try {
- if (waypointsFile.contains(key + ".world") && Bukkit.getWorld(waypointsFile.getString(key + ".world")) != null) {
+ if (waypointsFile.contains(key + ".world")
+ && Bukkit.getWorld(waypointsFile.getString(key + ".world")) != null) {
String waypointName = waypointsFile.getString(key + ".name");
Location loc = waypointsFile.getLocation(key);
waypoints.add(new Waypoint(this, key, loc, waypointName));
}
} catch (Exception x) {
- Slimefun.logger().log(Level.WARNING, x, () -> "Could not load Waypoint \"" + key + "\" for Player \"" + owner.getName() + '"');
+ Slimefun.logger()
+ .log(
+ Level.WARNING,
+ x,
+ () -> "Could not load Waypoint \"" + key + "\" for Player \"" + owner.getName() + '"');
}
}
}
@@ -93,7 +100,7 @@ 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 @Nonnull HashedArmorpiece[] getArmor() {
@@ -102,7 +109,7 @@ private void loadWaypoint() {
/**
* This returns the {@link UUID} this {@link PlayerProfile} is linked to.
- *
+ *
* @return The {@link UUID} of our {@link PlayerProfile}
*/
public @Nonnull UUID getUUID() {
@@ -112,7 +119,7 @@ private void loadWaypoint() {
/**
* 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() {
@@ -121,7 +128,7 @@ public boolean isMarkedForDeletion() {
/**
* This method returns whether the Profile has unsaved changes
- *
+ *
* @return Whether there are unsaved changes
*/
public boolean isDirty() {
@@ -140,7 +147,7 @@ public void save() {
/**
* This method sets the Player's "researched" status for this Research.
* Use the boolean to unlock or lock the {@link Research}
- *
+ *
* @param research
* The {@link Research} that should be unlocked or locked
* @param unlock
@@ -155,15 +162,17 @@ public void setResearched(@Nonnull Research research, boolean unlock) {
} else {
researches.remove(research);
}
- Slimefun.getDatabaseManager().getProfileDataController().setResearch(owner.getUniqueId().toString(), research.getKey(), unlock);
+ Slimefun.getDatabaseManager()
+ .getProfileDataController()
+ .setResearch(owner.getUniqueId().toString(), research.getKey(), unlock);
}
/**
* This method returns whether the {@link Player} has unlocked the given {@link Research}
- *
+ *
* @param research
* The {@link Research} that is being queried
- *
+ *
* @return Whether this {@link Research} has been unlocked
*/
public boolean hasUnlocked(@Nullable Research research) {
@@ -177,7 +186,7 @@ public boolean hasUnlocked(@Nullable Research research) {
/**
* This method returns whether this {@link Player} has unlocked all {@link Research Researches}.
- *
+ *
* @return Whether they unlocked every {@link Research}
*/
public boolean hasUnlockedEverything() {
@@ -194,7 +203,7 @@ public boolean hasUnlockedEverything() {
/**
* This Method will return all Researches that this {@link Player} has unlocked
- *
+ *
* @return A {@code Hashset} of all Researches this {@link Player} has unlocked
*/
public @Nonnull Set getResearches() {
@@ -204,7 +213,7 @@ public boolean hasUnlockedEverything() {
/**
* This returns a {@link List} of all {@link Waypoint Waypoints} belonging to this
* {@link PlayerProfile}.
- *
+ *
* @return A {@link List} containing every {@link Waypoint}
*/
public @Nonnull List getWaypoints() {
@@ -214,7 +223,7 @@ public boolean hasUnlockedEverything() {
/**
* This adds the given {@link Waypoint} to the {@link List} of {@link Waypoint Waypoints}
* of this {@link PlayerProfile}.
- *
+ *
* @param waypoint
* The {@link Waypoint} to add
*/
@@ -239,7 +248,7 @@ public void addWaypoint(@Nonnull Waypoint waypoint) {
/**
* This removes the given {@link Waypoint} from the {@link List} of {@link Waypoint Waypoints}
* of this {@link PlayerProfile}.
- *
+ *
* @param waypoint
* The {@link Waypoint} to remove
*/
@@ -285,7 +294,8 @@ public void setBackpackCount(int count) {
public @Nonnull String getTitle() {
List titles = Slimefun.getRegistry().getResearchRanks();
- float fraction = (float) researches.size() / Slimefun.getRegistry().getResearches().size();
+ float fraction = (float) researches.size()
+ / Slimefun.getRegistry().getResearches().size();
int index = (int) (fraction * (titles.size() - 1));
return titles.get(index);
@@ -293,7 +303,8 @@ public void setBackpackCount(int count) {
public void sendStats(@Nonnull CommandSender sender) {
Set unlockedResearches = getResearches();
- int levels = unlockedResearches.stream().mapToInt(Research::getLevelCost).sum();
+ int levels =
+ unlockedResearches.stream().mapToInt(Research::getLevelCost).sum();
int allResearches = nonEmptyResearches();
float progress = Math.round(((unlockedResearches.size() * 100.0F) / allResearches) * 100.0F) / 100.0F;
@@ -302,14 +313,23 @@ public void sendStats(@Nonnull CommandSender sender) {
sender.sendMessage(ChatColors.color("&7玩家研究统计: &b" + owner.getName()));
sender.sendMessage("");
sender.sendMessage(ChatColors.color("&7研究等级: " + ChatColor.AQUA + getTitle()));
- sender.sendMessage(ChatColors.color("&7研究进度: " + NumberUtils.getColorFromPercentage(progress) + progress + " &r% " + ChatColor.YELLOW + '(' + unlockedResearches.size() + " / " + allResearches + ')'));
+ sender.sendMessage(ChatColors.color("&7研究进度: "
+ + NumberUtils.getColorFromPercentage(progress)
+ + progress
+ + " &r% "
+ + ChatColor.YELLOW
+ + '('
+ + unlockedResearches.size()
+ + " / "
+ + allResearches
+ + ')'));
sender.sendMessage(ChatColors.color("&7总花费经验等级: " + ChatColor.AQUA + levels));
}
/**
* This returns the {@link Player} who this {@link PlayerProfile} belongs to.
* If the {@link Player} is offline, null will be returned.
- *
+ *
* @return The {@link Player} of this {@link PlayerProfile} or null
*/
public @Nullable Player getPlayer() {
@@ -319,7 +339,7 @@ public void sendStats(@Nonnull CommandSender sender) {
/**
* 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 @Nonnull GuideHistory getGuideHistory() {
@@ -337,7 +357,7 @@ public static boolean fromUUID(@Nonnull UUID uuid, @Nonnull Consumer callback) {
@@ -358,10 +378,10 @@ public static boolean get(@Nonnull OfflinePlayer p, @Nonnull Consumer find(@Nonnull OfflinePlayer p) {
@@ -453,9 +473,9 @@ public boolean isInvalid() {
// returns the amount of researches with at least 1 enabled item
private int nonEmptyResearches() {
- return (int) Slimefun.getRegistry().getResearches()
- .stream()
- .filter(research -> research.getAffectedItems().stream().anyMatch(item -> item.getState() == ItemState.ENABLED))
+ return (int) Slimefun.getRegistry().getResearches().stream()
+ .filter(research ->
+ research.getAffectedItems().stream().anyMatch(item -> item.getState() == ItemState.ENABLED))
.count();
}
@@ -483,5 +503,4 @@ private void invokeCb(PlayerProfile pf) {
}
});
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/StatusEffect.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/StatusEffect.java
index a66daf5fbf..23d2453a09 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/StatusEffect.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/StatusEffect.java
@@ -1,27 +1,24 @@
package io.github.thebusybiscuit.slimefun4.api.player;
+import io.github.bakedlibs.dough.common.CommonPatterns;
+import io.github.bakedlibs.dough.data.persistent.PersistentDataAPI;
import java.util.Optional;
import java.util.OptionalInt;
import java.util.concurrent.TimeUnit;
-
import javax.annotation.Nonnull;
-
import org.bukkit.Keyed;
import org.bukkit.NamespacedKey;
import org.bukkit.entity.Player;
-import io.github.bakedlibs.dough.common.CommonPatterns;
-import io.github.bakedlibs.dough.data.persistent.PersistentDataAPI;
-
/**
* A very simple API that is meant for adding/getting/clearing custom status effects
* to/from players.
- *
+ *
* The effects are stored via {@link PersistentDataAPI} and use NBT data that is
* saved across server restarts.
- *
+ *
* You can specify a level for your status effect too.
- *
+ *
* @author TheBusyBiscuit
*
*/
@@ -42,7 +39,7 @@ public StatusEffect(@Nonnull NamespacedKey key) {
* This applies this {@link StatusEffect} to the given {@link Player}.
* You can specify a duration, this will reference
* {@link StatusEffect#add(Player, int, int, TimeUnit)} with a level of 1.
- *
+ *
* @param p
* The {@link Player} whom to apply the effect to
* @param duration
@@ -56,7 +53,7 @@ public void add(@Nonnull Player p, int duration, @Nonnull TimeUnit unit) {
/**
* This applies this {@link StatusEffect} to the given {@link Player}.
- *
+ *
* @param p
* The {@link Player} whom to apply the effect to
* @param level
@@ -73,7 +70,7 @@ public void add(@Nonnull Player p, int level, int duration, @Nonnull TimeUnit un
/**
* This applies this {@link StatusEffect} to the given {@link Player}.
* This will apply it permanently, there is no duration.
- *
+ *
* @param p
* The {@link Player} whom to apply the effect to
* @param level
@@ -88,7 +85,7 @@ public void addPermanent(@Nonnull Player p, int level) {
* to that {@link Player}.
* If the effect has expired, it will automatically remove all associated
* NBT data of this effect.
- *
+ *
* @param p
* The {@link Player} to check for
* @return Whether this {@link StatusEffect} is currently applied
@@ -114,7 +111,7 @@ public boolean isPresent(@Nonnull Player p) {
/**
* This method returns an {@link OptionalInt} describing the level of this status
* effect on that player.
- *
+ *
* @param p
* The {@link Player} to check for
* @return An {@link OptionalInt} that describes the result
@@ -132,12 +129,11 @@ public boolean isPresent(@Nonnull Player p) {
/**
* This will remove this {@link StatusEffect} from the given {@link Player}.
- *
+ *
* @param p
* The {@link Player} to clear it from
*/
public void clear(@Nonnull Player p) {
PersistentDataAPI.remove(p, getKey());
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/package-info.java
index b213a63aab..30773f7d1e 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/package-info.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/package-info.java
@@ -2,4 +2,4 @@
* This package stores API-related classes that are related to a {@link org.bukkit.entity.Player},
* such as the {@link io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile} for example.
*/
-package io.github.thebusybiscuit.slimefun4.api.player;
\ No newline at end of file
+package io.github.thebusybiscuit.slimefun4.api.player;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/recipes/RecipeType.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/recipes/RecipeType.java
index 6a569c9077..18b43f5040 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/recipes/RecipeType.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/recipes/RecipeType.java
@@ -31,41 +31,108 @@
// TODO: Remove this class and rewrite the recipe system
public class RecipeType implements Keyed {
- public static final RecipeType MULTIBLOCK = new RecipeType(new NamespacedKey(Slimefun.instance(), "multiblock"), new CustomItemStack(Material.BRICKS, "&bMultiBlock", "", "&a&oBuild it in the World"));
- public static final RecipeType ARMOR_FORGE = new RecipeType(new NamespacedKey(Slimefun.instance(), "armor_forge"), SlimefunItems.ARMOR_FORGE, "", "&a&oCraft it in an Armor Forge");
- public static final RecipeType GRIND_STONE = new RecipeType(new NamespacedKey(Slimefun.instance(), "grind_stone"), SlimefunItems.GRIND_STONE, "", "&a&oGrind it using the Grind Stone");
- public static final RecipeType SMELTERY = new RecipeType(new NamespacedKey(Slimefun.instance(), "smeltery"), SlimefunItems.SMELTERY, "", "&a&oSmelt it using a Smeltery");
- public static final RecipeType ORE_CRUSHER = new RecipeType(new NamespacedKey(Slimefun.instance(), "ore_crusher"), SlimefunItems.ORE_CRUSHER, "", "&a&oCrush it using the Ore Crusher");
- public static final RecipeType GOLD_PAN = new RecipeType(new NamespacedKey(Slimefun.instance(), "gold_pan"), SlimefunItems.GOLD_PAN, "", "&a&oUse a Gold Pan on Gravel to obtain this Item");
- public static final RecipeType COMPRESSOR = new RecipeType(new NamespacedKey(Slimefun.instance(), "compressor"), SlimefunItems.COMPRESSOR, "", "&a&oCompress it using the Compressor");
- public static final RecipeType PRESSURE_CHAMBER = new RecipeType(new NamespacedKey(Slimefun.instance(), "pressure_chamber"), SlimefunItems.PRESSURE_CHAMBER, "", "&a&oCompress it using the Pressure Chamber");
- public static final RecipeType MAGIC_WORKBENCH = new RecipeType(new NamespacedKey(Slimefun.instance(), "magic_workbench"), SlimefunItems.MAGIC_WORKBENCH, "", "&a&oCraft it in a Magic Workbench");
- public static final RecipeType ORE_WASHER = new RecipeType(new NamespacedKey(Slimefun.instance(), "ore_washer"), SlimefunItems.ORE_WASHER, "", "&a&oWash it in an Ore Washer");
- public static final RecipeType ENHANCED_CRAFTING_TABLE = new RecipeType(new NamespacedKey(Slimefun.instance(), "enhanced_crafting_table"), SlimefunItems.ENHANCED_CRAFTING_TABLE, "", "&a&oA regular Crafting Table cannot", "&a&ohold this massive Amount of Power...");
- public static final RecipeType JUICER = new RecipeType(new NamespacedKey(Slimefun.instance(), "juicer"), SlimefunItems.JUICER, "", "&a&oUsed for Juice Creation");
-
- public static final RecipeType ANCIENT_ALTAR = new RecipeType(new NamespacedKey(Slimefun.instance(), "ancient_altar"), SlimefunItems.ANCIENT_ALTAR, (recipe, output) -> {
- AltarRecipe altarRecipe = new AltarRecipe(Arrays.asList(recipe), output);
- AncientAltar altar = ((AncientAltar) SlimefunItems.ANCIENT_ALTAR.getItem());
- altar.getRecipes().add(altarRecipe);
- }, (recipe, output) -> {
- AltarRecipe altarRecipe = new AltarRecipe(Arrays.asList(recipe), output);
- AncientAltar altar = ((AncientAltar) SlimefunItems.ANCIENT_ALTAR.getItem());
- altar.getRecipes().removeIf(ar -> ar.equals(altarRecipe));
- });
-
- public static final RecipeType MOB_DROP = new RecipeType(new NamespacedKey(Slimefun.instance(), "mob_drop"), new CustomItemStack(Material.IRON_SWORD, "&bMob Drop"), RecipeType::registerMobDrop, "", "&rKill the specified Mob to obtain this Item");
- public static final RecipeType BARTER_DROP = new RecipeType(new NamespacedKey(Slimefun.instance(), "barter_drop"), new CustomItemStack(Material.GOLD_INGOT, "&bBarter Drop"), RecipeType::registerBarterDrop, "&aBarter with piglins for a chance", "&ato obtain this item");
- public static final RecipeType INTERACT = new RecipeType(new NamespacedKey(Slimefun.instance(), "interact"), new CustomItemStack(Material.PLAYER_HEAD, "&bInteract", "", "&a&oRight click with this item"));
-
- public static final RecipeType HEATED_PRESSURE_CHAMBER = new RecipeType(new NamespacedKey(Slimefun.instance(), "heated_pressure_chamber"), SlimefunItems.HEATED_PRESSURE_CHAMBER);
- public static final RecipeType FOOD_FABRICATOR = new RecipeType(new NamespacedKey(Slimefun.instance(), "food_fabricator"), SlimefunItems.FOOD_FABRICATOR);
- public static final RecipeType FOOD_COMPOSTER = new RecipeType(new NamespacedKey(Slimefun.instance(), "food_composter"), SlimefunItems.FOOD_COMPOSTER);
- public static final RecipeType FREEZER = new RecipeType(new NamespacedKey(Slimefun.instance(), "freezer"), SlimefunItems.FREEZER);
- public static final RecipeType REFINERY = new RecipeType(new NamespacedKey(Slimefun.instance(), "refinery"), SlimefunItems.REFINERY);
-
- public static final RecipeType GEO_MINER = new RecipeType(new NamespacedKey(Slimefun.instance(), "geo_miner"), SlimefunItems.GEO_MINER);
- public static final RecipeType NUCLEAR_REACTOR = new RecipeType(new NamespacedKey(Slimefun.instance(), "nuclear_reactor"), SlimefunItems.NUCLEAR_REACTOR);
+ public static final RecipeType MULTIBLOCK = new RecipeType(
+ new NamespacedKey(Slimefun.instance(), "multiblock"),
+ new CustomItemStack(Material.BRICKS, "&bMultiBlock", "", "&a&oBuild it in the World"));
+ public static final RecipeType ARMOR_FORGE = new RecipeType(
+ new NamespacedKey(Slimefun.instance(), "armor_forge"),
+ SlimefunItems.ARMOR_FORGE,
+ "",
+ "&a&oCraft it in an Armor Forge");
+ public static final RecipeType GRIND_STONE = new RecipeType(
+ new NamespacedKey(Slimefun.instance(), "grind_stone"),
+ SlimefunItems.GRIND_STONE,
+ "",
+ "&a&oGrind it using the Grind Stone");
+ public static final RecipeType SMELTERY = new RecipeType(
+ new NamespacedKey(Slimefun.instance(), "smeltery"),
+ SlimefunItems.SMELTERY,
+ "",
+ "&a&oSmelt it using a Smeltery");
+ public static final RecipeType ORE_CRUSHER = new RecipeType(
+ new NamespacedKey(Slimefun.instance(), "ore_crusher"),
+ SlimefunItems.ORE_CRUSHER,
+ "",
+ "&a&oCrush it using the Ore Crusher");
+ public static final RecipeType GOLD_PAN = new RecipeType(
+ new NamespacedKey(Slimefun.instance(), "gold_pan"),
+ SlimefunItems.GOLD_PAN,
+ "",
+ "&a&oUse a Gold Pan on Gravel to obtain this Item");
+ public static final RecipeType COMPRESSOR = new RecipeType(
+ new NamespacedKey(Slimefun.instance(), "compressor"),
+ SlimefunItems.COMPRESSOR,
+ "",
+ "&a&oCompress it using the Compressor");
+ public static final RecipeType PRESSURE_CHAMBER = new RecipeType(
+ new NamespacedKey(Slimefun.instance(), "pressure_chamber"),
+ SlimefunItems.PRESSURE_CHAMBER,
+ "",
+ "&a&oCompress it using the Pressure Chamber");
+ public static final RecipeType MAGIC_WORKBENCH = new RecipeType(
+ new NamespacedKey(Slimefun.instance(), "magic_workbench"),
+ SlimefunItems.MAGIC_WORKBENCH,
+ "",
+ "&a&oCraft it in a Magic Workbench");
+ public static final RecipeType ORE_WASHER = new RecipeType(
+ new NamespacedKey(Slimefun.instance(), "ore_washer"),
+ SlimefunItems.ORE_WASHER,
+ "",
+ "&a&oWash it in an Ore Washer");
+ public static final RecipeType ENHANCED_CRAFTING_TABLE = new RecipeType(
+ new NamespacedKey(Slimefun.instance(), "enhanced_crafting_table"),
+ SlimefunItems.ENHANCED_CRAFTING_TABLE,
+ "",
+ "&a&oA regular Crafting Table cannot",
+ "&a&ohold this massive Amount of Power...");
+ public static final RecipeType JUICER = new RecipeType(
+ new NamespacedKey(Slimefun.instance(), "juicer"), SlimefunItems.JUICER, "", "&a&oUsed for Juice Creation");
+
+ public static final RecipeType ANCIENT_ALTAR = new RecipeType(
+ new NamespacedKey(Slimefun.instance(), "ancient_altar"),
+ SlimefunItems.ANCIENT_ALTAR,
+ (recipe, output) -> {
+ AltarRecipe altarRecipe = new AltarRecipe(Arrays.asList(recipe), output);
+ AncientAltar altar = ((AncientAltar) SlimefunItems.ANCIENT_ALTAR.getItem());
+ altar.getRecipes().add(altarRecipe);
+ },
+ (recipe, output) -> {
+ AltarRecipe altarRecipe = new AltarRecipe(Arrays.asList(recipe), output);
+ AncientAltar altar = ((AncientAltar) SlimefunItems.ANCIENT_ALTAR.getItem());
+ altar.getRecipes().removeIf(ar -> ar.equals(altarRecipe));
+ });
+
+ public static final RecipeType MOB_DROP = new RecipeType(
+ new NamespacedKey(Slimefun.instance(), "mob_drop"),
+ new CustomItemStack(Material.IRON_SWORD, "&bMob Drop"),
+ RecipeType::registerMobDrop,
+ "",
+ "&rKill the specified Mob to obtain this Item");
+ public static final RecipeType BARTER_DROP = new RecipeType(
+ new NamespacedKey(Slimefun.instance(), "barter_drop"),
+ new CustomItemStack(Material.GOLD_INGOT, "&bBarter Drop"),
+ RecipeType::registerBarterDrop,
+ "&aBarter with piglins for a chance",
+ "&ato obtain this item");
+ public static final RecipeType INTERACT = new RecipeType(
+ new NamespacedKey(Slimefun.instance(), "interact"),
+ new CustomItemStack(Material.PLAYER_HEAD, "&bInteract", "", "&a&oRight click with this item"));
+
+ public static final RecipeType HEATED_PRESSURE_CHAMBER = new RecipeType(
+ new NamespacedKey(Slimefun.instance(), "heated_pressure_chamber"), SlimefunItems.HEATED_PRESSURE_CHAMBER);
+ public static final RecipeType FOOD_FABRICATOR =
+ new RecipeType(new NamespacedKey(Slimefun.instance(), "food_fabricator"), SlimefunItems.FOOD_FABRICATOR);
+ public static final RecipeType FOOD_COMPOSTER =
+ new RecipeType(new NamespacedKey(Slimefun.instance(), "food_composter"), SlimefunItems.FOOD_COMPOSTER);
+ public static final RecipeType FREEZER =
+ new RecipeType(new NamespacedKey(Slimefun.instance(), "freezer"), SlimefunItems.FREEZER);
+ public static final RecipeType REFINERY =
+ new RecipeType(new NamespacedKey(Slimefun.instance(), "refinery"), SlimefunItems.REFINERY);
+
+ public static final RecipeType GEO_MINER =
+ new RecipeType(new NamespacedKey(Slimefun.instance(), "geo_miner"), SlimefunItems.GEO_MINER);
+ public static final RecipeType NUCLEAR_REACTOR =
+ new RecipeType(new NamespacedKey(Slimefun.instance(), "nuclear_reactor"), SlimefunItems.NUCLEAR_REACTOR);
public static final RecipeType NULL = new RecipeType();
@@ -108,7 +175,12 @@ public RecipeType(NamespacedKey key, ItemStack item, BiConsumer registerCallback, BiConsumer unregisterCallback, String... lore) {
+ public RecipeType(
+ NamespacedKey key,
+ ItemStack item,
+ BiConsumer registerCallback,
+ BiConsumer unregisterCallback,
+ String... lore) {
this.item = new CustomItemStack(item, null, lore);
this.key = key;
this.registerConsumer = registerCallback;
@@ -130,7 +202,8 @@ public RecipeType(NamespacedKey key, ItemStack item) {
public RecipeType(MinecraftRecipe> recipe) {
this.item = new ItemStack(recipe.getMachine());
this.machine = "";
- this.key = NamespacedKey.minecraft(recipe.getRecipeClass().getSimpleName().toLowerCase(Locale.ROOT).replace("recipe", ""));
+ this.key = NamespacedKey.minecraft(
+ recipe.getRecipeClass().getSimpleName().toLowerCase(Locale.ROOT).replace("recipe", ""));
}
public void register(ItemStack[] recipe, ItemStack result) {
@@ -195,7 +268,9 @@ private static void registerBarterDrop(ItemStack[] recipe, ItemStack output) {
@ParametersAreNonnullByDefault
private static void registerMobDrop(ItemStack[] recipe, ItemStack output) {
- String mob = ChatColor.stripColor(recipe[4].getItemMeta().getDisplayName()).toUpperCase(Locale.ROOT).replace(' ', '_');
+ String mob = ChatColor.stripColor(recipe[4].getItemMeta().getDisplayName())
+ .toUpperCase(Locale.ROOT)
+ .replace(' ', '_');
EntityType entity = EntityType.valueOf(mob);
Set dropping = Slimefun.getRegistry().getMobDrops().getOrDefault(entity, new HashSet<>());
dropping.add(output);
@@ -257,4 +332,4 @@ public static ItemStack getRecipeOutputList(MultiBlockMachine machine, ItemStack
List recipes = machine.getRecipes();
return recipes.get((recipes.indexOf(input) + 1))[0];
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/recipes/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/recipes/package-info.java
index ac5c2a8d45..d756a20368 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/recipes/package-info.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/recipes/package-info.java
@@ -1,4 +1,4 @@
/**
* This package contains all classes related to our recipe system.
*/
-package io.github.thebusybiscuit.slimefun4.api.recipes;
\ No newline at end of file
+package io.github.thebusybiscuit.slimefun4.api.recipes;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/PlayerResearchTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/PlayerResearchTask.java
index 70403ead2c..7a77dd1d4e 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/PlayerResearchTask.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/PlayerResearchTask.java
@@ -1,27 +1,23 @@
package io.github.thebusybiscuit.slimefun4.api.researches;
-import java.util.function.Consumer;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import org.apache.commons.lang.Validate;
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
-
import io.github.thebusybiscuit.slimefun4.api.events.ResearchUnlockEvent;
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
import io.github.thebusybiscuit.slimefun4.core.guide.options.SlimefunGuideSettings;
import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.utils.FireworkUtils;
-
+import java.util.function.Consumer;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import org.apache.commons.lang.Validate;
+import org.bukkit.Bukkit;
+import org.bukkit.entity.Player;
/**
* A {@link PlayerResearchTask} is run when a {@link Player} unlocks a {@link Research}.
*
* @author TheBusyBiscuit
- *
+ *
* @see Research
* @see ResearchUnlockEvent
* @see PlayerProfile
@@ -64,10 +60,15 @@ public void accept(PlayerProfile profile) {
}
if (!isInstant) {
- Slimefun.runSync(() -> {
- SoundEffect.PLAYER_RESEARCHING_SOUND.playFor(p);
- Slimefun.getLocalization().sendMessage(p, "messages.research.progress", true, msg -> msg.replace(PLACEHOLDER, research.getName(p)).replace("%progress%", "0%"));
- }, 5L);
+ Slimefun.runSync(
+ () -> {
+ SoundEffect.PLAYER_RESEARCHING_SOUND.playFor(p);
+ Slimefun.getLocalization()
+ .sendMessage(p, "messages.research.progress", true, msg -> msg.replace(
+ PLACEHOLDER, research.getName(p))
+ .replace("%progress%", "0%"));
+ },
+ 5L);
}
ResearchUnlockEvent event = new ResearchUnlockEvent(p, research);
@@ -76,14 +77,25 @@ public void accept(PlayerProfile profile) {
if (!event.isCancelled()) {
if (isInstant) {
Slimefun.runSync(() -> unlockResearch(p, profile));
- } else if (Slimefun.getRegistry().getCurrentlyResearchingPlayers().add(p.getUniqueId())) {
- Slimefun.getLocalization().sendMessage(p, "messages.research.start", true, msg -> msg.replace(PLACEHOLDER, research.getName(p)));
+ } else if (Slimefun.getRegistry()
+ .getCurrentlyResearchingPlayers()
+ .add(p.getUniqueId())) {
+ Slimefun.getLocalization()
+ .sendMessage(
+ p,
+ "messages.research.start",
+ true,
+ msg -> msg.replace(PLACEHOLDER, research.getName(p)));
sendUpdateMessage(p);
- Slimefun.runSync(() -> {
- unlockResearch(p, profile);
- Slimefun.getRegistry().getCurrentlyResearchingPlayers().remove(p.getUniqueId());
- }, (RESEARCH_PROGRESS.length + 1) * 20L);
+ Slimefun.runSync(
+ () -> {
+ unlockResearch(p, profile);
+ Slimefun.getRegistry()
+ .getCurrentlyResearchingPlayers()
+ .remove(p.getUniqueId());
+ },
+ (RESEARCH_PROGRESS.length + 1) * 20L);
}
}
}
@@ -93,20 +105,23 @@ private void sendUpdateMessage(@Nonnull Player p) {
for (int i = 1; i < RESEARCH_PROGRESS.length + 1; i++) {
int index = i;
- Slimefun.runSync(() -> {
- SoundEffect.PLAYER_RESEARCHING_SOUND.playFor(p);
+ Slimefun.runSync(
+ () -> {
+ SoundEffect.PLAYER_RESEARCHING_SOUND.playFor(p);
- Slimefun.getLocalization().sendMessage(p, "messages.research.progress", true, msg -> {
- String progress = RESEARCH_PROGRESS[index - 1] + "%";
- return msg.replace(PLACEHOLDER, research.getName(p)).replace("%progress%", progress);
- });
- }, i * 20L);
+ Slimefun.getLocalization().sendMessage(p, "messages.research.progress", true, msg -> {
+ String progress = RESEARCH_PROGRESS[index - 1] + "%";
+ return msg.replace(PLACEHOLDER, research.getName(p)).replace("%progress%", progress);
+ });
+ },
+ i * 20L);
}
}
private void unlockResearch(@Nonnull Player p, @Nonnull PlayerProfile profile) {
profile.setResearched(research, true);
- Slimefun.getLocalization().sendMessage(p, "messages.unlocked", true, msg -> msg.replace(PLACEHOLDER, research.getName(p)));
+ Slimefun.getLocalization()
+ .sendMessage(p, "messages.unlocked", true, msg -> msg.replace(PLACEHOLDER, research.getName(p)));
onFinish(p);
// Check if the Server and the Player have enabled fireworks for researches
@@ -117,7 +132,7 @@ private void unlockResearch(@Nonnull Player p, @Nonnull PlayerProfile profile) {
/**
* This method is called when the {@link Research} successfully finished to unlock.
- *
+ *
* @param p
* The {@link Player} who has unlocked this {@link Research}
*/
@@ -126,4 +141,4 @@ private void onFinish(@Nonnull Player p) {
callback.accept(p);
}
}
-}
\ No newline at end of file
+}
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 f2c1bd33d2..517dcfee2b 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
@@ -65,7 +65,8 @@ public class Research implements Keyed {
* The Cost in economy to unlock this {@link Research}
*
*/
- public Research(@Nonnull NamespacedKey key, int id, @Nonnull String defaultName, int levelCost, double currencyCost) {
+ public Research(
+ @Nonnull NamespacedKey key, int id, @Nonnull String defaultName, int levelCost, double currencyCost) {
Validate.notNull(key, "A NamespacedKey must be provided");
Validate.notNull(defaultName, "A default name must be specified");
@@ -114,7 +115,7 @@ public Research(@Nonnull NamespacedKey key, int id, @Nonnull String defaultName,
* This method returns whether this {@link Research} is enabled.
* {@code false} can mean that this particular {@link Research} was disabled or that
* researches altogether have been disabled.
- *
+ *
* @return Whether this {@link Research} is enabled or not
*/
public boolean isEnabled() {
@@ -124,9 +125,9 @@ public boolean isEnabled() {
/**
* Gets the ID of this {@link Research}.
* This is the old way of identifying Researches, use a {@link NamespacedKey} in the future.
- *
+ *
* @deprecated Numeric Ids for Researches are deprecated, use {@link #getKey()} for identification instead.
- *
+ *
* @return The ID of this {@link Research}
*/
@Deprecated
@@ -138,10 +139,10 @@ public int getID() {
* This method gives you a localized name for this {@link Research}.
* The name is automatically taken from the currently selected {@link Language} of
* the specified {@link Player}.
- *
+ *
* @param p
* The {@link Player} to translate this name for.
- *
+ *
* @return The localized Name of this {@link Research}.
*/
public @Nonnull String getName(@Nonnull Player p) {
@@ -208,7 +209,7 @@ public void setLevelCost(int levelCost) {
/**
* Bind the specified {@link SlimefunItem SlimefunItems} to this {@link Research}.
- *
+ *
* @param items
* Instances of {@link SlimefunItem} to bind to this {@link Research}
*/
@@ -222,10 +223,10 @@ public void addItems(SlimefunItem... items) {
/**
* Bind the specified ItemStacks to this {@link Research}.
- *
+ *
* @param items
* Instances of {@link ItemStack} to bind to this {@link Research}
- *
+ *
* @return The current instance of {@link Research}
*/
@Nonnull
@@ -243,7 +244,7 @@ public Research addItems(ItemStack... items) {
/**
* Lists every {@link SlimefunItem} that is bound to this {@link Research}.
- *
+ *
* @return The Slimefun items bound to this {@link Research}.
*/
@Nonnull
@@ -270,7 +271,13 @@ public List getAffectedItems() {
*
*/
@ParametersAreNonnullByDefault
- public void unlockFromGuide(SlimefunGuideImplementation guide, Player player, PlayerProfile profile, SlimefunItem sfItem, ItemGroup itemGroup, int page) {
+ public void unlockFromGuide(
+ SlimefunGuideImplementation guide,
+ Player player,
+ PlayerProfile profile,
+ SlimefunItem sfItem,
+ ItemGroup itemGroup,
+ int page) {
if (!Slimefun.getRegistry().getCurrentlyResearchingPlayers().contains(player.getUniqueId())) {
if (profile.hasUnlocked(this)) {
guide.openItemGroup(profile, itemGroup, page);
@@ -310,14 +317,15 @@ public boolean canUnlock(@Nonnull Player p) {
canUnlock = p.getLevel() >= levelCost;
}
- boolean creativeResearch = p.getGameMode() == GameMode.CREATIVE && Slimefun.getConfigManager().isFreeCreativeResearchingEnabled();
+ boolean creativeResearch = p.getGameMode() == GameMode.CREATIVE
+ && Slimefun.getConfigManager().isFreeCreativeResearchingEnabled();
return creativeResearch || canUnlock;
}
/**
* This unlocks this {@link Research} for the given {@link Player} without any form of callback.
- *
+ *
* @param p
* The {@link Player} who should unlock this {@link Research}
* @param instant
@@ -329,7 +337,7 @@ public void unlock(@Nonnull Player p, boolean instant) {
/**
* Unlocks this {@link Research} for the specified {@link Player}.
- *
+ *
* @param p
* The {@link Player} for which to unlock this {@link Research}
* @param isInstant
@@ -348,7 +356,8 @@ public void register() {
Slimefun.getResearchCfg().setDefaultValue("enable-researching", true);
String path = key.getNamespace() + '.' + key.getKey();
- if (Slimefun.getResearchCfg().contains(path + ".enabled") && !Slimefun.getResearchCfg().getBoolean(path + ".enabled")) {
+ if (Slimefun.getResearchCfg().contains(path + ".enabled")
+ && !Slimefun.getResearchCfg().getBoolean(path + ".enabled")) {
for (SlimefunItem item : new ArrayList<>(items)) {
if (item != null) {
item.setResearch(null);
@@ -410,7 +419,9 @@ public static Optional getResearchByID(@Nonnull Integer oldID) {
return Optional.empty();
}
- return Slimefun.getRegistry().getResearches().parallelStream().filter(r -> r.id == oldID).findFirst();
+ return Slimefun.getRegistry().getResearches().parallelStream()
+ .filter(r -> r.id == oldID)
+ .findFirst();
}
@Override
@@ -425,4 +436,4 @@ public double getCurrencyCost() {
public void setCurrencyCost(double currencyCost) {
this.currencyCost = currencyCost;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/package-info.java
index ba6cd3df54..8e1a33a4ab 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/package-info.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/package-info.java
@@ -2,4 +2,4 @@
* This package holds everything connected to the {@link io.github.thebusybiscuit.slimefun4.api.researches.Research}
* class.
*/
-package io.github.thebusybiscuit.slimefun4.api.researches;
\ No newline at end of file
+package io.github.thebusybiscuit.slimefun4.api.researches;
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 8c41ea176a..b22cb3324a 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java
@@ -14,17 +14,6 @@
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.implementation.guide.CheatSheetSlimefunGuide;
import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide;
-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 javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumMap;
@@ -36,11 +25,21 @@
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
+import javax.annotation.Nonnull;
+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;
/**
* This class houses a lot of instances of {@link Map} and {@link List} that hold
* various mappings and collections related to {@link SlimefunItem}.
- *
+ *
* @author TheBusyBiscuit
*
*/
@@ -92,7 +91,7 @@ public void load(@Nonnull Slimefun plugin) {
/**
* This returns a {@link List} containing every enabled {@link ItemGroup}.
- *
+ *
* @return {@link List} containing every enabled {@link ItemGroup}
*/
@Nonnull
@@ -102,7 +101,7 @@ public List getAllItemGroups() {
/**
* This {@link List} contains every {@link SlimefunItem}, even disabled items.
- *
+ *
* @return A {@link List} containing every {@link SlimefunItem}
*/
public @Nonnull List getAllSlimefunItems() {
@@ -123,7 +122,7 @@ public List getAllItemGroups() {
/**
* This {@link List} contains every enabled {@link SlimefunItem}.
- *
+ *
* @return A {@link List} containing every enabled {@link SlimefunItem}
*/
@Nonnull
@@ -133,7 +132,7 @@ public List getEnabledSlimefunItems() {
/**
* This returns a {@link List} containing every enabled {@link Research}.
- *
+ *
* @return A {@link List} containing every enabled {@link Research}
*/
@Nonnull
@@ -144,7 +143,7 @@ public List getResearches() {
/**
* This method returns a {@link Set} containing the {@link UUID} of every
* {@link Player} who is currently unlocking a {@link Research}.
- *
+ *
* @return A {@link Set} holding the {@link UUID} from every {@link Player}
* who is currently unlocking a {@link Research}
*/
@@ -160,7 +159,7 @@ public List getResearchRanks() {
/**
* This method returns a {@link List} of every enabled {@link MultiBlock}.
- *
+ *
* @return A {@link List} containing every enabled {@link MultiBlock}
*/
@Nonnull
@@ -175,10 +174,10 @@ public List getMultiBlocks() {
* This mainly only exists for internal purposes, if you want to open a certain section
* using the {@link SlimefunGuide}, then please use the static methods provided in the
* {@link SlimefunGuide} class.
- *
+ *
* @param mode
* The {@link SlimefunGuideMode}
- *
+ *
* @return The corresponding {@link SlimefunGuideImplementation}
*/
@Nonnull
@@ -197,7 +196,7 @@ public SlimefunGuideImplementation getSlimefunGuide(@Nonnull SlimefunGuideMode m
/**
* 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
*/
@Nonnull
@@ -208,7 +207,7 @@ public Map> getMobDrops() {
/**
* This returns a {@link Set} of {@link ItemStack ItemStacks} which can be obtained by bartering
* with {@link Piglin Piglins}.
- *
+ *
* @return A {@link Set} of bartering drops
*/
@Nonnull
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DamageableItem.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DamageableItem.java
index 05694f3e64..6a4fae9115 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DamageableItem.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DamageableItem.java
@@ -1,8 +1,10 @@
package io.github.thebusybiscuit.slimefun4.core.attributes;
+import io.github.bakedlibs.dough.config.Config;
+import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
+import io.github.thebusybiscuit.slimefun4.utils.UnbreakingAlgorithm;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-
import org.bukkit.Sound;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
@@ -10,22 +12,18 @@
import org.bukkit.inventory.meta.Damageable;
import org.bukkit.inventory.meta.ItemMeta;
-import io.github.bakedlibs.dough.config.Config;
-import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
-import io.github.thebusybiscuit.slimefun4.utils.UnbreakingAlgorithm;
-
/**
* This interface, when attached to a {@link SlimefunItem}, provides an easy method for damaging
* an {@link ItemStack}, see {@link #damageItem(Player, ItemStack)}.
- *
+ *
* It also provides a simple {@link #isDamageable()} method, in case you wanna add a config
* option that decides whether or not this {@link SlimefunItem} shall be damageable.
- *
+ *
* @author TheBusyBiscuit
* @author RobotHanzo
- *
+ *
* @see UnbreakingAlgorithm
- *
+ *
*/
public interface DamageableItem extends ItemAttribute {
@@ -33,7 +31,7 @@ public interface DamageableItem extends ItemAttribute {
* Implement this method to make the behaviour of this interface dependent
* on the state of your object.
* You could add a {@link Config} option to toggle the behaviour for example.
- *
+ *
* @return Whether this {@link SlimefunItem} is damageable
*/
boolean isDamageable();
@@ -41,9 +39,9 @@ public interface DamageableItem extends ItemAttribute {
/**
* This method will damage the given {@link ItemStack} once.
* It also takes into account the {@link Enchantment} {@code Unbreaking}.
- *
+ *
* It will only apply the damage if {@link #isDamageable()} returned true.
- *
+ *
* @param p
* The {@link Player} to which the item belongs
* @param item
@@ -82,12 +80,11 @@ default void damageItem(@Nonnull Player p, @Nullable ItemStack item) {
*
* @param unbreakingLevel
* The {@link Integer} level of the unbreaking {@link Enchantment}
- *
+ *
* @return Whether to save the item from taking damage
*
*/
default boolean evaluateUnbreakingEnchantment(int unbreakingLevel) {
return UnbreakingAlgorithm.TOOLS.evaluate(unbreakingLevel);
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DistinctiveItem.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DistinctiveItem.java
index 150bef8319..c8297065f9 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DistinctiveItem.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DistinctiveItem.java
@@ -1,12 +1,10 @@
package io.github.thebusybiscuit.slimefun4.core.attributes;
+import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
-import org.bukkit.inventory.meta.ItemMeta;
-
-import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
-
import javax.annotation.Nonnull;
+import org.bukkit.inventory.meta.ItemMeta;
/**
* Implement this interface for any {@link SlimefunItem} to prevent
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetComponent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetComponent.java
index cafe3bd812..30aef09c33 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetComponent.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetComponent.java
@@ -20,12 +20,12 @@
* This Interface, when attached to a class that inherits from {@link SlimefunItem}, marks
* the Item as an electric Block.
* This will make this Block interact with an {@link EnergyNet}.
- *
+ *
* You can specify the Type of Block via {@link EnergyNetComponent#getEnergyComponentType()}.
* You can also specify a capacity for this Block via {@link EnergyNetComponent#getCapacity()}.
- *
+ *
* @author TheBusyBiscuit
- *
+ *
* @see EnergyNetComponentType
* @see EnergyNet
*
@@ -35,7 +35,7 @@ public interface EnergyNetComponent extends ItemAttribute {
/**
* This method returns the Type of {@link EnergyNetComponentType} this {@link SlimefunItem} represents.
* It describes how this Block will interact with an {@link EnergyNet}.
- *
+ *
* @return The {@link EnergyNetComponentType} this {@link SlimefunItem} represents.
*/
@Nonnull
@@ -44,7 +44,7 @@ public interface EnergyNetComponent extends ItemAttribute {
/**
* This method returns the max amount of electricity this Block can hold.
* If the capacity is zero, then this Block cannot hold any electricity.
- *
+ *
* @return The max amount of electricity this Block can store.
*/
int getCapacity();
@@ -52,7 +52,7 @@ public interface EnergyNetComponent extends ItemAttribute {
/**
* This returns whether this {@link EnergyNetComponent} can hold energy charges.
* It returns true if {@link #getCapacity()} returns a number greater than zero.
- *
+ *
* @return Whether this {@link EnergyNetComponent} can store energy.
*/
default boolean isChargeable() {
@@ -61,10 +61,10 @@ default boolean isChargeable() {
/**
* This returns the currently stored charge at a given {@link Location}.
- *
+ *
* @param l
* The target {@link Location}
- *
+ *
* @return The charge stored at that {@link Location}
*/
default int getCharge(@Nonnull Location l) {
@@ -118,7 +118,7 @@ default int getCharge(@Nonnull Location l, @Nonnull Config config) {
* The target {@link Location}
* @param data
* The data at this {@link Location}
- *
+ *
* @return The charge stored at that {@link Location}
*/
default int getCharge(@Nonnull Location l, @Nonnull SlimefunBlockData data) {
@@ -143,7 +143,7 @@ default int getCharge(@Nonnull Location l, @Nonnull SlimefunBlockData data) {
* This method sets the charge which is stored at a given {@link Location}
* If this {@link EnergyNetComponent} is of type {@code EnergyNetComponentType.CAPACITOR}, then
* this method will automatically update the texture of this {@link Capacitor} as well.
- *
+ *
* @param l
* The target {@link Location}
* @param charge
@@ -182,7 +182,14 @@ default void setCharge(@Nonnull Location l, int charge) {
}
}
} catch (Exception | LinkageError x) {
- Slimefun.logger().log(Level.SEVERE, x, () -> "Exception while trying to set the energy-charge for \"" + getId() + "\" at " + new BlockPosition(l));
+ Slimefun.logger()
+ .log(
+ Level.SEVERE,
+ x,
+ () -> "Exception while trying to set the energy-charge for \""
+ + getId()
+ + "\" at "
+ + new BlockPosition(l));
}
}
@@ -209,7 +216,14 @@ default void addCharge(@Nonnull Location l, int charge) {
}
}
} catch (Exception | LinkageError x) {
- Slimefun.logger().log(Level.SEVERE, x, () -> "Exception while trying to add an energy-charge for \"" + getId() + "\" at " + new BlockPosition(l));
+ Slimefun.logger()
+ .log(
+ Level.SEVERE,
+ x,
+ () -> "Exception while trying to add an energy-charge for \""
+ + getId()
+ + "\" at "
+ + new BlockPosition(l));
}
}
@@ -236,8 +250,14 @@ default void removeCharge(@Nonnull Location l, int charge) {
}
}
} catch (Exception | LinkageError x) {
- Slimefun.logger().log(Level.SEVERE, x, () -> "Exception while trying to remove an energy-charge for \"" + getId() + "\" at " + new BlockPosition(l));
+ Slimefun.logger()
+ .log(
+ Level.SEVERE,
+ x,
+ () -> "Exception while trying to remove an energy-charge for \""
+ + getId()
+ + "\" at "
+ + new BlockPosition(l));
}
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetProvider.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetProvider.java
index f26a9d32cd..57211bffd1 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetProvider.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetProvider.java
@@ -6,12 +6,11 @@
import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType;
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.AbstractEnergyProvider;
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.Reactor;
+import javax.annotation.Nonnull;
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator;
import org.bukkit.Location;
-import javax.annotation.Nonnull;
-
/**
* An {@link EnergyNetProvider} is an extension of {@link EnergyNetComponent} which provides
* energy to an {@link EnergyNet}.
@@ -64,5 +63,4 @@ default boolean willExplode(@Nonnull Location l, @Nonnull SlimefunBlockData data
default boolean willExplode(@Nonnull Location l, @Nonnull Config data) {
return false;
}
-
-}
\ No newline at end of file
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ExternallyInteractable.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ExternallyInteractable.java
index 8204409886..fe4b0f7181 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ExternallyInteractable.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ExternallyInteractable.java
@@ -2,9 +2,8 @@
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.core.attributes.interactions.InteractionResult;
-import org.bukkit.Location;
-
import javax.annotation.Nonnull;
+import org.bukkit.Location;
/**
* Implement this interface for any {@link SlimefunItem} to provide methods for
@@ -26,5 +25,4 @@ public interface ExternallyInteractable {
*/
@Nonnull
InteractionResult onInteract(@Nonnull Location location);
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/HologramOwner.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/HologramOwner.java
index b14e32c35c..71cbe53a67 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/HologramOwner.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/HologramOwner.java
@@ -1,21 +1,19 @@
package io.github.thebusybiscuit.slimefun4.core.attributes;
-import javax.annotation.Nonnull;
-
-import org.bukkit.Location;
-import org.bukkit.block.Block;
-import org.bukkit.util.Vector;
-
import io.github.bakedlibs.dough.common.ChatColors;
import io.github.thebusybiscuit.slimefun4.core.services.holograms.HologramsService;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.HologramProjector;
+import javax.annotation.Nonnull;
+import org.bukkit.Location;
+import org.bukkit.block.Block;
+import org.bukkit.util.Vector;
/**
* This {@link ItemAttribute} manages holograms.
- *
+ *
* @author TheBusyBiscuit
- *
+ *
* @see HologramProjector
* @see HologramsService
*
@@ -24,10 +22,10 @@ public interface HologramOwner extends ItemAttribute {
/**
* This will update the hologram text for the given {@link Block}.
- *
+ *
* @param b
* The {@link Block} to which the hologram belongs
- *
+ *
* @param text
* The nametag for the hologram
*/
@@ -38,7 +36,7 @@ default void updateHologram(@Nonnull Block b, @Nonnull String text) {
/**
* This will remove the hologram for the given {@link Block}.
- *
+ *
* @param b
* The {@link Block} to which the hologram blocks
*/
@@ -51,15 +49,14 @@ default void removeHologram(@Nonnull Block b) {
* This returns the offset of the hologram as a {@link Vector}.
* This offset is applied to {@link Block#getLocation()} when spawning
* the hologram.
- *
+ *
* @param block
* The {@link Block} which serves as the origin point
- *
+ *
* @return The hologram offset
*/
@Nonnull
default Vector getHologramOffset(@Nonnull Block block) {
return Slimefun.getHologramsService().getDefaultOffset();
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ItemAttribute.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ItemAttribute.java
index 44236086ba..cc2b2bcad8 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ItemAttribute.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ItemAttribute.java
@@ -1,18 +1,17 @@
package io.github.thebusybiscuit.slimefun4.core.attributes;
-import javax.annotation.Nonnull;
-
import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
+import javax.annotation.Nonnull;
/**
* An empty interface that only serves the purpose of bundling together all
* interfaces of that kind.
- *
+ *
* An {@link ItemAttribute} must be attached to a {@link SlimefunItem}.
- *
+ *
* @author TheBusyBiscuit
- *
+ *
* @see SlimefunItem
* @see ItemHandler
*
@@ -26,5 +25,4 @@ public interface ItemAttribute {
*/
@Nonnull
String getId();
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineProcessHolder.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineProcessHolder.java
index 8c0ecfe111..677a68f65b 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineProcessHolder.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineProcessHolder.java
@@ -1,10 +1,9 @@
package io.github.thebusybiscuit.slimefun4.core.attributes;
-import javax.annotation.Nonnull;
-
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.core.machines.MachineOperation;
import io.github.thebusybiscuit.slimefun4.core.machines.MachineProcessor;
+import javax.annotation.Nonnull;
/**
* This {@link ItemAttribute} marks a {@link SlimefunItem} as a {@link MachineProcessHolder}.
@@ -25,5 +24,4 @@ public interface MachineProcessHolder extends ItemAt
*/
@Nonnull
MachineProcessor getMachineProcessor();
-
-}
\ No newline at end of file
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineTier.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineTier.java
index 212e1633b6..834e848bd2 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineTier.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineTier.java
@@ -3,7 +3,6 @@
import javax.annotation.Nonnull;
public enum MachineTier {
-
BASIC("&e基础"),
AVERAGE("&6普通"),
MEDIUM("&a中型"),
@@ -21,5 +20,4 @@ public enum MachineTier {
public String toString() {
return prefix;
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineType.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineType.java
index 68ff057ef4..99e729e4d7 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineType.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineType.java
@@ -3,7 +3,6 @@
import javax.annotation.Nonnull;
public enum MachineType {
-
CAPACITOR("电容"),
GENERATOR("发电机"),
MACHINE("机器");
@@ -18,5 +17,4 @@ public enum MachineType {
public String toString() {
return suffix;
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotConfigurable.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotConfigurable.java
index 2cea1d2f8d..3fb990ce48 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotConfigurable.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotConfigurable.java
@@ -8,6 +8,4 @@
*
* @author TheBusyBiscuit
*/
-public interface NotConfigurable extends ItemAttribute {
-
-}
\ No newline at end of file
+public interface NotConfigurable extends ItemAttribute {}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotHopperable.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotHopperable.java
index 00d23a2a5e..1c46aa8455 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotHopperable.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotHopperable.java
@@ -8,6 +8,4 @@
*
* @author CURVX
*/
-public interface NotHopperable extends ItemAttribute {
-
-}
\ No newline at end of file
+public interface NotHopperable extends ItemAttribute {}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotPlaceable.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotPlaceable.java
index 464e91b911..26312fce88 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotPlaceable.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotPlaceable.java
@@ -1,21 +1,18 @@
package io.github.thebusybiscuit.slimefun4.core.attributes;
+import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import org.bukkit.block.Block;
import org.bukkit.event.block.BlockPlaceEvent;
-import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
-
/**
* Implement this interface for any {@link SlimefunItem} to prevent
* that {@link SlimefunItem} from being placed.
- *
+ *
* Important: This will not cancel any {@link BlockPlaceEvent}.
* It will simply prevent Slimefun from ever registering this {@link SlimefunItem}
* as a placed {@link Block}.
- *
+ *
* @author TheBusyBiscuit
*
*/
-public interface NotPlaceable extends ItemAttribute {
-
-}
+public interface NotPlaceable extends ItemAttribute {}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/PiglinBarterDrop.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/PiglinBarterDrop.java
index cda9536f8b..ba968bd38b 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/PiglinBarterDrop.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/PiglinBarterDrop.java
@@ -1,21 +1,20 @@
package io.github.thebusybiscuit.slimefun4.core.attributes;
-import org.bukkit.entity.Piglin;
-import org.bukkit.event.entity.EntityDropItemEvent;
-
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.entity.PiglinListener;
+import org.bukkit.entity.Piglin;
+import org.bukkit.event.entity.EntityDropItemEvent;
/**
* This interface, when attached to a {@link SlimefunItem}, provides a variable (0-100%) chance for
* a {@link SlimefunItem} to be dropped by a {@link Piglin} on {@link EntityDropItemEvent}.
- *
+ *
* @author dNiym
*
* @see PiglinListener
* @see RandomMobDrop
- *
+ *
*/
public interface PiglinBarterDrop extends ItemAttribute {
@@ -27,9 +26,8 @@ public interface PiglinBarterDrop extends ItemAttribute {
* It is recommended that this chance is kept reasonably low to feel like
* a vanilla drop as a 100% chance will completely override all {@link Piglin}
* barter drops. (NOTE: this feature only exists in 1.16+)
- *
+ *
* @return The integer chance (1-99%) this {@link SlimefunItem} has to drop.
*/
int getBarteringLootChance();
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Placeable.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Placeable.java
index 28130d102e..7edaa74270 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Placeable.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Placeable.java
@@ -1,20 +1,17 @@
package io.github.thebusybiscuit.slimefun4.core.attributes;
+import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import java.util.Collection;
-
import javax.annotation.Nonnull;
-
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
-import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
-
/**
* DO NOT IMPLEMENT THIS INTERFACE
* This is implemented by every {@link SlimefunItem} by default.
* Might be changed in the future.
- *
+ *
* @author TheBusyBiscuit
*
*/
@@ -31,14 +28,13 @@ public interface Placeable {
* If true is returned then it will be treated as a vanilla {@link Block}.
* If false is returned then Slimefun will treat it as a {@link Block} that is
* the placed down version of a {@link SlimefunItem}.
- *
+ *
* It returns false by default.
* This was previously represented by the HandledBlock class.
- *
+ *
* @return Whether to use the vanilla block breaking behaviour
*/
default boolean useVanillaBlockBreaking() {
return false;
}
-
}
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 21f962e45a..68f38bf5c3 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
@@ -26,5 +26,4 @@ public enum ProtectionType {
* This damage type represents damage caused by flying into a wall with an elytra
*/
FLYING_INTO_WALL;
-
-}
\ No newline at end of file
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ProtectiveArmor.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ProtectiveArmor.java
index 11aebe179a..2e867ad3eb 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ProtectiveArmor.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ProtectiveArmor.java
@@ -2,11 +2,10 @@
import io.github.thebusybiscuit.slimefun4.implementation.items.armor.HazmatArmorPiece;
import io.github.thebusybiscuit.slimefun4.implementation.items.armor.SlimefunArmorPiece;
-import org.bukkit.NamespacedKey;
-import org.bukkit.entity.Player;
-
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
+import org.bukkit.NamespacedKey;
+import org.bukkit.entity.Player;
/**
* Implement this interface to a {@link SlimefunArmorPiece} to protect
@@ -45,6 +44,5 @@ public interface ProtectiveArmor extends ItemAttribute {
*
* @return The set {@link NamespacedKey}, null
if none is found.
*/
- @Nullable
- NamespacedKey getArmorSetId();
-}
\ No newline at end of file
+ @Nullable NamespacedKey getArmorSetId();
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/RadiationSymptom.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/RadiationSymptom.java
index 2c703de40b..b8e1c0d6fd 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/RadiationSymptom.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/RadiationSymptom.java
@@ -1,16 +1,13 @@
package io.github.thebusybiscuit.slimefun4.core.attributes;
-import javax.annotation.Nonnull;
-
import com.google.common.base.Preconditions;
-
+import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
+import io.github.thebusybiscuit.slimefun4.utils.RadiationUtils;
+import javax.annotation.Nonnull;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
-import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
-import io.github.thebusybiscuit.slimefun4.utils.RadiationUtils;
-
/**
* An enum of potential radiation symptoms.
* A symptom will be applied when the minExposure
@@ -24,7 +21,6 @@
* @see RadiationUtils
*/
public enum RadiationSymptom {
-
SLOW(10, PotionEffectType.SLOW, 3),
WITHER_LOW(25, PotionEffectType.WITHER, 0),
BLINDNESS(50, PotionEffectType.BLINDNESS, 4),
@@ -40,7 +36,8 @@ public enum RadiationSymptom {
Preconditions.checkArgument(level >= 0, "The status effect level must be non-negative.");
this.minExposure = minExposure;
- this.potionEffect = new PotionEffect(type, Slimefun.getCfg().getOrSetDefault("options.radiation-update-interval", 1) * 20 + 20, level);
+ this.potionEffect = new PotionEffect(
+ type, Slimefun.getCfg().getOrSetDefault("options.radiation-update-interval", 1) * 20 + 20, level);
}
/**
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Radioactive.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Radioactive.java
index 22b09378d0..7f01d727ef 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Radioactive.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Radioactive.java
@@ -1,16 +1,15 @@
package io.github.thebusybiscuit.slimefun4.core.attributes;
-import javax.annotation.Nonnull;
-
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
+import javax.annotation.Nonnull;
/**
* This Interface, when attached to a class that inherits from {@link SlimefunItem}, marks
* the Item as radioactive.
* Carrying such an item will give the wearer the radiation effect.
- *
+ *
* You can specify a level of {@link Radioactivity} for the severity of the effect.
- *
+ *
* @author TheBusyBiscuit
*
*/
@@ -19,10 +18,9 @@ public interface Radioactive extends ItemAttribute {
/**
* This method returns the level of {@link Radioactivity} for this {@link Radioactive} item.
* Higher levels cause more severe radiation effects.
- *
+ *
* @return The level of {@link Radioactivity} of this item.
*/
@Nonnull
Radioactivity getRadioactivity();
-
}
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 aec100ad30..9ce090bb8c 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
@@ -1,19 +1,17 @@
package io.github.thebusybiscuit.slimefun4.core.attributes;
+import io.github.thebusybiscuit.slimefun4.implementation.tasks.armor.RadiationTask;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
-
-import io.github.thebusybiscuit.slimefun4.implementation.tasks.armor.RadiationTask;
-
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
/**
* This enum holds all available levels of {@link Radioactivity}.
* The higher the level the more severe the effect of radiation will be.
- *
+ *
* @author TheBusyBiscuit
- *
+ *
* @see Radioactive
*
*/
@@ -79,13 +77,12 @@ public int getExposureModifier() {
/**
* This method returns the level for the radiation effect to use in conjunction
* with this level of {@link Radioactive}.
- *
+ *
* It is basically the index of this enum constant.
- *
+ *
* @return The level of radiation associated with this constant.
*/
public int getRadiationLevel() {
return ordinal() + 1;
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/RandomMobDrop.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/RandomMobDrop.java
index a0e51fe32d..97e9dfb69e 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/RandomMobDrop.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/RandomMobDrop.java
@@ -1,25 +1,24 @@
package io.github.thebusybiscuit.slimefun4.core.attributes;
-import org.bukkit.entity.EntityType;
-import org.bukkit.entity.Player;
-import org.bukkit.event.entity.EntityDeathEvent;
-
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.implementation.items.misc.BasicCircuitBoard;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.entity.MobDropListener;
+import org.bukkit.entity.EntityType;
+import org.bukkit.entity.Player;
+import org.bukkit.event.entity.EntityDeathEvent;
/**
* This interface, when attached to a {@link SlimefunItem}, provides an easy method for adding
* a % chance to drop for an {@link SlimefunItem} on {@link EntityDeathEvent}, this chance is 0-100
* and used in conjunction with the {@link RecipeType#MOB_DROP}.
- *
+ *
* @author dNiym
*
* @see BasicCircuitBoard
* @see MobDropListener
* @see PiglinBarterDrop
- *
+ *
*/
public interface RandomMobDrop extends ItemAttribute {
@@ -27,9 +26,8 @@ public interface RandomMobDrop extends ItemAttribute {
* Implement this method to make the object have a variable chance of being
* added to the dropList when {@link EntityType} specified in
* the {@link RecipeType#MOB_DROP} is killed by the {@link Player}.
- *
+ *
* @return The integer chance (0-100%) {@link SlimefunItem} has to drop.
*/
int getMobDropChance();
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Rechargeable.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Rechargeable.java
index 52081d5dfd..fea9a18beb 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Rechargeable.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Rechargeable.java
@@ -1,16 +1,15 @@
package io.github.thebusybiscuit.slimefun4.core.attributes;
-import org.apache.commons.lang.Validate;
-import org.bukkit.Material;
-import org.bukkit.inventory.ItemStack;
-import org.bukkit.inventory.meta.ItemMeta;
-
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNet;
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets.Jetpack;
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets.MultiTool;
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.ChargingBench;
import io.github.thebusybiscuit.slimefun4.utils.ChargeUtils;
+import org.apache.commons.lang.Validate;
+import org.bukkit.Material;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.ItemMeta;
/**
* A {@link Rechargeable} {@link SlimefunItem} can hold energy and is able to
@@ -146,5 +145,4 @@ default boolean removeItemCharge(ItemStack item, float charge) {
item.setItemMeta(meta);
return true;
}
-
-}
\ No newline at end of file
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/RecipeDisplayItem.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/RecipeDisplayItem.java
index c85cce7f3f..f18b0c3fa3 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/RecipeDisplayItem.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/RecipeDisplayItem.java
@@ -1,30 +1,26 @@
package io.github.thebusybiscuit.slimefun4.core.attributes;
-import java.util.List;
-
-import javax.annotation.Nonnull;
-
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.ItemStack;
-
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOMiner;
import io.github.thebusybiscuit.slimefun4.implementation.items.tools.GoldPan;
-
+import java.util.List;
+import javax.annotation.Nonnull;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
/**
* This interface, when attache to a {@link SlimefunItem} class will make additional items
* appear in the {@link SlimefunGuide}.
* These additional items can be used represent recipes or resources that are associated
* with this {@link SlimefunItem}.
- *
+ *
* You can find a few examples below.
- *
+ *
* @author TheBusyBiscuit
- *
+ *
* @see GoldPan
* @see GEOMiner
* @see AGenerator
@@ -37,7 +33,7 @@ public interface RecipeDisplayItem extends ItemAttribute {
* Note that these items will be filled in from top to bottom first.
* So if you want it to express a recipe, add your input {@link ItemStack}
* and then your output {@link ItemStack}.
- *
+ *
* @return The recipes to display in the {@link SlimefunGuide}
*/
@Nonnull
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Soulbound.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Soulbound.java
index a1534f5aa4..b4a112656c 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Soulbound.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Soulbound.java
@@ -11,6 +11,4 @@
* @author TheBusyBiscuit
* @see SoulboundItem
*/
-public interface Soulbound extends ItemAttribute {
-
-}
+public interface Soulbound extends ItemAttribute {}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/WitherProof.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/WitherProof.java
index 712f0df3ea..47f90f1754 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/WitherProof.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/WitherProof.java
@@ -1,20 +1,18 @@
package io.github.thebusybiscuit.slimefun4.core.attributes;
+import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
+import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.WitherProofBlock;
import javax.annotation.Nonnull;
-
import org.bukkit.block.Block;
import org.bukkit.entity.Wither;
-import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
-import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.WitherProofBlock;
-
/**
* This Interface, when attached to a class that inherits from {@link SlimefunItem}, marks
* the Item as "Wither-Proof".
* Wither-Proof blocks cannot be destroyed by a {@link Wither}.
- *
+ *
* @author TheBusyBiscuit
- *
+ *
* @see WitherProofBlock
*
*/
@@ -23,12 +21,11 @@ public interface WitherProof extends ItemAttribute {
/**
* This method is called when a {@link Wither} tried to attack the given {@link Block}.
* You can use this method to play particles or even damage the {@link Wither}.
- *
+ *
* @param block
* The {@link Block} which was attacked.
* @param wither
* The {@link Wither} who attacked.
*/
void onAttack(@Nonnull Block block, @Nonnull Wither wither);
-
}
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 d0b36ae606..c23255905b 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,7 +1,6 @@
package io.github.thebusybiscuit.slimefun4.core.attributes.interactions;
import io.github.thebusybiscuit.slimefun4.core.attributes.ExternallyInteractable;
-
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/interactions/ItemInteractionResult.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/interactions/ItemInteractionResult.java
index 3d93ffaf01..f2832ee6c1 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/interactions/ItemInteractionResult.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/interactions/ItemInteractionResult.java
@@ -1,12 +1,11 @@
package io.github.thebusybiscuit.slimefun4.core.attributes.interactions;
import io.github.thebusybiscuit.slimefun4.core.attributes.ExternallyInteractable;
-import org.bukkit.inventory.ItemStack;
-
-import javax.annotation.Nonnull;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
+import javax.annotation.Nonnull;
+import org.bukkit.inventory.ItemStack;
/**
* This class represents the result of an interaction on an {@link ExternallyInteractable} item.
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/interactions/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/interactions/package-info.java
index c8d0bf92b1..8155ee3eb6 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/interactions/package-info.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/interactions/package-info.java
@@ -2,4 +2,4 @@
* This package contains the various possible {@link io.github.thebusybiscuit.slimefun4.core.attributes.interactions.InteractionResult}s
* that can be returned by an {@link io.github.thebusybiscuit.slimefun4.core.attributes.ExternallyInteractable} object.
*/
-package io.github.thebusybiscuit.slimefun4.core.attributes.interactions;
\ No newline at end of file
+package io.github.thebusybiscuit.slimefun4.core.attributes.interactions;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/package-info.java
index 9a2c8c5699..cd73218db6 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/package-info.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/package-info.java
@@ -2,4 +2,4 @@
* This package contains all variations of {@link io.github.thebusybiscuit.slimefun4.core.attributes.ItemAttribute} that
* can be assigned to a {@link io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem}
*/
-package io.github.thebusybiscuit.slimefun4.core.attributes;
\ No newline at end of file
+package io.github.thebusybiscuit.slimefun4.core.attributes;
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 a0747bc5fc..eb03665794 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
@@ -1,13 +1,14 @@
package io.github.thebusybiscuit.slimefun4.core.commands;
+import io.github.bakedlibs.dough.common.ChatColors;
+import io.github.thebusybiscuit.slimefun4.core.commands.subcommands.SlimefunSubCommands;
+import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
-
import javax.annotation.Nonnull;
-
import org.apache.commons.lang.Validate;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@@ -16,14 +17,11 @@
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
-import io.github.bakedlibs.dough.common.ChatColors;
-import io.github.thebusybiscuit.slimefun4.core.commands.subcommands.SlimefunSubCommands;
-import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
-
/**
* This {@link CommandExecutor} holds the functionality of our {@code /slimefun} command.
*
* @author TheBusyBiscuit
+ *
*/
public class SlimefunCommand implements CommandExecutor, Listener {
@@ -116,10 +114,7 @@ public void onCommand(PlayerCommandPreprocessEvent e) {
*/
public @Nonnull List getSubCommandNames() {
// @formatter:off
- return commands.stream()
- .map(SubCommand::getName)
- .collect(Collectors.toList());
+ return commands.stream().map(SubCommand::getName).collect(Collectors.toList());
// @formatter:on
}
-
}
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 80b2712891..4a3f45490a 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
@@ -1,24 +1,20 @@
package io.github.thebusybiscuit.slimefun4.core.commands;
+import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
+import io.github.thebusybiscuit.slimefun4.api.researches.Research;
+import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
-import java.util.stream.Collectors;
-
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
-import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
-import io.github.thebusybiscuit.slimefun4.api.researches.Research;
-import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
-
class SlimefunTabCompleter implements TabCompleter {
private static final int MAX_SUGGESTIONS = 80;
@@ -29,20 +25,10 @@ public SlimefunTabCompleter(@Nonnull SlimefunCommand command) {
this.command = command;
}
- @Nullable
- @Override
+ @Nullable @Override
public List onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
if (args.length == 1) {
return createReturnList(command.getSubCommandNames(), args[0]);
- } else if (args.length == 2) {
- if (args[0].equalsIgnoreCase("banitem")) {
- return createReturnList(getSlimefunItems(), args[1]);
- }
- else if (args[0].equalsIgnoreCase("unbanitem")) {
- List list = Slimefun.getRegistry().getDisabledSlimefunItems().stream().map(sfItem -> sfItem.getId()).collect(Collectors.toList());
- return createReturnList(list, args[1]);
- }
- return null;
} else if (args.length == 3) {
if (args[0].equalsIgnoreCase("give")) {
return createReturnList(getSlimefunItems(), args[2]);
@@ -81,7 +67,7 @@ else if (args[0].equalsIgnoreCase("unbanitem")) {
*/
@Nonnull
private List createReturnList(@Nonnull List list, @Nonnull String string) {
- if (string.isEmpty()) {
+ if (string.length() == 0) {
return list;
}
@@ -114,5 +100,4 @@ private List getSlimefunItems() {
return list;
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SubCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SubCommand.java
index 4b5717a7a6..207d7c8772 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SubCommand.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SubCommand.java
@@ -1,24 +1,21 @@
package io.github.thebusybiscuit.slimefun4.core.commands;
+import io.github.thebusybiscuit.slimefun4.core.services.localization.Language;
+import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import java.util.Map;
-
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
-
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.defaults.HelpCommand;
import org.bukkit.entity.Player;
-import io.github.thebusybiscuit.slimefun4.core.services.localization.Language;
-import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
-
/**
* This class represents a {@link SubCommand}, it is a {@link Command} that starts with
* {@code /sf ...} and is followed by the name of this {@link SubCommand}.
- *
+ *
* @author TheBusyBiscuit
- *
+ *
* @see SlimefunCommand
*
*/
@@ -42,7 +39,7 @@ protected SubCommand(Slimefun plugin, SlimefunCommand cmd, String name, boolean
/**
* This returns the name of this {@link SubCommand}, the name is equivalent to the
* first argument given to the actual command.
- *
+ *
* @return The name of this {@link SubCommand}
*/
@Nonnull
@@ -52,7 +49,7 @@ public final String getName() {
/**
* This method returns whether this {@link SubCommand} is hidden from the {@link HelpCommand}.
- *
+ *
* @return Whether to hide this {@link SubCommand}
*/
public final boolean isHidden() {
@@ -74,10 +71,10 @@ protected String getDescription() {
* This returns a description for this {@link SubCommand}.
* If the given {@link CommandSender} is a {@link Player}, the description
* will be localized with the currently selected {@link Language} of that {@link Player}.
- *
+ *
* @param sender
* The {@link CommandSender} who requested the description
- *
+ *
* @return A possibly localized description of this {@link SubCommand}
*/
public @Nonnull String getDescription(@Nonnull CommandSender sender) {
@@ -87,5 +84,4 @@ protected String getDescription() {
return Slimefun.getLocalization().getMessage(getDescription());
}
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/package-info.java
index 13a08a12ac..54639a4aaf 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/package-info.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/package-info.java
@@ -1,4 +1,4 @@
/**
* This package contains everything related to Slimefun's ingame command.
*/
-package io.github.thebusybiscuit.slimefun4.core.commands;
\ No newline at end of file
+package io.github.thebusybiscuit.slimefun4.core.commands;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/BackpackCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/BackpackCommand.java
index ae222fe81c..25ee7949a4 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/BackpackCommand.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/BackpackCommand.java
@@ -47,13 +47,19 @@ public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) {
if (sender instanceof Player player) {
if (sender.hasPermission("slimefun.command.backpack")) {
if (args.length < 1) {
- Slimefun.getLocalization().sendMessage(sender, "messages.usage", true, msg -> msg.replace("%usage%", "/sf backpack (玩家名)"));
+ Slimefun.getLocalization()
+ .sendMessage(
+ sender,
+ "messages.usage",
+ true,
+ msg -> msg.replace("%usage%", "/sf backpack (玩家名)"));
return;
}
if (args.length == 2) {
if (sender.hasPermission("slimefun.command.backpack.other")) {
- Slimefun.getDatabaseManager().getProfileDataController()
+ Slimefun.getDatabaseManager()
+ .getProfileDataController()
.getPlayerUuidAsync(args[1], new IAsyncReadCallback<>() {
@Override
public void onResult(UUID result) {
@@ -65,7 +71,8 @@ public void onResult(UUID result) {
@Override
public void onResultNotFound() {
- Slimefun.getLocalization().sendMessage(player, "commands.backpack.backpack-does-not-exist");
+ Slimefun.getLocalization()
+ .sendMessage(player, "commands.backpack.backpack-does-not-exist");
}
});
} else {
@@ -88,7 +95,8 @@ public void onResultNotFound() {
private void openBackpackMenu(@Nonnull OfflinePlayer owner, @Nonnull Player p) {
Validate.notNull(p, "The player cannot be null!");
- Slimefun.getDatabaseManager().getProfileDataController()
+ Slimefun.getDatabaseManager()
+ .getProfileDataController()
.getBackpacksAsync(owner.getUniqueId().toString(), new IAsyncReadCallback<>() {
@Override
public boolean runOnMainThread() {
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 4a1fdaeb96..7c2c1160bf 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
@@ -4,14 +4,13 @@
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
+import javax.annotation.ParametersAreNonnullByDefault;
import net.guizhanss.slimefun4.utils.ChatUtils;
import org.bukkit.FluidCollisionMode;
import org.bukkit.block.Block;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-import javax.annotation.ParametersAreNonnullByDefault;
-
/**
* 该指令可直接对 Slimefun 方块数据进行设置。
*
@@ -41,9 +40,12 @@ public void onExecute(CommandSender sender, String[] args) {
}
if (args.length < 3) {
- Slimefun.getLocalization().sendMessage(sender, "messages.usage", true,
- msg -> msg.replace("%usage%", "/sf blockdata get/set/remove [value]")
- );
+ Slimefun.getLocalization()
+ .sendMessage(
+ sender,
+ "messages.usage",
+ true,
+ msg -> msg.replace("%usage%", "/sf blockdata get/set/remove [value]"));
return;
}
@@ -60,15 +62,17 @@ public void onExecute(CommandSender sender, String[] args) {
switch (args[1]) {
case "get" -> {
String value = blockData.getData(key);
- ChatUtils.sendMessage(player, "&a该方块 &b%key% &a的值为: &e%value%",
- msg -> msg.replace("%key%", key).replace("%value%", value)
- );
+ ChatUtils.sendMessage(player, "&a该方块 &b%key% &a的值为: &e%value%", msg -> msg.replace("%key%", key)
+ .replace("%value%", value));
}
case "set" -> {
if (args.length < 4) {
- Slimefun.getLocalization().sendMessage(sender, "messages.usage", true,
- msg -> msg.replace("%usage%", "/sf blockdata set ")
- );
+ Slimefun.getLocalization()
+ .sendMessage(
+ sender,
+ "messages.usage",
+ true,
+ msg -> msg.replace("%usage%", "/sf blockdata set "));
return;
}
@@ -80,9 +84,8 @@ public void onExecute(CommandSender sender, String[] args) {
String value = args[2];
blockData.setData(key, value);
- ChatUtils.sendMessage(player, "&a已设置该方块 &b%key% &a的值为: &e%value%",
- msg -> msg.replace("%key%", key).replace("%value%", value)
- );
+ ChatUtils.sendMessage(player, "&a已设置该方块 &b%key% &a的值为: &e%value%", msg -> msg.replace("%key%", key)
+ .replace("%value%", value));
}
case "remove" -> {
if (key.equalsIgnoreCase("id")) {
@@ -91,16 +94,16 @@ public void onExecute(CommandSender sender, String[] args) {
}
blockData.removeData(key);
- ChatUtils.sendMessage(player, "&a已移除该方块 &b%key% &a的值",
- msg -> msg.replace("%key%", 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]")
- );
+ 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/ChargeCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ChargeCommand.java
index 119091e1e6..85ed9706ce 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ChargeCommand.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ChargeCommand.java
@@ -1,16 +1,14 @@
package io.github.thebusybiscuit.slimefun4.core.commands.subcommands;
-import javax.annotation.ParametersAreNonnullByDefault;
-
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.ItemStack;
-
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable;
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
+import javax.annotation.ParametersAreNonnullByDefault;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
/**
* {@link ChargeCommand} adds an in game command which charges any {@link Rechargeable}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/CheatCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/CheatCommand.java
index 973ed1ee39..9c73d8ea58 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/CheatCommand.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/CheatCommand.java
@@ -1,14 +1,12 @@
package io.github.thebusybiscuit.slimefun4.core.commands.subcommands;
-import javax.annotation.ParametersAreNonnullByDefault;
-
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
+import javax.annotation.ParametersAreNonnullByDefault;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
class CheatCommand extends SubCommand {
@@ -29,5 +27,4 @@ public void onExecute(CommandSender sender, String[] args) {
Slimefun.getLocalization().sendMessage(sender, "messages.only-players", true);
}
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/DebugCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/DebugCommand.java
index bbb8bb0ea1..0c968f873d 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/DebugCommand.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/DebugCommand.java
@@ -1,58 +1,60 @@
-package io.github.thebusybiscuit.slimefun4.core.commands.subcommands;
-
-import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
-import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
-import io.github.thebusybiscuit.slimefun4.core.debug.Debug;
-import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
-import org.bukkit.command.CommandSender;
-
-import javax.annotation.Nonnull;
-
-/**
- * The debug command will allow server owners to get information for us developers.
- * We can put debug messages in the code and they can trigger it for us to see what exactly is going on.
- *
- * @author WalshyDev
- */
-public class DebugCommand extends SubCommand {
-
- protected DebugCommand(@Nonnull Slimefun plugin, @Nonnull SlimefunCommand cmd) {
- super(plugin, cmd, "debug", true);
- }
-
- @Override
- protected @Nonnull String getDescription() {
- return "commands.debug.description";
- }
-
- @Override
- public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) {
- if (!sender.hasPermission("slimefun.command.debug")) {
- Slimefun.getLocalization().sendMessage(sender, "messages.no-permission", true);
- return;
- }
-
- if (args.length == 1) {
- String currentCase = String.join(", ", Debug.getTestCase());
- if (!currentCase.isEmpty()) {
- Slimefun.getLocalization().sendMessage(sender, "commands.debug.current", true, msg -> msg.replace("%test_case%", currentCase));
- } else {
- Slimefun.getLocalization().sendMessage(sender, "commands.debug.none-running", true);
- }
- return;
- }
-
- String test = args[1];
-
- switch (test.toLowerCase()) {
- case "disable", "off" -> {
- Debug.disableTestCase();
- Slimefun.getLocalization().sendMessage(sender, "commands.debug.disabled");
- }
- default -> {
- Debug.addTestCase(test);
- Slimefun.getLocalization().sendMessage(sender, "commands.debug.running", msg -> msg.replace("%test%", test));
- }
- }
- }
-}
+package io.github.thebusybiscuit.slimefun4.core.commands.subcommands;
+
+import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
+import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
+import io.github.thebusybiscuit.slimefun4.core.debug.Debug;
+import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
+import javax.annotation.Nonnull;
+import org.bukkit.command.CommandSender;
+
+/**
+ * The debug command will allow server owners to get information for us developers.
+ * We can put debug messages in the code and they can trigger it for us to see what exactly is going on.
+ *
+ * @author WalshyDev
+ */
+public class DebugCommand extends SubCommand {
+
+ protected DebugCommand(@Nonnull Slimefun plugin, @Nonnull SlimefunCommand cmd) {
+ super(plugin, cmd, "debug", true);
+ }
+
+ @Override
+ protected @Nonnull String getDescription() {
+ return "commands.debug.description";
+ }
+
+ @Override
+ public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) {
+ if (!sender.hasPermission("slimefun.command.debug")) {
+ Slimefun.getLocalization().sendMessage(sender, "messages.no-permission", true);
+ return;
+ }
+
+ if (args.length == 1) {
+ String currentCase = String.join(", ", Debug.getTestCase());
+ if (!currentCase.isEmpty()) {
+ Slimefun.getLocalization()
+ .sendMessage(
+ sender, "commands.debug.current", true, msg -> msg.replace("%test_case%", currentCase));
+ } else {
+ Slimefun.getLocalization().sendMessage(sender, "commands.debug.none-running", true);
+ }
+ return;
+ }
+
+ String test = args[1];
+
+ switch (test.toLowerCase()) {
+ case "disable", "off" -> {
+ Debug.disableTestCase();
+ Slimefun.getLocalization().sendMessage(sender, "commands.debug.disabled");
+ }
+ default -> {
+ Debug.addTestCase(test);
+ Slimefun.getLocalization()
+ .sendMessage(sender, "commands.debug.running", msg -> msg.replace("%test%", test));
+ }
+ }
+ }
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/DebugFishCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/DebugFishCommand.java
index cc79b113e6..ff47f612ab 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/DebugFishCommand.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/DebugFishCommand.java
@@ -1,14 +1,12 @@
package io.github.thebusybiscuit.slimefun4.core.commands.subcommands;
-import javax.annotation.ParametersAreNonnullByDefault;
-
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
+import javax.annotation.ParametersAreNonnullByDefault;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
class DebugFishCommand extends SubCommand {
@@ -25,5 +23,4 @@ public void onExecute(CommandSender sender, String[] args) {
Slimefun.getLocalization().sendMessage(sender, "messages.no-permission", true);
}
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GiveCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GiveCommand.java
index 5d56959e84..5623ab1e5f 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GiveCommand.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GiveCommand.java
@@ -1,15 +1,5 @@
package io.github.thebusybiscuit.slimefun4.core.commands.subcommands;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Optional;
-
-import javax.annotation.ParametersAreNonnullByDefault;
-
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.ItemStack;
-
import io.github.bakedlibs.dough.common.CommonPatterns;
import io.github.bakedlibs.dough.common.PlayerList;
import io.github.bakedlibs.dough.items.CustomItemStack;
@@ -18,6 +8,13 @@
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Optional;
+import javax.annotation.ParametersAreNonnullByDefault;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
class GiveCommand extends SubCommand {
@@ -44,13 +41,28 @@ public void onExecute(CommandSender sender, String[] args) {
if (sfItem != null) {
giveItem(sender, p, sfItem, args);
} else {
- Slimefun.getLocalization().sendMessage(sender, "messages.invalid-item", true, msg -> msg.replace(PLACEHOLDER_ITEM, args[2]));
+ Slimefun.getLocalization()
+ .sendMessage(
+ sender,
+ "messages.invalid-item",
+ true,
+ msg -> msg.replace(PLACEHOLDER_ITEM, args[2]));
}
} else {
- Slimefun.getLocalization().sendMessage(sender, "messages.not-online", true, msg -> msg.replace(PLACEHOLDER_PLAYER, args[1]));
+ Slimefun.getLocalization()
+ .sendMessage(
+ sender,
+ "messages.not-online",
+ true,
+ msg -> msg.replace(PLACEHOLDER_PLAYER, args[1]));
}
} else {
- Slimefun.getLocalization().sendMessage(sender, "messages.usage", true, msg -> msg.replace("%usage%", "/sf give [Amount]"));
+ Slimefun.getLocalization()
+ .sendMessage(
+ sender,
+ "messages.usage",
+ true,
+ msg -> msg.replace("%usage%", "/sf give [Amount]"));
}
} else {
Slimefun.getLocalization().sendMessage(sender, "messages.no-permission", true);
@@ -64,17 +76,28 @@ private void giveItem(CommandSender sender, Player p, SlimefunItem sfItem, Strin
int amount = parseAmount(args);
if (amount > 0) {
- Slimefun.getLocalization().sendMessage(p, "messages.given-item", true, msg -> msg.replace(PLACEHOLDER_ITEM, sfItem.getItemName()).replace(PLACEHOLDER_AMOUNT, String.valueOf(amount)));
- Map excess = p.getInventory().addItem(new CustomItemStack(sfItem.getItem(), amount));
+ Slimefun.getLocalization().sendMessage(p, "messages.given-item", true, msg -> msg.replace(
+ PLACEHOLDER_ITEM, sfItem.getItemName())
+ .replace(PLACEHOLDER_AMOUNT, String.valueOf(amount)));
+ Map excess =
+ p.getInventory().addItem(new CustomItemStack(sfItem.getItem(), amount));
if (Slimefun.getCfg().getBoolean("options.drop-excess-sf-give-items") && !excess.isEmpty()) {
for (ItemStack is : excess.values()) {
p.getWorld().dropItem(p.getLocation(), is);
}
}
- Slimefun.getLocalization().sendMessage(sender, "messages.give-item", true, msg -> msg.replace(PLACEHOLDER_PLAYER, args[1]).replace(PLACEHOLDER_ITEM, sfItem.getItemName()).replace(PLACEHOLDER_AMOUNT, String.valueOf(amount)));
+ Slimefun.getLocalization()
+ .sendMessage(sender, "messages.give-item", true, msg -> msg.replace(PLACEHOLDER_PLAYER, args[1])
+ .replace(PLACEHOLDER_ITEM, sfItem.getItemName())
+ .replace(PLACEHOLDER_AMOUNT, String.valueOf(amount)));
} else {
- Slimefun.getLocalization().sendMessage(sender, "messages.invalid-amount", true, msg -> msg.replace(PLACEHOLDER_AMOUNT, args[3]));
+ Slimefun.getLocalization()
+ .sendMessage(
+ sender,
+ "messages.invalid-amount",
+ true,
+ msg -> msg.replace(PLACEHOLDER_AMOUNT, args[3]));
}
}
}
@@ -92,5 +115,4 @@ private int parseAmount(String[] args) {
return amount;
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GuideCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GuideCommand.java
index 006744d6c7..00900940c6 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GuideCommand.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GuideCommand.java
@@ -1,15 +1,13 @@
package io.github.thebusybiscuit.slimefun4.core.commands.subcommands;
-import javax.annotation.ParametersAreNonnullByDefault;
-
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
+import javax.annotation.ParametersAreNonnullByDefault;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
class GuideCommand extends SubCommand {
@@ -31,5 +29,4 @@ public void onExecute(CommandSender sender, String[] args) {
Slimefun.getLocalization().sendMessage(sender, "messages.only-players", true);
}
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/HelpCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/HelpCommand.java
index b3e411d388..a36c5f2ab1 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/HelpCommand.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/HelpCommand.java
@@ -1,12 +1,10 @@
package io.github.thebusybiscuit.slimefun4.core.commands.subcommands;
-import javax.annotation.ParametersAreNonnullByDefault;
-
-import org.bukkit.command.CommandSender;
-
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
+import javax.annotation.ParametersAreNonnullByDefault;
+import org.bukkit.command.CommandSender;
class HelpCommand extends SubCommand {
@@ -19,5 +17,4 @@ class HelpCommand extends SubCommand {
public void onExecute(CommandSender sender, String[] args) {
cmd.sendHelp(sender);
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/MigrateCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/MigrateCommand.java
index 7216f06ea5..e32b0b521a 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/MigrateCommand.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/MigrateCommand.java
@@ -58,8 +58,12 @@ public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) {
private void sendMigrateStatus(@Nonnull String migrateType, @Nonnull CommandSender sender, MigrateStatus status) {
switch (status) {
- case SUCCESS ->
- Slimefun.getLocalization().sendMessage(sender, "commands.migrate.success", true, msg -> msg.replace("%migrate_type%", migrateType));
+ case SUCCESS -> Slimefun.getLocalization()
+ .sendMessage(
+ sender,
+ "commands.migrate.success",
+ true,
+ msg -> msg.replace("%migrate_type%", migrateType));
case FAILED -> Slimefun.getLocalization().sendMessage(sender, "commands.migrate.failed", true);
case MIGRATING -> Slimefun.getLocalization().sendMessage(sender, "commands.migrate.in-progress", true);
case MIGRATED -> Slimefun.getLocalization().sendMessage(sender, "commands.migrate.already-migrated", true);
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/OpenGuideCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/OpenGuideCommand.java
index 83db842925..7d5efc3317 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/OpenGuideCommand.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/OpenGuideCommand.java
@@ -1,15 +1,13 @@
package io.github.thebusybiscuit.slimefun4.core.commands.subcommands;
-import javax.annotation.ParametersAreNonnullByDefault;
-
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
+import javax.annotation.ParametersAreNonnullByDefault;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
class OpenGuideCommand extends SubCommand {
@@ -31,5 +29,4 @@ public void onExecute(CommandSender sender, String[] args) {
Slimefun.getLocalization().sendMessage(sender, "messages.only-players", true);
}
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ResearchCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ResearchCommand.java
index 3014f44c36..01e837c6b6 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ResearchCommand.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ResearchCommand.java
@@ -54,13 +54,23 @@ public void onExecute(CommandSender sender, String[] args) {
}
});
} else {
- Slimefun.getLocalization().sendMessage(sender, "messages.not-online", true, msg -> msg.replace(PLACEHOLDER_PLAYER, args[1]));
+ Slimefun.getLocalization()
+ .sendMessage(
+ sender,
+ "messages.not-online",
+ true,
+ msg -> msg.replace(PLACEHOLDER_PLAYER, args[1]));
}
} else {
Slimefun.getLocalization().sendMessage(sender, "messages.no-permission", true);
}
} else {
- Slimefun.getLocalization().sendMessage(sender, "messages.usage", true, msg -> msg.replace("%usage%", "/sf research "));
+ Slimefun.getLocalization()
+ .sendMessage(
+ sender,
+ "messages.usage",
+ true,
+ msg -> msg.replace("%usage%", "/sf research "));
}
}
@@ -70,11 +80,14 @@ private void giveResearch(CommandSender sender, Player p, String input) {
if (research.isPresent()) {
research.get().unlock(p, true, player -> {
- UnaryOperator variables = msg -> msg.replace(PLACEHOLDER_PLAYER, player.getName()).replace(PLACEHOLDER_RESEARCH, research.get().getName(player));
+ UnaryOperator variables = msg -> msg.replace(PLACEHOLDER_PLAYER, player.getName())
+ .replace(PLACEHOLDER_RESEARCH, research.get().getName(player));
Slimefun.getLocalization().sendMessage(player, "messages.give-research", true, variables);
});
} else {
- Slimefun.getLocalization().sendMessage(sender, "messages.invalid-research", true, msg -> msg.replace(PLACEHOLDER_RESEARCH, input));
+ Slimefun.getLocalization()
+ .sendMessage(
+ sender, "messages.invalid-research", true, msg -> msg.replace(PLACEHOLDER_RESEARCH, input));
}
}
@@ -82,7 +95,9 @@ private void giveResearch(CommandSender sender, Player p, String input) {
private void researchAll(CommandSender sender, PlayerProfile profile, Player p) {
for (Research res : Slimefun.getRegistry().getResearches()) {
if (!profile.hasUnlocked(res)) {
- Slimefun.getLocalization().sendMessage(sender, "messages.give-research", true, msg -> msg.replace(PLACEHOLDER_PLAYER, p.getName()).replace(PLACEHOLDER_RESEARCH, res.getName(p)));
+ Slimefun.getLocalization().sendMessage(sender, "messages.give-research", true, msg -> msg.replace(
+ PLACEHOLDER_PLAYER, p.getName())
+ .replace(PLACEHOLDER_RESEARCH, res.getName(p)));
}
res.unlock(p, true);
@@ -95,7 +110,8 @@ private void reset(PlayerProfile profile, Player p) {
profile.setResearched(research, false);
}
- Slimefun.getLocalization().sendMessage(p, "commands.research.reset", true, msg -> msg.replace(PLACEHOLDER_PLAYER, p.getName()));
+ Slimefun.getLocalization()
+ .sendMessage(p, "commands.research.reset", true, msg -> msg.replace(PLACEHOLDER_PLAYER, p.getName()));
}
@Nonnull
@@ -112,5 +128,4 @@ private Optional getResearchFromString(@Nonnull String input) {
return Optional.empty();
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SearchCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SearchCommand.java
index 9783518b17..18d70fb894 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SearchCommand.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SearchCommand.java
@@ -1,18 +1,15 @@
package io.github.thebusybiscuit.slimefun4.core.commands.subcommands;
-import java.util.Arrays;
-
-import javax.annotation.ParametersAreNonnullByDefault;
-
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
+import java.util.Arrays;
+import javax.annotation.ParametersAreNonnullByDefault;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
class SearchCommand extends SubCommand {
@@ -27,9 +24,16 @@ public void onExecute(CommandSender sender, String[] args) {
if (sender.hasPermission("slimefun.command.search")) {
if (args.length > 1) {
String query = String.join(" ", Arrays.copyOfRange(args, 1, args.length));
- PlayerProfile.get(player, profile -> SlimefunGuide.openSearch(profile, query, SlimefunGuideMode.SURVIVAL_MODE, true));
+ PlayerProfile.get(
+ player,
+ profile -> SlimefunGuide.openSearch(profile, query, SlimefunGuideMode.SURVIVAL_MODE, true));
} else {
- Slimefun.getLocalization().sendMessage(sender, "messages.usage", true, msg -> msg.replace("%usage%", "/sf search "));
+ Slimefun.getLocalization()
+ .sendMessage(
+ sender,
+ "messages.usage",
+ true,
+ msg -> msg.replace("%usage%", "/sf search "));
}
} else {
Slimefun.getLocalization().sendMessage(sender, "messages.no-permission", true);
@@ -38,5 +42,4 @@ public void onExecute(CommandSender sender, String[] args) {
Slimefun.getLocalization().sendMessage(sender, "messages.only-players", true);
}
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SlimefunSubCommands.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SlimefunSubCommands.java
index b22796c432..c3d6b60e28 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SlimefunSubCommands.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SlimefunSubCommands.java
@@ -13,7 +13,7 @@
* This class holds the implementations of every {@link SubCommand}.
* The implementations themselves are package-private, this class only provides
* a static setup method
- *
+ *
* @author TheBusyBiscuit
*
*/
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/StatsCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/StatsCommand.java
index c5ca79fcbf..0885e7ba98 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/StatsCommand.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/StatsCommand.java
@@ -33,7 +33,8 @@ public void onExecute(CommandSender sender, String[] args) {
if (player.isPresent()) {
PlayerProfile.get(player.get(), profile -> profile.sendStats(sender));
} else {
- Slimefun.getLocalization().sendMessage(sender, "messages.not-online", true, msg -> msg.replace("%player%", args[1]));
+ Slimefun.getLocalization()
+ .sendMessage(sender, "messages.not-online", true, msg -> msg.replace("%player%", args[1]));
}
} else {
Slimefun.getLocalization().sendMessage(sender, "messages.no-permission", true);
@@ -44,5 +45,4 @@ public void onExecute(CommandSender sender, String[] args) {
Slimefun.getLocalization().sendMessage(sender, "messages.only-players", true);
}
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/TeleporterCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/TeleporterCommand.java
index 891ba85059..dc52c4fa32 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/TeleporterCommand.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/TeleporterCommand.java
@@ -1,17 +1,15 @@
package io.github.thebusybiscuit.slimefun4.core.commands.subcommands;
+import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
+import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
+import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import javax.annotation.ParametersAreNonnullByDefault;
-
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.block.BlockFace;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
-import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
-import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
-
class TeleporterCommand extends SubCommand {
@ParametersAreNonnullByDefault
@@ -24,19 +22,35 @@ public void onExecute(CommandSender sender, String[] args) {
if (sender instanceof Player player) {
if (sender.hasPermission("slimefun.command.teleporter")) {
if (args.length == 1) {
- Slimefun.getGPSNetwork().getTeleportationManager().openTeleporterGUI(player, player.getUniqueId(), player.getLocation().getBlock().getRelative(BlockFace.DOWN), 999999999);
+ Slimefun.getGPSNetwork()
+ .getTeleportationManager()
+ .openTeleporterGUI(
+ player,
+ player.getUniqueId(),
+ player.getLocation().getBlock().getRelative(BlockFace.DOWN),
+ 999999999);
} else if (args.length == 2) {
@SuppressWarnings("deprecation")
OfflinePlayer targetPlayer = Bukkit.getOfflinePlayer(args[1]);
if (targetPlayer.getName() != null) {
- Slimefun.getGPSNetwork().getTeleportationManager().openTeleporterGUI(player, targetPlayer.getUniqueId(), player.getLocation().getBlock().getRelative(BlockFace.DOWN), 999999999);
+ Slimefun.getGPSNetwork()
+ .getTeleportationManager()
+ .openTeleporterGUI(
+ player,
+ targetPlayer.getUniqueId(),
+ player.getLocation().getBlock().getRelative(BlockFace.DOWN),
+ 999999999);
} else {
- Slimefun.getLocalization().sendMessage(sender, "messages.unknown-player", msg -> msg.replace("%player%", args[1]));
+ Slimefun.getLocalization()
+ .sendMessage(
+ sender, "messages.unknown-player", msg -> msg.replace("%player%", args[1]));
}
} else {
- Slimefun.getLocalization().sendMessage(sender, "messages.usage", msg -> msg.replace("%usage%", "/sf teleporter [Player]"));
+ Slimefun.getLocalization()
+ .sendMessage(
+ sender, "messages.usage", msg -> msg.replace("%usage%", "/sf teleporter [Player]"));
}
} else {
Slimefun.getLocalization().sendMessage(sender, "messages.no-permission");
@@ -45,5 +59,4 @@ public void onExecute(CommandSender sender, String[] args) {
Slimefun.getLocalization().sendMessage(sender, "messages.only-players");
}
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/TimingsCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/TimingsCommand.java
index 3dfd8a78cc..4e4666024f 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/TimingsCommand.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/TimingsCommand.java
@@ -1,25 +1,22 @@
package io.github.thebusybiscuit.slimefun4.core.commands.subcommands;
+import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
+import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
+import io.github.thebusybiscuit.slimefun4.core.services.profiler.PerformanceInspector;
+import io.github.thebusybiscuit.slimefun4.core.services.profiler.SummaryOrderType;
+import io.github.thebusybiscuit.slimefun4.core.services.profiler.inspectors.ConsolePerformanceInspector;
+import io.github.thebusybiscuit.slimefun4.core.services.profiler.inspectors.PlayerPerformanceInspector;
+import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
-
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
-
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;
-import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
-import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
-import io.github.thebusybiscuit.slimefun4.core.services.profiler.PerformanceInspector;
-import io.github.thebusybiscuit.slimefun4.core.services.profiler.SummaryOrderType;
-import io.github.thebusybiscuit.slimefun4.core.services.profiler.inspectors.ConsolePerformanceInspector;
-import io.github.thebusybiscuit.slimefun4.core.services.profiler.inspectors.PlayerPerformanceInspector;
-import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
-
class TimingsCommand extends SubCommand {
private static final String FLAG_PREFIX = "--";
@@ -77,7 +74,9 @@ private boolean hasInvalidFlags(CommandSender sender, String[] args) {
if (argument.startsWith(FLAG_PREFIX) && !flags.contains(argument.substring(2))) {
hasInvalidFlags = true;
- Slimefun.getLocalization().sendMessage(sender, "commands.timings.unknown-flag", true, msg -> msg.replace("%flag%", argument));
+ Slimefun.getLocalization()
+ .sendMessage(
+ sender, "commands.timings.unknown-flag", true, msg -> msg.replace("%flag%", argument));
}
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/TransformCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/TransformCommand.java
index cd6f050cf3..6237c2f219 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/TransformCommand.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/TransformCommand.java
@@ -4,17 +4,16 @@
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.logging.Level;
import org.bukkit.Material;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.logging.Level;
-
class TransformCommand extends SubCommand {
TransformCommand(Slimefun plugin, SlimefunCommand cmd) {
super(plugin, cmd, "transform", false);
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 d217dd198b..b73c744cae 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
@@ -21,7 +21,7 @@
/**
* This is our class for the /sf versions subcommand.
- *
+ *
* @author TheBusyBiscuit
* @author Walshy
*
@@ -80,12 +80,10 @@ public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) {
addJavaVersion(builder);
// Add notice to warn those smart people
- builder.append("\n由 StarWishsama 汉化").color(ChatColor.WHITE)
- .append(
- "\n请不要将此版本信息截图到 Discord/Github 反馈 Bug" +
- "\n优先到汉化页面反馈" +
- "\n"
- ).color(ChatColor.RED);
+ builder.append("\n由 StarWishsama 汉化")
+ .color(ChatColor.WHITE)
+ .append("\n请不要将此版本信息截图到 Discord/Github 反馈 Bug" + "\n优先到汉化页面反馈" + "\n")
+ .color(ChatColor.RED);
builder.append("\n").event((HoverEvent) null);
addPluginVersions(builder);
@@ -101,17 +99,23 @@ private void addJavaVersion(@Nonnull ComponentBuilder builder) {
if (version < RECOMMENDED_JAVA_VERSION) {
// @formatter:off
- builder.append("Java " + version).color(ChatColor.RED)
- .event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[]{new TextComponent(
- "你使用的 Java 版本已过时!\n!" +
- "推荐你使用 Java " + RECOMMENDED_JAVA_VERSION + " 或更高版本.\n" +
- JAVA_VERSION_NOTICE
- )}))
+ builder.append("Java " + version)
+ .color(ChatColor.RED)
+ .event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[] {
+ new TextComponent("你使用的 Java 版本已过时!\n!"
+ + "推荐你使用 Java "
+ + RECOMMENDED_JAVA_VERSION
+ + " 或更高版本.\n"
+ + JAVA_VERSION_NOTICE)
+ }))
.append("\n")
.event((HoverEvent) null);
// @formatter:on
} else {
- builder.append("Java ").color(ChatColor.GREEN).append(version + "\n").color(ChatColor.DARK_GREEN);
+ builder.append("Java ")
+ .color(ChatColor.GREEN)
+ .append(version + "\n")
+ .color(ChatColor.DARK_GREEN);
}
}
@@ -123,7 +127,10 @@ private void addPluginVersions(@Nonnull ComponentBuilder builder) {
return;
}
- builder.append("安装的附属插件: ").color(ChatColor.GRAY).append("(" + addons.size() + ")").color(ChatColor.DARK_GRAY);
+ builder.append("安装的附属插件: ")
+ .color(ChatColor.GRAY)
+ .append("(" + addons.size() + ")")
+ .color(ChatColor.DARK_GRAY);
for (Plugin plugin : addons) {
String version = plugin.getDescription().getVersion();
@@ -140,25 +147,27 @@ private void addPluginVersions(@Nonnull ComponentBuilder builder) {
if (plugin instanceof SlimefunAddon addon && addon.getBugTrackerURL() != null) {
// @formatter:off
- hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[]{new TextComponent(new ComponentBuilder()
- .append("作者: ")
- .append(authors)
- .color(ChatColor.YELLOW)
- .append("\n> 单击打开反馈页面")
- .color(ChatColor.GOLD)
- .create()
- )});
+ hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[] {
+ new TextComponent(new ComponentBuilder()
+ .append("作者: ")
+ .append(authors)
+ .color(ChatColor.YELLOW)
+ .append("\n> 单击打开反馈页面")
+ .color(ChatColor.GOLD)
+ .create())
+ });
// @formatter:on
clickEvent = new ClickEvent(ClickEvent.Action.OPEN_URL, addon.getBugTrackerURL());
} else {
// @formatter:off
- hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[]{new TextComponent(new ComponentBuilder()
- .append("作者: ")
- .append(authors)
- .color(ChatColor.YELLOW)
- .create()
- )});
+ hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[] {
+ new TextComponent(new ComponentBuilder()
+ .append("作者: ")
+ .append(authors)
+ .color(ChatColor.YELLOW)
+ .create())
+ });
// @formatter:on
}
} else {
@@ -167,20 +176,23 @@ private void addPluginVersions(@Nonnull ComponentBuilder builder) {
if (plugin instanceof SlimefunAddon addon && addon.getBugTrackerURL() != null) {
// @formatter:off
- hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[]{new TextComponent(new ComponentBuilder()
- .append("此插件已被禁用.\n检查后台是否有报错.")
- .color(ChatColor.RED)
- .append("\n> 单击打开反馈页面")
- .color(ChatColor.DARK_RED)
- .create()
- )});
+ hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[] {
+ new TextComponent(new ComponentBuilder()
+ .append("此插件已被禁用.\n检查后台是否有报错.")
+ .color(ChatColor.RED)
+ .append("\n> 单击打开反馈页面")
+ .color(ChatColor.DARK_RED)
+ .create())
+ });
// @formatter:on
if (addon.getBugTrackerURL() != null) {
clickEvent = new ClickEvent(ClickEvent.Action.OPEN_URL, addon.getBugTrackerURL());
}
} else {
- hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[]{new TextComponent("插件已被禁用. 可以看看后台是否有报错.")});
+ hoverEvent = new HoverEvent(
+ HoverEvent.Action.SHOW_TEXT,
+ new TextComponent[] {new TextComponent("插件已被禁用. 可以看看后台是否有报错.")});
}
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/package-info.java
index c1b87ef5c7..4f8172faf8 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/package-info.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/package-info.java
@@ -2,4 +2,4 @@
* This package holds all implementations of {@link io.github.thebusybiscuit.slimefun4.core.commands.SubCommand}.
* You can find all sub commands of Slimefun in here.
*/
-package io.github.thebusybiscuit.slimefun4.core.commands.subcommands;
\ No newline at end of file
+package io.github.thebusybiscuit.slimefun4.core.commands.subcommands;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/config/SlimefunConfigManager.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/config/SlimefunConfigManager.java
index 82490ebc7b..25da8e027f 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/config/SlimefunConfigManager.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/config/SlimefunConfigManager.java
@@ -36,6 +36,7 @@ public class SlimefunConfigManager {
* Hold research config named "Researches.yml"
*/
private final Config researchesConfig;
+
private boolean automaticallyLoadItems;
private boolean enableResearches;
private boolean freeCreativeResearches;
@@ -58,13 +59,19 @@ public SlimefunConfigManager(@Nonnull Slimefun plugin) {
researchesConfig = getConfig(plugin, "Researches", () -> new Config(plugin, "Researches.yml"));
}
- @Nullable
- @ParametersAreNonnullByDefault
+ @Nullable @ParametersAreNonnullByDefault
private Config getConfig(Slimefun plugin, String name, Supplier supplier) {
try {
return supplier.get();
} catch (Exception x) {
- plugin.getLogger().log(Level.SEVERE, x, () -> "An Exception was thrown while loading the config file \"" + name + ".yml\" for Slimefun v" + plugin.getDescription().getVersion());
+ plugin.getLogger()
+ .log(
+ Level.SEVERE,
+ x,
+ () -> "An Exception was thrown while loading the config file \""
+ + name
+ + ".yml\" for Slimefun v"
+ + plugin.getDescription().getVersion());
return null;
}
}
@@ -96,7 +103,12 @@ public boolean load(boolean reload) {
researchesConfig.setDefaultValue("researches.currency-cost-convert-rate", 25.0);
researchCurrencyCostConvertRate = researchesConfig.getDouble("researches.currency-cost-convert-rate");
} catch (Exception x) {
- plugin.getLogger().log(Level.SEVERE, x, () -> "An Exception was caught while (re)loading the config files for Slimefun v" + plugin.getDescription().getVersion());
+ plugin.getLogger()
+ .log(
+ Level.SEVERE,
+ x,
+ () -> "An Exception was caught while (re)loading the config files for Slimefun v"
+ + plugin.getDescription().getVersion());
isSuccessful = false;
}
@@ -122,7 +134,12 @@ public boolean load(boolean reload) {
}
}
} catch (Exception x) {
- plugin.getLogger().log(Level.SEVERE, x, () -> "Something went wrong while trying to update the cost of a research: " + research);
+ plugin.getLogger()
+ .log(
+ Level.SEVERE,
+ x,
+ () -> "Something went wrong while trying to update the cost of a research: "
+ + research);
isSuccessful = false;
}
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/config/SlimefunDatabaseManager.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/config/SlimefunDatabaseManager.java
index b268e852f1..5afad85b84 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/config/SlimefunDatabaseManager.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/config/SlimefunDatabaseManager.java
@@ -1,200 +1,196 @@
-package io.github.thebusybiscuit.slimefun4.core.config;
-
-import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.IDataSourceAdapter;
-import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.mysql.MysqlAdapter;
-import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.mysql.MysqlConfig;
-import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.postgresql.PostgreSqlAdapter;
-import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.postgresql.PostgreSqlConfig;
-import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlite.SqliteAdapter;
-import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlite.SqliteConfig;
-import com.xzavier0722.mc.plugin.slimefun4.storage.common.DataType;
-import com.xzavier0722.mc.plugin.slimefun4.storage.controller.BlockDataController;
-import com.xzavier0722.mc.plugin.slimefun4.storage.controller.ControllerHolder;
-import com.xzavier0722.mc.plugin.slimefun4.storage.controller.ChunkDataLoadMode;
-import com.xzavier0722.mc.plugin.slimefun4.storage.controller.ProfileDataController;
-import com.xzavier0722.mc.plugin.slimefun4.storage.controller.StorageType;
-import io.github.bakedlibs.dough.config.Config;
-import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
-import java.io.File;
-import java.io.IOException;
-import java.util.logging.Level;
-import javax.annotation.Nullable;
-
-public class SlimefunDatabaseManager {
- private static final String PROFILE_CONFIG_FILE_NAME = "profile-storage.yml";
- private static final String BLOCK_STORAGE_FILE_NAME = "block-storage.yml";
- private final Slimefun plugin;
- private final Config profileConfig;
- private final Config blockStorageConfig;
- private StorageType profileStorageType;
- private StorageType blockDataStorageType;
- private IDataSourceAdapter> profileAdapter;
- private IDataSourceAdapter> blockStorageAdapter;
-
-
- public SlimefunDatabaseManager(Slimefun plugin) {
- this.plugin = plugin;
-
- if (!new File(plugin.getDataFolder(), PROFILE_CONFIG_FILE_NAME).exists()) {
- plugin.saveResource(PROFILE_CONFIG_FILE_NAME, false);
- }
-
- if (!new File(plugin.getDataFolder(), BLOCK_STORAGE_FILE_NAME).exists()) {
- plugin.saveResource(BLOCK_STORAGE_FILE_NAME, false);
- }
-
- profileConfig = new Config(plugin, PROFILE_CONFIG_FILE_NAME);
- blockStorageConfig = new Config(plugin, BLOCK_STORAGE_FILE_NAME);
- }
-
- public void init() {
- initDefaultVal();
- try {
- blockDataStorageType = StorageType.valueOf(blockStorageConfig.getString("storageType"));
- var readExecutorThread = blockStorageConfig.getInt("readExecutorThread");
- var writeExecutorThread = blockStorageConfig.getInt("writeExecutorThread");
-
- initAdapter(blockDataStorageType, DataType.BLOCK_STORAGE, blockStorageConfig);
-
- var blockDataController = ControllerHolder.createController(BlockDataController.class, blockDataStorageType);
- blockDataController.init(blockStorageAdapter, readExecutorThread, writeExecutorThread);
-
- if (blockStorageConfig.getBoolean("delayedWriting.enable")) {
- plugin.getLogger().log(Level.INFO, "已启用延时写入功能");
- blockDataController.initDelayedSaving(
- plugin,
- blockStorageConfig.getInt("delayedWriting.delayedSecond"),
- blockStorageConfig.getInt("delayedWriting.forceSavePeriod")
- );
- }
- } catch (IOException e) {
- plugin.getLogger().log(Level.SEVERE, "加载 Slimefun 方块存储适配器失败", e);
- return;
- }
-
- try {
- profileStorageType = StorageType.valueOf(profileConfig.getString("storageType"));
- var readExecutorThread = profileConfig.getInt("readExecutorThread");
- var writeExecutorThread = profileStorageType == StorageType.SQLITE ? 1 : profileConfig.getInt("writeExecutorThread");
-
- initAdapter(profileStorageType, DataType.PLAYER_PROFILE, profileConfig);
- var profileController = ControllerHolder.createController(ProfileDataController.class, profileStorageType);
- profileController.init(profileAdapter, readExecutorThread, writeExecutorThread);
- } catch (IOException e) {
- plugin.getLogger().log(Level.SEVERE, "加载玩家档案适配器失败", e);
- }
- }
-
- private void initAdapter(StorageType storageType, DataType dataType, Config databaseConfig) throws IOException {
- switch (storageType) {
- case MYSQL -> {
- var adapter = new MysqlAdapter();
-
- adapter.prepare(
- new MysqlConfig(
- databaseConfig.getString("mysql.host"),
- databaseConfig.getInt("mysql.port"),
- databaseConfig.getString("mysql.database"),
- databaseConfig.getString("mysql.tablePrefix"),
- databaseConfig.getString("mysql.user"),
- databaseConfig.getString("mysql.password"),
- databaseConfig.getBoolean("mysql.useSSL"),
- databaseConfig.getInt("mysql.maxConnection")
- ));
-
- switch (dataType) {
- case BLOCK_STORAGE -> blockStorageAdapter = adapter;
- case PLAYER_PROFILE -> profileAdapter = adapter;
- }
- }
- case SQLITE -> {
- var adapter = new SqliteAdapter();
-
- File databasePath = null;
-
- switch (dataType) {
- case PLAYER_PROFILE -> {
- databasePath = new File("data-storage/Slimefun", "profile.db");
- profileAdapter = adapter;
- }
- case BLOCK_STORAGE -> {
- databasePath = new File("data-storage/Slimefun", "block-storage.db");
- blockStorageAdapter = adapter;
- }
- }
- adapter.prepare(new SqliteConfig(databasePath.getAbsolutePath(), databaseConfig.getInt("sqlite.maxConnection")));
- }
- case POSTGRESQL -> {
- var adapter = new PostgreSqlAdapter();
-
- adapter.prepare(
- new PostgreSqlConfig(
- databaseConfig.getString("postgresql.host"),
- databaseConfig.getInt("postgresql.port"),
- databaseConfig.getString("postgresql.database"),
- databaseConfig.getString("postgresql.tablePrefix"),
- databaseConfig.getString("postgresql.user"),
- databaseConfig.getString("postgresql.password"),
- databaseConfig.getBoolean("postgresql.useSSL"),
- databaseConfig.getInt("postgresql.maxConnection")
- ));
-
- switch (dataType) {
- case BLOCK_STORAGE -> blockStorageAdapter = adapter;
- case PLAYER_PROFILE -> profileAdapter = adapter;
- }
- }
- }
- }
-
- @Nullable
- public ProfileDataController getProfileDataController() {
- return ControllerHolder.getController(ProfileDataController.class, profileStorageType);
- }
-
- public BlockDataController getBlockDataController() {
- return ControllerHolder.getController(BlockDataController.class, blockDataStorageType);
- }
-
- public void shutdown() {
- if (getProfileDataController() != null) {
- getProfileDataController().shutdown();
- }
-
- if (getBlockDataController() != null) {
- getBlockDataController().shutdown();
- }
-
- blockStorageAdapter.shutdown();
- profileAdapter.shutdown();
- ControllerHolder.clearControllers();
- }
-
- public boolean isBlockDataBase64Enabled() {
- return blockStorageConfig.getBoolean("base64EncodeVal");
- }
-
- public boolean isProfileDataBase64Enabled() {
- return profileConfig.getBoolean("base64EncodeVal");
- }
-
- public ChunkDataLoadMode getChunkDataLoadMode() {
- return ChunkDataLoadMode.valueOf(blockStorageConfig.getString("dataLoadMode"));
- }
-
- public StorageType getBlockDataStorageType() {
- return blockDataStorageType;
- }
-
- public StorageType getProfileStorageType() {
- return profileStorageType;
- }
-
- private void initDefaultVal() {
- profileConfig.setDefaultValue("sqlite.maxConnection", 5);
- profileConfig.save();
- blockStorageConfig.setDefaultValue("sqlite.maxConnection", 5);
- blockStorageConfig.setDefaultValue("dataLoadMode", "LOAD_WITH_CHUNK");
- blockStorageConfig.save();
- }
-}
+package io.github.thebusybiscuit.slimefun4.core.config;
+
+import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.IDataSourceAdapter;
+import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.mysql.MysqlAdapter;
+import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.mysql.MysqlConfig;
+import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.postgresql.PostgreSqlAdapter;
+import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.postgresql.PostgreSqlConfig;
+import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlite.SqliteAdapter;
+import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlite.SqliteConfig;
+import com.xzavier0722.mc.plugin.slimefun4.storage.common.DataType;
+import com.xzavier0722.mc.plugin.slimefun4.storage.controller.BlockDataController;
+import com.xzavier0722.mc.plugin.slimefun4.storage.controller.ChunkDataLoadMode;
+import com.xzavier0722.mc.plugin.slimefun4.storage.controller.ControllerHolder;
+import com.xzavier0722.mc.plugin.slimefun4.storage.controller.ProfileDataController;
+import com.xzavier0722.mc.plugin.slimefun4.storage.controller.StorageType;
+import io.github.bakedlibs.dough.config.Config;
+import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
+import java.io.File;
+import java.io.IOException;
+import java.util.logging.Level;
+import javax.annotation.Nullable;
+
+public class SlimefunDatabaseManager {
+ private static final String PROFILE_CONFIG_FILE_NAME = "profile-storage.yml";
+ private static final String BLOCK_STORAGE_FILE_NAME = "block-storage.yml";
+ private final Slimefun plugin;
+ private final Config profileConfig;
+ private final Config blockStorageConfig;
+ private StorageType profileStorageType;
+ private StorageType blockDataStorageType;
+ private IDataSourceAdapter> profileAdapter;
+ private IDataSourceAdapter> blockStorageAdapter;
+
+ public SlimefunDatabaseManager(Slimefun plugin) {
+ this.plugin = plugin;
+
+ if (!new File(plugin.getDataFolder(), PROFILE_CONFIG_FILE_NAME).exists()) {
+ plugin.saveResource(PROFILE_CONFIG_FILE_NAME, false);
+ }
+
+ if (!new File(plugin.getDataFolder(), BLOCK_STORAGE_FILE_NAME).exists()) {
+ plugin.saveResource(BLOCK_STORAGE_FILE_NAME, false);
+ }
+
+ profileConfig = new Config(plugin, PROFILE_CONFIG_FILE_NAME);
+ blockStorageConfig = new Config(plugin, BLOCK_STORAGE_FILE_NAME);
+ }
+
+ public void init() {
+ initDefaultVal();
+ try {
+ blockDataStorageType = StorageType.valueOf(blockStorageConfig.getString("storageType"));
+ var readExecutorThread = blockStorageConfig.getInt("readExecutorThread");
+ var writeExecutorThread = blockStorageConfig.getInt("writeExecutorThread");
+
+ initAdapter(blockDataStorageType, DataType.BLOCK_STORAGE, blockStorageConfig);
+
+ var blockDataController =
+ ControllerHolder.createController(BlockDataController.class, blockDataStorageType);
+ blockDataController.init(blockStorageAdapter, readExecutorThread, writeExecutorThread);
+
+ if (blockStorageConfig.getBoolean("delayedWriting.enable")) {
+ plugin.getLogger().log(Level.INFO, "已启用延时写入功能");
+ blockDataController.initDelayedSaving(
+ plugin,
+ blockStorageConfig.getInt("delayedWriting.delayedSecond"),
+ blockStorageConfig.getInt("delayedWriting.forceSavePeriod"));
+ }
+ } catch (IOException e) {
+ plugin.getLogger().log(Level.SEVERE, "加载 Slimefun 方块存储适配器失败", e);
+ return;
+ }
+
+ try {
+ profileStorageType = StorageType.valueOf(profileConfig.getString("storageType"));
+ var readExecutorThread = profileConfig.getInt("readExecutorThread");
+ var writeExecutorThread =
+ profileStorageType == StorageType.SQLITE ? 1 : profileConfig.getInt("writeExecutorThread");
+
+ initAdapter(profileStorageType, DataType.PLAYER_PROFILE, profileConfig);
+ var profileController = ControllerHolder.createController(ProfileDataController.class, profileStorageType);
+ profileController.init(profileAdapter, readExecutorThread, writeExecutorThread);
+ } catch (IOException e) {
+ plugin.getLogger().log(Level.SEVERE, "加载玩家档案适配器失败", e);
+ }
+ }
+
+ private void initAdapter(StorageType storageType, DataType dataType, Config databaseConfig) throws IOException {
+ switch (storageType) {
+ case MYSQL -> {
+ var adapter = new MysqlAdapter();
+
+ adapter.prepare(new MysqlConfig(
+ databaseConfig.getString("mysql.host"),
+ databaseConfig.getInt("mysql.port"),
+ databaseConfig.getString("mysql.database"),
+ databaseConfig.getString("mysql.tablePrefix"),
+ databaseConfig.getString("mysql.user"),
+ databaseConfig.getString("mysql.password"),
+ databaseConfig.getBoolean("mysql.useSSL"),
+ databaseConfig.getInt("mysql.maxConnection")));
+
+ switch (dataType) {
+ case BLOCK_STORAGE -> blockStorageAdapter = adapter;
+ case PLAYER_PROFILE -> profileAdapter = adapter;
+ }
+ }
+ case SQLITE -> {
+ var adapter = new SqliteAdapter();
+
+ File databasePath = null;
+
+ switch (dataType) {
+ case PLAYER_PROFILE -> {
+ databasePath = new File("data-storage/Slimefun", "profile.db");
+ profileAdapter = adapter;
+ }
+ case BLOCK_STORAGE -> {
+ databasePath = new File("data-storage/Slimefun", "block-storage.db");
+ blockStorageAdapter = adapter;
+ }
+ }
+ adapter.prepare(new SqliteConfig(
+ databasePath.getAbsolutePath(), databaseConfig.getInt("sqlite.maxConnection")));
+ }
+ case POSTGRESQL -> {
+ var adapter = new PostgreSqlAdapter();
+
+ adapter.prepare(new PostgreSqlConfig(
+ databaseConfig.getString("postgresql.host"),
+ databaseConfig.getInt("postgresql.port"),
+ databaseConfig.getString("postgresql.database"),
+ databaseConfig.getString("postgresql.tablePrefix"),
+ databaseConfig.getString("postgresql.user"),
+ databaseConfig.getString("postgresql.password"),
+ databaseConfig.getBoolean("postgresql.useSSL"),
+ databaseConfig.getInt("postgresql.maxConnection")));
+
+ switch (dataType) {
+ case BLOCK_STORAGE -> blockStorageAdapter = adapter;
+ case PLAYER_PROFILE -> profileAdapter = adapter;
+ }
+ }
+ }
+ }
+
+ @Nullable public ProfileDataController getProfileDataController() {
+ return ControllerHolder.getController(ProfileDataController.class, profileStorageType);
+ }
+
+ public BlockDataController getBlockDataController() {
+ return ControllerHolder.getController(BlockDataController.class, blockDataStorageType);
+ }
+
+ public void shutdown() {
+ if (getProfileDataController() != null) {
+ getProfileDataController().shutdown();
+ }
+
+ if (getBlockDataController() != null) {
+ getBlockDataController().shutdown();
+ }
+
+ blockStorageAdapter.shutdown();
+ profileAdapter.shutdown();
+ ControllerHolder.clearControllers();
+ }
+
+ public boolean isBlockDataBase64Enabled() {
+ return blockStorageConfig.getBoolean("base64EncodeVal");
+ }
+
+ public boolean isProfileDataBase64Enabled() {
+ return profileConfig.getBoolean("base64EncodeVal");
+ }
+
+ public ChunkDataLoadMode getChunkDataLoadMode() {
+ return ChunkDataLoadMode.valueOf(blockStorageConfig.getString("dataLoadMode"));
+ }
+
+ public StorageType getBlockDataStorageType() {
+ return blockDataStorageType;
+ }
+
+ public StorageType getProfileStorageType() {
+ return profileStorageType;
+ }
+
+ private void initDefaultVal() {
+ profileConfig.setDefaultValue("sqlite.maxConnection", 5);
+ profileConfig.save();
+ blockStorageConfig.setDefaultValue("sqlite.maxConnection", 5);
+ blockStorageConfig.setDefaultValue("dataLoadMode", "LOAD_WITH_CHUNK");
+ blockStorageConfig.save();
+ }
+}
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 ab9b53c0c8..0dd4ccec02 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
@@ -76,9 +76,9 @@ public static void log(@Nonnull String test, @Nonnull String msg, @Nonnull Objec
if (vars.length > 0) {
String formatted = formatMessage(msg, vars);
- Slimefun.logger().log(Level.INFO, "[DEBUG {0}] {1}", new Object[] { test, formatted });
+ Slimefun.logger().log(Level.INFO, "[DEBUG {0}] {1}", new Object[] {test, formatted});
} else {
- Slimefun.logger().log(Level.INFO, "[DEBUG {0}] {1}", new Object[] { test, msg });
+ Slimefun.logger().log(Level.INFO, "[DEBUG {0}] {1}", new Object[] {test, msg});
}
}
@@ -104,7 +104,8 @@ public static void log(@Nonnull String test, @Nonnull String msg, @Nonnull Objec
// Find an opening curly brace `{` and validate the next char is a closing one `}`
while ((i = msg.indexOf('{', i)) != -1 && msg.charAt(i + 1) == '}') {
- // Substring up to the opening brace `{`, add the variable for this and add the rest of the message
+ // Substring up to the opening brace `{`, add the variable for this and add the rest of the
+ // message
msg = msg.substring(0, i) + vars[idx] + msg.substring(i + 2);
idx++;
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/debug/TestCase.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/debug/TestCase.java
index 4a8941e34b..7c413f7b9f 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/debug/TestCase.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/debug/TestCase.java
@@ -26,8 +26,7 @@ public enum TestCase {
ENERGYNET;
- TestCase() {
- }
+ TestCase() {}
@Override
public @Nonnull String toString() {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/debug/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/debug/package-info.java
index 57ef3809c0..f987069d28 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/debug/package-info.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/debug/package-info.java
@@ -2,4 +2,4 @@
* This package holds the debug functionality of Slimefun, these can be used as addons but are mostly just
* going to be used by Slimefun itself.
*/
-package io.github.thebusybiscuit.slimefun4.core.debug;
\ No newline at end of file
+package io.github.thebusybiscuit.slimefun4.core.debug;
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 114980eefa..adf84d2a9c 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
@@ -24,5 +24,4 @@ public int getPage() {
public void setPage(int page) {
this.page = page;
}
-
-}
\ No newline at end of file
+}
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 d84adcfee2..e0b81251ec 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
@@ -1,25 +1,22 @@
package io.github.thebusybiscuit.slimefun4.core.guide;
+import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
+import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
+import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
import java.util.Deque;
import java.util.LinkedList;
-
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-
import org.apache.commons.lang.Validate;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
-import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
-import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
-import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
-
/**
* {@link GuideHistory} represents the browsing history of a {@link Player} through the
* {@link SlimefunGuide}.
- *
+ *
* @author TheBusyBiscuit
- *
+ *
* @see SlimefunGuide
* @see PlayerProfile
*
@@ -32,7 +29,7 @@ public class GuideHistory {
/**
* This creates a new {@link GuideHistory} for the given {@link PlayerProfile}
- *
+ *
* @param profile
* The {@link PlayerProfile} this {@link GuideHistory} was made for
*/
@@ -50,7 +47,7 @@ public void clear() {
/**
* This method sets the page of the main menu of this {@link GuideHistory}
- *
+ *
* @param page
* The current page of the main menu that should be stored
*/
@@ -62,7 +59,7 @@ public void setMainMenuPage(int page) {
/**
* This returns the current main menu page of this {@link GuideHistory}
- *
+ *
* @return The main menu page of this {@link GuideHistory}
*/
public int getMainMenuPage() {
@@ -73,7 +70,7 @@ public int getMainMenuPage() {
* This method adds a {@link ItemGroup} to this {@link GuideHistory}.
* Should the {@link ItemGroup} already be the last element in this {@link GuideHistory},
* then the entry will be overridden with the new page.
- *
+ *
* @param itemGroup
* The {@link ItemGroup} that should be added to this {@link GuideHistory}
* @param page
@@ -87,7 +84,7 @@ public void add(@Nonnull ItemGroup itemGroup, int page) {
* This method adds a {@link ItemStack} to this {@link GuideHistory}.
* Should the {@link ItemStack} already be the last element in this {@link GuideHistory},
* then the entry will be overridden with the new page.
- *
+ *
* @param item
* The {@link ItemStack} that should be added to this {@link GuideHistory}
* @param page
@@ -99,7 +96,7 @@ public void add(@Nonnull ItemStack item, int page) {
/**
* This method stores the given {@link SlimefunItem} in this {@link GuideHistory}.
- *
+ *
* @param item
* The {@link SlimefunItem} that should be added to this {@link GuideHistory}
*/
@@ -110,7 +107,7 @@ public void add(@Nonnull SlimefunItem item) {
/**
* This method stores the given search term in this {@link GuideHistory}.
- *
+ *
* @param searchTerm
* The term that the {@link Player} searched for
*/
@@ -134,7 +131,7 @@ private void refresh(@Nonnull T object, int page) {
/**
* This returns the amount of elements in this {@link GuideHistory}.
- *
+ *
* @return The size of this {@link GuideHistory}
*/
public int size() {
@@ -144,13 +141,12 @@ public int size() {
/**
* Retrieves the last page in the {@link SlimefunGuide} that was visited by a {@link Player}.
* Optionally also rewinds the history back to that entry.
- *
+ *
* @param remove
* Whether to remove the current entry so it moves back to the entry returned.
* @return The last Guide Entry that was saved to the given Players guide history.
*/
- @Nullable
- private GuideEntry> getLastEntry(boolean remove) {
+ @Nullable private GuideEntry> getLastEntry(boolean remove) {
if (remove && !queue.isEmpty()) {
queue.removeLast();
}
@@ -161,7 +157,7 @@ private GuideEntry> getLastEntry(boolean remove) {
/**
* This method opens the last opened entry to the associated {@link PlayerProfile}
* of this {@link GuideHistory}.
- *
+ *
* @param guide
* The {@link SlimefunGuideImplementation} to use
*/
@@ -174,9 +170,9 @@ public void openLastEntry(@Nonnull SlimefunGuideImplementation guide) {
* This method opens the previous entry to the associated {@link PlayerProfile}.
* More precisely, it will remove the last entry and open the second-last entry
* to the {@link Player}.
- *
+ *
* It can be thought of as a "back" button. Since that is what this is used for.
- *
+ *
* @param guide
* The {@link SlimefunGuideImplementation} to use
*/
@@ -200,5 +196,4 @@ private void open(@Nonnull SlimefunGuideImplementation guide, @Nullable Guid
throw new IllegalStateException("Unknown GuideHistory entry: " + entry.getIndexedObject());
}
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuide.java
index 91f70a6c80..20128043aa 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuide.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuide.java
@@ -1,15 +1,5 @@
package io.github.thebusybiscuit.slimefun4.core.guide;
-import java.util.Optional;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-import javax.annotation.ParametersAreNonnullByDefault;
-
-import org.bukkit.Material;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.ItemStack;
-
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
@@ -17,13 +7,20 @@
import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
import io.github.thebusybiscuit.slimefun4.utils.itemstack.SlimefunGuideItem;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import javax.annotation.ParametersAreNonnullByDefault;
+import org.bukkit.Material;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
/**
* This is a static utility class that provides convenient access to the methods
* of {@link SlimefunGuideImplementation} that abstracts away the actual implementation.
- *
+ *
* @author TheBusyBiscuit
- *
+ *
* @see SlimefunGuideImplementation
* @see SurvivalSlimefunGuide
*
@@ -82,7 +79,8 @@ public static void openMainMenu(PlayerProfile profile, SlimefunGuideMode mode, i
}
@ParametersAreNonnullByDefault
- public static void openItemGroup(PlayerProfile profile, ItemGroup itemGroup, SlimefunGuideMode mode, int selectedPage) {
+ public static void openItemGroup(
+ PlayerProfile profile, ItemGroup itemGroup, SlimefunGuideMode mode, int selectedPage) {
Slimefun.getRegistry().getSlimefunGuide(mode).openItemGroup(profile, itemGroup, selectedPage);
}
@@ -94,20 +92,24 @@ public static void openSearch(PlayerProfile profile, String input, SlimefunGuide
@ParametersAreNonnullByDefault
public static void displayItem(PlayerProfile profile, ItemStack item, boolean addToHistory) {
- Slimefun.getRegistry().getSlimefunGuide(SlimefunGuideMode.SURVIVAL_MODE).displayItem(profile, item, 0, addToHistory);
+ Slimefun.getRegistry()
+ .getSlimefunGuide(SlimefunGuideMode.SURVIVAL_MODE)
+ .displayItem(profile, item, 0, addToHistory);
}
@ParametersAreNonnullByDefault
public static void displayItem(PlayerProfile profile, SlimefunItem item, boolean addToHistory) {
- Slimefun.getRegistry().getSlimefunGuide(SlimefunGuideMode.SURVIVAL_MODE).displayItem(profile, item, addToHistory);
+ Slimefun.getRegistry()
+ .getSlimefunGuide(SlimefunGuideMode.SURVIVAL_MODE)
+ .displayItem(profile, item, addToHistory);
}
/**
* This method checks if a given {@link ItemStack} is a {@link SlimefunGuide}.
- *
+ *
* @param item
* The {@link ItemStack} to check
- *
+ *
* @return Whether this {@link ItemStack} represents a {@link SlimefunGuide}
*/
public static boolean isGuideItem(@Nullable ItemStack item) {
@@ -116,7 +118,8 @@ public static boolean isGuideItem(@Nullable ItemStack item) {
} else if (item instanceof SlimefunGuideItem) {
return true;
} else {
- return SlimefunUtils.isItemSimilar(item, getItem(SlimefunGuideMode.SURVIVAL_MODE), true) || SlimefunUtils.isItemSimilar(item, getItem(SlimefunGuideMode.CHEAT_MODE), true);
+ return SlimefunUtils.isItemSimilar(item, getItem(SlimefunGuideMode.SURVIVAL_MODE), true)
+ || SlimefunUtils.isItemSimilar(item, getItem(SlimefunGuideMode.CHEAT_MODE), true);
}
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideImplementation.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideImplementation.java
index eb7e3f8511..532f886e2e 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideImplementation.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideImplementation.java
@@ -20,7 +20,7 @@
* to the {@link SlimefunGuide}.
*
* @author TheBusyBiscuit
- *
+ *
* @see SlimefunGuideMode
* @see SurvivalSlimefunGuide
*
@@ -74,9 +74,9 @@ default void unlockItem(Player p, SlimefunItem sfitem, Consumer callback
p.setLevel(p.getLevel() - research.getLevelCost());
}
- boolean skipLearningAnimation = Slimefun.getConfigManager().isLearningAnimationDisabled() || !SlimefunGuideSettings.hasLearningAnimationEnabled(p);
+ boolean skipLearningAnimation = Slimefun.getConfigManager().isLearningAnimationDisabled()
+ || !SlimefunGuideSettings.hasLearningAnimationEnabled(p);
research.unlock(p, skipLearningAnimation, callback);
}
}
-
}
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 59597bd66a..e4ef843624 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,15 +1,14 @@
package io.github.thebusybiscuit.slimefun4.core.guide;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
-
import javax.annotation.Nonnull;
/**
* This enum holds the different designs a {@link SlimefunGuide} can have.
* Each constant corresponds to a {@link SlimefunGuideImplementation}.
- *
+ *
* @author TheBusyBiscuit
- *
+ *
* @see SlimefunGuide
* @see SlimefunGuideImplementation
*
@@ -41,5 +40,4 @@ public enum SlimefunGuideMode {
public @Nonnull String getDisplayName() {
return displayName;
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/ContributorsMenu.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/ContributorsMenu.java
index 93e8d89a35..fc117a1905 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/ContributorsMenu.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/ContributorsMenu.java
@@ -1,15 +1,5 @@
package io.github.thebusybiscuit.slimefun4.core.guide.options;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.ItemStack;
-import org.bukkit.inventory.meta.SkullMeta;
-
import io.github.bakedlibs.dough.common.ChatColors;
import io.github.bakedlibs.dough.common.CommonPatterns;
import io.github.bakedlibs.dough.items.CustomItemStack;
@@ -19,12 +9,19 @@
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
-
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.SkullMeta;
/**
* This menu shows a list of every {@link Contributor} to this project.
- *
+ *
* @author TheBusyBiscuit
*
*/
@@ -40,13 +37,17 @@ public static void open(Player p, int page) {
ChestMenuUtils.drawBackground(menu, 0, 2, 3, 4, 5, 6, 7, 8, 45, 47, 48, 49, 50, 51, 53);
- menu.addItem(1, new CustomItemStack(ChestMenuUtils.getBackButton(p, "", "&7" + Slimefun.getLocalization().getMessage(p, "guide.back.settings"))));
+ menu.addItem(
+ 1,
+ new CustomItemStack(ChestMenuUtils.getBackButton(
+ p, "", "&7" + Slimefun.getLocalization().getMessage(p, "guide.back.settings"))));
menu.addMenuClickHandler(1, (pl, slot, item, action) -> {
SlimefunGuideSettings.openSettings(pl, p.getInventory().getItemInMainHand());
return false;
});
- List contributors = new ArrayList<>(Slimefun.getGitHubService().getContributors().values());
+ List contributors =
+ new ArrayList<>(Slimefun.getGitHubService().getContributors().values());
contributors.sort(Comparator.comparingInt(Contributor::getPosition));
for (int i = page * 36; i < contributors.size() && i < (page + 1) * 36; i++) {
@@ -108,7 +109,8 @@ private static ItemStack getContributorHead(Player p, Contributor contributor) {
}
if (entry.getValue() > 0) {
- String commits = Slimefun.getLocalization().getMessage(p, "guide.credits." + (entry.getValue() > 1 ? "commits" : "commit"));
+ String commits = Slimefun.getLocalization()
+ .getMessage(p, "guide.credits." + (entry.getValue() > 1 ? "commits" : "commit"));
info += " &7(" + entry.getValue() + ' ' + commits + ')';
}
@@ -118,12 +120,12 @@ private static ItemStack getContributorHead(Player p, Contributor contributor) {
if (contributor.getProfile() != null) {
lore.add("");
- lore.add(ChatColors.color("&7\u21E8 &e") + Slimefun.getLocalization().getMessage(p, "guide.credits.profile-link"));
+ lore.add(ChatColors.color("&7\u21E8 &e")
+ + Slimefun.getLocalization().getMessage(p, "guide.credits.profile-link"));
}
meta.setLore(lore);
skull.setItemMeta(meta);
return skull;
}
-
}
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 5bf6775fb9..53fd042e49 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
@@ -29,7 +29,15 @@ public Optional getDisplayItem(Player p, ItemStack guide) {
if (cfgManager.isResearchingEnabled() && cfgManager.isResearchFireworkEnabled()) {
boolean enabled = getSelectedOption(p, guide).orElse(true);
- ItemStack item = new CustomItemStack(Material.FIREWORK_ROCKET, "&b烟花特效: &" + (enabled ? "a启用" : "4禁用"), "", "&7你现在可以选择是否", "&7在解锁一个新物品的时候", "&7展示烟花特效.", "", "&7\u21E8 &e点击 " + (enabled ? "禁用" : "启用") + " 烟花特效");
+ ItemStack item = new CustomItemStack(
+ Material.FIREWORK_ROCKET,
+ "&b烟花特效: &" + (enabled ? "a启用" : "4禁用"),
+ "",
+ "&7你现在可以选择是否",
+ "&7在解锁一个新物品的时候",
+ "&7展示烟花特效.",
+ "",
+ "&7\u21E8 &e点击 " + (enabled ? "禁用" : "启用") + " 烟花特效");
return Optional.of(item);
} else {
return Optional.empty();
@@ -53,5 +61,4 @@ public Optional getSelectedOption(Player p, ItemStack guide) {
public void setSelectedOption(Player p, ItemStack guide, Boolean value) {
PersistentDataAPI.setByte(p, getKey(), value.booleanValue() ? (byte) 1 : (byte) 0);
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/GuideModeOption.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/GuideModeOption.java
index cd9e331278..5ce62204d7 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/GuideModeOption.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/GuideModeOption.java
@@ -1,12 +1,15 @@
package io.github.thebusybiscuit.slimefun4.core.guide.options;
+import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
+import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
+import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode;
+import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
+import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
-
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
-
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
@@ -14,13 +17,6 @@
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
-import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
-import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
-import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode;
-import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
-import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
-import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
-
class GuideModeOption implements SlimefunGuideOption {
@Nonnull
@@ -113,5 +109,4 @@ public Optional getSelectedOption(@Nonnull Player p, @Nonnull
public void setSelectedOption(Player p, ItemStack guide, SlimefunGuideMode value) {
guide.setItemMeta(SlimefunGuide.getItem(value).getItemMeta());
}
-
-}
\ No newline at end of file
+}
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 f172eb950a..06ece07849 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
@@ -44,9 +44,12 @@ public Optional getDisplayItem(@Nonnull Player p, @Nonnull ItemStack
} else {
boolean enabled = getSelectedOption(p, guide).orElse(true);
String optionState = enabled ? "enabled" : "disabled";
- List lore = Slimefun.getLocalization().getMessages(p, "guide.options.learning-animation." + optionState + ".text");
+ List lore = Slimefun.getLocalization()
+ .getMessages(p, "guide.options.learning-animation." + optionState + ".text");
lore.add("");
- lore.add("&7\u21E8 " + Slimefun.getLocalization().getMessage(p, "guide.options.learning-animation." + optionState + ".click"));
+ lore.add("&7\u21E8 "
+ + Slimefun.getLocalization()
+ .getMessage(p, "guide.options.learning-animation." + optionState + ".click"));
ItemStack item = new CustomItemStack(enabled ? Material.MAP : Material.PAPER, lore);
return Optional.of(item);
@@ -70,5 +73,4 @@ public Optional getSelectedOption(@Nonnull Player p, @Nonnull ItemStack
public void setSelectedOption(@Nonnull Player p, @Nonnull ItemStack guide, @Nonnull Boolean value) {
PersistentDataAPI.setByte(p, getKey(), (byte) (value.booleanValue() ? 1 : 0));
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/PlayerLanguageOption.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/PlayerLanguageOption.java
index 925943eb90..62cc39fb6a 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/PlayerLanguageOption.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/PlayerLanguageOption.java
@@ -1,14 +1,5 @@
package io.github.thebusybiscuit.slimefun4.core.guide.options;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Optional;
-
-import org.bukkit.ChatColor;
-import org.bukkit.NamespacedKey;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.ItemStack;
-
import io.github.bakedlibs.dough.data.persistent.PersistentDataAPI;
import io.github.bakedlibs.dough.items.CustomItemStack;
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
@@ -20,8 +11,14 @@
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
import io.github.thebusybiscuit.slimefun4.utils.HeadTexture;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
-
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
+import org.bukkit.ChatColor;
+import org.bukkit.NamespacedKey;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
class PlayerLanguageOption implements SlimefunGuideOption {
@@ -39,17 +36,37 @@ public NamespacedKey getKey() {
public Optional getDisplayItem(Player p, ItemStack guide) {
if (Slimefun.getLocalization().isEnabled()) {
Language language = Slimefun.getLocalization().getLanguage(p);
- String languageName = language.isDefault() ? (Slimefun.getLocalization().getMessage(p, "languages.default") + ChatColor.DARK_GRAY + " (" + language.getName(p) + ")") : Slimefun.getLocalization().getMessage(p, "languages." + language.getId());
+ String languageName = language.isDefault()
+ ? (Slimefun.getLocalization().getMessage(p, "languages.default")
+ + ChatColor.DARK_GRAY
+ + " ("
+ + language.getName(p)
+ + ")")
+ : Slimefun.getLocalization().getMessage(p, "languages." + language.getId());
List lore = new ArrayList<>();
lore.add("");
lore.add("&e&o" + Slimefun.getLocalization().getMessage(p, "guide.work-in-progress"));
lore.add("");
- lore.addAll(Slimefun.getLocalization().getMessages(p, "guide.languages.description", msg -> msg.replace("%contributors%", String.valueOf(Slimefun.getGitHubService().getContributors().size()))));
+ lore.addAll(Slimefun.getLocalization()
+ .getMessages(
+ p,
+ "guide.languages.description",
+ msg -> msg.replace(
+ "%contributors%",
+ String.valueOf(Slimefun.getGitHubService()
+ .getContributors()
+ .size()))));
lore.add("");
lore.add("&7\u21E8 &e" + Slimefun.getLocalization().getMessage(p, "guide.languages.change"));
- ItemStack item = new CustomItemStack(language.getItem(), "&7" + Slimefun.getLocalization().getMessage(p, "guide.languages.selected-language") + " &a" + languageName, lore.toArray(new String[0]));
+ ItemStack item = new CustomItemStack(
+ language.getItem(),
+ "&7"
+ + Slimefun.getLocalization().getMessage(p, "guide.languages.selected-language")
+ + " &a"
+ + languageName,
+ lore.toArray(new String[0]));
return Optional.of(item);
} else {
return Optional.empty();
@@ -83,16 +100,29 @@ private void openLanguageSelection(Player p, ItemStack guide) {
for (int i = 0; i < 9; i++) {
if (i == 1) {
- menu.addItem(1, ChestMenuUtils.getBackButton(p, "", "&7" + Slimefun.getLocalization().getMessage(p, "guide.back.settings")), (pl, slot, item, action) -> {
- SlimefunGuideSettings.openSettings(pl, guide);
- return false;
- });
+ menu.addItem(
+ 1,
+ ChestMenuUtils.getBackButton(
+ p, "", "&7" + Slimefun.getLocalization().getMessage(p, "guide.back.settings")),
+ (pl, slot, item, action) -> {
+ SlimefunGuideSettings.openSettings(pl, guide);
+ return false;
+ });
} else if (i == 7) {
- menu.addItem(7, new CustomItemStack(SlimefunUtils.getCustomHead(HeadTexture.ADD_NEW_LANGUAGE.getTexture()), Slimefun.getLocalization().getMessage(p, "guide.languages.translations.name"), "", "&7\u21E8 &e" + Slimefun.getLocalization().getMessage(p, "guide.languages.translations.lore")), (pl, slot, item, action) -> {
- ChatUtils.sendURL(pl, "https://slimefun-wiki.guizhanss.cn/Translating-Slimefun");
- pl.closeInventory();
- return false;
- });
+ menu.addItem(
+ 7,
+ new CustomItemStack(
+ SlimefunUtils.getCustomHead(HeadTexture.ADD_NEW_LANGUAGE.getTexture()),
+ Slimefun.getLocalization().getMessage(p, "guide.languages.translations.name"),
+ "",
+ "&7\u21E8 &e"
+ + Slimefun.getLocalization()
+ .getMessage(p, "guide.languages.translations.lore")),
+ (pl, slot, item, action) -> {
+ ChatUtils.sendURL(pl, "https://slimefun-wiki.guizhanss.cn/Translating-Slimefun");
+ pl.closeInventory();
+ return false;
+ });
} else {
menu.addItem(i, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler());
}
@@ -101,34 +131,64 @@ private void openLanguageSelection(Player p, ItemStack guide) {
Language defaultLanguage = Slimefun.getLocalization().getDefaultLanguage();
String defaultLanguageString = Slimefun.getLocalization().getMessage(p, "languages.default");
- menu.addItem(9, new CustomItemStack(defaultLanguage.getItem(), ChatColor.GRAY + defaultLanguageString + ChatColor.DARK_GRAY + " (" + defaultLanguage.getName(p) + ")", "", "&7\u21E8 &e" + Slimefun.getLocalization().getMessage(p, "guide.languages.select-default")), (pl, i, item, action) -> {
- Slimefun.instance().getServer().getPluginManager().callEvent(new PlayerLanguageChangeEvent(pl, Slimefun.getLocalization().getLanguage(pl), defaultLanguage));
- setSelectedOption(pl, guide, null);
+ menu.addItem(
+ 9,
+ new CustomItemStack(
+ defaultLanguage.getItem(),
+ ChatColor.GRAY
+ + defaultLanguageString
+ + ChatColor.DARK_GRAY
+ + " ("
+ + defaultLanguage.getName(p)
+ + ")",
+ "",
+ "&7\u21E8 &e" + Slimefun.getLocalization().getMessage(p, "guide.languages.select-default")),
+ (pl, i, item, action) -> {
+ Slimefun.instance()
+ .getServer()
+ .getPluginManager()
+ .callEvent(new PlayerLanguageChangeEvent(
+ pl, Slimefun.getLocalization().getLanguage(pl), defaultLanguage));
+ setSelectedOption(pl, guide, null);
+
+ Slimefun.getLocalization()
+ .sendMessage(
+ pl, "guide.languages.updated", msg -> msg.replace("%lang%", defaultLanguageString));
- Slimefun.getLocalization().sendMessage(pl, "guide.languages.updated", msg -> msg.replace("%lang%", defaultLanguageString));
-
- SlimefunGuideSettings.openSettings(pl, guide);
- return false;
- });
+ SlimefunGuideSettings.openSettings(pl, guide);
+ return false;
+ });
int slot = 10;
for (Language language : Slimefun.getLocalization().getLanguages()) {
- menu.addItem(slot, new CustomItemStack(language.getItem(), ChatColor.GREEN + language.getName(p), "&b" + language.getTranslationProgress() + '%', "", "&7\u21E8 &e" + Slimefun.getLocalization().getMessage(p, "guide.languages.select")), (pl, i, item, action) -> {
- Slimefun.instance().getServer().getPluginManager().callEvent(new PlayerLanguageChangeEvent(pl, Slimefun.getLocalization().getLanguage(pl), language));
- setSelectedOption(pl, guide, language.getId());
-
- String name = language.getName(pl);
- Slimefun.getLocalization().sendMessage(pl, "guide.languages.updated", msg -> msg.replace("%lang%", name));
-
- SlimefunGuideSettings.openSettings(pl, guide);
- return false;
- });
+ menu.addItem(
+ slot,
+ new CustomItemStack(
+ language.getItem(),
+ ChatColor.GREEN + language.getName(p),
+ "&b" + language.getTranslationProgress() + '%',
+ "",
+ "&7\u21E8 &e" + Slimefun.getLocalization().getMessage(p, "guide.languages.select")),
+ (pl, i, item, action) -> {
+ Slimefun.instance()
+ .getServer()
+ .getPluginManager()
+ .callEvent(new PlayerLanguageChangeEvent(
+ pl, Slimefun.getLocalization().getLanguage(pl), language));
+ setSelectedOption(pl, guide, language.getId());
+
+ String name = language.getName(pl);
+ Slimefun.getLocalization()
+ .sendMessage(pl, "guide.languages.updated", msg -> msg.replace("%lang%", name));
+
+ SlimefunGuideSettings.openSettings(pl, guide);
+ return false;
+ });
slot++;
}
menu.open(p);
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideOption.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideOption.java
index 1caeb02826..82100c96ff 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideOption.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideOption.java
@@ -1,19 +1,16 @@
package io.github.thebusybiscuit.slimefun4.core.guide.options;
+import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
+import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
import java.util.Optional;
-
import javax.annotation.Nonnull;
-
import org.bukkit.Keyed;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
-import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
-import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
-
/**
* This interface represents an option in the {@link SlimefunGuide}.
- *
+ *
* @author TheBusyBiscuit
*
* @param
@@ -23,7 +20,7 @@ public interface SlimefunGuideOption extends Keyed {
/**
* This returns the {@link SlimefunAddon} which added this {@link SlimefunGuideOption}.
- *
+ *
* @return The registering {@link SlimefunAddon}
*/
@Nonnull
@@ -36,5 +33,4 @@ public interface SlimefunGuideOption extends Keyed {
Optional getSelectedOption(Player p, ItemStack guide);
void setSelectedOption(Player p, ItemStack guide, T value);
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideSettings.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideSettings.java
index df330df332..a1e72830d0 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideSettings.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideSettings.java
@@ -1,18 +1,5 @@
package io.github.thebusybiscuit.slimefun4.core.guide.options;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Optional;
-
-import javax.annotation.Nonnull;
-import javax.annotation.ParametersAreNonnullByDefault;
-
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-import org.bukkit.Material;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.ItemStack;
-
import io.github.bakedlibs.dough.items.CustomItemStack;
import io.github.thebusybiscuit.slimefun4.api.researches.Research;
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
@@ -26,23 +13,35 @@
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
-
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import javax.annotation.ParametersAreNonnullByDefault;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.Material;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
/**
* This static utility class offers various methods that provide access to the
* Settings menu of our {@link SlimefunGuide}.
- *
+ *
* This menu is used to allow a {@link Player} to change things such as the {@link Language}.
- *
+ *
* @author TheBusyBiscuit
- *
+ *
* @see SlimefunGuide
*
*/
public final class SlimefunGuideSettings {
- private static final int[] BACKGROUND_SLOTS = { 1, 3, 5, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 26, 27, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 48, 50, 52, 53 };
+ private static final int[] BACKGROUND_SLOTS = {
+ 1, 3, 5, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 26, 27, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 48,
+ 50, 52, 53
+ };
private static final List> options = new ArrayList<>();
static {
@@ -78,11 +77,13 @@ private static void addHeader(Player p, ChestMenu menu, ItemStack guide) {
LocalizationService locale = Slimefun.getLocalization();
// @formatter:off
- menu.addItem(0, new CustomItemStack(SlimefunGuide.getItem(SlimefunGuideMode.SURVIVAL_MODE),
- "&e\u21E6 " + locale.getMessage(p, "guide.back.title"),
- "",
- "&7" + locale.getMessage(p, "guide.back.guide")
- ));
+ menu.addItem(
+ 0,
+ new CustomItemStack(
+ SlimefunGuide.getItem(SlimefunGuideMode.SURVIVAL_MODE),
+ "&e\u21E6 " + locale.getMessage(p, "guide.back.title"),
+ "",
+ "&7" + locale.getMessage(p, "guide.back.guide")));
// @formatter:on
menu.addMenuClickHandler(0, (pl, slot, item, action) -> {
@@ -94,15 +95,22 @@ private static void addHeader(Player p, ChestMenu menu, ItemStack guide) {
List contributorsLore = new ArrayList<>();
contributorsLore.add("");
- contributorsLore.addAll(locale.getMessages(p, "guide.credits.description", msg -> msg.replace("%contributors%", String.valueOf(github.getContributors().size()))));
+ contributorsLore.addAll(locale.getMessages(
+ p,
+ "guide.credits.description",
+ msg -> msg.replace(
+ "%contributors%",
+ String.valueOf(github.getContributors().size()))));
contributorsLore.add("");
contributorsLore.add("&7\u21E8 &e" + locale.getMessage(p, "guide.credits.open"));
// @formatter:off
- menu.addItem(2, new CustomItemStack(SlimefunUtils.getCustomHead("e952d2b3f351a6b0487cc59db31bf5f2641133e5ba0006b18576e996a0293e52"),
- "&c" + locale.getMessage(p, "guide.title.credits"),
- contributorsLore.toArray(new String[0])
- ));
+ menu.addItem(
+ 2,
+ new CustomItemStack(
+ SlimefunUtils.getCustomHead("e952d2b3f351a6b0487cc59db31bf5f2641133e5ba0006b18576e996a0293e52"),
+ "&c" + locale.getMessage(p, "guide.title.credits"),
+ contributorsLore.toArray(new String[0])));
// @formatter:on
menu.addMenuClickHandler(2, (pl, slot, action, item) -> {
@@ -111,7 +119,10 @@ private static void addHeader(Player p, ChestMenu menu, ItemStack guide) {
});
// @formatter:off
- menu.addItem(4, new CustomItemStack(Material.WRITABLE_BOOK,
+ menu.addItem(
+ 4,
+ new CustomItemStack(
+ Material.WRITABLE_BOOK,
ChatColor.GREEN + locale.getMessage(p, "guide.title.versions"),
"&7&o" + locale.getMessage(p, "guide.tooltips.versions-notice"),
"",
@@ -123,24 +134,26 @@ private static void addHeader(Player p, ChestMenu menu, ItemStack guide) {
"",
"&fMinecraft: &a" + Bukkit.getBukkitVersion(),
"&fSlimefun: &a" + Slimefun.getVersion()),
- ChestMenuUtils.getEmptyClickHandler()
- );
+ ChestMenuUtils.getEmptyClickHandler());
// @formatter:on
// @formatter:off
- menu.addItem(6, new CustomItemStack(Material.COMPARATOR,
- "&e" + locale.getMessage(p, "guide.title.source"),
- "", "&7最近活动于: &a" + NumberUtils.getElapsedTime(github.getLastUpdate()) + " 前",
- "&7Forks: &e" + github.getForks(),
- "&7Stars: &e" + github.getStars(),
- "",
- "&7&oSlimefun 4 是一个由社区参与的项目,",
- "&7&o源代码可以在 GitHub 上找到",
- "&7&o如果你想让这个项目持续下去",
- "&7&o你可以考虑对项目做出贡献",
- "",
- "&7\u21E8 &e点击前往汉化版 GitHub 仓库"
- ));
+ menu.addItem(
+ 6,
+ new CustomItemStack(
+ Material.COMPARATOR,
+ "&e" + locale.getMessage(p, "guide.title.source"),
+ "",
+ "&7最近活动于: &a" + NumberUtils.getElapsedTime(github.getLastUpdate()) + " 前",
+ "&7Forks: &e" + github.getForks(),
+ "&7Stars: &e" + github.getStars(),
+ "",
+ "&7&oSlimefun 4 是一个由社区参与的项目,",
+ "&7&o源代码可以在 GitHub 上找到",
+ "&7&o如果你想让这个项目持续下去",
+ "&7&o你可以考虑对项目做出贡献",
+ "",
+ "&7\u21E8 &e点击前往汉化版 GitHub 仓库"));
// @formatter:on
menu.addMenuClickHandler(6, (pl, slot, item, action) -> {
@@ -150,15 +163,18 @@ private static void addHeader(Player p, ChestMenu menu, ItemStack guide) {
});
// @formatter:off
- menu.addItem(8, new CustomItemStack(Material.KNOWLEDGE_BOOK,
- "&3" + locale.getMessage(p, "guide.title.wiki"),
- "", "&7你需要对物品或机器方面的帮助吗?",
- "&7你不知道要干什么?",
- "&7查看我们的由社区维护的维基",
- "&7并考虑成为一名编辑者!",
- "",
- "&7\u21E8 &e点击前往非官方中文 Wiki"
- ));
+ menu.addItem(
+ 8,
+ new CustomItemStack(
+ Material.KNOWLEDGE_BOOK,
+ "&3" + locale.getMessage(p, "guide.title.wiki"),
+ "",
+ "&7你需要对物品或机器方面的帮助吗?",
+ "&7你不知道要干什么?",
+ "&7查看我们的由社区维护的维基",
+ "&7并考虑成为一名编辑者!",
+ "",
+ "&7\u21E8 &e点击前往非官方中文 Wiki"));
// @formatter:on
menu.addMenuClickHandler(8, (pl, slot, item, action) -> {
@@ -168,17 +184,19 @@ private static void addHeader(Player p, ChestMenu menu, ItemStack guide) {
});
// @formatter:off
- menu.addItem(47, new CustomItemStack(Material.BOOKSHELF,
- "&3" + locale.getMessage(p, "guide.title.addons"),
- "",
- "&7Slimefun 是一个大型项目,但附属插件的存在",
- "&7能让 Slimefun 真正的发光发亮",
- "&7看一看它们,也许你要寻找的附属插件就在那里!",
- "",
- "&7该服务器已安装附属插件: &b" + Slimefun.getInstalledAddons().size(),
- "",
- "&7\u21E8 &e点击查看 Slimefun4 可用的附属插件"
- ));
+ menu.addItem(
+ 47,
+ new CustomItemStack(
+ Material.BOOKSHELF,
+ "&3" + locale.getMessage(p, "guide.title.addons"),
+ "",
+ "&7Slimefun 是一个大型项目,但附属插件的存在",
+ "&7能让 Slimefun 真正的发光发亮",
+ "&7看一看它们,也许你要寻找的附属插件就在那里!",
+ "",
+ "&7该服务器已安装附属插件: &b" + Slimefun.getInstalledAddons().size(),
+ "",
+ "&7\u21E8 &e点击查看 Slimefun4 可用的附属插件"));
// @formatter:on
menu.addMenuClickHandler(47, (pl, slot, item, action) -> {
@@ -189,16 +207,18 @@ private static void addHeader(Player p, ChestMenu menu, ItemStack guide) {
if (Slimefun.getUpdater().getBranch().isOfficial()) {
// @formatter:off
- menu.addItem(49, new CustomItemStack(Material.REDSTONE_TORCH,
- "&4" + locale.getMessage(p, "guide.title.bugs"),
- "",
- "&7&oBug reports have to be made in English!",
- "",
- "&7Open Issues: &a" + github.getOpenIssues(),
- "&7Pending Pull Requests: &a" + github.getPendingPullRequests(),
- "",
- "&7\u21E8 &eClick to go to the Slimefun4 Bug Tracker"
- ));
+ menu.addItem(
+ 49,
+ new CustomItemStack(
+ Material.REDSTONE_TORCH,
+ "&4" + locale.getMessage(p, "guide.title.bugs"),
+ "",
+ "&7&oBug reports have to be made in English!",
+ "",
+ "&7Open Issues: &a" + github.getOpenIssues(),
+ "&7Pending Pull Requests: &a" + github.getPendingPullRequests(),
+ "",
+ "&7\u21E8 &eClick to go to the Slimefun4 Bug Tracker"));
// @formatter:on
menu.addMenuClickHandler(49, (pl, slot, item, action) -> {
@@ -210,10 +230,14 @@ private static void addHeader(Player p, ChestMenu menu, ItemStack guide) {
menu.addItem(49, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler());
}
- menu.addItem(51, new CustomItemStack(Material.TOTEM_OF_UNDYING, ChatColor.RED + locale.getMessage(p, "guide.work-in-progress")), (pl, slot, item, action) -> {
- // Add something here
- return false;
- });
+ menu.addItem(
+ 51,
+ new CustomItemStack(
+ Material.TOTEM_OF_UNDYING, ChatColor.RED + locale.getMessage(p, "guide.work-in-progress")),
+ (pl, slot, item, action) -> {
+ // Add something here
+ return false;
+ });
}
@ParametersAreNonnullByDefault
@@ -239,10 +263,10 @@ private static void addConfigurableOptions(Player p, ChestMenu menu, ItemStack g
* This method checks if the given {@link Player} has enabled the {@link FireworksOption}
* in their {@link SlimefunGuide}.
* If they enabled this setting, they will see fireworks when they unlock a {@link Research}.
- *
+ *
* @param p
* The {@link Player}
- *
+ *
* @return Whether this {@link Player} wants to see fireworks when unlocking a {@link Research}
*/
public static boolean hasFireworksEnabled(@Nonnull Player p) {
@@ -277,11 +301,12 @@ public static boolean hasLearningAnimationEnabled(@Nonnull Player p) {
* Type of the {@link SlimefunGuideOption}
* @param
* Type of the {@link SlimefunGuideOption} value
- *
+ *
* @return The value of given {@link SlimefunGuideOption}
*/
@Nonnull
- private static , V> V getOptionValue(@Nonnull Player p, @Nonnull Class optionsClass, @Nonnull V defaultValue) {
+ private static , V> V getOptionValue(
+ @Nonnull Player p, @Nonnull Class optionsClass, @Nonnull V defaultValue) {
for (SlimefunGuideOption> option : options) {
if (optionsClass.isInstance(option)) {
T o = optionsClass.cast(option);
@@ -292,5 +317,4 @@ private static , V> V getOptionValue(@Nonnull P
return defaultValue;
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/package-info.java
index 14f426c5c6..994c6bde17 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/package-info.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/package-info.java
@@ -3,4 +3,4 @@
* well as the interface {@link io.github.thebusybiscuit.slimefun4.core.guide.options.SlimefunGuideOption} for adding
* your own options
*/
-package io.github.thebusybiscuit.slimefun4.core.guide.options;
\ No newline at end of file
+package io.github.thebusybiscuit.slimefun4.core.guide.options;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/package-info.java
index 0d47912f05..4c1d020299 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/package-info.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/package-info.java
@@ -2,4 +2,4 @@
* This package contains the core system for the {@link io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide}.
* Note that you can find the individual implementations of the guide, in the implementation package
*/
-package io.github.thebusybiscuit.slimefun4.core.guide;
\ No newline at end of file
+package io.github.thebusybiscuit.slimefun4.core.guide;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockBreakHandler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockBreakHandler.java
index 7bd704a509..60affc23b5 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockBreakHandler.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockBreakHandler.java
@@ -1,29 +1,26 @@
package io.github.thebusybiscuit.slimefun4.core.handlers;
+import io.github.thebusybiscuit.slimefun4.api.events.AndroidMineEvent;
+import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler;
+import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
+import io.github.thebusybiscuit.slimefun4.implementation.items.androids.MinerAndroid;
import java.util.List;
-
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
-
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack;
-import io.github.thebusybiscuit.slimefun4.api.events.AndroidMineEvent;
-import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler;
-import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
-import io.github.thebusybiscuit.slimefun4.implementation.items.androids.MinerAndroid;
-
/**
* The {@link BlockBreakHandler} is called when a {@link Block} is broken
* which holds a {@link SlimefunItem}.
* The {@link BlockBreakHandler} provides three methods for this, one for block breaking
* caused by a {@link Player}, one for a {@link MinerAndroid} and one method for a {@link Block}
* being destroyed by an explosion.
- *
+ *
* @author TheBusyBiscuit
- *
+ *
* @see BlockPlaceHandler
*
*/
@@ -41,7 +38,7 @@ public abstract class BlockBreakHandler implements ItemHandler {
/**
* This constructs a new {@link BlockBreakHandler}.
- *
+ *
* @param allowAndroids
* Whether a {@link MinerAndroid} is allowed to break blocks of this type
* @param allowExplosions
@@ -67,7 +64,7 @@ public void onAndroidBreak(AndroidMineEvent e) {
/**
* This returns whether an explosion is able to break the given {@link Block}.
- *
+ *
* @param b
* The {@link Block}
* @return Whether explosions can destroy this {@link Block}
@@ -83,10 +80,10 @@ public boolean isExplosionAllowed(@Nonnull Block b) {
/**
* This returns whether a {@link MinerAndroid} is allowed to break
* the given {@link Block}.
- *
+ *
* @param b
* The {@link Block}
- *
+ *
* @return Whether androids can break the given {@link Block}
*/
public boolean isAndroidAllowed(@Nonnull Block b) {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockDispenseHandler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockDispenseHandler.java
index 8f10c0fa97..8884884c55 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockDispenseHandler.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockDispenseHandler.java
@@ -1,29 +1,27 @@
package io.github.thebusybiscuit.slimefun4.core.handlers;
-import java.util.Optional;
-
-import org.bukkit.Material;
-import org.bukkit.block.Block;
-import org.bukkit.block.Dispenser;
-import org.bukkit.event.block.BlockDispenseEvent;
-
import io.github.thebusybiscuit.slimefun4.api.exceptions.IncompatibleItemHandlerException;
import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable;
import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.BlockPlacer;
+import java.util.Optional;
+import org.bukkit.Material;
+import org.bukkit.block.Block;
+import org.bukkit.block.Dispenser;
+import org.bukkit.event.block.BlockDispenseEvent;
/**
* This {@link ItemHandler} is triggered when the {@link SlimefunItem} it was assigned to
* is a {@link Dispenser} and was triggered.
- *
+ *
* This {@link ItemHandler} is used for the {@link BlockPlacer}.
- *
+ *
* @author TheBusyBiscuit
*
* @see ItemHandler
* @see BlockPlacer
- *
+ *
*/
@FunctionalInterface
public interface BlockDispenseHandler extends ItemHandler {
@@ -31,7 +29,10 @@ public interface BlockDispenseHandler extends ItemHandler {
@Override
default Optional validate(SlimefunItem item) {
if (item instanceof NotPlaceable || item.getItem().getType() != Material.DISPENSER) {
- return Optional.of(new IncompatibleItemHandlerException("Only dispensers that are not marked as 'NotPlaceable' can have a BlockDispenseHandler.", item, this));
+ return Optional.of(new IncompatibleItemHandlerException(
+ "Only dispensers that are not marked as 'NotPlaceable' can have a" + " BlockDispenseHandler.",
+ item,
+ this));
}
return Optional.empty();
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockPlaceHandler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockPlaceHandler.java
index e2cb771bfc..b660ea7e47 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockPlaceHandler.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockPlaceHandler.java
@@ -1,21 +1,19 @@
package io.github.thebusybiscuit.slimefun4.core.handlers;
-import javax.annotation.Nonnull;
-
-import org.bukkit.block.Block;
-import org.bukkit.entity.Player;
-import org.bukkit.event.block.BlockPlaceEvent;
-
import io.github.thebusybiscuit.slimefun4.api.events.BlockPlacerPlaceEvent;
import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.BlockPlacer;
+import javax.annotation.Nonnull;
+import org.bukkit.block.Block;
+import org.bukkit.entity.Player;
+import org.bukkit.event.block.BlockPlaceEvent;
/**
* This {@link ItemHandler} is called whenever a {@link Block} was placed.
* This only listens to any {@link Block} of the same {@link SlimefunItem} this is assigned
* to.
- *
+ *
* @author TheBusyBiscuit
*
*/
@@ -29,7 +27,7 @@ protected BlockPlaceHandler(boolean allowBlockPlacers) {
/**
* This method is called whenever a {@link Player} placed this {@link Block}.
- *
+ *
* @param e
* The corresponding {@link BlockPlaceEvent}
*/
@@ -40,7 +38,7 @@ protected BlockPlaceHandler(boolean allowBlockPlacers) {
* You cannot cancel the {@link BlockPlacerPlaceEvent} from within this method!
* Override the method {@link #isBlockPlacerAllowed()} instead if you want to disallow the
* {@link BlockPlacer} from placing this {@link Block}.
- *
+ *
* @param e
* The corresponding {@link BlockPlacerPlaceEvent}
*/
@@ -50,7 +48,7 @@ public void onBlockPlacerPlace(@Nonnull BlockPlacerPlaceEvent e) {
/**
* This returns whether the {@link BlockPlacer} is allowed to place a {@link Block} of this type.
- *
+ *
* @return Whether a {@link BlockPlacer} is allowed to place this
*/
public boolean isBlockPlacerAllowed() {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockUseHandler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockUseHandler.java
index 7dde59c45e..a9401c6410 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockUseHandler.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockUseHandler.java
@@ -5,7 +5,6 @@
import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable;
-
import java.util.Optional;
@FunctionalInterface
@@ -16,7 +15,8 @@ public interface BlockUseHandler extends ItemHandler {
@Override
default Optional validate(SlimefunItem item) {
if (item instanceof NotPlaceable || !item.getItem().getType().isBlock()) {
- return Optional.of(new IncompatibleItemHandlerException("Only blocks that are not marked as 'NotPlaceable' can have a BlockUseHandler.", item, this));
+ return Optional.of(new IncompatibleItemHandlerException(
+ "Only blocks that are not marked as 'NotPlaceable' can have a BlockUseHandler.", item, this));
}
return Optional.empty();
@@ -26,5 +26,4 @@ default Optional validate(SlimefunItem item) {
default Class extends ItemHandler> getIdentifier() {
return BlockUseHandler.class;
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BowShootHandler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BowShootHandler.java
index f2c5aa7df0..fb7a65d995 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BowShootHandler.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BowShootHandler.java
@@ -1,25 +1,23 @@
package io.github.thebusybiscuit.slimefun4.core.handlers;
-import java.util.Optional;
-
-import org.bukkit.Material;
-import org.bukkit.entity.LivingEntity;
-import org.bukkit.event.entity.EntityDamageByEntityEvent;
-
import io.github.thebusybiscuit.slimefun4.api.exceptions.IncompatibleItemHandlerException;
import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.implementation.items.weapons.SlimefunBow;
+import java.util.Optional;
+import org.bukkit.Material;
+import org.bukkit.entity.LivingEntity;
+import org.bukkit.event.entity.EntityDamageByEntityEvent;
/**
* This {@link ItemHandler} is triggered when the {@link SlimefunItem} it was assigned to
* is a {@link SlimefunBow} and an Arrow fired from this bow hit a {@link LivingEntity}.
- *
+ *
* @author TheBusyBiscuit
*
* @see ItemHandler
* @see SlimefunBow
- *
+ *
*/
@FunctionalInterface
public interface BowShootHandler extends ItemHandler {
@@ -29,7 +27,8 @@ public interface BowShootHandler extends ItemHandler {
@Override
default Optional validate(SlimefunItem item) {
if (item.getItem().getType() != Material.BOW) {
- return Optional.of(new IncompatibleItemHandlerException("Only bows can have a BowShootHandler.", item, this));
+ return Optional.of(
+ new IncompatibleItemHandlerException("Only bows can have a BowShootHandler.", item, this));
}
return Optional.empty();
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/EntityInteractHandler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/EntityInteractHandler.java
index 1091d3a335..67c6022330 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/EntityInteractHandler.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/EntityInteractHandler.java
@@ -1,5 +1,9 @@
package io.github.thebusybiscuit.slimefun4.core.handlers;
+import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler;
+import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
+import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
+import io.github.thebusybiscuit.slimefun4.implementation.listeners.entity.EntityInteractionListener;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
@@ -7,11 +11,6 @@
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
-import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler;
-import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
-import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
-import io.github.thebusybiscuit.slimefun4.implementation.listeners.entity.EntityInteractionListener;
-
/**
* This is triggered when a {@link Player} interacts with an {@link Entity}.
*
@@ -42,4 +41,4 @@ public interface EntityInteractHandler extends ItemHandler {
default Class extends ItemHandler> getIdentifier() {
return EntityInteractHandler.class;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/EntityKillHandler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/EntityKillHandler.java
index 21ec3c0179..2437566dfc 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/EntityKillHandler.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/EntityKillHandler.java
@@ -1,24 +1,23 @@
package io.github.thebusybiscuit.slimefun4.core.handlers;
+import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler;
+import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
+import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.inventory.ItemStack;
-import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler;
-import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
-import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
-
/**
* If this {@link ItemHandler} is added to a {@link SlimefunItem} it will listen
* for any {@link EntityDeathEvent} that was triggered by a {@link Player} using
* the {@link SlimefunItem} this {@link EntityKillHandler} was linked to.
- *
+ *
* @author TheBusyBiscuit
*
* @see ItemHandler
* @see SimpleSlimefunItem
- *
+ *
*/
@FunctionalInterface
public interface EntityKillHandler extends ItemHandler {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/GlobalItemHandler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/GlobalItemHandler.java
index 3716eff948..1d0051e2d1 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/GlobalItemHandler.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/GlobalItemHandler.java
@@ -1,10 +1,9 @@
package io.github.thebusybiscuit.slimefun4.core.handlers;
-import org.bukkit.event.Event;
-import org.bukkit.event.Listener;
-
import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
+import org.bukkit.event.Event;
+import org.bukkit.event.Listener;
/**
* A {@link GlobalItemHandler} is a special type of {@link ItemHandler}
@@ -16,6 +15,4 @@
* @see ItemDropHandler
*
*/
-public interface GlobalItemHandler extends ItemHandler {
-
-}
\ No newline at end of file
+public interface GlobalItemHandler extends ItemHandler {}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ItemConsumptionHandler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ItemConsumptionHandler.java
index 69a5d44089..1648e8072d 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ItemConsumptionHandler.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ItemConsumptionHandler.java
@@ -1,29 +1,28 @@
package io.github.thebusybiscuit.slimefun4.core.handlers;
-import org.bukkit.entity.Player;
-import org.bukkit.event.player.PlayerItemConsumeEvent;
-import org.bukkit.inventory.ItemStack;
-
import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import io.github.thebusybiscuit.slimefun4.implementation.items.food.DietCookie;
import io.github.thebusybiscuit.slimefun4.implementation.items.food.FortuneCookie;
+import org.bukkit.entity.Player;
+import org.bukkit.event.player.PlayerItemConsumeEvent;
+import org.bukkit.inventory.ItemStack;
/**
* This {@link ItemHandler} is triggered when the {@link SlimefunItem} it was assigned to
* has been consumed.
- *
+ *
* This {@link ItemHandler} only works for food or potions.
- *
+ *
* @author TheBusyBiscuit
*
* @see ItemHandler
* @see SimpleSlimefunItem
- *
+ *
* @see FortuneCookie
* @see DietCookie
- *
+ *
*/
@FunctionalInterface
public interface ItemConsumptionHandler extends ItemHandler {
@@ -31,7 +30,7 @@ public interface ItemConsumptionHandler extends ItemHandler {
/**
* This method gets fired whenever a {@link PlayerItemConsumeEvent} involving this
* {@link SlimefunItem} has been triggered.
- *
+ *
* @param e
* The {@link PlayerItemConsumeEvent} that was fired
* @param p
@@ -45,5 +44,4 @@ public interface ItemConsumptionHandler extends ItemHandler {
default Class extends ItemHandler> getIdentifier() {
return ItemConsumptionHandler.class;
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ItemDropHandler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ItemDropHandler.java
index a0e6efbb6a..2e30ab3d54 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ItemDropHandler.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ItemDropHandler.java
@@ -1,17 +1,15 @@
package io.github.thebusybiscuit.slimefun4.core.handlers;
+import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler;
import javax.annotation.ParametersAreNonnullByDefault;
-
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerDropItemEvent;
-import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler;
-
/**
* The {@link ItemDropHandler} is a {@link GlobalItemHandler} which listens to
* an {@link Item} being dropped.
- *
+ *
* @author Linox
* @author TheBusyBiscuit
*
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ItemUseHandler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ItemUseHandler.java
index 987699bcf1..21e09b1132 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ItemUseHandler.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ItemUseHandler.java
@@ -22,5 +22,4 @@ public interface ItemUseHandler extends ItemHandler {
default Class extends ItemHandler> getIdentifier() {
return ItemUseHandler.class;
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/MultiBlockInteractionHandler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/MultiBlockInteractionHandler.java
index 0ae90600bd..5c6936bed2 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/MultiBlockInteractionHandler.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/MultiBlockInteractionHandler.java
@@ -1,24 +1,22 @@
package io.github.thebusybiscuit.slimefun4.core.handlers;
-import java.util.Optional;
-
-import org.bukkit.block.Block;
-import org.bukkit.entity.Player;
-
import io.github.thebusybiscuit.slimefun4.api.exceptions.IncompatibleItemHandlerException;
import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlock;
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
+import java.util.Optional;
+import org.bukkit.block.Block;
+import org.bukkit.entity.Player;
/**
* This {@link ItemHandler} is called whenever a {@link Player} interacts with
* this {@link MultiBlock}.
* Note that this {@link MultiBlockInteractionHandler} should be assigned to
* a class that inherits from {@link MultiBlockMachine}.
- *
+ *
* @author TheBusyBiscuit
- *
+ *
* @see ItemHandler
* @see MultiBlock
* @see MultiBlockMachine
@@ -32,7 +30,8 @@ public interface MultiBlockInteractionHandler extends ItemHandler {
@Override
default Optional validate(SlimefunItem item) {
if (!(item instanceof MultiBlockMachine)) {
- return Optional.of(new IncompatibleItemHandlerException("Only classes inheriting 'MultiBlockMachine' can have a MultiBlockInteractionHandler", item, this));
+ return Optional.of(new IncompatibleItemHandlerException(
+ "Only classes inheriting 'MultiBlockMachine' can have a MultiBlockInteractionHandler", item, this));
}
return Optional.empty();
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/RainbowTickHandler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/RainbowTickHandler.java
index 82572a8bc6..bd84a5a514 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/RainbowTickHandler.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/RainbowTickHandler.java
@@ -7,6 +7,9 @@
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.RainbowBlock;
import io.github.thebusybiscuit.slimefun4.utils.ColoredMaterial;
+import java.util.Arrays;
+import java.util.List;
+import javax.annotation.Nonnull;
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker;
import org.apache.commons.lang.Validate;
import org.bukkit.Material;
@@ -15,17 +18,13 @@
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.type.GlassPane;
-import javax.annotation.Nonnull;
-import java.util.Arrays;
-import java.util.List;
-
/**
* This is a {@link BlockTicker} that is exclusively used for Rainbow blocks.
* On every tick it cycles through the {@link LoopIterator} and chooses the next {@link Material}
* and sets itself to that.
- *
+ *
* @author TheBusyBiscuit
- *
+ *
* @see RainbowBlock
*
*/
@@ -60,10 +59,10 @@ public RainbowTickHandler(@Nonnull ColoredMaterial material) {
* that would result in a {@link GlassPane} {@link BlockData}.
* This is done to save performance, so we don't have to validate {@link BlockData} at
* runtime.
- *
+ *
* @param materials
* The {@link Material} Array to check
- *
+ *
* @return Whether the array contained any {@link GlassPane} materials
*/
private boolean containsGlassPanes(@Nonnull List materials) {
@@ -74,10 +73,10 @@ private boolean containsGlassPanes(@Nonnull List materials) {
for (Material type : materials) {
/*
- This BlockData is purely virtual and only created on startup, it should have
- no impact on performance, in fact it should save performance as it preloads
- the data but also saves heavy calls for other Materials
- */
+ This BlockData is purely virtual and only created on startup, it should have
+ no impact on performance, in fact it should save performance as it preloads
+ the data but also saves heavy calls for other Materials
+ */
if (type.createBlockData() instanceof GlassPane) {
return true;
}
@@ -90,9 +89,9 @@ private boolean containsGlassPanes(@Nonnull List materials) {
public void tick(Block b, SlimefunItem item, SlimefunBlockData data) {
if (b.getType().isAir()) {
/*
- The block was broken, setting the Material now would result in a
- duplication glitch
- */
+ The block was broken, setting the Material now would result in a
+ duplication glitch
+ */
return;
}
@@ -127,5 +126,4 @@ public void uniqueTick() {
public boolean isSynchronized() {
return true;
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ToolUseHandler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ToolUseHandler.java
index 579b5f5749..646c08325c 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ToolUseHandler.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ToolUseHandler.java
@@ -1,19 +1,17 @@
package io.github.thebusybiscuit.slimefun4.core.handlers;
+import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler;
+import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import java.util.List;
-
import org.bukkit.block.Block;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack;
-import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler;
-import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
-
/**
* This {@link ItemHandler} is called when a {@link Block} is broken with a {@link SlimefunItem}
* as its tool.
- *
+ *
* @author TheBusyBiscuit
*
* @see BlockBreakHandler
@@ -25,7 +23,7 @@ public interface ToolUseHandler extends ItemHandler {
/**
* This method is called whenever a {@link BlockBreakEvent} was fired when using this
* {@link SlimefunItem} to break a {@link Block}.
- *
+ *
* @param e
* The {@link BlockBreakEvent}
* @param tool
@@ -34,7 +32,7 @@ public interface ToolUseHandler extends ItemHandler {
* The amount of bonus drops to be expected from the fortune {@link Enchantment}.
* @param drops
* The dropped items
- *
+ *
*/
void onToolUse(BlockBreakEvent e, ItemStack tool, int fortune, List drops);
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/WeaponUseHandler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/WeaponUseHandler.java
index 81c40c69e5..30ce24818a 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/WeaponUseHandler.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/WeaponUseHandler.java
@@ -1,15 +1,13 @@
package io.github.thebusybiscuit.slimefun4.core.handlers;
+import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler;
+import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import javax.annotation.Nonnull;
-
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.inventory.ItemStack;
-import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler;
-import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
-
/**
* This is triggered when a {@link Player} attacks an {@link Entity}.
*
@@ -35,5 +33,4 @@ public interface WeaponUseHandler extends ItemHandler {
default Class extends ItemHandler> getIdentifier() {
return WeaponUseHandler.class;
}
-
-}
\ No newline at end of file
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/package-info.java
index d3c439ec1e..f20f02802b 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/package-info.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/package-info.java
@@ -2,4 +2,4 @@
* This package contains all variations of {@link io.github.thebusybiscuit.slimefun4.api.items.ItemHandler} that
* can be assigned to a {@link io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem}
*/
-package io.github.thebusybiscuit.slimefun4.core.handlers;
\ No newline at end of file
+package io.github.thebusybiscuit.slimefun4.core.handlers;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/machines/MachineOperation.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/machines/MachineOperation.java
index 2e80f4bebd..55da36772d 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/machines/MachineOperation.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/machines/MachineOperation.java
@@ -56,5 +56,4 @@ default int getRemainingTicks() {
default boolean isFinished() {
return getRemainingTicks() <= 0;
}
-
-}
\ No newline at end of file
+}
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 2294acccd5..d503fac907 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
@@ -1,11 +1,14 @@
package io.github.thebusybiscuit.slimefun4.core.machines;
+import io.github.bakedlibs.dough.blocks.BlockPosition;
+import io.github.thebusybiscuit.slimefun4.api.events.AsyncMachineOperationFinishEvent;
+import io.github.thebusybiscuit.slimefun4.core.attributes.MachineProcessHolder;
+import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-
+import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@@ -13,13 +16,6 @@
import org.bukkit.event.Event;
import org.bukkit.inventory.ItemStack;
-import io.github.bakedlibs.dough.blocks.BlockPosition;
-import io.github.thebusybiscuit.slimefun4.api.events.AsyncMachineOperationFinishEvent;
-import io.github.thebusybiscuit.slimefun4.core.attributes.MachineProcessHolder;
-import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
-
-import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
-
/**
* A {@link MachineProcessor} manages different {@link MachineOperation}s and handles
* their progress.
@@ -67,8 +63,7 @@ public MachineProcessHolder getOwner() {
*
* @return The progress bar icon or null
*/
- @Nullable
- public ItemStack getProgressBar() {
+ @Nullable public ItemStack getProgressBar() {
return progressBar;
}
@@ -145,8 +140,7 @@ public boolean startOperation(@Nonnull BlockPosition pos, @Nonnull T operation)
*
* @return The current {@link MachineOperation} or null.
*/
- @Nullable
- public T getOperation(@Nonnull Location loc) {
+ @Nullable public T getOperation(@Nonnull Location loc) {
Validate.notNull(loc, "The location cannot be null");
return getOperation(new BlockPosition(loc));
@@ -160,8 +154,7 @@ public T getOperation(@Nonnull Location loc) {
*
* @return The current {@link MachineOperation} or null.
*/
- @Nullable
- public T getOperation(@Nonnull Block b) {
+ @Nullable public T getOperation(@Nonnull Block b) {
Validate.notNull(b, "The Block cannot be null");
return getOperation(new BlockPosition(b));
@@ -177,8 +170,7 @@ public T getOperation(@Nonnull Block b) {
*
* @return The current {@link MachineOperation} or null.
*/
- @Nullable
- public T getOperation(@Nonnull BlockPosition pos) {
+ @Nullable public T getOperation(@Nonnull BlockPosition pos) {
Validate.notNull(pos, "The BlockPosition must not be null");
return machines.get(pos);
@@ -262,5 +254,4 @@ public void updateProgressBar(@Nonnull BlockMenu inv, int slot, @Nonnull T opera
ChestMenuUtils.updateProgressbar(inv, slot, remainingTicks, totalTicks, getProgressBar());
}
}
-
-}
\ No newline at end of file
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/machines/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/machines/package-info.java
index af07c73dce..3da041fda6 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/machines/package-info.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/machines/package-info.java
@@ -3,4 +3,4 @@
* {@link io.github.thebusybiscuit.slimefun4.core.machines.MachineProcessor}
* and any {@link io.github.thebusybiscuit.slimefun4.core.machines.MachineOperation}.
*/
-package io.github.thebusybiscuit.slimefun4.core.machines;
\ No newline at end of file
+package io.github.thebusybiscuit.slimefun4.core.machines;
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 4175b20527..f0f709629d 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
@@ -1,31 +1,28 @@
package io.github.thebusybiscuit.slimefun4.core.multiblocks;
+import io.github.thebusybiscuit.slimefun4.api.events.MultiBlockInteractEvent;
+import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
+import io.github.thebusybiscuit.slimefun4.core.handlers.MultiBlockInteractionHandler;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
-
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-
import org.apache.commons.lang.Validate;
import org.bukkit.Material;
import org.bukkit.Tag;
import org.bukkit.World;
import org.bukkit.block.BlockFace;
-import io.github.thebusybiscuit.slimefun4.api.events.MultiBlockInteractEvent;
-import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
-import io.github.thebusybiscuit.slimefun4.core.handlers.MultiBlockInteractionHandler;
-
/**
* A {@link MultiBlock} represents a structure build in a {@link World}.
* A {@link MultiBlock} is often linked to a {@link MultiBlockMachine} and is used
* to recognize that machine in a {@link MultiBlockInteractEvent}.
- *
+ *
* @author TheBusyBiscuit
* @author Liruxo
- *
+ *
* @see MultiBlockMachine
* @see MultiBlockInteractionHandler
* @see MultiBlockInteractEvent
@@ -143,12 +140,13 @@ private boolean compareBlocks(Material a, @Nullable Material b) {
/**
* This returns whether this {@link MultiBlock} is a symmetric structure or whether
* the left and right side differ.
- *
+ *
* @return Whether this {@link MultiBlock} is a symmetric structure
*/
public boolean isSymmetric() {
return isSymmetric;
}
+
@Override
public String toString() {
return "MultiBlock (" + item.getId() + ") {" + Arrays.toString(blocks) + "}";
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 c7d9f1f369..348027af20 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
@@ -1,18 +1,28 @@
package io.github.thebusybiscuit.slimefun4.core.multiblocks;
+import com.google.common.base.Preconditions;
+import io.github.bakedlibs.dough.inventory.InvUtils;
+import io.github.bakedlibs.dough.protection.Interaction;
+import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
+import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
+import io.github.thebusybiscuit.slimefun4.api.items.ItemSpawnReason;
+import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
+import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
+import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
+import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable;
+import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
+import io.github.thebusybiscuit.slimefun4.core.handlers.MultiBlockInteractionHandler;
+import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
+import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.OutputChest;
+import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
-
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
-
-import com.google.common.base.Preconditions;
-
import org.apache.commons.lang.Validate;
-
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
@@ -23,27 +33,12 @@
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
-import io.github.bakedlibs.dough.inventory.InvUtils;
-import io.github.bakedlibs.dough.protection.Interaction;
-import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
-import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
-import io.github.thebusybiscuit.slimefun4.api.items.ItemSpawnReason;
-import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
-import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
-import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
-import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable;
-import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
-import io.github.thebusybiscuit.slimefun4.core.handlers.MultiBlockInteractionHandler;
-import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
-import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.OutputChest;
-import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
-
/**
* A {@link MultiBlockMachine} is a {@link SlimefunItem} that is built in the {@link World}.
* It holds recipes and a {@link MultiBlock} object which represents its structure.
- *
+ *
* @author TheBusyBiscuit
- *
+ *
* @see MultiBlock
*
*/
@@ -54,7 +49,12 @@ public abstract class MultiBlockMachine extends SlimefunItem implements NotPlace
protected final MultiBlock multiblock;
@ParametersAreNonnullByDefault
- protected MultiBlockMachine(ItemGroup itemGroup, SlimefunItemStack item, ItemStack[] recipe, ItemStack[] machineRecipes, BlockFace trigger) {
+ protected MultiBlockMachine(
+ ItemGroup itemGroup,
+ SlimefunItemStack item,
+ ItemStack[] recipe,
+ ItemStack[] machineRecipes,
+ BlockFace trigger) {
super(itemGroup, item, RecipeType.MULTIBLOCK, recipe);
this.recipes = new ArrayList<>();
this.displayRecipes = new ArrayList<>();
@@ -90,7 +90,7 @@ public void addRecipe(ItemStack[] input, ItemStack output) {
Validate.notNull(output, "Recipes must have an Output!");
recipes.add(input);
- recipes.add(new ItemStack[] { output });
+ recipes.add(new ItemStack[] {output});
}
public void clearRecipe() {
@@ -112,7 +112,8 @@ public void postRegister() {
public void load() {
super.load();
- Preconditions.checkArgument(displayRecipes.size() % 2 == 0, "This MultiBlockMachine's display recipes were illegally modified!");
+ Preconditions.checkArgument(
+ displayRecipes.size() % 2 == 0, "This MultiBlockMachine's display recipes were illegally modified!");
for (int i = 0; i < displayRecipes.size(); i += 2) {
ItemStack inputStack = displayRecipes.get(i);
@@ -125,8 +126,8 @@ public void load() {
SlimefunItem outputItem = SlimefunItem.getByItem(outputStack);
// If the input/output is not a Slimefun item or it's not disabled then it's valid.
if ((inputItem == null || !inputItem.isDisabled()) && (outputItem == null || !outputItem.isDisabled())) {
- recipes.add(new ItemStack[] { inputStack });
- recipes.add(new ItemStack[] { outputStack });
+ recipes.add(new ItemStack[] {inputStack});
+ recipes.add(new ItemStack[] {outputStack});
}
}
}
@@ -134,7 +135,9 @@ public void load() {
protected @Nonnull MultiBlockInteractionHandler getInteractionHandler() {
return (p, mb, b) -> {
if (mb.equals(getMultiBlock())) {
- if (canUse(p, true) && Slimefun.getProtectionManager().hasPermission(p, b.getLocation(), Interaction.INTERACT_BLOCK)) {
+ if (canUse(p, true)
+ && Slimefun.getProtectionManager()
+ .hasPermission(p, b.getLocation(), Interaction.INTERACT_BLOCK)) {
onInteract(p, b);
}
@@ -152,24 +155,24 @@ public void load() {
* Fallbacks to the old system of putting the adding back into the dispenser.
* Optional last argument Inventory placeCheckerInv is for a {@link MultiBlockMachine} that create
* a dummy inventory to check if there's a space for the adding, i.e. Enhanced crafting table
- *
+ *
* @param adding
* The {@link ItemStack} that should be added
* @param dispBlock
* The {@link Block} of our {@link Dispenser}
* @param dispInv
* The {@link Inventory} of our {@link Dispenser}
- *
+ *
* @return The target {@link Inventory}
*/
-
@ParametersAreNonnullByDefault
protected @Nullable Inventory findOutputInventory(ItemStack adding, Block dispBlock, Inventory dispInv) {
return findOutputInventory(adding, dispBlock, dispInv, dispInv);
}
@ParametersAreNonnullByDefault
- protected @Nullable Inventory findOutputInventory(ItemStack product, Block dispBlock, Inventory dispInv, Inventory placeCheckerInv) {
+ protected @Nullable Inventory findOutputInventory(
+ ItemStack product, Block dispBlock, Inventory dispInv, Inventory placeCheckerInv) {
Optional outputChest = OutputChest.findOutputChestFor(dispBlock, product);
/*
@@ -226,5 +229,4 @@ protected void handleCraftedItem(ItemStack outputItem, Block block, Inventory bl
return materials.toArray(new Material[0]);
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/package-info.java
index 23867e7f6a..5456678716 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/package-info.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/package-info.java
@@ -2,4 +2,4 @@
* This package holds all core mechanics related to a
* {@link io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlock}, like that class itself.
*/
-package io.github.thebusybiscuit.slimefun4.core.multiblocks;
\ No newline at end of file
+package io.github.thebusybiscuit.slimefun4.core.multiblocks;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/NetworkManager.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/NetworkManager.java
index 7757f9bd95..c079881a81 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/NetworkManager.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/NetworkManager.java
@@ -26,10 +26,10 @@
/**
* The {@link NetworkManager} is responsible for holding all instances of {@link Network}
* and providing some utility methods that would have probably been static otherwise.
- *
+ *
* @author TheBusyBiscuit
* @author meiamsome
- *
+ *
* @see Network
* @see NetworkListener
*
@@ -42,7 +42,7 @@ public class NetworkManager {
/**
* Fixes #3041
- *
+ *
* We use a {@link CopyOnWriteArrayList} here to ensure thread-safety.
* This {@link List} is also much more frequently read than being written to.
* Therefore a {@link CopyOnWriteArrayList} should be perfect for this, even
@@ -52,7 +52,7 @@ public class NetworkManager {
/**
* This creates a new {@link NetworkManager} with the given capacity.
- *
+ *
* @param maxStepSize
* The maximum amount of nodes a {@link Network} can have
* @param enableVisualizer
@@ -70,7 +70,7 @@ public NetworkManager(int maxStepSize, boolean enableVisualizer, boolean deleteE
/**
* This creates a new {@link NetworkManager} with the given capacity.
- *
+ *
* @param maxStepSize
* The maximum amount of nodes a {@link Network} can have
*/
@@ -81,7 +81,7 @@ public NetworkManager(int maxStepSize) {
/**
* This method returns the limit of nodes a {@link Network} can have.
* This value is read from the {@link Config} file.
- *
+ *
* @return the maximum amount of nodes a {@link Network} can have
*/
public int getMaxSize() {
@@ -90,7 +90,7 @@ public int getMaxSize() {
/**
* This returns whether the {@link Network} visualizer is enabled.
- *
+ *
* @return Whether the {@link Network} visualizer is enabled
*/
public boolean isVisualizerEnabled() {
@@ -100,7 +100,7 @@ public boolean isVisualizerEnabled() {
/**
* This returns whether excess items from a {@link CargoNet} should be voided
* instead of being dropped to the ground.
- *
+ *
* @return Whether to delete excess items
*/
public boolean isItemDeletionEnabled() {
@@ -110,7 +110,7 @@ public boolean isItemDeletionEnabled() {
/**
* This returns a {@link List} of every {@link Network} on the {@link Server}.
* The returned {@link List} is not modifiable.
- *
+ *
* @return A {@link List} containing every {@link Network} on the {@link Server}
*/
@Nonnull
@@ -156,28 +156,31 @@ public List getNetworksFromLocation(@Nullable Location l,
/**
* This registers a given {@link Network}.
- *
+ *
* @param network
* The {@link Network} to register
*/
public void registerNetwork(@Nonnull Network network) {
Validate.notNull(network, "Cannot register a null Network");
- Debug.log(TestCase.ENERGYNET, "Registering network @ " + LocationUtils.locationToString(network.getRegulator()));
+ Debug.log(
+ TestCase.ENERGYNET, "Registering network @ " + LocationUtils.locationToString(network.getRegulator()));
networks.add(network);
}
/**
* This removes a {@link Network} from the network system.
- *
+ *
* @param network
* The {@link Network} to remove
*/
public void unregisterNetwork(@Nonnull Network network) {
Validate.notNull(network, "Cannot unregister a null Network");
- Debug.log(TestCase.ENERGYNET, "Unregistering network @ " + LocationUtils.locationToString(network.getRegulator()));
+ Debug.log(
+ TestCase.ENERGYNET,
+ "Unregistering network @ " + LocationUtils.locationToString(network.getRegulator()));
networks.remove(network);
}
@@ -185,7 +188,7 @@ public void unregisterNetwork(@Nonnull Network network) {
/**
* This method updates every {@link Network} found at the given {@link Location}.
* More precisely, {@link Network#markDirty(Location)} will be called.
- *
+ *
* @param l
* The {@link Location} to update
*/
@@ -206,7 +209,7 @@ public void updateAllNetworks(@Nonnull Location l) {
/*
* Only a Slimefun block can be part of a Network.
* This check helps to speed up performance.
- *
+ *
* (Skip for Unit Tests as they don't support block info yet)
*/
if (!StorageCacheUtils.hasBlock(l) && Slimefun.getMinecraftVersion() != MinecraftVersion.UNIT_TEST) {
@@ -218,8 +221,11 @@ public void updateAllNetworks(@Nonnull Location l) {
network.markDirty(l);
}
} catch (Exception x) {
- Slimefun.logger().log(Level.SEVERE, x, () -> "An Exception was thrown while causing a networks update @ " + new BlockPosition(l));
+ Slimefun.logger()
+ .log(
+ Level.SEVERE,
+ x,
+ () -> "An Exception was thrown while causing a networks update @ " + new BlockPosition(l));
}
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/AbstractItemNetwork.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/AbstractItemNetwork.java
index 2cce2bb796..6431327ae7 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/AbstractItemNetwork.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/AbstractItemNetwork.java
@@ -1,14 +1,17 @@
package io.github.thebusybiscuit.slimefun4.core.networks.cargo;
+import io.github.thebusybiscuit.slimefun4.api.network.Network;
+import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
+import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
-
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
-
+import me.mrCookieSlime.Slimefun.api.inventory.DirtyChestMenu;
+import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
@@ -17,17 +20,10 @@
import org.bukkit.block.data.Directional;
import org.bukkit.inventory.ItemStack;
-import io.github.thebusybiscuit.slimefun4.api.network.Network;
-import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
-import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
-
-import me.mrCookieSlime.Slimefun.api.inventory.DirtyChestMenu;
-import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
-
/**
* An abstract super class of {@link CargoNet} that handles
* interactions with ChestTerminal.
- *
+ *
* @author TheBusyBiscuit
*
*/
@@ -59,7 +55,8 @@ protected Optional getAttachedBlock(@Nonnull Location l) {
return Optional.of(block.getRelative(cached));
}
- BlockFace face = ((Directional) block.getBlockData()).getFacing().getOppositeFace();
+ BlockFace face =
+ ((Directional) block.getBlockData()).getFacing().getOppositeFace();
connectorCache.put(l, face);
return Optional.of(block.getRelative(face));
}
@@ -77,7 +74,7 @@ public void markDirty(@Nonnull Location l) {
/**
* This will mark the {@link ItemFilter} of the given node dirty.
* It will also invalidate the cached rotation.
- *
+ *
* @param node
* The {@link Location} of the cargo node
*/
@@ -131,5 +128,4 @@ private void filter(@Nullable ItemStack stack, List items,
return filter;
}
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNet.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNet.java
index b3ca0c5b35..5b399d65c7 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNet.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNet.java
@@ -7,13 +7,6 @@
import io.github.thebusybiscuit.slimefun4.api.network.NetworkComponent;
import io.github.thebusybiscuit.slimefun4.core.attributes.HologramOwner;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
-import org.bukkit.Bukkit;
-import org.bukkit.Location;
-import org.bukkit.block.Block;
-import org.bukkit.inventory.ItemStack;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
@@ -22,12 +15,18 @@
import java.util.Optional;
import java.util.Set;
import java.util.logging.Level;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.block.Block;
+import org.bukkit.inventory.ItemStack;
/**
* The {@link CargoNet} is a type of {@link Network} which deals with {@link ItemStack} transportation.
* It is also an extension of {@link AbstractItemNetwork} which provides methods to deal
* with the addon ChestTerminal.
- *
+ *
* @author meiamsome
* @author Poslovitch
* @author John000708
@@ -49,7 +48,9 @@ public class CargoNet extends AbstractItemNetwork implements HologramOwner {
private int tickDelayThreshold = 0;
public static @Nullable CargoNet getNetworkFromLocation(@Nonnull Location l) {
- return Slimefun.getNetworkManager().getNetworkFromLocation(l, CargoNet.class).orElse(null);
+ return Slimefun.getNetworkManager()
+ .getNetworkFromLocation(l, CargoNet.class)
+ .orElse(null);
}
public static @Nonnull CargoNet getNetworkFromLocationOrCreate(@Nonnull Location l) {
@@ -66,7 +67,7 @@ public class CargoNet extends AbstractItemNetwork implements HologramOwner {
/**
* This constructs a new {@link CargoNet} at the given {@link Location}.
- *
+ *
* @param l
* The {@link Location} marking the manager of this {@link Network}.
*/
@@ -95,9 +96,7 @@ public NetworkComponent classifyLocation(@Nonnull Location l) {
return switch (data.getSfId()) {
case "CARGO_MANAGER" -> NetworkComponent.REGULATOR;
case "CARGO_NODE" -> NetworkComponent.CONNECTOR;
- case "CARGO_NODE_INPUT",
- "CARGO_NODE_OUTPUT",
- "CARGO_NODE_OUTPUT_ADVANCED" -> NetworkComponent.TERMINUS;
+ case "CARGO_NODE_INPUT", "CARGO_NODE_OUTPUT", "CARGO_NODE_OUTPUT_ADVANCED" -> NetworkComponent.TERMINUS;
default -> null;
};
}
@@ -115,8 +114,7 @@ public void onClassificationChange(Location l, NetworkComponent from, NetworkCom
var data = StorageCacheUtils.getBlock(l);
switch (data.getSfId()) {
case "CARGO_NODE_INPUT" -> inputNodes.add(l);
- case "CARGO_NODE_OUTPUT",
- "CARGO_NODE_OUTPUT_ADVANCED" -> outputNodes.add(l);
+ case "CARGO_NODE_OUTPUT", "CARGO_NODE_OUTPUT_ADVANCED" -> outputNodes.add(l);
default -> {}
}
}
@@ -216,10 +214,10 @@ public void tick(@Nonnull Block b) {
* This method returns the frequency a given node is set to.
* Should there be invalid data this method it will fall back to zero in
* order to preserve the integrity of the {@link CargoNet}.
- *
+ *
* @param node
* The {@link Location} of our cargo node
- *
+ *
* @return The frequency of the given node
*/
private static int getFrequency(@Nonnull Location node) {
@@ -238,7 +236,19 @@ private static int getFrequency(@Nonnull Location node) {
if (frequency == null) {
return 0;
} else if (!CommonPatterns.NUMERIC.matcher(frequency).matches()) {
- Slimefun.logger().log(Level.SEVERE, () -> "Failed to parse a Cargo Node Frequency (" + node.getWorld().getName() + " - " + node.getBlockX() + ',' + node.getBlockY() + ',' + node.getBlockZ() + "): " + frequency);
+ Slimefun.logger()
+ .log(
+ Level.SEVERE,
+ () -> "Failed to parse a Cargo Node Frequency ("
+ + node.getWorld().getName()
+ + " - "
+ + node.getBlockX()
+ + ','
+ + node.getBlockY()
+ + ','
+ + node.getBlockZ()
+ + "): "
+ + frequency);
return 0;
} else {
return Integer.parseInt(frequency);
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 4c7f65d6d5..e008392b9b 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
@@ -9,14 +9,6 @@
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper;
-import me.mrCookieSlime.Slimefun.api.inventory.DirtyChestMenu;
-import org.bukkit.Location;
-import org.bukkit.block.Block;
-import org.bukkit.inventory.Inventory;
-import org.bukkit.inventory.ItemStack;
-
-import javax.annotation.Nullable;
-import javax.annotation.ParametersAreNonnullByDefault;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
@@ -27,15 +19,22 @@
import java.util.Objects;
import java.util.Optional;
import java.util.logging.Level;
+import javax.annotation.Nullable;
+import javax.annotation.ParametersAreNonnullByDefault;
+import me.mrCookieSlime.Slimefun.api.inventory.DirtyChestMenu;
+import org.bukkit.Location;
+import org.bukkit.block.Block;
+import org.bukkit.inventory.Inventory;
+import org.bukkit.inventory.ItemStack;
/**
* The {@link CargoNetworkTask} is the actual {@link Runnable} responsible for moving {@link ItemStack ItemStacks}
* around the {@link CargoNet}.
- *
+ *
* Inbefore this was just a method in the {@link CargoNet} class.
* However for aesthetic reasons but mainly to prevent the Cargo Task from showing up as
* "lambda:xyz-123" in timing reports... this was moved.
- *
+ *
* @see CargoNet
* @see CargoUtils
* @see AbstractItemNetwork
@@ -80,7 +79,12 @@ public void run() {
timestamp += Slimefun.getProfiler().closeEntry(entry.getKey(), inputNode, nodeTimestamp);
}
} catch (Exception | LinkageError x) {
- Slimefun.logger().log(Level.SEVERE, x, () -> "An Exception was caught while ticking a Cargo network @ " + new BlockPosition(network.getRegulator()));
+ Slimefun.logger()
+ .log(
+ Level.SEVERE,
+ x,
+ () -> "An Exception was caught while ticking a Cargo network @ "
+ + new BlockPosition(network.getRegulator()));
}
// Submit a timings report
@@ -88,7 +92,8 @@ public void run() {
}
@ParametersAreNonnullByDefault
- private void routeItems(Location inputNode, Block inputTarget, int frequency, Map> outputNodes) {
+ private void routeItems(
+ Location inputNode, Block inputTarget, int frequency, Map> outputNodes) {
ItemStackAndInteger slot = CargoUtils.withdraw(network, inventories, inputNode.getBlock(), inputTarget);
if (slot == null) {
@@ -122,7 +127,8 @@ private void insertItem(Block inputTarget, int previousSlot, ItemStack item) {
if (rest != null && !manager.isItemDeletionEnabled()) {
// If the item still couldn't be inserted, simply drop it on the ground
- SlimefunUtils.spawnItem(inputTarget.getLocation().add(0, 1, 0), rest, ItemSpawnReason.CARGO_OVERFLOW);
+ SlimefunUtils.spawnItem(
+ inputTarget.getLocation().add(0, 1, 0), rest, ItemSpawnReason.CARGO_OVERFLOW);
}
}
} else {
@@ -132,14 +138,14 @@ private void insertItem(Block inputTarget, int previousSlot, ItemStack item) {
if (menu.getItemInSlot(previousSlot) == null) {
menu.replaceExistingItem(previousSlot, item);
} else if (!manager.isItemDeletionEnabled()) {
- SlimefunUtils.spawnItem(inputTarget.getLocation().add(0, 1, 0), item, ItemSpawnReason.CARGO_OVERFLOW);
+ SlimefunUtils.spawnItem(
+ inputTarget.getLocation().add(0, 1, 0), item, ItemSpawnReason.CARGO_OVERFLOW);
}
}
}
}
- @Nullable
- @ParametersAreNonnullByDefault
+ @Nullable @ParametersAreNonnullByDefault
private ItemStack distributeItem(ItemStack stack, Location inputNode, List outputNodes) {
ItemStack item = stack;
@@ -172,7 +178,8 @@ private ItemStack distributeItem(ItemStack stack, Location inputNode, List outputNodes) {
}
}
}
-
}
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 a13c4ce23d..53ab71a358 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
@@ -11,6 +11,9 @@
import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper;
import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
import io.papermc.lib.PaperLib;
+import java.util.Map;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
import me.mrCookieSlime.Slimefun.api.inventory.DirtyChestMenu;
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
@@ -26,15 +29,11 @@
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-import java.util.Map;
-
/**
* This is a helper class for the {@link CargoNet} which provides
* a free static utility methods to let the {@link CargoNet} interact with
* an {@link Inventory} or {@link BlockMenu}.
- *
+ *
* @author TheBusyBiscuit
* @author Walshy
* @author DNx5
@@ -45,7 +44,7 @@ final class CargoUtils {
/**
* These are the slots where our filter items sit.
*/
- private static final int[] FILTER_SLOTS = { 19, 20, 21, 28, 29, 30, 37, 38, 39 };
+ private static final int[] FILTER_SLOTS = {19, 20, 21, 28, 29, 30, 37, 38, 39};
/**
* This is a utility class and should not be instantiated.
@@ -56,10 +55,10 @@ private CargoUtils() {}
/**
* This is a performance-saving shortcut to quickly test whether a given
* {@link Block} might be an {@link InventoryHolder} or not.
- *
+ *
* @param block
* The {@link Block} to check
- *
+ *
* @return Whether this {@link Block} represents a {@link BlockState} that is an {@link InventoryHolder}
*/
static boolean hasInventory(@Nullable Block block) {
@@ -78,27 +77,27 @@ static int[] getInputSlotRange(@Nonnull Inventory inv, @Nullable ItemStack item)
if (item != null && item.getType().isFuel()) {
if (isSmeltable(item, true)) {
// Any non-smeltable items should not land in the upper slot
- return new int[] { 0, 2 };
+ return new int[] {0, 2};
} else {
- return new int[] { 1, 2 };
+ return new int[] {1, 2};
}
} else {
- return new int[] { 0, 1 };
+ return new int[] {0, 1};
}
} else if (inv instanceof BrewerInventory) {
if (isPotion(item)) {
// Slots for potions
- return new int[] { 0, 3 };
+ return new int[] {0, 3};
} else if (item != null && item.getType() == Material.BLAZE_POWDER) {
// Blaze Powder slot
- return new int[] { 4, 5 };
+ return new int[] {4, 5};
} else {
// Input slot
- return new int[] { 3, 4 };
+ return new int[] {3, 4};
}
} else {
// Slot 0-size
- return new int[] { 0, inv.getSize() };
+ return new int[] {0, inv.getSize()};
}
}
@@ -106,18 +105,22 @@ static int[] getInputSlotRange(@Nonnull Inventory inv, @Nullable ItemStack item)
static int[] getOutputSlotRange(@Nonnull Inventory inv) {
if (inv instanceof FurnaceInventory) {
// Slot 2-3
- return new int[] { 2, 3 };
+ return new int[] {2, 3};
} else if (inv instanceof BrewerInventory) {
// Slot 0-3
- return new int[] { 0, 3 };
+ return new int[] {0, 3};
} else {
// Slot 0-size
- return new int[] { 0, inv.getSize() };
+ return new int[] {0, inv.getSize()};
}
}
- @Nullable
- static ItemStack withdraw(AbstractItemNetwork network, Map inventories, Block node, Block target, ItemStack template) {
+ @Nullable static ItemStack withdraw(
+ AbstractItemNetwork network,
+ Map inventories,
+ Block node,
+ Block target,
+ ItemStack template) {
DirtyChestMenu menu = getChestMenu(target);
if (menu == null) {
@@ -150,7 +153,8 @@ static ItemStack withdraw(AbstractItemNetwork network, Map
ItemStackWrapper wrapperItemInSlot = ItemStackWrapper.wrap(is);
- if (SlimefunUtils.isItemSimilar(wrapperItemInSlot, wrapperTemplate, true) && matchesFilter(network, node, wrapperItemInSlot)) {
+ if (SlimefunUtils.isItemSimilar(wrapperItemInSlot, wrapperTemplate, true)
+ && matchesFilter(network, node, wrapperItemInSlot)) {
if (is.getAmount() > template.getAmount()) {
is.setAmount(is.getAmount() - template.getAmount());
menu.replaceExistingItem(slot, is);
@@ -165,8 +169,8 @@ static ItemStack withdraw(AbstractItemNetwork network, Map
return null;
}
- @Nullable
- static ItemStack withdrawFromVanillaInventory(AbstractItemNetwork network, Block node, ItemStack template, Inventory inv) {
+ @Nullable static ItemStack withdrawFromVanillaInventory(
+ AbstractItemNetwork network, Block node, ItemStack template, Inventory inv) {
ItemStack[] contents = inv.getContents();
int[] range = getOutputSlotRange(inv);
int minSlot = range[0];
@@ -182,7 +186,8 @@ static ItemStack withdrawFromVanillaInventory(AbstractItemNetwork network, Block
}
ItemStackWrapper wrapperInSlot = ItemStackWrapper.wrap(itemInSlot);
- if (SlimefunUtils.isItemSimilar(wrapperInSlot, wrapper, true, false) && matchesFilter(network, node, wrapperInSlot)) {
+ if (SlimefunUtils.isItemSimilar(wrapperInSlot, wrapper, true, false)
+ && matchesFilter(network, node, wrapperInSlot)) {
if (itemInSlot.getAmount() > template.getAmount()) {
itemInSlot.setAmount(itemInSlot.getAmount() - template.getAmount());
return template;
@@ -197,8 +202,8 @@ static ItemStack withdrawFromVanillaInventory(AbstractItemNetwork network, Block
return null;
}
- @Nullable
- static ItemStackAndInteger withdraw(AbstractItemNetwork network, Map inventories, Block node, Block target) {
+ @Nullable static ItemStackAndInteger withdraw(
+ AbstractItemNetwork network, Map inventories, Block node, Block target) {
DirtyChestMenu menu = getChestMenu(target);
if (menu != null) {
@@ -239,8 +244,8 @@ static ItemStackAndInteger withdraw(AbstractItemNetwork network, Map inventories, Block node, Block target, boolean smartFill, ItemStack stack, ItemStackWrapper wrapper) {
+ @Nullable static ItemStack insert(
+ AbstractItemNetwork network,
+ Map inventories,
+ Block node,
+ Block target,
+ boolean smartFill,
+ ItemStack stack,
+ ItemStackWrapper wrapper) {
Debug.log(TestCase.CARGO_INPUT_TESTING, "CargoUtils#insert");
if (!matchesFilter(network, node, stack)) {
return stack;
@@ -333,8 +344,8 @@ static ItemStack insert(AbstractItemNetwork network, Map in
return stack;
}
- @Nullable
- private static ItemStack insertIntoVanillaInventory(@Nonnull ItemStack stack, @Nonnull ItemStackWrapper wrapper, boolean smartFill, @Nonnull Inventory inv) {
+ @Nullable private static ItemStack insertIntoVanillaInventory(
+ @Nonnull ItemStack stack, @Nonnull ItemStackWrapper wrapper, boolean smartFill, @Nonnull Inventory inv) {
/*
* If the Inventory does not accept this Item Type, bounce the item back.
* Example: Shulker boxes within shulker boxes (fixes #2662)
@@ -386,8 +397,7 @@ private static ItemStack insertIntoVanillaInventory(@Nonnull ItemStack stack, @N
return stack;
}
- @Nullable
- static DirtyChestMenu getChestMenu(@Nonnull Block block) {
+ @Nullable static DirtyChestMenu getChestMenu(@Nonnull Block block) {
return StorageCacheUtils.getMenu(block.getLocation());
}
@@ -404,12 +414,12 @@ static boolean matchesFilter(@Nonnull AbstractItemNetwork network, @Nonnull Bloc
* The lazy-option is a performance-saver since actually calculating this can be quite expensive.
* For the current applicational purposes a quick check for any wooden logs is sufficient.
* Otherwise the "lazyness" can be turned off in the future.
- *
+ *
* @param stack
* The {@link ItemStack} to test
* @param lazy
* Whether or not to perform a "lazy" but performance-saving check
- *
+ *
* @return Whether the given {@link ItemStack} can be smelted or not
*/
private static boolean isSmeltable(@Nullable ItemStack stack, boolean lazy) {
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 315406b943..a04e87cbb1 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
@@ -10,23 +10,22 @@
import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.CargoNode;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper;
-import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
-import org.bukkit.Material;
-import org.bukkit.block.Block;
-import org.bukkit.inventory.ItemStack;
-
-import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.function.Predicate;
+import javax.annotation.Nonnull;
+import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
+import org.bukkit.Material;
+import org.bukkit.block.Block;
+import org.bukkit.inventory.ItemStack;
/**
* The {@link ItemFilter} is a performance-optimization for our {@link CargoNet}.
* It is a snapshot of a cargo node's configuration.
- *
+ *
* @author TheBusyBiscuit
- *
+ *
* @see CargoNet
* @see CargoNetworkTask
*
@@ -64,7 +63,7 @@ class ItemFilter implements Predicate {
/**
* This creates a new {@link ItemFilter} for the given {@link Block}.
* This will copy all settings from that {@link Block} to this filter.
- *
+ *
* @param b
* The {@link Block}
*/
@@ -75,7 +74,7 @@ public ItemFilter(@Nonnull Block b) {
/**
* This updates or refreshes the {@link ItemFilter} to copy the settings
* from the given {@link Block}. It takes a new snapshot.
- *
+ *
* @param b
* The {@link Block}
*/
@@ -89,16 +88,15 @@ public void update(@Nonnull Block b) {
update(blockData);
} else {
isLoading = true;
- Slimefun.getDatabaseManager().getBlockDataController().loadBlockDataAsync(
- blockData,
- new IAsyncReadCallback<>() {
+ Slimefun.getDatabaseManager()
+ .getBlockDataController()
+ .loadBlockDataAsync(blockData, new IAsyncReadCallback<>() {
@Override
public void onResult(SlimefunBlockData result) {
update(blockData);
isLoading = false;
}
- }
- );
+ });
}
}
@@ -131,7 +129,10 @@ private void update(SlimefunBlockData blockData) {
* However if that ever happens again, we will know the reason and be able
* to send a warning in response to it.
*/
- item.warn("Cargo Node was marked as a 'filtering' node but has an insufficient inventory size (" + inventorySize + ")");
+ item.warn("Cargo Node was marked as a 'filtering' node but has an insufficient inventory size"
+ + " ("
+ + inventorySize
+ + ")");
return;
}
@@ -158,7 +159,7 @@ private void update(SlimefunBlockData blockData) {
/**
* This will clear the {@link ItemFilter} and reject any
* {@link ItemStack}.
- *
+ *
* @param rejectOnMatch
* Whether the item should be rejected on matches
*/
@@ -170,7 +171,7 @@ private void clear(boolean rejectOnMatch) {
/**
* Whether this {@link ItemFilter} is outdated and needs to be refreshed.
- *
+ *
* @return Whether the filter is outdated.
*/
public boolean isDirty() {
@@ -243,5 +244,4 @@ public boolean test(@Nonnull ItemStack item) {
return rejectOnMatch;
}
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemStackAndInteger.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemStackAndInteger.java
index 6ed5e6621d..4842e25be9 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemStackAndInteger.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemStackAndInteger.java
@@ -1,12 +1,10 @@
package io.github.thebusybiscuit.slimefun4.core.networks.cargo;
+import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper;
import javax.annotation.Nonnull;
-
import org.apache.commons.lang.Validate;
import org.bukkit.inventory.ItemStack;
-import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper;
-
class ItemStackAndInteger {
private ItemStack item;
@@ -49,5 +47,4 @@ private void initializeItem() {
this.item = copy;
}
}
-
-}
\ No newline at end of file
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/package-info.java
index 96c7abbb70..2db100dad9 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/package-info.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/package-info.java
@@ -2,4 +2,4 @@
* This package holds an implementation of {@link io.github.thebusybiscuit.slimefun4.api.network.Network}
* that is responsible for item transportation.
*/
-package io.github.thebusybiscuit.slimefun4.core.networks.cargo;
\ No newline at end of file
+package io.github.thebusybiscuit.slimefun4.core.networks.cargo;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/EnergyNet.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/EnergyNet.java
index 0ca42bf1f1..c64a1f36f6 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/EnergyNet.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/EnergyNet.java
@@ -29,10 +29,10 @@
/**
* The {@link EnergyNet} is an implementation of {@link Network} that deals with
* electrical energy being sent from and to nodes.
- *
+ *
* @author meiamsome
* @author TheBusyBiscuit
- *
+ *
* @see Network
* @see EnergyNetComponent
* @see EnergyNetProvider
@@ -100,10 +100,8 @@ public NetworkComponent classifyLocation(@Nonnull Location l) {
return null;
} else {
return switch (component.getEnergyComponentType()) {
- case CONNECTOR,
- CAPACITOR -> NetworkComponent.CONNECTOR;
- case CONSUMER,
- GENERATOR -> NetworkComponent.TERMINUS;
+ case CONNECTOR, CAPACITOR -> NetworkComponent.CONNECTOR;
+ case CONSUMER, GENERATOR -> NetworkComponent.TERMINUS;
default -> null;
};
}
@@ -130,7 +128,8 @@ public void onClassificationChange(Location l, NetworkComponent from, NetworkCom
if (component instanceof EnergyNetProvider provider) {
generators.put(l, provider);
} else if (component instanceof SlimefunItem item) {
- item.warn("This Item is marked as a GENERATOR but does not implement the interface EnergyNetProvider!");
+ item.warn("This Item is marked as a GENERATOR but does not implement the interface"
+ + " EnergyNetProvider!");
}
break;
default:
@@ -144,7 +143,8 @@ public void tick(@Nonnull Block b) {
if (!regulator.equals(b.getLocation())) {
updateHologram(b, "&4检测到附近有其他调节器");
- Slimefun.getProfiler().closeEntry(b.getLocation(), SlimefunItems.ENERGY_REGULATOR.getItem(), timestamp.get());
+ Slimefun.getProfiler()
+ .closeEntry(b.getLocation(), SlimefunItems.ENERGY_REGULATOR.getItem(), timestamp.get());
return;
}
@@ -324,8 +324,7 @@ private void updateHologram(@Nonnull Block b, double supply, double demand) {
}
}
- @Nullable
- private static EnergyNetComponent getComponent(@Nonnull Location l) {
+ @Nullable private static EnergyNetComponent getComponent(@Nonnull Location l) {
SlimefunItem item = StorageCacheUtils.getSfItem(l);
if (item instanceof EnergyNetComponent component) {
@@ -344,18 +343,19 @@ private static EnergyNetComponent getComponent(@Nonnull Location l) {
*
* @return The {@link EnergyNet} at that {@link Location}, or {@code null}
*/
- @Nullable
- public static EnergyNet getNetworkFromLocation(@Nonnull Location l) {
- return Slimefun.getNetworkManager().getNetworkFromLocation(l, EnergyNet.class).orElse(null);
+ @Nullable public static EnergyNet getNetworkFromLocation(@Nonnull Location l) {
+ return Slimefun.getNetworkManager()
+ .getNetworkFromLocation(l, EnergyNet.class)
+ .orElse(null);
}
/**
* This attempts to get an {@link EnergyNet} from a given {@link Location}.
* If no suitable {@link EnergyNet} could be found, a new one will be created.
- *
+ *
* @param l
* The target {@link Location}
- *
+ *
* @return The {@link EnergyNet} at that {@link Location}, or a new one
*/
@Nonnull
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 0f1fc00852..5623e80160 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
@@ -4,7 +4,6 @@
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.Capacitor;
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.EnergyConnector;
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.Reactor;
-
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator;
import org.bukkit.block.Block;
@@ -49,5 +48,4 @@ public enum EnergyNetComponentType {
* other options.
*/
NONE;
-
-}
\ No newline at end of file
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/package-info.java
index d5061d1036..34694e2608 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/package-info.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/package-info.java
@@ -2,4 +2,4 @@
* This package holds an implementation of {@link io.github.thebusybiscuit.slimefun4.api.network.Network}
* that is responsible for transmitting energy.
*/
-package io.github.thebusybiscuit.slimefun4.core.networks.energy;
\ No newline at end of file
+package io.github.thebusybiscuit.slimefun4.core.networks.energy;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/package-info.java
index 5f4e747aff..81163d607e 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/package-info.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/package-info.java
@@ -3,4 +3,4 @@
* class, such as the {@link io.github.thebusybiscuit.slimefun4.core.networks.NetworkManager} and also the subpackages
* for actual implementations of the {@link io.github.thebusybiscuit.slimefun4.api.network.Network} class.
*/
-package io.github.thebusybiscuit.slimefun4.core.networks;
\ No newline at end of file
+package io.github.thebusybiscuit.slimefun4.core.networks;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/package-info.java
index 4a303ab0e0..4c27464ee3 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/package-info.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/package-info.java
@@ -2,4 +2,4 @@
* This package holds the core systems of Slimefun, these are not necessarily used as an API
* but rather provide the core functionality of this {@link org.bukkit.plugin.Plugin}.
*/
-package io.github.thebusybiscuit.slimefun4.core;
\ No newline at end of file
+package io.github.thebusybiscuit.slimefun4.core;
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 06e4c27d68..cd80124363 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
@@ -2,17 +2,16 @@
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
-import org.bukkit.block.Block;
-import org.bukkit.entity.Player;
-
-import javax.annotation.Nonnull;
import java.util.Iterator;
import java.util.logging.Level;
+import javax.annotation.Nonnull;
+import org.bukkit.block.Block;
+import org.bukkit.entity.Player;
/**
* This Service is responsible for automatically saving {@link Player} and {@link Block}
* data.
- *
+ *
* @author TheBusyBiscuit
*
*/
@@ -22,7 +21,7 @@ public class AutoSavingService {
/**
* This method starts the {@link AutoSavingService} with the given interval.
- *
+ *
* @param plugin
* The current instance of Slimefun
* @param interval
@@ -32,12 +31,15 @@ public void start(@Nonnull Slimefun plugin, int interval) {
this.interval = interval;
plugin.getServer().getScheduler().runTaskTimer(plugin, this::saveAllPlayers, 2000L, interval * 60L * 20L);
- plugin.getServer().getScheduler().runTaskTimerAsynchronously(
- plugin,
- () -> Slimefun.getDatabaseManager().getBlockDataController().saveAllBlockInventories(),
- 2000L,
- interval * 60L * 20L
- );
+ plugin.getServer()
+ .getScheduler()
+ .runTaskTimerAsynchronously(
+ plugin,
+ () -> Slimefun.getDatabaseManager()
+ .getBlockDataController()
+ .saveAllBlockInventories(),
+ 2000L,
+ interval * 60L * 20L);
}
/**
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 e00d1c2982..a64354d6c9 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
@@ -2,9 +2,6 @@
import com.xzavier0722.mc.plugin.slimefun4.storage.controller.StorageType;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
-import org.apache.commons.lang.Validate;
-
-import javax.annotation.Nonnull;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -19,10 +16,12 @@
import java.util.logging.Level;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
+import javax.annotation.Nonnull;
+import org.apache.commons.lang.Validate;
/**
* This Service creates a Backup of your Slimefun world data on every server shutdown.
- *
+ *
* @author TheBusyBiscuit
*
*/
@@ -76,7 +75,12 @@ public void run() {
Slimefun.logger().log(Level.WARNING, "无法创建备份文件: {0}", file.getName());
}
} catch (IOException x) {
- Slimefun.logger().log(Level.SEVERE, x, () -> "An Exception occurred while creating a backup for Slimefun " + Slimefun.getVersion());
+ Slimefun.logger()
+ .log(
+ Level.SEVERE,
+ x,
+ () -> "An Exception occurred while creating a backup for Slimefun "
+ + Slimefun.getVersion());
}
}
}
@@ -109,7 +113,8 @@ private void addFile(ZipOutputStream output, File file, String path) throws IOEx
output.closeEntry();
}
- private void addDirectory(@Nonnull ZipOutputStream output, @Nonnull File directory, @Nonnull String zipPath) throws IOException {
+ private void addDirectory(@Nonnull ZipOutputStream output, @Nonnull File directory, @Nonnull String zipPath)
+ throws IOException {
for (File file : directory.listFiles()) {
addFile(output, file, zipPath);
}
@@ -117,17 +122,19 @@ private void addDirectory(@Nonnull ZipOutputStream output, @Nonnull File directo
/**
* This method will delete old backups.
- *
+ *
* @param backups
* The {@link List} of all backups
- *
+ *
* @throws IOException
* An {@link IOException} is thrown if a {@link File} could not be deleted
*/
private void purgeBackups(@Nonnull List backups) throws IOException {
Collections.sort(backups, (a, b) -> {
- LocalDateTime time1 = LocalDateTime.parse(a.getName().substring(0, a.getName().length() - 4), format);
- LocalDateTime time2 = LocalDateTime.parse(b.getName().substring(0, b.getName().length() - 4), format);
+ LocalDateTime time1 =
+ LocalDateTime.parse(a.getName().substring(0, a.getName().length() - 4), format);
+ LocalDateTime time2 =
+ LocalDateTime.parse(b.getName().substring(0, b.getName().length() - 4), format);
return time2.compareTo(time1);
});
@@ -136,5 +143,4 @@ private void purgeBackups(@Nonnull List backups) throws IOException {
Files.delete(backups.get(i).toPath());
}
}
-
}
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 69c9579286..f2bde71bb3 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
@@ -1,12 +1,12 @@
package io.github.thebusybiscuit.slimefun4.core.services;
+import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
+import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
+import io.papermc.lib.PaperLib;
import java.util.Optional;
import java.util.logging.Level;
-
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-
-import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import org.bukkit.Keyed;
@@ -20,15 +20,12 @@
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.Plugin;
-import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
-import io.papermc.lib.PaperLib;
-
/**
* The {@link BlockDataService} is similar to the {@link CustomItemDataService},
* it is responsible for storing NBT data inside a {@link TileState}.
- *
+ *
* This is used to speed up performance and prevent
- *
+ *
* @author TheBusyBiscuit
*
*/
@@ -40,7 +37,7 @@ public class BlockDataService implements Keyed {
* This creates a new {@link BlockDataService} for the given {@link Plugin}.
* The {@link Plugin} and key will together form a {@link NamespacedKey} used to store
* data on a {@link TileState}.
- *
+ *
* @param plugin
* The {@link Plugin} responsible for this service
* @param key
@@ -57,7 +54,7 @@ public NamespacedKey getKey() {
/**
* This will store the given {@link String} inside the NBT data of the given {@link Block}
- *
+ *
* @param b
* The {@link Block} in which to store the given value
* @param value
@@ -82,19 +79,26 @@ public void setBlockData(@Nonnull Block b, @Nonnull String value) {
Slimefun.logger().log(Level.SEVERE, "Please check if your Server Software is up to date!");
String serverSoftware = PaperLib.isSpigot() && !PaperLib.isPaper() ? "Spigot" : Bukkit.getName();
- Slimefun.logger().log(Level.SEVERE, () -> serverSoftware + " | " + Bukkit.getVersion() + " | " + Bukkit.getBukkitVersion());
-
- Slimefun.logger().log(Level.SEVERE, "An Exception was thrown while trying to set Persistent Data for a Block", x);
+ Slimefun.logger()
+ .log(
+ Level.SEVERE,
+ () -> serverSoftware + " | " + Bukkit.getVersion() + " | " + Bukkit.getBukkitVersion());
+
+ Slimefun.logger()
+ .log(
+ Level.SEVERE,
+ "An Exception was thrown while trying to set Persistent Data for a Block",
+ x);
}
}
}
/**
* This method returns the NBT data previously stored inside this {@link Block}.
- *
+ *
* @param b
* The {@link Block} to retrieve data from
- *
+ *
* @return The stored value
*/
public Optional getBlockData(@Nonnull Block b) {
@@ -110,8 +114,7 @@ public Optional getBlockData(@Nonnull Block b) {
}
}
- @Nullable
- private PersistentDataContainer getPersistentDataContainer(@Nonnull BlockState state) {
+ @Nullable private PersistentDataContainer getPersistentDataContainer(@Nonnull BlockState state) {
if (state instanceof TileState tileState) {
return tileState.getPersistentDataContainer();
} else {
@@ -123,13 +126,13 @@ private PersistentDataContainer getPersistentDataContainer(@Nonnull BlockState s
* This method checks whether the given {@link Material} is a Tile Entity.
* This is used to determine whether the {@link Block} produced by this {@link Material}
* produces a {@link TileState}, making it useable as a {@link PersistentDataHolder}.
- *
+ *
* Due to {@link Block#getState()} being a very expensive call performance-wise though,
* this simple lookup method is used instead.
- *
+ *
* @param type
* The {@link Material} to check for
- *
+ *
* @return Whether the given {@link Material} is considered a Tile Entity
*/
public boolean isTileEntity(@Nullable Material type) {
@@ -140,5 +143,4 @@ public boolean isTileEntity(@Nullable Material type) {
return SlimefunTag.TILE_ENTITIES.isTagged(type);
}
-
-}
\ No newline at end of file
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/CustomItemDataService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/CustomItemDataService.java
index e9617b7eec..ad16ded8f3 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/CustomItemDataService.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/CustomItemDataService.java
@@ -1,10 +1,10 @@
package io.github.thebusybiscuit.slimefun4.core.services;
+import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
+import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
import java.util.Optional;
-
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-
import org.apache.commons.lang.Validate;
import org.bukkit.Keyed;
import org.bukkit.Material;
@@ -15,16 +15,13 @@
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.Plugin;
-import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
-import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
-
/**
* This Service is responsible for applying NBT data to a {@link SlimefunItemStack}.
* This is used to ensure that the id of a {@link SlimefunItem} is stored alongside any
* {@link ItemStack} at all times.
- *
+ *
* @author TheBusyBiscuit
- *
+ *
* @see SlimefunItemStack
*
*/
@@ -38,7 +35,7 @@ public class CustomItemDataService implements Keyed {
/**
* This creates a new {@link CustomItemDataService} for the given {@link Plugin} and the
* provided data key.
- *
+ *
* @param plugin
* The {@link Plugin} for this service to use
* @param key
@@ -57,7 +54,7 @@ public NamespacedKey getKey() {
/**
* This method stores the given id on the provided {@link ItemStack} via
* persistent data.
- *
+ *
* @param item
* The {@link ItemStack} to store data on
* @param id
@@ -75,7 +72,7 @@ public void setItemData(@Nonnull ItemStack item, @Nonnull String id) {
/**
* This method stores the given id on the provided {@link ItemMeta} via
* persistent data.
- *
+ *
* @param meta
* The {@link ItemMeta} to store data on
* @param id
@@ -93,10 +90,10 @@ public void setItemData(@Nonnull ItemMeta meta, @Nonnull String id) {
* This method returns an {@link Optional} holding the data stored on the given {@link ItemStack}.
* The {@link Optional} will be empty if the given {@link ItemStack} is null, doesn't have any {@link ItemMeta}
* or if the requested data simply does not exist on that {@link ItemStack}.
- *
+ *
* @param item
* The {@link ItemStack} to check
- *
+ *
* @return An {@link Optional} describing the result
*/
public @Nonnull Optional getItemData(@Nullable ItemStack item) {
@@ -110,10 +107,10 @@ public void setItemData(@Nonnull ItemMeta meta, @Nonnull String id) {
/**
* This method returns an {@link Optional}, either empty or holding the data stored
* on the given {@link ItemMeta}.
- *
+ *
* @param meta
* The {@link ItemMeta} to check
- *
+ *
* @return An {@link Optional} describing the result
*/
public @Nonnull Optional getItemData(@Nonnull ItemMeta meta) {
@@ -127,12 +124,12 @@ public void setItemData(@Nonnull ItemMeta meta, @Nonnull String id) {
* This method compares the custom data stored on two {@link ItemMeta} objects.
* This method will only return {@literal true} if both {@link ItemMeta}s contain
* custom data and if both of their data values are equal.
- *
+ *
* @param meta1
* The first {@link ItemMeta}
* @param meta2
* The second {@link ItemMeta}
- *
+ *
* @return Whether both metas have data on them and its the same.
*/
public boolean hasEqualItemData(@Nonnull ItemMeta meta1, @Nonnull ItemMeta meta2) {
@@ -157,5 +154,4 @@ public boolean hasEqualItemData(@Nonnull ItemMeta meta1, @Nonnull ItemMeta meta2
return false;
}
}
-
}
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 5d55e8b03c..0cbc47ae4b 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
@@ -1,26 +1,23 @@
package io.github.thebusybiscuit.slimefun4.core.services;
+import io.github.bakedlibs.dough.config.Config;
+import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
+import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
+import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.logging.Level;
-
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-
import org.apache.commons.lang.Validate;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
-import io.github.bakedlibs.dough.config.Config;
-import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
-import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
-import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
-
/**
* This Service is responsible for applying custom model data to any {@link SlimefunItemStack}
* if a Server Owner configured Slimefun to use those.
@@ -57,7 +54,14 @@ public class CustomTextureService {
*/
public CustomTextureService(@Nonnull 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.\n0 means there is no data assigned to that item.\n\n" + "There is no official Slimefun resource pack at the moment.");
+ 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.");
config.getConfiguration().options().copyHeader(true);
}
@@ -106,8 +110,7 @@ private void loadDefaultValues() {
}
}
- @Nullable
- public String getVersion() {
+ @Nullable public String getVersion() {
return version;
}
@@ -169,5 +172,4 @@ public void setTexture(@Nonnull ItemMeta im, @Nonnull String id) {
int data = getModelData(id);
im.setCustomModelData(data == 0 ? null : data);
}
-
-}
\ No newline at end of file
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/LocalizationService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/LocalizationService.java
index e0c176b571..14733c9f94 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/LocalizationService.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/LocalizationService.java
@@ -1,5 +1,11 @@
package io.github.thebusybiscuit.slimefun4.core.services;
+import io.github.thebusybiscuit.slimefun4.core.services.localization.Language;
+import io.github.thebusybiscuit.slimefun4.core.services.localization.LanguageFile;
+import io.github.thebusybiscuit.slimefun4.core.services.localization.SlimefunLocalization;
+import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
+import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
+import io.github.thebusybiscuit.slimefun4.utils.PatternUtils;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
@@ -11,11 +17,9 @@
import java.util.Set;
import java.util.logging.Level;
import java.util.stream.Collectors;
-
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
-
import org.apache.commons.lang.Validate;
import org.bukkit.NamespacedKey;
import org.bukkit.Server;
@@ -26,13 +30,6 @@
import org.bukkit.persistence.PersistentDataContainer;
import org.bukkit.persistence.PersistentDataType;
-import io.github.thebusybiscuit.slimefun4.core.services.localization.Language;
-import io.github.thebusybiscuit.slimefun4.core.services.localization.LanguageFile;
-import io.github.thebusybiscuit.slimefun4.core.services.localization.SlimefunLocalization;
-import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
-import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
-import io.github.thebusybiscuit.slimefun4.utils.PatternUtils;
-
/**
* As the name suggests, this Service is responsible for Localization.
* It is used for managing the {@link Language} of a {@link Player} and the entire {@link Server}.
@@ -54,7 +51,8 @@ public class LocalizationService extends SlimefunLocalization {
private final NamespacedKey languageKey;
private final Language defaultLanguage;
- public LocalizationService(@Nonnull Slimefun plugin, @Nullable String prefix, @Nullable String serverDefaultLanguage) {
+ public LocalizationService(
+ @Nonnull Slimefun plugin, @Nullable String prefix, @Nullable String serverDefaultLanguage) {
super(plugin);
this.plugin = plugin;
@@ -64,7 +62,8 @@ public LocalizationService(@Nonnull Slimefun plugin, @Nullable String prefix, @N
if (serverDefaultLanguage != null) {
translationsEnabled = Slimefun.getCfg().getBoolean("options.enable-translations");
- defaultLanguage = new Language(serverDefaultLanguage, "11b3188fd44902f72602bd7c2141f5a70673a411adb3d81862c69e536166b");
+ defaultLanguage = new Language(
+ serverDefaultLanguage, "11b3188fd44902f72602bd7c2141f5a70673a411adb3d81862c69e536166b");
defaultLanguage.setFile(LanguageFile.MESSAGES, getConfig().getConfiguration());
loadEmbeddedLanguages();
@@ -79,7 +78,8 @@ public LocalizationService(@Nonnull Slimefun plugin, @Nullable String prefix, @N
setLanguage(serverDefaultLanguage, !serverDefaultLanguage.equals(language));
} else {
setLanguage("en", false);
- plugin.getLogger().log(Level.WARNING, "Could not recognize the given language: \"{0}\"", serverDefaultLanguage);
+ plugin.getLogger()
+ .log(Level.WARNING, "Could not recognize the given language: \"{0}\"", serverDefaultLanguage);
}
Slimefun.logger().log(Level.INFO, "Available languages: {0}", String.join(", ", languages.keySet()));
@@ -111,8 +111,7 @@ public NamespacedKey getKey() {
}
@Override
- @Nullable
- public Language getLanguage(@Nonnull String id) {
+ @Nullable public Language getLanguage(@Nonnull String id) {
Validate.notNull(id, "The language id cannot be null");
return languages.get(id);
}
@@ -187,7 +186,8 @@ private void setLanguage(@Nonnull String language, boolean reset) {
// Loading in the defaults from our resources folder
String path = "/languages/" + language + "/messages.yml";
- try (BufferedReader reader = new BufferedReader(new InputStreamReader(plugin.getClass().getResourceAsStream(path), StandardCharsets.UTF_8))) {
+ try (BufferedReader reader = new BufferedReader(
+ new InputStreamReader(plugin.getClass().getResourceAsStream(path), StandardCharsets.UTF_8))) {
FileConfiguration config = YamlConfiguration.loadConfiguration(reader);
getConfig().getConfiguration().setDefaults(config);
} catch (IOException e) {
@@ -212,7 +212,8 @@ protected void addLanguage(@Nonnull String id, @Nonnull String texture) {
Language language = new Language(id, texture);
for (LanguageFile file : LanguageFile.values()) {
- FileConfiguration defaults = file == LanguageFile.MESSAGES ? getConfig().getConfiguration() : null;
+ FileConfiguration defaults =
+ file == LanguageFile.MESSAGES ? getConfig().getConfiguration() : null;
FileConfiguration config = getConfigurationFromStream(file.getFilePath(language), defaults);
language.setFile(file, config);
}
@@ -252,7 +253,8 @@ public double calculateProgress(@Nonnull Language lang) {
return Math.min(NumberUtils.reparseDouble(100.0 * (matches / (double) defaultKeys.size())), 100.0);
}
- private @Nonnull FileConfiguration getConfigurationFromStream(@Nonnull String file, @Nullable FileConfiguration defaults) {
+ private @Nonnull FileConfiguration getConfigurationFromStream(
+ @Nonnull String file, @Nullable FileConfiguration defaults) {
InputStream inputStream = plugin.getClass().getResourceAsStream(file);
if (inputStream == null) {
@@ -281,4 +283,4 @@ public double calculateProgress(@Nonnull Language lang) {
return new YamlConfiguration();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MetricsService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MetricsService.java
index e186004c4e..da1f1e9911 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MetricsService.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MetricsService.java
@@ -1,5 +1,7 @@
package io.github.thebusybiscuit.slimefun4.core.services;
+import io.github.bakedlibs.dough.common.CommonPatterns;
+import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
@@ -10,20 +12,14 @@
import java.nio.file.StandardCopyOption;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
-
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-
-import org.bukkit.plugin.Plugin;
-
-import io.github.bakedlibs.dough.common.CommonPatterns;
-import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
-
import kong.unirest.GetRequest;
import kong.unirest.HttpResponse;
import kong.unirest.JsonNode;
import kong.unirest.Unirest;
import kong.unirest.UnirestException;
+import org.bukkit.plugin.Plugin;
/**
* This Class represents a Metrics Service that sends data to https://bstats.org/
@@ -74,17 +70,17 @@ public class MetricsService {
static {
// @formatter:off (We want this to stay this nicely aligned :D )
Unirest.config()
- .concurrency(2, 1)
- .setDefaultHeader("User-Agent", "MetricsModule Auto-Updater")
- .setDefaultHeader("Accept", "application/vnd.github.v3+json")
- .enableCookieManagement(false)
- .cookieSpec("ignoreCookies");
+ .concurrency(2, 1)
+ .setDefaultHeader("User-Agent", "MetricsModule Auto-Updater")
+ .setDefaultHeader("Accept", "application/vnd.github.v3+json")
+ .enableCookieManagement(false)
+ .cookieSpec("ignoreCookies");
// @formatter:on
}
/**
* This constructs a new instance of our {@link MetricsService}.
- *
+ *
* @param plugin
* Our {@link Slimefun} instance
*/
@@ -117,7 +113,9 @@ public void start() {
* Load the jar file into a child class loader using the Slimefun
* PluginClassLoader as a parent.
*/
- moduleClassLoader = URLClassLoader.newInstance(new URL[] { metricsModuleFile.toURI().toURL() }, plugin.getClass().getClassLoader());
+ moduleClassLoader = URLClassLoader.newInstance(
+ new URL[] {metricsModuleFile.toURI().toURL()},
+ plugin.getClass().getClassLoader());
Class> metricsClass = moduleClassLoader.loadClass("dev.walshy.sfmetrics.MetricsModule");
metricVersion = metricsClass.getPackage().getImplementationVersion();
@@ -142,7 +140,11 @@ public void start() {
start.invoke(null);
plugin.getLogger().info("Metrics build #" + version + " started.");
} catch (InvocationTargetException e) {
- plugin.getLogger().log(Level.WARNING, "An exception was thrown while starting the metrics module", e.getCause());
+ plugin.getLogger()
+ .log(
+ Level.WARNING,
+ "An exception was thrown while starting the metrics module",
+ e.getCause());
} catch (Exception | LinkageError e) {
plugin.getLogger().log(Level.WARNING, "Failed to start metrics.", e);
}
@@ -162,7 +164,8 @@ public void cleanUp() {
moduleClassLoader.close();
}
} catch (IOException e) {
- plugin.getLogger().log(Level.WARNING, "Could not clean up module class loader. Some memory may have been leaked.");
+ plugin.getLogger()
+ .log(Level.WARNING, "Could not clean up module class loader. Some memory may have been leaked.");
}
}
@@ -172,11 +175,12 @@ public void cleanUp() {
*
* @param currentVersion
* The current version which is being used.
- *
+ *
* @return if there is an update available.
*/
public boolean checkForUpdate(@Nullable String currentVersion) {
- if (currentVersion == null || !CommonPatterns.NUMERIC.matcher(currentVersion).matches()) {
+ if (currentVersion == null
+ || !CommonPatterns.NUMERIC.matcher(currentVersion).matches()) {
return false;
}
@@ -239,16 +243,26 @@ private boolean download(int version) {
GetRequest request = Unirest.get(DOWNLOAD_URL + "/" + version + "/" + JAR_NAME + ".jar");
HttpResponse response = request.downloadMonitor((b, fileName, bytesWritten, totalBytes) -> {
- int percent = (int) (20 * (Math.round((((double) bytesWritten / totalBytes) * 100) / 20)));
-
- if (percent != 0 && percent != lastPercentPosted.get()) {
- plugin.getLogger().info("# Downloading... " + percent + "% " + "(" + bytesWritten + "/" + totalBytes + " bytes)");
- lastPercentPosted.set(percent);
- }
- }).asFile(file.getPath());
+ int percent = (int) (20 * (Math.round((((double) bytesWritten / totalBytes) * 100) / 20)));
+
+ if (percent != 0 && percent != lastPercentPosted.get()) {
+ plugin.getLogger()
+ .info("# Downloading... "
+ + percent
+ + "% "
+ + "("
+ + bytesWritten
+ + "/"
+ + totalBytes
+ + " bytes)");
+ lastPercentPosted.set(percent);
+ }
+ })
+ .asFile(file.getPath());
if (response.isSuccess()) {
- plugin.getLogger().log(Level.INFO, "Successfully downloaded {0} build: #{1}", new Object[] { JAR_NAME, version });
+ plugin.getLogger()
+ .log(Level.INFO, "Successfully downloaded {0} build: #{1}", new Object[] {JAR_NAME, version});
// Replace the metric file with the new one
cleanUp();
@@ -259,9 +273,19 @@ private boolean download(int version) {
return true;
}
} catch (UnirestException e) {
- plugin.getLogger().log(Level.WARNING, "Failed to fetch the latest jar file from the builds page. Perhaps GitHub is down? Response: {0}", e.getMessage());
+ plugin.getLogger()
+ .log(
+ Level.WARNING,
+ "Failed to fetch the latest jar file from the builds page. Perhaps GitHub is down?"
+ + " Response: {0}",
+ e.getMessage());
} catch (IOException e) {
- plugin.getLogger().log(Level.WARNING, "Failed to replace the old metric file with the new one. Please do this manually! Error: {0}", e.getMessage());
+ plugin.getLogger()
+ .log(
+ Level.WARNING,
+ "Failed to replace the old metric file with the new one. Please do this manually!"
+ + " Error: {0}",
+ e.getMessage());
}
return false;
@@ -274,8 +298,7 @@ private boolean download(int version) {
*
* @return The current version or null if not loaded.
*/
- @Nullable
- public String getVersion() {
+ @Nullable public String getVersion() {
return metricVersion;
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MinecraftRecipeService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MinecraftRecipeService.java
index 3919122699..e7fe8bef7e 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MinecraftRecipeService.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MinecraftRecipeService.java
@@ -1,15 +1,16 @@
package io.github.thebusybiscuit.slimefun4.core.services;
+import io.github.bakedlibs.dough.recipes.MinecraftRecipe;
+import io.github.bakedlibs.dough.recipes.RecipeSnapshot;
+import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
import java.util.function.Consumer;
-
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import org.bukkit.Keyed;
@@ -22,10 +23,6 @@
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.plugin.Plugin;
-import io.github.bakedlibs.dough.recipes.MinecraftRecipe;
-import io.github.bakedlibs.dough.recipes.RecipeSnapshot;
-import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide;
-
/**
* This Service is responsible for accessing a {@link RecipeSnapshot}.
* This snapshot contains a compiled list of all recipes that could be found on the
@@ -194,5 +191,4 @@ public boolean isSmeltable(@Nullable ItemStack input) {
return Bukkit.getRecipe(key);
}
}
-
-}
\ No newline at end of file
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PerWorldSettingsService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PerWorldSettingsService.java
index a0dc615d30..1667d924c8 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PerWorldSettingsService.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PerWorldSettingsService.java
@@ -1,5 +1,11 @@
package io.github.thebusybiscuit.slimefun4.core.services;
+import io.github.bakedlibs.dough.collections.OptionalMap;
+import io.github.bakedlibs.dough.config.Config;
+import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
+import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
+import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
+import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import java.io.File;
import java.util.Collections;
import java.util.HashMap;
@@ -10,23 +16,14 @@
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
-
import javax.annotation.Nonnull;
-
import org.apache.commons.lang.Validate;
import org.bukkit.Server;
import org.bukkit.World;
-import io.github.bakedlibs.dough.collections.OptionalMap;
-import io.github.bakedlibs.dough.config.Config;
-import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
-import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
-import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
-import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
-
/**
* This Service is responsible for disabling a {@link SlimefunItem} in a certain {@link World}.
- *
+ *
* @author TheBusyBiscuit
*
*/
@@ -44,7 +41,7 @@ public PerWorldSettingsService(@Nonnull Slimefun plugin) {
/**
* This method will forcefully load all currently active Worlds to load up their settings.
- *
+ *
* @param worlds
* An {@link Iterable} of {@link World Worlds} to load
*/
@@ -56,7 +53,7 @@ public void load(@Nonnull Iterable worlds) {
/**
* This method loads the given {@link World} if it was not loaded before.
- *
+ *
* @param world
* The {@link World} to load
*/
@@ -67,12 +64,12 @@ public void load(@Nonnull World world) {
/**
* This method checks whether the given {@link SlimefunItem} is enabled in the given {@link World}.
- *
+ *
* @param world
* The {@link World} to check
* @param item
* The {@link SlimefunItem} that should be checked
- *
+ *
* @return Whether the given {@link SlimefunItem} is enabled in that {@link World}
*/
public boolean isEnabled(@Nonnull World world, @Nonnull SlimefunItem item) {
@@ -90,7 +87,7 @@ public boolean isEnabled(@Nonnull World world, @Nonnull SlimefunItem item) {
/**
* This method enables or disables the given {@link SlimefunItem} in the specified {@link World}.
- *
+ *
* @param world
* The {@link World} in which to disable or enable the given {@link SlimefunItem}
* @param item
@@ -113,7 +110,7 @@ public void setEnabled(@Nonnull World world, @Nonnull SlimefunItem item, boolean
/**
* This method enables or disables the given {@link World}.
- *
+ *
* @param world
* The {@link World} to enable or disable
* @param enabled
@@ -132,10 +129,10 @@ public void setEnabled(@Nonnull World world, boolean enabled) {
/**
* This checks whether the given {@link World} is enabled or not.
- *
+ *
* @param world
* The {@link World} to check
- *
+ *
* @return Whether this {@link World} is enabled
*/
public boolean isWorldEnabled(@Nonnull World world) {
@@ -147,25 +144,26 @@ public boolean isWorldEnabled(@Nonnull World world) {
/**
* This method checks whether the given {@link SlimefunAddon} is enabled in that {@link World}.
- *
+ *
* @param world
* The {@link World} to check
* @param addon
* The {@link SlimefunAddon} to check
- *
+ *
* @return Whether this addon is enabled in that {@link World}
*/
public boolean isAddonEnabled(@Nonnull World world, @Nonnull SlimefunAddon addon) {
Validate.notNull(world, "World cannot be null");
Validate.notNull(addon, "Addon cannot be null");
- return isWorldEnabled(world) && disabledAddons.getOrDefault(addon, Collections.emptySet()).contains(world.getName());
+ return isWorldEnabled(world)
+ && disabledAddons.getOrDefault(addon, Collections.emptySet()).contains(world.getName());
}
/**
* This will forcefully save the settings for that {@link World}.
* This should only be called if you altered the settings while the {@link Server} was still running.
* This writes to a {@link File} so it can be a heavy operation.
- *
+ *
* @param world
* The {@link World} to save
*/
@@ -198,7 +196,18 @@ private Set