aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java
diff options
context:
space:
mode:
authorThatGravyBoat <thatgravyboat@gmail.com>2021-07-27 04:38:13 -0230
committerThatGravyBoat <thatgravyboat@gmail.com>2021-07-27 04:38:13 -0230
commit7809a1362c9644c9bfb69d8563a13e3f1ed3354a (patch)
treed8e1a33db7656aa2aeaa9fcc44e2310df35b774d /src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java
parent39749967fc92a3976b231285492d71f8782e93da (diff)
downloadSkyblockHud-Death-Defied-7809a1362c9644c9bfb69d8563a13e3f1ed3354a.tar.gz
SkyblockHud-Death-Defied-7809a1362c9644c9bfb69d8563a13e3f1ed3354a.tar.bz2
SkyblockHud-Death-Defied-7809a1362c9644c9bfb69d8563a13e3f1ed3354a.zip
Added Dynamic Item Cooldowns.
Updated Profile Events to contain profile name. Added copy NPC skin command. Added warphandler gives me access to what warps you have. Moved all config and data files into its own folder. Added option to turn off adding back overflow mana.
Diffstat (limited to 'src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java')
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java35
1 files changed, 25 insertions, 10 deletions
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java b/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java
index 4741a1b..9b3da58 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java
@@ -5,6 +5,7 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.thatgravyboat.skyblockhud.api.KillTracking;
import com.thatgravyboat.skyblockhud.api.LeaderboardGetter;
+import com.thatgravyboat.skyblockhud.api.events.ProfileJoinedEvent;
import com.thatgravyboat.skyblockhud.api.events.ProfileSwitchedEvent;
import com.thatgravyboat.skyblockhud.commands.Commands;
import com.thatgravyboat.skyblockhud.config.KeyBindings;
@@ -51,7 +52,7 @@ import org.lwjgl.input.Keyboard;
public class SkyblockHud {
public static final String MODID = "skyblockhud";
- public static final String VERSION = "1.12";
+ public static final String VERSION = "1.13";
public static SBHConfig config;
@@ -61,7 +62,7 @@ public class SkyblockHud {
private final Gson gson = new GsonBuilder().setPrettyPrinting().excludeFieldsWithoutExposeAnnotation().create();
- private static File configDirectory;
+ public static File configDirectory;
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
@@ -88,12 +89,17 @@ public class SkyblockHud {
MinecraftForge.EVENT_BUS.register(new ActionBarParsing());
MinecraftForge.EVENT_BUS.register(new CrystalWaypoints());
MinecraftForge.EVENT_BUS.register(new FarmHouseHandler());
+ MinecraftForge.EVENT_BUS.register(new WarpHandler());
+ MinecraftForge.EVENT_BUS.register(new CooldownHandler());
Commands.init();
((IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager()).registerReloadListener(new NpcDialogue());
((IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager()).registerReloadListener(new Textures());
- configFile = new File(event.getModConfigurationDirectory(), "sbh-config.json");
+ configDirectory = new File(event.getModConfigurationDirectory(), "skyblockhud");
+ try { configDirectory.mkdir(); } catch (Exception ignored){}
+
+ configFile = new File(configDirectory, "sbh-config.json");
if (configFile.exists()) {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(configFile), StandardCharsets.UTF_8))) {
@@ -108,10 +114,12 @@ public class SkyblockHud {
Textures.setTexture(config.misc.style);
- configDirectory = event.getModConfigurationDirectory();
+ if (WarpHandler.load()) {
+ WarpHandler.save();
+ }
Runtime.getRuntime().addShutdownHook(new Thread(this::saveConfig));
- Runtime.getRuntime().addShutdownHook(new Thread(() -> TrackerFileLoader.saveTrackerStatsFile(event.getModConfigurationDirectory())));
+ Runtime.getRuntime().addShutdownHook(new Thread(TrackerFileLoader::saveTrackerStatsFile));
}
public void saveConfig() {
@@ -139,14 +147,14 @@ public class SkyblockHud {
public void loadComplete(FMLLoadCompleteEvent event) {
TrackerFileLoader.loadTrackersFile();
- if (TrackerFileLoader.loadTrackerStatsFile(configDirectory)) {
- TrackerFileLoader.saveTrackerStatsFile(configDirectory);
+ if (TrackerFileLoader.loadTrackerStatsFile()) {
+ TrackerFileLoader.saveTrackerStatsFile();
}
}
@SubscribeEvent
public void onLeaveServer(FMLNetworkEvent.ClientDisconnectionFromServerEvent event) {
- TrackerFileLoader.saveTrackerStatsFile(configDirectory);
+ TrackerFileLoader.saveTrackerStatsFile();
}
public static boolean hasSkyblockScoreboard() {
@@ -180,8 +188,15 @@ public class SkyblockHud {
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onStatusBar(ClientChatReceivedEvent event) {
- if (Utils.removeColor(event.message.getUnformattedText()).toLowerCase().trim().startsWith("your profile was changed to:")) {
- MinecraftForge.EVENT_BUS.post(new ProfileSwitchedEvent());
+ String message = Utils.removeColor(event.message.getUnformattedText()).toLowerCase().trim();
+
+ if (message.startsWith("your profile was changed to:")) {
+ String stripped = message.replace("your profile was changed to:", "").replace("(co-op)", "").trim();
+ MinecraftForge.EVENT_BUS.post(new ProfileSwitchedEvent(stripped));
+ }
+ if (message.startsWith("you are playing on profile:")){
+ String stripped = message.replace("you are playing on profile:", "").replace("(co-op)", "").trim();
+ MinecraftForge.EVENT_BUS.post(new ProfileJoinedEvent(stripped));
}
}