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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
/*
* 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.dungeon;
import kr.syeyoung.dungeonsguide.SkyblockStatus;
import kr.syeyoung.dungeonsguide.config.types.AColor;
import kr.syeyoung.dungeonsguide.dungeon.DungeonContext;
import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom;
import kr.syeyoung.dungeonsguide.DungeonsGuide;
import kr.syeyoung.dungeonsguide.features.text.StyledText;
import kr.syeyoung.dungeonsguide.features.text.TextHUDFeature;
import kr.syeyoung.dungeonsguide.features.text.TextStyle;
import kr.syeyoung.dungeonsguide.utils.TextUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.network.NetworkPlayerInfo;
import net.minecraft.scoreboard.ScorePlayerTeam;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class FeatureDungeonSecrets extends TextHUDFeature {
public FeatureDungeonSecrets() {
super("Dungeon.Dungeon Information", "Display Total # of Secrets", "Display how much total secrets have been found in a dungeon run.\n+ sign means DG does not know the correct number, but it's somewhere above that number.", "dungeon.stats.secrets", true, getFontRenderer().getStringWidth("Secrets: 999/999+ of 999+"), getFontRenderer().FONT_HEIGHT);
this.setEnabled(false);
getStyles().add(new TextStyle("title", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false));
getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false));
getStyles().add(new TextStyle("currentSecrets", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false));
getStyles().add(new TextStyle("separator2", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false));
getStyles().add(new TextStyle("totalSecrets", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false));
getStyles().add(new TextStyle("unknown", new AColor(0xFF, 0xFF,0x55,255), new AColor(0, 0,0,0), false));
}
SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus();
public int getSecretsFound() {
for (NetworkPlayerInfo networkPlayerInfoIn : Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()) {
String name = networkPlayerInfoIn.getDisplayName() != null ? networkPlayerInfoIn.getDisplayName().getFormattedText() : ScorePlayerTeam.formatPlayerName(networkPlayerInfoIn.getPlayerTeam(), networkPlayerInfoIn.getGameProfile().getName());
if (name.startsWith("§r Secrets Found: §r§b") && !name.contains("%")) {
String noColor = TextUtils.stripColor(name);
return Integer.parseInt(noColor.substring(16));
}
}
return 0;
}
public double getSecretPercentage() {
for (NetworkPlayerInfo networkPlayerInfoIn : Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()) {
String name = networkPlayerInfoIn.getDisplayName() != null ? networkPlayerInfoIn.getDisplayName().getFormattedText() : ScorePlayerTeam.formatPlayerName(networkPlayerInfoIn.getPlayerTeam(), networkPlayerInfoIn.getGameProfile().getName());
if (name.startsWith("§r Secrets Found: §r") && name.contains("%")) {
String noColor = TextUtils.stripColor(name);
return Double.parseDouble(noColor.substring(16).replace("%", ""));
}
}
return 0;
}
public int getTotalSecretsInt() {
if (getSecretsFound() != 0) return (int) Math.ceil (getSecretsFound() / getSecretPercentage() * 100);
DungeonContext context = skyblockStatus.getContext();
int totalSecrets = 0;
for (DungeonRoom dungeonRoom : context.getDungeonRoomList()) {
if (dungeonRoom.getTotalSecrets() != -1)
totalSecrets += dungeonRoom.getTotalSecrets();
}
return totalSecrets;
}
public boolean sureOfTotalSecrets() {
if (getSecretsFound() != 0) return true;
DungeonContext context = skyblockStatus.getContext();
if (context.getMapProcessor().getUndiscoveredRoom() > 0) return false;
boolean allknown = true;
for (DungeonRoom dungeonRoom : context.getDungeonRoomList()) {
if (dungeonRoom.getTotalSecrets() == -1) allknown = false;
}
return allknown;
}
public String getTotalSecrets() {
DungeonContext context = skyblockStatus.getContext();
if (context == null) return "?";
int totalSecrets = 0;
boolean allknown = true;
for (DungeonRoom dungeonRoom : context.getDungeonRoomList()) {
if (dungeonRoom.getTotalSecrets() != -1)
totalSecrets += dungeonRoom.getTotalSecrets();
else allknown = false;
}
return totalSecrets + (allknown ? "":"+");
}
private static final java.util.List<StyledText> dummyText= new ArrayList<StyledText>();
static {
dummyText.add(new StyledText("Secrets","title"));
dummyText.add(new StyledText(": ","separator"));
dummyText.add(new StyledText("999","currentSecrets"));
dummyText.add(new StyledText("/","separator2"));
dummyText.add(new StyledText("2","totalSecrets"));
dummyText.add(new StyledText("+","unknown"));
}
@Override
public boolean isHUDViewable() {
return skyblockStatus.isOnDungeon();
}
@Override
public java.util.List<String> getUsedTextStyle() {
return Arrays.asList("title", "separator", "currentSecrets", "separator2", "totalSecrets", "unknown");
}
@Override
public java.util.List<StyledText> getDummyText() {
return dummyText;
}
@Override
public java.util.List<StyledText> getText() {
List<StyledText> actualBit = new ArrayList<StyledText>();
actualBit.add(new StyledText("Secrets","title"));
actualBit.add(new StyledText(": ","separator"));
actualBit.add(new StyledText(getSecretsFound() +"","currentSecrets"));
actualBit.add(new StyledText("/","separator2"));
actualBit.add(new StyledText((int)Math.ceil(getTotalSecretsInt() * DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getContext().getSecretPercentage())+" of "+getTotalSecretsInt(),"totalSecrets"));
actualBit.add(new StyledText(getTotalSecrets().contains("+") ? "+" : "","unknown"));
return actualBit;
}
}
|