Skip to content

Commit

Permalink
Merge pull request #72 from discomal101/master
Browse files Browse the repository at this point in the history
Added A Toggle To Discord RPC
  • Loading branch information
coltonk9043 authored Dec 1, 2024
2 parents fd2689c + 2e1e742 commit 7c8eb00
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 17 deletions.
3 changes: 0 additions & 3 deletions src/main/java/net/aoba/AobaClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
17 changes: 3 additions & 14 deletions src/main/java/net/aoba/module/ModuleManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<IAddon> addons) {
try {
Expand Down
33 changes: 33 additions & 0 deletions src/main/java/net/aoba/module/modules/misc/DiscordRPCModule.java
Original file line number Diff line number Diff line change
@@ -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
}
}
17 changes: 17 additions & 0 deletions src/main/java/net/aoba/utils/discord/RPCManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";

Expand Down

0 comments on commit 7c8eb00

Please sign in to comment.