diff --git a/src/main/java/net/aoba/AobaClient.java b/src/main/java/net/aoba/AobaClient.java index 5341b792..33043108 100644 --- a/src/main/java/net/aoba/AobaClient.java +++ b/src/main/java/net/aoba/AobaClient.java @@ -127,9 +127,6 @@ public void loadAssets() { altManager = new AltManager(); proxyManager = new ProxyManager(); - LogUtils.getLogger().info("[Aoba] Starting Discord RPC"); - rpcManager = new RPCManager(); - rpcManager.startRpc(); LogUtils.getLogger().info("[Aoba] Aoba-chan initialized and ready to play!"); SettingManager.loadGlobalSettings(); diff --git a/src/main/java/net/aoba/module/ModuleManager.java b/src/main/java/net/aoba/module/ModuleManager.java index 3eaa2f03..27662cb9 100644 --- a/src/main/java/net/aoba/module/ModuleManager.java +++ b/src/main/java/net/aoba/module/ModuleManager.java @@ -17,7 +17,7 @@ */ /** - * A class to represent a system that manages all of the Modules. + * A class to represent a system that manages all the Modules. */ package net.aoba.module; @@ -46,19 +46,7 @@ import net.aoba.module.modules.combat.Nametags; import net.aoba.module.modules.combat.Reach; import net.aoba.module.modules.combat.TriggerBot; -import net.aoba.module.modules.misc.AntiCactus; -import net.aoba.module.modules.misc.AntiHunger; -import net.aoba.module.modules.misc.AutoEat; -import net.aoba.module.modules.misc.AutoFish; -import net.aoba.module.modules.misc.AutoShear; -import net.aoba.module.modules.misc.AutoWalk; -import net.aoba.module.modules.misc.EXPThrower; -import net.aoba.module.modules.misc.FakePlayer; -import net.aoba.module.modules.misc.FastBreak; -import net.aoba.module.modules.misc.FastPlace; -import net.aoba.module.modules.misc.MCA; -import net.aoba.module.modules.misc.Timer; -import net.aoba.module.modules.misc.XCarry; +import net.aoba.module.modules.misc.*; import net.aoba.module.modules.movement.ClickTP; import net.aoba.module.modules.movement.EntityControl; import net.aoba.module.modules.movement.FastLadder; @@ -183,6 +171,7 @@ public class ModuleManager implements KeyDownListener { public XCarry xCarry = new XCarry(); public XRay xray = new XRay(); public Zoom zoom = new Zoom(); + public DiscordRPCModule discordRPC = new DiscordRPCModule(); public ModuleManager(List addons) { try { diff --git a/src/main/java/net/aoba/module/modules/misc/DiscordRPCModule.java b/src/main/java/net/aoba/module/modules/misc/DiscordRPCModule.java new file mode 100644 index 00000000..b3281908 --- /dev/null +++ b/src/main/java/net/aoba/module/modules/misc/DiscordRPCModule.java @@ -0,0 +1,33 @@ +package net.aoba.module.modules.misc; + +import net.aoba.module.Category; +import net.aoba.module.Module; +import net.aoba.utils.discord.RPCManager; + +public class DiscordRPCModule extends Module { + + public DiscordRPCModule() { + super("DiscordRPC"); + + this.setCategory(Category.of("Misc")); + this.setDescription("Toggles Discord RPC On and Off"); + } + + @Override + public void onDisable() { + RPCManager rpcManager = new RPCManager(); + rpcManager.stopRpc(); + // Turns the Discord RPC Off + } + + @Override + public void onEnable() { + RPCManager rpcManager = new RPCManager(); + rpcManager.startRpc(); + // Turns the Discord RPC On + } + + @Override + public void onToggle() { // OnEnable And Disable Handle + } +} diff --git a/src/main/java/net/aoba/utils/discord/RPCManager.java b/src/main/java/net/aoba/utils/discord/RPCManager.java index 4d7a8221..409439e9 100644 --- a/src/main/java/net/aoba/utils/discord/RPCManager.java +++ b/src/main/java/net/aoba/utils/discord/RPCManager.java @@ -61,6 +61,23 @@ public void startRpc() { } } + /* + Stops the Discord Rich Presence (RPC). + */ + public void stopRpc() { + if (started) { + started = false; + + if (thread != null && thread.isAlive()) { + thread.interrupt(); + } + + rpc.Discord_Shutdown(); + + thread = null; + } + } + private String getDetails() { String result = "";