Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
newValue -> config.chat.hideMoltenWave = newValue)
.controller(ConfigUtils.createEnumController())
.build())
.option(Option.<ChatFilterResult>createBuilder()
.name(Component.translatable("skyblocker.config.chat.filter.hideRareCrops"))
.binding(defaults.chat.hideRareCrops,
() -> config.chat.hideRareCrops,
newValue -> config.chat.hideRareCrops = newValue)
.controller(ConfigUtils.createEnumController())
.build())
.option(Option.<ChatFilterResult>createBuilder()
.name(Component.translatable("skyblocker.config.chat.filter.hideAds"))
.binding(defaults.chat.hideAds,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class ChatConfig {

public ChatFilterResult hideMoltenWave = ChatFilterResult.PASS;

public ChatFilterResult hideRareCrops = ChatFilterResult.PASS;

public ChatFilterResult hideAds = ChatFilterResult.PASS;

public ChatFilterResult hideTeleportPad = ChatFilterResult.PASS;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package de.hysky.skyblocker.skyblock.chat.filters;

import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.skyblock.itemlist.ItemRepository;
import de.hysky.skyblocker.utils.FlexibleItemStack;
import de.hysky.skyblocker.utils.ItemUtils;
import de.hysky.skyblocker.utils.NEURepoManager;
import de.hysky.skyblocker.utils.SkyBlockIcons;
import de.hysky.skyblocker.utils.chat.ChatFilterResult;
import de.hysky.skyblocker.utils.chat.ChatPatternListener;
import de.hysky.skyblocker.utils.render.gui.BasicToast;
import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;
import org.jspecify.annotations.Nullable;

import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;

import static java.util.Map.entry;

public class RareCropFilter extends ChatPatternListener {
private static final Map<String, String> IDS = Map.ofEntries(
entry("Cropie", "CROPIE"),
entry("Squash", "SQUASH"),
entry("Fermento", "FERMENTO"),
entry("Helianthus", "HELIANTHUS"),
entry("Warty", "WARTY"),
entry("Burrowing Spores", "BURROWING_SPORES"),
entry("Overclocker 3000", "OVERCLOCKER_3000"),
entry("Ethereal Vine", "ETHEREAL_VINE"),
entry("Rarefinder Chip", "RAREFINDER_GARDEN_CHIP"),
// Seasoning has no item to display, so it's excluded here
entry("Cornucopia", "CORNUCOPIA"),
entry("Carrot Zest", "CARROT_ZEST"),
entry("Deepfries", "DEEPFRIES"),
entry("Aggourdian", "AGGOURDIAN"),
entry("Cane Knot", "CANE_KNOT"),
entry("Melon Juice", "MELON_JUICE"),
entry("Cactus Flower", "CACTUS_FLOWER"),
entry("Designer Coffee Beans", "DESIGNER_COFFEE_BEANS"),
entry("Feastfungus", "FEASTFUNGUS"),
entry("Botroot", "BOTROOT"),
entry("Salted Sunflower Seeds", "SALTED_SUNFLOWER_SEEDS"),
entry("Crystalized Moonlight", "CRYSTALIZED_MOONLIGHT"),
entry("Floral Gelatin", "FLORAL_GELATIN")
// Wild Strawberry Dye and Ray of Helios are handled as rare drops instead
);
private static final Map<String, FlexibleItemStack> ICONS = new HashMap<>();

public RareCropFilter() {
super("^RARE CROP!\\s+(?<crop>[\\w\\s]+)\\s+\\(\\+\\d+(?:\\.\\d+)?" + SkyBlockIcons.OVERBLOOM + "\\).*");
}

private @Nullable ItemStack getCropIcon(Matcher matcher) {
String skyblockId = IDS.get(matcher.group("crop"));
if (skyblockId == null) return null;
if (NEURepoManager.isLoading() || !ItemRepository.filesImported()) return ItemUtils.getItemIdPlaceholder(skyblockId).getStack();
return ICONS.computeIfAbsent(skyblockId, id -> ItemRepository.getItemStack(id, ItemUtils.getItemIdPlaceholder(id))).getStack();
}

@Override
public boolean onMatch(Component message, Matcher matcher) {
if (SkyblockerConfigManager.get().chat.hideRareCrops == ChatFilterResult.TOAST) {
Minecraft.getInstance().gui.toastManager().addToast(new BasicToast(message, (long) (SkyblockerConfigManager.get().chat.toastDisplayDuration * 1000L), getCropIcon(matcher)));
}
return true;
}

@Override
public ChatFilterResult state() {
if (SkyblockerConfigManager.get().chat.hideRareCrops == ChatFilterResult.TOAST)
return ChatFilterResult.FILTER;
else
return SkyblockerConfigManager.get().chat.hideRareCrops;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
public class RareDropSpecialEffects {
private static final Logger LOGGER = LoggerFactory.getLogger(RareDropSpecialEffects.class);
private static final Pattern MAGIC_FIND_PATTERN = Pattern.compile("^(?!.*:)(?:RARE|VERY RARE|CRAZY RARE|INSANE) DROP!\\s+\\(?(?<item>.+?)\\)?(?:\\s+\\(\\+\\d+%? "+SkyBlockIcons.MAGIC_FIND+" Magic Find\\))?$");
private static final Pattern OVERBLOOM_PATTERN = Pattern.compile("^RARE CROP!\\s+(?<crop>[\\w\\s]+)\\s+\\(\\+\\d+(?:\\.\\d+)?" + SkyBlockIcons.OVERBLOOM + "\\).*");

@Init
public static void init() {
Expand All @@ -34,6 +35,14 @@ private static boolean displayRareDropEffect(Component message, boolean overlay)

if (magicFindMatcher.matches()) {
triggerDropEffect(magicFindMatcher.group("item"));

return true;
}

Matcher overbloomMatcher = OVERBLOOM_PATTERN.matcher(stringForm);

if (overbloomMatcher.matches()) {
triggerDropEffect(overbloomMatcher.group("crop"));
}
} catch (Exception e) { //In case there's a regex failure or something else bad happens
LOGGER.error("[Skyblocker Special Effects] An unexpected exception was encountered: ", e);
Expand Down Expand Up @@ -85,6 +94,8 @@ private static void triggerDropEffect(String itemName) {
case "Radioactive Vial" -> "RADIOACTIVE_VIAL";
case "Tiki Mask" -> "TIKI_MASK";
case "Titanoboa Shed" -> "TITANOBOA_SHED";
//Farming
case "Ray of Helios" -> "RAY_OF_HELIOS";
default -> "NONE";
};

Expand Down
1 change: 1 addition & 0 deletions src/main/java/de/hysky/skyblocker/utils/SkyBlockIcons.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public final class SkyBlockIcons {

// Farming Stats
public static final char FARMING_FORTUNE = '\uE051';
public static final char OVERBLOOM = '\uE02B';

// Foraging stats
public static final char SWEEP = '\uE023';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import de.hysky.skyblocker.skyblock.chat.filters.LotteryFilter;
import de.hysky.skyblocker.skyblock.chat.filters.MimicFilter;
import de.hysky.skyblocker.skyblock.chat.filters.MoltenWaveFilter;
import de.hysky.skyblocker.skyblock.chat.filters.RareCropFilter;
import de.hysky.skyblocker.skyblock.chat.filters.ShowOffFilter;
import de.hysky.skyblocker.skyblock.chat.filters.SkyMallFilter;
import de.hysky.skyblocker.skyblock.chat.filters.SpiritSceptreFilter;
Expand Down Expand Up @@ -81,6 +82,7 @@ static void init() {
new ImplosionFilter(),
new SpiritSceptreFilter(),
new MoltenWaveFilter(),
new RareCropFilter(),
new TeleportPadFilter(),
new AutopetFilter(),
new ShowOffFilter(),
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/skyblocker/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@
"skyblocker.config.chat.filter.hideMimicKill": "Hide Mimic Kill Messages",
"skyblocker.config.chat.filter.hideMimicKill.@Tooltip": "Filters the \"Mimic dead!\" and \"Mimic killed!\" messages from chat.",
"skyblocker.config.chat.filter.hideMoltenWave": "Hide Molten Wave Message",
"skyblocker.config.chat.filter.hideRareCrops": "Hide Rare Crop Messages",
"skyblocker.config.chat.filter.hideShowOff": "Hide Show Off Messages",
"skyblocker.config.chat.filter.hideShowOff.@Tooltip": "Filters messages from the /show command",
"skyblocker.config.chat.filter.hideSpiritSceptre": "Hide Spirit Sceptre Message",
Expand Down