Skip to content

Commit 0bb3fea

Browse files
committed
Merge branch 'master' of https://github.com/discord-jda/JDA
2 parents c4df246 + 7d465e5 commit 0bb3fea

31 files changed

Lines changed: 1079 additions & 113 deletions

File tree

build.gradle.kts

Lines changed: 17 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@
1717
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
1818
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
1919
import de.undercouch.gradle.tasks.download.Download
20-
import net.dv8tion.jda.tasks.Version
21-
import net.dv8tion.jda.tasks.applyAudioExclusions
22-
import net.dv8tion.jda.tasks.applyOpusExclusions
23-
import net.dv8tion.jda.tasks.nullableReplacement
20+
import net.dv8tion.jda.tasks.*
2421
import nl.littlerobots.vcu.plugin.resolver.VersionSelectors
2522
import org.apache.tools.ant.filters.ReplaceTokens
2623
import org.jreleaser.gradle.plugin.tasks.AbstractJReleaserTask
@@ -47,7 +44,7 @@ plugins {
4744
////////////////////////////////////
4845

4946
projectEnvironment {
50-
version = Version(major = "6", minor = "1", revision = "0", classifier = null)
47+
version = Version(major = "6", minor = "1", revision = "1", classifier = null)
5148
}
5249

5350
artifactFilters {
@@ -62,19 +59,12 @@ if (projectEnvironment.canPublish) {
6259
project.version = "${projectEnvironment.version.get()}_${projectEnvironment.commitHash}"
6360
}
6461

65-
val javaVersion = JavaVersion.current()
66-
6762
project.group = "org.redlance.thirdparty"
6863

6964
base {
7065
archivesName.set("JDA")
7166
}
7267

73-
java {
74-
sourceCompatibility = JavaVersion.VERSION_1_8
75-
targetCompatibility = JavaVersion.VERSION_1_8
76-
}
77-
7868
configure<SourceSetContainer> {
7969
register("examples") {
8070
java.srcDir("src/examples/java")
@@ -277,24 +267,8 @@ val javadoc by tasks.getting(Javadoc::class) {
277267
tags("incubating:a:Incubating:")
278268
links("https://docs.oracle.com/javase/8/docs/api/", "https://takahikokawasaki.github.io/nv-websocket-client/")
279269

280-
if (JavaVersion.VERSION_1_8 < javaVersion) {
281-
addBooleanOption("html5", true) // Adds search bar
282-
addStringOption("-release", "8")
283-
}
284-
285-
// Fix for https://stackoverflow.com/questions/52326318/maven-javadoc-search-redirects-to-undefined-url
286-
if (javaVersion in JavaVersion.VERSION_11..JavaVersion.VERSION_12) {
287-
addBooleanOption("-no-module-directories", true)
288-
}
289-
290-
// Java 13 changed accessibility rules.
291-
// On versions less than Java 13, we simply ignore the errors.
292-
// Both of these remove "no comment" warnings.
293-
if (javaVersion >= JavaVersion.VERSION_13) {
294-
addBooleanOption("Xdoclint:all,-missing", true)
295-
} else {
296-
addBooleanOption("Xdoclint:all,-missing,-accessibility", true)
297-
}
270+
addStringOption("-release", "8")
271+
addBooleanOption("Xdoclint:all,-missing", true)
298272

299273
overview = "$projectDir/overview.html"
300274
}
@@ -319,15 +293,11 @@ tasks.withType<JavaCompile> {
319293

320294
val args = mutableListOf("-Xlint:deprecation", "-Xlint:unchecked")
321295

322-
if (javaVersion.isJava9Compatible) {
323-
args.add("--release")
324-
args.add("8")
325-
}
326-
296+
options.release = 8
327297
options.compilerArgs.addAll(args)
328298
}
329299

330-
tasks.named<JavaCompile>("compileJava").configure {
300+
val compileJava by tasks.getting(JavaCompile::class) {
331301
dependsOn(generateJavaSources)
332302
source = generateJavaSources.get().source
333303
}
@@ -393,6 +363,17 @@ tasks.test {
393363
}
394364
}
395365

366+
val verifyBytecodeVersion by tasks.registering(VerifyBytecodeVersion::class) {
367+
group = "verification"
368+
369+
expectedMajorVersion = 52
370+
classes.from(compileJava.outputs.files.asFileTree.matching {
371+
include("**/*.class")
372+
})
373+
}
374+
375+
compileJava.finalizedBy(verifyBytecodeVersion)
376+
396377

397378
////////////////////////////////////
398379
// //
@@ -493,4 +474,3 @@ jreleaser {
493474
tasks.withType<AbstractJReleaserTask>().configureEach {
494475
mustRunAfter(tasks.named("publish"))
495476
}
496-
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* Copyright 2015 Austin Keener, Michael Ritter, Florian Spieß, and the JDA contributors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package net.dv8tion.jda.tasks
18+
19+
import org.gradle.api.DefaultTask
20+
import org.gradle.api.GradleException
21+
import org.gradle.api.file.ConfigurableFileCollection
22+
import org.gradle.api.provider.Property
23+
import org.gradle.api.tasks.CacheableTask
24+
import org.gradle.api.tasks.Input
25+
import org.gradle.api.tasks.InputFiles
26+
import org.gradle.api.tasks.PathSensitive
27+
import org.gradle.api.tasks.PathSensitivity
28+
import org.gradle.api.tasks.TaskAction
29+
import java.io.File
30+
31+
@CacheableTask
32+
abstract class VerifyBytecodeVersion : DefaultTask() {
33+
@get:InputFiles
34+
@get:PathSensitive(PathSensitivity.RELATIVE)
35+
abstract val classes: ConfigurableFileCollection
36+
37+
@get:Input
38+
abstract val expectedMajorVersion: Property<Int>
39+
40+
@TaskAction
41+
fun verify() {
42+
val badFiles = classes.filter { it.readBytecodeVersion() != expectedMajorVersion.get() }.toList()
43+
44+
if (badFiles.isNotEmpty()) {
45+
println("Found ${badFiles.size} files that did not have the bytecode version ${expectedMajorVersion.get()}")
46+
println("The following classes have the wrong bytecode version:")
47+
for (file in badFiles) {
48+
println("\t- ${file.path} has version ${file.readBytecodeVersion()}")
49+
}
50+
51+
throw GradleException("Some compiled classes have the wrong bytecode version.")
52+
}
53+
}
54+
}
55+
56+
private val validClassHeaderBytes = listOf(0xCA.toByte(), 0xFE.toByte(), 0xBA.toByte(), 0xBE.toByte())
57+
58+
private fun File.readBytecodeVersion(): Int? = inputStream().buffered().use { stream ->
59+
val header = stream.readNBytes(8)
60+
if (header.size < 8) {
61+
return null
62+
}
63+
64+
if (header.take(4) != validClassHeaderBytes) {
65+
return null
66+
}
67+
68+
// Big-endian major version: bytes[6..7]
69+
return ((header[6].toInt() and 0xFF) shl 8) or (header[7].toInt() and 0xFF)
70+
}

src/main/java/net/dv8tion/jda/api/audit/AuditLogKey.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -426,19 +426,19 @@ public enum AuditLogKey
426426

427427
/**
428428
* Roles added to {@link net.dv8tion.jda.api.entities.Member#getRoles() Member.getRoles()} with this action
429-
* <br>Containing a list of {@link net.dv8tion.jda.api.entities.Role Role} IDs
429+
* <br>Containing a list of role objects (maps) with entries for {@code id} and {@code name}
430430
* <br>Use with {@link net.dv8tion.jda.api.entities.Guild#getRoleById(String) Guild.getRoleById(String)}
431431
*
432-
* <p>Expected type: <b>List{@literal <String>}</b>
432+
* <p>Expected type: <b>List{@literal <Map<String, String>>}</b>
433433
*/
434434
MEMBER_ROLES_ADD("$add"),
435435

436436
/**
437437
* Roles removed from {@link net.dv8tion.jda.api.entities.Member#getRoles() Member.getRoles()} with this action
438-
* <br>Containing a list of {@link net.dv8tion.jda.api.entities.Role Role} IDs
438+
* <br>Containing a list of role objects (maps) with entries for {@code id} and {@code name}
439439
* <br>Use with {@link net.dv8tion.jda.api.entities.Guild#getRoleById(String) Guild.getRoleById(String)}
440440
*
441-
* <p>Expected type: <b>List{@literal <String>}</b>
441+
* <p>Expected type: <b>List{@literal <Map<String, String>>}</b>
442442
*/
443443
MEMBER_ROLES_REMOVE("$remove"),
444444

src/main/java/net/dv8tion/jda/api/entities/Guild.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import net.dv8tion.jda.api.entities.emoji.RichCustomEmoji;
3939
import net.dv8tion.jda.api.entities.guild.SecurityIncidentActions;
4040
import net.dv8tion.jda.api.entities.guild.SecurityIncidentDetections;
41+
import net.dv8tion.jda.api.entities.guild.SystemChannelFlag;
4142
import net.dv8tion.jda.api.entities.sticker.*;
4243
import net.dv8tion.jda.api.entities.templates.Template;
4344
import net.dv8tion.jda.api.exceptions.InsufficientPermissionException;
@@ -1336,6 +1337,39 @@ default String getOwnerId()
13361337
@Nonnull
13371338
NSFWLevel getNSFWLevel();
13381339

1340+
/**
1341+
* Returns a {@link Set} of {@link SystemChannelFlag} associated to the guild.
1342+
* <br>For a description of what system channel flags represent, see {@link SystemChannelFlag}.
1343+
*
1344+
* @throws net.dv8tion.jda.api.exceptions.DetachedEntityException
1345+
* If this entity is {@link #isDetached() detached}.
1346+
*
1347+
* @return An <b>unmodifiable</b> set of system channel flags of this guild.
1348+
*
1349+
* @see <a href="https://discord.com/developers/docs/resources/guild#guild-object-system-channel-flags">
1350+
* System Channel Flags API documentation
1351+
* </a>
1352+
*/
1353+
@Nonnull
1354+
Set<SystemChannelFlag> getSystemChannelFlags();
1355+
1356+
/**
1357+
* Returns the bitmask of the {@linkplain SystemChannelFlag system channel flags} associated
1358+
* to the guild. This method may be preferable over {@link Guild#getSystemChannelFlags()}
1359+
* if new flags are introduced to the Discord API and the {@link SystemChannelFlag} enumeration
1360+
* cannot yet accommodate the new flags.
1361+
*
1362+
* @throws net.dv8tion.jda.api.exceptions.DetachedEntityException
1363+
* If this entity is {@link #isDetached() detached}.
1364+
*
1365+
* @return An integer bitmask of system channel flags of this guild.
1366+
*
1367+
* @see <a href="https://discord.com/developers/docs/resources/guild#guild-object-system-channel-flags">
1368+
* System Channel Flags API documentation
1369+
* </a>
1370+
*/
1371+
int getSystemChannelFlagsRaw();
1372+
13391373
/**
13401374
* Gets the Guild specific {@link Member Member} object for the provided
13411375
* {@link UserSnowflake}.

src/main/java/net/dv8tion/jda/api/entities/MessageHistory.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -375,10 +375,10 @@ public Message getMessageById(long id)
375375
* <br>{@code MessageHistory history = MessageHistory.getHistoryAfter(channel, messageId).limit(60).complete()}
376376
* <br>Will return a MessageHistory instance with the first 60 messages sent after the provided message ID.
377377
*
378-
* <p>Alternatively you can provide an epoch millisecond timestamp using {@link TimeUtil#getDiscordTimestamp(long) MiscUtil.getDiscordTimestamp(long)}:
378+
* <p>Alternatively you can provide an epoch millisecond timestamp using {@link TimeUtil#getDiscordTimestamp(long)}:
379379
* <br><pre><code>
380380
* long timestamp = System.currentTimeMillis(); // or any other epoch millis timestamp
381-
* String discordTimestamp = Long.toUnsignedString(MiscUtil.getDiscordTimestamp(timestamp));
381+
* String discordTimestamp = Long.toUnsignedString(TimeUtil.getDiscordTimestamp(timestamp));
382382
* MessageHistory history = MessageHistory.getHistoryAfter(channel, discordTimestamp).complete();
383383
* </code></pre>
384384
*
@@ -420,10 +420,10 @@ public static MessageRetrieveAction getHistoryAfter(@Nonnull MessageChannel chan
420420
* <br>{@code MessageHistory history = MessageHistory.getHistoryBefore(channel, messageId).limit(60).complete()}
421421
* <br>Will return a MessageHistory instance with the first 60 messages sent before the provided message ID.
422422
*
423-
* <p>Alternatively you can provide an epoch millisecond timestamp using {@link TimeUtil#getDiscordTimestamp(long) MiscUtil.getDiscordTimestamp(long)}:
423+
* <p>Alternatively you can provide an epoch millisecond timestamp using {@link TimeUtil#getDiscordTimestamp(long)}:
424424
* <br><pre><code>
425425
* long timestamp = System.currentTimeMillis(); // or any other epoch millis timestamp
426-
* String discordTimestamp = Long.toUnsignedString(MiscUtil.getDiscordTimestamp(timestamp));
426+
* String discordTimestamp = Long.toUnsignedString(TimeUtil.getDiscordTimestamp(timestamp));
427427
* MessageHistory history = MessageHistory.getHistoryBefore(channel, discordTimestamp).complete();
428428
* </code></pre>
429429
*
@@ -465,10 +465,10 @@ public static MessageRetrieveAction getHistoryBefore(@Nonnull MessageChannel cha
465465
* <br>{@code MessageHistory history = MessageHistory.getHistoryAround(channel, messageId).limit(60).complete()}
466466
* <br>Will return a MessageHistory instance with the first 60 messages sent around the provided message ID.
467467
*
468-
* <p>Alternatively you can provide an epoch millisecond timestamp using {@link TimeUtil#getDiscordTimestamp(long) MiscUtil.getDiscordTimestamp(long)}:
468+
* <p>Alternatively you can provide an epoch millisecond timestamp using {@link TimeUtil#getDiscordTimestamp(long)}:
469469
* <br><pre><code>
470470
* long timestamp = System.currentTimeMillis(); // or any other epoch millis timestamp
471-
* String discordTimestamp = Long.toUnsignedString(MiscUtil.getDiscordTimestamp(timestamp));
471+
* String discordTimestamp = Long.toUnsignedString(TimeUtil.getDiscordTimestamp(timestamp));
472472
* MessageHistory history = MessageHistory.getHistoryAround(channel, discordTimestamp).complete();
473473
* </code></pre>
474474
*

src/main/java/net/dv8tion/jda/api/entities/channel/middleman/MessageChannel.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,7 +1301,7 @@ default MessagePaginationAction getIterableHistory()
13011301
* @param messageId
13021302
* The id of the message that will act as a marker.
13031303
* @param limit
1304-
* The amount of messages to be retrieved around the marker. Minimum: 1, Max: 100.
1304+
* The amount of messages to be retrieved. Minimum: 1, Max: 100.
13051305
*
13061306
* @throws java.lang.IllegalArgumentException
13071307
* <ul>
@@ -1369,7 +1369,7 @@ default MessageHistory.MessageRetrieveAction getHistoryAround(@Nonnull String me
13691369
* @param messageId
13701370
* The id of the message that will act as a marker. The id must refer to a message from this MessageChannel.
13711371
* @param limit
1372-
* The amount of messages to be retrieved around the marker. Minimum: 1, Max: 100.
1372+
* The amount of messages to be retrieved. Minimum: 1, Max: 100.
13731373
*
13741374
* @throws java.lang.IllegalArgumentException
13751375
* <ul>
@@ -1437,7 +1437,7 @@ default MessageHistory.MessageRetrieveAction getHistoryAround(long messageId, in
14371437
* The {@link net.dv8tion.jda.api.entities.Message Message} that will act as a marker. The provided Message
14381438
* must be from this MessageChannel.
14391439
* @param limit
1440-
* The amount of messages to be retrieved around the marker. Minimum: 1, Max: 100.
1440+
* The amount of messages to be retrieved. Minimum: 1, Max: 100.
14411441
*
14421442
* @throws java.lang.IllegalArgumentException
14431443
* <ul>
@@ -1498,7 +1498,7 @@ default MessageHistory.MessageRetrieveAction getHistoryAround(@Nonnull Message m
14981498
* @param messageId
14991499
* The id of the message that will act as a marker.
15001500
* @param limit
1501-
* The amount of messages to be retrieved after the marker. Minimum: 1, Max: 100.
1501+
* The amount of messages to be retrieved. Minimum: 1, Max: 100.
15021502
*
15031503
* @throws java.lang.IllegalArgumentException
15041504
* <ul>
@@ -1558,7 +1558,7 @@ default MessageHistory.MessageRetrieveAction getHistoryAfter(@Nonnull String mes
15581558
* @param messageId
15591559
* The id of the message that will act as a marker.
15601560
* @param limit
1561-
* The amount of messages to be retrieved after the marker. Minimum: 1, Max: 100.
1561+
* The amount of messages to be retrieved. Minimum: 1, Max: 100.
15621562
*
15631563
* @throws java.lang.IllegalArgumentException
15641564
* Provided {@code limit} is less than {@code 1} or greater than {@code 100}.
@@ -1615,7 +1615,7 @@ default MessageHistory.MessageRetrieveAction getHistoryAfter(long messageId, int
16151615
* @param message
16161616
* The message that will act as a marker.
16171617
* @param limit
1618-
* The amount of messages to be retrieved after the marker. Minimum: 1, Max: 100.
1618+
* The amount of messages to be retrieved. Minimum: 1, Max: 100.
16191619
*
16201620
* @throws java.lang.IllegalArgumentException
16211621
* <ul>
@@ -1676,7 +1676,7 @@ default MessageHistory.MessageRetrieveAction getHistoryAfter(@Nonnull Message me
16761676
* @param messageId
16771677
* The id of the message that will act as a marker.
16781678
* @param limit
1679-
* The amount of messages to be retrieved after the marker. Minimum: 1, Max: 100.
1679+
* The amount of messages to be retrieved. Minimum: 1, Max: 100.
16801680
*
16811681
* @throws java.lang.IllegalArgumentException
16821682
* <ul>
@@ -1736,7 +1736,7 @@ default MessageHistory.MessageRetrieveAction getHistoryBefore(@Nonnull String me
17361736
* @param messageId
17371737
* The id of the message that will act as a marker.
17381738
* @param limit
1739-
* The amount of messages to be retrieved after the marker. Minimum: 1, Max: 100.
1739+
* The amount of messages to be retrieved. Minimum: 1, Max: 100.
17401740
*
17411741
* @throws java.lang.IllegalArgumentException
17421742
* <ul>
@@ -1771,7 +1771,7 @@ default MessageHistory.MessageRetrieveAction getHistoryBefore(long messageId, in
17711771
* <p><b>Examples:</b>
17721772
* <br>Retrieve 100 messages from the middle of history. {@literal >}100 message exist in history and the marker is {@literal >}50 messages
17731773
* from the edge of history.
1774-
* <br>{@code getHistoryAfter(message, 100)} - This will retrieve 100 messages from history sent before the marker.
1774+
* <br>{@code getHistoryBefore(message, 100)} - This will retrieve 100 messages from history sent before the marker.
17751775
*
17761776
* <p>The following {@link net.dv8tion.jda.api.requests.ErrorResponse ErrorResponses} are possible:
17771777
* <ul>
@@ -1796,7 +1796,7 @@ default MessageHistory.MessageRetrieveAction getHistoryBefore(long messageId, in
17961796
* @param message
17971797
* The message that will act as a marker.
17981798
* @param limit
1799-
* The amount of messages to be retrieved after the marker. Minimum: 1, Max: 100.
1799+
* The amount of messages to be retrieved. Minimum: 1, Max: 100.
18001800
*
18011801
* @throws java.lang.IllegalArgumentException
18021802
* <ul>

0 commit comments

Comments
 (0)