Skip to content

Commit d9e4644

Browse files
committed
Lots of suggestions done, and some bug fixes.
1 parent 8581638 commit d9e4644

File tree

18 files changed

+261
-80
lines changed

18 files changed

+261
-80
lines changed

src/main/java/llc/redstone/hysentials/command/HysentialsCommand.java

Lines changed: 129 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import cc.polyfrost.oneconfig.libs.universal.wrappers.message.UTextComponent;
55
import cc.polyfrost.oneconfig.utils.Multithreading;
66
import cc.polyfrost.oneconfig.utils.NetworkUtils;
7+
import com.google.gson.JsonArray;
78
import llc.redstone.hysentials.Hysentials;
89
import llc.redstone.hysentials.HysentialsUtilsKt;
910
import llc.redstone.hysentials.config.HysentialsConfig;
@@ -147,6 +148,17 @@ public void processCommand(ICommandSender sender, String[] args) throws CommandE
147148
break;
148149
}
149150

151+
case "leaderboard": {
152+
//Types levels, quests, emeralds, settings
153+
if (args.length > 1) {
154+
String[] newArgs = Arrays.copyOfRange(args, 2, args.length);
155+
handleLeaderboard(args[1], newArgs);
156+
} else {
157+
UChat.chat(HysentialsConfig.chatPrefix + " §cYou must specify a type! Use /hysentials leaderboard <type> for a list of types.");
158+
}
159+
break;
160+
}
161+
150162
case "phone":
151163
case "menu": {
152164
UChat.chat(HysentialsConfig.chatPrefix + " §cComing soon!");
@@ -193,6 +205,94 @@ public void processCommand(ICommandSender sender, String[] args) throws CommandE
193205
}
194206
}
195207

