aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr/syeyoung/dungeonsguide/features/impl
diff options
context:
space:
mode:
authorsyeyoung <cyong06@naver.com>2021-03-27 02:47:30 +0900
committersyeyoung <cyong06@naver.com>2021-03-27 02:47:30 +0900
commitcef6bf93b82dd2ba53c646b0852d7caee8f8634c (patch)
treea639e2770cca210b9fcf320bd56191a153ebd48f /src/main/java/kr/syeyoung/dungeonsguide/features/impl
parent5608fb71917c12f065c1dd5ce319d08ec6850382 (diff)
downloadSkyblock-Dungeons-Guide-cef6bf93b82dd2ba53c646b0852d7caee8f8634c.tar.gz
Skyblock-Dungeons-Guide-cef6bf93b82dd2ba53c646b0852d7caee8f8634c.tar.bz2
Skyblock-Dungeons-Guide-cef6bf93b82dd2ba53c646b0852d7caee8f8634c.zip
bye bye insta close
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/features/impl')
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureChestPrice.java58
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureInstaCloseChest.java123
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/ability/FeatureAbilityCooldown.java1
3 files changed, 56 insertions, 126 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureChestPrice.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureChestPrice.java
index 15e210c4..fdb7130b 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureChestPrice.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureChestPrice.java
@@ -2,8 +2,8 @@ package kr.syeyoung.dungeonsguide.features.impl.boss;
import kr.syeyoung.dungeonsguide.e;
import kr.syeyoung.dungeonsguide.features.SimpleFeature;
-import kr.syeyoung.dungeonsguide.features.impl.dungeon.FeatureInstaCloseChest;
import kr.syeyoung.dungeonsguide.features.listener.GuiBackgroundRenderListener;
+import kr.syeyoung.dungeonsguide.utils.AhUtils;
import kr.syeyoung.dungeonsguide.utils.RenderUtils;
import kr.syeyoung.dungeonsguide.utils.TextUtils;
import net.minecraft.client.Minecraft;
@@ -18,6 +18,10 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.client.event.GuiScreenEvent;
+import java.util.Comparator;
+import java.util.Set;
+import java.util.TreeSet;
+
public class FeatureChestPrice extends SimpleFeature implements GuiBackgroundRenderListener {
public FeatureChestPrice() {
super("Bossfight", "Show Profit of Dungeon Chests","Show Profit of Dungeon Chests", "bossfight.profitchest", true);
@@ -64,7 +68,7 @@ public class FeatureChestPrice extends SimpleFeature implements GuiBackgroundRen
}
}
}
- itemPrice += FeatureInstaCloseChest.getPrice(item) * item.stackSize;
+ itemPrice += getPrice(item) * item.stackSize;
}
}
@@ -94,4 +98,54 @@ public class FeatureChestPrice extends SimpleFeature implements GuiBackgroundRen
GlStateManager.enableLighting();
GlStateManager.enableBlend();
}
+
+ public static long getPrice(ItemStack itemStack) {
+ if (itemStack == null) return 0;
+ NBTTagCompound compound = itemStack.getTagCompound();
+ if (compound == null)
+ return 0;
+ if (!compound.hasKey("ExtraAttributes"))
+ return 0;
+ final String id = compound.getCompoundTag("ExtraAttributes").getString("id");
+ if (id.equals("ENCHANTED_BOOK")) {
+ final NBTTagCompound enchants = compound.getCompoundTag("ExtraAttributes").getCompoundTag("enchantments");
+ Set<String> keys = enchants.getKeySet();
+ Set<String> actualKeys = new TreeSet<String>(new Comparator<String>() {
+ public int compare(String o1, String o2) {
+ String id2 = id + "::" + o1 + "-" + enchants.getInteger(o1);
+ AhUtils.AuctionData auctionData = AhUtils.auctions.get(id2);
+ long price1 = (auctionData == null) ? 0 : auctionData.lowestBin;
+ String id3 = id + "::" + o2 + "-" + enchants.getInteger(o2);
+ AhUtils.AuctionData auctionData2 = AhUtils.auctions.get(id3);
+ long price2 = (auctionData2 == null) ? 0 : auctionData2.lowestBin;
+ return (compare2(price1, price2) == 0) ? o1.compareTo(o2) : compare2(price1, price2);
+ }
+
+ public int compare2(long y, long x) {
+ return (x < y) ? -1 : ((x == y) ? 0 : 1);
+ }
+ });
+ actualKeys.addAll(keys);
+ int totalLowestPrice = 0;
+ for (String key : actualKeys) {
+ String id2 = id + "::" + key + "-" + enchants.getInteger(key);
+ AhUtils.AuctionData auctionData = AhUtils.auctions.get(id2);
+ totalLowestPrice += auctionData.lowestBin;
+ }
+ return totalLowestPrice;
+ } else {
+ AhUtils.AuctionData auctionData = AhUtils.auctions.get(id);
+ if (auctionData == null) {
+ return 0;
+ } else {
+ if (auctionData.sellPrice == -1 && auctionData.lowestBin != -1) return auctionData.lowestBin;
+ else if (auctionData.sellPrice != -1 && auctionData.lowestBin == -1) return auctionData.sellPrice;
+ else {
+ long ahPrice = auctionData.lowestBin;
+ if (ahPrice > auctionData.sellPrice) return ahPrice;
+ else return auctionData.sellPrice;
+ }
+ }
+ }
+ }
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureInstaCloseChest.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureInstaCloseChest.java
deleted file mode 100644
index d6a6d7c4..00000000
--- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureInstaCloseChest.java
+++ /dev/null
@@ -1,123 +0,0 @@
-package kr.syeyoung.dungeonsguide.features.impl.dungeon;
-
-import kr.syeyoung.dungeonsguide.SkyblockStatus;
-import kr.syeyoung.dungeonsguide.e;
-import kr.syeyoung.dungeonsguide.features.FeatureParameter;
-import kr.syeyoung.dungeonsguide.features.GuiFeature;
-import kr.syeyoung.dungeonsguide.features.SimpleFeature;
-import kr.syeyoung.dungeonsguide.features.listener.GuiOpenListener;
-import kr.syeyoung.dungeonsguide.features.listener.TickListener;
-import kr.syeyoung.dungeonsguide.utils.AhUtils;
-import kr.syeyoung.dungeonsguide.utils.TextUtils;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.FontRenderer;
-import net.minecraft.client.gui.GuiScreen;
-import net.minecraft.client.gui.inventory.GuiChest;
-import net.minecraft.inventory.ContainerChest;
-import net.minecraft.inventory.IInventory;
-import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraftforge.client.event.GuiOpenEvent;
-import org.lwjgl.opengl.GL11;
-
-import java.awt.*;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Set;
-import java.util.TreeSet;
-
-public class FeatureInstaCloseChest extends SimpleFeature implements GuiOpenListener, TickListener {
- public FeatureInstaCloseChest() {
- super("Dungeon", "Auto-Close Secret Chest", "Automatically closes Secret Chest as soon as you open it\nCan put item price threshold by clicking edit", "qol.autoclose", false);
- parameters.put("threshold", new FeatureParameter<Integer>("threshold", "Price Threshold", "The maximum price of item for chest to be closed. Default 1m", 1000000, "integer"));
- }
-
- SkyblockStatus skyblockStatus = e.getDungeonsGuide().getSkyblockStatus();
- private boolean check;
- @Override
- public void onGuiOpen(GuiOpenEvent event) {
- if (!this.isEnabled()) return;
- if (!skyblockStatus.isOnDungeon()) return;
- if (!(event.gui instanceof GuiChest)) return;
-
- ContainerChest ch = (ContainerChest) ((GuiChest)event.gui).inventorySlots;
- if (!("Large Chest".equals(ch.getLowerChestInventory().getName())
- || "Chest".equals(ch.getLowerChestInventory().getName()))) return;
- check = true;
- }
-
- public static long getPrice(ItemStack itemStack) {
- if (itemStack == null) return 0;
- NBTTagCompound compound = itemStack.getTagCompound();
- if (compound == null)
- return 0;
- if (!compound.hasKey("ExtraAttributes"))
- return 0;
- final String id = compound.getCompoundTag("ExtraAttributes").getString("id");
- if (id.equals("ENCHANTED_BOOK")) {
- final NBTTagCompound enchants = compound.getCompoundTag("ExtraAttributes").getCompoundTag("enchantments");
- Set<String> keys = enchants.getKeySet();
- Set<String> actualKeys = new TreeSet<String>(new Comparator<String>() {
- public int compare(String o1, String o2) {
- String id2 = id + "::" + o1 + "-" + enchants.getInteger(o1);
- AhUtils.AuctionData auctionData = AhUtils.auctions.get(id2);
- long price1 = (auctionData == null) ? 0 : auctionData.lowestBin;
- String id3 = id + "::" + o2 + "-" + enchants.getInteger(o2);
- AhUtils.AuctionData auctionData2 = AhUtils.auctions.get(id3);
- long price2 = (auctionData2 == null) ? 0 : auctionData2.lowestBin;
- return (compare2(price1, price2) == 0) ? o1.compareTo(o2) : compare2(price1, price2);
- }
-
- public int compare2(long y, long x) {
- return (x < y) ? -1 : ((x == y) ? 0 : 1);
- }
- });
- actualKeys.addAll(keys);
- int totalLowestPrice = 0;
- for (String key : actualKeys) {
- String id2 = id + "::" + key + "-" + enchants.getInteger(key);
- AhUtils.AuctionData auctionData = AhUtils.auctions.get(id2);
- totalLowestPrice += auctionData.lowestBin;
- }
- return totalLowestPrice;
- } else {
- AhUtils.AuctionData auctionData = AhUtils.auctions.get(id);
- if (auctionData == null) {
- return 0;
- } else {
- if (auctionData.sellPrice == -1 && auctionData.lowestBin != -1) return auctionData.lowestBin;
- else if (auctionData.sellPrice != -1 && auctionData.lowestBin == -1) return auctionData.sellPrice;
- else {
- long ahPrice = auctionData.lowestBin;
- if (ahPrice > auctionData.sellPrice) return ahPrice;
- else return auctionData.sellPrice;
- }
- }
- }
- }
-
- @Override
- public void onTick() {
- if (!this.isEnabled()) return;
- if (check) {
- check = false;
-
- GuiScreen screen = Minecraft.getMinecraft().currentScreen;
- if (screen instanceof GuiChest){
-
- ContainerChest chest = (ContainerChest) ((GuiChest) screen).inventorySlots;
- IInventory actualChest = chest.getLowerChestInventory();
-
- int priceSum = 0;
- for (int i = 0; i < actualChest.getSizeInventory(); i++) {
- priceSum += getPrice(actualChest.getStackInSlot(i));
- }
-
- int threshold = this.<Integer>getParameter("threshold").getValue();
- if (priceSum < threshold) {
- Minecraft.getMinecraft().thePlayer.closeScreen();
- }
- }
- }
- }
-}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/ability/FeatureAbilityCooldown.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/ability/FeatureAbilityCooldown.java
index 1f568d49..374c4560 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/ability/FeatureAbilityCooldown.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/ability/FeatureAbilityCooldown.java
@@ -9,7 +9,6 @@ import kr.syeyoung.dungeonsguide.features.text.TextHUDFeature;
import kr.syeyoung.dungeonsguide.features.text.TextStyle;
import kr.syeyoung.dungeonsguide.utils.TextUtils;
import net.minecraftforge.client.event.ClientChatReceivedEvent;
-import scala.Long;
import java.util.*;
import java.util.regex.Matcher;