Added Title Config support

This commit is contained in:
minster586
2025-06-21 15:20:09 -04:00
parent d43794f34b
commit 6ae0d19a81
17 changed files with 38 additions and 10 deletions

View File

@@ -41,16 +41,21 @@ public class GotifySender {
}
public static void send(String message) {
String url = SmartCraftNotifier.getInstance().getConfig().getString("gotify.url");
String token = SmartCraftNotifier.getInstance().getConfig().getString("gotify.token");
var plugin = SmartCraftNotifier.getInstance();
var config = plugin.getConfig();
String url = config.getString("gotify.url");
String token = config.getString("gotify.token");
String title = config.getString("gotify.title", "SmartCraft Notifier")
.replace("{server}", plugin.getServerName());
if (url == null || token == null || url.isEmpty() || token.isEmpty()) {
SmartCraftNotifier.getInstance().getLogger().warning("Gotify URL or token is missing in config.yml");
plugin.getLogger().warning("Gotify URL or token is missing in config.yml");
return;
}
RequestBody body = new FormBody.Builder()
.add("title", "SmartCraft Notifier")
.add("title", title)
.add("message", message)
.add("priority", "5")
.build();
@@ -63,7 +68,7 @@ public class GotifySender {
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
SmartCraftNotifier.getInstance().getLogger().warning("Failed to send Gotify message: " + e.getMessage());
plugin.getLogger().warning("Failed to send Gotify message: " + e.getMessage());
}
@Override

View File

@@ -6,4 +6,8 @@ gotify:
url: "https://gotify.example.com"
# Token from your Gotify app
token: "REPLACE_WITH_YOUR_TOKEN"
token: "REPLACE_WITH_YOUR_TOKEN"
# Title used in Gotify notifications (supports {server} placeholder)
title: "🔔 Player Alert from {server}"

View File

@@ -1,5 +1,5 @@
name: SmartCraftNotifier
version: 1.2.0
version: 1.2.1
main: com.smartcraft.notifier.SmartCraftNotifier
api-version: 1.20