1package com.runehive.util;
3import com.runehive.fs.cache.FileSystem;
5import java.text.NumberFormat;
6import java.util.stream.IntStream;
13 'a',
'b',
'c',
'd',
'e',
'f',
'g',
'h',
'i',
'j',
'k',
'l',
'm',
14 'n',
'o',
'p',
'q',
'r',
's',
't',
'u',
'v',
'w',
'x',
'y',
'z',
15 '0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9'
19 if (amount >= 1_000 && amount < 1_000_000) {
20 return (amount / 1_000) +
"K";
21 }
else if (amount >= 1_000_000 && amount < 1_000_000_000) {
22 return (amount / 1_000_000) +
"M";
23 }
else if (amount >= 1_000_000_000) {
24 return (amount / 1_000_000_000) +
"B";
31 input = input.toLowerCase().replace(
" ",
"");
33 int pos = input.indexOf(
'k');
36 return Integer.parseInt(input.substring(0, pos)) * 1_000;
39 pos = input.indexOf(
'm');
42 return Integer.parseInt(input.substring(0, pos)) * 1_000_000;
45 pos = input.indexOf(
'b');
48 return Integer.parseInt(input.substring(0, pos)) * 1_000_000_000;
51 }
catch (Exception ex) {
64 char first = thing.toLowerCase().charAt(0);
65 boolean vowel = first ==
'a' || first ==
'e' || first ==
'i' || first ==
'o' || first ==
'u';
66 return vowel ?
"an" :
"a";
76 boolean needsPlural = !thing.endsWith(
"s") && !thing.endsWith(
")");
77 return needsPlural ?
"s" :
"";
101 return Character.toUpperCase(
string.charAt(0)) +
string.substring(1);
105 return NumberFormat.getInstance().format(num);
109 for (
int i = 0; i < s.length(); i++) {
111 s = String.format(
"%s%s", Character.toUpperCase(s.charAt(0)), s.substring(1));
113 if (!Character.isLetterOrDigit(s.charAt(i))) {
114 if (i + 1 < s.length()) {
115 s = String.format(
"%s%s%s", s.subSequence(0, i + 1), Character.toUpperCase(s.charAt(i + 1)), s.substring(i + 2));
119 return s.replace(
"_",
" ");
124 final char c = nextWord.toUpperCase().charAt(0);
125 if (c ==
'A' || c ==
'E' || c ==
'I' || c ==
'O' || c ==
'U') {
133 char decoded[] =
new char[length];
138 int index = (int) (
hash - input * 37);
142 return new String(decoded, length, decoded.length - length);
151 public static long hash(String input) {
154 for (
int index = 0; index < input.length(); index++) {
155 char key = input.charAt(index);
159 if (key >=
'A' && key <=
'Z') {
160 hash += (1 + key) - 65;
161 }
else if (key >=
'a' && key <=
'z') {
162 hash += (1 + key) - 97;
163 }
else if (key >=
'0' && key <=
'9') {
164 hash += (27 + key) - 48;
180 return _hash(
string.toUpperCase());
202 private static int _hash(String
string) {
203 return IntStream.range(0,
string.length()).reduce(0, (
hash, index) ->
hash * 61 +
string.charAt(index) - 32);
static String getAOrAn(String nextWord)
static String formatPrice(long amount)
static String formatText(String s)
static String capitalize(String string)
static int convertAmount(String input)
static String appendPluralCheck(String thing)
Appends the determined plural check to thing.
static String appendIndefiniteArticle(String thing)
Appends the determined indefinite article to thing.
static int hashArchive(String string)
Hashes a String using Jagex's algorithm, this method should be used to convert actual names to hashed...
static final char VALID_USERNAME_CHARACTERS[]
An array containing valid username characters.
static long hash(String input)
Hashes a given string input.
static String determinePluralCheck(String thing)
Determines the plural check of thing.
static String format(int num)
static int _hash(String string)
Hashes a String using Jagex's algorithm, this method should be used to convert actual names to hashed...
static String determineIndefiniteArticle(String thing)
Determines the indefinite article of thing.
static String hashToString(long input)