Skip to content

Commit e0da311

Browse files
committed
refactor: replace commons-lang Validate with Guava Preconditions (#3586)
Migrated all usages of org.apache.commons.lang.Validate to com.google.common.base.Preconditions as discussed in issue #3586. This removes the dependency on commons-lang for validation checks.
1 parent 5374034 commit e0da311

118 files changed

Lines changed: 555 additions & 555 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/main/java/io/github/thebusybiscuit/slimefun4/api/MinecraftVersion.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import javax.annotation.Nonnull;
44

5-
import org.apache.commons.lang.Validate;
5+
import com.google.common.base.Preconditions;
66
import org.bukkit.Server;
77

88
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
@@ -233,7 +233,7 @@ public boolean isMinecraftVersion(int minecraftVersion, int patchVersion) {
233233
* @return Whether this {@link MinecraftVersion} is newer or equal to the given {@link MinecraftVersion}
234234
*/
235235
public boolean isAtLeast(@Nonnull MinecraftVersion version) {
236-
Validate.notNull(version, "A Minecraft version cannot be null!");
236+
Preconditions.checkNotNull(version, "A Minecraft version cannot be null!");
237237

238238
if (this == UNKNOWN) {
239239
return false;
@@ -268,7 +268,7 @@ public boolean isAtLeast(@Nonnull MinecraftVersion version) {
268268
* @return Whether this {@link MinecraftVersion} is older than the given one
269269
*/
270270
public boolean isBefore(@Nonnull MinecraftVersion version) {
271-
Validate.notNull(version, "A Minecraft version cannot be null!");
271+
Preconditions.checkNotNull(version, "A Minecraft version cannot be null!");
272272

273273
if (this == UNKNOWN) {
274274
return true;

src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunAddon.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import javax.annotation.Nonnull;
66
import javax.annotation.Nullable;
77

8-
import org.apache.commons.lang.Validate;
8+
import com.google.common.base.Preconditions;
99
import org.bukkit.plugin.Plugin;
1010
import org.bukkit.plugin.PluginDescriptionFile;
1111
import org.bukkit.plugin.java.JavaPlugin;
@@ -86,7 +86,7 @@ public interface SlimefunAddon {
8686
* @return Whether this {@link SlimefunAddon} depends on the given {@link Plugin}
8787
*/
8888
default boolean hasDependency(@Nonnull String dependency) {
89-
Validate.notNull(dependency, "The dependency cannot be null");
89+
Preconditions.checkNotNull(dependency, "The dependency cannot be null");
9090

9191
// Well... it cannot depend on itself but you get the idea.
9292
if (getJavaPlugin().getName().equalsIgnoreCase(dependency)) {

src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunBranch.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import javax.annotation.Nonnull;
44

5-
import org.apache.commons.lang.Validate;
5+
import com.google.common.base.Preconditions;
66

77
import io.github.bakedlibs.dough.common.CommonPatterns;
88

@@ -45,7 +45,7 @@ public enum SlimefunBranch {
4545
private final boolean official;
4646

4747
SlimefunBranch(@Nonnull String name, boolean official) {
48-
Validate.notNull(name, "The branch name cannot be null");
48+
Preconditions.checkNotNull(name, "The branch name cannot be null");
4949

5050
this.name = name;
5151
this.official = official;

src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncAutoEnchanterProcessEvent.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import javax.annotation.Nonnull;
44

5-
import org.apache.commons.lang.Validate;
5+
import com.google.common.base.Preconditions;
66
import org.bukkit.event.Cancellable;
77
import org.bukkit.event.Event;
88
import org.bukkit.event.HandlerList;
@@ -31,9 +31,9 @@ public class AsyncAutoEnchanterProcessEvent extends Event implements Cancellable
3131
public AsyncAutoEnchanterProcessEvent(@Nonnull ItemStack item, @Nonnull ItemStack enchantedBook, @Nonnull BlockMenu menu) {
3232
super(true);
3333

34-
Validate.notNull(item, "The item to enchant cannot be null!");
35-
Validate.notNull(enchantedBook, "The enchanted book to enchant cannot be null!");
36-
Validate.notNull(menu, "The menu of auto-enchanter cannot be null!");
34+
Preconditions.checkNotNull(item, "The item to enchant cannot be null!");
35+
Preconditions.checkNotNull(enchantedBook, "The enchanted book to enchant cannot be null!");
36+
Preconditions.checkNotNull(menu, "The menu of auto-enchanter cannot be null!");
3737

3838
this.item = item;
3939
this.enchantedBook = enchantedBook;

src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncProfileLoadEvent.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import javax.annotation.Nonnull;
66

7-
import org.apache.commons.lang.Validate;
7+
import com.google.common.base.Preconditions;
88
import org.bukkit.entity.Player;
99
import org.bukkit.event.Event;
1010
import org.bukkit.event.HandlerList;
@@ -32,7 +32,7 @@ public class AsyncProfileLoadEvent extends Event {
3232
public AsyncProfileLoadEvent(@Nonnull PlayerProfile profile) {
3333
super(true);
3434

35-
Validate.notNull(profile, "The Profile cannot be null");
35+
Preconditions.checkNotNull(profile, "The Profile cannot be null");
3636

3737
this.uniqueId = profile.getUUID();
3838
this.profile = profile;
@@ -56,8 +56,8 @@ public PlayerProfile getProfile() {
5656
* The {@link PlayerProfile}
5757
*/
5858
public void setProfile(@Nonnull PlayerProfile profile) {
59-
Validate.notNull(profile, "The PlayerProfile cannot be null!");
60-
Validate.isTrue(profile.getUUID().equals(uniqueId), "Cannot inject a PlayerProfile with a different UUID");
59+
Preconditions.checkNotNull(profile, "The PlayerProfile cannot be null!");
60+
Preconditions.checkArgument(profile.getUUID().equals(uniqueId), "Cannot inject a PlayerProfile with a different UUID");
6161

6262
this.profile = profile;
6363
}

src/main/java/io/github/thebusybiscuit/slimefun4/api/events/BlockPlacerPlaceEvent.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import javax.annotation.Nonnull;
44
import javax.annotation.ParametersAreNonnullByDefault;
55

6-
import org.apache.commons.lang.Validate;
6+
import com.google.common.base.Preconditions;
77
import org.bukkit.block.Block;
88
import org.bukkit.event.Cancellable;
99
import org.bukkit.event.Event;
@@ -75,7 +75,7 @@ public ItemStack getItemStack() {
7575
* The {@link ItemStack} to be placed
7676
*/
7777
public void setItemStack(@Nonnull ItemStack item) {
78-
Validate.notNull(item, "The ItemStack must not be null!");
78+
Preconditions.checkNotNull(item, "The ItemStack must not be null!");
7979

8080
if (!locked) {
8181
this.placedItem = item;

src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ClimbingPickLaunchEvent.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import javax.annotation.Nonnull;
44
import javax.annotation.ParametersAreNonnullByDefault;
55

6-
import org.apache.commons.lang.Validate;
6+
import com.google.common.base.Preconditions;
77
import org.bukkit.block.Block;
88
import org.bukkit.entity.Player;
99
import org.bukkit.event.Cancellable;
@@ -63,7 +63,7 @@ public Vector getVelocity() {
6363
* The {@link Vector} velocity to apply
6464
*/
6565
public void setVelocity(@Nonnull Vector velocity) {
66-
Validate.notNull(velocity);
66+
Preconditions.checkNotNull(velocity);
6767
this.velocity = velocity;
6868
}
6969

src/main/java/io/github/thebusybiscuit/slimefun4/api/events/CoolerFeedPlayerEvent.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import javax.annotation.Nonnull;
44
import javax.annotation.ParametersAreNonnullByDefault;
55

6-
import org.apache.commons.lang.Validate;
6+
import com.google.common.base.Preconditions;
77
import org.bukkit.entity.Player;
88
import org.bukkit.event.Cancellable;
99
import org.bukkit.event.Event;
@@ -84,8 +84,8 @@ public ItemStack getConsumedItem() {
8484
* The new {@link ItemStack}
8585
*/
8686
public void setConsumedItem(@Nonnull ItemStack item) {
87-
Validate.notNull(item, "The consumed Item cannot be null!");
88-
Validate.isTrue(item.getItemMeta() instanceof PotionMeta, "The item must be a potion!");
87+
Preconditions.checkNotNull(item, "The consumed Item cannot be null!");
88+
Preconditions.checkArgument(item.getItemMeta() instanceof PotionMeta, "The item must be a potion!");
8989

9090
this.consumedItem = item;
9191
}

src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ExplosiveToolBreakBlocksEvent.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import javax.annotation.Nonnull;
66
import javax.annotation.ParametersAreNonnullByDefault;
77

8-
import org.apache.commons.lang.Validate;
8+
import com.google.common.base.Preconditions;
99
import org.bukkit.block.Block;
1010
import org.bukkit.entity.Player;
1111
import org.bukkit.event.Cancellable;
@@ -38,10 +38,10 @@ public class ExplosiveToolBreakBlocksEvent extends PlayerEvent implements Cancel
3838
public ExplosiveToolBreakBlocksEvent(Player player, Block block, List<Block> blocks, ItemStack item, ExplosiveTool explosiveTool) {
3939
super(player);
4040

41-
Validate.notNull(block, "The center block cannot be null!");
42-
Validate.notNull(blocks, "Blocks cannot be null");
43-
Validate.notNull(item, "Item cannot be null");
44-
Validate.notNull(explosiveTool, "ExplosiveTool cannot be null");
41+
Preconditions.checkNotNull(block, "The center block cannot be null!");
42+
Preconditions.checkNotNull(blocks, "Blocks cannot be null");
43+
Preconditions.checkNotNull(item, "Item cannot be null");
44+
Preconditions.checkNotNull(explosiveTool, "ExplosiveTool cannot be null");
4545

4646
this.mainBlock = block;
4747
this.additionalBlocks = blocks;

src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerPreResearchEvent.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import javax.annotation.Nonnull;
44
import javax.annotation.ParametersAreNonnullByDefault;
55

6-
import org.apache.commons.lang.Validate;
6+
import com.google.common.base.Preconditions;
77
import org.bukkit.entity.Player;
88
import org.bukkit.event.Cancellable;
99
import org.bukkit.event.Event;
@@ -35,9 +35,9 @@ public class PlayerPreResearchEvent extends Event implements Cancellable {
3535

3636
@ParametersAreNonnullByDefault
3737
public PlayerPreResearchEvent(Player p, Research research, SlimefunItem slimefunItem) {
38-
Validate.notNull(p, "The Player cannot be null");
39-
Validate.notNull(research, "Research cannot be null");
40-
Validate.notNull(slimefunItem, "SlimefunItem cannot be null");
38+
Preconditions.checkNotNull(p, "The Player cannot be null");
39+
Preconditions.checkNotNull(research, "Research cannot be null");
40+
Preconditions.checkNotNull(slimefunItem, "SlimefunItem cannot be null");
4141

4242
this.player = p;
4343
this.research = research;

0 commit comments

Comments
 (0)