diff options
Diffstat (limited to 'src/main/java/io')
6 files changed, 64 insertions, 125 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java index 016c17f0..726856cb 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java @@ -22,8 +22,6 @@ package io.github.moulberry.notenoughupdates.miscfeatures; import com.google.common.collect.Lists; import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; import com.google.gson.JsonNull; import com.google.gson.JsonObject; import com.google.gson.JsonParser; @@ -36,11 +34,8 @@ import io.github.moulberry.notenoughupdates.listener.RenderListener; import io.github.moulberry.notenoughupdates.options.NEUConfig; import io.github.moulberry.notenoughupdates.overlays.TextOverlay; import io.github.moulberry.notenoughupdates.overlays.TextOverlayStyle; -import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer; -import io.github.moulberry.notenoughupdates.profileviewer.SkyblockProfiles; import io.github.moulberry.notenoughupdates.util.Constants; import io.github.moulberry.notenoughupdates.util.PetLeveling; -import io.github.moulberry.notenoughupdates.util.ProfileApiSyncer; import io.github.moulberry.notenoughupdates.util.Utils; import io.github.moulberry.notenoughupdates.util.XPInformation; import net.minecraft.client.Minecraft; @@ -54,7 +49,6 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.client.event.ClientChatReceivedEvent; -import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; @@ -156,6 +150,10 @@ public class PetInfoOverlay extends TextOverlay { private static long lastPetSelect = -1; private static PetConfig config = new PetConfig(); + public static PetConfig getConfig() { + return config; + } + private static long lastUpdate = 0; private static float levelXpLast = 0; @@ -281,110 +279,6 @@ public class PetInfoOverlay extends TextOverlay { } } - private static void getAndSetPet(SkyblockProfiles profile) { - Map<String, ProfileViewer.Level> skyblockInfo = profile.getLatestProfile().getLevelingInfo(); - Map<String, JsonArray> invInfo = profile.getLatestProfile().getInventoryInfo(); - JsonObject profileInfo = profile.getLatestProfile().getProfileJson(); - if (invInfo != null && profileInfo != null) { - JsonObject stats = profileInfo.get("stats").getAsJsonObject(); - boolean hasBeastmasterCrest = false; - Rarity currentBeastRarity = Rarity.COMMON; - for (JsonElement talisman : invInfo.get("talisman_bag")) { - if (talisman.isJsonNull()) continue; - String internalName = talisman.getAsJsonObject().get("internalname").getAsString(); - if (internalName.startsWith("BEASTMASTER_CREST")) { - hasBeastmasterCrest = true; - try { - Rarity talismanRarity = Rarity.valueOf(internalName.replace("BEASTMASTER_CREST_", "")); - if (talismanRarity.beastcreatMultiplyer > currentBeastRarity.beastcreatMultiplyer) - currentBeastRarity = talismanRarity; - } catch (Exception ignored) { - } - } - } - if (hasBeastmasterCrest) { - if (stats.has("mythos_kills")) { - int mk = stats.get("mythos_kills").getAsInt(); - float petXpBoost = mk > 10000 ? 1f : mk > 7500 ? 0.9f : mk > 5000 ? 0.8f : mk > 2500 ? 0.7f : - mk > 1000 - ? 0.6f - : mk > 500 - ? 0.5f - : mk > 250 - ? 0.4f - : mk > 100 - ? 0.3f - : mk > 25 ? 0.2f : 0.1f; - config.beastMultiplier = petXpBoost * currentBeastRarity.beastcreatMultiplyer; - } else { - config.beastMultiplier = 0.1f * currentBeastRarity.beastcreatMultiplyer; - } - } - } - if (skyblockInfo != null && profile.getLatestProfile().skillsApiEnabled()) { - config.tamingLevel = (int) skyblockInfo.get("taming").level; - } - - //JsonObject petObject = profile.getPetsInfo(profile.getLatestProfile()); - /*JsonObject petsJson = Constants.PETS; - if(petsJson != null) { - if(petObject != null) { - boolean forceUpdateLevels = System.currentTimeMillis() - lastXpGain > 30000; - Set<String> foundPets = new HashSet<>(); - Set<Pet> addedPets = new HashSet<>(); - for(int i = 0; i < petObject.getAsJsonArray("pets").size(); i++) { - JsonElement petElement = petObject.getAsJsonArray("pets").get(i); - JsonObject petObj = petElement.getAsJsonObject(); - Pet pet = new Pet(); - pet.petType = petObj.get("type").getAsString(); - Rarity rarity; - try { - rarity = Rarity.valueOf(petObj.get("tier").getAsString()); - } catch(Exception ignored) { - rarity = Rarity.COMMON; - } - pet.rarity = rarity; - pet.petLevel = GuiProfileViewer.getPetLevel(petsJson.get("pet_levels").getAsJsonArray(), rarity.petOffset, petObj.get("exp").getAsFloat()); - JsonElement heldItem = petObj.get("heldItem"); - pet.petItem = heldItem.isJsonNull() ? null : heldItem.getAsString(); - if(rarity != Rarity.MYTHIC && pet.petItem != null && pet.petItem.equals("PET_ITEM_TIER_BOOST")) { - rarity = Rarity.values()[rarity.ordinal()+1]; - } - JsonObject petTypes = petsJson.get("pet_types").getAsJsonObject(); - pet.petXpType = petTypes.has(pet.petType) ? petTypes.get(pet.petType.toUpperCase()).getAsString().toLowerCase() : "unknown"; - - Pet closest = null; - if(petList.containsKey(pet.petType + ";" + pet.rarity.petId)) { - closest = getClosestPet(pet); - if(addedPets.contains(closest)) { - closest = null; - } - - if(closest != null) { - if(!forceUpdateLevels || Math.floor(pet.petLevel.level) < Math.floor(closest.petLevel.level)) { - pet.petLevel = closest.petLevel; - } - petList.get(pet.petType + ";" + pet.rarity.petId).remove(closest); - } - } - foundPets.add(pet.petType + ";" + pet.rarity.petId); - petList.computeIfAbsent(pet.petType + ";" + pet.rarity.petId, k->new HashSet<>()).add(pet); - addedPets.add(pet); - - if(petObj.get("active").getAsBoolean()) { - if(currentPet == null && !setActivePet) { - currentPet = pet; - } else if(closest == currentPet) { - currentPet = pet; - } - } - } - petList.keySet().retainAll(foundPets); - setActivePet = true; - } - }*/ - } - private float interp(float now, float last) { float interp = now; if (last >= 0 && last != now) { @@ -659,12 +553,6 @@ public class PetInfoOverlay extends TextOverlay { return; } - int updateTime = 60000; - - if (NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) { - ProfileApiSyncer.getInstance().requestResync("petinfo", updateTime, () -> {}, PetInfoOverlay::getAndSetPet); - } - Pet currentPet = getCurrentPet(); if (currentPet == null) { overlayStrings = null; @@ -1097,13 +985,6 @@ public class PetInfoOverlay extends TextOverlay { } } - @SubscribeEvent - public void switchWorld(WorldEvent.Load event) { - if (NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) { - ProfileApiSyncer.getInstance().requestResync("petinfo_quick", 10000, () -> {}, PetInfoOverlay::getAndSetPet); - } - } - private int lastLevelHovered = 0; private static final Pattern AUTOPET_EQUIP = Pattern.compile( diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperApiLoader.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperApiLoader.java index ecf02236..ed275c7a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperApiLoader.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperApiLoader.java @@ -53,7 +53,7 @@ public class MinionHelperApiLoader { private ApiData apiData = null; private boolean notifyNoCollectionApi = false; private long lastLoaded = 0; - private boolean invalidApiKey = false; + private boolean invalidApiKey = true; public MinionHelperApiLoader(MinionHelperManager manager) { this.manager = manager; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlay.java index 93a39ec0..a6a92a6a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlay.java @@ -115,7 +115,7 @@ public class MinionHelperOverlay { if (!NotEnoughUpdates.INSTANCE.config.minionHelper.gui) return; if (manager.isInvalidApiKey()) { LinkedHashMap<String, OverviewLine> map = new LinkedHashMap<>(); - map.put("§cInvalid API Key!", new OverviewText(Collections.emptyList(), () -> {})); + map.put("§cNo data found, try running /pv", new OverviewText(Collections.emptyList(), () -> {})); render(map); return; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java index a1135205..7db8a21c 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java @@ -766,6 +766,9 @@ public class BasicPage extends GuiProfileViewerPage { if (NotEnoughUpdates.INSTANCE.config.profileViewer.displayWeight) { renderWeight(mouseX, mouseY, selectedProfile); } + + selectedProfile.updateTamingLevel(); + selectedProfile.updateBeastMasterMultiplier(); } private String getIcon(String gameModeType) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/SkyblockProfiles.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/SkyblockProfiles.java index f2f9c6ad..3bfac529 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/SkyblockProfiles.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/SkyblockProfiles.java @@ -24,6 +24,8 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.events.ProfileDataLoadedEvent; +import io.github.moulberry.notenoughupdates.miscfeatures.PetInfoOverlay; import io.github.moulberry.notenoughupdates.profileviewer.bestiary.BestiaryData; import io.github.moulberry.notenoughupdates.profileviewer.weight.senither.SenitherWeight; import io.github.moulberry.notenoughupdates.profileviewer.weight.weight.Weight; @@ -32,6 +34,7 @@ import io.github.moulberry.notenoughupdates.util.UrsaClient; import io.github.moulberry.notenoughupdates.util.Utils; import io.github.moulberry.notenoughupdates.util.hypixelapi.ProfileCollectionInfo; import lombok.Getter; +import net.minecraft.client.Minecraft; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompressedStreamTools; @@ -320,6 +323,12 @@ public class SkyblockProfiles { profileViewer.getManager().ursaClient .get(UrsaClient.profiles(Utils.parseDashlessUUID(uuid))) .handle((profilesJson, throwable) -> { + try { + if (Utils.parseDashlessUUID(uuid).toString().equals(Minecraft.getMinecraft().thePlayer.getUniqueID().toString())) { + new ProfileDataLoadedEvent(uuid, profilesJson).post(); + } + } catch (Exception ignored) { + } if (profilesJson != null && profilesJson.has("success") && profilesJson.get("success").getAsBoolean() && profilesJson.has("profiles")) { Map<String, SkyblockProfile> nameToProfile = new HashMap<>(); @@ -1140,5 +1149,50 @@ public class SkyblockProfiles { loadMuseumData(); return new MuseumData(null).asLoading(); } + + public void updateBeastMasterMultiplier() { + if (!getUuid().equals(Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""))) return; + JsonObject stats = getProfileJson().get("stats").getAsJsonObject(); + boolean hasBeastmasterCrest = false; + PetInfoOverlay.Rarity currentBeastRarity = PetInfoOverlay.Rarity.COMMON; + for (JsonElement talisman : getInventoryInfo().get("talisman_bag")) { + if (talisman.isJsonNull()) continue; + String internalName = talisman.getAsJsonObject().get("internalname").getAsString(); + if (internalName.startsWith("BEASTMASTER_CREST")) { + hasBeastmasterCrest = true; + try { + PetInfoOverlay.Rarity talismanRarity = PetInfoOverlay.Rarity.valueOf(internalName.replace("BEASTMASTER_CREST_", "")); + if (talismanRarity.beastcreatMultiplyer > currentBeastRarity.beastcreatMultiplyer) + currentBeastRarity = talismanRarity; + } catch (Exception ignored) { + } + } + } + if (hasBeastmasterCrest) { + if (stats.has("mythos_kills")) { + int mk = stats.get("mythos_kills").getAsInt(); + float petXpBoost = mk > 10000 ? 1f : mk > 7500 ? 0.9f : mk > 5000 ? 0.8f : mk > 2500 ? 0.7f : + mk > 1000 + ? 0.6f + : mk > 500 + ? 0.5f + : mk > 250 + ? 0.4f + : mk > 100 + ? 0.3f + : mk > 25 ? 0.2f : 0.1f; + PetInfoOverlay.getConfig().beastMultiplier = petXpBoost * currentBeastRarity.beastcreatMultiplyer; + } else { + PetInfoOverlay.getConfig().beastMultiplier = 0.1f * currentBeastRarity.beastcreatMultiplyer; + } + } + } + + public void updateTamingLevel() { + if (!getUuid().equals(Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""))) return; + if (!getLatestProfile().skillsApiEnabled()) return; + + PetInfoOverlay.getConfig().tamingLevel = (int) getLevelingInfo().get("taming").level; + } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/ApiUtil.java b/src/main/java/io/github/moulberry/notenoughupdates/util/ApiUtil.java index e96043fa..9611f197 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/ApiUtil.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/ApiUtil.java @@ -109,6 +109,7 @@ public class ApiUtil { } public void updateProfileData(String playerUuid) { + if (true) return; if (!updateTasks.getOrDefault(playerUuid, CompletableFuture.completedFuture(null)).isDone()) return; String uuid = Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""); |