From f54b267b337dee36fc9997abd1193393db11878e Mon Sep 17 00:00:00 2001 From: syeyoung Date: Sun, 25 Apr 2021 17:31:37 +0900 Subject: oh wat --- .../commands/CommandDungeonsGuide.java | 11 +- .../guiconfig/PanelDefaultParameterConfig.java | 3 + .../dungeonsguide/config/types/TCStringList.java | 34 ++ .../config/types/TypeConverterRegistry.java | 1 + .../dungeonsguide/features/FeatureRegistry.java | 2 +- .../impl/party/FeatureViewPlayerOnJoin.java | 295 --------------- .../features/impl/party/api/ApiFetchur.java | 7 + .../features/impl/party/api/DungeonClass.java | 8 +- .../impl/party/playerpreview/DataRenderer.java | 9 + .../party/playerpreview/DataRendererEditor.java | 14 + .../party/playerpreview/DataRendererRegistry.java | 17 + .../playerpreview/FeatureViewPlayerOnJoin.java | 399 +++++++++++++++++++++ .../features/text/PanelTextParameterConfig.java | 4 +- .../kr/syeyoung/dungeonsguide/utils/TextUtils.java | 1 - .../kr/syeyoung/dungeonsguide/utils/XPUtils.java | 189 ++++++++++ 15 files changed, 680 insertions(+), 314 deletions(-) create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/types/TCStringList.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/FeatureViewPlayerOnJoin.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRenderer.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererEditor.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererRegistry.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/FeatureViewPlayerOnJoin.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/utils/XPUtils.java (limited to 'src/main/java/kr') 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> { + @Override + public String getTypeString() { + return "stringlist"; + } + + @Override + public List deserialize(JsonElement element) { + List strList = new ArrayList<>(); + for (JsonElement jsonElement : element.getAsJsonArray()) { + strList.add(jsonElement.getAsString()); + } + return strList; + } + + @Override + public JsonElement serialize(List 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/FeatureViewPlayerOnJoin.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/FeatureViewPlayerOnJoin.java deleted file mode 100644 index ceaaec84..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/FeatureViewPlayerOnJoin.java +++ /dev/null @@ -1,295 +0,0 @@ -package kr.syeyoung.dungeonsguide.features.impl.party; - -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.FeatureEditPane; -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.listener.ChatListener; -import kr.syeyoung.dungeonsguide.features.listener.GuiPostRenderListener; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import lombok.Getter; -import lombok.Setter; -import lombok.SneakyThrows; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.AbstractClientPlayer; -import net.minecraft.client.entity.EntityOtherPlayerMP; -import net.minecraft.client.gui.*; -import net.minecraft.client.gui.inventory.GuiInventory; -import net.minecraft.client.network.NetworkPlayerInfo; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.OpenGlHelper; -import net.minecraft.client.renderer.texture.TextureManager; -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.util.*; -import net.minecraft.world.World; -import net.minecraftforge.client.event.ClientChatReceivedEvent; -import net.minecraftforge.client.event.GuiScreenEvent; -import net.minecraftforge.fml.common.Loader; -import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.GL11; - -import java.awt.*; -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 FeatureViewPlayerOnJoin() { - super("Party Kicker", "View player stats when join", "view player rendering when joining/someone joins the party", "partykicker.viewstats", true); - } - - private Rectangle popupRect; - private String lastuid; // actually current uid - private Future> profileFuture; - private Future> gfFuture; - private Future skinFuture; - private FakePlayer fakePlayer; - @SneakyThrows - @Override - public void onGuiPostRender(GuiScreenEvent.DrawScreenEvent.Post rendered) { - if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChat)) { - popupRect = null; - profileFuture = null; - gfFuture = null; - skinFuture= null; - fakePlayer= null; - return; - } - 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; - - IChatComponent ichatcomponent = getHoveredComponent(scaledResolution); - String uid = null; - if (ichatcomponent != null && ichatcomponent.getChatStyle().getChatHoverEvent() instanceof HoverEventRenderPlayer) { - uid = ((HoverEventRenderPlayer) ichatcomponent.getChatStyle().getChatHoverEvent()).getUuid(); - } - - if (!((popupRect != null && popupRect.contains(mouseX, mouseY)) || uid != null && uid.equals(lastuid))) { - popupRect = null; - profileFuture = null; - lastuid = null; - gfFuture = null; - skinFuture= null; - fakePlayer= null; - } - - if (uid != null && !uid.equals(lastuid) && (popupRect==null || !popupRect.contains(mouseX, mouseY))) { - popupRect = null; - profileFuture = null; - gfFuture = null; - skinFuture= null; - fakePlayer= null; - lastuid = uid; - } - if (lastuid == null) return; - - - if (popupRect == null) { - popupRect = new Rectangle(mouseX, mouseY, 150, 200); - 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); - } - if (skinFuture == null && gfFuture.isDone()) { - skinFuture = SkinFetchur.getSkinSet(gfFuture.get().orElse(null)); - } - - if (fakePlayer == null && skinFuture != null && profileFuture != null && skinFuture.isDone() && profileFuture.isDone()) { - fakePlayer = new FakePlayer(gfFuture.get().orElse(null), skinFuture.get(), profileFuture.get().orElse(null)); - } - - - render(popupRect, scaledResolution, mouseX, mouseY, profileFuture.isDone() ? profileFuture.get() : null); - } - - public void render(Rectangle popupRect, ScaledResolution scaledResolution, int mouseX, int mouseY, Optional playerProfile) { - - 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); - 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; - } - - - 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; - 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); - - int relX = mouseX - popupRect.x; - int relY = mouseY - popupRect.y; - ItemStack toHover = null; - System.out.println(relX + " , "+relY); - if (relX > 5 && relX < 75) { - if (33<=relY && relY <= 66) { - toHover = fakePlayer.getInventory()[3]; - } else if (66 <= relY && relY <= 108) { - toHover = fakePlayer.getInventory()[2]; - } else if (108 <= relY && relY <= 130) { - toHover = fakePlayer.getInventory()[1]; - } else if (130 <= relY && relY <= 154) { - toHover = fakePlayer.getInventory()[0]; - } - } - - if (toHover != null) { - List list = toHover.getTooltip(Minecraft.getMinecraft().thePlayer, Minecraft.getMinecraft().gameSettings.advancedItemTooltips); - - for (int i = 0; i < list.size(); ++i) - { - if (i == 0) - { - list.set(i, toHover.getRarity().rarityColor + (String)list.get(i)); - } - 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); - } - } else { - fr.drawString("Loading", 5,35, 0xFFEFFF00); - } - - GL11.glDisable(GL11.GL_SCISSOR_TEST); - GlStateManager.popMatrix(); // 33 66 108 130 154 // 5 75 - } - - public IChatComponent getHoveredComponent(ScaledResolution scaledResolution) { - IChatComponent ichatcomponent = null; - if (Loader.isModLoaded("hychat")) { - try { - ChatManager chatManager = HyChat.getInstance().getChatManager(); - GuiChatBox guiChatBox = chatManager.getFocusedChat(); - - int x = guiChatBox.getX(scaledResolution); - int y = guiChatBox.getY(scaledResolution); - ichatcomponent = guiChatBox.chatArray.getHoveredComponent(guiChatBox.getSelectedTab().getChatLines(), Mouse.getX(), Mouse.getY(), x, y); - } catch (Throwable t) {} - } - if (ichatcomponent == null) { - ichatcomponent = Minecraft.getMinecraft().ingameGUI.getChatGUI().getChatComponent(Mouse.getX(), Mouse.getY()); - } - return ichatcomponent; - } - - @Override - public void onChat(ClientChatReceivedEvent clientChatReceivedEvent) { - } - - public static class HoverEventRenderPlayer extends HoverEvent { - @Getter - private String uuid; - public HoverEventRenderPlayer(String uuid) { - super(Action.SHOW_TEXT, new ChatComponentText("")); - this.uuid = uuid; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - if (!super.equals(o)) return false; - HoverEventRenderPlayer that = (HoverEventRenderPlayer) o; - return Objects.equals(uuid, that.uuid); - } - - @Override - public int hashCode() { - return Objects.hash(super.hashCode(), uuid); - } - - private IChatComponent cached; - - @Override - public IChatComponent getValue() { - if (cached == null) - return cached = new ChatComponentText("").setChatStyle(new ChatStyle().setChatHoverEvent(new HoverEvent(Action.SHOW_TEXT, new ChatComponentText(uuid)))); - return cached; - } - } - - public static class FakePlayer extends EntityOtherPlayerMP { - @Setter - @Getter - private PlayerProfile skyblockProfile; - private SkinFetchur.SkinSet skinSet; - private PlayerProfile.Armor armor; - private FakePlayer(World w) { - super(w, null); - throw new UnsupportedOperationException("what"); - } - public FakePlayer(GameProfile playerProfile, SkinFetchur.SkinSet skinSet, PlayerProfile skyblockProfile) { - super(Minecraft.getMinecraft().theWorld, playerProfile); - this.skyblockProfile = skyblockProfile; - this.skinSet = skinSet; - armor= skyblockProfile.getCurrentArmor(); - this.inventory.armorInventory = skyblockProfile.getCurrentArmor().getArmorSlots(); - } - - public String getSkinType() { - return this.skinSet == null ? DefaultPlayerSkin.getSkinType(getGameProfile().getId()) : this.skinSet.getSkinType(); - } - - public ResourceLocation getLocationSkin() { - return com.google.common.base.Objects.firstNonNull(skinSet.getSkinLoc(), DefaultPlayerSkin.getDefaultSkin(getGameProfile().getId())); - } - - public ResourceLocation getLocationCape() { - return skinSet.getCapeLoc(); - } - - @Override - public ItemStack[] getInventory() { - return this.inventory.armorInventory; - } - } -} 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 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 dataRendererMap = new HashMap<>(); + + public static DataRenderer getDataRenderer(String id) { + return dataRendererMap.get(id); + } + + public static Set getValidDataRenderer() { + return dataRendererMap.keySet(); + } +} 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 new file mode 100644 index 00000000..effbf35e --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/FeatureViewPlayerOnJoin.java @@ -0,0 +1,399 @@ +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.*; +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; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.AbstractClientPlayer; +import net.minecraft.client.entity.EntityOtherPlayerMP; +import net.minecraft.client.gui.*; +import net.minecraft.client.gui.inventory.GuiInventory; +import net.minecraft.client.network.NetworkPlayerInfo; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.texture.TextureManager; +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; +import net.minecraftforge.client.event.GuiScreenEvent; +import net.minecraftforge.fml.common.Loader; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.GL11; + +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 Kicker", "View player stats when join", "view player rendering when joining/someone joins the party", "partykicker.viewstats", true); + this.parameters.put("datarenderers", new FeatureParameter>("datarenderers", "DataRenderers","Datarenderssdasd", new ArrayList<>(), "stringlist")); + } + + private Rectangle popupRect; + private String lastuid; // actually current uid + private Future> profileFuture; + private Future> gfFuture; + private Future skinFuture; + private FakePlayer fakePlayer; + @SneakyThrows + @Override + public void onGuiPostRender(GuiScreenEvent.DrawScreenEvent.Post rendered) { + if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChat)) { + popupRect = null; + profileFuture = null; + gfFuture = null; + skinFuture= null; + fakePlayer= null; + return; + } + 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; + + IChatComponent ichatcomponent = getHoveredComponent(scaledResolution); + String uid = null; + if (ichatcomponent != null && ichatcomponent.getChatStyle().getChatHoverEvent() instanceof HoverEventRenderPlayer) { + uid = ((HoverEventRenderPlayer) ichatcomponent.getChatStyle().getChatHoverEvent()).getUuid(); + } + + if (!((popupRect != null && popupRect.contains(mouseX, mouseY)) || uid != null && uid.equals(lastuid))) { + popupRect = null; + profileFuture = null; + lastuid = null; + gfFuture = null; + skinFuture= null; + fakePlayer= null; + } + + if (uid != null && !uid.equals(lastuid) && (popupRect==null || !popupRect.contains(mouseX, mouseY))) { + popupRect = null; + profileFuture = null; + gfFuture = null; + skinFuture= null; + fakePlayer= null; + lastuid = uid; + } + if (lastuid == null) return; + + + if (popupRect == null) { + popupRect = new Rectangle(mouseX, mouseY, 190, 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); + } + if (skinFuture == null && gfFuture.isDone()) { + skinFuture = SkinFetchur.getSkinSet(gfFuture.get().orElse(null)); + } + + if (fakePlayer == null && skinFuture != null && profileFuture != null && skinFuture.isDone() && profileFuture.isDone()) { + fakePlayer = new FakePlayer(gfFuture.get().orElse(null), skinFuture.get(), profileFuture.get().orElse(null)); + } + + + render(popupRect, scaledResolution, mouseX, mouseY, profileFuture.isDone() ? profileFuture.get() : null); + } + + public void render(Rectangle popupRect, ScaledResolution scaledResolution, int mouseX, int mouseY, Optional playerProfile) { + + 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); + 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); + MPanel.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); + 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.>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(45, 150, 60, -(mouseX - popupRect.x - 75), 0, fakePlayer); + fr.drawString(fakePlayer.getName(), (90 - fr.getStringWidth(fakePlayer.getName())) / 2, 15, 0xFFEFFF00); + + ItemStack toHover = null; + if (relX > 20 && relX < 70) { + if (33<=relY && relY <= 66) { + toHover = fakePlayer.getInventory()[3]; + } else if (66 <= relY && relY <= 108) { + toHover = fakePlayer.getInventory()[2]; + } else if (108 <= relY && relY <= 130) { + toHover = fakePlayer.getInventory()[1]; + } 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 list = toHover.getTooltip(Minecraft.getMinecraft().thePlayer, Minecraft.getMinecraft().gameSettings.advancedItemTooltips); + for (int i = 0; i < list.size(); ++i) { + if (i == 0) { + list.set(i, toHover.getRarity().rarityColor + (String)list.get(i)); + } else { + list.set(i, EnumChatFormatting.GRAY + (String)list.get(i)); + } + } + FontRenderer font = toHover.getItem().getFontRenderer(toHover); + 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); + } + } else { + fr.drawString("Loading", 5,35, 0xFFEFFF00); + } + + 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; + if (Loader.isModLoaded("hychat")) { + try { + ChatManager chatManager = HyChat.getInstance().getChatManager(); + GuiChatBox guiChatBox = chatManager.getFocusedChat(); + + int x = guiChatBox.getX(scaledResolution); + int y = guiChatBox.getY(scaledResolution); + ichatcomponent = guiChatBox.chatArray.getHoveredComponent(guiChatBox.getSelectedTab().getChatLines(), Mouse.getX(), Mouse.getY(), x, y); + } catch (Throwable t) {} + } + if (ichatcomponent == null) { + ichatcomponent = Minecraft.getMinecraft().ingameGUI.getChatGUI().getChatComponent(Mouse.getX(), Mouse.getY()); + } + return ichatcomponent; + } + + @Override + public void onChat(ClientChatReceivedEvent clientChatReceivedEvent) { + } + + + public static class HoverEventRenderPlayer extends HoverEvent { + @Getter + private String uuid; + public HoverEventRenderPlayer(String uuid) { + super(Action.SHOW_TEXT, new ChatComponentText("")); + this.uuid = uuid; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + HoverEventRenderPlayer that = (HoverEventRenderPlayer) o; + return Objects.equals(uuid, that.uuid); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), uuid); + } + + private IChatComponent cached; + + @Override + public IChatComponent getValue() { + if (cached == null) + return cached = new ChatComponentText("").setChatStyle(new ChatStyle().setChatHoverEvent(new HoverEvent(Action.SHOW_TEXT, new ChatComponentText(uuid)))); + return cached; + } + } + + public static class FakePlayer extends EntityOtherPlayerMP { + @Setter + @Getter + private PlayerProfile skyblockProfile; + private SkinFetchur.SkinSet skinSet; + private PlayerProfile.Armor armor; + private FakePlayer(World w) { + super(w, null); + throw new UnsupportedOperationException("what"); + } + public FakePlayer(GameProfile playerProfile, SkinFetchur.SkinSet skinSet, PlayerProfile skyblockProfile) { + super(Minecraft.getMinecraft().theWorld, playerProfile); + this.skyblockProfile = skyblockProfile; + 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() { + return this.skinSet == null ? DefaultPlayerSkin.getSkinType(getGameProfile().getId()) : this.skinSet.getSkinType(); + } + + public ResourceLocation getLocationSkin() { + return com.google.common.base.Objects.firstNonNull(skinSet.getSkinLoc(), DefaultPlayerSkin.getDefaultSkin(getGameProfile().getId())); + } + + public ResourceLocation getLocationCape() { + return skinSet.getCapeLoc(); + } + + @Override + public ItemStack[] getInventory() { + return this.inventory.armorInventory; + } + } + + + + @Override + public String getEditRoute(final GuiConfig config) { + ConfigPanelCreator.map.put("base." + getKey() , new Supplier() { + @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 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 suffixes = new TreeMap(); 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 catacombXp = new TreeMap<>(); + private static TreeMap skillXp = new TreeMap<>(); + private static TreeMap 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 totalXpEn = catacombXp.floorEntry(totalXp); + XPCalcResult xpCalcResult = new XPCalcResult(); + xpCalcResult.level = totalXpEn.getValue(); + xpCalcResult.remainingXp = totalXp - totalXpEn.getKey(); + Map.Entry 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 totalXpEn = skillXp2.floorEntry(totalXp); + XPCalcResult xpCalcResult = new XPCalcResult(); + xpCalcResult.level = totalXpEn.getValue(); + xpCalcResult.remainingXp = totalXp - totalXpEn.getKey(); + Map.Entry 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; + } + } +} -- cgit