Skip to content

Commit fd04004

Browse files
committed
Add community shop slot text for account & profile upgrades
1 parent ce063e8 commit fd04004

File tree

2 files changed

+62
-1
lines changed

2 files changed

+62
-1
lines changed

src/main/java/de/hysky/skyblocker/skyblock/item/slottext/SlotTextManager.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ public class SlotTextManager {
2525
new AttributeShardAdder(),
2626
new PrehistoricEggAdder(),
2727
new PotionLevelAdder(),
28-
new CollectionAdder()
28+
new CollectionAdder(),
29+
new CommunityShopAdder()
2930
};
3031
private static final ArrayList<SlotTextAdder> currentScreenAdders = new ArrayList<>();
3132

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package de.hysky.skyblocker.skyblock.item.slottext.adders;
2+
3+
import de.hysky.skyblocker.skyblock.item.slottext.SlotText;
4+
import de.hysky.skyblocker.skyblock.item.slottext.SlotTextAdder;
5+
import de.hysky.skyblocker.utils.ItemUtils;
6+
import de.hysky.skyblocker.utils.RomanNumerals;
7+
import net.minecraft.item.ItemStack;
8+
import net.minecraft.item.Items;
9+
import net.minecraft.screen.slot.Slot;
10+
import net.minecraft.text.Text;
11+
import net.minecraft.util.Formatting;
12+
import org.jetbrains.annotations.NotNull;
13+
14+
import java.util.List;
15+
16+
public class CommunityShopAdder extends SlotTextAdder {
17+
private static final byte CATEGORIES_START = 10;
18+
private static final byte CATEGORIES_END = 14; //Inclusive
19+
20+
public CommunityShopAdder() {
21+
super("^Community Shop");
22+
}
23+
24+
@Override
25+
public @NotNull List<SlotText> getText(Slot slot) {
26+
for (byte i = CATEGORIES_START; i <= CATEGORIES_END; i++) {
27+
if (slot.inventory.getStack(i).isOf(Items.LIME_STAINED_GLASS_PANE)) { //Only the selected category has a lime stained glass pane, the others have a gray one.
28+
return switch (i) { //This is a switch to allow adding more categories easily in the future, if we ever add more.
29+
case 11 -> getTextForUpgradesScreen(slot);
30+
default -> List.of();
31+
};
32+
}
33+
}
34+
return List.of();
35+
}
36+
37+
private static List<SlotText> getTextForUpgradesScreen(Slot slot) {
38+
final ItemStack stack = slot.getStack();
39+
switch (slot.id) {
40+
case 30, 31, 32, 33, 34, 38, 39, 40, 41, 42, 43, 44 -> {
41+
String name = stack.getName().getString();
42+
int lastIndex = name.lastIndexOf(' ');
43+
String roman = name.substring(lastIndex + 1); // + 1 as we don't want the space
44+
if (!RomanNumerals.isValidRomanNumeral(roman)) return List.of();
45+
46+
List<Text> lore = ItemUtils.getLore(stack);
47+
if (lore.isEmpty()) return List.of();
48+
String lastLine = lore.getLast().getString();
49+
return List.of(SlotText.bottomLeft(switch (lastLine) {
50+
case "Maxed out!" -> Text.literal("Max").withColor(0xfab387);
51+
case "Currently upgrading!" -> Text.literal("⏰").withColor(0xf9e2af).formatted(Formatting.BOLD);
52+
//Todo: Add the case for when the upgrade has finished and is ready to be claimed
53+
default -> Text.literal(String.valueOf(RomanNumerals.romanToDecimal(roman))).withColor(0xcba6f7);
54+
}));
55+
56+
}
57+
}
58+
return List.of();
59+
}
60+
}

0 commit comments

Comments
 (0)