-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
ActivityExample.java
65 lines (57 loc) · 1.62 KB
/
ActivityExample.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import de.jcm.discordgamesdk.Core;
import de.jcm.discordgamesdk.CreateParams;
import de.jcm.discordgamesdk.activity.Activity;
import java.io.File;
import java.io.IOException;
import java.time.Instant;
/**
* Example how to set a custom activity.
*/
public class ActivityExample
{
public static void main(String[] args) throws IOException
{
// Set parameters for the Core
try(CreateParams params = new CreateParams())
{
params.setClientID(698611073133051974L);
params.setFlags(CreateParams.getDefaultFlags());
// Create the Core
try(Core core = new Core(params))
{
// Create the Activity
try(Activity activity = new Activity())
{
activity.setDetails("Running an example");
activity.setState("and having fun");
// Setting a start time causes an "elapsed" field to appear
activity.timestamps().setStart(Instant.now());
// We are in a party with 10 out of 100 people.
activity.party().size().setMaxSize(100);
activity.party().size().setCurrentSize(10);
// Make a "cool" image show up
activity.assets().setLargeImage("test");
// Setting a join secret and a party ID causes an "Ask to Join" button to appear
activity.party().setID("Party!");
activity.secrets().setJoinSecret("Join!");
// Finally, update the current activity to our activity
core.activityManager().updateActivity(activity);
}
// Run callbacks forever
while(true)
{
core.runCallbacks();
try
{
// Sleep a bit to save CPU
Thread.sleep(16);
}
catch(InterruptedException e)
{
e.printStackTrace();
}
}
}
}
}
}