Skip to content

Commit

Permalink
chore: use Preconditions
Browse files Browse the repository at this point in the history
  • Loading branch information
ybw0014 committed Aug 6, 2023
1 parent 881ea3f commit 622b3e1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper;

import com.google.common.base.Preconditions;

import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker;

/**
Expand Down Expand Up @@ -890,9 +892,7 @@ public final void addOfficialWikipage(@Nonnull String page) {
* The associated wiki page name.
*/
public final void addWikiPage(@Nonnull String page) {
Validate.notNull(page, "Wiki page cannot be null.");
Validate.isTrue(getState() != ItemState.UNREGISTERED, "Wiki page can only be added after item has been registered.");
wikiURL = Optional.of(getAddon().getWikiURL().replace("%item%", page));
addCustomWikiPage(getAddon().getWikiURL().replace("%item%", page));
}

/**
Expand All @@ -902,8 +902,8 @@ public final void addWikiPage(@Nonnull String page) {
* The associated wiki page URL.
*/
public final void addCustomWikiPage(@Nonnull String url) {
Validate.notNull(url, "Wiki URL cannot be null.");
Validate.isTrue(getState() != ItemState.UNREGISTERED, "Wiki page can only be added after item has been registered.");
Preconditions.checkArgument(url != null, "Wiki page cannot be null.");
Preconditions.checkState(getState() != ItemState.UNREGISTERED, "Wiki page can only be added after item has been registered.");
wikiURL = Optional.of(url);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

import javax.annotation.Nonnull;

import org.apache.commons.lang.Validate;
import org.bukkit.plugin.Plugin;

import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;

import com.google.common.base.Preconditions;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;

Expand Down Expand Up @@ -48,8 +48,9 @@ public static void setupWiki(@Nonnull Plugin plugin) {
* The formatter to apply to the wiki page name.
*/
public static void setupWiki(@Nonnull Plugin plugin, @Nonnull UnaryOperator<String> formatter) {
Validate.notNull(plugin, "The plugin cannot be null");
Validate.isTrue(plugin instanceof SlimefunAddon, "The plugin must be a SlimefunAddon");
Preconditions.checkArgument(plugin != null, "The plugin cannot be null");
Preconditions.checkArgument(formatter != null, "The formatter cannot be null");
Preconditions.checkArgument(plugin instanceof SlimefunAddon, "The plugin must be a SlimefunAddon");

try (BufferedReader reader = new BufferedReader(new InputStreamReader(plugin.getClass().getResourceAsStream("/wiki.json"), StandardCharsets.UTF_8))) {
JsonElement element = JsonUtils.parseString(reader.lines().collect(Collectors.joining("")));
Expand Down

0 comments on commit 622b3e1

Please sign in to comment.