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

@@ -6,7 +6,7 @@
<groupId>com.smartcraft.notifier</groupId>
<artifactId>SmartCraftNotifier</artifactId>
<version>1.2.0</version>
<version>1.2.1</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>

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

@@ -7,3 +7,7 @@ gotify:
# Token from your Gotify app
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

View File

@@ -7,3 +7,7 @@ gotify:
# Token from your Gotify app
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

View File

@@ -0,0 +1,3 @@
artifactId=SmartCraftNotifier
groupId=com.smartcraft.notifier
version=1.2.1

View File

@@ -0,0 +1,7 @@
com\smartcraft\notifier\GotifySender$1.class
com\smartcraft\notifier\listeners\CoreJoinQuitListener.class
com\smartcraft\notifier\GotifySender$2.class
com\smartcraft\notifier\SmartCraftNotifier.class
com\smartcraft\notifier\GotifySender.class
com\smartcraft\notifier\CommandHandler.class
com\smartcraft\notifier\ConfigManager.class

View File

@@ -0,0 +1,5 @@
G:\github\Smartcraft-Server\smartcraft-notifier\src\main\java\com\smartcraft\notifier\SmartCraftNotifier.java
G:\github\Smartcraft-Server\smartcraft-notifier\src\main\java\com\smartcraft\notifier\listeners\CoreJoinQuitListener.java
G:\github\Smartcraft-Server\smartcraft-notifier\src\main\java\com\smartcraft\notifier\ConfigManager.java
G:\github\Smartcraft-Server\smartcraft-notifier\src\main\java\com\smartcraft\notifier\GotifySender.java
G:\github\Smartcraft-Server\smartcraft-notifier\src\main\java\com\smartcraft\notifier\CommandHandler.java

Binary file not shown.