public class UniversalUtils extends Object
Modifier and Type | Class and Description |
---|---|
static class |
UniversalUtils.OS |
Modifier and Type | Field and Description |
---|---|
static String |
BUNDLED_ASSETS_BASE |
static boolean |
checkAgainForMcleaks |
static boolean |
HAVE_INTERNET |
static char[] |
HEX_DIGITS |
static UniversalUtils.OS |
os |
Constructor and Description |
---|
UniversalUtils() |
Modifier and Type | Method and Description |
---|---|
static boolean |
containsChineseCharacters(String s)
Check if the given string contains a chinese characters
|
static @Nullable Path |
copyBundledFile(String name,
Path destFile)
Copies a bundled file to the file denoted by the given Path
|
static void |
doTrustToCertificates() |
static int |
floor(double d) |
static boolean |
getBoolean(String s) |
static Optional<Cheat> |
getCheatFromItem(Material m) |
static Optional<String> |
getContentFromURL(String url) |
static Optional<String> |
getContentFromURL(String urlName,
String post)
Get content from URL.
|
static Optional<String> |
getContentFromURLWithException(String urlName,
String post)
Get content from URL.
|
static Optional<Integer> |
getFirstInt(String... args) |
static Optional<SemVer> |
getLatestVersion() |
static @Nullable SemVer |
getLatestVersionIfNewer() |
static Optional<String> |
getLatestVersionString() |
static List<String> |
getListFromURL(String urlName)
Get content from URL.
|
static List<String> |
getListFromURLWithException(String urlName,
String post)
Get content from URL.
|
static int |
getMultipleOf(int i,
int multiple,
int more) |
static int |
getMultipleOf(int i,
int multiple,
int more,
int limit) |
static UniversalUtils.OS |
getOs() |
static int |
getPorcentFromBoolean(boolean b) |
static int |
getPorcentFromBoolean(boolean b,
int max) |
static int |
getPorcentFromBoolean(boolean b,
int max,
int min) |
static Optional<Special> |
getSpecialFromItem(Object m) |
static String |
hexToString(byte[] data) |
static boolean |
isDouble(String s) |
static boolean |
isInteger(String s) |
static boolean |
isLong(String s) |
static boolean |
isMe(String uuid) |
static boolean |
isMe(UUID uuid) |
static boolean |
isUUID(String s) |
static boolean |
isValidName(String name) |
static Configuration |
loadConfig(File configFile,
String configName) |
static @Nullable InputStream |
openBundledFile(String name)
Opens a bundled file as an InputStream
|
static int |
parseInPorcent(double i) |
static int |
parseInPorcent(int i) |
static String |
replacePlaceholders(String rawMessage,
Object... placeholders) |
static CompletableFuture<String> |
requestMcleaksData(String uuid) |
static byte[] |
stringToHex(String string) |
static int |
sum(HashMap<Integer,Integer> relia) |
static @Nullable String |
truncate(@Nullable String string,
int maxLength) |
public static final String BUNDLED_ASSETS_BASE
public static final char[] HEX_DIGITS
public static boolean HAVE_INTERNET
public static boolean checkAgainForMcleaks
public static UniversalUtils.OS os
public static int getMultipleOf(int i, int multiple, int more)
public static int getMultipleOf(int i, int multiple, int more, int limit)
public static int floor(double d)
public static int getPorcentFromBoolean(boolean b)
public static int getPorcentFromBoolean(boolean b, int max)
public static int getPorcentFromBoolean(boolean b, int max, int min)
public static int parseInPorcent(int i)
public static int parseInPorcent(double i)
public static boolean isMe(String uuid)
public static boolean isMe(UUID uuid)
public static boolean isInteger(String s)
public static boolean isDouble(String s)
public static boolean isLong(String s)
public static boolean isUUID(String s)
public static boolean getBoolean(String s)
public static Optional<String> getContentFromURL(String urlName, String post)
urlName
- the URLpost
- post value, or empty if use getpublic static Optional<String> getContentFromURLWithException(String urlName, String post) throws Exception
urlName
- the URLpost
- post value, or empty if use getException
- if something gone wrongpublic static List<String> getListFromURL(String urlName)
urlName
- the URLpublic static List<String> getListFromURLWithException(String urlName, String post) throws Exception
urlName
- the URLpost
- post value, or empty if use getException
- if something gone wrongpublic static @Nullable SemVer getLatestVersionIfNewer()
public static CompletableFuture<String> requestMcleaksData(String uuid)
public static void doTrustToCertificates() throws KeyManagementException, NoSuchAlgorithmException
public static String replacePlaceholders(String rawMessage, Object... placeholders)
public static boolean isValidName(String name)
public static boolean containsChineseCharacters(String s)
s
- The string where we are looking for chinese charpublic static @Nullable InputStream openBundledFile(String name)
name
- the name of the bundled filepublic static @Nullable Path copyBundledFile(String name, Path destFile) throws IOException
name
- the name of the bundled filedestFile
- the file Path it will be copied toIOException
- if an IO exception occurredpublic static Configuration loadConfig(File configFile, String configName)
public static String hexToString(byte[] data)
public static byte[] stringToHex(String string)
public static UniversalUtils.OS getOs()