diff --git a/.gitignore b/.gitignore
index 5185500aca..cb530532f4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,6 +8,7 @@
/data-storage/
/javadocs/
/local-deps/
+/scripts/
.classpath
.factorypath
diff --git a/pom.xml b/pom.xml
index 7b0ad486c5..9629099569 100644
--- a/pom.xml
+++ b/pom.xml
@@ -168,7 +168,7 @@
io.github.thebusybiscuit.slimefun4.libraries.unirest
- org.apache.commons.lang3
+ org.apache.commons.lang
io.github.thebusybiscuit.slimefun4.libraries.commons.lang
@@ -543,9 +543,9 @@
- org.apache.commons
- commons-lang3
- 3.20.0
+ commons-lang
+ commons-lang
+ 2.6
compile
diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataConfigWrapper.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataConfigWrapper.java
index 574dea14b0..112eeb9d33 100644
--- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataConfigWrapper.java
+++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataConfigWrapper.java
@@ -6,7 +6,6 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
-import org.apache.commons.lang3.NotImplementedException;
import org.bukkit.configuration.file.FileConfiguration;
import org.jetbrains.annotations.ApiStatus;
@@ -67,7 +66,7 @@ public FileConfiguration getConfiguration() {
@Override
public void setDefaultValue(@Nonnull String path, @Nullable Object value) {
if (!(value instanceof String str)) {
- throw new NotImplementedException();
+ throw new RuntimeException("Value must be of type String");
}
if (getString(path) == null) {
blockData.setData(path, str);
@@ -81,7 +80,7 @@ public void setValue(@Nonnull String path, Object value) {
}
if (!(value instanceof String str)) {
- throw new NotImplementedException();
+ throw new RuntimeException("Value must be of type String");
}
blockData.setData(path, str);
}
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 a7fc55d018..aeb36281d1 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/MinecraftVersion.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/MinecraftVersion.java
@@ -1,9 +1,9 @@
package io.github.thebusybiscuit.slimefun4.api;
+import com.google.common.base.Preconditions;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.papermc.lib.PaperLib;
import javax.annotation.Nonnull;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Server;
/**
@@ -207,7 +207,7 @@ public boolean isMinecraftVersion(int minecraftVersion, int patchVersion) {
* @return Whether this {@link MinecraftVersion} is newer or equal to the given {@link MinecraftVersion}
*/
public boolean isAtLeast(@Nonnull MinecraftVersion version) {
- Validate.notNull(version, "A Minecraft version cannot be null!");
+ Preconditions.checkNotNull(version, "A Minecraft version cannot be null!");
if (this == UNKNOWN) {
return false;
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 3c79e8462e..c0a578b168 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunAddon.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunAddon.java
@@ -1,10 +1,10 @@
package io.github.thebusybiscuit.slimefun4.api;
+import com.google.common.base.Preconditions;
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.lang3.Validate;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;
@@ -83,7 +83,7 @@ public interface SlimefunAddon {
* @return Whether this {@link SlimefunAddon} depends on the given {@link Plugin}
*/
default boolean hasDependency(@Nonnull String dependency) {
- Validate.notNull(dependency, "The dependency cannot be null");
+ Preconditions.checkNotNull(dependency, "The dependency cannot be null");
// Well... it cannot depend on itself but you get the idea.
if (getJavaPlugin().getName().equalsIgnoreCase(dependency)) {
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 f74040a8cd..667a9a3350 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunBranch.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunBranch.java
@@ -1,8 +1,8 @@
package io.github.thebusybiscuit.slimefun4.api;
+import com.google.common.base.Preconditions;
import io.github.bakedlibs.dough.common.CommonPatterns;
import javax.annotation.Nonnull;
-import org.apache.commons.lang3.Validate;
/**
* This enum represents the branch this Slimefun build is on.
@@ -38,7 +38,7 @@ public enum SlimefunBranch {
private final boolean official;
SlimefunBranch(@Nonnull String name, boolean official) {
- Validate.notNull(name, "The branch name cannot be null");
+ Preconditions.checkNotNull(name, "The branch name cannot be null");
this.name = name;
this.official = official;
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 1df9f55866..11d7699037 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,9 +1,9 @@
package io.github.thebusybiscuit.slimefun4.api.events;
+import com.google.common.base.Preconditions;
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.lang3.Validate;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
@@ -29,9 +29,9 @@ public AsyncAutoEnchanterProcessEvent(
@Nonnull ItemStack item, @Nonnull ItemStack enchantedBook, @Nonnull BlockMenu menu) {
super(true);
- Validate.notNull(item, "The item to enchant cannot be null!");
- Validate.notNull(enchantedBook, "The enchanted book to enchant cannot be null!");
- Validate.notNull(menu, "The menu of auto-enchanter cannot be null!");
+ Preconditions.checkNotNull(item, "The item to enchant cannot be null!");
+ Preconditions.checkNotNull(enchantedBook, "The enchanted book to enchant cannot be null!");
+ Preconditions.checkNotNull(menu, "The menu of auto-enchanter cannot be null!");
this.item = item;
this.enchantedBook = enchantedBook;
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 09979928d4..5e77137bfd 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,9 +1,9 @@
package io.github.thebusybiscuit.slimefun4.api.events;
+import com.google.common.base.Preconditions;
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
import java.util.UUID;
import javax.annotation.Nonnull;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
@@ -32,7 +32,7 @@ public AsyncProfileLoadEvent(@Nonnull PlayerProfile profile) {
// we are not sure
super(!Bukkit.isPrimaryThread());
- Validate.notNull(profile, "The Profile cannot be null");
+ Preconditions.checkNotNull(profile, "The Profile cannot be null");
this.uniqueId = profile.getUUID();
this.profile = profile;
@@ -56,8 +56,9 @@ public PlayerProfile getProfile() {
* The {@link PlayerProfile}
*/
public void setProfile(@Nonnull PlayerProfile profile) {
- Validate.notNull(profile, "The PlayerProfile cannot be null!");
- Validate.isTrue(profile.getUUID().equals(uniqueId), "Cannot inject a PlayerProfile with a different UUID");
+ Preconditions.checkNotNull(profile, "The PlayerProfile cannot be null!");
+ Preconditions.checkArgument(
+ profile.getUUID().equals(uniqueId), "Cannot inject a PlayerProfile with a different UUID");
this.profile = profile;
}
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 add6eb35f2..01167c7334 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,10 +1,10 @@
package io.github.thebusybiscuit.slimefun4.api.events;
+import com.google.common.base.Preconditions;
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.lang3.Validate;
import org.bukkit.block.Block;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
@@ -73,7 +73,7 @@ public ItemStack getItemStack() {
* The {@link ItemStack} to be placed
*/
public void setItemStack(@Nonnull ItemStack item) {
- Validate.notNull(item, "The ItemStack must not be null!");
+ Preconditions.checkNotNull(item, "The ItemStack must not be null!");
if (!locked) {
this.placedItem = item;
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 717dea9736..17f35e8a79 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,9 +1,9 @@
package io.github.thebusybiscuit.slimefun4.api.events;
+import com.google.common.base.Preconditions;
import io.github.thebusybiscuit.slimefun4.implementation.items.tools.ClimbingPick;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
-import org.apache.commons.lang3.Validate;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
@@ -60,7 +60,7 @@ public Vector getVelocity() {
* The {@link Vector} velocity to apply
*/
public void setVelocity(@Nonnull Vector velocity) {
- Validate.notNull(velocity);
+ Preconditions.checkNotNull(velocity);
this.velocity = velocity;
}
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 870d22f9b8..a0f172a1ff 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,9 +1,9 @@
package io.github.thebusybiscuit.slimefun4.api.events;
+import com.google.common.base.Preconditions;
import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.Cooler;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
-import org.apache.commons.lang3.Validate;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
@@ -79,8 +79,8 @@ public ItemStack getConsumedItem() {
* @param item The new {@link ItemStack}
*/
public void setConsumedItem(@Nonnull ItemStack item) {
- Validate.notNull(item, "The consumed Item cannot be null!");
- Validate.isTrue(item.getItemMeta() instanceof PotionMeta, "The item must be a potion!");
+ Preconditions.checkNotNull(item, "The consumed Item cannot be null!");
+ Preconditions.checkArgument(item.getItemMeta() instanceof PotionMeta, "The item must be a potion!");
this.consumedItem = item;
}
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 5e1c6b62b2..98084fd03b 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,10 @@
package io.github.thebusybiscuit.slimefun4.api.events;
+import com.google.common.base.Preconditions;
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.lang3.Validate;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
@@ -36,10 +36,10 @@ public ExplosiveToolBreakBlocksEvent(
Player player, Block block, List blocks, ItemStack item, ExplosiveTool explosiveTool) {
super(player);
- Validate.notNull(block, "The center block cannot be null!");
- Validate.notNull(blocks, "Blocks cannot be null");
- Validate.notNull(item, "Item cannot be null");
- Validate.notNull(explosiveTool, "ExplosiveTool cannot be null");
+ Preconditions.checkNotNull(block, "The center block cannot be null!");
+ Preconditions.checkNotNull(blocks, "Blocks cannot be null");
+ Preconditions.checkNotNull(item, "Item cannot be null");
+ Preconditions.checkNotNull(explosiveTool, "ExplosiveTool cannot be null");
this.mainBlock = block;
this.additionalBlocks = blocks;
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 eaa73d3348..9e7dfe8ed8 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,12 +1,12 @@
package io.github.thebusybiscuit.slimefun4.api.events;
+import com.google.common.base.Preconditions;
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.lang3.Validate;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
@@ -33,9 +33,9 @@ public class PlayerPreResearchEvent extends Event implements Cancellable {
@ParametersAreNonnullByDefault
public PlayerPreResearchEvent(Player p, Research research, SlimefunItem slimefunItem) {
- Validate.notNull(p, "The Player cannot be null");
- Validate.notNull(research, "Research cannot be null");
- Validate.notNull(slimefunItem, "SlimefunItem cannot be null");
+ Preconditions.checkNotNull(p, "The Player cannot be null");
+ Preconditions.checkNotNull(research, "Research cannot be null");
+ Preconditions.checkNotNull(slimefunItem, "SlimefunItem cannot be null");
this.player = p;
this.research = research;
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 0cd8d89680..017e37912b 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
@@ -1,11 +1,11 @@
package io.github.thebusybiscuit.slimefun4.api.events;
+import com.google.common.base.Preconditions;
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.lang3.Validate;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
@@ -167,12 +167,12 @@ public Result useBlock() {
}
public void setUseItem(@Nonnull Result result) {
- Validate.notNull(result, "Result cannot be null");
+ Preconditions.checkNotNull(result, "Result cannot be null");
itemResult = result;
}
public void setUseBlock(@Nonnull Result result) {
- Validate.notNull(result, "Result cannot be null");
+ Preconditions.checkNotNull(result, "Result cannot be null");
blockResult = result;
}
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 f830cd8482..db5f3b69ff 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,9 +1,9 @@
package io.github.thebusybiscuit.slimefun4.api.events;
+import com.google.common.base.Preconditions;
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.lang3.Validate;
import org.bukkit.Location;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
@@ -22,8 +22,8 @@ public class ReactorExplodeEvent extends Event {
private final Reactor reactor;
public ReactorExplodeEvent(@Nonnull Location l, @Nonnull Reactor reactor) {
- Validate.notNull(l, "A Location must be provided");
- Validate.notNull(reactor, "A Reactor cannot be null");
+ Preconditions.checkNotNull(l, "A Location must be provided");
+ Preconditions.checkNotNull(reactor, "A Reactor cannot be null");
this.location = l;
this.reactor = reactor;
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 85ca97ccf8..894334da1a 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,8 +1,8 @@
package io.github.thebusybiscuit.slimefun4.api.events;
+import com.google.common.base.Preconditions;
import io.github.thebusybiscuit.slimefun4.api.researches.Research;
import javax.annotation.Nonnull;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
@@ -28,8 +28,8 @@ public class ResearchUnlockEvent extends Event implements Cancellable {
public ResearchUnlockEvent(@Nonnull Player p, @Nonnull Research research) {
super(!Bukkit.isPrimaryThread());
- Validate.notNull(p, "The Player cannot be null");
- Validate.notNull(research, "Research cannot be null");
+ Preconditions.checkNotNull(p, "The Player cannot be null");
+ Preconditions.checkNotNull(research, "Research cannot be null");
this.player = p;
this.research = research;
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 4f510729ba..3a427778a2 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,8 +1,8 @@
package io.github.thebusybiscuit.slimefun4.api.events;
+import com.google.common.base.Preconditions;
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode;
import javax.annotation.Nonnull;
-import org.apache.commons.lang3.Validate;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
@@ -26,9 +26,9 @@ public class SlimefunGuideOpenEvent extends Event implements Cancellable {
private boolean cancelled;
public SlimefunGuideOpenEvent(@Nonnull Player p, @Nonnull ItemStack guide, @Nonnull SlimefunGuideMode layout) {
- Validate.notNull(p, "The Player cannot be null");
- Validate.notNull(guide, "Guide cannot be null");
- Validate.notNull(layout, "Layout cannot be null");
+ Preconditions.checkNotNull(p, "The Player cannot be null");
+ Preconditions.checkNotNull(guide, "Guide cannot be null");
+ Preconditions.checkNotNull(layout, "Layout cannot be null");
this.player = p;
this.guide = guide;
this.layout = layout;
@@ -74,7 +74,7 @@ public SlimefunGuideMode getGuideLayout() {
* The new {@link SlimefunGuideMode}
*/
public void setGuideLayout(@Nonnull SlimefunGuideMode layout) {
- Validate.notNull(layout, "You must specify a layout that is not-null!");
+ Preconditions.checkNotNull(layout, "You must specify a layout that is not-null!");
this.layout = layout;
}
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 55697ae1b2..14c7ef06c7 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,11 +1,11 @@
package io.github.thebusybiscuit.slimefun4.api.events;
+import com.google.common.base.Preconditions;
import io.github.thebusybiscuit.slimefun4.api.items.ItemSpawnReason;
import java.util.Optional;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
@@ -81,7 +81,7 @@ public SlimefunItemSpawnEvent(Location location, ItemStack itemStack, ItemSpawnR
* The {@link Location} where to drop the {@link ItemStack}
*/
public void setLocation(@Nonnull Location location) {
- Validate.notNull(location, "The Location cannot be null!");
+ Preconditions.checkNotNull(location, "The Location cannot be null!");
this.location = location;
}
@@ -102,8 +102,8 @@ public void setLocation(@Nonnull Location location) {
* The {@link ItemStack} to drop
*/
public void setItemStack(@Nonnull ItemStack itemStack) {
- Validate.notNull(itemStack, "Cannot drop null.");
- Validate.isTrue(!itemStack.getType().isAir(), "Cannot drop air.");
+ Preconditions.checkNotNull(itemStack, "Cannot drop null.");
+ Preconditions.checkArgument(!itemStack.getType().isAir(), "Cannot drop air.");
this.itemStack = itemStack;
}
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 3d49a16ff7..77d8451af2 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
@@ -1,10 +1,10 @@
package io.github.thebusybiscuit.slimefun4.api.events;
+import com.google.common.base.Preconditions;
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.lang3.Validate;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
@@ -35,8 +35,8 @@ public class WaypointCreateEvent extends PlayerEvent implements Cancellable {
public WaypointCreateEvent(@Nonnull Player player, @Nonnull String name, @Nonnull Location location) {
super(player);
- Validate.notNull(location, "Location must not be null!");
- Validate.notNull(name, "Name must not be null!");
+ Preconditions.checkNotNull(location, "Location must not be null!");
+ Preconditions.checkNotNull(name, "Name must not be null!");
this.location = location;
this.name = name;
@@ -60,7 +60,7 @@ public Location getLocation() {
* @param loc The {@link Location} to set
*/
public void setLocation(@Nonnull Location loc) {
- Validate.notNull(loc, "Cannot set the Location to null!");
+ Preconditions.checkNotNull(loc, "Cannot set the Location to null!");
this.location = loc;
}
@@ -81,7 +81,7 @@ public String getName() {
* The name for this waypoint
*/
public void setName(@Nonnull String name) {
- Validate.notEmpty(name, "The name of a waypoint must not be empty!");
+ Preconditions.checkArgument(!name.isEmpty(), "The name of a waypoint must not be empty!");
this.name = 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 fb7d3e018c..095d8b97fd 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
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.api.geo;
+import com.google.common.base.Preconditions;
import com.xzavier0722.mc.plugin.slimefun4.storage.callback.IAsyncReadCallback;
import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunChunkData;
import io.github.bakedlibs.dough.blocks.BlockPosition;
@@ -23,7 +24,6 @@
import java.util.concurrent.ThreadLocalRandom;
import javax.annotation.Nonnull;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Chunk;
@@ -70,8 +70,8 @@ public ResourceManager(@Nonnull Slimefun plugin) {
* The {@link GEOResource} to register
*/
void register(@Nonnull GEOResource resource) {
- Validate.notNull(resource, "Cannot register null as a GEO-Resource");
- Validate.notNull(resource.getKey(), "GEO-Resources must have a NamespacedKey which is not null");
+ Preconditions.checkNotNull(resource, "Cannot register null as a GEO-Resource");
+ Preconditions.checkNotNull(resource.getKey(), "GEO-Resources must have a NamespacedKey which is not null");
// Resources may only be registered once
if (Slimefun.getRegistry().getGEOResources().containsKey(resource.getKey())) {
@@ -108,8 +108,8 @@ void register(@Nonnull GEOResource resource) {
* @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) {
- Validate.notNull(resource, "Cannot get supplies for null");
- Validate.notNull(world, "World must not be null");
+ Preconditions.checkNotNull(resource, "Cannot get supplies for null");
+ Preconditions.checkNotNull(world, "World must not be null");
String key = resource.getKey().toString().replace(':', '-');
var chunkData = Slimefun.getDatabaseManager().getBlockDataController().getChunkData(world.getChunkAt(x, z));
@@ -164,8 +164,8 @@ public void onResultNotFound() {
* The new supply value
*/
public void setSupplies(@Nonnull GEOResource resource, @Nonnull World world, int x, int z, int value) {
- Validate.notNull(resource, "Cannot set supplies for null");
- Validate.notNull(world, "World cannot be null");
+ Preconditions.checkNotNull(resource, "Cannot set supplies for null");
+ Preconditions.checkNotNull(world, "World cannot be null");
String key = resource.getKey().toString().replace(':', '-');
Slimefun.getDatabaseManager()
@@ -195,8 +195,8 @@ public void setSupplies(@Nonnull GEOResource resource, @Nonnull World world, int
* @return The new supply value
*/
private int generate(@Nonnull GEOResource resource, @Nonnull World world, int x, int y, int z) {
- Validate.notNull(resource, "Cannot generate resources for null");
- Validate.notNull(world, "World cannot be null");
+ Preconditions.checkNotNull(resource, "Cannot generate resources for null");
+ Preconditions.checkNotNull(world, "World cannot be null");
// Get the corresponding Block (and Biome)
Block block = world.getBlockAt(x << 4, y, z << 4);
@@ -206,7 +206,7 @@ private int generate(@Nonnull GEOResource resource, @Nonnull World world, int x,
* getBiome() is marked as NotNull, but it seems like some servers ignore this entirely.
* We have seen multiple reports on Tuinity where it has indeed returned null.
*/
- Validate.notNull(biome, "Biome appears to be null for position: " + new BlockPosition(block));
+ Preconditions.checkNotNull(biome, "Biome appears to be null for position: " + new BlockPosition(block));
// Make sure the value is not below zero.
int value = Math.max(0, resource.getDefaultSupply(world.getEnvironment(), biome));
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 b22cef978a..6b7c4bbc88 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
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.api.gps;
+import com.google.common.base.Preconditions;
import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils;
import io.github.bakedlibs.dough.chat.ChatInput;
import io.github.bakedlibs.dough.common.ChatColors;
@@ -28,7 +29,6 @@
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
@@ -367,8 +367,8 @@ private void setPage(Player p, int page, int totalPages) {
* The {@link Location} of the new waypoint
*/
public void createWaypoint(@Nonnull Player p, @Nonnull Location l) {
- Validate.notNull(p, "Player cannot be null!");
- Validate.notNull(l, "Waypoint Location cannot be null!");
+ Preconditions.checkNotNull(p, "Player cannot be null!");
+ Preconditions.checkNotNull(l, "Waypoint Location cannot be null!");
PlayerProfile.get(p, profile -> {
if (profile.getWaypoints().size() >= maxWaypoints) {
@@ -394,9 +394,9 @@ public void createWaypoint(@Nonnull Player p, @Nonnull Location l) {
* The {@link Location} of this waypoint
*/
public void addWaypoint(@Nonnull Player p, @Nonnull String name, @Nonnull Location l) {
- Validate.notNull(p, "Player cannot be null!");
- Validate.notNull(name, "Waypoint name cannot be null!");
- Validate.notNull(l, "Waypoint Location cannot be null!");
+ Preconditions.checkNotNull(p, "Player cannot be null!");
+ Preconditions.checkNotNull(name, "Waypoint name cannot be null!");
+ Preconditions.checkNotNull(l, "Waypoint Location cannot be null!");
PlayerProfile.get(p, profile -> {
if (profile.getWaypoints().size() >= maxWaypoints) {
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 ac844511ba..f9a395e660 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,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.api.gps;
+import com.google.common.base.Preconditions;
import io.github.bakedlibs.dough.common.ChatColors;
import io.github.bakedlibs.dough.items.CustomItemStack;
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
@@ -22,7 +23,6 @@
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
@@ -196,8 +196,8 @@ public void teleport(UUID uuid, int complexity, Location source, Location destin
* @return The amount of time the teleportation will take
*/
public int getTeleportationTime(int complexity, @Nonnull Location source, @Nonnull Location destination) {
- Validate.notNull(source, "Source cannot be null");
- Validate.notNull(source, "Destination cannot be null");
+ Preconditions.checkNotNull(source, "Source cannot be null");
+ Preconditions.checkNotNull(source, "Destination cannot be null");
if (complexity < 100) {
return 100;
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 30d5d9cecf..7c839e9242 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,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.api.gps;
+import com.google.common.base.Preconditions;
import io.github.thebusybiscuit.slimefun4.api.events.WaypointCreateEvent;
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
@@ -8,7 +9,6 @@
import java.util.UUID;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World.Environment;
@@ -68,10 +68,10 @@ public Waypoint(PlayerProfile profile, String id, Location loc, String name) {
*/
@ParametersAreNonnullByDefault
public Waypoint(UUID ownerId, String id, Location loc, String name) {
- Validate.notNull(ownerId, "owner ID must never be null!");
- Validate.notNull(id, "id must never be null!");
- Validate.notNull(loc, "Location must never be null!");
- Validate.notNull(name, "Name must never be null!");
+ Preconditions.checkNotNull(ownerId, "owner ID must never be null!");
+ Preconditions.checkNotNull(id, "id must never be null!");
+ Preconditions.checkNotNull(loc, "Location must never be null!");
+ Preconditions.checkNotNull(name, "Name must never be null!");
this.ownerId = ownerId;
this.id = id;
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 aee1822be7..681753351b 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,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.api.items;
+import com.google.common.base.Preconditions;
import io.github.bakedlibs.dough.items.CustomItemStack;
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
import io.github.thebusybiscuit.slimefun4.api.items.groups.LockedItemGroup;
@@ -15,7 +16,6 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
-import org.apache.commons.lang3.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Keyed;
import org.bukkit.NamespacedKey;
@@ -74,8 +74,8 @@ public ItemGroup(NamespacedKey key, ItemStack item) {
*/
@ParametersAreNonnullByDefault
public ItemGroup(NamespacedKey key, ItemStack item, int tier) {
- Validate.notNull(key, "An item group's NamespacedKey must not be null!");
- Validate.notNull(item, "An item group's ItemStack must not be null!");
+ Preconditions.checkNotNull(key, "An item group's NamespacedKey must not be null!");
+ Preconditions.checkNotNull(item, "An item group's ItemStack must not be null!");
this.item = item;
this.key = key;
@@ -103,7 +103,7 @@ public ItemGroup(NamespacedKey key, ItemStack item, int tier) {
* The {@link SlimefunAddon} that wants to register this {@link ItemGroup}
*/
public void register(@Nonnull SlimefunAddon addon) {
- Validate.notNull(addon, "The Addon cannot be null");
+ Preconditions.checkNotNull(addon, "The Addon cannot be null");
if (isRegistered()) {
throw new UnsupportedOperationException("This ItemGroup has already been registered!");
@@ -176,7 +176,7 @@ private void sortCategoriesByTier() {
* the {@link SlimefunItem} that should be added to this {@link ItemGroup}
*/
public void add(@Nonnull SlimefunItem item) {
- Validate.notNull(item, "Cannot add null Items to an ItemGroup!");
+ Preconditions.checkNotNull(item, "Cannot add null Items to an ItemGroup!");
if (items.contains(item)) {
// Ignore duplicate entries
@@ -200,7 +200,7 @@ public void add(@Nonnull SlimefunItem item) {
* the {@link SlimefunItem} that should be removed from this {@link ItemGroup}
*/
public void remove(@Nonnull SlimefunItem item) {
- Validate.notNull(item, "Cannot remove null from an ItemGroup!");
+ Preconditions.checkNotNull(item, "Cannot remove null from an ItemGroup!");
items.remove(item);
}
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 35ae690925..a222733849 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,12 +1,12 @@
package io.github.thebusybiscuit.slimefun4.api.items;
+import com.google.common.base.Preconditions;
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.lang3.Validate;
/**
* This class represents a Setting for a {@link SlimefunItem} that can be modified via
@@ -38,9 +38,9 @@ public class ItemSetting {
*/
@ParametersAreNonnullByDefault
public ItemSetting(SlimefunItem item, String key, T defaultValue) {
- Validate.notNull(item, "The provided SlimefunItem must not be null!");
- Validate.notNull(key, "The key of an ItemSetting is not allowed to be null!");
- Validate.notNull(defaultValue, "The default value of an ItemSetting is not allowed to be null!");
+ Preconditions.checkNotNull(item, "The provided SlimefunItem must not be null!");
+ Preconditions.checkNotNull(key, "The key of an ItemSetting is not allowed to be null!");
+ Preconditions.checkNotNull(defaultValue, "The default value of an ItemSetting is not allowed to be null!");
this.item = item;
this.key = key;
@@ -161,7 +161,7 @@ public boolean isType(@Nonnull Class> c) {
*/
@SuppressWarnings("unchecked")
public void reload() {
- Validate.notNull(item, "Cannot apply settings for a non-existing SlimefunItem");
+ Preconditions.checkNotNull(item, "Cannot apply settings for a non-existing SlimefunItem");
Slimefun.getItemCfg().setDefaultValue(item.getId() + '.' + getKey(), getDefaultValue());
Object configuredValue = Slimefun.getItemCfg().getValue(item.getId() + '.' + getKey());
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 b087c026be..e327e9496c 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,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.api.items;
+import com.google.common.base.Preconditions;
import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData;
import io.github.bakedlibs.dough.collections.OptionalMap;
import io.github.bakedlibs.dough.items.ItemUtils;
@@ -39,7 +40,6 @@
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker;
-import org.apache.commons.lang3.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.World;
@@ -154,9 +154,9 @@ public SlimefunItem(
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!");
+ Preconditions.checkNotNull(itemGroup, "'itemGroup' is not allowed to be null!");
+ Preconditions.checkNotNull(item, "'item' is not allowed to be null!");
+ Preconditions.checkNotNull(recipeType, "'recipeType' is not allowed to be null!");
this.itemGroup = itemGroup;
this.itemStackTemplate = item;
@@ -169,10 +169,10 @@ public SlimefunItem(
// Previously deprecated constructor, now only for internal purposes
@ParametersAreNonnullByDefault
protected SlimefunItem(ItemGroup itemGroup, ItemStack item, String id, RecipeType recipeType, ItemStack[] recipe) {
- Validate.notNull(itemGroup, "'itemGroup' is not allowed to be null!");
- Validate.notNull(item, "'item' is not allowed to be null!");
- Validate.notNull(id, "'id' is not allowed to be null!");
- Validate.notNull(recipeType, "'recipeType' is not allowed to be null!");
+ Preconditions.checkNotNull(itemGroup, "'itemGroup' is not allowed to be null!");
+ Preconditions.checkNotNull(item, "'item' is not allowed to be null!");
+ Preconditions.checkNotNull(id, "'id' is not allowed to be null!");
+ Preconditions.checkNotNull(recipeType, "'recipeType' is not allowed to be null!");
this.itemGroup = itemGroup;
this.itemStackTemplate = item;
@@ -412,8 +412,9 @@ public BlockTicker getBlockTicker() {
* @param addon The {@link SlimefunAddon} that this {@link SlimefunItem} belongs to.
*/
public void register(@Nonnull SlimefunAddon addon) {
- Validate.notNull(addon, "A SlimefunAddon cannot be null!");
- Validate.notNull(addon.getJavaPlugin(), "SlimefunAddon#getJavaPlugin() is not allowed to return null!");
+ Preconditions.checkNotNull(addon, "A SlimefunAddon cannot be null!");
+ Preconditions.checkNotNull(
+ addon.getJavaPlugin(), "SlimefunAddon#getJavaPlugin() is not allowed to return null!");
this.addon = addon;
@@ -721,7 +722,7 @@ public void setRecipe(@Nonnull ItemStack[] recipe) {
* The {@link RecipeType} for this {@link SlimefunItem}
*/
public void setRecipeType(@Nonnull RecipeType type) {
- Validate.notNull(type, "The RecipeType is not allowed to be null!");
+ Preconditions.checkNotNull(type, "The RecipeType is not allowed to be null!");
this.recipeType = type;
}
@@ -732,7 +733,7 @@ public void setRecipeType(@Nonnull RecipeType type) {
* The new {@link ItemGroup}
*/
public void setItemGroup(@Nonnull ItemGroup itemGroup) {
- Validate.notNull(itemGroup, "The ItemGroup is not allowed to be null!");
+ Preconditions.checkNotNull(itemGroup, "The ItemGroup is not allowed to be null!");
this.itemGroup.remove(this);
itemGroup.add(this);
@@ -829,8 +830,9 @@ public void load() {
* 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...");
- Validate.noNullElements(handlers, "You cannot add any 'null' ItemHandler!");
+ for (ItemHandler handler : handlers) {
+ Preconditions.checkNotNull(handler, "You cannot add any 'null' ItemHandler!");
+ }
// Make sure they are added before the item was registered.
if (state != ItemState.UNREGISTERED) {
@@ -858,8 +860,9 @@ public final void addItemHandler(ItemHandler... handlers) {
* 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!");
+ for (ItemSetting> setting : settings) {
+ Preconditions.checkNotNull(setting, "You cannot add any 'null' ItemSetting!");
+ }
if (state != ItemState.UNREGISTERED) {
throw new UnsupportedOperationException(
@@ -918,7 +921,7 @@ public void postRegister() {
*/
@Deprecated
public final void addOfficialWikipage(@Nonnull String page) {
- Validate.notNull(page, "Wiki page cannot be null.");
+ Preconditions.checkNotNull(page, "Wiki page cannot be null.");
// 转换链接
page = page.replace("#", "?id=");
wikiURL = Optional.of("https://slimefun-wiki.guizhanss.cn/" + page);
@@ -930,7 +933,7 @@ public final void addOfficialWikipage(@Nonnull String page) {
* @param page 物品的 Wiki 页面
*/
public final void addWikiPage(@Nonnull String page) {
- Validate.notNull(page, "Wiki page cannot be null.");
+ Preconditions.checkNotNull(page, "Wiki page cannot be null.");
if (addon == null) {
Slimefun.logger().warning("该物品\"" + getId() + "\"暂未注册, 请在物品注册后再添加Wiki页面");
@@ -1057,7 +1060,7 @@ public String toString() {
*/
@ParametersAreNonnullByDefault
public void info(String message) {
- Validate.notNull(addon, "Cannot log a message for an unregistered item!");
+ Preconditions.checkNotNull(addon, "Cannot log a message for an unregistered item!");
String msg = toString() + ": " + message;
addon.getLogger().log(Level.INFO, msg);
@@ -1073,7 +1076,7 @@ public void info(String message) {
*/
@ParametersAreNonnullByDefault
public void warn(String message) {
- Validate.notNull(addon, "Cannot send a warning for an unregistered item!");
+ Preconditions.checkNotNull(addon, "Cannot send a warning for an unregistered item!");
String msg = toString() + ": " + message;
addon.getLogger().log(Level.WARNING, msg);
@@ -1095,7 +1098,7 @@ public void warn(String message) {
*/
@ParametersAreNonnullByDefault
public void error(String message, Throwable throwable) {
- Validate.notNull(addon, "Cannot send an error for an unregistered item!");
+ Preconditions.checkNotNull(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()
});
@@ -1122,7 +1125,7 @@ public void error(String message, Throwable throwable) {
*/
@ParametersAreNonnullByDefault
public void sendDeprecationWarning(Player player) {
- Validate.notNull(player, "The Player must not be null.");
+ Preconditions.checkNotNull(player, "The Player must not be null.");
Slimefun.getLocalization().sendMessage(player, "messages.deprecated-item");
}
@@ -1148,7 +1151,7 @@ public void sendDeprecationWarning(Player player) {
* @return Whether this {@link Player} is able to use this {@link SlimefunItem}.
*/
public boolean canUse(@Nonnull Player p, boolean sendMessage) {
- Validate.notNull(p, "The Player cannot be null!");
+ Preconditions.checkNotNull(p, "The Player cannot be null!");
if (getState() == ItemState.VANILLA_FALLBACK) {
// Vanilla items (which fell back) can always be used.
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 2cde4a0e81..159fb2af8e 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,6 @@
package io.github.thebusybiscuit.slimefun4.api.items;
+import com.google.common.base.Preconditions;
import io.github.bakedlibs.dough.common.CommonPatterns;
import io.github.bakedlibs.dough.items.ItemMetaSnapshot;
import io.github.bakedlibs.dough.skins.PlayerHead;
@@ -19,7 +20,6 @@
import java.util.function.Consumer;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import org.apache.commons.lang3.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Material;
@@ -53,8 +53,8 @@ public SlimefunItemStack(@Nonnull String id, @Nonnull ItemStack item) {
setItemMeta(item.getItemMeta());
}
- Validate.notNull(id, "The Item id must never be null!");
- Validate.isTrue(
+ Preconditions.checkNotNull(id, "The Item id must never be null!");
+ Preconditions.checkArgument(
id.equals(id.toUpperCase(Locale.ROOT)), "Slimefun Item Ids must be uppercase! (e.g. 'MY_ITEM_ID')");
if (Slimefun.instance() == null) {
@@ -302,8 +302,8 @@ public void lock() {
}
private static @Nonnull String getTexture(@Nonnull String id, @Nonnull String texture) {
- Validate.notNull(id, "The id cannot be null");
- Validate.notNull(texture, "The texture cannot be null");
+ Preconditions.checkNotNull(id, "The id cannot be null");
+ Preconditions.checkNotNull(texture, "The texture cannot be null");
if (texture.startsWith("ey")) {
return texture;
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 b367e0b437..19704f2485 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,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.api.items.groups;
+import com.google.common.base.Preconditions;
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
@@ -12,7 +13,6 @@
import java.util.logging.Level;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
-import org.apache.commons.lang3.Validate;
import org.bukkit.NamespacedKey;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@@ -67,7 +67,9 @@ public LockedItemGroup(NamespacedKey key, ItemStack item, NamespacedKey... paren
@ParametersAreNonnullByDefault
public LockedItemGroup(NamespacedKey key, ItemStack item, int tier, NamespacedKey... parents) {
super(key, item, tier);
- Validate.noNullElements(parents, "A LockedItemGroup must not have any 'null' parents!");
+ for (NamespacedKey parent : parents) {
+ Preconditions.checkNotNull(parent, "A LockedItemGroup must not have any 'null' parents!");
+ }
this.keys = parents;
}
@@ -154,8 +156,8 @@ public void removeParent(@Nonnull ItemGroup group) {
* @return Whether the {@link Player} has fully completed all parent categories, otherwise false
*/
public boolean hasUnlocked(@Nonnull Player p, @Nonnull PlayerProfile profile) {
- Validate.notNull(p, "The player cannot be null!");
- Validate.notNull(profile, "The Profile cannot be null!");
+ Preconditions.checkNotNull(p, "The player cannot be null!");
+ Preconditions.checkNotNull(profile, "The Profile cannot be null!");
for (ItemGroup parent : parents) {
for (SlimefunItem item : parent.getItems()) {
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 d7439f7493..7899c64cea 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,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.api.items.groups;
+import com.google.common.base.Preconditions;
import io.github.bakedlibs.dough.items.CustomItemStack;
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
import io.github.thebusybiscuit.slimefun4.core.guide.GuideHistory;
@@ -14,7 +15,6 @@
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
-import org.apache.commons.lang3.Validate;
import org.bukkit.ChatColor;
import org.bukkit.NamespacedKey;
import org.bukkit.entity.Player;
@@ -42,7 +42,7 @@ public NestedItemGroup(NamespacedKey key, ItemStack item, int tier) {
* The {@link SubItemGroup} to add.
*/
public void addSubGroup(@Nonnull SubItemGroup group) {
- Validate.notNull(group, "The sub item group cannot be null!");
+ Preconditions.checkNotNull(group, "The sub item group cannot be null!");
subGroups.add(group);
}
@@ -54,7 +54,7 @@ public void addSubGroup(@Nonnull SubItemGroup group) {
* The {@link SubItemGroup} to remove.
*/
public void removeSubGroup(@Nonnull SubItemGroup group) {
- Validate.notNull(group, "The sub item group cannot be null!");
+ Preconditions.checkNotNull(group, "The sub item group cannot be null!");
subGroups.remove(group);
}
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 4a1754b9d8..c835281b28 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,11 +1,11 @@
package io.github.thebusybiscuit.slimefun4.api.items.groups;
+import com.google.common.base.Preconditions;
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.lang3.Validate;
import org.bukkit.NamespacedKey;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@@ -38,7 +38,7 @@ public class SeasonalItemGroup extends ItemGroup {
@ParametersAreNonnullByDefault
public SeasonalItemGroup(NamespacedKey key, Month month, int tier, ItemStack item) {
super(key, item, tier);
- Validate.notNull(month, "The Month cannot be null");
+ Preconditions.checkNotNull(month, "The Month cannot be null");
this.month = month;
}
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 387c8887f8..570d3989e5 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,11 +1,11 @@
package io.github.thebusybiscuit.slimefun4.api.items.groups;
+import com.google.common.base.Preconditions;
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.lang3.Validate;
import org.bukkit.NamespacedKey;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@@ -32,7 +32,7 @@ public SubItemGroup(NamespacedKey key, NestedItemGroup parent, ItemStack item) {
public SubItemGroup(NamespacedKey key, NestedItemGroup parent, ItemStack item, int tier) {
super(key, item, tier);
- Validate.notNull(parent, "The parent group cannot be null");
+ Preconditions.checkNotNull(parent, "The parent group cannot be null");
parentItemGroup = parent;
parent.addSubGroup(this);
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 08e73104e7..4475f68e62 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,10 +1,10 @@
package io.github.thebusybiscuit.slimefun4.api.items.settings;
+import com.google.common.base.Preconditions;
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.lang3.Validate;
/**
* This variation of {@link ItemSetting} allows you to define an {@link Double} range
@@ -24,7 +24,7 @@ public class DoubleRangeSetting extends ItemSetting {
@ParametersAreNonnullByDefault
public DoubleRangeSetting(SlimefunItem item, String key, double min, double defaultValue, double max) {
super(item, key, defaultValue);
- Validate.isTrue(defaultValue >= min && defaultValue <= max, "The default value is not in range.");
+ Preconditions.checkArgument(defaultValue >= min && defaultValue <= max, "The default value is not in range.");
this.min = min;
this.max = max;
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 2e88f7a89a..f96da639db 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,10 +1,10 @@
package io.github.thebusybiscuit.slimefun4.api.items.settings;
+import com.google.common.base.Preconditions;
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.lang3.Validate;
/**
* This variation of {@link ItemSetting} allows you to define an {@link Integer} range
@@ -24,7 +24,7 @@ public class IntRangeSetting extends ItemSetting {
@ParametersAreNonnullByDefault
public IntRangeSetting(SlimefunItem item, String key, int min, int defaultValue, int max) {
super(item, key, defaultValue);
- Validate.isTrue(defaultValue >= min && defaultValue <= max, "The default value is not in range.");
+ Preconditions.checkArgument(defaultValue >= min && defaultValue <= max, "The default value is not in range.");
this.min = min;
this.max = max;
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 7a37c7c769..f4650ef1fe 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
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.api.network;
+import com.google.common.base.Preconditions;
import com.xzavier0722.mc.plugin.slimefun4.storage.util.LocationUtils;
import io.github.thebusybiscuit.slimefun4.core.debug.Debug;
import io.github.thebusybiscuit.slimefun4.core.debug.TestCase;
@@ -12,7 +13,6 @@
import java.util.Set;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Particle;
@@ -53,8 +53,8 @@ public abstract class Network {
* The {@link Location} marking the regulator of this {@link Network}.
*/
protected Network(@Nonnull NetworkManager manager, @Nonnull Location regulator) {
- Validate.notNull(manager, "A NetworkManager must be provided");
- Validate.notNull(regulator, "No regulator was specified");
+ Preconditions.checkNotNull(manager, "A NetworkManager must be provided");
+ Preconditions.checkNotNull(regulator, "No regulator was specified");
this.manager = manager;
this.regulator = regulator;
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 8787a0b4af..ac4389fd7f 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,8 +1,8 @@
package io.github.thebusybiscuit.slimefun4.api.network;
+import com.google.common.base.Preconditions;
import io.github.thebusybiscuit.slimefun4.utils.compatibility.VersionedParticle;
import javax.annotation.Nonnull;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Particle.DustOptions;
@@ -32,8 +32,8 @@ class NetworkVisualizer implements Runnable {
* The {@link Network} to visualize
*/
NetworkVisualizer(@Nonnull Network network, @Nonnull Color color) {
- Validate.notNull(network, "The network should not be null.");
- Validate.notNull(color, "The color cannot be null.");
+ Preconditions.checkNotNull(network, "The network should not be null.");
+ Preconditions.checkNotNull(color, "The color cannot be null.");
this.network = network;
this.particleOptions = new DustOptions(color, 3F);
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 d45bd2476c..3a45eb933d 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
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.api.player;
+import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.xzavier0722.mc.plugin.slimefun4.storage.callback.IAsyncReadCallback;
@@ -30,7 +31,6 @@
import java.util.logging.Level;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
@@ -181,7 +181,7 @@ public void saveAsync() {
* Whether the {@link Research} should be unlocked or locked
*/
public void setResearched(@Nonnull Research research, boolean unlock) {
- Validate.notNull(research, "Research must not be null!");
+ Preconditions.checkNotNull(research, "Research must not be null!");
// markDirty();
if (unlock) {
@@ -256,7 +256,7 @@ public boolean hasUnlockedEverything() {
* The {@link Waypoint} to add
*/
public void addWaypoint(@Nonnull Waypoint waypoint) {
- Validate.notNull(waypoint, "Cannot add a 'null' waypoint!");
+ Preconditions.checkNotNull(waypoint, "Cannot add a 'null' waypoint!");
for (Waypoint wp : waypoints) {
if (wp.getId().equals(waypoint.getId())) {
@@ -283,7 +283,7 @@ public void addWaypoint(@Nonnull Waypoint waypoint) {
* The {@link Waypoint} to remove
*/
public void removeWaypoint(@Nonnull Waypoint waypoint) {
- Validate.notNull(waypoint, "Cannot remove a 'null' waypoint!");
+ Preconditions.checkNotNull(waypoint, "Cannot remove a 'null' waypoint!");
if (waypoints.remove(waypoint)) {
waypointsFile.setValue(waypoint.getId(), null);
@@ -420,7 +420,7 @@ public static boolean fromUUID(@Nonnull UUID uuid, @Nonnull Consumer callback) {
- Validate.notNull(p, "Cannot get a PlayerProfile for: null!");
+ Preconditions.checkNotNull(p, "Cannot get a PlayerProfile for: null!");
UUID uuid = p.getUniqueId();
PlayerProfile profile = Slimefun.getRegistry().getPlayerProfiles().get(uuid);
@@ -452,7 +452,7 @@ public static boolean get(@Nonnull OfflinePlayer p, @Nonnull Consumer {
* The callback to run when the task has completed
*/
PlayerResearchTask(@Nonnull Research research, boolean isInstant, @Nullable Consumer callback) {
- Validate.notNull(research, "The Research must not be null");
+ Preconditions.checkNotNull(research, "The Research must not be null");
this.research = research;
this.isInstant = isInstant;
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 4500cc5e4b..371bc4de21 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
@@ -1,6 +1,7 @@
package io.github.thebusybiscuit.slimefun4.api.researches;
import city.norain.slimefun4.VaultIntegration;
+import com.google.common.base.Preconditions;
import io.github.thebusybiscuit.slimefun4.api.events.PlayerPreResearchEvent;
import io.github.thebusybiscuit.slimefun4.api.events.ResearchUnlockEvent;
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
@@ -19,7 +20,6 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
@@ -68,8 +68,8 @@ public class Research implements Keyed {
*/
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");
+ Preconditions.checkNotNull(key, "A NamespacedKey must be provided");
+ Preconditions.checkNotNull(defaultName, "A default name must be specified");
this.key = key;
this.id = id;
@@ -96,8 +96,8 @@ public Research(
*
*/
public Research(@Nonnull NamespacedKey key, int id, @Nonnull String defaultName, int defaultCost) {
- Validate.notNull(key, "A NamespacedKey must be provided");
- Validate.notNull(defaultName, "A default name must be specified");
+ Preconditions.checkNotNull(key, "A NamespacedKey must be provided");
+ Preconditions.checkNotNull(defaultName, "A default name must be specified");
this.key = key;
this.id = id;
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 45d086efc6..b5a41ee8d5 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.core;
+import com.google.common.base.Preconditions;
import io.github.bakedlibs.dough.collections.KeyMap;
import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource;
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
@@ -28,7 +29,6 @@
import javax.annotation.Nonnull;
import me.mrCookieSlime.Slimefun.api.BlockInfoConfig;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
-import org.apache.commons.lang3.Validate;
import org.bukkit.NamespacedKey;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
@@ -76,7 +76,7 @@ public final class SlimefunRegistry {
private final Map, Set> globalItemHandlers = new HashMap<>();
public void load(@Nonnull Slimefun plugin) {
- Validate.notNull(plugin, "The Plugin cannot be null!");
+ Preconditions.checkNotNull(plugin, "The Plugin cannot be null!");
soulboundKey = new NamespacedKey(plugin, "soulbound");
itemChargeKey = new NamespacedKey(plugin, "item_charge");
@@ -181,7 +181,7 @@ public List getMultiBlocks() {
*/
@Nonnull
public SlimefunGuideImplementation getSlimefunGuide(@Nonnull SlimefunGuideMode mode) {
- Validate.notNull(mode, "The Guide mode cannot be null");
+ Preconditions.checkNotNull(mode, "The Guide mode cannot be null");
SlimefunGuideImplementation guide = guides.get(mode);
@@ -246,7 +246,7 @@ public Map, Set> getGlobalItemHandlers
@Nonnull
public Set getGlobalItemHandlers(@Nonnull Class extends ItemHandler> identifier) {
- Validate.notNull(identifier, "The identifier for an ItemHandler cannot be null!");
+ Preconditions.checkNotNull(identifier, "The identifier for an ItemHandler cannot be null!");
return globalItemHandlers.computeIfAbsent(identifier, c -> new HashSet<>());
}
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 0ed21c8119..7f3383235a 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
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.core.attributes;
+import com.google.common.base.Preconditions;
import com.xzavier0722.mc.plugin.slimefun4.storage.controller.ASlimefunDataContainer;
import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData;
import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils;
@@ -14,7 +15,6 @@
import java.util.logging.Level;
import javax.annotation.Nonnull;
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Location;
/**
@@ -103,7 +103,7 @@ default int getCharge(@Nonnull Location l) {
default int getCharge(@Nonnull Location l, @Nonnull Config config) {
Slimefun.logger().log(Level.FINE, "正在调用旧 BlockStorage 的方法, 建议使用对应附属的新方块存储适配版.");
- Validate.notNull(l, "Location was null!");
+ Preconditions.checkNotNull(l, "Location was null!");
// Emergency fallback, this cannot hold a charge, so we'll just return zero
if (!isChargeable()) {
@@ -149,8 +149,8 @@ default long getChargeLong(@Nonnull Location l, @Nonnull SlimefunBlockData data)
* @return The charge stored at that {@link Location}
*/
default long getChargeLong(@Nonnull Location l, @Nonnull ASlimefunDataContainer data) {
- Validate.notNull(l, "Location was null!");
- Validate.notNull(data, "data was null!");
+ Preconditions.checkNotNull(l, "Location was null!");
+ Preconditions.checkNotNull(data, "data was null!");
// Emergency fallback, this cannot hold a charge, so we'll just return zero
if (!isChargeable()) {
@@ -183,8 +183,8 @@ default void setCharge(@Nonnull Location l, int charge) {
* The new charge
*/
default void setCharge(@Nonnull Location l, long charge) {
- Validate.notNull(l, "Location was null!");
- Validate.isTrue(charge >= 0, "You can only set a charge of zero or more!");
+ Preconditions.checkNotNull(l, "Location was null!");
+ Preconditions.checkArgument(charge >= 0, "You can only set a charge of zero or more!");
try {
long capacity = getCapacity();
@@ -232,8 +232,8 @@ default void addCharge(@Nonnull Location l, int charge) {
}
default void addCharge(@Nonnull Location l, long charge) {
- Validate.notNull(l, "Location was null!");
- Validate.isTrue(charge > 0, "You can only add a positive charge!");
+ Preconditions.checkNotNull(l, "Location was null!");
+ Preconditions.checkArgument(charge > 0, "You can only add a positive charge!");
try {
long capacity = getCapacityLong();
@@ -271,8 +271,8 @@ default void removeCharge(@Nonnull Location l, int charge) {
}
default void removeCharge(@Nonnull Location l, long charge) {
- Validate.notNull(l, "Location was null!");
- Validate.isTrue(charge > 0, "The charge to remove must be greater than zero!");
+ Preconditions.checkNotNull(l, "Location was null!");
+ Preconditions.checkArgument(charge > 0, "The charge to remove must be greater than zero!");
try {
long capacity = getCapacityLong();
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 371ceaa34b..191ff509f1 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,12 +1,12 @@
package io.github.thebusybiscuit.slimefun4.core.attributes;
+import com.google.common.base.Preconditions;
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.lang3.Validate;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
@@ -90,7 +90,7 @@ default float getItemCharge(ItemStack item) {
* @return Whether the given charge could be added successfully
*/
default boolean addItemCharge(ItemStack item, float charge) {
- Validate.isTrue(charge > 0, "Charge must be above zero!");
+ Preconditions.checkArgument(charge > 0, "Charge must be above zero!");
if (item == null || item.getType() == Material.AIR) {
throw new IllegalArgumentException("Cannot add Item charge for null or AIR");
@@ -125,7 +125,7 @@ default boolean addItemCharge(ItemStack item, float charge) {
* @return Whether the given charge could be removed successfully
*/
default boolean removeItemCharge(ItemStack item, float charge) {
- Validate.isTrue(charge > 0, "Charge must be above zero!");
+ Preconditions.checkArgument(charge > 0, "Charge must be above zero!");
if (item == null || item.getType() == Material.AIR) {
throw new IllegalArgumentException("Cannot remove Item charge for null or AIR");
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 c918e33e4e..f852ae62ce 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,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.core.commands;
+import com.google.common.base.Preconditions;
import io.github.bakedlibs.dough.common.ChatColors;
import io.github.thebusybiscuit.slimefun4.core.commands.subcommands.SlimefunSubCommands;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
@@ -9,7 +10,6 @@
import java.util.Map;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
-import org.apache.commons.lang3.Validate;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@@ -41,7 +41,7 @@ public SlimefunCommand(@Nonnull Slimefun plugin) {
}
public void register() {
- Validate.isTrue(!registered, "Slimefun's subcommands have already been registered!");
+ Preconditions.checkArgument(!registered, "Slimefun's subcommands have already been registered!");
registered = true;
plugin.getServer().getPluginManager().registerEvents(this, plugin);
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 59020b7ddd..0351f7d159 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
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.core.commands.subcommands;
+import com.google.common.base.Preconditions;
import com.xzavier0722.mc.plugin.slimefun4.storage.callback.IAsyncReadCallback;
import io.github.thebusybiscuit.slimefun4.api.player.PlayerBackpack;
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
@@ -14,7 +15,6 @@
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
@@ -93,7 +93,7 @@ public void onResultNotFound() {
}
private void openBackpackMenu(@Nonnull OfflinePlayer owner, @Nonnull Player p) {
- Validate.notNull(p, "The player cannot be null!");
+ Preconditions.checkNotNull(p, "The player cannot be null!");
Slimefun.getDatabaseManager()
.getProfileDataController()
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 17a180b08d..e68e2ab347 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
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.core.config;
+import com.google.common.base.Preconditions;
import io.github.bakedlibs.dough.config.Config;
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
import io.github.thebusybiscuit.slimefun4.api.items.ItemState;
@@ -13,7 +14,6 @@
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import lombok.Getter;
-import org.apache.commons.lang3.Validate;
import org.bukkit.NamespacedKey;
import org.bukkit.Server;
@@ -72,7 +72,7 @@ public class SlimefunConfigManager {
private boolean bypassItemLengthCheck;
public SlimefunConfigManager(@Nonnull Slimefun plugin) {
- Validate.notNull(plugin, "The Plugin instance cannot be null");
+ Preconditions.checkNotNull(plugin, "The Plugin instance cannot be null");
this.plugin = plugin;
pluginConfig = getConfig(plugin, "config", () -> new Config(plugin));
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 1361df4df9..5a4d7e8914 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,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.core.guide;
+import com.google.common.base.Preconditions;
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
@@ -7,7 +8,6 @@
import java.util.LinkedList;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import org.apache.commons.lang3.Validate;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@@ -34,7 +34,7 @@ public class GuideHistory {
* The {@link PlayerProfile} this {@link GuideHistory} was made for
*/
public GuideHistory(@Nonnull PlayerProfile profile) {
- Validate.notNull(profile, "Cannot create a GuideHistory without a PlayerProfile!");
+ Preconditions.checkNotNull(profile, "Cannot create a GuideHistory without a PlayerProfile!");
this.profile = profile;
}
@@ -52,7 +52,7 @@ public void clear() {
* The current page of the main menu that should be stored
*/
public void setMainMenuPage(int page) {
- Validate.isTrue(page >= 1, "page must be greater than 0!");
+ Preconditions.checkArgument(page >= 1, "page must be greater than 0!");
mainMenuPage = page;
}
@@ -101,7 +101,7 @@ public void add(@Nonnull ItemStack item, int page) {
* The {@link SlimefunItem} that should be added to this {@link GuideHistory}
*/
public void add(@Nonnull SlimefunItem item) {
- Validate.notNull(item, "Cannot add a non-existing SlimefunItem to the GuideHistory!");
+ Preconditions.checkNotNull(item, "Cannot add a non-existing SlimefunItem to the GuideHistory!");
queue.add(new GuideEntry<>(item, 0));
}
@@ -112,13 +112,13 @@ public void add(@Nonnull SlimefunItem item) {
* The term that the {@link Player} searched for
*/
public void add(@Nonnull String searchTerm) {
- Validate.notNull(searchTerm, "Cannot add an empty Search Term to the GuideHistory!");
+ Preconditions.checkNotNull(searchTerm, "Cannot add an empty Search Term to the GuideHistory!");
queue.add(new GuideEntry<>(searchTerm, 0));
}
private void refresh(@Nonnull T object, int page) {
- Validate.notNull(object, "Cannot add a null Entry to the GuideHistory!");
- Validate.isTrue(page >= 0, "page must not be negative!");
+ Preconditions.checkNotNull(object, "Cannot add a null Entry to the GuideHistory!");
+ Preconditions.checkArgument(page >= 0, "page must not be negative!");
GuideEntry> lastEntry = getLastEntry(false);
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 6d22116c47..19c9cf4f6d 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
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.core.handlers;
+import com.google.common.base.Preconditions;
import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData;
import io.github.bakedlibs.dough.collections.LoopIterator;
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
@@ -11,7 +12,6 @@
import java.util.List;
import javax.annotation.Nonnull;
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
@@ -35,7 +35,9 @@ public class RainbowTickHandler extends BlockTicker {
private Material material;
public RainbowTickHandler(@Nonnull List materials) {
- Validate.noNullElements(materials, "A RainbowTicker cannot have a Material that is null!");
+ for (Material material : materials) {
+ Preconditions.checkNotNull(material, "A RainbowTicker cannot have a Material that is null!");
+ }
if (materials.isEmpty()) {
throw new IllegalArgumentException("A RainbowTicker must have at least one Material associated with it!");
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 41a244141a..5a8f411a99 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,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.core.machines;
+import com.google.common.base.Preconditions;
import io.github.bakedlibs.dough.blocks.BlockPosition;
import io.github.thebusybiscuit.slimefun4.api.events.AsyncMachineOperationFinishEvent;
import io.github.thebusybiscuit.slimefun4.core.attributes.MachineProcessHolder;
@@ -9,7 +10,6 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.Block;
@@ -42,7 +42,7 @@ public class MachineProcessor {
* The owner of this {@link MachineProcessor}.
*/
public MachineProcessor(@Nonnull MachineProcessHolder owner) {
- Validate.notNull(owner, "The MachineProcessHolder cannot be null.");
+ Preconditions.checkNotNull(owner, "The MachineProcessHolder cannot be null.");
this.owner = owner;
}
@@ -90,8 +90,8 @@ public void setProgressBar(@Nullable ItemStack progressBar) {
* {@link MachineOperation} has already been started at that {@link Location}.
*/
public boolean startOperation(@Nonnull Location loc, @Nonnull T operation) {
- Validate.notNull(loc, "The location must not be null");
- Validate.notNull(operation, "The operation cannot be null");
+ Preconditions.checkNotNull(loc, "The location must not be null");
+ Preconditions.checkNotNull(operation, "The operation cannot be null");
return startOperation(new BlockPosition(loc), operation);
}
@@ -108,8 +108,8 @@ public boolean startOperation(@Nonnull Location loc, @Nonnull T operation) {
* {@link MachineOperation} has already been started at that {@link Block}.
*/
public boolean startOperation(@Nonnull Block b, @Nonnull T operation) {
- Validate.notNull(b, "The Block must not be null");
- Validate.notNull(operation, "The machine operation cannot be null");
+ Preconditions.checkNotNull(b, "The Block must not be null");
+ Preconditions.checkNotNull(operation, "The machine operation cannot be null");
return startOperation(new BlockPosition(b), operation);
}
@@ -126,8 +126,8 @@ public boolean startOperation(@Nonnull Block b, @Nonnull T operation) {
* {@link MachineOperation} has already been started at that {@link BlockPosition}.
*/
public boolean startOperation(@Nonnull BlockPosition pos, @Nonnull T operation) {
- Validate.notNull(pos, "The BlockPosition must not be null");
- Validate.notNull(operation, "The machine operation cannot be null");
+ Preconditions.checkNotNull(pos, "The BlockPosition must not be null");
+ Preconditions.checkNotNull(operation, "The machine operation cannot be null");
return machines.putIfAbsent(pos, operation) == null;
}
@@ -141,7 +141,7 @@ public boolean startOperation(@Nonnull BlockPosition pos, @Nonnull T operation)
* @return The current {@link MachineOperation} or null.
*/
@Nullable public T getOperation(@Nonnull Location loc) {
- Validate.notNull(loc, "The location cannot be null");
+ Preconditions.checkNotNull(loc, "The location cannot be null");
return getOperation(new BlockPosition(loc));
}
@@ -155,7 +155,7 @@ public boolean startOperation(@Nonnull BlockPosition pos, @Nonnull T operation)
* @return The current {@link MachineOperation} or null.
*/
@Nullable public T getOperation(@Nonnull Block b) {
- Validate.notNull(b, "The Block cannot be null");
+ Preconditions.checkNotNull(b, "The Block cannot be null");
return getOperation(new BlockPosition(b));
}
@@ -169,7 +169,7 @@ public boolean startOperation(@Nonnull BlockPosition pos, @Nonnull T operation)
* @return The current {@link MachineOperation} or null.
*/
@Nullable public T getOperation(@Nonnull BlockPosition pos) {
- Validate.notNull(pos, "The BlockPosition must not be null");
+ Preconditions.checkNotNull(pos, "The BlockPosition must not be null");
return machines.get(pos);
}
@@ -184,7 +184,7 @@ public boolean startOperation(@Nonnull BlockPosition pos, @Nonnull T operation)
* {@link MachineOperation} to begin with.
*/
public boolean endOperation(@Nonnull Location loc) {
- Validate.notNull(loc, "The location should not be null");
+ Preconditions.checkNotNull(loc, "The location should not be null");
return endOperation(new BlockPosition(loc));
}
@@ -199,7 +199,7 @@ public boolean endOperation(@Nonnull Location loc) {
* {@link MachineOperation} to begin with.
*/
public boolean endOperation(@Nonnull Block b) {
- Validate.notNull(b, "The Block should not be null");
+ Preconditions.checkNotNull(b, "The Block should not be null");
return endOperation(new BlockPosition(b));
}
@@ -214,7 +214,7 @@ public boolean endOperation(@Nonnull Block b) {
* {@link MachineOperation} to begin with.
*/
public boolean endOperation(@Nonnull BlockPosition pos) {
- Validate.notNull(pos, "The BlockPosition cannot be null");
+ Preconditions.checkNotNull(pos, "The BlockPosition cannot be null");
T operation = machines.remove(pos);
@@ -237,8 +237,8 @@ public boolean endOperation(@Nonnull BlockPosition pos) {
}
public void updateProgressBar(@Nonnull BlockMenu inv, int slot, @Nonnull T operation) {
- Validate.notNull(inv, "The inventory must not be null.");
- Validate.notNull(operation, "The MachineOperation must not be null.");
+ Preconditions.checkNotNull(inv, "The inventory must not be null.");
+ Preconditions.checkNotNull(operation, "The MachineOperation must not be null.");
if (getProgressBar() == null) {
// No progress bar, no need to update anything.
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 568985ec7d..c69eecb990 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,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.core.multiblocks;
+import com.google.common.base.Preconditions;
import io.github.thebusybiscuit.slimefun4.api.events.MultiBlockInteractEvent;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.core.handlers.MultiBlockInteractionHandler;
@@ -9,7 +10,6 @@
import java.util.Set;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Material;
import org.bukkit.Tag;
import org.bukkit.World;
@@ -52,7 +52,7 @@ public static Set> getSupportedTags() {
private final boolean isSymmetric;
public MultiBlock(@Nonnull SlimefunItem item, Material[] build, @Nonnull BlockFace trigger) {
- Validate.notNull(item, "A MultiBlock requires a SlimefunItem!");
+ Preconditions.checkNotNull(item, "A MultiBlock requires a SlimefunItem!");
if (build == null || build.length != 9) {
throw new IllegalArgumentException("MultiBlocks must have a length of 9!");
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 d333f106f9..e4699f5117 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
@@ -22,7 +22,6 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
@@ -87,7 +86,7 @@ protected void registerDefaultRecipes(@Nonnull List recipes) {
}
public void addRecipe(ItemStack[] input, ItemStack output) {
- Validate.notNull(output, "Recipes must have an Output!");
+ Preconditions.checkNotNull(output, "Recipes must have an Output!");
recipes.add(input);
recipes.add(new ItemStack[] {output});
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 a094ec4c55..a4370f1cab 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
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.core.networks;
+import com.google.common.base.Preconditions;
import com.xzavier0722.mc.plugin.slimefun4.storage.util.LocationUtils;
import io.github.bakedlibs.dough.blocks.BlockPosition;
import io.github.bakedlibs.dough.blocks.ChunkPosition;
@@ -19,7 +20,6 @@
import java.util.logging.Level;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Location;
import org.bukkit.Server;
@@ -64,7 +64,7 @@ public class NetworkManager {
* Whether excess items from a {@link CargoNet} should be voided
*/
public NetworkManager(int maxStepSize, boolean enableVisualizer, boolean deleteExcessItems) {
- Validate.isTrue(maxStepSize > 0, "The maximal Network size must be above zero!");
+ Preconditions.checkArgument(maxStepSize > 0, "The maximal Network size must be above zero!");
this.enableVisualizer = enableVisualizer;
this.deleteExcessItems = deleteExcessItems;
@@ -127,7 +127,7 @@ public Optional getNetworkFromLocation(@Nullable Location
return Optional.empty();
}
- Validate.notNull(type, "Type must not be null");
+ Preconditions.checkNotNull(type, "Type must not be null");
ChunkPosition chunkPos = new ChunkPosition(l);
List chunkNetworks = networks.get(chunkPos);
@@ -152,7 +152,7 @@ public List getNetworksFromLocation(@Nullable Location l,
return new ArrayList<>();
}
- Validate.notNull(type, "Type must not be null");
+ Preconditions.checkNotNull(type, "Type must not be null");
List list = new ArrayList<>();
ChunkPosition chunkPos = new ChunkPosition(l);
@@ -178,7 +178,7 @@ public List getNetworksFromLocation(@Nullable Location l,
* The {@link Network} to register
*/
public void registerNetwork(@Nonnull Network network) {
- Validate.notNull(network, "Cannot register a null Network");
+ Preconditions.checkNotNull(network, "Cannot register a null Network");
Debug.log(
TestCase.ENERGYNET, "Registering network @ " + LocationUtils.locationToString(network.getRegulator()));
@@ -201,7 +201,7 @@ public void registerNetwork(@Nonnull Network network) {
* The {@link Network} to remove
*/
public void unregisterNetwork(@Nonnull Network network) {
- Validate.notNull(network, "Cannot unregister a null Network");
+ Preconditions.checkNotNull(network, "Cannot unregister a null Network");
Debug.log(
TestCase.ENERGYNET,
@@ -223,7 +223,7 @@ public void unregisterNetwork(@Nonnull Network network) {
* The {@link Location} to update
*/
public void updateAllNetworks(@Nonnull Location l) {
- Validate.notNull(l, "The Location cannot be null");
+ Preconditions.checkNotNull(l, "The Location cannot be null");
Debug.log(TestCase.ENERGYNET, "Updating all networks now.");
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 a2a665accb..18d4894644 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,8 +1,8 @@
package io.github.thebusybiscuit.slimefun4.core.networks.cargo;
+import com.google.common.base.Preconditions;
import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper;
import javax.annotation.Nonnull;
-import org.apache.commons.lang3.Validate;
import org.bukkit.inventory.ItemStack;
class ItemStackAndInteger {
@@ -12,7 +12,7 @@ class ItemStackAndInteger {
private int number;
ItemStackAndInteger(@Nonnull ItemStack item, int amount) {
- Validate.notNull(item, "Item cannot be null!");
+ Preconditions.checkNotNull(item, "Item cannot be null!");
this.number = amount;
this.item = item;
}
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 1deb56a38c..1d56450624 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
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.core.services;
+import com.google.common.base.Preconditions;
import com.xzavier0722.mc.plugin.slimefun4.storage.controller.StorageType;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import java.io.File;
@@ -16,7 +17,6 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import javax.annotation.Nonnull;
-import org.apache.commons.lang3.Validate;
/**
* This Service creates a Backup of your Slimefun world data on every server shutdown.
@@ -86,7 +86,7 @@ public void run() {
}
private void createBackup(@Nonnull ZipOutputStream output) throws IOException {
- Validate.notNull(output, "The Output Stream cannot be null!");
+ Preconditions.checkNotNull(output, "The Output Stream cannot be null!");
if (Slimefun.getDatabaseManager().getProfileStorageType() == StorageType.SQLITE) {
addFile(output, new File("data-storage/Slimefun", "profile.db"), "");
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 bc06e32ea9..529962af28 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,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.core.services;
+import com.google.common.base.Preconditions;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
import io.papermc.lib.PaperLib;
@@ -8,7 +9,6 @@
import java.util.logging.Level;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Bukkit;
import org.bukkit.Keyed;
import org.bukkit.Material;
@@ -88,8 +88,8 @@ public void updateUniversalDataUUID(@Nonnull Block b, @Nonnull String uuid) {
* The value to store
*/
public void setBlockData(@Nonnull Block b, @Nonnull NamespacedKey key, @Nonnull String value) {
- Validate.notNull(b, "The block cannot be null!");
- Validate.notNull(value, "The value cannot be null!");
+ Preconditions.checkNotNull(b, "The block cannot be null!");
+ Preconditions.checkNotNull(value, "The value cannot be null!");
/**
* Don't use PaperLib here, it seems to be quite buggy in block-placing scenarios
@@ -155,7 +155,7 @@ public Optional getUniversalDataUUID(@Nonnull Block b) {
}
public Optional getBlockData(@Nonnull Block b, @Nonnull NamespacedKey key) {
- Validate.notNull(b, "The block cannot be null!");
+ Preconditions.checkNotNull(b, "The block cannot be null!");
BlockState state = PaperLib.getBlockState(b, false).getState();
PersistentDataContainer container = getPersistentDataContainer(state);
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 1881d58e98..e883a0ac59 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,11 +1,11 @@
package io.github.thebusybiscuit.slimefun4.core.services;
+import com.google.common.base.Preconditions;
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.lang3.Validate;
import org.bukkit.Keyed;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
@@ -61,8 +61,8 @@ public NamespacedKey getKey() {
* The id to store on the {@link ItemStack}
*/
public void setItemData(@Nonnull ItemStack item, @Nonnull String id) {
- Validate.notNull(item, "The Item cannot be null!");
- Validate.notNull(id, "Cannot store null on an Item!");
+ Preconditions.checkNotNull(item, "The Item cannot be null!");
+ Preconditions.checkNotNull(id, "Cannot store null on an Item!");
ItemMeta im = item.getItemMeta();
setItemData(im, id);
@@ -79,8 +79,8 @@ public void setItemData(@Nonnull ItemStack item, @Nonnull String id) {
* The id to store on the {@link ItemMeta}
*/
public void setItemData(@Nonnull ItemMeta meta, @Nonnull String id) {
- Validate.notNull(meta, "The ItemMeta cannot be null!");
- Validate.notNull(id, "Cannot store null on an ItemMeta!");
+ Preconditions.checkNotNull(meta, "The ItemMeta cannot be null!");
+ Preconditions.checkNotNull(id, "Cannot store null on an ItemMeta!");
PersistentDataContainer container = meta.getPersistentDataContainer();
container.set(namespacedKey, PersistentDataType.STRING, id);
@@ -114,7 +114,7 @@ public void setItemData(@Nonnull ItemMeta meta, @Nonnull String id) {
* @return An {@link Optional} describing the result
*/
public @Nonnull Optional getItemData(@Nonnull ItemMeta meta) {
- Validate.notNull(meta, "Cannot read data from null!");
+ Preconditions.checkNotNull(meta, "Cannot read data from null!");
PersistentDataContainer container = meta.getPersistentDataContainer();
return Optional.ofNullable(container.get(namespacedKey, PersistentDataType.STRING));
@@ -133,8 +133,8 @@ public void setItemData(@Nonnull ItemMeta meta, @Nonnull String id) {
* @return Whether both metas have data on them and its the same.
*/
public boolean hasEqualItemData(@Nonnull ItemMeta meta1, @Nonnull ItemMeta meta2) {
- Validate.notNull(meta1, "Cannot read data from null (first arg)");
- Validate.notNull(meta2, "Cannot read data from null (second arg)");
+ Preconditions.checkNotNull(meta1, "Cannot read data from null (first arg)");
+ Preconditions.checkNotNull(meta2, "Cannot read data from null (second arg)");
Optional data1 = getItemData(meta1);
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 ae17ca9861..defc01fcea 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,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.core.services;
+import com.google.common.base.Preconditions;
import io.github.bakedlibs.dough.config.Config;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
@@ -12,7 +13,6 @@
import java.util.logging.Level;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import org.apache.commons.lang3.Validate;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.inventory.ItemStack;
@@ -75,7 +75,9 @@ public CustomTextureService(@Nonnull Config config) {
* Whether to save this file
*/
public void register(@Nonnull Collection items, boolean save) {
- Validate.notEmpty(items, "items must neither be null or empty.");
+ for (SlimefunItem item : items) {
+ Preconditions.checkNotNull(item, "items must neither be null or empty.");
+ }
loadDefaultValues();
@@ -133,7 +135,7 @@ public boolean isActive() {
* @return The configured custom model data
*/
public int getModelData(@Nonnull String id) {
- Validate.notNull(id, "Cannot get the ModelData for 'null'");
+ Preconditions.checkNotNull(id, "Cannot get the ModelData for 'null'");
return config.getInt(id);
}
@@ -148,8 +150,8 @@ public int getModelData(@Nonnull String id) {
* The id for which to get the configured model data
*/
public void setTexture(@Nonnull ItemStack item, @Nonnull String id) {
- Validate.notNull(item, "The Item cannot be null!");
- Validate.notNull(id, "Cannot store null on an Item!");
+ Preconditions.checkNotNull(item, "The Item cannot be null!");
+ Preconditions.checkNotNull(id, "Cannot store null on an Item!");
ItemMeta im = item.getItemMeta();
setTexture(im, id);
@@ -166,8 +168,8 @@ public void setTexture(@Nonnull ItemStack item, @Nonnull String id) {
* The id for which to get the configured model data
*/
public void setTexture(@Nonnull ItemMeta im, @Nonnull String id) {
- Validate.notNull(im, "The ItemMeta cannot be null!");
- Validate.notNull(id, "Cannot store null on an ItemMeta!");
+ Preconditions.checkNotNull(im, "The ItemMeta cannot be null!");
+ Preconditions.checkNotNull(id, "Cannot store null on an ItemMeta!");
int data = getModelData(id);
im.setCustomModelData(data == 0 ? null : data);
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 5106b69bb0..bd5ad6be63 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,6 @@
package io.github.thebusybiscuit.slimefun4.core.services;
+import com.google.common.base.Preconditions;
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;
@@ -20,7 +21,6 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
-import org.apache.commons.lang3.Validate;
import org.bukkit.NamespacedKey;
import org.bukkit.Server;
import org.bukkit.configuration.InvalidConfigurationException;
@@ -112,7 +112,7 @@ public NamespacedKey getKey() {
@Override
@Nullable public Language getLanguage(@Nonnull String id) {
- Validate.notNull(id, "The language id cannot be null");
+ Preconditions.checkNotNull(id, "The language id cannot be null");
return languages.get(id);
}
@@ -124,7 +124,7 @@ public Collection getLanguages() {
@Override
public boolean hasLanguage(@Nonnull String id) {
- Validate.notNull(id, "The language id cannot be null");
+ Preconditions.checkNotNull(id, "The language id cannot be null");
// Checks if our jar files contains a messages.yml file for that language
String file = LanguageFile.MESSAGES.getFilePath(id);
@@ -140,7 +140,7 @@ public boolean hasLanguage(@Nonnull String id) {
* @return Whether or not this {@link Language} is loaded
*/
public boolean isLanguageLoaded(@Nonnull String id) {
- Validate.notNull(id, "The language cannot be null!");
+ Preconditions.checkNotNull(id, "The language cannot be null!");
return languages.containsKey(id);
}
@@ -151,7 +151,7 @@ public Language getDefaultLanguage() {
@Override
public Language getLanguage(@Nonnull Player p) {
- Validate.notNull(p, "Player cannot be null!");
+ Preconditions.checkNotNull(p, "Player cannot be null!");
PersistentDataContainer container = p.getPersistentDataContainer();
String language = container.get(languageKey, PersistentDataType.STRING);
@@ -205,8 +205,8 @@ private void copyToDefaultLanguage(String language, LanguageFile file) {
@Override
protected void addLanguage(@Nonnull String id, @Nonnull String texture) {
- Validate.notNull(id, "The language id cannot be null!");
- Validate.notNull(texture, "The language texture cannot be null");
+ Preconditions.checkNotNull(id, "The language id cannot be null!");
+ Preconditions.checkNotNull(texture, "The language texture cannot be null");
if (hasLanguage(id)) {
Language language = new Language(id, texture);
@@ -233,7 +233,7 @@ protected void addLanguage(@Nonnull String id, @Nonnull String texture) {
* @return A percentage {@code (0.0 - 100.0)} for the progress of translation of that {@link Language}
*/
public double calculateProgress(@Nonnull Language lang) {
- Validate.notNull(lang, "Cannot get the language progress of null");
+ Preconditions.checkNotNull(lang, "Cannot get the language progress of null");
Set defaultKeys = getTotalKeys(languages.get("en"));
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 856a70b303..b43ce17403 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,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.core.services;
+import com.google.common.base.Preconditions;
import io.github.bakedlibs.dough.recipes.MinecraftRecipe;
import io.github.bakedlibs.dough.recipes.RecipeSnapshot;
import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide;
@@ -11,7 +12,6 @@
import java.util.function.Consumer;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Bukkit;
import org.bukkit.Keyed;
import org.bukkit.NamespacedKey;
@@ -83,7 +83,7 @@ public void refresh() {
* A callback to run when the {@link RecipeSnapshot} has been created.
*/
public void subscribe(@Nonnull Consumer subscription) {
- Validate.notNull(subscription, "Callback must not be null!");
+ Preconditions.checkNotNull(subscription, "Callback must not be null!");
subscriptions.add(subscription);
}
@@ -129,7 +129,7 @@ public boolean isSmeltable(@Nullable ItemStack input) {
* @return An Array of {@link RecipeChoice} representing the shape of this {@link Recipe}
*/
public @Nonnull RecipeChoice[] getRecipeShape(@Nonnull Recipe recipe) {
- Validate.notNull(recipe, "Recipe must not be null!");
+ Preconditions.checkNotNull(recipe, "Recipe must not be null!");
if (recipe instanceof ShapedRecipe shapedRecipe) {
List choices = new LinkedList<>();
@@ -182,7 +182,7 @@ public boolean isSmeltable(@Nullable ItemStack input) {
* @return The corresponding {@link Recipe} or null
*/
public @Nullable Recipe getRecipe(@Nonnull NamespacedKey key) {
- Validate.notNull(key, "The NamespacedKey should not be null");
+ Preconditions.checkNotNull(key, "The NamespacedKey should not be null");
if (snapshot != null) {
// We operate on a cached HashMap which is much faster than Bukkit's method.
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 1769d1efb7..a7507bfb5b 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,6 @@
package io.github.thebusybiscuit.slimefun4.core.services;
+import com.google.common.base.Preconditions;
import io.github.bakedlibs.dough.collections.OptionalMap;
import io.github.bakedlibs.dough.config.Config;
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
@@ -17,7 +18,6 @@
import java.util.Set;
import java.util.UUID;
import javax.annotation.Nonnull;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Server;
import org.bukkit.World;
@@ -58,7 +58,7 @@ public void load(@Nonnull Iterable worlds) {
* The {@link World} to load
*/
public void load(@Nonnull World world) {
- Validate.notNull(world, "Cannot load a world that is null");
+ Preconditions.checkNotNull(world, "Cannot load a world that is null");
disabledItems.putIfAbsent(world.getUID(), loadWorldFromConfig(world));
}
@@ -73,8 +73,8 @@ public void load(@Nonnull World world) {
* @return Whether the given {@link SlimefunItem} is enabled in that {@link World}
*/
public boolean isEnabled(@Nonnull World world, @Nonnull SlimefunItem item) {
- Validate.notNull(world, "The world cannot be null");
- Validate.notNull(item, "The SlimefunItem cannot be null");
+ Preconditions.checkNotNull(world, "The world cannot be null");
+ Preconditions.checkNotNull(item, "The SlimefunItem cannot be null");
Set items = disabledItems.computeIfAbsent(world.getUID(), id -> loadWorldFromConfig(world));
@@ -96,8 +96,8 @@ public boolean isEnabled(@Nonnull World world, @Nonnull SlimefunItem item) {
* Whether the given {@link SlimefunItem} should be enabled in that world
*/
public void setEnabled(@Nonnull World world, @Nonnull SlimefunItem item, boolean enabled) {
- Validate.notNull(world, "The world cannot be null");
- Validate.notNull(item, "The SlimefunItem cannot be null");
+ Preconditions.checkNotNull(world, "The world cannot be null");
+ Preconditions.checkNotNull(item, "The SlimefunItem cannot be null");
Set items = disabledItems.computeIfAbsent(world.getUID(), id -> loadWorldFromConfig(world));
@@ -117,7 +117,7 @@ public void setEnabled(@Nonnull World world, @Nonnull SlimefunItem item, boolean
* Whether this {@link World} should be enabled or not
*/
public void setEnabled(@Nonnull World world, boolean enabled) {
- Validate.notNull(world, "null is not a valid World");
+ Preconditions.checkNotNull(world, "null is not a valid World");
load(world);
if (enabled) {
@@ -136,7 +136,7 @@ public void setEnabled(@Nonnull World world, boolean enabled) {
* @return Whether this {@link World} is enabled
*/
public boolean isWorldEnabled(@Nonnull World world) {
- Validate.notNull(world, "null is not a valid World");
+ Preconditions.checkNotNull(world, "null is not a valid World");
load(world);
return !disabledWorlds.contains(world.getUID());
@@ -153,8 +153,8 @@ public boolean isWorldEnabled(@Nonnull World world) {
* @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");
+ Preconditions.checkNotNull(world, "World cannot be null");
+ Preconditions.checkNotNull(addon, "Addon cannot be null");
return isWorldEnabled(world)
&& disabledAddons.getOrDefault(addon, Collections.emptySet()).contains(world.getName());
}
@@ -168,7 +168,7 @@ public boolean isAddonEnabled(@Nonnull World world, @Nonnull SlimefunAddon addon
* The {@link World} to save
*/
public void save(@Nonnull World world) {
- Validate.notNull(world, "Cannot save a World that does not exist");
+ Preconditions.checkNotNull(world, "Cannot save a World that does not exist");
Set items = disabledItems.computeIfAbsent(world.getUID(), id -> loadWorldFromConfig(world));
Config config = getConfig(world);
@@ -185,7 +185,7 @@ public void save(@Nonnull World world) {
@Nonnull
private Set loadWorldFromConfig(@Nonnull World world) {
- Validate.notNull(world, "Cannot load a World that does not exist");
+ Preconditions.checkNotNull(world, "Cannot load a World that does not exist");
String name = world.getName();
Optional> optional = disabledItems.get(world.getUID());
@@ -259,7 +259,7 @@ private void loadItemsFromWorldConfig(
*/
@Nonnull
private Config getConfig(@Nonnull World world) {
- Validate.notNull(world, "World cannot be null");
+ Preconditions.checkNotNull(world, "World cannot be null");
return new Config(plugin, "world-settings/" + world.getName() + ".yml");
}
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PermissionsService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PermissionsService.java
index 5a395dae75..de70b89b36 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PermissionsService.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PermissionsService.java
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.core.services;
+import com.google.common.base.Preconditions;
import io.github.bakedlibs.dough.config.Config;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
@@ -10,7 +11,6 @@
import java.util.Optional;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import org.apache.commons.lang3.Validate;
import org.bukkit.entity.Player;
import org.bukkit.permissions.Permissible;
import org.bukkit.permissions.Permission;
@@ -65,7 +65,7 @@ public void update(@Nonnull Iterable items, boolean save) {
}
public void update(@Nonnull SlimefunItem item, boolean save) {
- Validate.notNull(item, "The Item should not be null!");
+ Preconditions.checkNotNull(item, "The Item should not be null!");
String path = item.getId() + ".permission";
@@ -113,7 +113,7 @@ public boolean hasPermission(Permissible p, SlimefunItem item) {
*/
@Nonnull
public Optional getPermission(@Nonnull SlimefunItem item) {
- Validate.notNull(item, "Cannot get permissions for null");
+ Preconditions.checkNotNull(item, "Cannot get permissions for null");
String permission = permissions.get(item.getId());
if (permission == null || permission.equals("none")) {
@@ -132,7 +132,7 @@ public Optional getPermission(@Nonnull SlimefunItem item) {
* The {@link Permission} to set
*/
public void setPermission(@Nonnull SlimefunItem item, @Nullable String permission) {
- Validate.notNull(item, "You cannot set the permission for null");
+ Preconditions.checkNotNull(item, "You cannot set the permission for null");
permissions.put(item.getId(), permission != null ? permission : "none");
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/Contributor.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/Contributor.java
index f6e20865f0..cee0f14b0d 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/Contributor.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/Contributor.java
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.core.services.github;
+import com.google.common.base.Preconditions;
import io.github.bakedlibs.dough.data.TriStateOptional;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.utils.HeadTexture;
@@ -13,7 +14,6 @@
import java.util.concurrent.ConcurrentMap;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import org.apache.commons.lang3.Validate;
import org.bukkit.ChatColor;
/**
@@ -45,8 +45,8 @@ public class Contributor {
* A link to their GitHub profile
*/
public Contributor(@Nonnull String minecraftName, @Nonnull String profile) {
- Validate.notNull(minecraftName, "Username must never be null!");
- Validate.notNull(profile, "The profile cannot be null!");
+ Preconditions.checkNotNull(minecraftName, "Username must never be null!");
+ Preconditions.checkNotNull(profile, "The profile cannot be null!");
githubUsername = profile.substring(profile.lastIndexOf('/') + 1);
minecraftUsername = minecraftName;
@@ -60,7 +60,7 @@ public Contributor(@Nonnull String minecraftName, @Nonnull String profile) {
* The username of this {@link Contributor}
*/
public Contributor(@Nonnull String username) {
- Validate.notNull(username, "Username must never be null!");
+ Preconditions.checkNotNull(username, "Username must never be null!");
githubUsername = username;
minecraftUsername = username;
@@ -77,8 +77,8 @@ public Contributor(@Nonnull String username) {
* The amount of contributions made as that role
*/
public void setContributions(@Nonnull String role, int commits) {
- Validate.notNull(role, "The role cannot be null!");
- Validate.isTrue(commits >= 0, "Contributions cannot be negative");
+ Preconditions.checkNotNull(role, "The role cannot be null!");
+ Preconditions.checkArgument(commits >= 0, "Contributions cannot be negative");
contributions.put(role, commits);
}
@@ -137,7 +137,7 @@ public List> getContributions() {
* @return The amount of contributions this {@link Contributor} submitted as the given role
*/
public int getContributions(@Nonnull String role) {
- Validate.notNull(role, "The role cannot be null!");
+ Preconditions.checkNotNull(role, "The role cannot be null!");
return contributions.getOrDefault(role, 0);
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubService.java
index d6b3a4d1f3..e23f00f650 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubService.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubService.java
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.core.services.github;
+import com.google.common.base.Preconditions;
import io.github.bakedlibs.dough.config.Config;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.utils.HeadTexture;
@@ -15,7 +16,6 @@
import java.util.logging.Level;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import org.apache.commons.lang3.Validate;
/**
* This Service is responsible for grabbing every {@link Contributor} to this project
@@ -103,10 +103,10 @@ private void addContributor(@Nonnull String name, @Nonnull String role) {
public @Nonnull Contributor addContributor(
@Nonnull String minecraftName, @Nonnull String profileURL, @Nonnull String role, int commits) {
- Validate.notNull(minecraftName, "Minecraft username must not be null.");
- Validate.notNull(profileURL, "GitHub profile url must not be null.");
- Validate.notNull(role, "Role should not be null.");
- Validate.isTrue(commits >= 0, "Commit count cannot be negative.");
+ Preconditions.checkNotNull(minecraftName, "Minecraft username must not be null.");
+ Preconditions.checkNotNull(profileURL, "GitHub profile url must not be null.");
+ Preconditions.checkNotNull(role, "Role should not be null.");
+ Preconditions.checkArgument(commits >= 0, "Commit count cannot be negative.");
String username = profileURL.substring(profileURL.lastIndexOf('/') + 1);
@@ -118,9 +118,9 @@ private void addContributor(@Nonnull String name, @Nonnull String role) {
}
public @Nonnull Contributor addContributor(@Nonnull String username, @Nonnull String role, int commits) {
- Validate.notNull(username, "Username must not be null.");
- Validate.notNull(role, "Role should not be null.");
- Validate.isTrue(commits >= 0, "Commit count cannot be negative.");
+ Preconditions.checkNotNull(username, "Username must not be null.");
+ Preconditions.checkNotNull(role, "Role should not be null.");
+ Preconditions.checkArgument(commits >= 0, "Commit count cannot be negative.");
Contributor contributor = contributors.computeIfAbsent(username, key -> new Contributor(username));
contributor.setContributions(role, commits);
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/holograms/HologramsService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/holograms/HologramsService.java
index e4a8153c91..f7e7a2f64f 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/holograms/HologramsService.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/holograms/HologramsService.java
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.core.services.holograms;
+import com.google.common.base.Preconditions;
import io.github.bakedlibs.dough.blocks.BlockPosition;
import io.github.thebusybiscuit.slimefun4.core.attributes.HologramOwner;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
@@ -12,7 +13,6 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.NamespacedKey;
@@ -124,7 +124,7 @@ private void purge() {
* @return The existing (or newly created) hologram
*/
@Nullable private Hologram getHologram(@Nonnull Location loc, boolean createIfNoneExists) {
- Validate.notNull(loc, "Location cannot be null");
+ Preconditions.checkNotNull(loc, "Location cannot be null");
BlockPosition position = new BlockPosition(loc);
Hologram hologram = cache.get(position);
@@ -245,8 +245,8 @@ private boolean isHologram(@Nonnull Entity n) {
* The callback to run
*/
private void updateHologram(@Nonnull Location loc, @Nonnull Consumer consumer) {
- Validate.notNull(loc, "Location must not be null");
- Validate.notNull(consumer, "Callbacks must not be null");
+ Preconditions.checkNotNull(loc, "Location must not be null");
+ Preconditions.checkNotNull(consumer, "Callbacks must not be null");
Runnable runnable = () -> {
try {
@@ -280,7 +280,7 @@ private void updateHologram(@Nonnull Location loc, @Nonnull Consumer c
* exist or was already removed
*/
public boolean removeHologram(@Nonnull Location loc) {
- Validate.notNull(loc, "Location cannot be null");
+ Preconditions.checkNotNull(loc, "Location cannot be null");
if (Bukkit.isPrimaryThread()) {
try {
@@ -312,7 +312,7 @@ public boolean removeHologram(@Nonnull Location loc) {
* The label to set, can be null
*/
public void setHologramLabel(@Nonnull Location loc, @Nullable String label) {
- Validate.notNull(loc, "Location must not be null");
+ Preconditions.checkNotNull(loc, "Location must not be null");
updateHologram(loc, hologram -> hologram.setLabel(label));
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Language.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Language.java
index f600c74240..c8dc7d99b2 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Language.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Language.java
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.core.services.localization;
+import com.google.common.base.Preconditions;
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
import io.github.thebusybiscuit.slimefun4.core.services.LocalizationService;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
@@ -10,7 +11,6 @@
import java.util.Map;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Server;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
@@ -42,8 +42,8 @@ public final class Language {
* The hash of the skull texture to use
*/
public Language(@Nonnull String id, @Nonnull String hash) {
- Validate.notNull(id, "A Language must have an id that is not null!");
- Validate.notNull(hash, "A Language must have a texture that is not null!");
+ Preconditions.checkNotNull(id, "A Language must have an id that is not null!");
+ Preconditions.checkNotNull(hash, "A Language must have a texture that is not null!");
this.id = id;
this.item = SlimefunUtils.getCustomHead(hash);
@@ -84,8 +84,8 @@ public double getTranslationProgress() {
}
public void setFile(@Nonnull LanguageFile file, @Nonnull FileConfiguration config) {
- Validate.notNull(file, "The provided file should not be null.");
- Validate.notNull(config, "The provided config should not be null.");
+ Preconditions.checkNotNull(file, "The provided file should not be null.");
+ Preconditions.checkNotNull(config, "The provided config should not be null.");
files.put(file, config);
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/LanguageFile.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/LanguageFile.java
index 59e91258bb..f8658535e2 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/LanguageFile.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/LanguageFile.java
@@ -1,7 +1,7 @@
package io.github.thebusybiscuit.slimefun4.core.services.localization;
+import com.google.common.base.Preconditions;
import javax.annotation.Nonnull;
-import org.apache.commons.lang3.Validate;
/**
* This enum holds the different types of files each {@link Language} holds.
@@ -34,7 +34,7 @@ public String getFilePath(@Nonnull Language language) {
@Nonnull
public String getFilePath(@Nonnull String languageId) {
- Validate.notNull(languageId, "Language id must not be null!");
+ Preconditions.checkNotNull(languageId, "Language id must not be null!");
return "/languages/" + languageId + '/' + fileName;
}
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/SlimefunLocalization.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/SlimefunLocalization.java
index 726921b3ac..e919a920d2 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/SlimefunLocalization.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/SlimefunLocalization.java
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.core.services.localization;
+import com.google.common.base.Preconditions;
import io.github.bakedlibs.dough.common.ChatColors;
import io.github.bakedlibs.dough.config.Config;
import io.github.bakedlibs.dough.items.CustomItemStack;
@@ -20,7 +21,6 @@
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TextComponent;
-import org.apache.commons.lang3.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Keyed;
import org.bukkit.Material;
@@ -159,8 +159,8 @@ protected void loadEmbeddedLanguages() {
@ParametersAreNonnullByDefault
private @Nullable String getStringOrNull(@Nullable Language language, LanguageFile file, String path) {
- Validate.notNull(file, "You need to provide a LanguageFile!");
- Validate.notNull(path, "The path cannot be null!");
+ Preconditions.checkNotNull(file, "You need to provide a LanguageFile!");
+ Preconditions.checkNotNull(path, "The path cannot be null!");
if (language == null) {
// Unit-Test scenario (or something went horribly wrong)
@@ -194,8 +194,8 @@ protected void loadEmbeddedLanguages() {
@ParametersAreNonnullByDefault
private @Nullable List getStringListOrNull(@Nullable Language language, LanguageFile file, String path) {
- Validate.notNull(file, "You need to provide a LanguageFile!");
- Validate.notNull(path, "The path cannot be null!");
+ Preconditions.checkNotNull(file, "You need to provide a LanguageFile!");
+ Preconditions.checkNotNull(path, "The path cannot be null!");
if (language == null) {
// Unit-Test scenario (or something went horribly wrong)
@@ -228,7 +228,7 @@ protected void loadEmbeddedLanguages() {
}
public @Nonnull String getMessage(@Nonnull String key) {
- Validate.notNull(key, "Message key must not be null!");
+ Preconditions.checkNotNull(key, "Message key must not be null!");
Language language = getDefaultLanguage();
@@ -244,8 +244,8 @@ protected void loadEmbeddedLanguages() {
}
public @Nonnull String getMessage(@Nonnull Player p, @Nonnull String key) {
- Validate.notNull(p, "Player must not be null!");
- Validate.notNull(key, "Message key must not be null!");
+ Preconditions.checkNotNull(p, "Player must not be null!");
+ Preconditions.checkNotNull(key, "Message key must not be null!");
return getString(getLanguage(p), LanguageFile.MESSAGES, key);
}
@@ -262,17 +262,17 @@ protected void loadEmbeddedLanguages() {
}
public @Nonnull List getMessages(@Nonnull Player p, @Nonnull String key) {
- Validate.notNull(p, "Player should not be null.");
- Validate.notNull(key, "Message key cannot be null.");
+ Preconditions.checkNotNull(p, "Player should not be null.");
+ Preconditions.checkNotNull(key, "Message key cannot be null.");
return getStringList(getLanguage(p), LanguageFile.MESSAGES, key);
}
@ParametersAreNonnullByDefault
public @Nonnull List getMessages(Player p, String key, UnaryOperator function) {
- Validate.notNull(p, "Player cannot be null.");
- Validate.notNull(key, "Message key cannot be null.");
- Validate.notNull(function, "Function cannot be null.");
+ Preconditions.checkNotNull(p, "Player cannot be null.");
+ Preconditions.checkNotNull(key, "Message key cannot be null.");
+ Preconditions.checkNotNull(function, "Function cannot be null.");
List messages = getMessages(p, key);
messages.replaceAll(function);
@@ -281,29 +281,29 @@ protected void loadEmbeddedLanguages() {
}
public @Nullable String getResearchName(@Nonnull Player p, @Nonnull NamespacedKey key) {
- Validate.notNull(p, "Player must not be null.");
- Validate.notNull(key, "NamespacedKey cannot be null.");
+ Preconditions.checkNotNull(p, "Player must not be null.");
+ Preconditions.checkNotNull(key, "NamespacedKey cannot be null.");
return getStringOrNull(getLanguage(p), LanguageFile.RESEARCHES, key.getNamespace() + '.' + key.getKey());
}
public @Nullable String getItemGroupName(@Nonnull Player p, @Nonnull NamespacedKey key) {
- Validate.notNull(p, "Player must not be null.");
- Validate.notNull(key, "NamespacedKey cannot be null!");
+ Preconditions.checkNotNull(p, "Player must not be null.");
+ Preconditions.checkNotNull(key, "NamespacedKey cannot be null!");
return getStringOrNull(getLanguage(p), LanguageFile.CATEGORIES, key.getNamespace() + '.' + key.getKey());
}
public @Nullable String getResourceString(@Nonnull Player p, @Nonnull String key) {
- Validate.notNull(p, "Player should not be null!");
- Validate.notNull(key, "Message key should not be null!");
+ Preconditions.checkNotNull(p, "Player should not be null!");
+ Preconditions.checkNotNull(key, "Message key should not be null!");
return getStringOrNull(getLanguage(p), LanguageFile.RESOURCES, key);
}
public @Nonnull ItemStack getRecipeTypeItem(@Nonnull Player p, @Nonnull RecipeType recipeType) {
- Validate.notNull(p, "Player cannot be null!");
- Validate.notNull(recipeType, "Recipe type cannot be null!");
+ Preconditions.checkNotNull(p, "Player cannot be null!");
+ Preconditions.checkNotNull(recipeType, "Recipe type cannot be null!");
ItemStack item = recipeType.toItem();
@@ -340,8 +340,8 @@ protected void loadEmbeddedLanguages() {
}
public void sendMessage(@Nonnull CommandSender recipient, @Nonnull String key, boolean addPrefix) {
- Validate.notNull(recipient, "Recipient cannot be null!");
- Validate.notNull(key, "Message key cannot be null!");
+ Preconditions.checkNotNull(recipient, "Recipient cannot be null!");
+ Preconditions.checkNotNull(key, "Message key cannot be null!");
String prefix = addPrefix ? getChatPrefix() : "";
@@ -353,8 +353,8 @@ public void sendMessage(@Nonnull CommandSender recipient, @Nonnull String key, b
}
public void sendActionbarMessage(@Nonnull Player player, @Nonnull String key, boolean addPrefix) {
- Validate.notNull(player, "Player cannot be null!");
- Validate.notNull(key, "Message key cannot be null!");
+ Preconditions.checkNotNull(player, "Player cannot be null!");
+ Preconditions.checkNotNull(key, "Message key cannot be null!");
String prefix = addPrefix ? getChatPrefix() : "";
String message = ChatColors.color(prefix + getMessage(player, key));
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/PerformanceRating.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/PerformanceRating.java
index 72c30ab084..b3a318ea04 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/PerformanceRating.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/PerformanceRating.java
@@ -1,9 +1,9 @@
package io.github.thebusybiscuit.slimefun4.core.services.profiler;
+import com.google.common.base.Preconditions;
import java.util.function.Predicate;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import org.apache.commons.lang3.Validate;
import org.bukkit.ChatColor;
/**
@@ -33,7 +33,7 @@ public enum PerformanceRating implements Predicate {
private final float threshold;
PerformanceRating(@Nonnull ChatColor color, float threshold) {
- Validate.notNull(color, "Color cannot be null");
+ Preconditions.checkNotNull(color, "Color cannot be null");
this.color = color;
this.threshold = threshold;
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/SlimefunProfiler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/SlimefunProfiler.java
index 55fb454911..9fdbef9038 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/SlimefunProfiler.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/SlimefunProfiler.java
@@ -2,6 +2,7 @@
import city.norain.slimefun4.utils.SlimefunPoolExecutor;
import city.norain.slimefun4.utils.StringUtil;
+import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.AtomicDouble;
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
@@ -26,7 +27,6 @@
import java.util.logging.Level;
import javax.annotation.Nonnull;
import lombok.Getter;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.Server;
@@ -154,8 +154,8 @@ public void scheduleEntries(int amount) {
* @return The total timings of this entry
*/
public long closeEntry(@Nonnull Location l, @Nonnull SlimefunItem item, long timestamp) {
- Validate.notNull(l, "Location must not be null!");
- Validate.notNull(item, "You need to specify a SlimefunItem!");
+ Preconditions.checkNotNull(l, "Location must not be null!");
+ Preconditions.checkNotNull(item, "You need to specify a SlimefunItem!");
if (timestamp == 0) {
return 0;
@@ -189,7 +189,7 @@ public void stop() {
}
public void registerPool(SlimefunPoolExecutor executor) {
- Validate.notNull(executor, "Cannot register a null SlimefunPoolExecutor");
+ Preconditions.checkNotNull(executor, "Cannot register a null SlimefunPoolExecutor");
if (threadPools.contains(executor)) {
// Already registered
@@ -268,7 +268,7 @@ private void finishReport() {
* @param inspector The {@link PerformanceInspector} who shall receive this summary.
*/
public void requestSummary(@Nonnull PerformanceInspector inspector) {
- Validate.notNull(inspector, "Cannot request a summary for null");
+ Preconditions.checkNotNull(inspector, "Cannot request a summary for null");
requests.add(inspector);
}
@@ -312,7 +312,7 @@ protected Map getByChunk() {
}
protected int getBlocksInChunk(@Nonnull String chunk) {
- Validate.notNull(chunk, "The chunk cannot be null!");
+ Preconditions.checkNotNull(chunk, "The chunk cannot be null!");
int blocks = 0;
for (ProfiledBlock block : timings.keySet()) {
@@ -329,7 +329,7 @@ protected int getBlocksInChunk(@Nonnull String chunk) {
}
protected int getBlocksOfId(@Nonnull String id) {
- Validate.notNull(id, "The id cannot be null!");
+ Preconditions.checkNotNull(id, "The id cannot be null!");
int blocks = 0;
for (ProfiledBlock block : timings.keySet()) {
@@ -342,7 +342,7 @@ protected int getBlocksOfId(@Nonnull String id) {
}
protected int getBlocksFromPlugin(@Nonnull String pluginName) {
- Validate.notNull(pluginName, "The Plugin name cannot be null!");
+ Preconditions.checkNotNull(pluginName, "The Plugin name cannot be null!");
int blocks = 0;
for (ProfiledBlock block : timings.keySet()) {
@@ -396,20 +396,20 @@ public int getTickRate() {
* @return Whether timings of this {@link Block} have been collected
*/
public boolean hasTimings(@Nonnull Block b) {
- Validate.notNull(b, "Cannot get timings for a null Block");
+ Preconditions.checkNotNull(b, "Cannot get timings for a null Block");
return timings.containsKey(new ProfiledBlock(b));
}
public String getTime(@Nonnull Block b) {
- Validate.notNull(b, "Cannot get timings for a null Block");
+ Preconditions.checkNotNull(b, "Cannot get timings for a null Block");
long time = timings.getOrDefault(new ProfiledBlock(b), 0L);
return NumberUtils.getAsMillis(time);
}
public String getTime(@Nonnull Chunk chunk) {
- Validate.notNull(chunk, "Cannot get timings for a null Chunk");
+ Preconditions.checkNotNull(chunk, "Cannot get timings for a null Chunk");
long time = getByChunk()
.getOrDefault(chunk.getWorld().getName() + " (" + chunk.getX() + ',' + chunk.getZ() + ')', 0L);
@@ -417,7 +417,7 @@ public String getTime(@Nonnull Chunk chunk) {
}
public String getTime(@Nonnull SlimefunItem item) {
- Validate.notNull(item, "Cannot get timings for a null SlimefunItem");
+ Preconditions.checkNotNull(item, "Cannot get timings for a null SlimefunItem");
long time = getByItem().getOrDefault(item.getId(), 0L);
return NumberUtils.getAsMillis(time);
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/inspectors/ConsolePerformanceInspector.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/inspectors/ConsolePerformanceInspector.java
index e2dd54c2b4..e8fbf35e36 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/inspectors/ConsolePerformanceInspector.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/inspectors/ConsolePerformanceInspector.java
@@ -1,10 +1,10 @@
package io.github.thebusybiscuit.slimefun4.core.services.profiler.inspectors;
+import com.google.common.base.Preconditions;
import io.github.thebusybiscuit.slimefun4.core.services.profiler.PerformanceInspector;
import io.github.thebusybiscuit.slimefun4.core.services.profiler.SummaryOrderType;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
-import org.apache.commons.lang3.Validate;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
@@ -45,8 +45,8 @@ public class ConsolePerformanceInspector implements PerformanceInspector {
*/
@ParametersAreNonnullByDefault
public ConsolePerformanceInspector(CommandSender console, boolean verbose, SummaryOrderType orderType) {
- Validate.notNull(console, "CommandSender cannot be null");
- Validate.notNull(orderType, "SummaryOrderType cannot be null");
+ Preconditions.checkNotNull(console, "CommandSender cannot be null");
+ Preconditions.checkNotNull(orderType, "SummaryOrderType cannot be null");
this.console = console;
this.verbose = verbose;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/inspectors/PlayerPerformanceInspector.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/inspectors/PlayerPerformanceInspector.java
index cd1ed802a6..b5ff0808ae 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/inspectors/PlayerPerformanceInspector.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/inspectors/PlayerPerformanceInspector.java
@@ -1,12 +1,12 @@
package io.github.thebusybiscuit.slimefun4.core.services.profiler.inspectors;
+import com.google.common.base.Preconditions;
import io.github.thebusybiscuit.slimefun4.core.services.profiler.PerformanceInspector;
import io.github.thebusybiscuit.slimefun4.core.services.profiler.SummaryOrderType;
import java.util.UUID;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.md_5.bungee.api.chat.TextComponent;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@@ -38,8 +38,8 @@ public class PlayerPerformanceInspector implements PerformanceInspector {
* The {@link SummaryOrderType} of the timings
*/
public PlayerPerformanceInspector(@Nonnull Player player, @Nonnull SummaryOrderType orderType) {
- Validate.notNull(player, "Player cannot be null");
- Validate.notNull(orderType, "SummaryOrderType cannot be null");
+ Preconditions.checkNotNull(player, "Player cannot be null");
+ Preconditions.checkNotNull(orderType, "SummaryOrderType cannot be null");
this.uuid = player.getUniqueId();
this.orderType = orderType;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java
index 0c08d613c1..cd3aafc549 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java
@@ -2,6 +2,7 @@
import city.norain.slimefun4.SlimefunExtended;
import city.norain.slimefun4.timings.SQLProfiler;
+import com.google.common.base.Preconditions;
import com.xzavier0722.mc.plugin.slimefun4.chat.PlayerChatCatcher;
import com.xzavier0722.mc.plugin.slimefun4.storage.migrator.BlockStorageMigrator;
import com.xzavier0722.mc.plugin.slimefun4.storage.migrator.PlayerProfileMigrator;
@@ -124,7 +125,6 @@
import javax.annotation.ParametersAreNonnullByDefault;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.MenuListener;
import net.guizhanss.slimefun4.updater.AutoUpdateTask;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Bukkit;
import org.bukkit.Server;
import org.bukkit.World;
@@ -1131,8 +1131,8 @@ public static boolean isNewlyInstalled() {
* @return The resulting {@link BukkitTask} or null if Slimefun was disabled
*/
public static @Nullable BukkitTask runSync(@Nonnull Runnable runnable, long delay) {
- Validate.notNull(runnable, "Cannot run null");
- Validate.isTrue(delay >= 0, "The delay cannot be negative");
+ Preconditions.checkNotNull(runnable, "Cannot run null");
+ Preconditions.checkArgument(delay >= 0, "The delay cannot be negative");
// Run the task instantly within a Unit Test
if (getMinecraftVersion() == MinecraftVersion.UNIT_TEST) {
@@ -1160,7 +1160,7 @@ public static boolean isNewlyInstalled() {
* @return The resulting {@link BukkitTask} or null if Slimefun was disabled
*/
public static @Nullable BukkitTask runSync(@Nonnull Runnable runnable) {
- Validate.notNull(runnable, "Cannot run null");
+ Preconditions.checkNotNull(runnable, "Cannot run null");
// Run the task instantly within a Unit Test
if (getMinecraftVersion() == MinecraftVersion.UNIT_TEST) {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java
index fe31a5cbd2..5fe6c3afb9 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java
@@ -1,6 +1,7 @@
package io.github.thebusybiscuit.slimefun4.implementation.guide;
import city.norain.slimefun4.VaultIntegration;
+import com.google.common.base.Preconditions;
import io.github.bakedlibs.dough.chat.ChatInput;
import io.github.bakedlibs.dough.items.CustomItemStack;
import io.github.bakedlibs.dough.items.ItemUtils;
@@ -39,7 +40,6 @@
import javax.annotation.ParametersAreNonnullByDefault;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler;
-import org.apache.commons.lang3.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Tag;
@@ -660,9 +660,9 @@ private void displayItem(
@ParametersAreNonnullByDefault
public void createHeader(Player p, PlayerProfile profile, ChestMenu menu) {
- Validate.notNull(p, "The Player cannot be null!");
- Validate.notNull(profile, "The Profile cannot be null!");
- Validate.notNull(menu, "The Inventory cannot be null!");
+ Preconditions.checkNotNull(p, "The Player cannot be null!");
+ Preconditions.checkNotNull(profile, "The Profile cannot be null!");
+ Preconditions.checkNotNull(menu, "The Inventory cannot be null!");
for (int i = 0; i < 9; i++) {
menu.addItem(i, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler());
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/handlers/VanillaInventoryDropHandler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/handlers/VanillaInventoryDropHandler.java
index 479ad76847..fe396e26a3 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/handlers/VanillaInventoryDropHandler.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/handlers/VanillaInventoryDropHandler.java
@@ -1,11 +1,11 @@
package io.github.thebusybiscuit.slimefun4.implementation.handlers;
+import com.google.common.base.Preconditions;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler;
import java.util.List;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
-import org.apache.commons.lang3.Validate;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.Chest;
@@ -45,7 +45,7 @@ public class VanillaInventoryDropHandler
*/
public VanillaInventoryDropHandler(@Nonnull Class blockStateClass) {
super(false, true);
- Validate.notNull(blockStateClass, "The provided class must not be null!");
+ Preconditions.checkNotNull(blockStateClass, "The provided class must not be null!");
this.blockStateClass = blockStateClass;
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/LimitedUseItem.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/LimitedUseItem.java
index f06c920e31..96a2f2df8e 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/LimitedUseItem.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/LimitedUseItem.java
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.implementation.items;
+import com.google.common.base.Preconditions;
import io.github.bakedlibs.dough.common.ChatColors;
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
@@ -15,7 +16,6 @@
import java.util.List;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.entity.Player;
@@ -67,7 +67,7 @@ public final int getMaxUseCount() {
* @return The {@link LimitedUseItem} for chaining of setters
*/
public final @Nonnull LimitedUseItem setMaxUseCount(int count) {
- Validate.isTrue(count > 0, "The maximum use count must be greater than zero!");
+ Preconditions.checkArgument(count > 0, "The maximum use count must be greater than zero!");
maxUseCount = count;
return this;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Instruction.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Instruction.java
index 9e061c8593..543322f799 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Instruction.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Instruction.java
@@ -1,6 +1,7 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.androids;
import city.norain.slimefun4.api.menu.UniversalMenu;
+import com.google.common.base.Preconditions;
import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils;
import io.github.thebusybiscuit.slimefun4.utils.HeadTexture;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
@@ -10,7 +11,6 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
@@ -279,7 +279,7 @@ public AndroidType getRequiredType() {
@ParametersAreNonnullByDefault
public void execute(ProgrammableAndroid android, Block b, UniversalMenu inventory, BlockFace face) {
- Validate.notNull(method, "Instruction '" + name() + "' must be executed manually!");
+ Preconditions.checkNotNull(method, "Instruction '" + name() + "' must be executed manually!");
method.perform(android, b, inventory, face);
}
@@ -295,7 +295,7 @@ public void execute(ProgrammableAndroid android, Block b, UniversalMenu inventor
* @return The {@link Instruction} or null if it does not exist.
*/
@Nullable public static Instruction getInstruction(@Nonnull String value) {
- Validate.notNull(value, "An Instruction cannot be null!");
+ Preconditions.checkNotNull(value, "An Instruction cannot be null!");
return nameLookup.get(value);
}
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java
index 7141fe4301..99e0d56998 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java
@@ -3,6 +3,7 @@
import city.norain.slimefun4.api.menu.UniversalMenu;
import city.norain.slimefun4.api.menu.UniversalMenuPreset;
import city.norain.slimefun4.utils.TaskUtil;
+import com.google.common.base.Preconditions;
import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunUniversalBlockData;
import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunUniversalData;
import com.xzavier0722.mc.plugin.slimefun4.storage.controller.attributes.UniversalBlock;
@@ -50,7 +51,6 @@
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.interfaces.InventoryBlock;
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker;
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@@ -679,17 +679,19 @@ protected void editInstruction(Player p, SlimefunUniversalBlockData uniData, Str
@Nonnull
public String getScript(@Nonnull SlimefunUniversalBlockData ubd) {
- Validate.notNull(ubd, "SlimefunUniversalBlockData for android not specified");
+ Preconditions.checkNotNull(ubd, "SlimefunUniversalBlockData for android not specified");
String script = ubd.getData("script");
return script != null ? script : DEFAULT_SCRIPT;
}
public void setScript(@Nonnull SlimefunUniversalBlockData ubd, @Nonnull String script) {
- Validate.notNull(ubd, "SlimefunUniversalBlockData for android not specified");
- Validate.notNull(script, "No script given");
- Validate.isTrue(script.startsWith(Instruction.START.name() + '-'), "A script must begin with a 'START' token.");
- Validate.isTrue(script.endsWith('-' + Instruction.REPEAT.name()), "A script must end with a 'REPEAT' token.");
- Validate.isTrue(
+ Preconditions.checkNotNull(ubd, "SlimefunUniversalBlockData for android not specified");
+ Preconditions.checkNotNull(script, "No script given");
+ Preconditions.checkArgument(
+ script.startsWith(Instruction.START.name() + '-'), "A script must begin with a 'START' token.");
+ Preconditions.checkArgument(
+ script.endsWith('-' + Instruction.REPEAT.name()), "A script must end with a 'REPEAT' token.");
+ Preconditions.checkArgument(
CommonPatterns.DASH.split(script).length <= MAX_SCRIPT_LENGTH,
"Scripts may not have more than " + MAX_SCRIPT_LENGTH + " segments");
@@ -733,7 +735,7 @@ private void registerDefaultFuelTypes() {
}
public void registerFuelType(@Nonnull MachineFuel fuel) {
- Validate.notNull(fuel, "Cannot register null as a Fuel type");
+ Preconditions.checkNotNull(fuel, "Cannot register null as a Fuel type");
fuelTypes.add(fuel);
}
@@ -983,7 +985,7 @@ public boolean onClick(
@ParametersAreNonnullByDefault
public void addItems(Block b, ItemStack... items) {
- Validate.notNull(b, "The Block cannot be null.");
+ Preconditions.checkNotNull(b, "The Block cannot be null.");
Optional uuid =
TaskUtil.runSyncMethod(() -> Slimefun.getBlockDataService().getUniversalDataUUID(b));
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Script.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Script.java
index bbabb01fcf..7bbd87ab4f 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Script.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Script.java
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.androids;
+import com.google.common.base.Preconditions;
import io.github.bakedlibs.dough.config.Config;
import io.github.bakedlibs.dough.items.CustomItemStack;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
@@ -15,7 +16,6 @@
import java.util.logging.Level;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
@@ -42,18 +42,18 @@ public final class Script {
* The {@link Config}
*/
private Script(@Nonnull Config config) {
- Validate.notNull(config);
+ Preconditions.checkNotNull(config);
this.config = config;
this.name = config.getString("name");
this.code = config.getString("code");
String uuid = config.getString("author");
- Validate.notNull(name);
- Validate.notNull(code);
- Validate.notNull(uuid);
- Validate.notNull(config.getStringList("rating.positive"));
- Validate.notNull(config.getStringList("rating.negative"));
+ Preconditions.checkNotNull(name);
+ Preconditions.checkNotNull(code);
+ Preconditions.checkNotNull(uuid);
+ Preconditions.checkNotNull(config.getStringList("rating.positive"));
+ Preconditions.checkNotNull(config.getStringList("rating.negative"));
OfflinePlayer player = Bukkit.getOfflinePlayer(UUID.fromString(uuid));
this.author = player.getName() != null ? player.getName() : config.getString("author_name");
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/menu/AndroidShareMenu.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/menu/AndroidShareMenu.java
index 93ff23d55c..64dcfe23c2 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/menu/AndroidShareMenu.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/menu/AndroidShareMenu.java
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.androids.menu;
+import com.google.common.base.Preconditions;
import io.github.bakedlibs.dough.items.CustomItemStack;
import io.github.bakedlibs.dough.skins.PlayerHead;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
@@ -16,7 +17,6 @@
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Bukkit;
import org.bukkit.NamespacedKey;
import org.bukkit.OfflinePlayer;
@@ -49,8 +49,8 @@ private AndroidShareMenu() {}
*/
@ParametersAreNonnullByDefault
public static void openShareMenu(Player p, Block b) {
- Validate.notNull(p, "The player cannot be null!");
- Validate.notNull(b, "The android block cannot be null!");
+ Preconditions.checkNotNull(p, "The player cannot be null!");
+ Preconditions.checkNotNull(b, "The android block cannot be null!");
ChestMenu menu = new ChestMenu(Slimefun.getLocalization().getMessage("android.access-manager.title"));
@@ -128,10 +128,10 @@ public static void openShareMenu(Player p, Block b) {
@ParametersAreNonnullByDefault
private static void addPlayer(Player owner, OfflinePlayer p, Block android, List users) {
- Validate.notNull(owner, "The android cannot be null!");
- Validate.notNull(p, "The target player cannot be null!");
- Validate.notNull(android, "The android block cannot be null!");
- Validate.notNull(users, "The trusted users list cannot be null!");
+ Preconditions.checkNotNull(owner, "The android cannot be null!");
+ Preconditions.checkNotNull(p, "The target player cannot be null!");
+ Preconditions.checkNotNull(android, "The android block cannot be null!");
+ Preconditions.checkNotNull(users, "The trusted users list cannot be null!");
if (users.contains(p.getUniqueId().toString())) {
Slimefun.getLocalization()
@@ -155,10 +155,10 @@ private static void addPlayer(Player owner, OfflinePlayer p, Block android, List
@ParametersAreNonnullByDefault
private static void removePlayer(Player owner, OfflinePlayer p, Block android, List users) {
- Validate.notNull(owner, "The android cannot be null!");
- Validate.notNull(p, "The target player cannot be null!");
- Validate.notNull(android, "The android block cannot be null!");
- Validate.notNull(users, "The trusted users list cannot be null!");
+ Preconditions.checkNotNull(owner, "The android cannot be null!");
+ Preconditions.checkNotNull(p, "The target player cannot be null!");
+ Preconditions.checkNotNull(android, "The android block cannot be null!");
+ Preconditions.checkNotNull(users, "The trusted users list cannot be null!");
if (users.contains(p.getUniqueId().toString())) {
users.remove(p.getUniqueId().toString());
@@ -185,7 +185,7 @@ private static void removePlayer(Player owner, OfflinePlayer p, Block android, L
* @return parse trusted player list
*/
private @Nonnull static List parseBlockInfoToList(@Nonnull String value) {
- Validate.notNull(value, "The trusted player list cannot be null!");
+ Preconditions.checkNotNull(value, "The trusted player list cannot be null!");
String replacedText = value.replace("[", "").replace("]", "");
@@ -203,7 +203,7 @@ private static void removePlayer(Player owner, OfflinePlayer p, Block android, L
* @return trusted users list
*/
public @Nonnull static List getTrustedUsers(@Nonnull Block b) {
- Validate.notNull(b, "The android block cannot be null!");
+ Preconditions.checkNotNull(b, "The android block cannot be null!");
Optional trustUsers = getSharedUserData(b.getState());
@@ -226,8 +226,8 @@ private static void removePlayer(Player owner, OfflinePlayer p, Block android, L
*/
@ParametersAreNonnullByDefault
public static boolean isTrustedUser(Block b, UUID uuid) {
- Validate.notNull(b, "The android block cannot be null!");
- Validate.notNull(uuid, "The UUID of player to check cannot be null!");
+ Preconditions.checkNotNull(b, "The android block cannot be null!");
+ Preconditions.checkNotNull(uuid, "The UUID of player to check cannot be null!");
Optional trustUsers = getSharedUserData(b.getState());
@@ -235,8 +235,8 @@ public static boolean isTrustedUser(Block b, UUID uuid) {
}
private static void setSharedUserData(@Nonnull BlockState state, @Nonnull String value) {
- Validate.notNull(state, "The android block state cannot be null!");
- Validate.notNull(value, "The data value cannot be null!");
+ Preconditions.checkNotNull(state, "The android block state cannot be null!");
+ Preconditions.checkNotNull(value, "The data value cannot be null!");
if (!(state instanceof TileState)) {
return;
@@ -253,7 +253,7 @@ private static void setSharedUserData(@Nonnull BlockState state, @Nonnull String
}
private @Nonnull static Optional getSharedUserData(@Nonnull BlockState state) {
- Validate.notNull(state, "The android block state cannot be null!");
+ Preconditions.checkNotNull(state, "The android block state cannot be null!");
if (!(state instanceof TileState)) {
return Optional.empty();
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/RainbowArmorPiece.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/RainbowArmorPiece.java
index aa5a48dedf..0adee0e842 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/RainbowArmorPiece.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/RainbowArmorPiece.java
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.armor;
+import com.google.common.base.Preconditions;
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
@@ -7,7 +8,6 @@
import java.util.Arrays;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Color;
import org.bukkit.DyeColor;
import org.bukkit.inventory.ItemStack;
@@ -42,7 +42,7 @@ public RainbowArmorPiece(
// TODO Change this validation over to our custom validation blocked by
// https://github.com/baked-libs/dough/pull/184
- Validate.notEmpty(dyeColors, "RainbowArmorPiece colors cannot be empty!");
+ Preconditions.checkArgument(dyeColors.length != 0, "RainbowArmorPiece colors cannot be empty!");
if (!SlimefunTag.LEATHER_ARMOR.isTagged(item.getType())) {
throw new IllegalArgumentException("Rainbow armor needs to be a leather armor piece!");
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/AbstractAutoCrafter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/AbstractAutoCrafter.java
index 09b46aca34..a4e72d3803 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/AbstractAutoCrafter.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/AbstractAutoCrafter.java
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.autocrafters;
+import com.google.common.base.Preconditions;
import com.xzavier0722.mc.plugin.slimefun4.autocrafter.ChestInventoryParser;
import com.xzavier0722.mc.plugin.slimefun4.autocrafter.CrafterInteractable;
import com.xzavier0722.mc.plugin.slimefun4.autocrafter.CrafterInteractorManager;
@@ -42,7 +43,6 @@
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
@@ -158,8 +158,8 @@ public void postRegister() {
*/
@ParametersAreNonnullByDefault
public void onRightClick(Block b, Player p) {
- Validate.notNull(b, "The Block must not be null!");
- Validate.notNull(p, "The Player cannot be null!");
+ Preconditions.checkNotNull(b, "The Block must not be null!");
+ Preconditions.checkNotNull(p, "The Player cannot be null!");
// Check if we have a valid chest below
if (!isValidInventory(b.getRelative(BlockFace.DOWN))) {
@@ -340,7 +340,7 @@ protected boolean isValidInventory(@Nonnull Block block) {
* The {@link AbstractRecipe} to select
*/
protected void setSelectedRecipe(@Nonnull Block b, @Nullable AbstractRecipe recipe) {
- Validate.notNull(b, "The Block cannot be null!");
+ Preconditions.checkNotNull(b, "The Block cannot be null!");
BlockStateSnapshotResult result = PaperLib.getBlockState(b, false);
BlockState state = result.getState();
@@ -376,9 +376,9 @@ protected void setSelectedRecipe(@Nonnull Block b, @Nullable AbstractRecipe reci
*/
@ParametersAreNonnullByDefault
protected void showRecipe(Player p, Block b, AbstractRecipe recipe) {
- Validate.notNull(p, "The Player should not be null");
- Validate.notNull(b, "The Block should not be null");
- Validate.notNull(recipe, "The Recipe should not be null");
+ Preconditions.checkNotNull(p, "The Player should not be null");
+ Preconditions.checkNotNull(b, "The Block should not be null");
+ Preconditions.checkNotNull(recipe, "The Recipe should not be null");
ChestMenu menu = new ChestMenu(getItemName());
menu.setPlayerInventoryClickable(false);
@@ -473,8 +473,8 @@ private void deleteRecipe(Player p, Block b) {
* @return Whether this crafting operation was successful or not
*/
public boolean craft(@Nonnull CrafterInteractable inv, @Nonnull AbstractRecipe recipe) {
- Validate.notNull(inv, "The Inventory must not be null");
- Validate.notNull(recipe, "The Recipe shall not be null");
+ Preconditions.checkNotNull(inv, "The Inventory must not be null");
+ Preconditions.checkNotNull(recipe, "The Recipe shall not be null");
// Make sure that the Recipe is actually enabled
if (!recipe.isEnabled()) {
@@ -579,7 +579,7 @@ public int getEnergyConsumption() {
*/
@Nonnull
public final AbstractAutoCrafter setCapacity(int capacity) {
- Validate.isTrue(capacity > 0, "The capacity must be greater than zero!");
+ Preconditions.checkArgument(capacity > 0, "The capacity must be greater than zero!");
if (getState() == ItemState.UNREGISTERED) {
this.energyCapacity = capacity;
@@ -599,9 +599,10 @@ public final AbstractAutoCrafter setCapacity(int capacity) {
*/
@Nonnull
public final AbstractAutoCrafter setEnergyConsumption(int energyConsumption) {
- Validate.isTrue(energyConsumption > 0, "The energy consumption must be greater than zero!");
- Validate.isTrue(energyCapacity > 0, "You must specify the capacity before you can set the consumption amount.");
- Validate.isTrue(
+ Preconditions.checkArgument(energyConsumption > 0, "The energy consumption must be greater than zero!");
+ Preconditions.checkArgument(
+ energyCapacity > 0, "You must specify the capacity before you can set the consumption amount.");
+ Preconditions.checkArgument(
energyConsumption <= energyCapacity,
"The energy consumption cannot be higher than the capacity (" + energyCapacity + ')');
@@ -611,7 +612,7 @@ public final AbstractAutoCrafter setEnergyConsumption(int energyConsumption) {
@Override
public void register(@Nonnull SlimefunAddon addon) {
- Validate.notNull(addon, "A SlimefunAddon cannot be null!");
+ Preconditions.checkNotNull(addon, "A SlimefunAddon cannot be null!");
this.addon = addon;
if (getCapacity() <= 0) {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/AbstractRecipe.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/AbstractRecipe.java
index 0b80bb4584..5670a2b7a2 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/AbstractRecipe.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/AbstractRecipe.java
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.autocrafters;
+import com.google.common.base.Preconditions;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.EnhancedCraftingTable;
@@ -10,7 +11,6 @@
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
-import org.apache.commons.lang3.Validate;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Recipe;
import org.bukkit.inventory.RecipeChoice.MaterialChoice;
@@ -56,8 +56,8 @@ public abstract class AbstractRecipe {
*/
@ParametersAreNonnullByDefault
protected AbstractRecipe(Collection> ingredients, ItemStack result) {
- Validate.notEmpty(ingredients, "The input predicates cannot be null or an empty array");
- Validate.notNull(result, "The recipe result must not be null!");
+ Preconditions.checkArgument(!ingredients.isEmpty(), "The input predicates cannot be null or an empty array");
+ Preconditions.checkNotNull(result, "The recipe result must not be null!");
this.ingredients = ingredients;
this.result = result;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/SlimefunAutoCrafter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/SlimefunAutoCrafter.java
index b09de3cb5f..1734f97a0e 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/SlimefunAutoCrafter.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/SlimefunAutoCrafter.java
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.autocrafters;
+import com.google.common.base.Preconditions;
import io.github.bakedlibs.dough.items.CustomItemStack;
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
@@ -14,7 +15,6 @@
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
-import org.apache.commons.lang3.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
@@ -57,7 +57,7 @@ protected SlimefunAutoCrafter(
@Override
@Nullable public AbstractRecipe getSelectedRecipe(@Nonnull Block b) {
- Validate.notNull(b, "The Block cannot be null!");
+ Preconditions.checkNotNull(b, "The Block cannot be null!");
BlockState state = PaperLib.getBlockState(b, false).getState();
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/SlimefunItemRecipe.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/SlimefunItemRecipe.java
index 48a484de81..bfa1fc6a9a 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/SlimefunItemRecipe.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/SlimefunItemRecipe.java
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.autocrafters;
+import com.google.common.base.Preconditions;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.implementation.tasks.AsyncRecipeChoiceTask;
@@ -11,7 +12,6 @@
import java.util.function.Predicate;
import javax.annotation.Nonnull;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
-import org.apache.commons.lang3.Validate;
import org.bukkit.inventory.ItemStack;
/**
@@ -50,8 +50,8 @@ private static Collection> getInputs(@Nonnull SlimefunItem
@Override
public void show(@Nonnull ChestMenu menu, @Nonnull AsyncRecipeChoiceTask task) {
- Validate.notNull(menu, "The ChestMenu cannot be null!");
- Validate.notNull(task, "The RecipeChoiceTask cannot be null!");
+ Preconditions.checkNotNull(menu, "The ChestMenu cannot be null!");
+ Preconditions.checkNotNull(task, "The RecipeChoiceTask cannot be null!");
menu.addItem(24, getResult().clone(), ChestMenuUtils.getEmptyClickHandler());
ItemStack[] recipe = item.getRecipe();
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/VanillaAutoCrafter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/VanillaAutoCrafter.java
index 912ab5ad66..47ada1652c 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/VanillaAutoCrafter.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/VanillaAutoCrafter.java
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.autocrafters;
+import com.google.common.base.Preconditions;
import io.github.bakedlibs.dough.common.CommonPatterns;
import io.github.bakedlibs.dough.items.CustomItemStack;
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
@@ -20,7 +21,6 @@
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
-import org.apache.commons.lang3.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
@@ -128,7 +128,8 @@ protected void updateRecipe(@Nonnull Block b, @Nonnull Player p) {
@ParametersAreNonnullByDefault
private void offerRecipe(
Player p, Block b, List recipes, int index, ChestMenu menu, AsyncRecipeChoiceTask task) {
- Validate.isTrue(index >= 0 && index < recipes.size(), "page must be between 0 and " + (recipes.size() - 1));
+ Preconditions.checkArgument(
+ index >= 0 && index < recipes.size(), "page must be between 0 and " + (recipes.size() - 1));
menu.replaceExistingItem(46, ChestMenuUtils.getPreviousButton(p, index + 1, recipes.size()));
menu.addMenuClickHandler(46, (pl, slot, item, action) -> {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/VanillaRecipe.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/VanillaRecipe.java
index ee8d183249..5456b0e5d9 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/VanillaRecipe.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/VanillaRecipe.java
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.autocrafters;
+import com.google.common.base.Preconditions;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.implementation.tasks.AsyncRecipeChoiceTask;
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
@@ -9,7 +10,6 @@
import java.util.function.Predicate;
import javax.annotation.Nonnull;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Keyed;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Recipe;
@@ -72,8 +72,8 @@ private static RecipeChoice[] getShape(@Nonnull Recipe recipe) {
@Override
public void show(@Nonnull ChestMenu menu, @Nonnull AsyncRecipeChoiceTask task) {
- Validate.notNull(menu, "The ChestMenu cannot be null!");
- Validate.notNull(task, "The RecipeChoiceTask cannot be null!");
+ Preconditions.checkNotNull(menu, "The ChestMenu cannot be null!");
+ Preconditions.checkNotNull(task, "The RecipeChoiceTask cannot be null!");
menu.replaceExistingItem(24, getResult().clone());
menu.addMenuClickHandler(24, ChestMenuUtils.getEmptyClickHandler());
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/AbstractMonsterSpawner.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/AbstractMonsterSpawner.java
index 4664a81f14..4884502548 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/AbstractMonsterSpawner.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/AbstractMonsterSpawner.java
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.blocks;
+import com.google.common.base.Preconditions;
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
@@ -12,7 +13,6 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
-import org.apache.commons.lang3.Validate;
import org.bukkit.ChatColor;
import org.bukkit.block.BlockState;
import org.bukkit.block.CreatureSpawner;
@@ -49,7 +49,7 @@ public abstract class AbstractMonsterSpawner extends SlimefunItem implements Dis
*/
@Nonnull
public Optional getEntityType(@Nonnull ItemStack item) {
- Validate.notNull(item, "The Item cannot be null");
+ Preconditions.checkNotNull(item, "The Item cannot be null");
ItemMeta meta = item.getItemMeta();
@@ -89,7 +89,7 @@ public Optional getEntityType(@Nonnull ItemStack item) {
*/
@Nonnull
public ItemStack getItemForEntityType(@Nullable EntityType type) {
- // Validate.notNull(type, "The EntityType cannot be null");
+ // Preconditions.checkNotNull(type, "The EntityType cannot be null");
ItemStack item = getItem().clone();
ItemMeta meta = item.getItemMeta();
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/IgnitionChamber.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/IgnitionChamber.java
index 0f7d7bbbd9..9a09e3de1a 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/IgnitionChamber.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/IgnitionChamber.java
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.blocks;
+import com.google.common.base.Preconditions;
import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils;
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
@@ -13,7 +14,6 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
@@ -65,8 +65,8 @@ public IgnitionChamber(ItemGroup itemGroup, SlimefunItemStack item, RecipeType r
*/
@ParametersAreNonnullByDefault
public static boolean useFlintAndSteel(Player p, Block smelteryBlock) {
- Validate.notNull(p, "The Player must not be null!");
- Validate.notNull(smelteryBlock, "The smeltery block cannot be null!");
+ Preconditions.checkNotNull(p, "The Player must not be null!");
+ Preconditions.checkNotNull(smelteryBlock, "The smeltery block cannot be null!");
Inventory inv = findIgnitionChamber(smelteryBlock);
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractCargoNode.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractCargoNode.java
index 189ea3a982..d0d3745f40 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractCargoNode.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractCargoNode.java
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.cargo;
+import com.google.common.base.Preconditions;
import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils;
import io.github.bakedlibs.dough.items.CustomItemStack;
import io.github.bakedlibs.dough.protection.Interaction;
@@ -20,7 +21,6 @@
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
@@ -138,7 +138,7 @@ protected void addChannelSelector(Block b, BlockMenu menu, int slotPrev, int slo
@Override
public int getSelectedChannel(@Nonnull Block b) {
- Validate.notNull(b, "Block must not be null");
+ Preconditions.checkNotNull(b, "Block must not be null");
String frequency = StorageCacheUtils.getData(b.getLocation(), FREQUENCY);
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/AbstractEnergyProvider.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/AbstractEnergyProvider.java
index b48f7f588e..c6710ac3ea 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/AbstractEnergyProvider.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/AbstractEnergyProvider.java
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.electric;
+import com.google.common.base.Preconditions;
import io.github.bakedlibs.dough.common.ChatColors;
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
@@ -19,7 +20,6 @@
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.interfaces.InventoryBlock;
-import org.apache.commons.lang3.Validate;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
@@ -85,7 +85,7 @@ public final EnergyNetComponentType getEnergyComponentType() {
}
public void registerFuel(@Nonnull MachineFuel fuel) {
- Validate.notNull(fuel, "Machine Fuel cannot be null!");
+ Preconditions.checkNotNull(fuel, "Machine Fuel cannot be null!");
fuelTypes.add(fuel);
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/AnimalProduce.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/AnimalProduce.java
index e1a5bdf456..f28b131dad 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/AnimalProduce.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/AnimalProduce.java
@@ -1,10 +1,10 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.entities;
+import com.google.common.base.Preconditions;
import java.util.function.Predicate;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe;
-import org.apache.commons.lang3.Validate;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.ItemStack;
@@ -23,7 +23,7 @@ public class AnimalProduce extends MachineRecipe implements Predicate predicate) {
super(5, new ItemStack[] {input}, new ItemStack[] {result});
- Validate.notNull(predicate, "The Predicate must not be null");
+ Preconditions.checkNotNull(predicate, "The Predicate must not be null");
this.predicate = predicate;
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/ProduceCollector.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/ProduceCollector.java
index e6fbfe953e..2a9d2e5a51 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/ProduceCollector.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/ProduceCollector.java
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.entities;
+import com.google.common.base.Preconditions;
import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData;
import io.github.bakedlibs.dough.inventory.InvUtils;
import io.github.bakedlibs.dough.items.CustomItemStack;
@@ -25,7 +26,6 @@
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe;
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Ageable;
@@ -86,7 +86,7 @@ protected void registerDefaultRecipes() {
* The {@link AnimalProduce} to add
*/
public void addProduce(@Nonnull AnimalProduce produce) {
- Validate.notNull(produce, "A produce cannot be null");
+ Preconditions.checkNotNull(produce, "A produce cannot be null");
this.animalProduces.add(produce);
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/elevator/ElevatorFloor.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/elevator/ElevatorFloor.java
index a99a1a16ab..f276e7be58 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/elevator/ElevatorFloor.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/elevator/ElevatorFloor.java
@@ -1,7 +1,7 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.elevator;
+import com.google.common.base.Preconditions;
import javax.annotation.Nonnull;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
@@ -37,8 +37,8 @@ class ElevatorFloor {
* @param block The {@link Block} of this floor
*/
public ElevatorFloor(@Nonnull String name, int number, @Nonnull Block block) {
- Validate.notNull(name, "An ElevatorFloor must have a name");
- Validate.notNull(block, "An ElevatorFloor must have a block");
+ Preconditions.checkNotNull(name, "An ElevatorFloor must have a name");
+ Preconditions.checkNotNull(block, "An ElevatorFloor must have a block");
this.name = name;
this.number = number;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOMiner.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOMiner.java
index 0d88b7f774..15bcf426ca 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOMiner.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOMiner.java
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.geo;
+import com.google.common.base.Preconditions;
import com.xzavier0722.mc.plugin.slimefun4.storage.callback.IAsyncReadCallback;
import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData;
import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunChunkData;
@@ -33,7 +34,6 @@
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
-import org.apache.commons.lang3.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
@@ -126,7 +126,7 @@ public int getSpeed() {
* @return This method will return the current instance of {@link GEOMiner}, so that can be chained.
*/
public final GEOMiner setCapacity(int capacity) {
- Validate.isTrue(capacity > 0, "The capacity must be greater than zero!");
+ Preconditions.checkArgument(capacity > 0, "The capacity must be greater than zero!");
if (getState() == ItemState.UNREGISTERED) {
this.energyCapacity = capacity;
@@ -145,7 +145,7 @@ public final GEOMiner setCapacity(int capacity) {
* @return This method will return the current instance of {@link GEOMiner}, so that can be chained.
*/
public final GEOMiner setProcessingSpeed(int speed) {
- Validate.isTrue(speed > 0, "The speed must be greater than zero!");
+ Preconditions.checkArgument(speed > 0, "The speed must be greater than zero!");
this.processingSpeed = speed;
return this;
@@ -160,9 +160,10 @@ public final GEOMiner setProcessingSpeed(int speed) {
* @return This method will return the current instance of {@link GEOMiner}, so that can be chained.
*/
public final GEOMiner setEnergyConsumption(int energyConsumption) {
- Validate.isTrue(energyConsumption > 0, "The energy consumption must be greater than zero!");
- Validate.isTrue(energyCapacity > 0, "You must specify the capacity before you can set the consumption amount.");
- Validate.isTrue(
+ Preconditions.checkArgument(energyConsumption > 0, "The energy consumption must be greater than zero!");
+ Preconditions.checkArgument(
+ energyCapacity > 0, "You must specify the capacity before you can set the consumption amount.");
+ Preconditions.checkArgument(
energyConsumption <= energyCapacity,
"The energy consumption cannot be higher than the capacity (" + energyCapacity + ')');
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/MagicianTalisman.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/MagicianTalisman.java
index ee364311d0..616d9c5228 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/MagicianTalisman.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/MagicianTalisman.java
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.magical.talismans;
+import com.google.common.base.Preconditions;
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
@@ -13,7 +14,6 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
@@ -83,8 +83,8 @@ public MagicianTalisman(SlimefunItemStack item, ItemStack[] recipe) {
*/
@Nullable public TalismanEnchantment getRandomEnchantment(
@Nonnull ItemStack item, @Nonnull Set existingEnchantments) {
- Validate.notNull(item, "The ItemStack cannot be null");
- Validate.notNull(existingEnchantments, "The Enchantments Set cannot be null");
+ Preconditions.checkNotNull(item, "The ItemStack cannot be null");
+ Preconditions.checkNotNull(existingEnchantments, "The Enchantments Set cannot be null");
// @formatter:off
List enabled = enchantments.stream()
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/Talisman.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/Talisman.java
index 996c6e2ea1..66cf1271b6 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/Talisman.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/Talisman.java
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.magical.talismans;
+import com.google.common.base.Preconditions;
import io.github.bakedlibs.dough.items.CustomItemStack;
import io.github.bakedlibs.dough.items.ItemUtils;
import io.github.thebusybiscuit.slimefun4.api.events.TalismanActivateEvent;
@@ -18,7 +19,6 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.NamespacedKey;
@@ -311,7 +311,7 @@ public boolean isSilent() {
* The {@link Player} who shall receive the message
*/
public void sendMessage(@Nonnull Player p) {
- Validate.notNull(p, "The Player must not be null.");
+ Preconditions.checkNotNull(p, "The Player must not be null.");
// Check if this Talisman has a message
if (!isSilent()) {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/GoldIngot.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/GoldIngot.java
index 41499603af..505c64fe4e 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/GoldIngot.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/GoldIngot.java
@@ -1,12 +1,12 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.misc;
+import com.google.common.base.Preconditions;
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
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.implementation.items.multiblocks.Smeltery;
import javax.annotation.ParametersAreNonnullByDefault;
-import org.apache.commons.lang3.Validate;
import org.bukkit.inventory.ItemStack;
/**
@@ -32,8 +32,8 @@ public GoldIngot(
ItemGroup itemGroup, int caratRating, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(itemGroup, item, recipeType, recipe);
- Validate.isTrue(caratRating > 0, "Carat rating must be above zero.");
- Validate.isTrue(caratRating <= 24, "Carat rating cannot go above 24.");
+ Preconditions.checkArgument(caratRating > 0, "Carat rating must be above zero.");
+ Preconditions.checkArgument(caratRating <= 24, "Carat rating cannot go above 24.");
this.caratRating = caratRating;
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/IndustrialMiner.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/IndustrialMiner.java
index 1e5b5e4ad9..d18b30dc8a 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/IndustrialMiner.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/IndustrialMiner.java
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.miner;
+import com.google.common.base.Preconditions;
import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils;
import io.github.bakedlibs.dough.common.ChatColors;
import io.github.bakedlibs.dough.items.CustomItemStack;
@@ -19,7 +20,6 @@
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Tag;
@@ -151,8 +151,8 @@ protected void registerDefaultFuelTypes() {
* The item that shall be consumed
*/
public void addFuelType(int ores, @Nonnull ItemStack item) {
- Validate.isTrue(ores > 1 && ores % 2 == 0, "矿石的数量必须 >= 2 且为 2 的倍数.");
- Validate.notNull(item, "The fuel item cannot be null");
+ Preconditions.checkArgument(ores > 1 && ores % 2 == 0, "矿石的数量必须 >= 2 且为 2 的倍数.");
+ Preconditions.checkNotNull(item, "The fuel item cannot be null");
fuelTypes.add(new MachineFuel(ores / 2, item));
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ClimbingPick.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ClimbingPick.java
index 25b8022955..64158d0936 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ClimbingPick.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ClimbingPick.java
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.tools;
+import com.google.common.base.Preconditions;
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
import io.github.thebusybiscuit.slimefun4.api.events.ClimbingPickLaunchEvent;
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
@@ -26,7 +27,6 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
import org.bukkit.GameMode;
@@ -121,7 +121,7 @@ public Collection getClimbableSurfaces() {
* @return The climbing speed for this {@link Material} or 0.
*/
public double getClimbingSpeed(@Nonnull Material type) {
- Validate.notNull(type, "The surface cannot be null");
+ Preconditions.checkNotNull(type, "The surface cannot be null");
ClimbableSurface surface = surfaces.get(type);
if (surface != null) {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VersionedMiddleClickListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VersionedMiddleClickListener.java
index fd6f5cc7e3..d198af001f 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VersionedMiddleClickListener.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VersionedMiddleClickListener.java
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.implementation.listeners;
+import com.google.common.base.Preconditions;
import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
@@ -7,7 +8,6 @@
import java.lang.reflect.Method;
import java.util.logging.Level;
import javax.annotation.Nonnull;
-import org.apache.commons.lang3.Validate;
import org.bukkit.GameMode;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
@@ -23,7 +23,7 @@ public VersionedMiddleClickListener(@Nonnull Slimefun plugin) {
try {
pickBlockEventClass = (Class extends PlayerPickItemEvent>)
Class.forName("io.papermc.paper.event.player.PlayerPickBlockEvent");
- Validate.isTrue(PlayerPickItemEvent.class.isAssignableFrom(pickBlockEventClass));
+ Preconditions.checkArgument(PlayerPickItemEvent.class.isAssignableFrom(pickBlockEventClass));
getBlockMethod = pickBlockEventClass.getMethod("getBlock");
getBlockMethod.setAccessible(true);
plugin.getServer().getPluginManager().registerEvents(this, plugin);
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/operations/CraftingOperation.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/operations/CraftingOperation.java
index 862e592f2e..7afa471f7c 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/operations/CraftingOperation.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/operations/CraftingOperation.java
@@ -1,9 +1,9 @@
package io.github.thebusybiscuit.slimefun4.implementation.operations;
+import com.google.common.base.Preconditions;
import io.github.thebusybiscuit.slimefun4.core.machines.MachineOperation;
import javax.annotation.Nonnull;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe;
-import org.apache.commons.lang3.Validate;
import org.bukkit.inventory.ItemStack;
/**
@@ -25,9 +25,9 @@ public CraftingOperation(@Nonnull MachineRecipe recipe) {
}
public CraftingOperation(@Nonnull ItemStack[] ingredients, @Nonnull ItemStack[] results, int totalTicks) {
- Validate.notEmpty(ingredients, "The Ingredients array cannot be empty or null");
- Validate.notEmpty(results, "The results array cannot be empty or null");
- Validate.isTrue(
+ Preconditions.checkArgument(ingredients.length != 0, "The Ingredients array cannot be empty or null");
+ Preconditions.checkArgument(results.length != 0, "The results array cannot be empty or null");
+ Preconditions.checkArgument(
totalTicks >= 0,
"The amount of total ticks must be a positive integer or zero, received: " + totalTicks);
@@ -38,7 +38,7 @@ public CraftingOperation(@Nonnull ItemStack[] ingredients, @Nonnull ItemStack[]
@Override
public void addProgress(int num) {
- Validate.isTrue(num > 0, "Progress must be positive.");
+ Preconditions.checkArgument(num > 0, "Progress must be positive.");
currentTicks += num;
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/operations/FuelOperation.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/operations/FuelOperation.java
index 2678df26e3..525d04040c 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/operations/FuelOperation.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/operations/FuelOperation.java
@@ -1,10 +1,10 @@
package io.github.thebusybiscuit.slimefun4.implementation.operations;
+import com.google.common.base.Preconditions;
import io.github.thebusybiscuit.slimefun4.core.machines.MachineOperation;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel;
-import org.apache.commons.lang3.Validate;
import org.bukkit.inventory.ItemStack;
/**
@@ -26,8 +26,8 @@ public FuelOperation(@Nonnull MachineFuel recipe) {
}
public FuelOperation(@Nonnull ItemStack ingredient, @Nullable ItemStack result, int totalTicks) {
- Validate.notNull(ingredient, "The Ingredient cannot be null");
- Validate.isTrue(totalTicks > 0, "The amount of total ticks must be a positive integer");
+ Preconditions.checkNotNull(ingredient, "The Ingredient cannot be null");
+ Preconditions.checkArgument(totalTicks > 0, "The amount of total ticks must be a positive integer");
this.ingredient = ingredient;
this.result = result;
@@ -36,7 +36,7 @@ public FuelOperation(@Nonnull ItemStack ingredient, @Nullable ItemStack result,
@Override
public void addProgress(int num) {
- Validate.isTrue(num > 0, "Progress must be positive.");
+ Preconditions.checkArgument(num > 0, "Progress must be positive.");
currentTicks += num;
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/operations/MiningOperation.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/operations/MiningOperation.java
index cfb26be90c..dc16030d8c 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/operations/MiningOperation.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/operations/MiningOperation.java
@@ -1,8 +1,8 @@
package io.github.thebusybiscuit.slimefun4.implementation.operations;
+import com.google.common.base.Preconditions;
import io.github.thebusybiscuit.slimefun4.core.machines.MachineOperation;
import javax.annotation.Nonnull;
-import org.apache.commons.lang3.Validate;
import org.bukkit.inventory.ItemStack;
/**
@@ -20,8 +20,8 @@ public class MiningOperation implements MachineOperation {
private int currentTicks = 0;
public MiningOperation(@Nonnull ItemStack result, int totalTicks) {
- Validate.notNull(result, "The result cannot be null");
- Validate.isTrue(
+ Preconditions.checkNotNull(result, "The result cannot be null");
+ Preconditions.checkArgument(
totalTicks >= 0,
"The amount of total ticks must be a positive integer or zero, received: " + totalTicks);
@@ -31,7 +31,7 @@ public MiningOperation(@Nonnull ItemStack result, int totalTicks) {
@Override
public void addProgress(int num) {
- Validate.isTrue(num > 0, "Progress must be positive.");
+ Preconditions.checkArgument(num > 0, "Progress must be positive.");
currentTicks += num;
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/AbstractResource.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/AbstractResource.java
index c8fc704d60..07edff6188 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/AbstractResource.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/AbstractResource.java
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.implementation.resources;
+import com.google.common.base.Preconditions;
import com.google.gson.JsonElement;
import io.github.thebusybiscuit.slimefun4.api.exceptions.BiomeMapException;
import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource;
@@ -8,7 +9,6 @@
import java.util.logging.Level;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
-import org.apache.commons.lang3.Validate;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.ItemStack;
@@ -33,9 +33,9 @@ abstract class AbstractResource implements GEOResource {
@ParametersAreNonnullByDefault
AbstractResource(String key, String defaultName, ItemStack item, int maxDeviation, boolean geoMiner) {
- Validate.notNull(key, "NamespacedKey cannot be null!");
- Validate.notNull(defaultName, "The default name cannot be null!");
- Validate.notNull(item, "item cannot be null!");
+ Preconditions.checkNotNull(key, "NamespacedKey cannot be null!");
+ Preconditions.checkNotNull(defaultName, "The default name cannot be null!");
+ Preconditions.checkNotNull(item, "item cannot be null!");
this.key = new NamespacedKey(Slimefun.instance(), key);
this.defaultName = defaultName;
@@ -85,8 +85,8 @@ public boolean isObtainableFromGEOMiner() {
*/
@ParametersAreNonnullByDefault
static final @Nonnull BiomeMap getBiomeMap(AbstractResource resource, String path) {
- Validate.notNull(resource, "Resource cannot be null.");
- Validate.notNull(path, "Path cannot be null.");
+ Preconditions.checkNotNull(resource, "Resource cannot be null.");
+ Preconditions.checkNotNull(path, "Path cannot be null.");
try {
return BiomeMap.fromResource(resource.getKey(), Slimefun.instance(), path, JsonElement::getAsInt);
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/AsyncRecipeChoiceTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/AsyncRecipeChoiceTask.java
index f93aaa9daf..1db538ae86 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/AsyncRecipeChoiceTask.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/AsyncRecipeChoiceTask.java
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.implementation.tasks;
+import com.google.common.base.Preconditions;
import io.github.bakedlibs.dough.collections.LoopIterator;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide;
@@ -8,7 +9,6 @@
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import javax.annotation.Nonnull;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Tag;
@@ -44,7 +44,7 @@ public class AsyncRecipeChoiceTask implements Runnable {
* The {@link Inventory} to start this task for
*/
public void start(@Nonnull Inventory inv) {
- Validate.notNull(inv, "Inventory must not be null");
+ Preconditions.checkNotNull(inv, "Inventory must not be null");
inventory = inv;
id = Bukkit.getScheduler()
@@ -53,7 +53,7 @@ public void start(@Nonnull Inventory inv) {
}
public void add(int slot, @Nonnull MaterialChoice choice) {
- Validate.notNull(choice, "Cannot add a null RecipeChoice");
+ Preconditions.checkNotNull(choice, "Cannot add a null RecipeChoice");
lock.writeLock().lock();
@@ -65,7 +65,7 @@ public void add(int slot, @Nonnull MaterialChoice choice) {
}
public void add(int slot, @Nonnull Tag tag) {
- Validate.notNull(tag, "Cannot add a null Tag");
+ Preconditions.checkNotNull(tag, "Cannot add a null Tag");
lock.writeLock().lock();
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/CapacitorTextureUpdateTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/CapacitorTextureUpdateTask.java
index be69867265..9893c043b5 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/CapacitorTextureUpdateTask.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/CapacitorTextureUpdateTask.java
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.implementation.tasks;
+import com.google.common.base.Preconditions;
import io.github.bakedlibs.dough.skins.PlayerHead;
import io.github.bakedlibs.dough.skins.PlayerSkin;
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.Capacitor;
@@ -7,7 +8,6 @@
import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
import io.papermc.lib.PaperLib;
import javax.annotation.Nonnull;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Server;
@@ -42,7 +42,7 @@ public class CapacitorTextureUpdateTask implements Runnable {
* The percentage of charge in this {@link Capacitor}
*/
public CapacitorTextureUpdateTask(@Nonnull Location l, double percentage) {
- Validate.notNull(l, "The Location cannot be null");
+ Preconditions.checkNotNull(l, "The Location cannot be null");
this.l = l;
this.filledPercentage = NumberUtils.clamp(0.0D, percentage, 1.0D);
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/TickerTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/TickerTask.java
index c2f0a9e972..7f4da28a11 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/TickerTask.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/TickerTask.java
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.implementation.tasks;
+import com.google.common.base.Preconditions;
import com.xzavier0722.mc.plugin.slimefun4.storage.controller.ASlimefunDataContainer;
import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData;
import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunUniversalData;
@@ -24,7 +25,6 @@
import javax.annotation.ParametersAreNonnullByDefault;
import lombok.Setter;
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.scheduler.BukkitScheduler;
@@ -331,7 +331,7 @@ public Map> getTickLocations() {
*/
@Nonnull
public Set getLocations(@Nonnull Chunk chunk) {
- Validate.notNull(chunk, "The Chunk cannot be null!");
+ Preconditions.checkNotNull(chunk, "The Chunk cannot be null!");
Set locations = tickingLocations.getOrDefault(new ChunkPosition(chunk), Collections.emptySet());
return locations.stream().map(TickLocation::getLocation).collect(Collectors.toUnmodifiableSet());
@@ -351,7 +351,7 @@ public Set getLocations(@Nonnull Chunk chunk) {
*/
@Nonnull
public Set getTickLocations(@Nonnull Chunk chunk) {
- Validate.notNull(chunk, "The Chunk cannot be null!");
+ Preconditions.checkNotNull(chunk, "The Chunk cannot be null!");
return tickingLocations.getOrDefault(new ChunkPosition(chunk), Collections.emptySet());
}
@@ -367,7 +367,7 @@ public void enableTicker(@Nonnull Location l) {
}
public void enableTicker(@Nonnull Location l, @Nullable UUID uuid) {
- Validate.notNull(l, "Location cannot be null!");
+ Preconditions.checkNotNull(l, "Location cannot be null!");
synchronized (tickingLocations) {
ChunkPosition chunk = new ChunkPosition(l.getWorld(), l.getBlockX() >> 4, l.getBlockZ() >> 4);
@@ -404,7 +404,7 @@ public void enableTicker(@Nonnull Location l, @Nullable UUID uuid) {
* The {@link Location} to remove
*/
public void disableTicker(@Nonnull Location l) {
- Validate.notNull(l, "Location cannot be null!");
+ Preconditions.checkNotNull(l, "Location cannot be null!");
synchronized (tickingLocations) {
ChunkPosition chunk = new ChunkPosition(l.getWorld(), l.getBlockX() >> 4, l.getBlockZ() >> 4);
@@ -431,7 +431,7 @@ public void disableTicker(@Nonnull Location l) {
* The {@link UUID} to remove
*/
public void disableTicker(@Nonnull UUID uuid) {
- Validate.notNull(uuid, "Universal Data ID cannot be null!");
+ Preconditions.checkNotNull(uuid, "Universal Data ID cannot be null!");
synchronized (tickingLocations) {
tickingLocations.values().forEach(loc -> loc.removeIf(tk -> uuid.equals(tk.getUuid())));
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/storage/data/PlayerData.java b/src/main/java/io/github/thebusybiscuit/slimefun4/storage/data/PlayerData.java
index 81dc9b9aff..1f83482db3 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/storage/data/PlayerData.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/storage/data/PlayerData.java
@@ -1,6 +1,7 @@
package io.github.thebusybiscuit.slimefun4.storage.data;
import com.google.common.annotations.Beta;
+import com.google.common.base.Preconditions;
import io.github.thebusybiscuit.slimefun4.api.gps.Waypoint;
import io.github.thebusybiscuit.slimefun4.api.player.PlayerBackpack;
import io.github.thebusybiscuit.slimefun4.api.researches.Research;
@@ -9,7 +10,6 @@
import java.util.Map;
import java.util.Set;
import javax.annotation.Nonnull;
-import org.apache.commons.lang3.Validate;
/**
* The data which backs {@link io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile}
@@ -35,12 +35,12 @@ public Set getResearches() {
}
public void addResearch(@Nonnull Research research) {
- Validate.notNull(research, "Cannot add a 'null' research!");
+ Preconditions.checkNotNull(research, "Cannot add a 'null' research!");
researches.add(research);
}
public void removeResearch(@Nonnull Research research) {
- Validate.notNull(research, "Cannot remove a 'null' research!");
+ Preconditions.checkNotNull(research, "Cannot remove a 'null' research!");
researches.remove(research);
}
@@ -55,12 +55,12 @@ public PlayerBackpack getBackpack(int id) {
}
public void addBackpack(@Nonnull PlayerBackpack backpack) {
- Validate.notNull(backpack, "Cannot add a 'null' backpack!");
+ Preconditions.checkNotNull(backpack, "Cannot add a 'null' backpack!");
backpacks.put(backpack.getId(), backpack);
}
public void removeBackpack(@Nonnull PlayerBackpack backpack) {
- Validate.notNull(backpack, "Cannot remove a 'null' backpack!");
+ Preconditions.checkNotNull(backpack, "Cannot remove a 'null' backpack!");
backpacks.remove(backpack.getId());
}
@@ -69,7 +69,7 @@ public Set getWaypoints() {
}
public void addWaypoint(@Nonnull Waypoint waypoint) {
- Validate.notNull(waypoint, "Cannot add a 'null' waypoint!");
+ Preconditions.checkNotNull(waypoint, "Cannot add a 'null' waypoint!");
for (Waypoint wp : waypoints) {
if (wp.getId().equals(waypoint.getId())) {
@@ -86,7 +86,7 @@ public void addWaypoint(@Nonnull Waypoint waypoint) {
}
public void removeWaypoint(@Nonnull Waypoint waypoint) {
- Validate.notNull(waypoint, "Cannot remove a 'null' waypoint!");
+ Preconditions.checkNotNull(waypoint, "Cannot remove a 'null' waypoint!");
waypoints.remove(waypoint);
}
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChargeUtils.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChargeUtils.java
index 022725a20b..e4e2cac67a 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChargeUtils.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChargeUtils.java
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.utils;
+import com.google.common.base.Preconditions;
import io.github.bakedlibs.dough.common.ChatColors;
import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
@@ -9,7 +10,6 @@
import java.util.List;
import java.util.regex.Pattern;
import javax.annotation.Nonnull;
-import org.apache.commons.lang3.Validate;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataContainer;
@@ -35,10 +35,10 @@ public final class ChargeUtils {
private ChargeUtils() {}
public static void setCharge(@Nonnull ItemMeta meta, float charge, float capacity) {
- Validate.notNull(meta, "Meta cannot be null!");
- Validate.isTrue(charge >= 0, "Charge has to be equal to or greater than 0!");
- Validate.isTrue(capacity > 0, "Capacity has to be greater than 0!");
- Validate.isTrue(charge <= capacity, "Charge may not be bigger than the capacity!");
+ Preconditions.checkNotNull(meta, "Meta cannot be null!");
+ Preconditions.checkArgument(charge >= 0, "Charge has to be equal to or greater than 0!");
+ Preconditions.checkArgument(capacity > 0, "Capacity has to be greater than 0!");
+ Preconditions.checkArgument(charge <= capacity, "Charge may not be bigger than the capacity!");
BigDecimal decimal = BigDecimal.valueOf(charge).setScale(2, RoundingMode.HALF_UP);
float value = decimal.floatValue();
@@ -62,7 +62,7 @@ public static void setCharge(@Nonnull ItemMeta meta, float charge, float capacit
}
public static float getCharge(@Nonnull ItemMeta meta) {
- Validate.notNull(meta, "Meta cannot be null!");
+ Preconditions.checkNotNull(meta, "Meta cannot be null!");
NamespacedKey key = Slimefun.getRegistry().getItemChargeDataKey();
PersistentDataContainer container = meta.getPersistentDataContainer();
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ColoredMaterial.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ColoredMaterial.java
index dfc3e14947..cb7ec28c1a 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ColoredMaterial.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ColoredMaterial.java
@@ -1,11 +1,11 @@
package io.github.thebusybiscuit.slimefun4.utils;
+import com.google.common.base.Preconditions;
import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nonnull;
-import org.apache.commons.lang3.Validate;
import org.bukkit.DyeColor;
import org.bukkit.Material;
@@ -207,8 +207,10 @@ public enum ColoredMaterial {
* @param materials The {@link Material Materials} for this {@link ColoredMaterial}.
*/
ColoredMaterial(@Nonnull Material[] materials) {
- Validate.noNullElements(materials, "The List cannot contain any null elements");
- Validate.isTrue(
+ for (Material material : materials) {
+ Preconditions.checkNotNull(material, "The List cannot contain any null elements");
+ }
+ Preconditions.checkArgument(
materials.length == 16, "Expected 16, received: " + materials.length + ". Did you miss a color?");
list = Collections.unmodifiableList(Arrays.asList(materials));
@@ -221,13 +223,13 @@ public List asList() {
@Nonnull
public Material get(int index) {
- Validate.isTrue(index >= 0 && index < 16, "The index must be between 0 and 15 (inclusive).");
+ Preconditions.checkArgument(index >= 0 && index < 16, "The index must be between 0 and 15 (inclusive).");
return list.get(index);
}
public Material get(@Nonnull DyeColor color) {
- Validate.notNull(color, "Color cannot be null!");
+ Preconditions.checkNotNull(color, "Color cannot be null!");
return get(color.ordinal());
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/HeadTexture.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/HeadTexture.java
index 3e1f6a6c45..2b21e4280f 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/HeadTexture.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/HeadTexture.java
@@ -1,11 +1,11 @@
package io.github.thebusybiscuit.slimefun4.utils;
+import com.google.common.base.Preconditions;
import io.github.bakedlibs.dough.common.CommonPatterns;
import io.github.bakedlibs.dough.skins.PlayerSkin;
import java.nio.charset.StandardCharsets;
import java.util.UUID;
import javax.annotation.Nonnull;
-import org.apache.commons.lang3.Validate;
import org.bukkit.inventory.ItemStack;
/**
@@ -123,8 +123,9 @@ public enum HeadTexture {
private final UUID uuid;
HeadTexture(@Nonnull String texture) {
- Validate.notNull(texture, "Texture cannot be null");
- Validate.isTrue(CommonPatterns.HEXADECIMAL.matcher(texture).matches(), "Textures must be in hexadecimal.");
+ Preconditions.checkNotNull(texture, "Texture cannot be null");
+ Preconditions.checkArgument(
+ CommonPatterns.HEXADECIMAL.matcher(texture).matches(), "Textures must be in hexadecimal.");
this.texture = texture;
this.uuid = UUID.nameUUIDFromBytes(texture.getBytes(StandardCharsets.UTF_8));
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/InfiniteBlockGenerator.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/InfiniteBlockGenerator.java
index 0e589fe364..3ae37cbd26 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/InfiniteBlockGenerator.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/InfiniteBlockGenerator.java
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.utils;
+import com.google.common.base.Preconditions;
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
import io.github.thebusybiscuit.slimefun4.implementation.items.androids.MinerAndroid;
import io.papermc.lib.PaperLib;
@@ -7,7 +8,6 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.Block;
@@ -72,7 +72,7 @@ public enum InfiniteBlockGenerator implements Predicate {
*/
@Override
public boolean test(@Nonnull Block b) {
- Validate.notNull(b, "Block cannot be null!");
+ Preconditions.checkNotNull(b, "Block cannot be null!");
/*
* This will eliminate non-matching base materials If we
@@ -104,8 +104,8 @@ public boolean test(@Nonnull Block b) {
@ParametersAreNonnullByDefault
private boolean hasSurroundingMaterials(Block b, Material... materials) {
- Validate.notNull(b, "The Block cannot be null!");
- Validate.notEmpty(materials, "Materials need to have a size of at least one!");
+ Preconditions.checkNotNull(b, "The Block cannot be null!");
+ Preconditions.checkArgument(materials.length != 0, "Materials need to have a size of at least one!");
boolean[] matches = new boolean[materials.length];
int count = 0;
@@ -142,7 +142,7 @@ private boolean hasSurroundingMaterials(Block b, Material... materials) {
*/
@Nonnull
public BlockFormEvent callEvent(@Nonnull Block block) {
- Validate.notNull(block, "The Block cannot be null!");
+ Preconditions.checkNotNull(block, "The Block cannot be null!");
BlockState state = PaperLib.getBlockState(block, false).getState();
BlockFormEvent event = new BlockFormEvent(block, state);
Bukkit.getPluginManager().callEvent(event);
@@ -158,7 +158,7 @@ public BlockFormEvent callEvent(@Nonnull Block block) {
* @return An {@link InfiniteBlockGenerator} or null if none was found.
*/
@Nullable public static InfiniteBlockGenerator findAt(@Nonnull Block b) {
- Validate.notNull(b, "Cannot find a generator without a Location!");
+ Preconditions.checkNotNull(b, "Cannot find a generator without a Location!");
for (InfiniteBlockGenerator generator : valuesCached) {
if (generator.test(b)) {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/NumberUtils.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/NumberUtils.java
index d4d80601ea..8a8a157e17 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/NumberUtils.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/NumberUtils.java
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.utils;
+import com.google.common.base.Preconditions;
import io.github.bakedlibs.dough.common.CommonPatterns;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import java.text.DecimalFormat;
@@ -11,7 +12,6 @@
import java.util.logging.Level;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import org.apache.commons.lang3.Validate;
import org.bukkit.ChatColor;
/**
@@ -87,7 +87,7 @@ private NumberUtils() {}
* @return The {@link LocalDateTime} for the given input
*/
public static @Nonnull LocalDateTime parseGitHubDate(@Nonnull String date) {
- Validate.notNull(date, "Provided date was null");
+ Preconditions.checkNotNull(date, "Provided date was null");
return LocalDateTime.parse(date.substring(0, date.length() - 1));
}
@@ -153,8 +153,8 @@ private NumberUtils() {}
* @return The elapsed time as a {@link String}
*/
public static @Nonnull String getElapsedTime(@Nonnull LocalDateTime current, @Nonnull LocalDateTime priorDate) {
- Validate.notNull(current, "Provided current date was null");
- Validate.notNull(priorDate, "Provided past date was null");
+ Preconditions.checkNotNull(current, "Provided current date was null");
+ Preconditions.checkNotNull(priorDate, "Provided past date was null");
long hours = Duration.between(priorDate, current).toHours();
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java
index 8dff06afb6..ed56c4063e 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java
@@ -1,6 +1,7 @@
package io.github.thebusybiscuit.slimefun4.utils;
import city.norain.slimefun4.SlimefunExtended;
+import com.google.common.base.Preconditions;
import io.github.bakedlibs.dough.common.CommonPatterns;
import io.github.bakedlibs.dough.items.ItemMetaSnapshot;
import io.github.bakedlibs.dough.skins.PlayerHead;
@@ -30,7 +31,6 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
-import org.apache.commons.lang3.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
@@ -225,7 +225,7 @@ public static boolean isRadioactive(@Nullable ItemStack item) {
* @return An {@link ItemStack} with this Head texture
*/
public static @Nonnull ItemStack getCustomHead(@Nonnull String texture) {
- Validate.notNull(texture, "The provided texture is null");
+ Preconditions.checkNotNull(texture, "The provided texture is null");
if (Slimefun.instance() == null) {
throw new PrematureCodeException("You cannot instantiate a custom head before Slimefun was loaded.");
@@ -539,8 +539,8 @@ private static boolean equalsItemMeta(
* @return Whether the two lores are equal
*/
public static boolean equalsLore(@Nonnull List lore1, @Nonnull List lore2) {
- Validate.notNull(lore1, "Cannot compare lore that is null!");
- Validate.notNull(lore2, "Cannot compare lore that is null!");
+ Preconditions.checkNotNull(lore1, "Cannot compare lore that is null!");
+ Preconditions.checkNotNull(lore2, "Cannot compare lore that is null!");
List longerList = lore1.size() > lore2.size() ? lore1 : lore2;
List shorterList = lore1.size() > lore2.size() ? lore2 : lore1;
@@ -579,8 +579,8 @@ private static boolean isLineIgnored(@Nonnull String line) {
@Deprecated(forRemoval = true)
public static void updateCapacitorTexture(@Nonnull Location l, int charge, int capacity) {
- Validate.notNull(l, "Cannot update a texture for null");
- Validate.isTrue(capacity > 0, "Capacity must be greater than zero!");
+ Preconditions.checkNotNull(l, "Cannot update a texture for null");
+ Preconditions.checkArgument(capacity > 0, "Capacity must be greater than zero!");
updateCapacitorTexture(l, (double) charge / capacity);
}
@@ -605,7 +605,7 @@ public static void updateCapacitorTexture(@Nonnull Location l, double percentage
* @return Whether the {@link Player} is able to use that item.
*/
public static boolean canPlayerUseItem(@Nonnull Player p, @Nullable ItemStack item, boolean sendMessage) {
- Validate.notNull(p, "The player cannot be null");
+ Preconditions.checkNotNull(p, "The player cannot be null");
SlimefunItem sfItem = SlimefunItem.getByItem(item);
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/biomes/BiomeMap.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/biomes/BiomeMap.java
index a7754402d1..38b13c5549 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/biomes/BiomeMap.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/biomes/BiomeMap.java
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.utils.biomes;
+import com.google.common.base.Preconditions;
import com.google.gson.JsonElement;
import io.github.thebusybiscuit.slimefun4.api.exceptions.BiomeMapException;
import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource;
@@ -14,7 +15,6 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Keyed;
import org.bukkit.NamespacedKey;
import org.bukkit.block.Biome;
@@ -57,31 +57,31 @@ public class BiomeMap implements Keyed {
*/
@ParametersAreNonnullByDefault
public BiomeMap(NamespacedKey namespacedKey) {
- Validate.notNull(namespacedKey, "The key must not be null.");
+ Preconditions.checkNotNull(namespacedKey, "The key must not be null.");
this.namespacedKey = namespacedKey;
}
public @Nullable T get(@Nonnull Biome biome) {
- Validate.notNull(biome, "The biome shall not be null.");
+ Preconditions.checkNotNull(biome, "The biome shall not be null.");
return dataMap.get(biome);
}
public @Nonnull T getOrDefault(@Nonnull Biome biome, T defaultValue) {
- Validate.notNull(biome, "The biome should not be null.");
+ Preconditions.checkNotNull(biome, "The biome should not be null.");
return dataMap.getOrDefault(biome, defaultValue);
}
public boolean containsKey(@Nonnull Biome biome) {
- Validate.notNull(biome, "The biome must not be null.");
+ Preconditions.checkNotNull(biome, "The biome must not be null.");
return dataMap.containsKey(biome);
}
public boolean containsValue(@Nonnull T value) {
- Validate.notNull(value, "The value must not be null.");
+ Preconditions.checkNotNull(value, "The value must not be null.");
return dataMap.containsValue(value);
}
@@ -97,26 +97,26 @@ public boolean isEmpty() {
}
public boolean put(@Nonnull Biome biome, @Nonnull T value) {
- Validate.notNull(biome, "The biome should not be null.");
- Validate.notNull(value, "Values cannot be null.");
+ Preconditions.checkNotNull(biome, "The biome should not be null.");
+ Preconditions.checkNotNull(value, "Values cannot be null.");
return dataMap.put(biome, value) == null;
}
public void putAll(@Nonnull Map map) {
- Validate.notNull(map, "The map should not be null.");
+ Preconditions.checkNotNull(map, "The map should not be null.");
dataMap.putAll(map);
}
public void putAll(@Nonnull BiomeMap map) {
- Validate.notNull(map, "The map should not be null.");
+ Preconditions.checkNotNull(map, "The map should not be null.");
dataMap.putAll(map.dataMap);
}
public boolean remove(@Nonnull Biome biome) {
- Validate.notNull(biome, "The biome cannot be null.");
+ Preconditions.checkNotNull(biome, "The biome cannot be null.");
return dataMap.remove(biome) != null;
}
@@ -161,9 +161,9 @@ public String toString() {
public static @Nonnull BiomeMap fromResource(
NamespacedKey key, JavaPlugin plugin, String path, BiomeDataConverter valueConverter)
throws BiomeMapException {
- Validate.notNull(key, "The key shall not be null.");
- Validate.notNull(plugin, "The plugin shall not be null.");
- Validate.notNull(path, "The path should not be null!");
+ Preconditions.checkNotNull(key, "The key shall not be null.");
+ Preconditions.checkNotNull(plugin, "The plugin shall not be null.");
+ Preconditions.checkNotNull(path, "The path should not be null!");
try (BufferedReader reader = new BufferedReader(
new InputStreamReader(plugin.getClass().getResourceAsStream(path), StandardCharsets.UTF_8))) {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/biomes/BiomeMapParser.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/biomes/BiomeMapParser.java
index 703f4e4eda..4fb3328d31 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/biomes/BiomeMapParser.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/biomes/BiomeMapParser.java
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.utils.biomes;
+import com.google.common.base.Preconditions;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
@@ -16,7 +17,6 @@
import java.util.Set;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
-import org.apache.commons.lang3.Validate;
import org.bukkit.NamespacedKey;
import org.bukkit.block.Biome;
@@ -59,8 +59,8 @@ public class BiomeMapParser {
*/
@ParametersAreNonnullByDefault
public BiomeMapParser(NamespacedKey key, BiomeDataConverter valueConverter) {
- Validate.notNull(key, "The key shall not be null.");
- Validate.notNull(
+ Preconditions.checkNotNull(key, "The key shall not be null.");
+ Preconditions.checkNotNull(
valueConverter, "You must provide a Function to convert raw json values to your desired data type.");
this.key = key;
@@ -95,7 +95,7 @@ public boolean isLenient() {
}
public void read(@Nonnull String json) throws BiomeMapException {
- Validate.notNull(json, "The JSON string should not be null!");
+ Preconditions.checkNotNull(json, "The JSON string should not be null!");
JsonArray root = null;
try {
@@ -112,7 +112,7 @@ public void read(@Nonnull String json) throws BiomeMapException {
}
public void read(@Nonnull JsonArray json) throws BiomeMapException {
- Validate.notNull(json, "The JSON Array should not be null!");
+ Preconditions.checkNotNull(json, "The JSON Array should not be null!");
for (JsonElement element : json) {
if (element instanceof JsonObject) {
@@ -126,7 +126,7 @@ public void read(@Nonnull JsonArray json) throws BiomeMapException {
}
private void readEntry(@Nonnull JsonObject entry) throws BiomeMapException {
- Validate.notNull(entry, "The JSON entry should not be null!");
+ Preconditions.checkNotNull(entry, "The JSON entry should not be null!");
/*
* Check if the entry has a "value" element.
@@ -158,7 +158,7 @@ private void readEntry(@Nonnull JsonObject entry) throws BiomeMapException {
}
private @Nonnull Set readBiomes(@Nonnull JsonArray array) throws BiomeMapException {
- Validate.notNull(array, "The JSON array should not be null!");
+ Preconditions.checkNotNull(array, "The JSON array should not be null!");
Set biomes = new HashSet<>();
for (JsonElement element : array) {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/ItemStackWrapper.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/ItemStackWrapper.java
index ee604a0501..e61511186e 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/ItemStackWrapper.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/ItemStackWrapper.java
@@ -1,9 +1,9 @@
package io.github.thebusybiscuit.slimefun4.utils.itemstack;
+import com.google.common.base.Preconditions;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nonnull;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
@@ -108,7 +108,7 @@ public void addUnsafeEnchantment(Enchantment ench, int level) {
* @see #wrap(ItemStack)
*/
public static @Nonnull ItemStackWrapper forceWrap(@Nonnull ItemStack itemStack) {
- Validate.notNull(itemStack, "The ItemStack cannot be null!");
+ Preconditions.checkNotNull(itemStack, "The ItemStack cannot be null!");
return new ItemStackWrapper(itemStack);
}
@@ -124,7 +124,7 @@ public void addUnsafeEnchantment(Enchantment ench, int level) {
* @see #forceWrap(ItemStack)
*/
public static @Nonnull ItemStackWrapper wrap(@Nonnull ItemStack itemStack) {
- Validate.notNull(itemStack, "The ItemStack cannot be null!");
+ Preconditions.checkNotNull(itemStack, "The ItemStack cannot be null!");
if (itemStack instanceof ItemStackWrapper wrapper) {
return wrapper;
@@ -142,7 +142,7 @@ public void addUnsafeEnchantment(Enchantment ench, int level) {
* @return An {@link ItemStackWrapper} array
*/
public static @Nonnull ItemStackWrapper[] wrapArray(@Nonnull ItemStack[] items) {
- Validate.notNull(items, "The array must not be null!");
+ Preconditions.checkNotNull(items, "The array must not be null!");
ItemStackWrapper[] array = new ItemStackWrapper[items.length];
@@ -164,7 +164,7 @@ public void addUnsafeEnchantment(Enchantment ench, int level) {
* @return An {@link ItemStackWrapper} array
*/
public static @Nonnull List wrapList(@Nonnull List items) {
- Validate.notNull(items, "The list must not be null!");
+ Preconditions.checkNotNull(items, "The list must not be null!");
List list = new ArrayList<>(items.size());
for (ItemStack item : items) {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java
index 0c0cd45aa8..d017644e78 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.utils.tags;
+import com.google.common.base.Preconditions;
import io.github.thebusybiscuit.slimefun4.api.exceptions.TagMisconfigurationException;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.implementation.items.autocrafters.AbstractAutoCrafter;
@@ -23,7 +24,6 @@
import java.util.stream.Stream;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.Tag;
@@ -432,7 +432,7 @@ public boolean isEmpty() {
* @return The {@link SlimefunTag} or null if it does not exist.
*/
public static @Nullable SlimefunTag getTag(@Nonnull String value) {
- Validate.notNull(value, "A tag cannot be null!");
+ Preconditions.checkNotNull(value, "A tag cannot be null!");
return nameLookup.get(value);
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java
index 615c6a2fd2..f7601c3be0 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.utils.tags;
+import com.google.common.base.Preconditions;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
@@ -22,7 +23,6 @@
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Bukkit;
import org.bukkit.Keyed;
import org.bukkit.Material;
@@ -92,7 +92,7 @@ void parse(@Nonnull SlimefunTag tag, @Nonnull BiConsumer, Set, Set>> callback)
throws TagMisconfigurationException {
- Validate.notNull(json, "Cannot parse a null String");
+ Preconditions.checkNotNull(json, "Cannot parse a null String");
try {
Set materials = EnumSet.noneOf(Material.class);
diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java
index 4322739dfc..dd51014b31 100644
--- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java
+++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java
@@ -1,5 +1,6 @@
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems;
+import com.google.common.base.Preconditions;
import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData;
import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils;
import io.github.bakedlibs.dough.inventory.InvUtils;
@@ -32,7 +33,6 @@
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
@@ -197,7 +197,7 @@ public int getSpeed() {
* @return This method will return the current instance of {@link AContainer}, so that can be chained.
*/
public final AContainer setCapacity(int capacity) {
- Validate.isTrue(capacity > 0, "The capacity must be greater than zero!");
+ Preconditions.checkArgument(capacity > 0, "The capacity must be greater than zero!");
if (getState() == ItemState.UNREGISTERED) {
this.energyCapacity = capacity;
@@ -216,7 +216,7 @@ public final AContainer setCapacity(int capacity) {
* @return This method will return the current instance of {@link AContainer}, so that can be chained.
*/
public final AContainer setProcessingSpeed(int speed) {
- Validate.isTrue(speed > 0, "The speed must be greater than zero!");
+ Preconditions.checkArgument(speed > 0, "The speed must be greater than zero!");
this.processingSpeed = speed;
return this;
@@ -231,9 +231,10 @@ public final AContainer setProcessingSpeed(int speed) {
* @return This method will return the current instance of {@link AContainer}, so that can be chained.
*/
public final AContainer setEnergyConsumption(int energyConsumption) {
- Validate.isTrue(energyConsumption > 0, "The energy consumption must be greater than zero!");
- Validate.isTrue(energyCapacity > 0, "You must specify the capacity before you can set the consumption amount.");
- Validate.isTrue(
+ Preconditions.checkArgument(energyConsumption > 0, "The energy consumption must be greater than zero!");
+ Preconditions.checkArgument(
+ energyCapacity > 0, "You must specify the capacity before you can set the consumption amount.");
+ Preconditions.checkArgument(
energyConsumption <= energyCapacity,
"The energy consumption cannot be higher than the capacity (" + energyCapacity + ')');
@@ -393,7 +394,7 @@ protected void tick(Block b) {
* @return Whether charge was taken if its chargeable
*/
protected boolean takeCharge(@Nonnull Location l) {
- Validate.notNull(l, "Can't attempt to take charge from a null location!");
+ Preconditions.checkNotNull(l, "Can't attempt to take charge from a null location!");
if (isChargeable()) {
long charge = getChargeLong(l);
diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java
index caf46a526c..3b6770d660 100644
--- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java
+++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java
@@ -1,5 +1,6 @@
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems;
+import com.google.common.base.Preconditions;
import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData;
import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils;
import io.github.bakedlibs.dough.items.CustomItemStack;
@@ -30,7 +31,6 @@
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
@@ -253,7 +253,7 @@ public int getEnergyProduction() {
* @return This method will return the current instance of {@link AGenerator}, so that can be chained.
*/
public final AGenerator setCapacity(int capacity) {
- Validate.isTrue(capacity >= 0, "The capacity cannot be negative!");
+ Preconditions.checkArgument(capacity >= 0, "The capacity cannot be negative!");
if (getState() == ItemState.UNREGISTERED) {
this.energyCapacity = capacity;
@@ -272,7 +272,7 @@ public final AGenerator setCapacity(int capacity) {
* @return This method will return the current instance of {@link AGenerator}, so that can be chained.
*/
public final AGenerator setEnergyProduction(int energyProduced) {
- Validate.isTrue(energyProduced > 0, "The energy production must be greater than zero!");
+ Preconditions.checkArgument(energyProduced > 0, "The energy production must be greater than zero!");
this.energyProducedPerTick = energyProduced;
return this;
diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/MachineFuel.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/MachineFuel.java
index 975745767b..c0f47186a6 100644
--- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/MachineFuel.java
+++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/MachineFuel.java
@@ -1,9 +1,9 @@
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems;
+import com.google.common.base.Preconditions;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper;
import java.util.function.Predicate;
-import org.apache.commons.lang3.Validate;
import org.bukkit.inventory.ItemStack;
// This class will be rewritten in the "Recipe Rewrite"
@@ -21,8 +21,8 @@ public MachineFuel(int seconds, ItemStack fuel) {
}
public MachineFuel(int seconds, ItemStack fuel, ItemStack output) {
- Validate.notNull(fuel, "Fuel must never be null!");
- Validate.isTrue(seconds > 0, "Fuel must last at least one second!");
+ Preconditions.checkNotNull(fuel, "Fuel must never be null!");
+ Preconditions.checkArgument(seconds > 0, "Fuel must last at least one second!");
this.ticks = seconds * 2;
this.fuel = fuel;
diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/BlockMenuPreset.java b/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/BlockMenuPreset.java
index f98262f4d5..f471cdaae3 100644
--- a/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/BlockMenuPreset.java
+++ b/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/BlockMenuPreset.java
@@ -1,5 +1,6 @@
package me.mrCookieSlime.Slimefun.api.inventory;
+import com.google.common.base.Preconditions;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
@@ -9,7 +10,6 @@
import javax.annotation.Nullable;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
-import org.apache.commons.lang3.Validate;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
@@ -29,7 +29,7 @@ public abstract class BlockMenuPreset extends ChestMenu {
protected BlockMenuPreset(@Nonnull String id, @Nonnull String title) {
super(title);
- Validate.notNull(id, "You need to specify an id!");
+ Preconditions.checkNotNull(id, "You need to specify an id!");
this.id = id;
this.inventoryTitle = title;
@@ -107,7 +107,7 @@ public void replaceExistingItem(int slot, ItemStack item) {
* The slots which should be treated as background
*/
public void drawBackground(@Nonnull ItemStack item, @Nonnull int[] slots) {
- Validate.notNull(item, "The background item cannot be null!");
+ Preconditions.checkNotNull(item, "The background item cannot be null!");
checkIfLocked();
for (int slot : slots) {
@@ -218,7 +218,7 @@ protected void clone(@Nonnull DirtyChestMenu menu) {
}
public void newInstance(@Nonnull BlockMenu menu, @Nonnull Location l) {
- Validate.notNull(l, "Cannot create a new BlockMenu without a Location");
+ Preconditions.checkNotNull(l, "Cannot create a new BlockMenu without a Location");
Slimefun.runSync(() -> {
locked = true;