diff options
author | syeyoung <cyong06@naver.com> | 2021-01-04 21:45:04 +0900 |
---|---|---|
committer | syeyoung <cyong06@naver.com> | 2021-01-04 21:45:04 +0900 |
commit | 04d414547e4d932f4db9a74dbc4aea8d75b96960 (patch) | |
tree | acfccab2803dc6161e4ce099021d2fa972967ace /src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureDungeonSBTime.java | |
parent | ece0af65a8bba6c722ac6f0853c570d2e8cad784 (diff) | |
download | Skyblock-Dungeons-Guide-04d414547e4d932f4db9a74dbc4aea8d75b96960.tar.gz Skyblock-Dungeons-Guide-04d414547e4d932f4db9a74dbc4aea8d75b96960.tar.bz2 Skyblock-Dungeons-Guide-04d414547e4d932f4db9a74dbc4aea8d75b96960.zip |
Various things
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureDungeonSBTime.java')
-rw-r--r-- | src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureDungeonSBTime.java | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureDungeonSBTime.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureDungeonSBTime.java new file mode 100644 index 00000000..65f06f58 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureDungeonSBTime.java @@ -0,0 +1,92 @@ +package kr.syeyoung.dungeonsguide.features.impl; + +import kr.syeyoung.dungeonsguide.SkyblockStatus; +import kr.syeyoung.dungeonsguide.e; +import kr.syeyoung.dungeonsguide.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.features.GuiFeature; +import kr.syeyoung.dungeonsguide.features.listener.ChatListener; +import kr.syeyoung.dungeonsguide.features.listener.TickListener; +import kr.syeyoung.dungeonsguide.utils.TextUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.scoreboard.Score; +import net.minecraft.scoreboard.ScoreObjective; +import net.minecraft.scoreboard.ScorePlayerTeam; +import net.minecraft.scoreboard.Scoreboard; +import net.minecraftforge.client.event.ClientChatReceivedEvent; +import org.lwjgl.opengl.GL11; + +import java.awt.*; +import java.util.Collection; + +public class FeatureDungeonSBTime extends GuiFeature implements TickListener { + public FeatureDungeonSBTime() { + super("Dungeon", "Display Ingame Dungeon Time", "Display how much time skyblock thinks has passed since dungeon run started", "dungeon.stats.igtime", true, getFontRenderer().getStringWidth("Time(IG): 1h 59m 59s"), getFontRenderer().FONT_HEIGHT); + this.setEnabled(false); + parameters.put("color", new FeatureParameter<Color>("color", "Color", "Color of text", Color.orange, "color")); + } + + private long started = -1; + @Override + public void drawHUD(float partialTicks) { + if (started == -1) return; + FontRenderer fr = getFontRenderer(); + double scale = getFeatureRect().getHeight() / fr.FONT_HEIGHT; + GL11.glScaled(scale, scale, 0); + Scoreboard scoreboard = Minecraft.getMinecraft().theWorld.getScoreboard(); + ScoreObjective objective = scoreboard.getObjectiveInDisplaySlot(1); + Collection<Score> scores = scoreboard.getSortedScores(objective); + String time = "idkyet"; + for (Score sc:scores) { + ScorePlayerTeam scorePlayerTeam = scoreboard.getPlayersTeam(sc.getPlayerName()); + String strippedLine = TextUtils.keepScoreboardCharacters(TextUtils.stripColor(ScorePlayerTeam.formatPlayerName(scorePlayerTeam, sc.getPlayerName()))).trim(); + if (strippedLine.startsWith("Time Elapsed: ")) { + time = strippedLine.substring(14); + } + } + fr.drawString("Time(Ig): "+time, 0,0, this.<Color>getParameter("color").getValue().getRGB()); + } + public int getTimeElapsed() { + Scoreboard scoreboard = Minecraft.getMinecraft().theWorld.getScoreboard(); + ScoreObjective objective = scoreboard.getObjectiveInDisplaySlot(1); + Collection<Score> scores = scoreboard.getSortedScores(objective); + String time = "idkyet"; + for (Score sc:scores) { + ScorePlayerTeam scorePlayerTeam = scoreboard.getPlayersTeam(sc.getPlayerName()); + String strippedLine = TextUtils.keepScoreboardCharacters(TextUtils.stripColor(ScorePlayerTeam.formatPlayerName(scorePlayerTeam, sc.getPlayerName()))).trim(); + if (strippedLine.startsWith("Time Elapsed: ")) { + time = strippedLine.substring(14); + } + } + time = time.replace(" ", ""); + int hour = time.indexOf('h') == -1 ? 0 : Integer.parseInt(time.substring(0, time.indexOf('h'))); + if (time.contains("h")) time = time.substring(time.indexOf('h') + 1); + int minute = time.indexOf('m') == -1 ? 0 : Integer.parseInt(time.substring(0, time.indexOf('m'))); + if (time.contains("m")) time = time.substring(time.indexOf('m') + 1); + int second = time.indexOf('s') == -1 ? 0 : Integer.parseInt(time.substring(0, time.indexOf('s'))); + + int time2 = hour * 60 * 60 + minute * 60 + second; + return time2 * 1000; + } + + @Override + public void drawDemo(float partialTicks) { + FontRenderer fr = getFontRenderer(); + double scale = getFeatureRect().getHeight() / fr.FONT_HEIGHT; + GL11.glScaled(scale, scale, 0); + + fr.drawString("Time(Ig): -42h", 0,0, this.<Color>getParameter("color").getValue().getRGB()); + } + + SkyblockStatus skyblockStatus = e.getDungeonsGuide().getSkyblockStatus(); + private boolean wasInDungeon = false; + @Override + public void onTick() { + if (wasInDungeon && !skyblockStatus.isOnDungeon()) { + if (skyblockStatus.isOnSkyblock()) started = -1; + } else if (!wasInDungeon && skyblockStatus.isOnDungeon()) { + started = System.currentTimeMillis(); + } + wasInDungeon = skyblockStatus.isOnDungeon(); + } +} |