Skip to content

Commit 8ddecfa

Browse files
committed
Fixed some bugs?
1 parent bff2c42 commit 8ddecfa

File tree

4 files changed

+30
-32
lines changed

4 files changed

+30
-32
lines changed

src/main/java/llc/redstone/hysentials/util/ImageIconRenderer.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ private void renderStringAtPosA(String text, boolean shadow) {
117117
}
118118
accessor.setTextColor(textColor);
119119
this.setColor((float) (textColor >> 16) / 255.0F, (float) (textColor >> 8 & 255) / 255.0F, (float) (textColor & 255) / 255.0F, accessor.alpha());
120-
i += 8;
120+
i += 8; //9?
121121
continue;
122122
}
123123
}
@@ -131,6 +131,7 @@ private void renderStringAtPosA(String text, boolean shadow) {
131131
if (num.matches("\\d+") && !num.isEmpty()) {
132132
this.posX += renderNumberedString(num, hex, (int) this.posX, (int) this.posY, textColor, shadow);
133133
i += hex.length() + num.length() + 2;
134+
//Is this supposed to be 3?
134135
continue;
135136
}
136137
}
@@ -569,10 +570,10 @@ public static String getFormatFromString(String text) {
569570

570571
while ((i = text.indexOf(167, i + 1)) != -1) {
571572
if (i < j - 1) {
572-
if (i + 3 < j - 1 && isFormatColor(text.charAt(i + 3))) {
573+
char c0 = text.charAt(i + 1);
574+
if (!isFormatColor(c0) && i + 3 < j - 1 && isFormatColor(text.charAt(i + 3))) {
573575
continue;
574576
}
575-
char c0 = text.charAt(i + 1);
576577
if (isFormatColor(c0)) {
577578
s = "§" + c0;
578579
} else if (isFormatSpecial(c0)) {

src/main/kotlin/llc/redstone/hysentials/cosmetic/CosmeticUtils.kt

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ import org.json.JSONObject
2020
import java.util.*
2121

2222
object CosmeticManager {
23-
var actions = mapOf(
24-
"equip" to mutableSetOf<String>(),
25-
"unequip" to mutableSetOf<String>(),
26-
"purchase" to mutableSetOf<String>()
23+
var actions = mutableListOf<Actions>()
24+
25+
data class Actions(
26+
var action: String,
27+
var name: String
2728
)
2829

2930
var previewing = mutableListOf<String>()
@@ -37,9 +38,9 @@ object CosmeticManager {
3738
it.equipped.remove(Minecraft.getMinecraft().thePlayer.uniqueID.toString())
3839
}
3940
if (preview) {
40-
previewing.remove(name)
41+
previewing.remove(it.name)
4142
} else {
42-
actions["unequip"]
43+
actions.add(Actions("unequip", it.name))
4344
}
4445
}
4546
}
@@ -51,17 +52,19 @@ object CosmeticManager {
5152
cosmetic?.let {
5253
if (BlockWAPIUtils.getCosmetic(it.type).isNotEmpty()) {
5354
BlockWAPIUtils.getCosmetic(it.type).forEach { cosmetic ->
54-
unEquipCosmetic(cosmetic.name)
55-
previewing.remove(cosmetic.name)
55+
if (cosmetic.equipped.contains(Minecraft.getMinecraft().thePlayer.uniqueID.toString())) {
56+
unEquipCosmetic(cosmetic.name)
57+
previewing.remove(cosmetic.name)
58+
}
5659
}
5760
}
5861
if (!it.equipped.contains(Minecraft.getMinecraft().thePlayer.uniqueID.toString())) {
5962
it.equipped.add(Minecraft.getMinecraft().thePlayer.uniqueID.toString())
6063
}
6164
if (preview) {
62-
previewing.add(name)
65+
previewing.add(it.name)
6366
} else {
64-
actions["equip"]?.add(name)
67+
actions.add(Actions("equip", it.name))
6568
}
6669
}
6770
}
@@ -89,34 +92,28 @@ object CosmeticManager {
8992
it.users.add(Minecraft.getMinecraft().thePlayer.uniqueID.toString())
9093
Socket.cachedUser.amountSpent = Socket.cachedUser.amountSpent?.plus(it.cost)
9194
Socket.cachedUser.emeralds = Socket.cachedUser.emeralds.minus(it.cost)
92-
actions["purchase"]?.add(cosmeticName)
95+
actions.add(Actions("purchase", it.name))
9396
}
9497
}
9598
}
9699

97100
fun updateCosmetics() {
98101
Multithreading.runAsync {
99102
for (action in actions) {
100-
val list = action.value
101-
val func = action.key
102-
103-
for (name in list) {
104-
val response =
105-
NetworkUtils.postString(HYSENTIALS_API + "/cosmetic?name=$name&function=${func}&uuid=${Minecraft.getMinecraft().thePlayer.uniqueID}&key=${Socket.serverId}")
106-
val json = JSONObject(response)
107-
if (json.get("success") == false) {
108-
Hysentials.INSTANCE.sendMessage(
109-
"&cFailed to $func $name: ${json.get("message")}",
110-
)
111-
}
103+
val func = action.action
104+
val name = action.name
105+
106+
val response =
107+
NetworkUtils.postString(HYSENTIALS_API + "/cosmetic?name=$name&function=${func}&uuid=${Minecraft.getMinecraft().thePlayer.uniqueID}&key=${Socket.serverId}")
108+
val json = JSONObject(response)
109+
if (json.get("success") == false) {
110+
Hysentials.INSTANCE.sendMessage(
111+
"&cFailed to $func $name: ${json.get("message")}",
112+
)
112113
}
113114
}
114115
previewing.clear()
115-
actions = mapOf(
116-
"equip" to mutableSetOf<String>(),
117-
"unequip" to mutableSetOf<String>(),
118-
"purchase" to mutableSetOf<String>()
119-
)
116+
actions = mutableListOf()
120117
var cosmetics: JsonElement? =
121118
NetworkUtils.getJsonElement("$HYSENTIALS_API/cosmetic", true) ?: return@runAsync
122119
val `object` = cosmetics!!.asJsonObject

src/main/kotlin/llc/redstone/hysentials/websocket/methods/Chat.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class Chat : Channel("chat") {
5151
).setHover(HoverEvent.Action.SHOW_TEXT, (rank.prefixCheck + hoverUsername)) // Hover over the username to see the rank
5252
).appendSibling(
5353
UTextComponent(
54-
" ${if (FormattingConfig.hexRendering()) "<#fff1d4>" else "&6"}" + // Color of the message
54+
(if (FormattingConfig.hexRendering()) "<#fff1d4>" else "&6") + // Color of the message
5555
": $message" // The message
5656
)
5757
)
3.74 KB
Loading

0 commit comments

Comments
 (0)