Skip to content

Commit 62443b0

Browse files
committed
Version 6.4.0
+ JavaBotBlockAPIInfo Provides static info about the wrapper.
1 parent 44be88b commit 62443b0

File tree

7 files changed

+100
-35
lines changed

7 files changed

+100
-35
lines changed

build.gradle

+1-6
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ plugins{
66
id 'maven-publish'
77
id 'maven'
88
id 'com.github.johnrengelman.shadow' version '5.2.0'
9-
id 'net.kyori.blossom' version '1.1.0'
109
}
1110

12-
def ver = new Version(major: 6, minor: 3, patch: 4)
11+
def ver = new Version(major: 6, minor: 4, patch: 0)
1312

1413
allprojects {
1514
apply plugin: 'com.jfrog.bintray'
@@ -192,10 +191,6 @@ subprojects {
192191
rootProject.dependencies.compile project
193192
}
194193
}
195-
196-
blossom{
197-
replaceToken("API_VERSION", version)
198-
}
199194
}
200195

201196
configurations {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright 2019 - 2021 Andre601
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5+
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation
6+
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
7+
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8+
*
9+
* The above copyright notice and this permission notice shall be included in all copies or substantial
10+
* portions of the Software.
11+
*
12+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13+
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
14+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
15+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
16+
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17+
*/
18+
19+
package org.botblock.javabotblockapi.core;
20+
21+
/**
22+
* Class containing static info used in other modules.
23+
* <br>Feel free to use the info shared here inside your bot if you, for example, want to share what Lib your bot
24+
* uses to post Guild count or similar.
25+
*/
26+
public class JavaBotBlockAPIInfo{
27+
28+
/**
29+
* Major version of the Wrapper.
30+
*/
31+
public static final String MAJOR = "6";
32+
/**
33+
* Minor version of the Wrapper.
34+
*/
35+
public static final String MINOR = "4";
36+
/**
37+
* Patch version of the Wrapper.
38+
*/
39+
public static final String PATCH = "0";
40+
41+
/**
42+
* Full version in the format {@code major.minor.patch}.
43+
*/
44+
public static final String VERSION = String.format("%s.%s.%s", MAJOR, MINOR, PATCH);
45+
46+
/**
47+
* URL to the GitHub repository.
48+
*/
49+
public static final String GITHUB = "https://github.com/botblock/JavaBotBlockAPI";
50+
}

javacord/src/main/java/org/botblock/javabotblockapi/javacord/PostAction.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import org.botblock.javabotblockapi.core.BotBlockAPI;
2222
import org.botblock.javabotblockapi.core.CheckUtil;
23+
import org.botblock.javabotblockapi.core.JavaBotBlockAPIInfo;
2324
import org.botblock.javabotblockapi.core.exceptions.RateLimitedException;
2425
import org.botblock.javabotblockapi.requests.handler.RequestHandler;
2526
import org.javacord.api.DiscordApi;
@@ -63,9 +64,10 @@ public class PostAction{
6364
*/
6465
public PostAction(DiscordApi api){
6566
this.requestHandler = new RequestHandler(String.format(
66-
"%s-%s/API_VERSION (Javacord) DBots/%s",
67+
"%s-%s/%s (Javacord) DBots/%s",
6768
api.getYourself().getName(),
6869
api.getYourself().getDiscriminator(),
70+
JavaBotBlockAPIInfo.VERSION,
6971
api.getYourself().getId()
7072
));
7173
this.scheduler = requestHandler.getScheduler();
@@ -138,7 +140,8 @@ public void disableAutoPost(long time, @Nonnull TimeUnit timeUnit){
138140

139141
try{
140142
scheduler.shutdown();
141-
scheduler.awaitTermination(time, timeUnit);
143+
if(!scheduler.awaitTermination(time, timeUnit))
144+
LOG.warn("Scheduler couldn't properly wait for termination.");
142145
}catch(InterruptedException ex){
143146
LOG.warn("Got interrupted while shutting down the Scheduler!", ex);
144147
}

jda/src/main/java/org/botblock/javabotblockapi/jda/PostAction.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import net.dv8tion.jda.api.JDA;
2222
import net.dv8tion.jda.api.sharding.ShardManager;
2323
import org.botblock.javabotblockapi.core.BotBlockAPI;
24+
import org.botblock.javabotblockapi.core.JavaBotBlockAPIInfo;
2425
import org.botblock.javabotblockapi.core.exceptions.RateLimitedException;
2526
import org.botblock.javabotblockapi.core.CheckUtil;
2627
import org.botblock.javabotblockapi.requests.handler.RequestHandler;
@@ -78,9 +79,10 @@ public PostAction(@Nonnull ShardManager shardManager){
7879
*/
7980
public PostAction(@Nonnull JDA jda){
8081
this.requestHandler = new RequestHandler(String.format(
81-
"%s-%s/API_VERSION (JDA) DBots/%s",
82+
"%s-%s/%s (JDA) DBots/%s",
8283
jda.getSelfUser().getName(),
8384
jda.getSelfUser().getDiscriminator(),
85+
JavaBotBlockAPIInfo.VERSION,
8486
jda.getSelfUser().getId()
8587
));
8688
this.scheduler = requestHandler.getScheduler();
@@ -157,7 +159,8 @@ public void disableAutoPost(long time, @Nonnull TimeUnit timeUnit){
157159

158160
try{
159161
scheduler.shutdown();
160-
scheduler.awaitTermination(time, timeUnit);
162+
if(!scheduler.awaitTermination(time, timeUnit))
163+
LOG.warn("Scheduler couldn't properly wait for termination.");
161164
}catch(InterruptedException ex){
162165
LOG.warn("Got interrupted while shutting down the Scheduler!", ex);
163166
}

request/src/main/java/org/botblock/javabotblockapi/requests/GetBotAction.java

+15-10
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
package org.botblock.javabotblockapi.requests;
2020

21+
import org.botblock.javabotblockapi.core.JavaBotBlockAPIInfo;
2122
import org.botblock.javabotblockapi.core.Site;
2223
import org.botblock.javabotblockapi.core.CheckUtil;
2324
import org.botblock.javabotblockapi.core.exceptions.RateLimitedException;
@@ -53,11 +54,13 @@ public class GetBotAction{
5354
* <li>User-Agent: {@code "JavaBotBlockAPI-0000/API_VERSION (Unknown; +https://jbba.dev) DBots/{id}"}</li>
5455
* </ul>
5556
*
57+
* <p>Following Exceptions can be thrown from the {@link org.botblock.javabotblockapi.core.CheckUtil CheckUtil}:
58+
* <ul>
59+
* <li>{@link java.lang.NullPointerException NullPointerException} - When the provided id is empty.</li>
60+
* </ul>
61+
*
5662
* @param id
5763
* The id of the bot. This is required for the internal User-Agent.
58-
*
59-
* @throws java.lang.NullPointerException
60-
* When the provided id is empty.
6164
*/
6265
public GetBotAction(@Nonnull String id){
6366
this(false, id);
@@ -72,17 +75,22 @@ public GetBotAction(@Nonnull String id){
7275
* <li>User-Agent: {@code "JavaBotBlockAPI-0000/API_VERSION (Unknown; +https://jbba.dev) DBots/{id}"}</li>
7376
* </ul>
7477
*
78+
* <p>Following Exceptions can be thrown from the {@link org.botblock.javabotblockapi.core.CheckUtil CheckUtil}:
79+
* <ul>
80+
* <li>{@link java.lang.NullPointerException NullPointerException} - When the provided id is empty.</li>
81+
* </ul>
82+
*
7583
* @param disableCache
7684
* If the cache should be disabled.
7785
* <br>{@code true} means the cache is <b>disabled</b>.
7886
* @param id
7987
* The id of the bot. This is required for the internal User-Agent.
80-
*
81-
* @throws java.lang.NullPointerException
82-
* When the provided id is empty.
8388
*/
8489
public GetBotAction(boolean disableCache, @Nonnull String id){
85-
this(disableCache, "JavaBotBlockAPI-0000/API_VERSION (Unknown; +https://jbba.dev) DBots/{id}", id);
90+
this(disableCache, String.format(
91+
"JavaBotBlockAPI-0000/%s (Unknown; +https://jbba.dev) DBots/{id}",
92+
JavaBotBlockAPIInfo.VERSION
93+
), id);
8694
}
8795

8896
/**
@@ -104,9 +112,6 @@ public GetBotAction(boolean disableCache, @Nonnull String id){
104112
* The Name that should be used as User-Agent.
105113
* @param id
106114
* The id of the bot. This is required for the internal User-Agent.
107-
*
108-
* @throws java.lang.NullPointerException
109-
* When the provided userAgent or id is empty.
110115
*/
111116
public GetBotAction(boolean disableCache, @Nonnull String userAgent, @Nonnull String id){
112117
CheckUtil.notEmpty(userAgent, "UserAgent");

request/src/main/java/org/botblock/javabotblockapi/requests/GetListAction.java

+10-7
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
package org.botblock.javabotblockapi.requests;
2020

21+
import org.botblock.javabotblockapi.core.JavaBotBlockAPIInfo;
2122
import org.botblock.javabotblockapi.core.Site;
2223
import org.botblock.javabotblockapi.core.CheckUtil;
2324
import org.botblock.javabotblockapi.requests.handler.RequestHandler;
@@ -69,17 +70,22 @@ public GetListAction(@Nonnull String id){
6970
* <li>User-Agent: {@code "JavaBotBlockAPI-0000/API_VERSION (Unknown; +https://jbba.dev) DBots/{id}"}</li>
7071
* </ul>
7172
*
73+
* <p>Following Exceptions can be thrown from the {@link org.botblock.javabotblockapi.core.CheckUtil CheckUtil}:
74+
* <ul>
75+
* <li>{@link java.lang.NullPointerException NullPointerException} - When the provided id is empty.</li>
76+
* </ul>
77+
*
7278
* @param disableCache
7379
* If the cache should be disabled.
7480
* <br>{@code true} means the cache is <b>disabled</b>.
7581
* @param id
7682
* The id of the bot. This is required for the internal User-Agent.
77-
*
78-
* @throws java.lang.NullPointerException
79-
* When the provided id is empty.
8083
*/
8184
public GetListAction(boolean disableCache, @Nonnull String id){
82-
this(disableCache, "JavaBotBlockAPI-0000/API_VERSION (Unknown; +https://jbba.dev) DBots/{id}", id);
85+
this(disableCache, String.format(
86+
"JavaBotBlockAPI-0000/%s (Unknown; +https://jbba.dev) DBots/{id}",
87+
JavaBotBlockAPIInfo.VERSION
88+
), id);
8389
}
8490

8591
/**
@@ -101,9 +107,6 @@ public GetListAction(boolean disableCache, @Nonnull String id){
101107
* The Name that should be used as User-Agent.
102108
* @param id
103109
* The id of the bot. This is required for the internal User-Agent.
104-
*
105-
* @throws java.lang.NullPointerException
106-
* When the provided userAgent or id is empty.
107110
*/
108111
public GetListAction(boolean disableCache, @Nonnull String userAgent, @Nonnull String id){
109112
CheckUtil.notEmpty(userAgent, "UserAgent");

request/src/main/java/org/botblock/javabotblockapi/requests/PostAction.java

+14-8
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
package org.botblock.javabotblockapi.requests;
2020

2121
import org.botblock.javabotblockapi.core.BotBlockAPI;
22+
import org.botblock.javabotblockapi.core.JavaBotBlockAPIInfo;
2223
import org.botblock.javabotblockapi.core.exceptions.RateLimitedException;
2324
import org.botblock.javabotblockapi.core.CheckUtil;
2425
import org.botblock.javabotblockapi.requests.handler.RequestHandler;
@@ -54,14 +55,16 @@ public class PostAction{
5455
* <li>User-Agent: {@code "JavaBotBlockAPI-0000/API_VERSION (Unknown; +https://jbba.dev) DBots/{id}"}</li>
5556
* </ul>
5657
*
58+
* <p>Following Exceptions can be thrown from the {@link org.botblock.javabotblockapi.core.CheckUtil CheckUtil}:
59+
* <ul>
60+
* <li>{@link java.lang.NullPointerException NullPointerException} - When the provided ID is empty.</li>
61+
* </ul>
62+
*
5763
* @param id
5864
* The id of the bot. This is required for the internal User-Agent.
59-
*
60-
* @throws NullPointerException
61-
* When the provided id is empty.
6265
*/
6366
public PostAction(@Nonnull String id){
64-
this("JavaBotBlockAPI-0000/API_VERSION (Unknown; +https://jbba.dev) DBots/{id}", id);
67+
this(String.format("JavaBotBlockAPI-0000/%s (Unknown; +https://jbba.dev) DBots/{id}", JavaBotBlockAPIInfo.VERSION), id);
6568
}
6669

6770
/**
@@ -70,13 +73,15 @@ public PostAction(@Nonnull String id){
7073
*
7174
* <p>Note that you can provide {@code {id}} inside the userAgent to get it replaced with the provided id.
7275
*
76+
* <p>Following Exceptions can be thrown from the {@link org.botblock.javabotblockapi.core.CheckUtil CheckUtil}:
77+
* <ul>
78+
* <li>{@link java.lang.NullPointerException NullPointerException} - When the provided ID or User Agent are empty.</li>
79+
* </ul>
80+
*
7381
* @param userAgent
7482
* The Name to use as User-Agent.
7583
* @param id
7684
* The id of the bot. This is required for the internal User-Agent.
77-
*
78-
* @throws NullPointerException
79-
* When the provided userAgent or id is empty.
8085
*/
8186
public PostAction(@Nonnull String userAgent, @Nonnull String id){
8287
CheckUtil.notEmpty(userAgent, "UserAgent");
@@ -152,7 +157,8 @@ public void disableAutoPost(long time, @Nonnull TimeUnit timeUnit){
152157

153158
try{
154159
scheduler.shutdown();
155-
scheduler.awaitTermination(time, timeUnit);
160+
if(!scheduler.awaitTermination(time, timeUnit))
161+
LOG.warn("Scheduler couldn't properly wait for termination.");
156162
}catch(InterruptedException ex){
157163
LOG.warn("Got interrupted while shutting down the Scheduler!", ex);
158164
}

0 commit comments

Comments
 (0)