mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
Updated to CommonPatterns
This commit is contained in:
parent
a2a42a7b62
commit
9c0d28e64b
@ -4,7 +4,7 @@ import javax.annotation.Nonnull;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.utils.PatternUtils;
|
||||
import io.github.bakedlibs.dough.common.CommonPatterns;
|
||||
|
||||
/**
|
||||
* This enum represents the branch this Slimefun build is on.
|
||||
@ -50,7 +50,7 @@ public enum SlimefunBranch {
|
||||
this.name = name;
|
||||
this.official = official;
|
||||
|
||||
if (!PatternUtils.ASCII.matcher(name).matches()) {
|
||||
if (!CommonPatterns.ASCII.matcher(name).matches()) {
|
||||
throw new IllegalStateException("The SlimefunBranch enum contains ILLEGAL CHARACTERS. DO NOT TRANSLATE THIS FILE.");
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import io.github.bakedlibs.dough.common.CommonPatterns;
|
||||
import io.github.bakedlibs.dough.items.ItemMetaSnapshot;
|
||||
import io.github.bakedlibs.dough.skins.PlayerHead;
|
||||
import io.github.bakedlibs.dough.skins.PlayerSkin;
|
||||
@ -31,7 +32,6 @@ import io.github.thebusybiscuit.slimefun4.api.exceptions.PrematureCodeException;
|
||||
import io.github.thebusybiscuit.slimefun4.api.exceptions.WrongItemStackException;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.HeadTexture;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.PatternUtils;
|
||||
|
||||
/**
|
||||
* The {@link SlimefunItemStack} functions as the base for any
|
||||
@ -297,7 +297,7 @@ public class SlimefunItemStack extends ItemStack {
|
||||
|
||||
if (texture.startsWith("ey")) {
|
||||
return texture;
|
||||
} else if (PatternUtils.HEXADECIMAL.matcher(texture).matches()) {
|
||||
} else if (CommonPatterns.HEXADECIMAL.matcher(texture).matches()) {
|
||||
String value = "{\"textures\":{\"SKIN\":{\"url\":\"http://textures.minecraft.net/texture/" + texture + "\"}}}";
|
||||
return Base64.getEncoder().encodeToString(value.getBytes(StandardCharsets.UTF_8));
|
||||
} else {
|
||||
|
@ -31,6 +31,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import io.github.bakedlibs.dough.common.ChatColors;
|
||||
import io.github.bakedlibs.dough.common.CommonPatterns;
|
||||
import io.github.bakedlibs.dough.config.Config;
|
||||
import io.github.thebusybiscuit.slimefun4.api.events.AsyncProfileLoadEvent;
|
||||
import io.github.thebusybiscuit.slimefun4.api.gps.Waypoint;
|
||||
@ -42,7 +43,6 @@ import io.github.thebusybiscuit.slimefun4.core.guide.GuideHistory;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.armor.SlimefunArmorPiece;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.PatternUtils;
|
||||
|
||||
/**
|
||||
* A class that can store a Player's {@link Research} progress for caching purposes.
|
||||
@ -439,9 +439,9 @@ public class PlayerProfile {
|
||||
|
||||
for (String line : item.getItemMeta().getLore()) {
|
||||
if (line.startsWith(ChatColors.color("&7ID: ")) && line.indexOf('#') != -1) {
|
||||
String[] splitLine = PatternUtils.HASH.split(line);
|
||||
String[] splitLine = CommonPatterns.HASH.split(line);
|
||||
|
||||
if (PatternUtils.NUMERIC.matcher(splitLine[1]).matches()) {
|
||||
if (CommonPatterns.NUMERIC.matcher(splitLine[1]).matches()) {
|
||||
id = OptionalInt.of(Integer.parseInt(splitLine[1]));
|
||||
uuid = splitLine[0].replace(ChatColors.color("&7ID: "), "");
|
||||
}
|
||||
|
@ -10,8 +10,8 @@ import org.bukkit.Keyed;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import io.github.bakedlibs.dough.common.CommonPatterns;
|
||||
import io.github.bakedlibs.dough.data.persistent.PersistentDataAPI;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.PatternUtils;
|
||||
|
||||
/**
|
||||
* A very simple API that is meant for adding/getting/clearing custom status effects
|
||||
@ -97,7 +97,7 @@ public class StatusEffect implements Keyed {
|
||||
Optional<String> optional = PersistentDataAPI.getOptionalString(p, getKey());
|
||||
|
||||
if (optional.isPresent()) {
|
||||
String[] data = PatternUtils.SEMICOLON.split(optional.get());
|
||||
String[] data = CommonPatterns.SEMICOLON.split(optional.get());
|
||||
long timestamp = Long.parseLong(data[1]);
|
||||
|
||||
if (timestamp == 0 || timestamp >= System.currentTimeMillis()) {
|
||||
@ -123,7 +123,7 @@ public class StatusEffect implements Keyed {
|
||||
Optional<String> optional = PersistentDataAPI.getOptionalString(p, getKey());
|
||||
|
||||
if (optional.isPresent()) {
|
||||
String[] data = PatternUtils.SEMICOLON.split(optional.get());
|
||||
String[] data = CommonPatterns.SEMICOLON.split(optional.get());
|
||||
return OptionalInt.of(Integer.parseInt(data[0]));
|
||||
} else {
|
||||
return OptionalInt.empty();
|
||||
|
@ -8,13 +8,13 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.bakedlibs.dough.common.CommonPatterns;
|
||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
||||
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
|
||||
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.RestoredBackpack;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.PatternUtils;
|
||||
|
||||
/**
|
||||
* This command that allows for backpack retrieval in the event they are lost.
|
||||
@ -47,7 +47,7 @@ class BackpackCommand extends SubCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!PatternUtils.NUMERIC.matcher(args[2]).matches()) {
|
||||
if (!CommonPatterns.NUMERIC.matcher(args[2]).matches()) {
|
||||
Slimefun.getLocalization().sendMessage(sender, "commands.backpack.invalid-id");
|
||||
return;
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.bakedlibs.dough.common.CommonPatterns;
|
||||
import io.github.bakedlibs.dough.common.PlayerList;
|
||||
import io.github.bakedlibs.dough.items.CustomItemStack;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
@ -17,7 +18,6 @@ import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
|
||||
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
|
||||
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.PatternUtils;
|
||||
|
||||
class GiveCommand extends SubCommand {
|
||||
|
||||
@ -83,7 +83,7 @@ class GiveCommand extends SubCommand {
|
||||
int amount = 1;
|
||||
|
||||
if (args.length == 4) {
|
||||
if (PatternUtils.NUMERIC.matcher(args[3]).matches()) {
|
||||
if (CommonPatterns.NUMERIC.matcher(args[3]).matches()) {
|
||||
amount = Integer.parseInt(args[3]);
|
||||
} else {
|
||||
return 0;
|
||||
|
@ -12,12 +12,12 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import io.github.bakedlibs.dough.common.ChatColors;
|
||||
import io.github.bakedlibs.dough.common.CommonPatterns;
|
||||
import io.github.bakedlibs.dough.items.CustomItemStack;
|
||||
import io.github.thebusybiscuit.slimefun4.core.services.github.Contributor;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.PatternUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
||||
@ -99,7 +99,7 @@ final class ContributorsMenu {
|
||||
String info = entry.getKey();
|
||||
|
||||
if (!info.startsWith("&")) {
|
||||
String[] segments = PatternUtils.COMMA.split(info);
|
||||
String[] segments = CommonPatterns.COMMA.split(info);
|
||||
info = Slimefun.getLocalization().getMessage(p, "guide.credits.roles." + segments[0]);
|
||||
|
||||
if (segments.length == 2) {
|
||||
|
@ -16,11 +16,11 @@ import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.bakedlibs.dough.common.CommonPatterns;
|
||||
import io.github.thebusybiscuit.slimefun4.api.network.Network;
|
||||
import io.github.thebusybiscuit.slimefun4.api.network.NetworkComponent;
|
||||
import io.github.thebusybiscuit.slimefun4.core.attributes.HologramOwner;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.PatternUtils;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||
|
||||
@ -261,7 +261,7 @@ public class CargoNet extends AbstractItemNetwork implements HologramOwner {
|
||||
|
||||
if (frequency == null) {
|
||||
return 0;
|
||||
} else if (!PatternUtils.NUMERIC.matcher(frequency).matches()) {
|
||||
} else if (!CommonPatterns.NUMERIC.matcher(frequency).matches()) {
|
||||
Slimefun.logger().log(Level.SEVERE, () -> "Failed to parse a Cargo Node Frequency (" + node.getWorld().getName() + " - " + node.getBlockX() + ',' + node.getBlockY() + ',' + node.getBlockZ() + "): " + frequency);
|
||||
return 0;
|
||||
} else {
|
||||
|
@ -15,8 +15,8 @@ import javax.annotation.Nullable;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import io.github.bakedlibs.dough.common.CommonPatterns;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.PatternUtils;
|
||||
|
||||
import kong.unirest.GetRequest;
|
||||
import kong.unirest.HttpResponse;
|
||||
@ -168,7 +168,7 @@ public class MetricsService {
|
||||
* @return if there is an update available.
|
||||
*/
|
||||
public boolean checkForUpdate(@Nullable String currentVersion) {
|
||||
if (currentVersion == null || !PatternUtils.NUMERIC.matcher(currentVersion).matches()) {
|
||||
if (currentVersion == null || !CommonPatterns.NUMERIC.matcher(currentVersion).matches()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,7 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import io.github.bakedlibs.dough.chat.ChatInput;
|
||||
import io.github.bakedlibs.dough.common.ChatColors;
|
||||
import io.github.bakedlibs.dough.common.CommonPatterns;
|
||||
import io.github.bakedlibs.dough.items.CustomItemStack;
|
||||
import io.github.bakedlibs.dough.items.ItemUtils;
|
||||
import io.github.bakedlibs.dough.skins.PlayerHead;
|
||||
@ -49,7 +50,6 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.HeadTexture;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.PatternUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||
import io.papermc.lib.PaperLib;
|
||||
|
||||
@ -255,7 +255,7 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock,
|
||||
return false;
|
||||
});
|
||||
|
||||
String[] script = PatternUtils.DASH.split(sourceCode);
|
||||
String[] script = CommonPatterns.DASH.split(sourceCode);
|
||||
|
||||
for (int i = 1; i < script.length; i++) {
|
||||
int index = i;
|
||||
@ -499,7 +499,7 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock,
|
||||
String script = BlockStorage.getLocationInfo(b.getLocation()).getString("script");
|
||||
// Fixes #2937
|
||||
if (script != null) {
|
||||
if (PatternUtils.DASH.split(script).length <= MAX_SCRIPT_LENGTH) {
|
||||
if (CommonPatterns.DASH.split(script).length <= MAX_SCRIPT_LENGTH) {
|
||||
openScript(pl, b, getScript(b.getLocation()));
|
||||
} else {
|
||||
pl.closeInventory();
|
||||
@ -594,7 +594,7 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock,
|
||||
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(PatternUtils.DASH.split(script).length <= MAX_SCRIPT_LENGTH, "Scripts may not have more than " + MAX_SCRIPT_LENGTH + " segments");
|
||||
Validate.isTrue(CommonPatterns.DASH.split(script).length <= MAX_SCRIPT_LENGTH, "Scripts may not have more than " + MAX_SCRIPT_LENGTH + " segments");
|
||||
|
||||
BlockStorage.addBlockInfo(l, "script", script);
|
||||
}
|
||||
@ -694,7 +694,7 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock,
|
||||
consumeFuel(b, menu);
|
||||
} else {
|
||||
String code = data.getString("script");
|
||||
String[] script = PatternUtils.DASH.split(code == null ? DEFAULT_SCRIPT : code);
|
||||
String[] script = CommonPatterns.DASH.split(code == null ? DEFAULT_SCRIPT : code);
|
||||
|
||||
String indexData = data.getString("index");
|
||||
int index = (indexData == null ? 0 : Integer.parseInt(indexData)) + 1;
|
||||
|
@ -24,6 +24,7 @@ import org.bukkit.inventory.ShapelessRecipe;
|
||||
import org.bukkit.persistence.PersistentDataContainer;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
|
||||
import io.github.bakedlibs.dough.common.CommonPatterns;
|
||||
import io.github.bakedlibs.dough.items.CustomItemStack;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
@ -33,7 +34,6 @@ import io.github.thebusybiscuit.slimefun4.core.services.MinecraftRecipeService;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.tasks.AsyncRecipeChoiceTask;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.PatternUtils;
|
||||
import io.papermc.lib.PaperLib;
|
||||
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
||||
@ -67,7 +67,7 @@ public class VanillaAutoCrafter extends AbstractAutoCrafter {
|
||||
String value = container.get(recipeStorageKey, PersistentDataType.STRING);
|
||||
|
||||
if (value != null) {
|
||||
String[] values = PatternUtils.COLON.split(value);
|
||||
String[] values = CommonPatterns.COLON.split(value);
|
||||
|
||||
/*
|
||||
* Normally this constructor should not be used.
|
||||
|
@ -17,6 +17,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import io.github.bakedlibs.dough.common.ChatColors;
|
||||
import io.github.bakedlibs.dough.common.CommonPatterns;
|
||||
import io.github.bakedlibs.dough.items.ItemUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
@ -26,7 +27,6 @@ import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
||||
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.SlimefunBackpack;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.PatternUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||
|
||||
/**
|
||||
@ -119,7 +119,7 @@ abstract class AbstractCraftingTable extends MultiBlockMachine {
|
||||
for (String line : backpack.getItemMeta().getLore()) {
|
||||
if (line.startsWith(ChatColors.color("&7ID: ")) && line.contains("#")) {
|
||||
String id = line.replace(ChatColors.color("&7ID: "), "");
|
||||
String[] idSplit = PatternUtils.HASH.split(id);
|
||||
String[] idSplit = CommonPatterns.HASH.split(id);
|
||||
|
||||
PlayerProfile.fromUUID(UUID.fromString(idSplit[0]), profile -> {
|
||||
Optional<PlayerBackpack> optional = profile.getBackpack(Integer.parseInt(idSplit[1]));
|
||||
|
@ -11,6 +11,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import io.github.bakedlibs.dough.chat.ChatInput;
|
||||
import io.github.bakedlibs.dough.common.ChatColors;
|
||||
import io.github.bakedlibs.dough.common.CommonPatterns;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
|
||||
/**
|
||||
@ -67,7 +68,7 @@ public final class ChatUtils {
|
||||
*/
|
||||
public static @Nonnull String humanize(@Nonnull String string) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
String[] segments = PatternUtils.UNDERSCORE.split(string.toLowerCase(Locale.ROOT));
|
||||
String[] segments = CommonPatterns.UNDERSCORE.split(string.toLowerCase(Locale.ROOT));
|
||||
|
||||
builder.append(Character.toUpperCase(segments[0].charAt(0))).append(segments[0].substring(1));
|
||||
|
||||
|
@ -8,6 +8,7 @@ import javax.annotation.Nonnull;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.bakedlibs.dough.common.CommonPatterns;
|
||||
import io.github.bakedlibs.dough.skins.PlayerSkin;
|
||||
|
||||
/**
|
||||
@ -127,7 +128,7 @@ public enum HeadTexture {
|
||||
|
||||
HeadTexture(@Nonnull String texture) {
|
||||
Validate.notNull(texture, "Texture cannot be null");
|
||||
Validate.isTrue(PatternUtils.HEXADECIMAL.matcher(texture).matches(), "Textures must be in hexadecimal.");
|
||||
Validate.isTrue(CommonPatterns.HEXADECIMAL.matcher(texture).matches(), "Textures must be in hexadecimal.");
|
||||
|
||||
this.texture = texture;
|
||||
this.uuid = UUID.nameUUIDFromBytes(texture.getBytes(StandardCharsets.UTF_8));
|
||||
|
@ -14,6 +14,7 @@ import javax.annotation.Nullable;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import io.github.bakedlibs.dough.common.CommonPatterns;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
|
||||
/**
|
||||
@ -196,7 +197,7 @@ public final class NumberUtils {
|
||||
* @return The resulting {@link Integer}
|
||||
*/
|
||||
public static int getInt(@Nonnull String str, int defaultValue) {
|
||||
if (PatternUtils.NUMERIC.matcher(str).matches()) {
|
||||
if (CommonPatterns.NUMERIC.matcher(str).matches()) {
|
||||
return Integer.parseInt(str);
|
||||
} else {
|
||||
return defaultValue;
|
||||
@ -209,7 +210,7 @@ public final class NumberUtils {
|
||||
}
|
||||
|
||||
String number = roundDecimalNumber(nanoseconds / 1000000.0);
|
||||
String[] parts = PatternUtils.NUMBER_SEPARATOR.split(number);
|
||||
String[] parts = CommonPatterns.NUMBER_SEPARATOR.split(number);
|
||||
|
||||
if (parts.length == 1) {
|
||||
return parts[0] + "ms";
|
||||
@ -273,7 +274,7 @@ public final class NumberUtils {
|
||||
javaVer = javaVer.substring(0, javaVer.indexOf('.'));
|
||||
}
|
||||
|
||||
if (PatternUtils.NUMERIC.matcher(javaVer).matches()) {
|
||||
if (CommonPatterns.NUMERIC.matcher(javaVer).matches()) {
|
||||
return Integer.parseInt(javaVer);
|
||||
} else {
|
||||
Slimefun.logger().log(Level.SEVERE, "Error: Cannot identify Java version - {0}", javaVer);
|
||||
|
@ -2,7 +2,7 @@ package io.github.thebusybiscuit.slimefun4.utils;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
/**
|
||||
* This class is created for common-use patterns used in things such as {@link String#split(String)}. <br>
|
||||
@ -18,18 +18,7 @@ public final class PatternUtils {
|
||||
|
||||
private PatternUtils() {}
|
||||
|
||||
public static final Pattern COLON = Pattern.compile(":");
|
||||
public static final Pattern SEMICOLON = Pattern.compile(";");
|
||||
public static final Pattern HASH = Pattern.compile("#");
|
||||
public static final Pattern COMMA = Pattern.compile(",");
|
||||
public static final Pattern SLASH_SEPARATOR = Pattern.compile(" / ");
|
||||
public static final Pattern DASH = Pattern.compile("-");
|
||||
public static final Pattern UNDERSCORE = Pattern.compile("_");
|
||||
public static final Pattern ASCII = Pattern.compile("[A-Za-z \"_]+");
|
||||
public static final Pattern HEXADECIMAL = Pattern.compile("[A-Fa-f0-9]+");
|
||||
public static final Pattern NUMERIC = Pattern.compile("[0-9]+");
|
||||
|
||||
public static final Pattern NUMBER_SEPARATOR = Pattern.compile("[,.]");
|
||||
|
||||
public static final Pattern MINECRAFT_MATERIAL = Pattern.compile("minecraft:[a-z_]+");
|
||||
public static final Pattern MINECRAFT_TAG = Pattern.compile("#minecraft:[a-z_]+");
|
||||
|
@ -25,6 +25,7 @@ import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.persistence.PersistentDataContainer;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
|
||||
import io.github.bakedlibs.dough.common.CommonPatterns;
|
||||
import io.github.bakedlibs.dough.items.ItemMetaSnapshot;
|
||||
import io.github.bakedlibs.dough.skins.PlayerHead;
|
||||
import io.github.bakedlibs.dough.skins.PlayerSkin;
|
||||
@ -222,7 +223,7 @@ public final class SlimefunUtils {
|
||||
|
||||
String base64 = texture;
|
||||
|
||||
if (PatternUtils.HEXADECIMAL.matcher(texture).matches()) {
|
||||
if (CommonPatterns.HEXADECIMAL.matcher(texture).matches()) {
|
||||
base64 = Base64.getEncoder().encodeToString(("{\"textures\":{\"SKIN\":{\"url\":\"http://textures.minecraft.net/texture/" + texture + "\"}}}").getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@ import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
|
||||
import io.github.bakedlibs.dough.common.CommonPatterns;
|
||||
import io.github.thebusybiscuit.slimefun4.api.exceptions.TagMisconfigurationException;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.PatternUtils;
|
||||
@ -145,7 +146,7 @@ public class TagParser implements Keyed {
|
||||
}
|
||||
} else if (PatternUtils.MINECRAFT_TAG.matcher(value).matches()) {
|
||||
// Get the actual Key portion and match it to item and block tags.
|
||||
String keyValue = PatternUtils.COLON.split(value)[1];
|
||||
String keyValue = CommonPatterns.COLON.split(value)[1];
|
||||
NamespacedKey namespacedKey = NamespacedKey.minecraft(keyValue);
|
||||
Tag<Material> itemsTag = Bukkit.getTag(Tag.REGISTRY_ITEMS, namespacedKey, Material.class);
|
||||
Tag<Material> blocksTag = Bukkit.getTag(Tag.REGISTRY_BLOCKS, namespacedKey, Material.class);
|
||||
@ -162,7 +163,7 @@ public class TagParser implements Keyed {
|
||||
}
|
||||
} else if (PatternUtils.SLIMEFUN_TAG.matcher(value).matches()) {
|
||||
// Get a SlimefunTag enum value for the given key
|
||||
String keyValue = PatternUtils.COLON.split(value)[1].toUpperCase(Locale.ROOT);
|
||||
String keyValue = CommonPatterns.COLON.split(value)[1].toUpperCase(Locale.ROOT);
|
||||
SlimefunTag tag = SlimefunTag.getTag(keyValue);
|
||||
|
||||
if (tag != null) {
|
||||
|
@ -34,10 +34,10 @@ import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
|
||||
import io.github.bakedlibs.dough.common.CommonPatterns;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.PatternUtils;
|
||||
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
||||
@ -91,7 +91,7 @@ public class BlockStorage {
|
||||
|
||||
private static Location deserializeLocation(String l) {
|
||||
try {
|
||||
String[] components = PatternUtils.SEMICOLON.split(l);
|
||||
String[] components = CommonPatterns.SEMICOLON.split(l);
|
||||
if (components.length != 4) {
|
||||
return null;
|
||||
}
|
||||
@ -229,7 +229,7 @@ public class BlockStorage {
|
||||
|
||||
for (String key : cfg.getKeys(false)) {
|
||||
try {
|
||||
if (world.getName().equals(PatternUtils.SEMICOLON.split(key)[0])) {
|
||||
if (world.getName().equals(CommonPatterns.SEMICOLON.split(key)[0])) {
|
||||
BlockInfoConfig data = new BlockInfoConfig(parseJSON(cfg.getString(key)));
|
||||
Slimefun.getRegistry().getChunks().put(key, data);
|
||||
}
|
||||
|
@ -13,12 +13,12 @@ import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
|
||||
import io.github.bakedlibs.dough.common.CommonPatterns;
|
||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerBackpack;
|
||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||
import io.github.thebusybiscuit.slimefun4.test.TestUtilities;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.PatternUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||
|
||||
import be.seeseemelk.mockbukkit.MockBukkit;
|
||||
@ -76,7 +76,7 @@ class TestBackpackCommand {
|
||||
|
||||
server.execute("slimefun", player, "backpack", player.getName(), id).assertSucceeded();
|
||||
|
||||
if (PatternUtils.NUMERIC.matcher(id).matches()) {
|
||||
if (CommonPatterns.NUMERIC.matcher(id).matches()) {
|
||||
Assertions.assertFalse(hasBackpack(player, Integer.parseInt(id)));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user