aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorsyeyoung <cyong06@naver.com>2021-03-03 00:06:40 +0900
committersyeyoung <cyong06@naver.com>2021-03-03 00:06:40 +0900
commit55e475a31c722a3e9e3bd3216bc0e0d396b6f359 (patch)
treee4401081a5838592edcf0dd1f7c7572862616296 /src/main
parent0b9a21c54720ca8a3c271c2dacbe98df9dac03b2 (diff)
downloadSkyblock-Dungeons-Guide-55e475a31c722a3e9e3bd3216bc0e0d396b6f359.tar.gz
Skyblock-Dungeons-Guide-55e475a31c722a3e9e3bd3216bc0e0d396b6f359.tar.bz2
Skyblock-Dungeons-Guide-55e475a31c722a3e9e3bd3216bc0e0d396b6f359.zip
temp
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/RichPresenceManager.java74
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/e.java22
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java1
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureWarningOnPortal.java2
4 files changed, 85 insertions, 14 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/RichPresenceManager.java b/src/main/java/kr/syeyoung/dungeonsguide/RichPresenceManager.java
new file mode 100644
index 00000000..f3b75d41
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/RichPresenceManager.java
@@ -0,0 +1,74 @@
+package kr.syeyoung.dungeonsguide;
+
+import com.jagrosh.discordipc.IPCClient;
+import com.jagrosh.discordipc.IPCListener;
+import com.jagrosh.discordipc.entities.Packet;
+import com.jagrosh.discordipc.entities.RichPresence;
+import com.jagrosh.discordipc.entities.User;
+import com.jagrosh.discordipc.exceptions.NoDiscordClientException;
+import kr.syeyoung.dungeonsguide.events.SkyblockJoinedEvent;
+import kr.syeyoung.dungeonsguide.events.SkyblockLeftEvent;
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+import org.json.JSONObject;
+
+import java.time.OffsetDateTime;
+
+public class RichPresenceManager implements IPCListener {
+ public static RichPresenceManager INSTANCE = new RichPresenceManager();
+
+ private IPCClient ipcClient;
+ public void setup() throws NoDiscordClientException {
+ ipcClient = new IPCClient(816298079732498473L);
+ ipcClient.setListener(this);
+ ipcClient.connect();
+ }
+
+ @Override
+ public void onReady(IPCClient client) {
+ updatePresence();
+ }
+
+ @Override
+ public void onActivityJoinRequest(IPCClient client, String secret, User user) {
+ System.out.println(user.getAsMention()+" wanna join");
+ }
+
+ @Override
+ public void onPacketReceived(IPCClient client, Packet packet) {
+ System.out.println("Packet recv from rpc "+packet);
+ }
+
+ @Override
+ public void onDisconnect(IPCClient client, Throwable t) {
+ t.printStackTrace();
+ try {
+ setup();
+ } catch (NoDiscordClientException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private SkyblockStatus skyblockStatus = e.getDungeonsGuide().getSkyblockStatus();
+
+
+ public void updatePresence() {
+ if (!skyblockStatus.isOnHypixel()) {
+ ipcClient.sendRichPresence(null);
+ } else {
+ ipcClient.sendRichPresence(new RichPresence.Builder()
+ .setJoinSecret(""));
+ }
+ }
+
+ private String JOIN_SECRET;
+
+
+ @SubscribeEvent
+ public void joinSkyblock(SkyblockJoinedEvent skyblockJoinedEvent) {
+ updatePresence();
+ }
+ @SubscribeEvent
+ public void leaveSkyblock(SkyblockLeftEvent skyblockLeftEvent) {
+ updatePresence();
+ }
+}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/e.java b/src/main/java/kr/syeyoung/dungeonsguide/e.java
index 98fac826..5bc3f0d7 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/e.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/e.java
@@ -1,5 +1,7 @@
package kr.syeyoung.dungeonsguide;
+import com.jagrosh.discordipc.entities.RichPresence;
+import com.jagrosh.discordipc.exceptions.NoDiscordClientException;
import kr.syeyoung.dungeonsguide.commands.*;
import kr.syeyoung.dungeonsguide.config.Config;
import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoomInfoRegistry;
@@ -95,19 +97,7 @@ public class e implements c, CloseListener {
progressbar.step("Downloading Roomdatas");
try {
DungeonRoomInfoRegistry.loadAll(configDir);
- } catch (BadPaddingException e) {
- e.printStackTrace();
- } catch (InvalidAlgorithmParameterException e) {
- e.printStackTrace();
- } catch (NoSuchAlgorithmException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- } catch (IllegalBlockSizeException e) {
- e.printStackTrace();
- } catch (NoSuchPaddingException e) {
- e.printStackTrace();
- } catch (InvalidKeyException e) {
+ } catch (BadPaddingException | InvalidKeyException | NoSuchPaddingException | IllegalBlockSizeException | IOException | NoSuchAlgorithmException | InvalidAlgorithmParameterException e) {
e.printStackTrace();
}
Keybinds.register();
@@ -119,6 +109,12 @@ public class e implements c, CloseListener {
} catch (Exception e) {
throw new RuntimeException(e);
}
+ try {
+ RichPresenceManager.INSTANCE.setup();
+ } catch (NoDiscordClientException e) {
+ e.printStackTrace();
+ }
+ MinecraftForge.EVENT_BUS.register(RichPresenceManager.INSTANCE);
progressbar.step("Loading Config");
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java
index c758bc25..762527cf 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java
@@ -46,6 +46,7 @@ public class FeatureRegistry {
public static final FeatureRoomDebugInfo ADVANCED_DEBUG_ROOM = register(new FeatureRoomDebugInfo());
public static final FeatureDebuggableMap ADVANCED_DEBUGGABLE_MAP = register(new FeatureDebuggableMap());
public static final FeatureRoomCoordDisplay ADVANCED_COORDS = register(new FeatureRoomCoordDisplay());
+ public static final SimpleFeature ADVANCED_RICHPRESENCE = register(new SimpleFeature("Advanced", "Rich presence (Testing WIP)", "Will support ask to join", "advanced.testrich", false));
public static final SimpleFeature SOLVER_RIDDLE = register(new SimpleFeature("Solver", "Riddle Puzzle (3 weirdo) Solver", "Highlights the correct box after clicking on all 3 weirdos", "solver.riddle"));
public static final SimpleFeature SOLVER_KAHOOT = register(new SimpleFeature("Solver", "Trivia Puzzle (Omnicrescent) Solver", "Highlights the correct solution for trivia puzzle", "solver.trivia"));
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureWarningOnPortal.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureWarningOnPortal.java
index 2b4c42df..38c2c6f9 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureWarningOnPortal.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureWarningOnPortal.java
@@ -90,7 +90,7 @@ public class FeatureWarningOnPortal extends SimpleFeature implements StyledTextP
texts.add(new StyledText("There are at least "+context.getMapProcessor().getUndiscoveredRoom()+" undiscovered rooms!\n", "warning"));
} else if (!scoreCalculation.isFullyCleared()) {
texts.add(new StyledText("Some rooms are not fully cleared!\n", "warning"));
- } else if (scoreCalculation.getTombs() <= 5) {
+ } else if (scoreCalculation.getTombs() < 5) {
texts.add(new StyledText("Only less than 5 crypts are blown up!\n", "warning"));
} else {
texts.add(new StyledText("\n", "warning"));