From 664dbf0fc006ef68abe7423c452b39012eaffd89 Mon Sep 17 00:00:00 2001 From: dan28000 <84990628+dan28000@users.noreply.github.com> Date: Thu, 20 Jun 2024 17:03:11 +0200 Subject: [PATCH] holy amount work fr --- .../api/objects/gacha/enums/Rarity.java | 2 +- .../api/objects/gacha/enums/ResultType.java | 8 +++++ .../gacha/ultimatemenu/ComponentBuilder.java | 35 +++++++++++++------ 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/paper/src/main/java/com/badbones69/crazycrates/api/objects/gacha/enums/Rarity.java b/paper/src/main/java/com/badbones69/crazycrates/api/objects/gacha/enums/Rarity.java index 207ecd6ab..8746f684b 100644 --- a/paper/src/main/java/com/badbones69/crazycrates/api/objects/gacha/enums/Rarity.java +++ b/paper/src/main/java/com/badbones69/crazycrates/api/objects/gacha/enums/Rarity.java @@ -22,7 +22,7 @@ public enum Rarity { this.modelData = modelData; } - public NumberType getPity() { + public NumberType getNumberType() { return switch (this) { case LEGENDARY -> NumberType.LEGENDARY_PITY; case EPIC -> NumberType.EPIC_PITY; diff --git a/paper/src/main/java/com/badbones69/crazycrates/api/objects/gacha/enums/ResultType.java b/paper/src/main/java/com/badbones69/crazycrates/api/objects/gacha/enums/ResultType.java index 5aaf49f21..79d0d8964 100644 --- a/paper/src/main/java/com/badbones69/crazycrates/api/objects/gacha/enums/ResultType.java +++ b/paper/src/main/java/com/badbones69/crazycrates/api/objects/gacha/enums/ResultType.java @@ -16,4 +16,12 @@ public enum ResultType { ResultType(TextColor color) { this.color = color; } + + public String getNext() { + return switch (this) { + case LOST -> "c"; + case GUARANTEED, WON -> "b"; + default -> ""; + }; + } } diff --git a/paper/src/main/java/com/badbones69/crazycrates/api/objects/gacha/ultimatemenu/ComponentBuilder.java b/paper/src/main/java/com/badbones69/crazycrates/api/objects/gacha/ultimatemenu/ComponentBuilder.java index 7d7303374..9e1133b25 100644 --- a/paper/src/main/java/com/badbones69/crazycrates/api/objects/gacha/ultimatemenu/ComponentBuilder.java +++ b/paper/src/main/java/com/badbones69/crazycrates/api/objects/gacha/ultimatemenu/ComponentBuilder.java @@ -6,6 +6,8 @@ import com.badbones69.crazycrates.api.objects.gacha.data.PlayerProfile; import com.badbones69.crazycrates.api.objects.gacha.data.RaritySettings; import com.badbones69.crazycrates.api.objects.gacha.enums.Rarity; +import com.badbones69.crazycrates.api.objects.gacha.enums.ResultType; +import com.badbones69.crazycrates.api.objects.gacha.util.Pair; import lombok.experimental.UtilityClass; import net.kyori.adventure.key.Key; import net.kyori.adventure.text.Component; @@ -26,9 +28,9 @@ public final class ComponentBuilder { private static final Component SPACE_NEGATIVE = translatable("space.-1", "").font(KEY); private static final Component SPACE_PAGE = translatable("space.223", "").font(KEY); private static final Component SPACE_TIME = translatable("space.-335", "").font(KEY); - private static final Component SPACE_PITY = translatable("space.-40", "").font(KEY); + private static final Component SPACE_PITY = translatable("space.-71", "").font(KEY); private static final Component SPACE_SLASH = translatable("space.9", "").font(KEY); - private static final Component SPACE_TEST = translatable("space.-41", "").font(KEY); + private static final Component SPACE_NEWLINE = translatable("space.-72", "").font(KEY); private static final Component FILL_TOP = translatable("fill_top", "").color(COLOR).append(SPACE_NEGATIVE); private static final Component FILL_DOWN = translatable("fill_down", "").color(COLOR).append(SPACE_NEGATIVE); private static final Component FILL_TIME = translatable("fill_time", "").color(COLOR).append(SPACE_NEGATIVE); @@ -79,7 +81,7 @@ public static Component trans(Player player, CrateSettings crateSettings) { } for (char c : time.toCharArray()) { - builder.append(sw(c, NumberType.TIME)); + builder.append(sw(c, NumberType.TIME, true)); if (c == ' ') { builder.append(FILL_TIME).append(FILL_TIME); } @@ -100,14 +102,19 @@ public static Component trans(Player player, CrateSettings crateSettings) { } private static void pity(TextComponent.Builder builder, PlayerProfile playerProfile, Rarity rarity, RaritySettings settings) { - int currentPity = playerProfile.getPity(rarity).first(); + Pair result = playerProfile.getPity(rarity); + int currentPity = result.first(); + String resultType = result.second().getNext(); String current = String.format("%02d", currentPity); String pity = String.format("%02d", settings.pity()); - appendChars(builder, current, rarity.getPity()); + NumberType numberType = rarity.getNumberType(); + + appendChars(builder, resultType, numberType, false); + appendChars(builder, current, numberType); builder.append(SPACE_SLASH); - appendChars(builder, pity, rarity.getPity()); - builder.append(SPACE_TEST); + appendChars(builder, pity, numberType); + builder.append(SPACE_NEWLINE); } private static void down(TextComponent.Builder builder, String amount, int spaceLength, Component filler, Component space) { @@ -121,14 +128,18 @@ private static void down(TextComponent.Builder builder, String amount, int space appendChars(builder, amount, NumberType.DOWN); } - private void appendChars(TextComponent.Builder builder, String str, NumberType numberType) { + private static void appendChars(TextComponent.Builder builder, String str, NumberType numberType) { + appendChars(builder, str, numberType, true); + } + + private void appendChars(TextComponent.Builder builder, String str, NumberType numberType, boolean space) { for (char c : str.toCharArray()) { - builder.append(sw(c, numberType)); + builder.append(sw(c, numberType, space)); } } - private static Component sw(char c, NumberType numberType) { - return translatable(charSwap(c, numberType), "").color(COLOR).append(SPACE_NEGATIVE); + private static Component sw(char c, NumberType numberType, boolean space) { + return translatable(charSwap(c, numberType), "").color(COLOR).append(space ? SPACE_NEGATIVE : Component.empty()); } private static String charSwap(char c, NumberType numberType) { @@ -147,6 +158,8 @@ private static String charSwap(char c, NumberType numberType) { case 'h' -> "hours"; case 'm' -> "minutes"; case ' ' -> "fill"; + case 'c' -> "color"; + case 'b' -> "black"; default -> c + ""; } + switch (numberType) { case TOP -> "_top";