1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
package kr.syeyoung.dungeonsguide.features.impl;
import kr.syeyoung.dungeonsguide.SkyblockStatus;
import kr.syeyoung.dungeonsguide.e;
import kr.syeyoung.dungeonsguide.events.DungeonEndedEvent;
import kr.syeyoung.dungeonsguide.features.FeatureParameter;
import kr.syeyoung.dungeonsguide.features.GuiFeature;
import kr.syeyoung.dungeonsguide.features.listener.*;
import kr.syeyoung.dungeonsguide.utils.TextUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.GlStateManager;
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 {
private SkyblockStatus skyblockStatus = e.getDungeonsGuide().getSkyblockStatus();
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"));
}
@Override
public void drawHUD(float partialTicks) {
if (!skyblockStatus.isOnDungeon()) return;
FontRenderer fr = getFontRenderer();
double scale = getFeatureRect().getHeight() / fr.FONT_HEIGHT;
GlStateManager.scale(scale, scale, 0);
Scoreboard scoreboard = Minecraft.getMinecraft().theWorld.getScoreboard();
ScoreObjective objective = scoreboard.getObjectiveInDisplaySlot(1);
Collection<Score> scores = scoreboard.getSortedScores(objective);
String time = "unknown";
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;
GlStateManager.scale(scale, scale, 0);
fr.drawString("Time(Ig): -42h", 0,0, this.<Color>getParameter("color").getValue().getRGB());
}
}
|