aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/FeatureGoodParties.java29
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/customgui/PanelPartyFinderSettings.java38
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/customgui/PanelPartyListElement.java48
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/PartyFinderParty.java77
4 files changed, 107 insertions, 85 deletions
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/FeatureGoodParties.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/FeatureGoodParties.java
index c0f911f5..a4628303 100644
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/FeatureGoodParties.java
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/FeatureGoodParties.java
@@ -23,6 +23,7 @@ package kr.syeyoung.dungeonsguide.mod.features.impl.party;
import kr.syeyoung.dungeonsguide.mod.events.annotations.DGEventHandler;
import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature;
import kr.syeyoung.dungeonsguide.mod.features.impl.etc.FeatureCollectDiagnostics;
+import kr.syeyoung.dungeonsguide.mod.utils.PartyFinderParty;
import kr.syeyoung.dungeonsguide.mod.utils.TextUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
@@ -74,22 +75,12 @@ public class FeatureGoodParties extends SimpleFeature {
if (nbt == null || nbt.hasNoTags()) continue;
NBTTagCompound display = nbt.getCompoundTag("display");
if (display.hasNoTags()) return;
- NBTTagList lore = display.getTagList("Lore", 8);
- int classLvReq = 0;
- int cataLvReq = 0;
- boolean Req = false;
- String note = "";
- for (int n = 0; n < lore.tagCount(); n++) {
- String str = lore.getStringTagAt(n);
- if (str.startsWith("§7Dungeon Level Required: §b")) cataLvReq = Integer.parseInt(str.substring(28));
- if (str.startsWith("§7Class Level Required: §b")) classLvReq = Integer.parseInt(str.substring(26));
- if (str.startsWith("§7§7Note:")) note = TextUtils.stripColor(str.substring(10));
- if (str.startsWith("§cRequires")) Req = true;
- }
+
+ PartyFinderParty party = PartyFinderParty.fromItemStack(s.getStack());
int x = s.xDisplayPosition;
int y = s.yDisplayPosition;
- if (Req) {
+ if (!party.canJoin) {
Gui.drawRect(x, y, x + 16, y + 16, 0x77AA0000);
} else {
@@ -97,18 +88,18 @@ public class FeatureGoodParties extends SimpleFeature {
GlStateManager.enableBlend();
GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
- if (note.toLowerCase().contains("car")) {
+ if (party.note.toLowerCase().contains("car")) {
fr.drawStringWithShadow("C", x + 1, y + 1, 0xFFFF0000);
- } else if (note.toLowerCase().replace(" ", "").contains("s/s+")) {
+ } else if (party.note.toLowerCase().replace(" ", "").contains("s/s+")) {
fr.drawStringWithShadow("S+", x + 1, y + 1, 0xFFFFFF00);
- } else if (note.toLowerCase().contains("s+")) {
+ } else if (party.note.toLowerCase().contains("s+")) {
fr.drawStringWithShadow("S+", x + 1, y + 1, 0xFF00FF00);
- } else if (note.toLowerCase().contains(" s") || note.toLowerCase().contains(" s ")) {
+ } else if (party.note.toLowerCase().contains(" s") || party.note.toLowerCase().contains(" s ")) {
fr.drawStringWithShadow("S", x + 1, y + 1, 0xFFFFFF00);
- } else if (note.toLowerCase().contains("rush")) {
+ } else if (party.note.toLowerCase().contains("rush")) {
fr.drawStringWithShadow("R", x + 1, y + 1, 0xFFFF0000);
}
- fr.drawStringWithShadow("§e"+Integer.max(classLvReq, cataLvReq), x + 1, y + fr.FONT_HEIGHT, 0xFFFFFFFF);
+ fr.drawStringWithShadow("§e"+Integer.max(party.requiredClassLevel, party.requiredDungeonLevel), x + 1, y + fr.FONT_HEIGHT, 0xFFFFFFFF);
}
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/customgui/PanelPartyFinderSettings.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/customgui/PanelPartyFinderSettings.java
index 97538a60..c4026311 100644
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/customgui/PanelPartyFinderSettings.java
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/customgui/PanelPartyFinderSettings.java
@@ -23,6 +23,7 @@ import kr.syeyoung.dungeonsguide.mod.chat.ChatProcessor;
import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry;
import kr.syeyoung.dungeonsguide.mod.gui.elements.*;
import kr.syeyoung.dungeonsguide.mod.party.PartyManager;
+import kr.syeyoung.dungeonsguide.mod.utils.PartyFinderParty;
import kr.syeyoung.dungeonsguide.mod.utils.TextUtils;
import lombok.Getter;
import net.minecraft.client.Minecraft;
@@ -244,46 +245,27 @@ public class PanelPartyFinderSettings extends MPanelScaledGUI {
}
public boolean filter(ItemStack itemStack) {
- NBTTagCompound stackTagCompound = itemStack.getTagCompound();
- String note = "";
- int dLV = 0;
+ PartyFinderParty party = PartyFinderParty.fromItemStack(itemStack);
+
Set<String> invalidClasses = new HashSet<>();
for (String s : blacklistClassTxt.getText().split(",")) {
- invalidClasses.add(s.toLowerCase());
+ invalidClasses.add(s.toLowerCase().trim());
}
- if (stackTagCompound.hasKey("display", 10)) {
- NBTTagCompound nbttagcompound = stackTagCompound.getCompoundTag("display");
-
- if (nbttagcompound.getTagId("Lore") == 9) {
- NBTTagList nbttaglist1 = nbttagcompound.getTagList("Lore", 8);
-
- for (int i = 0; i < nbttaglist1.tagCount(); i++) {
- String str = nbttaglist1.getStringTagAt(i);
- if (str.startsWith("§cRequires ") && filterCantjoinButton.isEnabled()) return false;
- if (str.startsWith("§7§7Note:")) {
- note = str.substring(12);
- }
- if (str.startsWith("§7Dungeon Level Required: §b")) {
- dLV = Integer.parseInt(str.substring(28));
- }
- if (str.startsWith(" ") && str.contains(":")) {
- String clazz = TextUtils.stripColor(str).trim().split(" ")[1];
- if (invalidClasses.contains(clazz.toLowerCase())) return false;
- }
- }
- }
+ for(String badClass : invalidClasses) {
+ if(party.classes.contains(badClass))return false;
}
- if (integerSelection.getData() >dLV) return false;
+ if (!party.canJoin && filterCantjoinButton.isEnabled()) return false;
+ if (integerSelection.getData() > party.requiredDungeonLevel) return false;
if (!filterBlacklist.getText().isEmpty()) {
for (String s1 : filterBlacklist.getText().split(",")) {
- if (note.toLowerCase().contains(s1.toLowerCase())) return false;
+ if (party.note.toLowerCase().contains(s1.toLowerCase())) return false;
}
}
if (!filterWhitelist.getText().isEmpty()) {
boolean s = false;
for (String s1 : filterWhitelist.getText().split(",")) {
- if (note.toLowerCase().contains(s1.toLowerCase())) {
+ if (party.note.toLowerCase().contains(s1.toLowerCase())) {
s = true; break;
}
}
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/customgui/PanelPartyListElement.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/customgui/PanelPartyListElement.java
index 51c9fdaf..6929e13d 100644
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/customgui/PanelPartyListElement.java
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/customgui/PanelPartyListElement.java
@@ -22,6 +22,7 @@ import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry;
import kr.syeyoung.dungeonsguide.mod.gui.MPanel;
import kr.syeyoung.dungeonsguide.mod.gui.elements.MTooltip;
import kr.syeyoung.dungeonsguide.mod.gui.elements.MTooltipText;
+import kr.syeyoung.dungeonsguide.mod.utils.PartyFinderParty;
import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils;
import kr.syeyoung.dungeonsguide.mod.utils.TextUtils;
import kr.syeyoung.dungeonsguide.mod.utils.cursor.EnumCursor;
@@ -76,44 +77,15 @@ public class PanelPartyListElement extends MPanel {
itemStack = lastStack;
int color = RenderUtils.blendAlpha(0x141414, 0.0f);
- String note = "";
+ PartyFinderParty party = PartyFinderParty.fromItemStack(itemStack);
+ String note = party.note;
boolean notFound = false;
- boolean cantJoin = false;
+ boolean cantJoin = !party.canJoin;
if (itemStack.getItem() == Item.getItemFromBlock(Blocks.bedrock)) {
cantJoin = true;
notFound = true;
}
- int minClass = -1, minDungeon = -1;
- int pplIn = 0;
- Set<String> dungeonClasses = new HashSet<>();
- {
- NBTTagCompound stackTagCompound = itemStack.getTagCompound();
- if (stackTagCompound.hasKey("display", 10)) {
- NBTTagCompound nbtTagCompound = stackTagCompound.getCompoundTag("display");
-
- if (nbtTagCompound.getTagId("Lore") == 9) {
- NBTTagList nbtTagList1 = nbtTagCompound.getTagList("Lore", 8);
-
- for (int i = 0; i < nbtTagList1.tagCount(); i++) {
- String str = nbtTagList1.getStringTagAt(i);
- if (str.startsWith("§7§7Note:")) {
- note = str.substring(12);
- } else if (str.startsWith("§7Class Level Required: §b")) {
- minClass = Integer.parseInt(str.substring(26));
- } else if (str.startsWith("§7Dungeon Level Required: §b")) {
- minDungeon = Integer.parseInt(str.substring(28));
- } else if (str.startsWith("§cRequires ")) cantJoin = true;
- if (str.endsWith("§b)")) pplIn ++;
-
- if (str.startsWith(" ") && str.contains(":")) {
- String clazz = TextUtils.stripColor(str).trim().split(" ")[1];
- dungeonClasses.add(clazz);
- }
- }
- }
- }
- }
-
+ int minClass = party.requiredClassLevel, minDungeon = party.requiredDungeonLevel;
boolean nodupe = note.toLowerCase().contains("nodupe") || note.toLowerCase().contains("no dupe") || (note.toLowerCase().contains("nd") && (note.toLowerCase().indexOf("nd") == 0 || note.charAt(note.toLowerCase().indexOf("nd")-1) == ' '));
note = note.replaceAll("(?i)(S\\+)", "§6$1§r");
@@ -140,7 +112,7 @@ public class PanelPartyListElement extends MPanel {
color = RenderUtils.blendTwoColors(color, 0x44FFAA00);
}
- if (nodupe && dungeonClasses.contains(FeatureRegistry.PARTYKICKER_CUSTOM.getLastClass())) {
+ if (nodupe && party.classes.contains(FeatureRegistry.PARTYKICKER_CUSTOM.getLastClass())) {
color = RenderUtils.blendTwoColors(color, 0x44FF0000);
note = note.replace("nodupe", "§cnodupe§r").replace("no dupe", "§cno dupe§r").replace("nd", "§cnd§r");
}
@@ -165,13 +137,13 @@ public class PanelPartyListElement extends MPanel {
fr.drawString(name, 0,0,-1);
if (!notFound)
- note = "§7("+pplIn+") §f"+note;
+ note = "§7("+party.classes.size()+") §f"+note;
fr.drawString(note, fr.getStringWidth("AAAAAAAAAAAAAAAA")+5, 0,-1);
GlStateManager.popMatrix();
GlStateManager.pushMatrix();
String sideNote = "";
- if (minClass != -1) sideNote += "§7CLv ≥§b"+minClass+" ";
- if (minDungeon != -1) sideNote += "§7DLv ≥§b"+minDungeon+" ";
+ if (minClass > 0) sideNote += "§7CLv ≥§b"+minClass+" ";
+ if (minDungeon > 0) sideNote += "§7DLv ≥§b"+minDungeon+" ";
if (cantJoin && !notFound) sideNote = "§cCan't join";
sideNote = sideNote.trim();
@@ -197,7 +169,7 @@ public class PanelPartyListElement extends MPanel {
mTooltip.open(this);
} else if (!lastAbsClip.contains(absMousex, absMousey)){
if (mTooltip != null)
- mTooltip.close();
+ mTooltip.close();
mTooltip = null;
}
}
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/PartyFinderParty.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/PartyFinderParty.java
new file mode 100644
index 00000000..053fe0c8
--- /dev/null
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/PartyFinderParty.java
@@ -0,0 +1,77 @@
+/*
+ * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod
+ * Copyright (C) 2023 Linnea Gräf
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package kr.syeyoung.dungeonsguide.mod.utils;
+
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class PartyFinderParty {
+ public String note = "";
+ public boolean canJoin = true;
+ public int requiredDungeonLevel = 0;
+ public int requiredClassLevel = 0;
+ public List<String> classes = new ArrayList<>();
+
+ public static PartyFinderParty fromItemStack(ItemStack itemStack) {
+ return fromItemNbt(itemStack.getTagCompound());
+ }
+
+ public static PartyFinderParty fromItemNbt(NBTTagCompound stackTagCompound) {
+ if (stackTagCompound != null && stackTagCompound.hasKey("display", 10)) {
+ NBTTagCompound nbttagcompound = stackTagCompound.getCompoundTag("display");
+
+ if (nbttagcompound.getTagId("Lore") == 9) {
+ NBTTagList nbttaglist1 = nbttagcompound.getTagList("Lore", 8);
+ return fromLore(nbttaglist1);
+ }
+ }
+ return new PartyFinderParty();
+ }
+
+ public static PartyFinderParty fromLore(NBTTagList tagList) {
+ PartyFinderParty party = new PartyFinderParty();
+ for (int i = 0; i < tagList.tagCount(); i++) {
+ String line = tagList.getStringTagAt(i);
+ if (line.startsWith("§7§7Note:")) {
+ party.note = line.substring(12).trim();
+ if (i + 1 < tagList.tagCount()) {
+ String nextLine = tagList.getStringTagAt(i + 1);
+ if (!nextLine.contains("§7") && !nextLine.replaceAll("§.| ", "").isEmpty()) {
+ i++;
+ party.note += " " + nextLine;
+ }
+ }
+ } else if (line.startsWith("§cRequires ")) {
+ party.canJoin = false;
+ } else if (line.startsWith("§7Dungeon Level Required: §b")) {
+ party.requiredDungeonLevel = Integer.parseInt(line.substring(28));
+ } else if (line.startsWith("§7Class Level Required: §b")) {
+ party.requiredClassLevel = Integer.parseInt(line.substring(26));
+ } else if (line.startsWith(" ") && line.contains(":")) {
+ String dungeonClass = TextUtils.stripColor(line).trim().split(" ")[1];
+ party.classes.add(dungeonClass);
+ }
+ }
+ return party;
+ }
+}