Skip to content
This repository was archived by the owner on Jul 27, 2025. It is now read-only.

Commit 2fbde8e

Browse files
Merge pull request #28 from beanbeanjuice/integration
v1.5.0 Release
2 parents c92140c + f61834b commit 2fbde8e

64 files changed

Lines changed: 1038 additions & 1377 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

pom.xml

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<maven.compiler.target>16</maven.compiler.target>
1515
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1616
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
17-
<version.number>1.4.0</version.number>
17+
<version.number>1.5.0</version.number>
1818
</properties>
1919

2020
<profiles>
@@ -162,47 +162,39 @@
162162
<dependency>
163163
<groupId>org.apache.maven.plugins</groupId>
164164
<artifactId>maven-gpg-plugin</artifactId>
165-
<version>3.1.0</version>
165+
<version>3.2.4</version>
166166
<type>maven-plugin</type>
167167
</dependency>
168168

169169
<!-- Nexus Staging Maven Plugin -->
170170
<dependency>
171171
<groupId>org.sonatype.plugins</groupId>
172172
<artifactId>nexus-staging-maven-plugin</artifactId>
173-
<version>1.6.13</version>
174-
</dependency>
175-
176-
<!-- Jetbrains Annotations -->
177-
<dependency>
178-
<groupId>org.jetbrains</groupId>
179-
<artifactId>annotations</artifactId>
180-
<version>23.0.0</version>
181-
<scope>compile</scope>
173+
<version>1.7.0</version>
182174
</dependency>
183175

184176
<!-- Faster XML for JSON Parsing -->
185177
<dependency>
186178
<groupId>com.fasterxml.jackson.core</groupId>
187179
<artifactId>jackson-core</artifactId>
188-
<version>2.15.2</version>
180+
<version>2.17.1</version>
189181
</dependency>
190182
<dependency>
191183
<groupId>com.fasterxml.jackson.core</groupId>
192184
<artifactId>jackson-databind</artifactId>
193-
<version>2.15.2</version>
185+
<version>2.17.1</version>
194186
</dependency>
195187
<dependency>
196188
<groupId>com.fasterxml.jackson.core</groupId>
197189
<artifactId>jackson-annotations</artifactId>
198-
<version>2.15.2</version>
190+
<version>2.17.1</version>
199191
</dependency>
200192

201193
<!-- HTTPComponents for REQUESTS to the API -->
202194
<dependency>
203195
<groupId>org.apache.httpcomponents.client5</groupId>
204196
<artifactId>httpclient5</artifactId>
205-
<version>5.2.1</version>
197+
<version>5.3.1</version>
206198
</dependency>
207199

208200
<!-- DOTENV for Environment Variable Support -->
@@ -222,9 +214,15 @@
222214
<dependency>
223215
<groupId>org.junit.jupiter</groupId>
224216
<artifactId>junit-jupiter</artifactId>
225-
<version>5.9.0</version>
217+
<version>5.10.2</version>
226218
<scope>test</scope>
227219
</dependency>
220+
<dependency>
221+
<groupId>org.projectlombok</groupId>
222+
<artifactId>lombok</artifactId>
223+
<version>1.18.30</version>
224+
<scope>provided</scope>
225+
</dependency>
228226

229227
</dependencies>
230228

src/main/java/com/beanbeanjuice/cafeapi/CafeAPI.java

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import com.beanbeanjuice.cafeapi.cafebot.birthdays.Birthdays;
99
import com.beanbeanjuice.cafeapi.cafebot.cafe.CafeUsers;
1010
import com.beanbeanjuice.cafeapi.cafebot.codes.GeneratedCodes;
11-
import com.beanbeanjuice.cafeapi.cafebot.counting.CountingInformations;
12-
import com.beanbeanjuice.cafeapi.cafebot.guilds.GuildInformations;
11+
import com.beanbeanjuice.cafeapi.cafebot.counting.GlobalCountingInformation;
12+
import com.beanbeanjuice.cafeapi.cafebot.guilds.GlobalGuildInformation;
1313
import com.beanbeanjuice.cafeapi.cafebot.interactions.Interactions;
1414
import com.beanbeanjuice.cafeapi.cafebot.interactions.pictures.InteractionPictures;
1515
import com.beanbeanjuice.cafeapi.cafebot.minigames.winstreaks.WinStreaks;
@@ -20,15 +20,15 @@
2020
import com.beanbeanjuice.cafeapi.cafebot.voicebinds.VoiceChannelBinds;
2121
import com.beanbeanjuice.cafeapi.cafebot.welcomes.Welcomes;
2222
import com.beanbeanjuice.cafeapi.cafebot.words.Words;
23-
import org.jetbrains.annotations.NotNull;
23+
import lombok.Getter;
2424

