Skip to content

Commit a14017a

Browse files
authored
Merge pull request SkyblockerMod#729 from Emirlol/chocolate-factory-hotfix
Fix egg found message being sent twice
2 parents 0451352 + 382525b commit a14017a

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

src/main/java/de/hysky/skyblocker/skyblock/chocolatefactory/EggFinder.java

-11
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434

3535
public class EggFinder {
3636
private static final Pattern eggFoundPattern = Pattern.compile("^(?:HOPPITY'S HUNT You found a Chocolate|You have already collected this Chocolate) (Breakfast|Lunch|Dinner)");
37-
private static final Pattern newEggPattern = Pattern.compile("^HOPPITY'S HUNT A Chocolate (Breakfast|Lunch|Dinner) Egg has appeared!$");
3837
private static final Logger logger = LoggerFactory.getLogger("Skyblocker Egg Finder");
3938
private static final LinkedList<ArmorStandEntity> armorStandQueue = new LinkedList<>();
4039
private static final Location[] possibleLocations = {Location.CRIMSON_ISLE, Location.CRYSTAL_HOLLOWS, Location.DUNGEON_HUB, Location.DWARVEN_MINES, Location.HUB, Location.THE_END, Location.THE_PARK, Location.GOLD_MINE};
@@ -146,16 +145,6 @@ private static void onChatMessage(Text text, boolean overlay) {
146145
logger.error("[Skyblocker Egg Finder] Failed to find egg type for egg found message. Tried to match against: " + matcher.group(0), e);
147146
}
148147
}
149-
150-
//There's only one egg of the same type at any given time, so we can set the changed egg to null
151-
matcher = newEggPattern.matcher(text.getString());
152-
if (matcher.find()) {
153-
try {
154-
EggType.valueOf(matcher.group(1).toUpperCase()).egg.setValue(null);
155-
} catch (IllegalArgumentException e) {
156-
logger.error("[Skyblocker Egg Finder] Failed to find egg type for egg spawn message. Tried to match against: " + matcher.group(0), e);
157-
}
158-
}
159148
}
160149

161150
record Egg(ArmorStandEntity entity, Waypoint waypoint) { }

src/main/java/de/hysky/skyblocker/skyblock/chocolatefactory/TimeTowerReminder.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.mojang.brigadier.Message;
44
import de.hysky.skyblocker.SkyblockerMod;
5+
import de.hysky.skyblocker.config.SkyblockerConfigManager;
56
import de.hysky.skyblocker.events.SkyblockEvents;
67
import de.hysky.skyblocker.utils.Constants;
78
import de.hysky.skyblocker.utils.Utils;
@@ -49,16 +50,17 @@ public static void checkIfTimeTower(Message message, boolean overlay) {
4950
}
5051

5152
try (FileWriter writer = new FileWriter(tempFile)) {
52-
writer.write(String.valueOf(System.currentTimeMillis()));
53+
writer.write(String.valueOf(System.currentTimeMillis())); //Overwrites the file so no need to handle case where the file already exists and has text
5354
} catch (IOException e) {
5455
LOGGER.error("[Skyblocker Time Tower Reminder] Failed to write to temp file for Time Tower Reminder!", e);
5556
}
5657
}
5758

5859
private static void sendMessage() {
5960
if (MinecraftClient.getInstance().player == null || !Utils.isOnSkyblock()) return;
60-
MinecraftClient.getInstance().player.sendMessage(Constants.PREFIX.get().append(Text.literal("Your Chocolate Factory's Time Tower has deactivated!").formatted(Formatting.RED)));
61-
61+
if (SkyblockerConfigManager.get().helpers.chocolateFactory.enableTimeTowerReminder) {
62+
MinecraftClient.getInstance().player.sendMessage(Constants.PREFIX.get().append(Text.literal("Your Chocolate Factory's Time Tower has deactivated!").formatted(Formatting.RED)));
63+
}
6264
File tempFile = SkyblockerMod.CONFIG_DIR.resolve(TIME_TOWER_FILE).toFile();
6365
try {
6466
scheduled = false;

0 commit comments

Comments
 (0)