diff options
| author | kokoniara <70776766+kingstefan26@users.noreply.github.com> | 2022-10-07 14:50:22 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-07 21:50:22 +0900 |
| commit | dd7a4209752715db544b2fef804da9762c532cdc (patch) | |
| tree | 496c7bf318c8b047285aba0c5c695b2242e3a336 /src/main/java/kr/syeyoung/dungeonsguide/features | |
| parent | 95af42d0a671517bad21df43ba82e61cd64e5fba (diff) | |
| download | Skyblock-Dungeons-Guide-dd7a4209752715db544b2fef804da9762c532cdc.tar.gz Skyblock-Dungeons-Guide-dd7a4209752715db544b2fef804da9762c532cdc.tar.bz2 Skyblock-Dungeons-Guide-dd7a4209752715db544b2fef804da9762c532cdc.zip | |
fix player profile not never loading in chat (#63)
* fix player profile not never loading in chat
* cut out hychat like a cancer
* ApiFetchur now caches whole players not single profiles,
added a switch profile button in gui
* ugh git
* Revert "cut out hychat like a cancer"
This reverts commit 2ee11afa
* ugh git x2
* I tried, good luck maintaining this
* forgot to uncomment hychat fix
* now shows which profile is now selected
put button on top
a lil refactor
* fix player profile sometimes not loading
Co-authored-by: syeyoung <42869671+cyoung06@users.noreply.github.com>
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/features')
35 files changed, 1386 insertions, 1047 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java index 7ef483e1..bf3be41d 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java @@ -36,7 +36,7 @@ import kr.syeyoung.dungeonsguide.features.impl.party.APIKey; import kr.syeyoung.dungeonsguide.features.impl.party.FeaturePartyList; import kr.syeyoung.dungeonsguide.features.impl.party.FeaturePartyReady; import kr.syeyoung.dungeonsguide.features.impl.party.customgui.FeatureCustomPartyFinder; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.FeatureViewPlayerOnJoin; +import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.FeatureViewPlayerStatsOnJoin; import kr.syeyoung.dungeonsguide.features.impl.secret.*; import kr.syeyoung.dungeonsguide.features.impl.secret.mechanicbrowser.FeatureMechanicBrowse; import kr.syeyoung.dungeonsguide.features.impl.solvers.*; @@ -161,7 +161,7 @@ public class FeatureRegistry { public static final FeatureSimonSaysSolver BOSSFIGHT_SIMONSAYS_SOLVER = register(new FeatureSimonSaysSolver()); public static final APIKey PARTYKICKER_APIKEY = register(new APIKey()); - public static final FeatureViewPlayerOnJoin PARTYKICKER_VIEWPLAYER = register(new FeatureViewPlayerOnJoin()); + public static final FeatureViewPlayerStatsOnJoin PARTYKICKER_VIEWPLAYER = register(new FeatureViewPlayerStatsOnJoin()); public static final FeatureCustomPartyFinder PARTYKICKER_CUSTOM = register(new FeatureCustomPartyFinder()); public static final FeaturePartyList PARTY_LIST = register(new FeaturePartyList()); public static final FeaturePartyReady PARTY_READY = register(new FeaturePartyReady()); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureAutoAcceptReparty.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureAutoAcceptReparty.java index 3a469793..0cb126ef 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureAutoAcceptReparty.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureAutoAcceptReparty.java @@ -22,10 +22,8 @@ import kr.syeyoung.dungeonsguide.SkyblockStatus; import kr.syeyoung.dungeonsguide.DungeonsGuide; import kr.syeyoung.dungeonsguide.chat.ChatProcessor; import kr.syeyoung.dungeonsguide.features.SimpleFeature; -import kr.syeyoung.dungeonsguide.features.impl.party.api.ApiFetchur; import kr.syeyoung.dungeonsguide.features.listener.ChatListener; import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.client.Minecraft; import net.minecraftforge.client.event.ClientChatReceivedEvent; public class FeatureAutoAcceptReparty extends SimpleFeature implements ChatListener { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/FeatureGoodParties.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/FeatureGoodParties.java index 7f292e13..6d33ebc9 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/FeatureGoodParties.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/FeatureGoodParties.java @@ -18,22 +18,15 @@ package kr.syeyoung.dungeonsguide.features.impl.party; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.features.SimpleFeature; -import kr.syeyoung.dungeonsguide.features.impl.party.api.ApiFetchur; -import kr.syeyoung.dungeonsguide.features.impl.party.api.DungeonType; -import kr.syeyoung.dungeonsguide.features.impl.party.api.PlayerProfile; import kr.syeyoung.dungeonsguide.features.listener.GuiPostRenderListener; -import kr.syeyoung.dungeonsguide.features.listener.TickListener; import kr.syeyoung.dungeonsguide.utils.TextUtils; -import kr.syeyoung.dungeonsguide.utils.XPUtils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.inventory.GuiChest; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.init.Items; -import net.minecraft.inventory.Container; import net.minecraft.inventory.ContainerChest; import net.minecraft.inventory.Slot; import net.minecraft.nbt.NBTTagCompound; @@ -42,10 +35,6 @@ import net.minecraftforge.client.event.GuiScreenEvent; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL14; -import java.util.Optional; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; - public class FeatureGoodParties extends SimpleFeature implements GuiPostRenderListener { public FeatureGoodParties() { super("Party Kicker", "Highlight parties in party viewer", "Highlight parties you can't join with red", "partykicker.goodparty",true); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/PanelPartyFinderSettings.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/PanelPartyFinderSettings.java index 46107ff8..fe719de2 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/PanelPartyFinderSettings.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/PanelPartyFinderSettings.java @@ -21,7 +21,6 @@ package kr.syeyoung.dungeonsguide.features.impl.party.customgui; import kr.syeyoung.dungeonsguide.chat.ChatProcessor; import kr.syeyoung.dungeonsguide.chat.PartyManager; import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.features.impl.party.api.ApiFetchur; import kr.syeyoung.dungeonsguide.gui.elements.*; import kr.syeyoung.dungeonsguide.utils.TextUtils; import lombok.Getter; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/FakePlayer.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/FakePlayer.java new file mode 100644 index 00000000..ec8a29d9 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/FakePlayer.java @@ -0,0 +1,101 @@ +package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview; + +import com.google.common.base.Objects; +import com.mojang.authlib.GameProfile; +import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.PlayerProfile; +import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.SkinFetcher; +import kr.syeyoung.dungeonsguide.utils.TextUtils; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityOtherPlayerMP; +import net.minecraft.client.resources.DefaultPlayerSkin; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.scoreboard.ScorePlayerTeam; +import net.minecraft.scoreboard.Team; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; + +public class FakePlayer extends EntityOtherPlayerMP { + @Setter + @Getter + private PlayerProfile skyblockProfile; + private final SkinFetcher.SkinSet skinSet; + private final PlayerProfile.Armor armor; + @Getter + private final int profileNumber; + + private FakePlayer(World w) { + super(w, null); + throw new UnsupportedOperationException("what"); + } + + public FakePlayer(GameProfile playerProfile, SkinFetcher.SkinSet skinSet, PlayerProfile skyblockProfile, int profileNumber) { + super(Minecraft.getMinecraft().theWorld, playerProfile); + this.profileNumber = profileNumber; + this.skyblockProfile = skyblockProfile; + this.skinSet = skinSet; + armor = skyblockProfile.getCurrentArmor(); + this.inventory.armorInventory = skyblockProfile.getCurrentArmor().getArmorSlots(); + + int highestDungeonScore = Integer.MIN_VALUE; + if (skyblockProfile.getInventory() != null) { + ItemStack highestItem = null; + for (ItemStack itemStack : skyblockProfile.getInventory()) { + if (itemStack == null) continue; + NBTTagCompound display = itemStack.getTagCompound().getCompoundTag("display"); + if (display == null) continue; + NBTTagList nbtTagList = display.getTagList("Lore", 8); + if (nbtTagList == null) continue; + for (int i = 0; i < nbtTagList.tagCount(); i++) { + String str = nbtTagList.getStringTagAt(i); + if (TextUtils.stripColor(str).startsWith("Gear")) { + int dungeonScore = Integer.parseInt(TextUtils.keepIntegerCharactersOnly(TextUtils.stripColor(str).split(" ")[2])); + if (dungeonScore > highestDungeonScore) { + highestItem = itemStack; + highestDungeonScore = dungeonScore; + } + } + } + } + + this.inventory.mainInventory[0] = highestItem; + this.inventory.currentItem = 0; + } + } + + public String getSkinType() { + return this.skinSet == null ? DefaultPlayerSkin.getSkinType(getGameProfile().getId()) : this.skinSet.getSkinType(); + } + + public ResourceLocation getLocationSkin() { + return Objects.firstNonNull(skinSet.getSkinLoc(), DefaultPlayerSkin.getDefaultSkin(getGameProfile().getId())); + } + + public ResourceLocation getLocationCape() { + return skinSet.getCapeLoc(); + } + + @Override + public ItemStack[] getInventory() { + return this.inventory.armorInventory; + } + + @Override + public boolean isInvisibleToPlayer(EntityPlayer player) { + return true; + } + + @Override + public Team getTeam() { + return new ScorePlayerTeam(null, null) { + @Override + public EnumVisible getNameTagVisibility() { + return EnumVisible.NEVER; + } + }; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/FeatureViewPlayerOnJoin.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/FeatureViewPlayerOnJoin.java deleted file mode 100644 index ceca0022..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/FeatureViewPlayerOnJoin.java +++ /dev/null @@ -1,620 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * 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.features.impl.party.playerpreview; - -import com.google.common.base.Supplier; -import com.mojang.authlib.GameProfile; -import io.github.moulberry.hychat.HyChat; -import io.github.moulberry.hychat.chat.ChatManager; -import io.github.moulberry.hychat.gui.GuiChatBox; -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.chat.ChatProcessor; -import kr.syeyoung.dungeonsguide.chat.PartyManager; -import kr.syeyoung.dungeonsguide.config.guiconfig.ConfigPanelCreator; -import kr.syeyoung.dungeonsguide.config.guiconfig.MFeatureEdit; -import kr.syeyoung.dungeonsguide.config.guiconfig.MParameterEdit; -import kr.syeyoung.dungeonsguide.config.guiconfig.RootConfigPanel; -import kr.syeyoung.dungeonsguide.cosmetics.ActiveCosmetic; -import kr.syeyoung.dungeonsguide.cosmetics.CosmeticData; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; -import kr.syeyoung.dungeonsguide.features.impl.party.api.*; -import kr.syeyoung.dungeonsguide.features.listener.ChatListener; -import kr.syeyoung.dungeonsguide.features.listener.GuiClickListener; -import kr.syeyoung.dungeonsguide.features.listener.GuiPostRenderListener; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import lombok.Getter; -import lombok.Setter; -import lombok.SneakyThrows; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.EntityOtherPlayerMP; -import net.minecraft.client.gui.*; -import net.minecraft.client.gui.inventory.GuiInventory; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.client.resources.DefaultPlayerSkin; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.event.HoverEvent; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.scoreboard.ScorePlayerTeam; -import net.minecraft.scoreboard.Team; -import net.minecraft.util.*; -import net.minecraft.world.World; -import net.minecraftforge.client.event.ClientChatReceivedEvent; -import net.minecraftforge.client.event.GuiScreenEvent; -import net.minecraftforge.fml.client.config.GuiUtils; -import net.minecraftforge.fml.common.Loader; -import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; - -import java.awt.*; -import java.util.*; -import java.util.List; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; - -public class FeatureViewPlayerOnJoin extends SimpleFeature implements GuiPostRenderListener, ChatListener, GuiClickListener { - - public FeatureViewPlayerOnJoin() { - super("Party", "View player stats when join", "view player rendering when joining/someone joins the party", "partykicker.viewstats", true); - this.parameters.put("datarenderers", new FeatureParameter<List<String>>("datarenderers", "DataRenderers","Datarenderssdasd", new ArrayList<>(Arrays.asList( - "catalv", "selected_class_lv", "dungeon_catacombs_higheststat", "dungeon_master_catacombs_higheststat", "skill_combat_lv", "skill_foraging_lv", "skill_mining_lv", "fairysouls", "dummy" - )), "stringlist")); - } - - private Rectangle popupRect; - private String lastuid; // actually current uid - private Future<Optional<PlayerProfile>> profileFuture; - private Future<Optional<GameProfile>> gfFuture; - private Future<SkinFetchur.SkinSet> skinFuture; - private FakePlayer fakePlayer; - private boolean drawInv = false; - @SneakyThrows - @Override - public void onGuiPostRender(GuiScreenEvent.DrawScreenEvent.Post rendered) { - if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChat)) { - cancelRender(); - return; - } - ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - IChatComponent ichatcomponent = getHoveredComponent(scaledResolution); - String uid = null; - if (ichatcomponent != null && ichatcomponent.getChatStyle().getChatHoverEvent() instanceof HoverEventRenderPlayer) { - uid = ((HoverEventRenderPlayer) ichatcomponent.getChatStyle().getChatHoverEvent()).getUuid(); - } - reqRender(uid); - } - - public void cancelRender() { - popupRect = null; - profileFuture = null; - lastuid = null; - gfFuture = null; - skinFuture= null; - fakePlayer= null; - drawInv = false; - } - - public void reqRender(String uid) { - ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - int width = scaledResolution.getScaledWidth(); - int height = scaledResolution.getScaledHeight(); - int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; - int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; - - - if (!((popupRect != null && (popupRect.contains(mouseX, mouseY) || drawInv)) || uid != null && uid.equals(lastuid))) { - cancelRender(); - } - - if (uid != null && !uid.equals(lastuid) && (popupRect==null || (!popupRect.contains(mouseX, mouseY) && !drawInv)) ) { - cancelRender(); - lastuid = uid; - } - if (lastuid == null) return; - - - if (popupRect == null) { - popupRect = new Rectangle(mouseX, mouseY, 220, 220); - if (popupRect.y + popupRect.height > scaledResolution.getScaledHeight()) { - popupRect.y -= popupRect.y + popupRect.height - scaledResolution.getScaledHeight(); - } - } - - if (profileFuture == null) { - profileFuture = ApiFetchur.fetchMostRecentProfileAsync(lastuid, FeatureRegistry.PARTYKICKER_APIKEY.getAPIKey()); - } - - if (gfFuture == null) { - gfFuture = ApiFetchur.getSkinGameProfileByUUIDAsync(lastuid); - } - boolean plsSetAPIKEY = false; - if (skinFuture == null && gfFuture.isDone()) { - try { - skinFuture = SkinFetchur.getSkinSet(gfFuture.get().orElse(null)); - } catch (InterruptedException | ExecutionException e) { - e.printStackTrace(); - } - } - - try { - if (fakePlayer == null && skinFuture != null && profileFuture != null && skinFuture.isDone() && profileFuture.isDone() && profileFuture.get().isPresent()) { - fakePlayer = new FakePlayer(gfFuture.get().orElse(null), skinFuture.get(), profileFuture.get().orElse(null)); - } - } catch (InterruptedException | ExecutionException e) { - plsSetAPIKEY = true; - } - - - try { - render(popupRect, scaledResolution, mouseX, mouseY, plsSetAPIKEY ? null : (profileFuture.isDone() ? profileFuture.get() : null), plsSetAPIKEY); - } catch (InterruptedException | ExecutionException e) { - } - - } - - public static void clip(ScaledResolution resolution, int x, int y, int width, int height) { - if (width < 0 || height < 0) return; - - int scale = resolution.getScaleFactor(); - GL11.glScissor((x ) * scale, Minecraft.getMinecraft().displayHeight - (y + height) * scale, (width) * scale, height * scale); - } - private void render(Rectangle popupRect, ScaledResolution scaledResolution, int mouseX, int mouseY, Optional<PlayerProfile> playerProfile, boolean apiKeyPlsSet) { - - GlStateManager.pushMatrix(); - GlStateManager.translate(popupRect.x, popupRect.y, 0); - Gui.drawRect(0,0, popupRect.width, popupRect.height, 0xFF23272a); - Gui.drawRect(2,2, popupRect.width-2, popupRect.height-2, 0XFF2c2f33); - - 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 (apiKeyPlsSet) { - Minecraft.getMinecraft().fontRendererObj.drawString("Please set API KEY on /dg -> Party Kicker", 5,5, 0xFFFFFFFF); - GlStateManager.popMatrix(); - return; - } - if (playerProfile == null) { - Minecraft.getMinecraft().fontRendererObj.drawString("Fetching data...", 5,5, 0xFFFFFFFF); - GlStateManager.popMatrix(); - return; - } - if (!playerProfile.isPresent()) { - Minecraft.getMinecraft().fontRendererObj.drawString("User could not be found", 5,5, 0xFFFFFFFF); - GlStateManager.popMatrix(); - return; - } - int relX = mouseX - popupRect.x; - int relY = mouseY - popupRect.y; - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - - - GL11.glEnable(GL11.GL_SCISSOR_TEST); - clip(scaledResolution, popupRect.x, popupRect.y, popupRect.width, popupRect.height); - - Gui.drawRect(0,168, 90, 195, 0xFF23272a); - Gui.drawRect(2,170, 88, 193, new Rectangle(2,170,86,23).contains(relX, relY) ? 0xFFff7777 : 0xFFFF3333); - - Gui.drawRect(0,193, 90, 220, 0xFF23272a); - Gui.drawRect(2,195, 88, 218, new Rectangle(2,195,86,23).contains(relX, relY) ? 0xFF859DF0 : 0xFF7289da); - 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); - fr.drawString("Kick", (90 - fr.getStringWidth("Kick")) / 2,(364 - fr.FONT_HEIGHT) / 2, 0xFFFFFFFF); - fr.drawString("Invite", (90 - fr.getStringWidth("Invite")) / 2,(414 - fr.FONT_HEIGHT) / 2, 0xFFFFFFFF); - - GlStateManager.pushMatrix(); - - GlStateMana |
