aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/Danker
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/me/Danker')
-rw-r--r--src/main/java/me/Danker/DankersSkyblockMod.java19
-rw-r--r--src/main/java/me/Danker/commands/ReloadRepoCommand.java15
-rw-r--r--src/main/java/me/Danker/commands/ToggleCommand.java2
-rw-r--r--src/main/java/me/Danker/utils/Utils.java12
4 files changed, 23 insertions, 25 deletions
diff --git a/src/main/java/me/Danker/DankersSkyblockMod.java b/src/main/java/me/Danker/DankersSkyblockMod.java
index 1b736ca..9ee1d33 100644
--- a/src/main/java/me/Danker/DankersSkyblockMod.java
+++ b/src/main/java/me/Danker/DankersSkyblockMod.java
@@ -10,7 +10,6 @@ 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;
@@ -58,11 +57,9 @@ import org.lwjgl.input.Mouse;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
-import java.util.stream.Collectors;
@Mod(modid = DankersSkyblockMod.MODID, version = DankersSkyblockMod.VERSION, clientSideOnly = true)
public class DankersSkyblockMod {
@@ -72,6 +69,7 @@ public class DankersSkyblockMod {
public static boolean showTitle = false;
public static String titleText = "";
public static int tickAmount = 1;
+ public static int repoTickAmount = 1;
public static KeyBinding[] keyBindings = new KeyBinding[3];
public static boolean usingLabymod = false;
public static boolean usingOAM = false;
@@ -167,13 +165,7 @@ public class DankersSkyblockMod {
ClientRegistry.registerKeyBinding(keyBinding);
}
- new Thread(() -> {
- 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")));
- ColouredNames.users = data.get("colourednames").getAsJsonObject().entrySet().stream()
- .map(Map.Entry::getKey)
- .collect(Collectors.toCollection(ArrayList::new));
- }).start();
+ new Thread(Utils::refreshRepo).start();
}
@EventHandler
@@ -359,6 +351,7 @@ public class DankersSkyblockMod {
tickAmount++;
if (tickAmount % 20 == 0) {
+ repoTickAmount++;
if (player != null) {
Utils.checkForSkyblock();
Utils.checkForDungeons();
@@ -367,6 +360,12 @@ public class DankersSkyblockMod {
tickAmount = 0;
}
+ if (repoTickAmount % 3601 == 0) {
+ // I didn't want to change everything so I just made a new tick variable
+ new Thread(Utils::refreshRepo).start();
+ repoTickAmount = 1;
+ }
+
if (titleTimer >= 0) {
if (titleTimer == 0) {
showTitle = false;
diff --git a/src/main/java/me/Danker/commands/ReloadRepoCommand.java b/src/main/java/me/Danker/commands/ReloadRepoCommand.java
index 1681971..a50a5c8 100644
--- a/src/main/java/me/Danker/commands/ReloadRepoCommand.java
+++ b/src/main/java/me/Danker/commands/ReloadRepoCommand.java
@@ -1,18 +1,13 @@
package me.Danker.commands;
import me.Danker.DankersSkyblockMod;
-import me.Danker.features.ColouredNames;
-import me.Danker.handlers.APIHandler;
+import me.Danker.utils.Utils;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ChatComponentText;
-import java.util.ArrayList;
-import java.util.Map;
-import java.util.stream.Collectors;
-
public class ReloadRepoCommand extends CommandBase {
@Override
@@ -39,13 +34,7 @@ public class ReloadRepoCommand extends CommandBase {
// MULTI THREAD DRIFTING
new Thread(() -> {
EntityPlayer player = (EntityPlayer) arg0;
-
- 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")));
- ColouredNames.users = DankersSkyblockMod.data.get("colourednames").getAsJsonObject().entrySet().stream()
- .map(Map.Entry::getKey)
- .collect(Collectors.toCollection(ArrayList::new));
-
+ Utils.refreshRepo();
player.addChatMessage(new ChatComponentText(DankersSkyblockMod.MAIN_COLOUR + "Refreshed Danker's Skyblock Mod repo."));
}).start();
}
diff --git a/src/main/java/me/Danker/commands/ToggleCommand.java b/src/main/java/me/Danker/commands/ToggleCommand.java
index 44b1df2..3770d8f 100644
--- a/src/main/java/me/Danker/commands/ToggleCommand.java
+++ b/src/main/java/me/Danker/commands/ToggleCommand.java
@@ -1,9 +1,7 @@
package me.Danker.commands;
-import jdk.nashorn.internal.runtime.regexp.joni.Config;
import me.Danker.DankersSkyblockMod;
import me.Danker.features.CustomMusic;
-import me.Danker.features.EndOfFarmAlert;
import me.Danker.handlers.ConfigHandler;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
diff --git a/src/main/java/me/Danker/utils/Utils.java b/src/main/java/me/Danker/utils/Utils.java
index e2dde4b..e1a99ea 100644
--- a/src/main/java/me/Danker/utils/Utils.java
+++ b/src/main/java/me/Danker/utils/Utils.java
@@ -1,7 +1,9 @@
package me.Danker.utils;
import me.Danker.DankersSkyblockMod;
+import me.Danker.features.ColouredNames;
import me.Danker.features.GoldenEnchants;
+import me.Danker.handlers.APIHandler;
import me.Danker.handlers.ConfigHandler;
import me.Danker.handlers.ScoreboardHandler;
import me.Danker.handlers.TextRenderer;
@@ -30,6 +32,7 @@ import java.util.List;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import java.util.stream.Collectors;
public class Utils {
@@ -614,4 +617,13 @@ public class Utils {
return level;
}
+ public static void refreshRepo() {
+ 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")));
+ ColouredNames.users = DankersSkyblockMod.data.get("colourednames").getAsJsonObject().entrySet().stream()
+ .map(Map.Entry::getKey)
+ .collect(Collectors.toCollection(ArrayList::new));
+ System.out.println("Refreshed DSM repo at " + System.currentTimeMillis());
+ }
+
}