2525
import java.util.TimeZone;
2626

2727
public class CafeAPI {
2828

2929
private String apiKey;
3030
private String userAgent;
31-
private static RequestLocation requestLocation;
31+
@Getter private static RequestLocation requestLocation;
3232
public KawaiiAPI KAWAII_API;
3333

3434
public Users USER;
@@ -42,10 +42,10 @@ public class CafeAPI {
4242
public WinStreaks WIN_STREAK;
4343
public Interactions INTERACTION;
4444
public GuildTwitches TWITCH;
45-
public GuildInformations GUILD;
45+
public GlobalGuildInformation GUILD;
4646
public GeneratedCodes GENERATED_CODE;
4747
public Versions VERSION;
48-
public CountingInformations COUNTING_INFORMATION;
48+
public GlobalCountingInformation COUNTING_INFORMATION;
4949
public CafeUsers CAFE_USER;
5050
public Birthdays BIRTHDAY;
5151
public DonationUsers DONATION_USER;
@@ -57,7 +57,7 @@ public class CafeAPI {
5757
* @param password The {@link String password}.
5858
* @param requestLocation The {@link RequestLocation requestLocation}.
5959
*/
60-
public CafeAPI(@NotNull String username, @NotNull String password, @NotNull RequestLocation requestLocation) {
60+
public CafeAPI(String username, String password, RequestLocation requestLocation) {
6161
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
6262
this.userAgent = username;
6363
CafeAPI.requestLocation = requestLocation;
@@ -80,10 +80,10 @@ public CafeAPI(@NotNull String username, @NotNull String password, @NotNull Requ
8080
WIN_STREAK = new WinStreaks(apiKey);
8181
INTERACTION = new Interactions(apiKey);
8282
TWITCH = new GuildTwitches(apiKey);
83-
GUILD = new GuildInformations(apiKey);
83+
GUILD = new GlobalGuildInformation(apiKey);
8484
GENERATED_CODE = new GeneratedCodes(apiKey);
8585
VERSION = new Versions(apiKey);
86-
COUNTING_INFORMATION = new CountingInformations(apiKey);
86+
COUNTING_INFORMATION = new GlobalCountingInformation(apiKey);
8787
CAFE_USER = new CafeUsers(apiKey);
8888
BIRTHDAY = new Birthdays(apiKey);
8989
DONATION_USER = new DonationUsers(apiKey);
@@ -92,28 +92,20 @@ public CafeAPI(@NotNull String username, @NotNull String password, @NotNull Requ
9292
KAWAII_API = new KawaiiAPI("anonymous");
9393
}
9494

95-
/**
96-
* @return The {@link RequestLocation} for the {@link CafeAPI}.
97-
*/
98-
@NotNull
99-
public static RequestLocation getRequestLocation() {
100-
return requestLocation;
101-
}
102-
10395
/**
10496
* Sets the {@link KawaiiAPI} token.
10597
* @param token The {@link String} token for the {@link KawaiiAPI}.
10698
*/
107-
public void setKawaiiAPI(@NotNull String token) {
99+
public void setKawaiiAPI(String token) {
108100
KAWAII_API = new KawaiiAPI(token);
109101
}
110102

111-
private String getToken(@NotNull String username, @NotNull String password) {
103+
private String getToken(String username, String password) {
112104
Request request = new RequestBuilder(RequestRoute.CAFE, RequestType.POST)
113105
.setRoute("/user/login")
114106
.addParameter("username", username)
115107
.addParameter("password", password)
116-
.build();
108+
.build().orElseThrow();
117109

118110
return request.getData().get("api_key").textValue();
119111
}

src/main/java/com/beanbeanjuice/cafeapi/api/CafeAPI.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package com.beanbeanjuice.cafeapi.api;
22

3-
import org.jetbrains.annotations.NotNull;
4-
53
/**
64
* An interface used for {@link com.beanbeanjuice.cafeapi.CafeAPI CafeAPI} Requests.
75
*
@@ -13,6 +11,6 @@ public interface CafeAPI {
1311
* Updates the {@link String apiKey}.
1412
* @param apiKey The new {@link String apiKey}.
1513
*/
16-
void updateAPIKey(@NotNull String apiKey);
14+
void updateAPIKey(String apiKey);
1715

1816
}

src/main/java/com/beanbeanjuice/cafeapi/cafebot/beancoins/users/DonationUsers.java

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@
88
import com.beanbeanjuice.cafeapi.requests.RequestRoute;
99
import com.beanbeanjuice.cafeapi.requests.RequestType;
1010
import com.fasterxml.jackson.databind.JsonNode;
11-
import org.jetbrains.annotations.NotNull;
12-
import org.jetbrains.annotations.Nullable;
1311

1412
import java.sql.Timestamp;
1513
import java.util.HashMap;
14+
import java.util.Optional;
1615

1716
/**
1817
* A class used to make {@link DonationUsers} requests to the {@link CafeAPI CafeAPI}.
@@ -27,7 +26,7 @@ public class DonationUsers implements com.beanbeanjuice.cafeapi.api.CafeAPI {
2726
* Creates a new {@link DonationUsers} object.
2827
* @param apiKey The {@link String apiKey} used for authorization.
2928
*/
30-
public DonationUsers(@NotNull String apiKey) {
29+
public DonationUsers(String apiKey) {
3130
this.apiKey = apiKey;
3231
}
3332

@@ -37,19 +36,18 @@ public DonationUsers(@NotNull String apiKey) {
3736
* @throws AuthorizationException Thrown when the {@link String apiKey} is invalid.
3837
* @throws ResponseException Thrown when there is a generic server-side {@link CafeException}.
3938
*/
40-
@NotNull
4139
public HashMap<String, Timestamp> getAllUserDonationTimes()
4240
throws AuthorizationException, ResponseException {
4341
HashMap<String, Timestamp> donationUsers = new HashMap<>();
4442

4543
Request request = new RequestBuilder(RequestRoute.CAFEBOT, RequestType.GET)
4644
.setRoute("/beanCoin/donation_users")
4745
.setAuthorization(apiKey)
48-
.build();
46+
.build().orElseThrow();
4947

5048
for (JsonNode user : request.getData().get("users")) {
5149
String userID = user.get("user_id").asText();
52-
Timestamp timeUntilNextDonation = CafeGeneric.parseTimestampFromAPI(user.get("time_until_next_donation").asText());
50+
Timestamp timeUntilNextDonation = CafeGeneric.parseTimestampFromAPI(user.get("time_until_next_donation").asText()).orElse(null);
5351

5452
donationUsers.put(userID, timeUntilNextDonation);
5553
}
@@ -65,13 +63,12 @@ public HashMap<String, Timestamp> getAllUserDonationTimes()
6563
* @throws ResponseException Thrown when there is a generic server-side {@link CafeException}.
6664
* @throws NotFoundException Thrown when the {@link Timestamp timeUntilNextDonation} does not exist for the specified {@link String userID}.
6765
*/
68-
@Nullable
69-
public Timestamp getUserDonationTime(@NotNull String userID)
66+
public Optional<Timestamp> getUserDonationTime(String userID)
7067
throws AuthorizationException, ResponseException, NotFoundException {
7168
Request request = new RequestBuilder(RequestRoute.CAFEBOT, RequestType.GET)
7269
.setRoute("/beanCoin/donation_users/" + userID)
7370
.setAuthorization(apiKey)
74-
.build();
71+
.build().orElseThrow();
7572

7673
return CafeGeneric.parseTimestampFromAPI(request.getData().get("user").get("time_until_next_donation").asText());
7774
}
@@ -86,14 +83,13 @@ public Timestamp getUserDonationTime(@NotNull String userID)
8683
* @throws ConflictException Thrown when the {@link Timestamp timeUntilNextDonation} already exists for the specified {@link String userID}.
8784
* @throws UndefinedVariableException Thrown when a variable is undefined.
8885
*/
89-
@NotNull
90-
public Boolean addDonationUser(@NotNull String userID, @NotNull Timestamp timeUntilNextDonation)
86+
public Boolean addDonationUser(String userID, Timestamp timeUntilNextDonation)
9187
throws AuthorizationException, ResponseException, ConflictException, UndefinedVariableException {
9288
Request request = new RequestBuilder(RequestRoute.CAFEBOT, RequestType.POST)
9389
.setRoute("/beanCoin/donation_users/" + userID)
9490
.addParameter("time_stamp", timeUntilNextDonation.toString())
9591
.setAuthorization(apiKey)
96-
.build();
92+
.build().orElseThrow();
9793

9894
return request.getStatusCode() == 201;
9995
}
@@ -105,13 +101,12 @@ public Boolean addDonationUser(@NotNull String userID, @NotNull Timestamp timeUn
105101
* @throws AuthorizationException Thrown when the {@link String apiKey} is invalid.
106102
* @throws ResponseException Thrown when there is a generic server-side {@link CafeException}.
107103
*/
108-
@NotNull
109-
public Boolean deleteDonationUser(@NotNull String userID)
104+
public Boolean deleteDonationUser(String userID)
110105
throws AuthorizationException, ResponseException {
111106
Request request = new RequestBuilder(RequestRoute.CAFEBOT, RequestType.DELETE)
112107
.setRoute("/beanCoin/donation_users/" + userID)
113108
.setAuthorization(apiKey)
114-
.build();
109+
.build().orElseThrow();
115110

116111
return request.getStatusCode() == 200;
117112
}
@@ -121,7 +116,8 @@ public Boolean deleteDonationUser(@NotNull String userID)
121116
* @param apiKey The new {@link String apiKey}.
122117
*/
123118
@Override
124-
public void updateAPIKey(@NotNull String apiKey) {
119+
public void updateAPIKey(String apiKey) {
125120
this.apiKey = apiKey;
126121
}
122+
127123
}

src/main/java/com/beanbeanjuice/cafeapi/cafebot/birthdays/Birthday.java

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import com.beanbeanjuice.cafeapi.exception.program.BirthdayOverfillException;
44
import com.beanbeanjuice.cafeapi.exception.program.InvalidTimeZoneException;
55
import com.beanbeanjuice.cafeapi.utility.Time;
6-
import org.jetbrains.annotations.NotNull;
76

87
import java.text.ParseException;
98
import java.util.Date;
@@ -17,18 +16,18 @@
1716
public class Birthday {
1817

1918
private final BirthdayMonth month;
20-
private final Integer day;
19+
private final int day;
2120
private final TimeZone timeZone;
22-
private final Boolean alreadyMentioned;
21+
private final boolean alreadyMentioned;
2322

2423
/**
2524
* Creates a new {@link Birthday} object.
2625
* @param month The {@link BirthdayMonth month} of the {@link Birthday}.
2726
* @param day The {@link Integer day} of the {@link Birthday}.
2827
* @param alreadyMentioned False, if the user's birthday has not been mentioned by cafeBot.
2928
*/
30-
public Birthday(@NotNull BirthdayMonth month, @NotNull Integer day, @NotNull String timeZone,
31-
@NotNull Boolean alreadyMentioned) throws InvalidTimeZoneException, BirthdayOverfillException {
29+
public Birthday(BirthdayMonth month, int day, String timeZone,
30+
boolean alreadyMentioned) throws InvalidTimeZoneException, BirthdayOverfillException {
3231
this.month = month;
3332
this.day = day;
3433

@@ -45,40 +44,35 @@ public Birthday(@NotNull BirthdayMonth month, @NotNull Integer day, @NotNull Str
4544
/**
4645
* @return The {@link BirthdayMonth month} of the {@link Birthday}.
4746
*/
48-
@NotNull
4947
public BirthdayMonth getMonth() {
5048
return month;
5149
}
5250

5351
/**
5452
* @return The {@link Integer day} of the {@link Birthday}.
5553
*/
56-
@NotNull
57-
public Integer getDay() {
54+
public int getDay() {
5855
return day;
5956
}
6057

6158
/**
6259
* @return False, if the user's birthday has not been mentioned by cafeBot.
6360
*/
64-
@NotNull
65-
public Boolean alreadyMentioned() {
61+
public boolean alreadyMentioned() {
6662
return alreadyMentioned;
6763
}
6864

6965
/**
7066
* @return The {@link Date} of the {@link Birthday} in {@link TimeZone UTC} time.
7167
* @throws ParseException Thrown when the {@link Birthday} was unable to be parsed.
7268
*/
73-
@NotNull
7469
public Date getUTCDate() throws ParseException {
7570
return Time.getFullDate(month.getMonthNumber() + "-" + day + "-2020", timeZone);
7671
}
7772

7873
/**
7974
* @return The {@link TimeZone} for the {@link Birthday}.
8075
*/
81-
@NotNull
8276
public TimeZone getTimeZone() {
8377
return timeZone;
8478
}

0 commit comments

Comments
 (0)