Added Title Config support
This commit is contained in:
@@ -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
|
||||
|
@@ -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}"
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
name: SmartCraftNotifier
|
||||
version: 1.2.0
|
||||
version: 1.2.1
|
||||
main: com.smartcraft.notifier.SmartCraftNotifier
|
||||
api-version: 1.20
|
||||
|
||||
|
Reference in New Issue
Block a user