Skip to content

Commit 907f766

Browse files
Merge pull request discord-jda#594 from DV8FromTheWorld/release/3.5.0
Release 3.5.0
2 parents e837413 + 27c7d19 commit 907f766

File tree

505 files changed

+2284
-1526
lines changed

Some content is hidden

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

505 files changed

+2284
-1526
lines changed

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright 2015-2017 Austin Keener & Michael Ritter & Florian Spieß
189+
Copyright 2015-2018 Austin Keener & Michael Ritter & Florian Spieß
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

README.md

+19-21
Original file line numberDiff line numberDiff line change
@@ -103,42 +103,40 @@ To use sharding in JDA you will need to use `JDABuilder.useSharding(int shardId,
103103
has the ID 0. The **shardTotal** is the total amount of shards (not 0-based) which can be seen similar to the length of an array, the last shard has the ID of
104104
`shardTotal - 1`.
105105

106-
When using sharding it is also recommended to use a `SessionReconnectQueue` instance for all shards. This allows JDA to properly
107-
handle reconnecting multiple shards without violating Discord limitations (not using this might cause an IP ban on bad days).
106+
The [`SessionController`](https://home.dv8tion.net:8080/job/JDA/javadoc/net/dv8tion/jda/core/utils/SessionController.html) is a tool of the JDABuilder
107+
that allows to control state and behaviour between shards (sessions). When using multiple builders to build shards you have to create one instance
108+
of this controller and add the same instance to each builder: `builder.setSessionController(controller)`
108109

109-
Additionally to keep track of the global REST rate-limit JDA has a `ShardedRateLimiter` which is set by default when using the same JDABuilder
110-
for all shards. If you want to use multiple builders to build your shards you should use the same ShardedRateLimiter instance!
110+
Since version **3.4.0** JDA provides a `ShardManager` which automates this building process.
111111

112-
**Logins between shards _must_ happen with a minimum of _5 SECONDS_ of backoff time. JDA will inform you if the backoff is too short
113-
with a log message:**
114-
115-
```
116-
Encountered IDENTIFY (OP 2) Rate Limit! Waiting 5 seconds before trying again!
117-
```
118-
> Note: Failing to backoff properly will cause JDA to wait 5 seconds after failing to connect. Respect the 5 second login rate limit!
119-
120-
#### Example Sharding
112+
#### Example Sharding - Using JDABuilder
121113

122114
```java
123115
public static void main(String[] args) throws Exception
124116
{
125-
JDABuilder shardBuilder = new JDABuilder(AccountType.BOT).setToken(args[0]).setReconnectQueue(new SessionReconnectQueue());
117+
JDABuilder shardBuilder = new JDABuilder(AccountType.BOT).setToken(args[0]);
126118
//register your listeners here using shardBuilder.addEventListener(...)
127119
shardBuilder.addEventListener(new MessageListener());
128120
for (int i = 0; i < 10; i++)
129121
{
130-
//using buildBlocking(JDA.Status.AWAITING_LOGIN_CONFIRMATION)
131-
// makes sure we start to delay the next shard once the current one actually
132-
// sent the login information, otherwise we might hit nasty race conditions
133122
shardBuilder.useSharding(i, 10)
134-
.buildBlocking(JDA.Status.AWAITING_LOGIN_CONFIRMATION);
135-
Thread.sleep(5000); //sleep 5 seconds between each login
123+
.buildAsync();
136124
}
137125
}
138126
```
139127

140-
> Note: We are not setting a `ShardedRateLimiter` here as it isn't necessary when we use the same builder!<br>
141-
> When you use multiple builders you should use JDABuilder.setShardedRateLimiter(ShardedRateLimiter) with a shared instance of the same ShardedRateLimiter!
128+
> When the `useSharding` method is invoked for the first time, the builder automatically sets a SessionController internally (if none is present)
129+
130+
#### Example Sharding - Using DefaultShardManager
131+
```java
132+
public static void main(String[] args) throws Exception
133+
{
134+
DefaultShardManagerBuilder builder = new DefaultShardManagerBuilder();
135+
builder.setToken(args[0]);
136+
builder.addEventListener(new MessageListener());
137+
builder.build();
138+
}
139+
```
142140

143141
## More Examples
144142
We provide a small set of Examples in the [Example Directory](https://github.com/DV8FromTheWorld/JDA/tree/master/src/examples/java).

build.gradle

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2017 Austin Keener & Michael Ritter & Florian Spieß
2+
* Copyright 2015-2018 Austin Keener & Michael Ritter & Florian Spieß
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,7 +28,7 @@ plugins {
2828
id 'com.github.johnrengelman.shadow' version '2.0.1'
2929
}
3030

31-
def versionObj = new Version(major: 3, minor: 4, revision: 0)
31+
def versionObj = new Version(major: 3, minor: 5, revision: 0)
3232

3333
group = "net.dv8tion"
3434
archivesBaseName = "JDA"
@@ -226,8 +226,9 @@ bintrayUpload {
226226
class Version {
227227
String major, minor, revision
228228

229-
String getBuild() {
230-
System.getenv("BUILD_NUMBER") ?: System.getProperty("BUILD_NUMBER") ?: "DEV"
229+
static String getBuild() {
230+
System.getenv("BUILD_NUMBER") ?: System.getProperty("BUILD_NUMBER") ?:
231+
System.getenv("GIT_COMMIT")?.substring(0, 7) ?: System.getProperty("GIT_COMMIT")?.substring(0, 7) ?:"DEV"
231232
}
232233

233234
String toString() {

src/examples/java/MessageListenerExample.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2017 Austin Keener & Michael Ritter & Florian Spieß
2+
* Copyright 2015-2018 Austin Keener & Michael Ritter & Florian Spieß
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/main/java/com/iwebpp/crypto/TweetNaclFast.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*
22
* This is taken from:
33
* <a href="https://github.com/InstantWebP2P/tweetnacl-java">https://github.com/InstantWebP2P/tweetnacl-java</a><br>
44
* All credit goes to the original author.

src/main/java/net/dv8tion/jda/bot/JDABot.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2017 Austin Keener & Michael Ritter & Florian Spieß
2+
* Copyright 2015-2018 Austin Keener & Michael Ritter & Florian Spieß
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/main/java/net/dv8tion/jda/bot/entities/ApplicationInfo.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2017 Austin Keener & Michael Ritter & Florian Spieß
2+
* Copyright 2015-2018 Austin Keener & Michael Ritter & Florian Spieß
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/main/java/net/dv8tion/jda/bot/entities/impl/ApplicationInfoImpl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2017 Austin Keener & Michael Ritter & Florian Spieß
2+
* Copyright 2015-2018 Austin Keener & Michael Ritter & Florian Spieß
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/main/java/net/dv8tion/jda/bot/entities/impl/JDABotImpl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2017 Austin Keener & Michael Ritter & Florian Spieß
2+
* Copyright 2015-2018 Austin Keener & Michael Ritter & Florian Spieß
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)