aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorExternalTime <84183548+ExternalTime@users.noreply.github.com>2021-09-19 18:10:00 +0200
committerExternalTime <84183548+ExternalTime@users.noreply.github.com>2021-09-19 18:22:25 +0200
commita0feb55973fc3eb4be4ae0ae2c76c88c9cd9f200 (patch)
treed9898d2c480d4ee002b35e18b54178ca327c99cf /src/main/java
parent83747a8bb2553aef5acc5988727de752bac55ffc (diff)
downloadSkyblocker-a0feb55973fc3eb4be4ae0ae2c76c88c9cd9f200.tar.gz
Skyblocker-a0feb55973fc3eb4be4ae0ae2c76c88c9cd9f200.tar.bz2
Skyblocker-a0feb55973fc3eb4be4ae0ae2c76c88c9cd9f200.zip
Rewrote Trivia solver to use the new interface
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/chat/ChatParser.java2
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java1
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/DungeonPuzzles.java118
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/Trivia.java89
4 files changed, 92 insertions, 118 deletions
diff --git a/src/main/java/me/xmrvizzy/skyblocker/chat/ChatParser.java b/src/main/java/me/xmrvizzy/skyblocker/chat/ChatParser.java
index a74138ce..9965c7c7 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/chat/ChatParser.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/chat/ChatParser.java
@@ -2,6 +2,7 @@ package me.xmrvizzy.skyblocker.chat;
import me.xmrvizzy.skyblocker.chat.filters.*;
import me.xmrvizzy.skyblocker.skyblock.dungeon.ThreeWeirdos;
+import me.xmrvizzy.skyblocker.skyblock.dungeon.Trivia;
import me.xmrvizzy.skyblocker.skyblock.dwarven.Fetchur;
import me.xmrvizzy.skyblocker.skyblock.dwarven.Puzzler;
@@ -18,6 +19,7 @@ public class ChatParser {
new AdFilter(),
new Fetchur(),
new Puzzler(),
+ new Trivia(),
};
public boolean shouldFilter(String message) {
diff --git a/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java b/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java
index fd289c5d..5a085818 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java
@@ -53,6 +53,7 @@ public class SkyblockerConfig implements ConfigData {
public boolean enableMap = true;
public boolean solveThreeWeirdos = true;
public boolean blazesolver = true;
+ public boolean solveTrivia = true;
}
public static class DwarvenMines {
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/DungeonPuzzles.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/DungeonPuzzles.java
deleted file mode 100644
index 49276a6e..00000000
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/DungeonPuzzles.java
+++ /dev/null
@@ -1,118 +0,0 @@
-package me.xmrvizzy.skyblocker.skyblock.dungeon;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.entity.decoration.ArmorStandEntity;
-import net.minecraft.text.LiteralText;
-import net.minecraft.text.Text;
-import net.minecraft.util.Formatting;
-
-public class DungeonPuzzles {
-
- public static void threeWeirdos(String message) {
- MinecraftClient client = MinecraftClient.getInstance();
- if (client.player == null && client.world == null) return;
-
- String[] solutions = {
- "The reward is not in my chest!",
- "At least one of them is lying, and the reward is not in",
- "My chest doesn't have the reward. We are all telling the truth.",
- "My chest has the reward and I'm telling the truth!",
- "The reward isn't in any of our chests.",
- "Both of them are telling the truth. Also,"
- };
-
- for (String s : solutions) {
- if (message.contains(s)) {
- String npc = message.substring(message.indexOf("]") + 4, message.indexOf(":") - 2);
- client.world.getEntitiesByClass(ArmorStandEntity.class, client.player.getBoundingBox().expand(3), entity -> {
- if (entity.hasCustomName() && entity.getCustomName().getString().contains(npc))
- return true;
- return false;
- }).forEach(entity -> entity.setCustomName(Text.of(Formatting.GREEN + npc)));
- }
- }
- }
- public static String[] triviaAnswers = null;
- public static void trivia(String message, CallbackInfo ci){
- MinecraftClient client = MinecraftClient.getInstance();
-
-
- if (client.player == null && client.world == null) return;
- if (message.contains("What SkyBlock year is it?")) {
- double currentTime = System.currentTimeMillis() /1000L;
-
- double diff = Math.floor(currentTime - 1560276000);
-
- int year = (int) (diff / 446400 + 1);
- triviaAnswers = new String[]{"Year " + year};
- }else{
- Map<String, String[]> solutions = new HashMap<>();
- solutions.put("What is the status of The Watcher?", new String[]{"Stalker"});
- solutions.put("What is the status of Bonzo?", new String[]{"New Necromancer"});
- solutions.put("What is the status of Scarf?", new String[]{"Apprentice Necromancer"});
- solutions.put("What is the status of The Professor?", new String[]{"Professor"});
- solutions.put("What is the status of Thorn?", new String[]{"Shaman Necromancer"});
- solutions.put("What is the status of Livid?", new String[]{"Master Necromancer"});
- solutions.put("What is the status of Sadan?", new String[]{"Necromancer Lord"});
- solutions.put("What is the status of Maxor?", new String[]{"Young Wither"});
- solutions.put("What is the status of Goldor?", new String[]{"Wither Soldier"});
- solutions.put("What is the status of Storm?", new String[]{"Elementalist"});
- solutions.put("What is the status of Necron?", new String[]{"Wither Lord"});
- solutions.put("How many total Fairy Souls are there?", new String[]{"220 Fairy Souls"});
- solutions.put("How many Fairy Souls are there in Spider's Den?", new String[]{"19 Fairy Souls"});
- solutions.put("How many Fairy Souls are there in The End?", new String[]{"12 Fairy Souls"});
- solutions.put("How many Fairy Souls are there in The Barn?", new String[]{"7 Fairy Souls"});
- solutions.put("How many Fairy Souls are there in Mushroom Desert?", new String[]{"8 Fairy Souls"});
- solutions.put("How many Fairy Souls are there in Blazing Fortress?", new String[]{"19 Fairy Souls"});
- solutions.put("How many Fairy Souls are there in The Park?", new String[]{"11 Fairy Souls"});
- solutions.put("How many Fairy Souls are there in Jerry's Workshop?", new String[]{"5 Fairy Souls"});
- solutions.put("How many Fairy Souls are there in Hub?", new String[]{"79 Fairy Souls"});
- solutions.put("How many Fairy Souls are there in The Hub?", new String[]{"79 Fairy Souls"});
- solutions.put("How many Fairy Souls are there in Deep Caverns?", new String[]{"21 Fairy Souls"});
- solutions.put("How many Fairy Souls are there in Gold Mine?", new String[]{"12 Fairy Souls"});
- solutions.put("How many Fairy Souls are there in Dungeon Hub?", new String[]{"7 Fairy Souls"});
- solutions.put("Which brother is on the Spider's Den?", new String[]{"Rick"});
- solutions.put("What is the name of Rick's brother?", new String[]{"Pat"});
- solutions.put("What is the name of the Painter in the Hub?", new String[]{"Marco"});
- solutions.put("What is the name of the person that upgrades pets?", new String[]{"Kat"});
- solutions.put("What is the name of the lady of the Nether?", new String[]{"Elle"});
- solutions.put("Which villager in the Village gives you a Rogue Sword?", new String[]{"Jamie"});
- solutions.put("How many unique minions are there?", new String[]{"53 Minions"});
- solutions.put("Which of these enemies does not spawn in the Spider's Den?", new String[]{"Zombie Spider", "Cave Spider", "Wither Skeleton",
- "Dashing Spooder", "Broodfather", "Night Spider"});
- solutions.put("Which of these monsters only spawns at night?", new String[]{"Zombie Villager", "Ghast"});
- solutions.put("Which of these is not a dragon in The End?", new String[]{"Zoomer Dragon", "Weak Dragon", "Stonk Dragon", "Holy Dragon", "Boomer Dragon",
- "Booger Dragon", "Older Dragon", "Elder Dragon", "Stable Dragon", "Professor Dragon"});
-
- for (String question : solutions.keySet()) {
- if (message.contains(question)) {
- triviaAnswers = solutions.get(question);
- break;
- }
- }
- }
-
- if (triviaAnswers != null && (message.contains("ⓐ") || message.contains("ⓑ") || message.contains("ⓒ"))) {
- boolean isSolution = false;
- for (String solution : triviaAnswers) {
- if (message.contains(solution)) {
- //client.player.sendMessage(new LiteralText(solution), false);
- isSolution = true;
- break;
- }
- }
- if (!isSolution) {
- char letter = message.charAt(5);
- String option = message.substring(6);
- ci.cancel();
- client.player.sendMessage(new LiteralText(" " + Formatting.GOLD + letter + Formatting.RED + option), false);
- return;
- }
- }
- }
-} \ No newline at end of file
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/Trivia.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/Trivia.java
new file mode 100644
index 00000000..3d3e5c28
--- /dev/null
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/Trivia.java
@@ -0,0 +1,89 @@
+package me.xmrvizzy.skyblocker.skyblock.dungeon;
+
+import me.xmrvizzy.skyblocker.chat.ChatListener;
+import me.xmrvizzy.skyblocker.config.SkyblockerConfig;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.network.ClientPlayerEntity;
+import net.minecraft.text.LiteralText;
+import net.minecraft.util.Formatting;
+
+import java.util.*;
+
+public class Trivia extends ChatListener {
+ private static final Map<String, String[]> answers;
+ private List<String> solutions = Collections.emptyList();
+
+ public Trivia() {
+ super("^ +(?:([A-Za-z' ]*\\?)|§6 ([ⓐⓑⓒ]) §a([a-zA-Z0-9 ]+))$");
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return SkyblockerConfig.get().locations.dungeons.solveTrivia;
+ }
+
+ @Override
+ public boolean onMessage(String[] groups) {
+ if (groups[3] != null) {
+ if (!solutions.contains(groups[3])) {
+ ClientPlayerEntity player = MinecraftClient.getInstance().player;
+ assert player != null;
+ MinecraftClient.getInstance().player.sendMessage(new LiteralText(" " + Formatting.GOLD + groups[2] + Formatting.RED + " " + groups[3]), false);
+ return true;
+ }
+ } else
+ updateSolutions(groups[1]);
+ return false;
+ }
+
+ private void updateSolutions(String question) {
+ if (question.equals("What SkyBlock year is it?")) {
+ long currentTime = System.currentTimeMillis() / 1000L;
+ long diff = currentTime - 1560276000;
+ int year = (int) (diff / 446400 + 1);
+ solutions = Collections.singletonList("Year " + year);
+ } else {
+ solutions = Arrays.asList(answers.get(question));
+ }
+ }
+
+ static {
+ answers = new HashMap<>();
+ answers.put("What is the status of The Watcher?", new String[]{"Stalker"});
+ answers.put("What is the status of Bonzo?", new String[]{"New Necromancer"});
+ answers.put("What is the status of Scarf?", new String[]{"Apprentice Necromancer"});
+ answers.put("What is the status of The Professor?", new String[]{"Professor"});
+ answers.put("What is the status of Thorn?", new String[]{"Shaman Necromancer"});
+ answers.put("What is the status of Livid?", new String[]{"Master Necromancer"});
+ answers.put("What is the status of Sadan?", new String[]{"Necromancer Lord"});
+ answers.put("What is the status of Maxor?", new String[]{"Young Wither"});
+ answers.put("What is the status of Goldor?", new String[]{"Wither Soldier"});
+ answers.put("What is the status of Storm?", new String[]{"Elementalist"});
+ answers.put("What is the status of Necron?", new String[]{"Wither Lord"});
+ answers.put("How many total Fairy Souls are there?", new String[]{"227 Fairy Souls"});
+ answers.put("How many Fairy Souls are there in Spider's Den?", new String[]{"19 Fairy Souls"});
+ answers.put("How many Fairy Souls are there in The End?", new String[]{"12 Fairy Souls"});
+ answers.put("How many Fairy Souls are there in The Barn?", new String[]{"7 Fairy Souls"});
+ answers.put("How many Fairy Souls are there in Mushroom Desert?", new String[]{"13 Fairy Souls"});
+ answers.put("How many Fairy Souls are there in Blazing Fortress?", new String[]{"19 Fairy Souls"});
+ answers.put("How many Fairy Souls are there in The Park?", new String[]{"11 Fairy Souls"});
+ answers.put("How many Fairy Souls are there in Jerry's Workshop?", new String[]{"5 Fairy Souls"});
+ answers.put("How many Fairy Souls are there in Hub?", new String[]{"79 Fairy Souls"});
+ answers.put("How many Fairy Souls are there in The Hub?", new String[]{"79 Fairy Souls"});
+ answers.put("How many Fairy Souls are there in Deep Caverns?", new String[]{"21 Fairy Souls"});
+ answers.put("How many Fairy Souls are there in Gold Mine?", new String[]{"12 Fairy Souls"});
+ answers.put("How many Fairy Souls are there in Dungeon Hub?", new String[]{"7 Fairy Souls"});
+ answers.put("Which brother is on the Spider's Den?", new String[]{"Rick"});
+ answers.put("What is the name of Rick's brother?", new String[]{"Pat"});
+ answers.put("What is the name of the Painter in the Hub?", new String[]{"Marco"});
+ answers.put("What is the name of the person that upgrades pets?", new String[]{"Kat"});
+ answers.put("What is the name of the lady of the Nether?", new String[]{"Elle"});
+ answers.put("Which villager in the Village gives you a Rogue Sword?", new String[]{"Jamie"});
+ answers.put("How many unique minions are there?", new String[]{"53 Minions"});
+ answers.put("Which of these enemies does not spawn in the Spider's Den?", new String[]{"Zombie Spider", "Cave Spider", "Wither Skeleton",
+ "Dashing Spooder", "Broodfather", "Night Spider"});
+ answers.put("Which of these monsters only spawns at night?", new String[]{"Zombie Villager", "Ghast"});
+ answers.put("Which of these is not a dragon in The End?", new String[]{"Zoomer Dragon", "Weak Dragon", "Stonk Dragon", "Holy Dragon", "Boomer Dragon",
+ "Booger Dragon", "Older Dragon", "Elder Dragon", "Stable Dragon", "Professor Dragon"});
+ }
+}