Skip to content

Commit 23bc08c

Browse files
Patch Builds
1 parent 01cf56d commit 23bc08c

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

.github/workflows/build-dev.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ jobs:
2020
java-version: 25
2121
distribution: temurin
2222

23+
- name: Download Server
24+
run: wget -O HytaleServer.jar ${{ secrets.SERVER }}
25+
2326
- name: Build
2427
run: mvn package
2528

pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
<groupId>com.hypixel.hytale</groupId>
2020
<artifactId>HytaleServer-parent</artifactId>
2121
<version>1.0-SNAPSHOT</version>
22-
<scope>provided</scope>
22+
<scope>system</scope>
23+
<systemPath>${project.basedir}/HytaleServer.jar</systemPath>
2324
</dependency>
2425

2526
<dependency>

src/main/java/net/aerh/discordbridge/config/EventsConfig.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.hypixel.hytale.codec.Codec;
44
import com.hypixel.hytale.codec.KeyedCodec;
55
import com.hypixel.hytale.codec.builder.BuilderCodec;
6+
import org.jetbrains.annotations.NotNull;
67

78
/**
89
* Configuration for event broadcast toggles.

src/main/java/net/aerh/discordbridge/discord/DiscordBotConnection.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
1212
import net.dv8tion.jda.api.requests.GatewayIntent;
1313
import net.dv8tion.jda.api.utils.MemberCachePolicy;
14-
import net.dv8tion.jda.api.webhook.WebhookClient;
1514
import org.jetbrains.annotations.NotNull;
1615

1716
import java.util.concurrent.CompletableFuture;
@@ -109,15 +108,20 @@ public void sendWebhookMessage(@NotNull String webhookUrl, @NotNull String usern
109108
return;
110109
}
111110

112-
try (WebhookClient webhookClient = WebhookClient.createClient(jda, webhookUrl)) {
113-
webhookClient.sendMessage(content)
114-
.setUsername(username)
115-
.queue(null, throwable -> logger.at(Level.WARNING)
116-
.withCause(throwable)
117-
.log("Failed to send webhook message to Discord"));
118-
} catch (Exception e) {
119-
logger.at(Level.WARNING).withCause(e).log("Failed to create webhook client");
120-
}
111+
// Send via HTTP POST to webhook URL
112+
java.net.http.HttpClient httpClient = java.net.http.HttpClient.newHttpClient();
113+
String json = String.format("{\"username\": \"%s\", \"content\": \"%s\"}", username.replace("\"", "\\\""), content.replace("\"", "\\\""));
114+
java.net.http.HttpRequest request = java.net.http.HttpRequest.newBuilder()
115+
.uri(java.net.URI.create(webhookUrl))
116+
.header("Content-Type", "application/json")
117+
.POST(java.net.http.HttpRequest.BodyPublishers.ofString(json))
118+
.build();
119+
120+
httpClient.sendAsync(request, java.net.http.HttpResponse.BodyHandlers.discarding())
121+
.exceptionally(throwable -> {
122+
logger.at(Level.WARNING).withCause(throwable).log("Failed to send webhook message to Discord");
123+
return null;
124+
});
121125
}
122126

123127
@Override

0 commit comments

Comments
 (0)