-
-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Corpse profit tracker initial commit * A bunch of stuff - Extract `CorpseLoot` and `Reward` inner classes into separate classes - Use translatables where it makes sense - Add config option to toggle corpse profit tracker (can't believe I forgot this on corpse tracker as well) - Some minor command adjustments and fixes to both `PowderMiningTracker` and `CorpseProfitTracker` - Refactored `CorpseProfitHistoryScreen` into `CorpseProfitScreen`. The button that switched from one to the other is now a view switch button that changes the displayed list, and functionality of both screens is combined in one. - Add hover/click events to the profit text sent when a corpse is looted that opens the screen * Round the chat message so it's more copy-friendly * Fix keys' total price not being multiplied by key amount * Fix `pricePerUnit` display of items to match keys This way, they don't display the price per unit when the amount is 1.
- Loading branch information
Showing
14 changed files
with
1,289 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
src/main/java/de/hysky/skyblocker/skyblock/dwarven/CorpseType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package de.hysky.skyblocker.skyblock.dwarven; | ||
|
||
import com.mojang.brigadier.context.CommandContext; | ||
import com.mojang.serialization.Codec; | ||
import de.hysky.skyblocker.utils.ItemUtils; | ||
import net.minecraft.command.argument.EnumArgumentType; | ||
import net.minecraft.util.Formatting; | ||
import net.minecraft.util.StringIdentifiable; | ||
|
||
public enum CorpseType implements StringIdentifiable { | ||
LAPIS("LAPIS_ARMOR_HELMET", null, Formatting.BLUE), // dark blue looks bad and these two never exist in same shaft | ||
UMBER("ARMOR_OF_YOG_HELMET", "UMBER_KEY", Formatting.GOLD), | ||
TUNGSTEN("MINERAL_HELMET", "TUNGSTEN_KEY", Formatting.GRAY), | ||
VANGUARD("VANGUARD_HELMET", "SKELETON_KEY", Formatting.AQUA), | ||
UNKNOWN("UNKNOWN", null, Formatting.RED); | ||
|
||
public static final Codec<CorpseType> CODEC = StringIdentifiable.createCodec(CorpseType::values); | ||
public final String helmetItemId; | ||
public final String keyItemId; | ||
public final Formatting color; | ||
|
||
CorpseType(String helmetItemId, String keyItemId, Formatting color) { | ||
this.helmetItemId = helmetItemId; | ||
this.keyItemId = keyItemId; | ||
this.color = color; | ||
} | ||
|
||
static CorpseType fromHelmetItemId(String helmetItemId) { | ||
for (CorpseType value : values()) { | ||
if (value.helmetItemId.equals(helmetItemId)) { | ||
return value; | ||
} | ||
} | ||
return UNKNOWN; | ||
} | ||
|
||
@Override | ||
public String asString() { | ||
return name().toLowerCase(); | ||
} | ||
|
||
/** | ||
* @return the price of the key item for this corpse type | ||
* @throws IllegalStateException when there's no price found for the key item, or when the corpse type is UNKNOWN | ||
*/ | ||
public double getKeyPrice() throws IllegalStateException { | ||
return switch (this) { | ||
case UNKNOWN -> throw new IllegalStateException("There's no key or key price for the UNKNOWN corpse type!"); | ||
case LAPIS -> 0; // Lapis corpses don't need a key | ||
default -> { | ||
var result = ItemUtils.getItemPrice(keyItemId); | ||
if (!result.rightBoolean()) throw new IllegalStateException("No price found for key item `" + keyItemId + "`!"); | ||
yield result.leftDouble(); | ||
} | ||
}; | ||
} | ||
|
||
public static class CorpseTypeArgumentType extends EnumArgumentType<CorpseType> { | ||
protected CorpseTypeArgumentType() { | ||
super(CODEC, CorpseType::values); | ||
} | ||
|
||
static CorpseTypeArgumentType corpseType() { | ||
return new CorpseTypeArgumentType(); | ||
} | ||
|
||
static <S> CorpseType getCorpseType(CommandContext<S> context, String name) { | ||
return context.getArgument(name, CorpseType.class); | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/de/hysky/skyblocker/skyblock/dwarven/profittrackers/AbstractProfitTracker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package de.hysky.skyblocker.skyblock.dwarven.profittrackers; | ||
|
||
import de.hysky.skyblocker.SkyblockerMod; | ||
|
||
import java.nio.file.Path; | ||
import java.util.regex.Pattern; | ||
|
||
/** | ||
* Abstract class for profit trackers that use the chat messages. | ||
* <br> | ||
* There isn't meant to be much inheritance from this class, it's more of a util class that provides some common methods. | ||
*/ | ||
public abstract class AbstractProfitTracker { | ||
private static final String REWARD_TRACKERS_DIR = "reward-trackers"; | ||
protected static final Pattern REWARD_PATTERN = Pattern.compile(" {4}(.*?) ?x?([\\d,]*)"); | ||
protected static final Pattern HOTM_XP_PATTERN = Pattern.compile(" {4}\\+[\\d,]+ HOTM Experience"); | ||
protected static final Pattern GEMSTONE_SYMBOLS = Pattern.compile("[α☘☠✎✧❁❂❈❤⸕] "); | ||
|
||
protected static String replaceGemstoneSymbols(String reward) { | ||
return GEMSTONE_SYMBOLS.matcher(reward).replaceAll(""); | ||
} | ||
|
||
protected Path getRewardFilePath(String fileName) { | ||
return SkyblockerMod.CONFIG_DIR.resolve(REWARD_TRACKERS_DIR).resolve(fileName); // 2 resolve calls to avoid the need for a possibly confusing / placement | ||
} | ||
} |
Oops, something went wrong.