Added Title Config support
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>com.smartcraft.notifier</groupId>
|
<groupId>com.smartcraft.notifier</groupId>
|
||||||
<artifactId>SmartCraftNotifier</artifactId>
|
<artifactId>SmartCraftNotifier</artifactId>
|
||||||
<version>1.2.0</version>
|
<version>1.2.1</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
@@ -41,16 +41,21 @@ public class GotifySender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void send(String message) {
|
public static void send(String message) {
|
||||||
String url = SmartCraftNotifier.getInstance().getConfig().getString("gotify.url");
|
var plugin = SmartCraftNotifier.getInstance();
|
||||||
String token = SmartCraftNotifier.getInstance().getConfig().getString("gotify.token");
|
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()) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RequestBody body = new FormBody.Builder()
|
RequestBody body = new FormBody.Builder()
|
||||||
.add("title", "SmartCraft Notifier")
|
.add("title", title)
|
||||||
.add("message", message)
|
.add("message", message)
|
||||||
.add("priority", "5")
|
.add("priority", "5")
|
||||||
.build();
|
.build();
|
||||||
@@ -63,7 +68,7 @@ public class GotifySender {
|
|||||||
client.newCall(request).enqueue(new Callback() {
|
client.newCall(request).enqueue(new Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Call call, IOException e) {
|
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
|
@Override
|
||||||
|
@@ -7,3 +7,7 @@ gotify:
|
|||||||
|
|
||||||
# Token from your Gotify app
|
# 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
|
name: SmartCraftNotifier
|
||||||
version: 1.2.0
|
version: 1.2.1
|
||||||
main: com.smartcraft.notifier.SmartCraftNotifier
|
main: com.smartcraft.notifier.SmartCraftNotifier
|
||||||
api-version: 1.20
|
api-version: 1.20
|
||||||
|
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -7,3 +7,7 @@ gotify:
|
|||||||
|
|
||||||
# Token from your Gotify app
|
# 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
|
name: SmartCraftNotifier
|
||||||
version: 1.2.0
|
version: 1.2.1
|
||||||
main: com.smartcraft.notifier.SmartCraftNotifier
|
main: com.smartcraft.notifier.SmartCraftNotifier
|
||||||
api-version: 1.20
|
api-version: 1.20
|
||||||
|
|
||||||
|
3
target/maven-archiver/pom.properties
Normal file
3
target/maven-archiver/pom.properties
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
artifactId=SmartCraftNotifier
|
||||||
|
groupId=com.smartcraft.notifier
|
||||||
|
version=1.2.1
|
@@ -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
|
@@ -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
|
BIN
target/original-SmartCraftNotifier.jar
Normal file
BIN
target/original-SmartCraftNotifier.jar
Normal file
Binary file not shown.
Reference in New Issue
Block a user