208+
public static void handleLeaderboard(String command, String[] args) {
209+
switch (command) {
210+
case "levels": {
211+
Socket.user.sendWithAuth(
212+
"leaderboardLookup",
213+
"type", "levels"
214+
);
215+
Socket.awaiting.add(new DuoVariable<>("leaderboardLookup", HysentialsCommand::handleLeaderboardJson));
216+
break;
217+
}
218+
// case "quests": { Coming at some point
219+
// break;
220+
// }
221+
case "emeralds": {
222+
Socket.user.sendWithAuth(
223+
"leaderboardLookup",
224+
"type", "emeralds"
225+
);
226+
Socket.awaiting.add(new DuoVariable<>("leaderboardLookup", HysentialsCommand::handleLeaderboardJson));
227+
break;
228+
}
229+
case "settings": {
230+
if (args.length < 2) {
231+
UChat.chat(HysentialsConfig.chatPrefix + " §cYou must specify a setting to set! Use /hysentials leaderboard settings <setting> <value>");
232+
UChat.chat("§c - hide <true/false> (Hides you from the leaderboard)");
233+
return;
234+
}
235+
switch (args[1]) {
236+
case "hide": {
237+
if (args.length < 3) {
238+
UChat.chat(HysentialsConfig.chatPrefix + " §cYou must specify a value to set! Use /hysentials leaderboard settings hide <true/false>");
239+
return;
240+
}
241+
boolean hide = Boolean.parseBoolean(args[2]);
242+
Socket.user.sendWithAuth(
243+
"leaderboardSettings",
244+
new JSONObject().put("hide", hide)
245+
);
246+
UChat.chat(HysentialsConfig.chatPrefix + " §aSuccessfully set leaderboard setting!");
247+
break;
248+
}
249+
default: {
250+
UChat.chat(HysentialsConfig.chatPrefix + " §cUnknown setting! Use /hysentials leaderboard settings <setting> <value>");
251+
UChat.chat("§c - hide <true/false> (Hides you from the leaderboard)");
252+
break;
253+
}
254+
}
255+
break;
256+
}
257+
default: {
258+
UChat.chat(HysentialsConfig.chatPrefix + " §cUnknown leaderboard type! Use /hysentials leaderboard <level/emeralds/settings> for a list of types.");
259+
break;
260+
261+
}
262+
}
263+
}
264+
265+
public static void handleLeaderboardJson(JsonObject json) {
266+
UTextComponent text = new UTextComponent("");
267+
text.appendText("§9&m \n");
268+
text.appendText(ChatLib.getCenteredText("&6Leaderboard\n"));
269+
int page = 1; //Eventually this will be a variable
270+
if (json.has("levels")) {
271+
JsonArray levels = json.get("levels").getAsJsonArray();
272+
//10 elements per page
273+
int start = (page - 1) * 10;
274+
int end = Math.min(start + 10, levels.size());
275+
for (int i = start; i < end; i++) {
276+
JsonObject obj = levels.get(i).getAsJsonObject();
277+
text.appendText("&e" + (i + 1) + ". &7" + obj.get("username").getAsString() + " &8- &aLevel " + obj.get("level").getAsInt() + " &7(" + obj.get("xp").getAsInt() + " HEXP)\n");
278+
}
279+
} else if (json.has("emeralds")) {
280+
JsonArray emeralds = json.get("emeralds").getAsJsonArray();
281+
//10 elements per page
282+
int start = (page - 1) * 10;
283+
int end = Math.min(start + 10, emeralds.size());
284+
for (int i = start; i < end; i++) {
285+
JsonObject obj = emeralds.get(i).getAsJsonObject();
286+
text.appendText("&e" + (i + 1) + ". &7" + obj.get("username").getAsString() + " &8- &a" + obj.get("emeralds").getAsInt() + " &7Emeralds\n");
287+
}
288+
}
289+
if (json.get("count").getAsInt() - (page * 10) > 0) {
290+
text.appendText("&eAnd " + (json.get("count").getAsInt() - (page * 10)) + " more...\n");
291+
}
292+
text.appendText("§9&m ");
293+
text.chat();
294+
}
295+
196296
public static void handleImport(String id) {
197297
try {
198298
String codeToBeCompiled = null;
@@ -222,6 +322,13 @@ public static void handleImport(String id) {
222322
public void helpPage(int page) {
223323
UTextComponent text = new UTextComponent("");
224324
int maxPage = 3;
325+
if (page > maxPage) {
326+
UChat.chat(HysentialsConfig.chatPrefix + " §cInvalid page number max page number is " + maxPage + "! Use /hysentials help <page>");
327+
return;
328+
} else if (page < 1) {
329+
UChat.chat(HysentialsConfig.chatPrefix + " §cInvalid page number min page number is 1! Use /hysentials help <page>");
330+
return;
331+
}
225332
text.appendText("§9&m \n");
226333
switch (page) {
227334
case 1: {
@@ -237,7 +344,7 @@ public void helpPage(int page) {
237344
text.appendText("&e/hysentials online &7- &bShows the online players.\n");
238345
text.appendText("&e/hysentials menu &7- &bOpens the Hysentials menu.\n");
239346
text.appendText("&e/hysentials discord &7- &bShows the discord invite link.\n");
240-
text.appendText("&e/hysentials editor <file> &7- &bOpens the HTSL code editor.\n");
347+
text.appendText("&e/hysentials leaderboard <level/emeralds/settings> &7- Leaderboard.\n");
241348
text.appendText("§9&m ");
242349
break;
243350
}
@@ -270,7 +377,7 @@ public void helpPage(int page) {
270377
text.appendText("&e/sll <line> <value> &7- &bSet lore line.\n");
271378
text.appendText("&e/rename <name> &7- &bSet name on held item.\n");
272379
text.appendText("&e/openinv <player> &7- &bView the held item and armor of a player.\n");
273-
//2 more can be added here
380+
//1 more can be added here
274381
text.appendText("§9&m ");
275382
}
276383
}
@@ -427,29 +534,26 @@ private static void handleTest(String command, String args) {
427534
}
428535
}
429536

430-
public static List<MovingObjectPosition> getMouseOverExtended(float dist)
431-
{
537+
public static List<MovingObjectPosition> getMouseOverExtended(float dist) {
432538
List<MovingObjectPosition> mopReturn = new ArrayList<>();
433539
Minecraft mc = FMLClientHandler.instance().getClient();
434540
Entity theRenderViewEntity = mc.getRenderViewEntity();
435541
AxisAlignedBB theViewBoundingBox = new AxisAlignedBB(
436-
theRenderViewEntity.posX-0.5D,
437-
theRenderViewEntity.posY-0.0D,
438-
theRenderViewEntity.posZ-0.5D,
439-
theRenderViewEntity.posX+0.5D,
440-
theRenderViewEntity.posY+1.5D,
441-
theRenderViewEntity.posZ+0.5D
542+
theRenderViewEntity.posX - 0.5D,
543+
theRenderViewEntity.posY - 0.0D,
544+
theRenderViewEntity.posZ - 0.5D,
545+
theRenderViewEntity.posX + 0.5D,
546+
theRenderViewEntity.posY + 1.5D,
547+
theRenderViewEntity.posZ + 0.5D
442548
);
443549
MovingObjectPosition returnMOP = null;
444-
if (mc.theWorld != null)
445-
{
550+
if (mc.theWorld != null) {
446551
double var2 = dist;
447552
returnMOP = theRenderViewEntity.rayTrace(var2, 0);
448553
double calcdist = var2;
449554
Vec3 pos = theRenderViewEntity.getPositionEyes(0);
450555
var2 = calcdist;
451-
if (returnMOP != null)
452-
{
556+
if (returnMOP != null) {
453557
calcdist = returnMOP.hitVec.distanceTo(pos);
454558
}
455559

@@ -468,34 +572,28 @@ public static List<MovingObjectPosition> getMouseOverExtended(float dist)
468572
lookvec.zCoord * var2).expand(var9, var9, var9));
469573
double d = calcdist;
470574

471-
for (Entity entity : list)
472-
{
473-
if (entity.canBeCollidedWith())
474-
{
575+
for (Entity entity : list) {
576+
if (entity.canBeCollidedWith()) {
475577
float bordersize = entity.getCollisionBorderSize();
476578
AxisAlignedBB aabb = new AxisAlignedBB(
477-
entity.posX-entity.width/2,
579+
entity.posX - entity.width / 2,
478580
entity.posY,
479-
entity.posZ-entity.width/2,
480-
entity.posX+entity.width/2,
481-
entity.posY+entity.height,
482-
entity.posZ+entity.width/2);
581+
entity.posZ - entity.width / 2,
582+
entity.posX + entity.width / 2,
583+
entity.posY + entity.height,
584+
entity.posZ + entity.width / 2);
483585
aabb.expand(bordersize, bordersize, bordersize);
484586
MovingObjectPosition mop0 = aabb.calculateIntercept(pos, var8);
485587

486-
if (aabb.isVecInside(pos))
487-
{
488-
if (0.0D < d || d == 0.0D)
489-
{
588+
if (aabb.isVecInside(pos)) {
589+
if (0.0D < d || d == 0.0D) {
490590
mopReturn.add(new MovingObjectPosition(entity));
491591
d = 0.0D;
492592
}
493-
} else if (mop0 != null)
494-
{
593+
} else if (mop0 != null) {
495594
double d1 = pos.distanceTo(mop0.hitVec);
496595

497-
if (d1 < d || d == 0.0D)
498-
{
596+
if (d1 < d || d == 0.0D) {
499597
mopReturn.add(new MovingObjectPosition(entity));
500598
d = d1;
501599
}

src/main/java/llc/redstone/hysentials/config/hysentialmods/ChatConfig.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ public class ChatConfig extends Config {
5454
placeholder = ":partyprefix: "
5555
)
5656
public static String partyPrefix = ":partyprefix: ";
57+
@Text(
58+
name = "Party Chat Color",
59+
description = "The color for all party chat messages.",
60+
category = "Party",
61+
subcategory = "General",
62+
placeholder = "<#c0def5>"
63+
)
64+
public static String partyChatColor = "<#c0def5>";
5765

5866
@Switch(
5967
name = "Hide Lines",
@@ -88,6 +96,15 @@ public class ChatConfig extends Config {
8896
)
8997
public static String guildPrefix = ":guild: ";
9098

99+
@Text(
100+
name = "Guild Chat Color",
101+
description = "The color for all guild chat messages.",
102+
category = "Guild",
103+
subcategory = "General",
104+
placeholder = "<#c6f5c0>"
105+
)
106+
public static String guildChatColor = "<#c6f5c0>";
107+
91108
@Switch(
92109
name = "Player Guild Chat Prefix",
93110
description = "Enable/Disable player prefixes in guild chat.",

src/main/java/llc/redstone/hysentials/config/hysentialmods/HousingConfig.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ public class HousingConfig extends Config {
7373
)
7474
public static boolean housingNameScoreboard = true;
7575

76+
@Switch(
77+
name = "Housing Name Colors",
78+
category = "Housing",
79+
subcategory = "General",
80+
description = "Adds color to the housing name in the scoreboards title."
81+
)
82+
public static boolean housingNameColors = true;
83+
7684
@Switch(
7785
name = "Shift+Right Click OpenInv",
7886
category = "Housing",

src/main/java/llc/redstone/hysentials/guis/sbBoxes/huds/ActionBarHUD.java

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ protected void drawBackground(float x, float y, float width, float height, float
7575
int style = this.cornerType;
7676
switch (style) {
7777
case 0: {
78-
GlStateManager.pushMatrix();
79-
Renderer.drawRect(bgColor, x, y, width, height);
80-
GlStateManager.popMatrix();
78+
NanoVGHelper.INSTANCE.setupAndDraw(true, (vg) -> {
79+
NanoVGHelper.INSTANCE.drawRect(vg, x, y, width, height, bgColor);
80+
});
8181
break;
8282
}
8383
case 1: {
@@ -89,27 +89,13 @@ protected void drawBackground(float x, float y, float width, float height, float
8989
break;
9090
}
9191
case 2: {
92-
GlStateManager.pushMatrix();
93-
if (this.shadow) {
94-
SbbRenderer.drawBox(x, y, width, height, this.bgColor, this.shadowColor, (int) this.cornerRadius);
95-
} else {
96-
SbbRenderer.drawBox(x, y, width, height, this.bgColor, false, (int) this.cornerRadius);
97-
}
98-
GlStateManager.popMatrix();
92+
NanoVGHelper.INSTANCE.setupAndDraw(true, (vg) -> {
93+
SbbRenderer.drawBox(vg, x, y, width, height, this.bgColor, this.shadow, (int) this.cornerRadius);
94+
});
9995
}
10096
}
10197
}
10298

103-
@Override
104-
protected float getHeight(float scale, boolean example) {
105-
return super.getHeight(scale, example) + 5 * scale;
106-
}
107-
108-
@Override
109-
protected float getWidth(float scale, boolean example) {
110-
return super.getWidth(scale, example) + 10 * scale;
111-
}
112-
11399
@Override
114100
protected String getText(boolean example) {
115101
GuiIngameAccessor ingameGUI = (GuiIngameAccessor) UMinecraft.getMinecraft().ingameGUI;

src/main/java/llc/redstone/hysentials/guis/sbBoxes/huds/BossbarSbBoxHud.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public void draw(UMatrixStack matrices, float x, float y, float scale, boolean e
123123
protected float getWidth(float scale, boolean example) {
124124
float textWidth = this.renderText ? UMinecraft.getFontRenderer().getStringWidth(getText(example)) : 0.0f;
125125
float healthWidth = this.renderHealth ? BAR_WIDTH : 0.0f;
126-
return Math.max(textWidth, healthWidth) * scale + 10f * scale;
126+
return Math.max(textWidth, healthWidth) * scale + paddingX * scale * 2;
127127
}
128128

129129
@Override
@@ -142,6 +142,6 @@ protected float getHeight(float scale, boolean example) {
142142
height += 1.0F;
143143
}
144144

145-
return height * scale + 5.0F * scale;
145+
return height * scale + paddingY * scale * 2;
146146
}
147147
}

src/main/java/llc/redstone/hysentials/guis/sbBoxes/huds/HeldItemTooltipHUD.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,4 @@ protected String getText(boolean example) {
127127
}
128128
return "";
129129
}
130-
131-
@Override
132-
protected float getHeight(float scale, boolean example) {
133-
return super.getHeight(scale, example) + 5 * scale;
134-
}
135-
136-
@Override
137-
protected float getWidth(float scale, boolean example) {
138-
return super.getWidth(scale, example) + 10 * scale;
139-
}
140130
}

src/main/java/llc/redstone/hysentials/guis/sbBoxes/huds/SBBoxesTextHud.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,12 @@ protected float getWidth(float scale, boolean example) {
109109
for (String line : text.split("\n")) {
110110
width = Math.max(width, getLineWidth(line, scale));
111111
}
112-
return width;
112+
return width + paddingX * scale * 2;
113113
}
114114

115115
@Override
116116
protected float getHeight(float scale, boolean example) {
117-
return text == null ? 0 : (text.split("\n").length * 12 - 4) * scale;
117+
return text == null ? 0 : (text.split("\n").length * 12 - 4) * scale + paddingY * scale * 2;
118118
}
119119

120120
protected abstract String getText(boolean example);
@@ -170,4 +170,19 @@ public boolean shouldDrawBackground() {
170170
options = {"No Shadow", "Shadow", "Full Shadow"}
171171
)
172172
protected int textType = 0;
173+
174+
@Slider(
175+
name = "X-Padding",
176+
description = "The horizontal padding of the HUD.",
177+
min = 0,
178+
max = 10
179+
)
180+
protected float paddingX = 5f;
181+
@Slider(
182+
name = "Y-Padding",
183+
description = "The Vertical padding of the HUD.",
184+
min = 0,
185+
max = 10
186+
)
187+
protected float paddingY = 2.5f;
173188
}

0 commit comments

Comments
 (0)