Add more relocations to fix compatibility issues

This commit is contained in:
Norbi Peti 2021-02-09 23:00:40 +01:00
parent cbc9728c02
commit b18f6beba9
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
2 changed files with 27 additions and 2 deletions

14
pom.xml
View file

@ -53,6 +53,18 @@
<excludes>
</excludes>
</relocation>
<relocation>
<pattern>com.fasterxml</pattern>
<shadedPattern>btndvtm.dp.com.fasterxml</shadedPattern>
</relocation>
<relocation>
<pattern>org.mockito</pattern>
<shadedPattern>btndvtm.dp.org.mockito</shadedPattern>
</relocation>
<relocation>
<pattern>org.slf4j</pattern>
<shadedPattern>btndvtm.dp.org.slf4j</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
@ -148,7 +160,7 @@
<dependency>
<groupId>com.discord4j</groupId>
<artifactId>discord4j-core</artifactId>
<version>3.1.1</version>
<version>3.1.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-jdk14 -->
<dependency>

View file

@ -135,16 +135,28 @@ public class DiscordPlugin extends ButtonPlugin {
}
}
starting = true;
//System.out.println("This line should show up for sure");
val cb = DiscordClientBuilder.create(token).build().gateway();
//System.out.println("Got gateway bootstrap");
cb.setInitialStatus(si -> Presence.doNotDisturb(Activity.playing("booting")));
cb.setStoreService(new JdkStoreService()); //The default doesn't work for some reason - it's waaay faster now
cb.login().doOnError(t -> stopStarting()).subscribe(dc -> {
//System.out.println("Initial status and store service set");
cb.login().doOnError(t -> {
stopStarting();
//System.out.println("Got this error: " + t); t.printStackTrace();
}).subscribe(dc -> {
//System.out.println("Login successful, got dc: " + dc);
DiscordPlugin.dc = dc; //Set to gateway client
dc.on(ReadyEvent.class) // Listen for ReadyEvent(s)
.map(event -> event.getGuilds().size()) // Get how many guilds the bot is in
.flatMap(size -> dc
.on(GuildCreateEvent.class) // Listen for GuildCreateEvent(s)
.take(size) // Take only the first `size` GuildCreateEvent(s) to be received
.doOnError(t -> {
stopStarting();
//System.out.println("Got error: " + t);
t.printStackTrace();
})
.collectList()).doOnError(t -> stopStarting()).subscribe(this::handleReady); // Take all received GuildCreateEvents and make it a List
}); /* All guilds have been received, client is fully connected */
} catch (Exception e) {
@ -164,6 +176,7 @@ public class DiscordPlugin extends ButtonPlugin {
public static Guild mainServer;
private void handleReady(List<GuildCreateEvent> event) {
//System.out.println("Got ready event");
try {
if (mainServer != null) { //This is not the first ready event
getLogger().info("Ready event already handled"); //TODO: It should probably handle disconnections