-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7fca3f6
commit ad1bd5d
Showing
5 changed files
with
89 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
mod_id=scc | ||
mod_name=Skyclient Cosmetics | ||
mod_version=BETA-2 | ||
mod_version=BETA-3 | ||
mod_description=Cosmetics for the mod installer Skyclient! | ||
|
||
org.gradle.jvmargs=-Xmx2G |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package io.github.koxx12_dev.scc.Utils; | ||
|
||
import io.github.koxx12_dev.scc.GUI.SCCConfig; | ||
import io.github.koxx12_dev.scc.SCC; | ||
import net.arikia.dev.drpc.DiscordEventHandlers; | ||
import net.arikia.dev.drpc.DiscordRPC; | ||
import net.arikia.dev.drpc.DiscordRichPresence; | ||
import net.minecraft.client.Minecraft; | ||
|
||
import java.time.Instant; | ||
|
||
public class RPC implements Runnable { | ||
|
||
public static RPC INSTANCE = new RPC(); | ||
|
||
private Thread trd = new Thread(this); | ||
|
||
private long timestamp = Instant.now().getEpochSecond(); | ||
|
||
public void RPCManager() { | ||
trd.start(); | ||
Runtime.getRuntime().addShutdownHook(new Thread(() -> { | ||
System.out.println("Closing Discord hook."); | ||
DiscordRPC.discordShutdown(); | ||
})); | ||
} | ||
|
||
public void initRPC() { | ||
|
||
DiscordEventHandlers handlers = new DiscordEventHandlers.Builder().setReadyEventHandler((user) -> { | ||
System.out.println("Discord user: " + user.username); | ||
DiscordRichPresence.Builder presence = new DiscordRichPresence.Builder(SCCConfig.RPCText); | ||
presence.setDetails(Minecraft.getMinecraft().getSession().getUsername()+" is very cool"); | ||
presence.setBigImage("skyclienticon","skyclient is very cool"); | ||
presence.setStartTimestamps(timestamp); | ||
DiscordRPC.discordUpdatePresence(presence.build()); | ||
SCC.RPCon = true; | ||
}).build(); | ||
DiscordRPC.discordInitialize("857240025288802356", handlers, true); | ||
} | ||
|
||
public void updateRPC() { | ||
|
||
if (!SCCConfig.RPC) { | ||
DiscordRPC.discordClearPresence(); | ||
} else { | ||
DiscordRichPresence.Builder presence = new DiscordRichPresence.Builder(SCCConfig.RPCText); | ||
presence.setDetails(Minecraft.getMinecraft().getSession().getUsername()+" is very cool"); | ||
presence.setBigImage("skyclienticon","skyclient is very cool"); | ||
presence.setStartTimestamps(timestamp); | ||
DiscordRPC.discordUpdatePresence(presence.build()); | ||
} | ||
|
||
} | ||
|
||
@Override | ||
public void run() { | ||
try { | ||
Thread.sleep(300L); | ||
initRPC(); | ||
while(!Thread.interrupted()) { | ||
DiscordRPC.discordRunCallbacks(); | ||
Thread.sleep(300L); | ||
updateRPC(); | ||
} | ||
} catch (Exception e) {e.printStackTrace();} | ||
} | ||
} |