aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/me/Danker/DankersSkyblockMod.java8
-rw-r--r--src/main/java/me/Danker/features/puzzlesolvers/ThreeManSolver.java71
-rw-r--r--src/main/java/me/Danker/features/puzzlesolvers/TriviaSolver.java99
-rw-r--r--src/main/java/me/Danker/gui/EditLocationsGui.java3
4 files changed, 127 insertions, 54 deletions
diff --git a/src/main/java/me/Danker/DankersSkyblockMod.java b/src/main/java/me/Danker/DankersSkyblockMod.java
index b3701cb..f176bbe 100644
--- a/src/main/java/me/Danker/DankersSkyblockMod.java
+++ b/src/main/java/me/Danker/DankersSkyblockMod.java
@@ -1,5 +1,6 @@
package me.Danker;
+import com.google.gson.JsonObject;
import me.Danker.commands.*;
import me.Danker.events.ChestSlotClickedEvent;
import me.Danker.events.GuiChestBackgroundDrawnEvent;
@@ -9,6 +10,7 @@ import me.Danker.features.loot.LootDisplay;
import me.Danker.features.loot.LootTracker;
import me.Danker.features.puzzlesolvers.*;
import me.Danker.gui.*;
+import me.Danker.handlers.APIHandler;
import me.Danker.handlers.ConfigHandler;
import me.Danker.handlers.PacketHandler;
import me.Danker.utils.Utils;
@@ -74,6 +76,7 @@ public class DankersSkyblockMod {
public static String guiToOpen = null;
public static boolean firstLaunch = false;
public static String configDirectory;
+ public static JsonObject data = null;
public static String MAIN_COLOUR;
public static String SECONDARY_COLOUR;
@@ -149,6 +152,11 @@ public class DankersSkyblockMod {
for (KeyBinding keyBinding : keyBindings) {
ClientRegistry.registerKeyBinding(keyBinding);
}
+
+ new Thread(() -> {
+ DankersSkyblockMod.data = APIHandler.getResponse("https://raw.githubusercontent.com/bowser0000/SkyblockMod-REPO/main/data.json");
+ System.out.println("Loaded data from GitHub?: " + (DankersSkyblockMod.data != null && DankersSkyblockMod.data.has("trivia")));
+ }).start();
}
@EventHandler
diff --git a/src/main/java/me/Danker/features/puzzlesolvers/ThreeManSolver.java b/src/main/java/me/Danker/features/puzzlesolvers/ThreeManSolver.java
index 8f7de95..500c8eb 100644
--- a/src/main/java/me/Danker/features/puzzlesolvers/ThreeManSolver.java
+++ b/src/main/java/me/Danker/features/puzzlesolvers/ThreeManSolver.java
@@ -1,5 +1,6 @@
package me.Danker.features.puzzlesolvers;
+import com.google.gson.JsonArray;
import me.Danker.DankersSkyblockMod;
import me.Danker.commands.ToggleCommand;
import me.Danker.utils.Utils;
@@ -16,6 +17,7 @@ import java.util.List;
public class ThreeManSolver {
+ // Hard coded solutions if api call fails
static String[] riddleSolutions = {"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."};
@@ -33,33 +35,22 @@ public class ThreeManSolver {
if (!Utils.inDungeons) return;
if (ToggleCommand.threeManToggled && message.contains("[NPC]")) {
- for (String solution : riddleSolutions) {
- if (message.contains(solution)) {
- Minecraft mc = Minecraft.getMinecraft();
- String npcName = message.substring(message.indexOf("]") + 2, message.indexOf(":"));
- mc.thePlayer.addChatMessage(new ChatComponentText(DankersSkyblockMod.ANSWER_COLOUR + EnumChatFormatting.BOLD + StringUtils.stripControlCodes(npcName) + DankersSkyblockMod.MAIN_COLOUR + " has the blessing."));
- if (riddleChest == null) {
- List<Entity> entities = mc.theWorld.getLoadedEntityList();
- for (Entity entity : entities) {
- if (entity == null || !entity.hasCustomName()) continue;
- if (entity.getCustomNameTag().contains(npcName)) {
- BlockPos npcLocation = new BlockPos(entity.posX, 69, entity.posZ);
- if (mc.theWorld.getBlockState(npcLocation.north()).getBlock() == Blocks.chest) {
- riddleChest = npcLocation.north();
- } else if (mc.theWorld.getBlockState(npcLocation.east()).getBlock() == Blocks.chest) {
- riddleChest = npcLocation.east();
- } else if (mc.theWorld.getBlockState(npcLocation.south()).getBlock() == Blocks.chest) {
- riddleChest = npcLocation.south();
- } else if (mc.theWorld.getBlockState(npcLocation.west()).getBlock() == Blocks.chest) {
- riddleChest = npcLocation.west();
- } else {
- System.out.print("Could not find correct riddle chest.");
- }
- break;
- }
- }
+ if (DankersSkyblockMod.data != null && DankersSkyblockMod.data.has("threeman")) {
+ JsonArray riddleSolutions = DankersSkyblockMod.data.get("threeman").getAsJsonArray();
+
+ for (int i = 0; i < riddleSolutions.size(); i++) {
+ String solution = riddleSolutions.get(i).getAsString();
+ if (message.contains(solution)) {
+ answer(message);
+ break;
+ }
+ }
+ } else {
+ for (String solution : riddleSolutions) {
+ if (message.contains(solution)) {
+ answer(message);
+ break;
}
- break;
}
}
}
@@ -72,4 +63,32 @@ public class ThreeManSolver {
}
}
+ public static void answer(String message) {
+ Minecraft mc = Minecraft.getMinecraft();
+ String npcName = message.substring(message.indexOf("]") + 2, message.indexOf(":"));
+ mc.thePlayer.addChatMessage(new ChatComponentText(DankersSkyblockMod.ANSWER_COLOUR + EnumChatFormatting.BOLD + StringUtils.stripControlCodes(npcName) + DankersSkyblockMod.MAIN_COLOUR + " has the blessing."));
+
+ if (riddleChest == null) {
+ List<Entity> entities = mc.theWorld.getLoadedEntityList();
+ for (Entity entity : entities) {
+ if (entity == null || !entity.hasCustomName()) continue;
+ if (entity.getCustomNameTag().contains(npcName)) {
+ BlockPos npcLocation = new BlockPos(entity.posX, 69, entity.posZ);
+ if (mc.theWorld.getBlockState(npcLocation.north()).getBlock() == Blocks.chest) {
+ riddleChest = npcLocation.north();
+ } else if (mc.theWorld.getBlockState(npcLocation.east()).getBlock() == Blocks.chest) {
+ riddleChest = npcLocation.east();
+ } else if (mc.theWorld.getBlockState(npcLocation.south()).getBlock() == Blocks.chest) {
+ riddleChest = npcLocation.south();
+ } else if (mc.theWorld.getBlockState(npcLocation.west()).getBlock() == Blocks.chest) {
+ riddleChest = npcLocation.west();
+ } else {
+ System.out.print("Could not find correct riddle chest.");
+ }
+ break;
+ }
+ }
+ }
+ }
+
}
diff --git a/src/main/java/me/Danker/features/puzzlesolvers/TriviaSolver.java b/src/main/java/me/Danker/features/puzzlesolvers/TriviaSolver.java
index 9adc555..dd2c23e 100644
--- a/src/main/java/me/Danker/features/puzzlesolvers/TriviaSolver.java
+++ b/src/main/java/me/Danker/features/puzzlesolvers/TriviaSolver.java
@@ -1,5 +1,9 @@
package me.Danker.features.puzzlesolvers;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+import me.Danker.DankersSkyblockMod;
import me.Danker.commands.ToggleCommand;
import me.Danker.utils.Utils;
import net.minecraft.util.ChatComponentText;
@@ -9,16 +13,21 @@ import net.minecraftforge.client.event.ClientChatReceivedEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
+import java.util.stream.Collectors;
public class TriviaSolver {
static Map<String, String[]> triviaSolutions = new HashMap<>();
static String[] triviaAnswers = null;
+ static JsonArray triviaAnswersJson = null;
public static String TRIVIA_WRONG_ANSWER_COLOUR;
public static void init() {
+ // Hard coded solutions if api call fails
triviaSolutions.put("What is the status of The Watcher?", new String[]{"Stalker"});
triviaSolutions.put("What is the status of Bonzo?", new String[]{"New Necromancer"});
triviaSolutions.put("What is the status of Scarf?", new String[]{"Apprentice Necromancer"});
@@ -30,11 +39,10 @@ public class TriviaSolver {
triviaSolutions.put("What is the status of Goldor?", new String[]{"Wither Soldier"});
triviaSolutions.put("What is the status of Storm?", new String[]{"Elementalist"});
triviaSolutions.put("What is the status of Necron?", new String[]{"Wither Lord"});
- triviaSolutions.put("How many total Fairy Souls are there?", new String[]{"222 Fairy Souls"});
+ triviaSolutions.put("How many total Fairy Souls are there?", new String[]{"227 Fairy Souls"});
triviaSolutions.put("How many Fairy Souls are there in Spider's Den?", new String[]{"19 Fairy Souls"});
triviaSolutions.put("How many Fairy Souls are there in The End?", new String[]{"12 Fairy Souls"});
- triviaSolutions.put("How many Fairy Souls are there in The Barn?", new String[]{"7 Fairy Souls"});
- triviaSolutions.put("How many Fairy Souls are there in Mushroom Desert?", new String[]{"8 Fairy Souls"});
+ triviaSolutions.put("How many Fairy Souls are there in The Farming Islands?", new String[]{"20 Fairy Souls"});
triviaSolutions.put("How many Fairy Souls are there in Blazing Fortress?", new String[]{"19 Fairy Souls"});
triviaSolutions.put("How many Fairy Souls are there in The Park?", new String[]{"11 Fairy Souls"});
triviaSolutions.put("How many Fairy Souls are there in Jerry's Workshop?", new String[]{"5 Fairy Souls"});
@@ -65,35 +73,76 @@ public class TriviaSolver {
if (event.type == 2) return;
if (ToggleCommand.oruoToggled) {
- if (message.contains("What SkyBlock year is it?")) {
- double currentTime = System.currentTimeMillis() /1000L;
+ if (DankersSkyblockMod.data != null && DankersSkyblockMod.data.has("trivia")) {
+ if (message.contains("What SkyBlock year is it?")) {
+ double currentTime = System.currentTimeMillis() / 1000L;
- double diff = Math.floor(currentTime - 1560276000);
+ double diff = Math.floor(currentTime - 1560276000);
- int year = (int) (diff / 446400 + 1);
- triviaAnswers = new String[]{"Year " + year};
- } else {
- for (String question : triviaSolutions.keySet()) {
- if (message.contains(question)) {
- triviaAnswers = triviaSolutions.get(question);
- break;
+ int year = (int) (diff / 446400 + 1);
+ triviaAnswersJson = new JsonArray();
+ triviaAnswersJson.add(new JsonPrimitive("Year " + year));
+ } else {
+ JsonObject triviaSolutions = DankersSkyblockMod.data.get("trivia").getAsJsonObject();
+
+ List<String> triviaSolutionsList = triviaSolutions.entrySet().stream()
+ .map(Map.Entry::getKey)
+ .collect(Collectors.toCollection(ArrayList::new));
+ for (String question : triviaSolutionsList) {
+ if (message.contains(question)) {
+ triviaAnswersJson = triviaSolutions.get(question).getAsJsonArray();
+ break;
+ }
}
}
- }
- // Set wrong answers to red and remove click events
- if (triviaAnswers != null && (message.contains("ⓐ") || message.contains("ⓑ") || message.contains("ⓒ"))) {
- boolean isSolution = false;
- for (String solution : triviaAnswers) {
- if (message.contains(solution)) {
- isSolution = true;
- break;
+ // Set wrong answers to red and remove click events
+ if (triviaAnswersJson != null && (message.contains("ⓐ") || message.contains("ⓑ") || message.contains("ⓒ"))) {
+ boolean isSolution = false;
+ for (int i = 0; i < triviaAnswersJson.size(); i++) {
+ String solution = triviaAnswersJson.get(i).getAsString();
+ if (message.contains(solution)) {
+ isSolution = true;
+ break;
+ }
+ }
+ if (!isSolution) {
+ char letter = message.charAt(5);
+ String option = message.substring(6);
+ event.message = new ChatComponentText(" " + EnumChatFormatting.GOLD + letter + TRIVIA_WRONG_ANSWER_COLOUR + option);
+ }
+ }
+ } else {
+ 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 {
+ for (String question : triviaSolutions.keySet()) {
+ if (message.contains(question)) {
+ triviaAnswers = triviaSolutions.get(question);
+ break;
+ }
}
}
- if (!isSolution) {
- char letter = message.charAt(5);
- String option = message.substring(6);
- event.message = new ChatComponentText(" " + EnumChatFormatting.GOLD + letter + TRIVIA_WRONG_ANSWER_COLOUR + option);
+
+ // Set wrong answers to red and remove click events
+ if (triviaAnswers != null && (message.contains("ⓐ") || message.contains("ⓑ") || message.contains("ⓒ"))) {
+ boolean isSolution = false;
+ for (String solution : triviaAnswers) {
+ if (message.contains(solution)) {
+ isSolution = true;
+ break;
+ }
+ }
+ if (!isSolution) {
+ char letter = message.charAt(5);
+ String option = message.substring(6);
+ event.message = new ChatComponentText(" " + EnumChatFormatting.GOLD + letter + TRIVIA_WRONG_ANSWER_COLOUR + option);
+ }
}
}
}
diff --git a/src/main/java/me/Danker/gui/EditLocationsGui.java b/src/main/java/me/Danker/gui/EditLocationsGui.java
index 2c8b336..fed6ee9 100644
--- a/src/main/java/me/Danker/gui/EditLocationsGui.java
+++ b/src/main/java/me/Danker/gui/EditLocationsGui.java
@@ -1,6 +1,5 @@
package me.Danker.gui;
-import javafx.scene.transform.Scale;
import me.Danker.DankersSkyblockMod;
import me.Danker.commands.MoveCommand;
import me.Danker.commands.ScaleCommand;
@@ -14,8 +13,6 @@ import net.minecraft.client.gui.GuiScreen;
import net.minecraft.util.EnumChatFormatting;
import org.lwjgl.opengl.GL11;
-import javax.xml.stream.Location;
-
public class EditLocationsGui extends GuiScreen {
private String moving = null;