Skip to content

Commit 2f42aa2

Browse files
committed
added rich presence builder
updated ver and readme
1 parent 3de70f8 commit 2f42aa2

File tree

4 files changed

+140
-47
lines changed

4 files changed

+140
-47
lines changed

.gitignore

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
1-
# Compiled class file
2-
*.class
3-
4-
# Log file
5-
*.log
6-
7-
# BlueJ files
8-
*.ctxt
9-
10-
# Mobile Tools for Java (J2ME)
11-
.mtj.tmp/
12-
13-
# Package Files #
14-
*.jar
15-
*.war
16-
*.ear
17-
*.zip
18-
*.tar.gz
19-
*.rar
20-
21-
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
22-
hs_err_pid*
23-
24-
# Intellij Project Files
25-
/.idea/
26-
/out/
27-
*.iml
28-
29-
# Testing
30-
/src/test/
1+
# Compiled class file
2+
*.class
3+
4+
# Log file
5+
*.log
6+
7+
# BlueJ files
8+
*.ctxt
9+
10+
# Mobile Tools for Java (J2ME)
11+
.mtj.tmp/
12+
13+
# Package Files #
14+
*.jar
15+
*.war
16+
*.ear
17+
*.zip
18+
*.tar.gz
19+
*.rar
20+
21+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
22+
hs_err_pid*
23+
24+
# Intellij Project Files
25+
/.idea/
26+
/out/
27+
*.iml
28+
29+
# Testing
30+
/src/test/
31+
/target/

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
[version]: https://api.bintray.com/packages/jagrosh/maven/Discord-IPC/images/download.svg
1+
[version]: https://api.bintray.com/packages/jagrosh/maven/DiscordIPC/images/download.svg
22
[download]: https://bintray.com/jagrosh/maven/DiscordIPC/_latestVersion
33
[license]: https://img.shields.io/badge/License-Apache%202.0-lightgrey.svg
44

55
[ ![version][] ][download]
6-
[ ![license][] ](https://github.com/jagrosh/Discord-IPC/tree/master/LICENSE)
6+
[ ![license][] ](https://github.com/jagrosh/DiscordIPC/tree/master/LICENSE)
77

88
# DiscordIPC
99

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.jagrosh</groupId>
55
<artifactId>DiscordIPC</artifactId>
6-
<version>0.1</version>
6+
<version>0.2</version>
77
<packaging>jar</packaging>
88

99
<dependencies>

src/main/java/com/jagrosh/discordipc/entities/RichPresence.java

Lines changed: 106 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,110 @@ public JSONObject toJson()
8686
.put("instance", instance);
8787
}
8888

89-
//const char* details; /* max 128 bytes */
90-
//int64_t startTimestamp;
91-
//int64_t endTimestamp;
92-
//const char* largeImageKey; /* max 32 bytes */
93-
//const char* largeImageText; /* max 128 bytes */
94-
//const char* smallImageKey; /* max 32 bytes */
95-
//const char* smallImageText; /* max 128 bytes */
96-
//const char* partyId; /* max 128 bytes */
97-
//int partySize;
98-
//int partyMax;
99-
//const char* matchSecret; /* max 128 bytes */
100-
//const char* joinSecret; /* max 128 bytes */
101-
//const char* spectateSecret; /* max 128 bytes */
102-
//int8_t instance;
89+
public static class Builder
90+
{
91+
private String state;
92+
private String details;
93+
private OffsetDateTime startTimestamp;
94+
private OffsetDateTime endTimestamp;
95+
private String largeImageKey;
96+
private String largeImageText;
97+
private String smallImageKey;
98+
private String smallImageText;
99+
private String partyId;
100+
private int partySize;
101+
private int partyMax;
102+
private String matchSecret;
103+
private String joinSecret;
104+
private String spectateSecret;
105+
private boolean instance;
106+
107+
public RichPresence build()
108+
{
109+
return new RichPresence(state, details, startTimestamp, endTimestamp,
110+
largeImageKey, largeImageText, smallImageKey, smallImageText,
111+
partyId, partySize, partyMax, matchSecret, joinSecret,
112+
spectateSecret, instance);
113+
}
114+
115+
public Builder setState(String state)
116+
{
117+
this.state = state;
118+
return this;
119+
}
120+
121+
public Builder setDetails(String details)
122+
{
123+
this.details = details;
124+
return this;
125+
}
126+
127+
public Builder setStartTimestamp(OffsetDateTime startTimestamp)
128+
{
129+
this.startTimestamp = startTimestamp;
130+
return this;
131+
}
132+
133+
public Builder setEndTimestamp(OffsetDateTime endTimestamp)
134+
{
135+
this.endTimestamp = endTimestamp;
136+
return this;
137+
}
138+
139+
public Builder setLargeImage(String largeImageKey, String largeImageText)
140+
{
141+
this.largeImageKey = largeImageKey;
142+
this.largeImageText = largeImageText;
143+
return this;
144+
}
145+
146+
public Builder setLargeImage(String largeImageKey)
147+
{
148+
return setLargeImage(largeImageKey, null);
149+
}
150+
151+
public Builder setSmallImage(String smallImageKey, String smallImageText)
152+
{
153+
this.smallImageKey = smallImageKey;
154+
this.smallImageText = smallImageText;
155+
return this;
156+
}
157+
158+
public Builder setSmallImage(String smallImageKey)
159+
{
160+
return setSmallImage(smallImageKey, null);
161+
}
162+
163+
public Builder setParty(String partyId, int partySize, int partyMax)
164+
{
165+
this.partyId = partyId;
166+
this.partySize = partySize;
167+
this.partyMax = partyMax;
168+
return this;
169+
}
170+
171+
public Builder setMatchSecret(String matchSecret)
172+
{
173+
this.matchSecret = matchSecret;
174+
return this;
175+
}
176+
177+
public Builder setJoinSecret(String joinSecret)
178+
{
179+
this.joinSecret = joinSecret;
180+
return this;
181+
}
182+
183+
public Builder setSpectateSecret(String spectateSecret)
184+
{
185+
this.spectateSecret = spectateSecret;
186+
return this;
187+
}
188+
189+
public Builder setInstance(boolean instance)
190+
{
191+
this.instance = instance;
192+
return this;
193+
}
194+
}
103195
}

0 commit comments

Comments
 (0)