diff options
author | syeyoung <cyong06@naver.com> | 2021-04-25 17:31:37 +0900 |
---|---|---|
committer | syeyoung <cyong06@naver.com> | 2021-04-25 17:31:37 +0900 |
commit | f54b267b337dee36fc9997abd1193393db11878e (patch) | |
tree | 8da9e45c1537edcce86bc05972f421bbe0fc3d52 /src/main/java/kr/syeyoung | |
parent | 60f06415a290a659b5c8a56b1d9f879bbea91d10 (diff) | |
download | Skyblock-Dungeons-Guide-f54b267b337dee36fc9997abd1193393db11878e.tar.gz Skyblock-Dungeons-Guide-f54b267b337dee36fc9997abd1193393db11878e.tar.bz2 Skyblock-Dungeons-Guide-f54b267b337dee36fc9997abd1193393db11878e.zip |
oh wat
Diffstat (limited to 'src/main/java/kr/syeyoung')
14 files changed, 416 insertions, 50 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java index a0adf7b9..87ff13e2 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java @@ -12,42 +12,33 @@ import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoomInfoRegistry; import kr.syeyoung.dungeonsguide.e; import kr.syeyoung.dungeonsguide.events.DungeonLeftEvent; import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.features.impl.party.FeatureViewPlayerOnJoin; +import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.FeatureViewPlayerOnJoin; import kr.syeyoung.dungeonsguide.features.impl.party.api.ApiFetchur; -import kr.syeyoung.dungeonsguide.features.impl.party.api.PlayerProfile; import kr.syeyoung.dungeonsguide.party.PartyManager; import kr.syeyoung.dungeonsguide.roomprocessor.GeneralRoomProcessor; import kr.syeyoung.dungeonsguide.utils.AhUtils; import kr.syeyoung.dungeonsguide.utils.MapUtils; -import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.command.CommandBase; import net.minecraft.command.ICommandSender; -import net.minecraft.nbt.CompressedStreamTools; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ChatComponentText; import net.minecraft.util.ChatStyle; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; -import net.minecraftforge.fml.relauncher.ReflectionHelper; import javax.crypto.BadPaddingException; import javax.crypto.IllegalBlockSizeException; import javax.crypto.NoSuchPaddingException; import java.awt.*; import java.io.*; -import java.lang.reflect.Method; import java.security.*; import java.security.cert.CertificateException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Map; -import java.util.Optional; import java.util.UUID; -import java.util.concurrent.CompletableFuture; -import java.util.zip.GZIPOutputStream; public class CommandDungeonsGuide extends CommandBase { @Override diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDefaultParameterConfig.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDefaultParameterConfig.java index 72411e62..d0d1e984 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDefaultParameterConfig.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDefaultParameterConfig.java @@ -72,6 +72,9 @@ public class PanelDefaultParameterConfig extends MPanel { @Override public void mouseScrolled(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) { + for (MPanel childComponent : getChildComponents()) { + if (!(childComponent instanceof MParameter) && childComponent.getBounds().contains(relMouseX0, relMouseY0)) return; + } if (scrollAmount > 0) offsetY -= 20; else if (scrollAmount < 0) offsetY += 20; if (offsetY < 0) offsetY = 0; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCStringList.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCStringList.java new file mode 100644 index 00000000..0c8bce3d --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCStringList.java @@ -0,0 +1,34 @@ +package kr.syeyoung.dungeonsguide.config.types; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonPrimitive; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; + +public class TCStringList implements TypeConverter<List<String>> { + @Override + public String getTypeString() { + return "stringlist"; + } + + @Override + public List<String> deserialize(JsonElement element) { + List<String> strList = new ArrayList<>(); + for (JsonElement jsonElement : element.getAsJsonArray()) { + strList.add(jsonElement.getAsString()); + } + return strList; + } + + @Override + public JsonElement serialize(List<String> element) { + JsonArray jsonElements = new JsonArray(); + for (String s : element) { + jsonElements.add(new JsonPrimitive(s)); + } + return jsonElements; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverterRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverterRegistry.java index b100d62f..cce82ea3 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverterRegistry.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverterRegistry.java @@ -30,5 +30,6 @@ public class TypeConverterRegistry { register(new TCAColor()); register(new TCTextStyleList()); register(new TCTextStyle()); + register(new TCStringList()); } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java index ac8610e9..b62a6764 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java @@ -11,7 +11,7 @@ import kr.syeyoung.dungeonsguide.features.impl.dungeon.*; import kr.syeyoung.dungeonsguide.features.impl.etc.*; import kr.syeyoung.dungeonsguide.features.impl.etc.ability.FeatureAbilityCooldown; import kr.syeyoung.dungeonsguide.features.impl.party.APIKey; -import kr.syeyoung.dungeonsguide.features.impl.party.FeatureViewPlayerOnJoin; +import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.FeatureViewPlayerOnJoin; import kr.syeyoung.dungeonsguide.features.impl.secret.FeatureActions; import kr.syeyoung.dungeonsguide.features.impl.secret.FeatureFreezePathfind; import kr.syeyoung.dungeonsguide.features.impl.secret.FeatureMechanicBrowse; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/api/ApiFetchur.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/api/ApiFetchur.java index adc15d43..d760bd27 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/api/ApiFetchur.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/api/ApiFetchur.java @@ -32,6 +32,13 @@ public class ApiFetchur { public static void purgeCache() { playerProfileCache.clear(); nicknameToUID.clear(); + UIDtoNickname.clear(); + UIDtoGameProfile.clear(); + + completableFutureMap.clear(); + completableFutureMap2.clear(); + completableFutureMap3.clear(); + completableFutureMap4.clear(); } public static JsonObject getJson(String url) throws IOException { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/api/DungeonClass.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/api/DungeonClass.java index a1d63f05..6f2a2d71 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/api/DungeonClass.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/api/DungeonClass.java @@ -7,15 +7,13 @@ import java.util.HashMap; import java.util.Map; @Getter +@AllArgsConstructor public enum DungeonClass { - MAGE("mage"), ARCHER("archer"), HEALER("healer"), TANK("tank"), BERSERK("berserk"); + MAGE("mage", "Mage"), ARCHER("archer","Archer"), HEALER("healer", "Healer"), TANK("tank", "Tank"), BERSERK("berserk", "Berserk"); private String jsonName; - private DungeonClass(String jsonName) { - this.jsonName = jsonName; - } - + private String familarName; private static final Map<String, DungeonClass> jsonNameToClazz = new HashMap<>(); static { for (DungeonClass value : values()) { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRenderer.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRenderer.java new file mode 100644 index 00000000..95847014 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRenderer.java @@ -0,0 +1,9 @@ +package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview; + +import kr.syeyoung.dungeonsguide.features.impl.party.api.PlayerProfile; + +import java.awt.*; + +public interface DataRenderer { + Dimension renderData(PlayerProfile playerProfile); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererEditor.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererEditor.java new file mode 100644 index 00000000..808fa8b3 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererEditor.java @@ -0,0 +1,14 @@ +package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview; + +import kr.syeyoung.dungeonsguide.config.guiconfig.GuiConfig; +import kr.syeyoung.dungeonsguide.gui.MPanel; + +public class DataRendererEditor extends MPanel { + private FeatureViewPlayerOnJoin feature; + private GuiConfig config; + + public DataRendererEditor(GuiConfig config, FeatureViewPlayerOnJoin featureViewPlayerOnJoin) { + this.config = config; + this.feature = featureViewPlayerOnJoin; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererRegistry.java new file mode 100644 index 00000000..a8085f0d --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererRegistry.java @@ -0,0 +1,17 @@ +package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +public class DataRendererRegistry { + private static final Map<String, DataRenderer> dataRendererMap = new HashMap<>(); + + public static DataRenderer getDataRenderer(String id) { + return dataRendererMap.get(id); + } + + public static Set<String> getValidDataRenderer() { + return dataRendererMap.keySet(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/FeatureViewPlayerOnJoin.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/FeatureViewPlayerOnJoin.java index ceaaec84..effbf35e 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/FeatureViewPlayerOnJoin.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/FeatureViewPlayerOnJoin.java @@ -1,19 +1,27 @@ -package kr.syeyoung.dungeonsguide.features.impl.party; +package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview; +import com.google.common.base.Supplier; import com.mojang.authlib.GameProfile; import com.mojang.authlib.minecraft.MinecraftProfileTexture; import io.github.moulberry.hychat.HyChat; import io.github.moulberry.hychat.chat.ChatManager; import io.github.moulberry.hychat.gui.GuiChatBox; +import kr.syeyoung.dungeonsguide.config.guiconfig.ConfigPanelCreator; import kr.syeyoung.dungeonsguide.config.guiconfig.FeatureEditPane; +import kr.syeyoung.dungeonsguide.config.guiconfig.GuiConfig; +import kr.syeyoung.dungeonsguide.config.guiconfig.PanelDefaultParameterConfig; +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.ApiFetchur; -import kr.syeyoung.dungeonsguide.features.impl.party.api.PlayerProfile; -import kr.syeyoung.dungeonsguide.features.impl.party.api.SkinFetchur; +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.features.text.PanelTextParameterConfig; +import kr.syeyoung.dungeonsguide.features.text.TextHUDFeature; import kr.syeyoung.dungeonsguide.gui.MPanel; +import kr.syeyoung.dungeonsguide.utils.TextUtils; +import kr.syeyoung.dungeonsguide.utils.XPUtils; import lombok.Getter; import lombok.Setter; import lombok.SneakyThrows; @@ -30,6 +38,8 @@ import net.minecraft.client.resources.DefaultPlayerSkin; import net.minecraft.client.resources.SkinManager; import net.minecraft.event.HoverEvent; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; import net.minecraft.util.*; import net.minecraft.world.World; import net.minecraftforge.client.event.ClientChatReceivedEvent; @@ -39,16 +49,16 @@ import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; import java.awt.*; +import java.util.*; import java.util.List; -import java.util.Objects; -import java.util.Optional; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; -public class FeatureViewPlayerOnJoin extends SimpleFeature implements GuiPostRenderListener, ChatListener { +public class FeatureViewPlayerOnJoin extends SimpleFeature implements GuiPostRenderListener, ChatListener, GuiClickListener { public FeatureViewPlayerOnJoin() { super("Party Kicker", "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<>(), "stringlist")); } private Rectangle popupRect; @@ -101,7 +111,7 @@ public class FeatureViewPlayerOnJoin extends SimpleFeature implements GuiPostRen if (popupRect == null) { - popupRect = new Rectangle(mouseX, mouseY, 150, 200); + popupRect = new Rectangle(mouseX, mouseY, 190, 220); if (popupRect.y + popupRect.height > scaledResolution.getScaledHeight()) { popupRect.y -= popupRect.y + popupRect.height - scaledResolution.getScaledHeight(); } @@ -130,8 +140,8 @@ public class FeatureViewPlayerOnJoin extends SimpleFeature implements GuiPostRen GlStateManager.pushMatrix(); GlStateManager.translate(popupRect.x, popupRect.y, 0); - Gui.drawRect(0,0, popupRect.width, popupRect.height, 0xFF000000); - Gui.drawRect(1,1, popupRect.width-1, popupRect.height-1, 0xFFAAAAAA); + Gui.drawRect(0,0, popupRect.width, popupRect.height, 0xFF23272a); + Gui.drawRect(2,2, popupRect.width-2, popupRect.height-2, 0XFF2c2f33); if (playerProfile == null) { Minecraft.getMinecraft().fontRendererObj.drawString("Fetching data...", 5,5, 0xFFFFFFFF); GlStateManager.popMatrix(); @@ -142,24 +152,49 @@ public class FeatureViewPlayerOnJoin extends SimpleFeature implements GuiPostRen GlStateManager.popMatrix(); return; } + int relX = mouseX - popupRect.x; + int relY = mouseY - popupRect.y; + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; GL11.glEnable(GL11.GL_SCISSOR_TEST); MPanel.clip(scaledResolution, popupRect.x, popupRect.y, popupRect.width, popupRect.height); - Gui.drawRect(0,0, 80, popupRect.height-40, 0xFF000000); - Gui.drawRect(1,1, 79, popupRect.height-41, 0xFF444444); - GlStateManager.color(1, 1, 1, 1.0F); - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + Gui.drawRect(0,168, 90, 195, 0xFF23272a); + Gui.drawRect(2,170, 88, 193, new Rectangle(2,170,86,23).contains(relX, relY) ? 0xFFff7777 : 0xFFFF3333); + fr.drawString("Kick", (90 - fr.getStringWidth("Kick")) / 2,(364 - fr.FONT_HEIGHT) / 2, 0xFFFFFFFF); + Gui.drawRect(0,193, 90, 220, 0xFF23272a); + Gui.drawRect(2,195, 88, 218, new Rectangle(2,195,86,23).contains(relX, relY) ? 0xFF859DF0 : 0xFF7289da); + fr.drawString("Invite", (90 - fr.getStringWidth("Invite")) / 2,(414 - fr.FONT_HEIGHT) / 2, 0xFFFFFFFF); + + GlStateManager.pushMatrix(); + + GlStateManager.translate(95, 5, 0); + for (String datarenderers : this.<List<String>>getParameter("datarenderers").getValue()) { + DataRenderer dataRenderer = DataRendererRegistry.getDataRenderer(datarenderers); + if (dataRenderer == null) { + fr.drawString("Couldn't find Datarenderer", 0,0, 0xFFFF0000); + fr.drawString(datarenderers, 0,fr.FONT_HEIGHT, 0xFFFF0000); + GlStateManager.translate(0, fr.FONT_HEIGHT * 2, 0); + } else { + GlStateManager.pushMatrix(); + Dimension dimension = dataRenderer.renderData(playerProfile.get()); + GlStateManager.popMatrix(); + GlStateManager.translate(0,dimension.height,0); + } + } + + GlStateManager.popMatrix(); + + Gui.drawRect(0,0, 90, 170, 0xFF23272a); + Gui.drawRect(2,2, 88, 168, 0xFF444444); + GlStateManager.color(1, 1, 1, 1.0F); if (fakePlayer != null) { - GuiInventory.drawEntityOnScreen(40, 150, 60, -(mouseX - popupRect.x - 75), 0, fakePlayer); - fr.drawString(fakePlayer.getName(), (80 - fr.getStringWidth(fakePlayer.getName())) / 2, 15, 0xFFEFFF00); + GuiInventory.drawEntityOnScreen(45, 150, 60, -(mouseX - popupRect.x - 75), 0, fakePlayer); + fr.drawString(fakePlayer.getName(), (90 - fr.getStringWidth(fakePlayer.getName())) / 2, 15, 0xFFEFFF00); - int relX = mouseX - popupRect.x; - int relY = mouseY - popupRect.y; ItemStack toHover = null; - System.out.println(relX + " , "+relY); - if (relX > 5 && relX < 75) { + if (relX > 20 && relX < 70) { if (33<=relY && relY <= 66) { toHover = fakePlayer.getInventory()[3]; } else if (66 <= relY && relY <= 108) { @@ -169,29 +204,25 @@ public class FeatureViewPlayerOnJoin extends SimpleFeature implements GuiPostRen } else if (130 <= relY && relY <= 154) { toHover = fakePlayer.getInventory()[0]; } + } else if (relX > 0 && relX <= 20) { + if (80 <= relY && relY <= 120) { + toHover = fakePlayer.inventory.mainInventory[fakePlayer.inventory.currentItem]; + } } if (toHover != null) { List<String> list = toHover.getTooltip(Minecraft.getMinecraft().thePlayer, Minecraft.getMinecraft().gameSettings.advancedItemTooltips); - - for (int i = 0; i < list.size(); ++i) - { - if (i == 0) - { + for (int i = 0; i < list.size(); ++i) { + if (i == 0) { list.set(i, toHover.getRarity().rarityColor + (String)list.get(i)); - } - else - { + } else { list.set(i, EnumChatFormatting.GRAY + (String)list.get(i)); } } - FontRenderer font = toHover.getItem().getFontRenderer(toHover); - System.out.println(list); GL11.glDisable(GL11.GL_SCISSOR_TEST); FontRenderer theRenderer = (font == null ? fr : font); int minY = scaledResolution.getScaledHeight() - (list.size()+4) * theRenderer.FONT_HEIGHT - popupRect.y; - FeatureEditPane.drawHoveringText(list,relX, Math.min(minY, relY), theRenderer); GL11.glEnable(GL11.GL_SCISSOR_TEST); } @@ -202,6 +233,39 @@ public class FeatureViewPlayerOnJoin extends SimpleFeature implements GuiPostRen GL11.glDisable(GL11.GL_SCISSOR_TEST); GlStateManager.popMatrix(); // 33 66 108 130 154 // 5 75 } + @Override + public void onMouseInput(GuiScreenEvent.MouseInputEvent.Pre mouseInputEvent) { + 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)) return; + + mouseInputEvent.setCanceled(true); + + int relX = mouseX - popupRect.x; + int relY = mouseY - popupRect.y; + + try { + PlayerProfile playerProfile = profileFuture.isDone() ? profileFuture.get().orElse(null) : null; + if (playerProfile == null) return; + if (Mouse.getEventButton() != -1 && Mouse.isButtonDown(Mouse.getEventButton())) { + if (new Rectangle(2, 195, 86, 23).contains(relX, relY)) { + // invite + Minecraft.getMinecraft().thePlayer.sendChatMessage("/p invite " + ApiFetchur.fetchNicknameAsync(playerProfile.getMemberUID()).get().orElse("-")); + } else if (new Rectangle(2, 170, 86, 23).contains(relX, relY)) { + // kick + Minecraft.getMinecraft().thePlayer.sendChatMessage("/p kick " + ApiFetchur.fetchNicknameAsync(playerProfile.getMemberUID()).get().orElse("-")); + } + } + + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + + + } public IChatComponent getHoveredComponent(ScaledResolution scaledResolution) { IChatComponent ichatcomponent = null; @@ -225,6 +289,7 @@ public class FeatureViewPlayerOnJoin extends SimpleFeature implements GuiPostRen public void onChat(ClientChatReceivedEvent clientChatReceivedEvent) { } + public static class HoverEventRenderPlayer extends HoverEvent { @Getter private String uuid; @@ -273,6 +338,29 @@ public class FeatureViewPlayerOnJoin extends SimpleFeature implements GuiPostRen this.skinSet = skinSet; armor= skyblockProfile.getCurrentArmor(); this.inventory.armorInventory = skyblockProfile.getCurrentArmor().getArmorSlots(); + + int highestDungeonScore = Integer.MIN_VALUE; + 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 (str.contains("Gear")) { + int dungeonScore = Integer.parseInt(TextUtils.keepIntegerCharactersOnly(TextUtils.stripColor(str).split(" ")[3])); + if (dungeonScore > highestDungeonScore) { + highestItem = itemStack; + highestDungeonScore = dungeonScore; + } + } + } + } + + this.inventory.mainInventory[0] = highestItem; + this.inventory.currentItem = 0; } public String getSkinType() { @@ -292,4 +380,20 @@ public class FeatureViewPlayerOnJoin extends SimpleFeature implements GuiPostRen return this.inventory.armorInventory; } } + + + + @Override + public String getEditRoute(final GuiConfig config) { + ConfigPanelCreator.map.put("base." + getKey() , new Supplier<MPanel>() { + @Override + public MPanel get() { + return new PanelDefaultParameterConfig(config, FeatureViewPlayerOnJoin.this, + Arrays.asList(new MPanel[] { + new DataRendererEditor(config, FeatureViewPlayerOnJoin.this) + }), Collections.singleton("datarenderers")); + } + }); + return "base." + getKey() ; + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/text/PanelTextParameterConfig.java b/src/main/java/kr/syeyoung/dungeonsguide/features/text/PanelTextParameterConfig.java index a1f280a9..adab8bd0 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/text/PanelTextParameterConfig.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/text/PanelTextParameterConfig.java @@ -121,7 +121,7 @@ public class PanelTextParameterConfig extends MPanel { for (StyledTextRenderer.StyleTextAssociated calc3: calc) { if (selected.contains(calc3.getStyledText().getGroup())) { Gui.drawRect(calc3.getRectangle().x, calc3.getRectangle().y, calc3.getRectangle().x + calc3.getRectangle().width, calc3.getRectangle().y + calc3.getRectangle().height, 0x4244A800); - } else if (bool && calc3.getRectangle().contains((relMousex0-5 -offsetX) * scale , (relMousey0 - 5 - offsetY) * scale)) { + } else if (bool && calc3.getRectangle().contains((relMousex0-5 -offsetX) / scale , (relMousey0 - 5 - offsetY) / scale)) { for (StyledTextRenderer.StyleTextAssociated calc2 : calc) { if (calc2.getStyledText().getGroup().equals(calc3.getStyledText().getGroup())) Gui.drawRect(calc2.getRectangle().x, calc2.getRectangle().y, calc2.getRectangle().x + calc2.getRectangle().width, calc2.getRectangle().y + calc2.getRectangle().height, 0x55777777); @@ -166,7 +166,7 @@ public class PanelTextParameterConfig extends MPanel { boolean found = false; List<StyledTextRenderer.StyleTextAssociated> calc = StyledTextRenderer.calculate(texts, 0,0, styles); for (StyledTextRenderer.StyleTextAssociated calc3: calc) { - if (calc3.getRectangle().contains((relMouseX-5 -offsetX) * scale , (relMouseY - 5 - offsetY) * scale)) { + if (calc3.getRectangle().contains((relMouseX-5 -offsetX) / scale , (relMouseY - 5 - offsetY) / scale)) { if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) { if (!selected.contains(calc3.getStyledText().getGroup())) selected.add(calc3.getStyledText().getGroup()); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/TextUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/TextUtils.java index a7b4a598..7b853be4 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/utils/TextUtils.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/utils/TextUtils.java @@ -36,7 +36,6 @@ public class TextUtils { } - private static final TreeMap<Long, String> suffixes = new TreeMap<Long, String>(); static { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/XPUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/XPUtils.java new file mode 100644 index 00000000..9ac8ef09 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/utils/XPUtils.java @@ -0,0 +1,189 @@ +package kr.syeyoung.dungeonsguide.utils; + +import kr.syeyoung.dungeonsguide.features.impl.party.api.Skill; +import lombok.Data; + +import java.util.Map; +import java.util.TreeMap; + +public class XPUtils { + @Data + public static class XPCalcResult { + private int level; + private double remainingXp; + private double nextLvXp; + } + + private static TreeMap<Double, Integer> catacombXp = new TreeMap<>(); + private static TreeMap<Double, Integer> skillXp = new TreeMap<>(); + private static TreeMap<Double, Integer> skillXp2 = new TreeMap<>(); + static { + catacombXp.put(50.0, 1); + catacombXp.put(125.0, 2); + catacombXp.put(235.0, 3); + catacombXp.put(395.0, 4); + catacombXp.put(625.0, 5); + catacombXp.put(955.0, 6); + catacombXp.put(1425.0, 7); + catacombXp.put(2095.0, 8); + catacombXp.put(3045.0, 9); + catacombXp.put(4385.0, 10); + catacombXp.put(6275.0, 11); + catacombXp.put(8940.0, 12); + catacombXp.put(12700.0, 13); + catacombXp.put(17960.0, 14); + catacombXp.put(25340.0, 15); + catacombXp.put(35640.0, 16); + catacombXp.put(50040.0, 17); + catacombXp.put(70040.0, 18); + catacombXp.put(97640.0, 19); + catacombXp.put(135640.0, 20); + catacombXp.put(188140.0, 21); + catacombXp.put(259640.0, 22); + catacombXp.put(356640.0, 23); + catacombXp.put(488640.0, 24); + catacombXp.put(668640.0, 25); + catacombXp.put(911640.0, 26); + catacombXp.put(1239640.0, 27); + catacombXp.put(1684640.0, 28); + catacombXp.put(2284640.0, 29); + catacombXp.put(3084640.0, 30); + catacombXp.put(4149640.0, 31); + catacombXp.put(5559640.0, 32); + catacombXp.put(7459640.0, 33); + catacombXp.put(9959640.0, 34); + catacombXp.put(13259640.0, 35); + catacombXp.put(17559640.0, 36); + catacombXp.put(23159640.0, 37); + catacombXp.put(30359640.0, 38); + catacombXp.put(39559640.0, 39); + catacombXp.put(51559640.0, 40); + catacombXp.put(66559640.0, 41); + catacombXp.put(85559640.0, 42); + catacombXp.put(109559640.0, 43); + catacombXp.put(139559640.0, 44); + catacombXp.put(177559640.0, 45); + catacombXp.put(225559640.0, 46); + catacombXp.put(285559640.0, 47); + catacombXp.put(360559640.0, 48); + catacombXp.put(453559640.0, 49); + catacombXp.put(569809640.0, 50); + skillXp.put(0.0, 0); + skillXp.put(50.0, 1); + skillXp.put(175.0, 2); + skillXp.put(375.0, 3); + skillXp.put(675.0, 4); + skillXp.put(1175.0, 5); + skillXp.put(1925.0, 6); + skillXp.put(2925.0, 7); + skillXp.put(4425.0, 8); + skillXp.put(6425.0, 9); + skillXp.put(9925.0, 10); + skillXp.put(14925.0, 11); + skillXp.put(22425.0, 12); + skillXp.put(32425.0, 13); + skillXp.put(47425.0, 14); + skillXp.put(67425.0, 15); + skillXp.put(97425.0, 16); + skillXp.put(147425.0, 17); + skillXp.put(222425.0, 18); + skillXp.put(322425.0, 19); + skillXp.put(522425.0, 20); + skillXp.put(822425.0, 21); + skillXp.put(1222425.0, 22); + skillXp.put(1722425.0, 23); + skillXp.put(2322425.0, 24); + skillXp.put(3022425.0, 25); + skillXp.put(3822425.0, 26); + skillXp.put(4722425.0, 27); + skillXp.put(5722425.0, 28); + skillXp.put(6822425.0, 29); + skillXp.put(8022425.0, 30); + skillXp.put(9322425.0, 31); + skillXp.put(10722425.0, 32); + skillXp.put(12222425.0, 33); + skillXp.put(13722425.0, 34); + skillXp.put(15522425.0, 35); + skillXp.put(17322425.0, 36); + skillXp.put(19222425.0, 37); + skillXp.put(21222425.0, 38); + skillXp.put(23322425.0, 39); + skillXp.put(25522425.0, 40); + skillXp.put(27822425.0, 41); + skillXp.put(30222425.0, 42); + skillXp.put(32722425.0, 43); + skillXp.put(35322425.0, 44); + skillXp.put(38072425.0, 45); + skillXp.put(40972425.0, 46); + skillXp.put(44072425.0, 47); + skillXp.put(47472425.0, 48); + skillXp.put(51172425.0, 49); + skillXp.put(55172425.0, 50); + skillXp.put(59472425.0, 51); + skillXp.put(64072425.0, 52); + skillXp.put(68972425.0, 53); + skillXp.put(74172425.0, 54); + skillXp.put(79672425.0, 55); + skillXp.put(85472425.0, 56); + skillXp.put(91572425.0, 57); + skillXp.put(97972425.0, 58); + skillXp.put(104672425.0, 59); + skillXp.put(111672425.0, 60); + skillXp2.put(0.0, 0); + skillXp2.put(50.0, 1); + skillXp2.put(150.0, 2); + skillXp2.put(275.0, 3); + skillXp2.put(435.0, 4); + skillXp2.put(635.0, 5); + skillXp2.put(885.0, 6); + skillXp2.put(1200.0, 7); + skillXp2.put(1600.0, 8); + skillXp2.put(2100.0, 9); + skillXp2.put(2725.0, 10); + skillXp2.put(3510.0, 11); + skillXp2.put(4510.0, 12); + skillXp2.put(5760.0, 13); + skillXp2.put(7324.0, 14); + skillXp2.put(9325.0, 15); + skillXp2.put(11825.0, 16); + skillXp2.put(14950.0, 17); + skillXp2.put(18950.0, 18); + skillXp2.put(23950.0, 19); + skillXp2.put(30200.0, 20); + skillXp2.put(38050.0, 21); + skillXp2.put(47850.0, 22); + skillXp2.put(60100.0, 23); + skillXp2.put(75400.0, 24); + skillXp2.put(94450.0, 25); + } + + public static XPCalcResult getCataXp(double totalXp) { + Map.Entry<Double, Integer> totalXpEn = catacombXp.floorEntry(totalXp); + XPCalcResult xpCalcResult = new XPCalcResult(); + xpCalcResult.level = totalXpEn.getValue(); + xpCalcResult.remainingXp = totalXp - totalXpEn.getKey(); + Map.Entry<Double, Integer> asdasd = catacombXp.ceilingEntry(totalXp); + xpCalcResult.nextLvXp = asdasd == null ? 0 : asdasd.getKey(); + return xpCalcResult; + } + public static XPCalcResult getSkillXp(Skill skill, double totalXp) { + switch(skill) { + case RUNECRAFTING: + Map.Entry<Double, Integer> totalXpEn = skillXp2.floorEntry(totalXp); + XPCalcResult xpCalcResult = new XPCalcResult(); + xpCalcResult.level = totalXpEn.getValue(); + xpCalcResult.remainingXp = totalXp - totalXpEn.getKey(); + Map.Entry<Double, Integer> asdasd = skillXp2.ceilingEntry(totalXp); + xpCalcResult.nextLvXp = asdasd == null ? 0 : asdasd.getKey(); + return xpCalcResult; + default: + totalXpEn = skillXp.floorEntry(totalXp); + xpCalcResult = new XPCalcResult(); + xpCalcResult.level = totalXpEn.getValue(); + xpCalcResult.remainingXp = totalXp - totalXpEn.getKey(); + asdasd = skillXp.ceilingEntry(totalXp); + xpCalcResult.nextLvXp = asdasd == null ? 0 : asdasd.getKey(); + return xpCalcResult; + } + } +} |