aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
diff options
context:
space:
mode:
authorDoKM <mcazzyman@gmail.com>2021-08-23 14:13:19 +0200
committerDoKM <mcazzyman@gmail.com>2021-08-23 14:13:19 +0200
commitf85740988b8fe5ae8255a97eca2333e63937f96c (patch)
tree7c43417b87086453c98c17ed457353d5fd7a9f8c /src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
parent97b19369c6cc26705c71e0c7697a1133f5246681 (diff)
downloadnotenoughupdates-f85740988b8fe5ae8255a97eca2333e63937f96c.tar.gz
notenoughupdates-f85740988b8fe5ae8255a97eca2333e63937f96c.tar.bz2
notenoughupdates-f85740988b8fe5ae8255a97eca2333e63937f96c.zip
First working version
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java81
1 files changed, 67 insertions, 14 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
index 5ca9b316..8f373460 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
@@ -472,23 +472,74 @@ public class Utils {
private static String[] rarityArr = new String[] {
"COMMON", "UNCOMMON", "RARE", "EPIC", "LEGENDARY", "MYTHIC", "SPECIAL", "VERY SPECIAL",
};
+
+ public static String getRarityFromInt(int rarity){
+ if(rarity < 0|| rarity >= rarityArr.length){ return rarityArr[0]; }
+ return rarityArr[rarity];
+ }
+
+ public static int checkItemTypePet(List<String> lore){
+ for(int i=lore.size()-1; i>=0; i--){
+ String line = Utils.cleanColour(lore.get(i));
+ for (int i1 = 0; i1 < rarityArr.length; i1++) {
+ if(line.equals(rarityArr[i1])){
+ return i1;
+ }
+ }
+ }
+ return -1;
+ }
+
public static int checkItemType(JsonArray lore, boolean contains, String... typeMatches) {
for(int i=lore.size()-1; i>=0; i--) {
String line = lore.get(i).getAsString();
- for(String rarity : rarityArr) {
- for(int j=0; j<typeMatches.length; j++) {
- if(contains) {
- if(line.trim().contains(rarity + " " + typeMatches[j])) {
- return j;
- } else if(line.trim().contains(rarity + " DUNGEON " + typeMatches[j])) {
- return j;
- }
- } else {
- if(line.trim().endsWith(rarity + " " + typeMatches[j])) {
- return j;
- } else if(line.trim().endsWith(rarity + " DUNGEON " + typeMatches[j])) {
- return j;
- }
+
+ int returnType = checkItemType(line, contains, typeMatches);
+ if(returnType != -1){
+ return returnType;
+ }
+ }
+ return -1;
+ }
+
+ public static int checkItemType(String[] lore, boolean contains, String... typeMatches) {
+ for(int i=lore.length-1; i>=0; i--) {
+ String line = lore[i];
+
+ int returnType = checkItemType(line, contains, typeMatches);
+ if(returnType != -1){
+ return returnType;
+ }
+ }
+ return -1;
+ }
+
+ public static int checkItemType(List<String> lore, boolean contains, String... typeMatches) {
+ for(int i=lore.size()-1; i>=0; i--) {
+ String line = lore.get(i);
+
+ int returnType = checkItemType(line, contains, typeMatches);
+ if(returnType != -1){
+ return returnType;
+ }
+ }
+ return -1;
+ }
+
+ private static int checkItemType(String line, boolean contains, String... typeMatches) {
+ for (String rarity : rarityArr) {
+ for (int j = 0; j < typeMatches.length; j++) {
+ if (contains) {
+ if (line.trim().contains(rarity + " " + typeMatches[j])) {
+ return j;
+ } else if (line.trim().contains(rarity + " DUNGEON " + typeMatches[j])) {
+ return j;
+ }
+ } else {
+ if (line.trim().endsWith(rarity + " " + typeMatches[j])) {
+ return j;
+ } else if (line.trim().endsWith(rarity + " DUNGEON " + typeMatches[j])) {
+ return j;
}
}
}
@@ -496,6 +547,8 @@ public class Utils {
return -1;
}
+
+
public static void playPressSound() {
playSound(new ResourceLocation("gui.button.press"), true);
}