aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr
diff options
context:
space:
mode:
authorsyeyoung <cyong06@naver.com>2021-03-06 13:01:03 +0900
committersyeyoung <cyong06@naver.com>2021-03-06 13:01:03 +0900
commitccdcb508b1b7b5fcc212efc39466434631118e87 (patch)
treef09e4fb0db49a10a1f91757c0432a908e6f89a6d /src/main/java/kr
parentd07cfe08841302ad1ce1e29902d06c4c439a589f (diff)
downloadSkyblock-Dungeons-Guide-ccdcb508b1b7b5fcc212efc39466434631118e87.tar.gz
Skyblock-Dungeons-Guide-ccdcb508b1b7b5fcc212efc39466434631118e87.tar.bz2
Skyblock-Dungeons-Guide-ccdcb508b1b7b5fcc212efc39466434631118e87.zip
UHH why would you troll
Diffstat (limited to 'src/main/java/kr')
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/RichPresenceManager.java39
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/party/PartyManager.java5
2 files changed, 29 insertions, 15 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/RichPresenceManager.java b/src/main/java/kr/syeyoung/dungeonsguide/RichPresenceManager.java
index 422d15e1..641522a6 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/RichPresenceManager.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/RichPresenceManager.java
@@ -6,18 +6,23 @@ import kr.syeyoung.dungeonsguide.features.FeatureRegistry;
import kr.syeyoung.dungeonsguide.party.PartyManager;
import kr.syeyoung.dungeonsguide.stomp.StompHeader;
import kr.syeyoung.dungeonsguide.stomp.StompPayload;
-import net.arikia.dev.drpc.DiscordEventHandlers;
-import net.arikia.dev.drpc.DiscordRPC;
-import net.arikia.dev.drpc.DiscordRichPresence;
-import net.arikia.dev.drpc.DiscordUser;
+import net.arikia.dev.drpc.*;
import net.arikia.dev.drpc.callbacks.*;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import org.json.JSONObject;
-public class RichPresenceManager implements JoinRequestCallback, JoinGameCallback, ErroredCallback, DisconnectedCallback {
+import java.io.*;
+import java.net.URL;
+
+public class RichPresenceManager implements JoinRequestCallback, JoinGameCallback, ErroredCallback, DisconnectedCallback, Runnable {
public static RichPresenceManager INSTANCE = new RichPresenceManager();
+ public RichPresenceManager() {
+ setup();
+ new Thread(this).start();
+ Runtime.getRuntime().addShutdownHook(new Thread(DiscordRPC::discordShutdown));
+ }
public void setup() {
DiscordRPC.discordInitialize("816298079732498473", new DiscordEventHandlers.Builder()
.setReadyEventHandler(new ReadyCallback() {
@@ -36,7 +41,6 @@ public class RichPresenceManager implements JoinRequestCallback, JoinGameCallbac
public void updatePresence() {
- nextUpdate= System.currentTimeMillis() + 10000L;
if (!skyblockStatus.isOnHypixel() || !FeatureRegistry.ADVANCED_RICHPRESENCE.isEnabled()) {
DiscordRPC.discordClearPresence();
} else {
@@ -67,17 +71,9 @@ public class RichPresenceManager implements JoinRequestCallback, JoinGameCallbac
}
private String lastLoc = "";
- private long nextUpdate = System.currentTimeMillis() + 10000L;
+
@SubscribeEvent
public void tick(TickEvent.ClientTickEvent clientTickEvent) {
- try {
- if (skyblockStatus.isOnSkyblock() && !lastLoc.equalsIgnoreCase(skyblockStatus.getDungeonName())) {
- lastLoc = skyblockStatus.getDungeonName()+"";
- updatePresence();
- } else if (nextUpdate < System.currentTimeMillis()) {
- updatePresence();
- }
- } catch (Exception e) {e.printStackTrace();}
}
@Override
@@ -99,4 +95,17 @@ public class RichPresenceManager implements JoinRequestCallback, JoinGameCallbac
System.out.println(user.username+" wants to join");
DiscordRPC.discordRespond(user.userId, DiscordRPC.DiscordReply.YES);
}
+
+ @Override
+ public void run() {
+ while(true) {
+ try {
+ DiscordRPC.discordRunCallbacks();
+ if (skyblockStatus.isOnSkyblock() && !lastLoc.equalsIgnoreCase(skyblockStatus.getDungeonName())) {
+ lastLoc = skyblockStatus.getDungeonName()+"";
+ }
+ updatePresence();
+ } catch (Exception e) {e.printStackTrace();}
+ }
+ }
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/party/PartyManager.java b/src/main/java/kr/syeyoung/dungeonsguide/party/PartyManager.java
index 08492ae8..e3c3ff49 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/party/PartyManager.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/party/PartyManager.java
@@ -148,6 +148,9 @@ public class PartyManager implements StompMessageHandler {
} else if (str.startsWith("§cYou are not currently in a party.§r")) {
members.clear();
setPartyID(null);
+ } else if (str.startsWith("§cYou are not in a party!§r")) {
+ members.clear();
+ setPartyID(null);
} else if (str.startsWith("§eParty ") && str.contains(":")) {
String playerNames = TextUtils.stripColor(str.split(":")[1]);
for (String s : playerNames.split(" ")) {
@@ -163,6 +166,8 @@ public class PartyManager implements StompMessageHandler {
RichPresenceManager.INSTANCE.updatePresence();
} else if (str.equals("§cCouldn't find a player with that name!§r")) {
canInvite = true;
+ } else if (str.equals("§cYou cannot invite that player since they're not online.")) {
+ canInvite = true;
} else if (str.endsWith("§aenabled All Invite§r")) {
canInvite = true;
} else if (str.endsWith("§cdisabled All Invite§r")) {