diff options
Diffstat (limited to 'src/main/java/me/Danker')
5 files changed, 51 insertions, 0 deletions
diff --git a/src/main/java/me/Danker/DankersSkyblockMod.java b/src/main/java/me/Danker/DankersSkyblockMod.java index 39653ca..07ba904 100644 --- a/src/main/java/me/Danker/DankersSkyblockMod.java +++ b/src/main/java/me/Danker/DankersSkyblockMod.java @@ -106,6 +106,7 @@ public class DankersSkyblockMod { MinecraftForge.EVENT_BUS.register(new ArrowTerminalSolver()); MinecraftForge.EVENT_BUS.register(new AutoAcceptReparty()); MinecraftForge.EVENT_BUS.register(new AutoDisplay()); + MinecraftForge.EVENT_BUS.register(new AutoJoinSkyblock()); MinecraftForge.EVENT_BUS.register(new AutoSwapToPickBlock()); MinecraftForge.EVENT_BUS.register(new BlazeSolver()); MinecraftForge.EVENT_BUS.register(new BlockPlacingFlowers()); diff --git a/src/main/java/me/Danker/commands/ToggleCommand.java b/src/main/java/me/Danker/commands/ToggleCommand.java index 8bce0b3..9c56958 100644 --- a/src/main/java/me/Danker/commands/ToggleCommand.java +++ b/src/main/java/me/Danker/commands/ToggleCommand.java @@ -49,6 +49,7 @@ public class ToggleCommand extends CommandBase implements ICommand { public static boolean alerts; public static boolean dungeonScore; public static boolean hideArmour; + public static boolean autoJoinSkyblock; // Chat Messages public static boolean sceptreMessages; public static boolean midasStaffMessages; diff --git a/src/main/java/me/Danker/features/AutoJoinSkyblock.java b/src/main/java/me/Danker/features/AutoJoinSkyblock.java new file mode 100644 index 0000000..91d6039 --- /dev/null +++ b/src/main/java/me/Danker/features/AutoJoinSkyblock.java @@ -0,0 +1,41 @@ +package me.Danker.features; + +import me.Danker.commands.ToggleCommand; +import me.Danker.utils.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.network.FMLNetworkEvent; + +public class AutoJoinSkyblock { + + static boolean joinedServer = false; + + @SubscribeEvent + public void onConnect(FMLNetworkEvent.ClientConnectedToServerEvent event) { + if (ToggleCommand.autoJoinSkyblock && !joinedServer) { + joinedServer = true; + new Thread(() -> { + EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; + + try { + while (player == null) { + Thread.sleep(100); + player = Minecraft.getMinecraft().thePlayer; + } + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + if (Utils.isOnHypixel()) player.sendChatMessage("/play sb"); + }).start(); + } + } + + @SubscribeEvent + public void onDisconnect(FMLNetworkEvent.ClientDisconnectionFromServerEvent event) { + joinedServer = false; + } + +} diff --git a/src/main/java/me/Danker/gui/DankerGui.java b/src/main/java/me/Danker/gui/DankerGui.java index fb84b0a..2900489 100644 --- a/src/main/java/me/Danker/gui/DankerGui.java +++ b/src/main/java/me/Danker/gui/DankerGui.java @@ -87,6 +87,7 @@ public class DankerGui extends GuiScreen { private GuiButton bonzoTimer; private GuiButton dungeonScore; private GuiButton hideArmour; + private GuiButton autoJoinSkyblock; // Chat Messages private GuiButton sceptreMessages; private GuiButton midasStaffMessages; @@ -178,6 +179,7 @@ public class DankerGui extends GuiScreen { abilityCooldown = new FeatureButton("Ability Cooldowns: " + Utils.getColouredBoolean(ToggleCommand.abilityCooldowns), "Displays ability cooldowns."); dungeonScore = new FeatureButton("Dungeon Score Display: " + Utils.getColouredBoolean(ToggleCommand.dungeonScore), "Displays an estimated dungeon score with secrets."); hideArmour = new FeatureButton("Hide Player Armour: " + Utils.getColouredBoolean(ToggleCommand.hideArmour), "Makes player armour invisible, showing their skin."); + autoJoinSkyblock = new FeatureButton("Automatically Join Skyblock: " + Utils.getColouredBoolean(ToggleCommand.autoJoinSkyblock), "Automatically join Skyblock when you join Hypixel.\nYou have an addiction."); allButtons.clear(); allButtons.add(changeDisplay); @@ -235,6 +237,7 @@ public class DankerGui extends GuiScreen { allButtons.add(abilityCooldown); allButtons.add(dungeonScore); allButtons.add(hideArmour); + allButtons.add(autoJoinSkyblock); search.setText(initSearchText); search.setVisible(true); @@ -518,6 +521,10 @@ public class DankerGui extends GuiScreen { ToggleCommand.hideArmour = !ToggleCommand.hideArmour; ConfigHandler.writeBooleanConfig("toggles", "HideArmour", ToggleCommand.hideArmour); hideArmour.displayString = "Hide Player Armour: " + Utils.getColouredBoolean(ToggleCommand.hideArmour); + } else if (button == autoJoinSkyblock) { + ToggleCommand.autoJoinSkyblock = !ToggleCommand.autoJoinSkyblock; + ConfigHandler.writeBooleanConfig("toggles", "AutoJoinSkyblock", ToggleCommand.autoJoinSkyblock); + autoJoinSkyblock.displayString = "Automatically Join Skyblock: " + Utils.getColouredBoolean(ToggleCommand.autoJoinSkyblock); } } diff --git a/src/main/java/me/Danker/handlers/ConfigHandler.java b/src/main/java/me/Danker/handlers/ConfigHandler.java index 14386e4..21fa57f 100644 --- a/src/main/java/me/Danker/handlers/ConfigHandler.java +++ b/src/main/java/me/Danker/handlers/ConfigHandler.java @@ -242,6 +242,7 @@ public class ConfigHandler { ToggleCommand.alerts = initBoolean("toggles", "Alerts", false); ToggleCommand.dungeonScore = initBoolean("toggles", "DungeonScore", false); ToggleCommand.hideArmour = initBoolean("toggles", "HideArmour", false); + ToggleCommand.autoJoinSkyblock = initBoolean("toggles", "AutoJoinSkyblock", false); // Chat Messages ToggleCommand.sceptreMessages = initBoolean("toggles", "SceptreMessages", true); ToggleCommand.midasStaffMessages = initBoolean("toggles", "MidasStaffMessages", true); |