did some updates

This commit is contained in:
minster586
2025-08-09 02:59:19 -04:00
parent 95ee183b38
commit c28b4b89ba
7 changed files with 29 additions and 13 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/target

12
pom.xml
View File

@@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.minster586</groupId>
<artifactId>NTFYNotifier</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
<packaging>jar</packaging>
<name>NTFYNotifier</name>
@@ -34,9 +34,19 @@
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>plugin.yml</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<excludes>
<exclude>plugin.yml</exclude>
</excludes>
</resource>
</resources>
<plugins>

View File

@@ -25,14 +25,16 @@ public class CommandMonitor implements Listener {
public void onPlayerCommand(PlayerCommandPreprocessEvent event) {
if (!config.getBoolean("notifications.commands.enabled", true)) return;
String commandLine = event.getMessage().toLowerCase().trim();
String commandLine = event.getMessage().trim();
CommandSender sender = event.getPlayer();
List<String> watched = config.getStringList("notifications.commands.watch");
for (String keyword : watched) {
if (commandLine.startsWith("/" + keyword.toLowerCase())) {
if (commandLine.toLowerCase().startsWith("/" + keyword.toLowerCase())) {
String[] parts = commandLine.split("\\s+");
String target = parts.length > 1 ? parts[1] : null;
String title = messageManager.getMessage(keyword + ".title");
String message = messageManager.formatMessage(keyword + ".message", (sender instanceof Player) ? (Player) sender : null);
String message = messageManager.formatMessage(keyword + ".message", (sender instanceof Player) ? (Player) sender : null, target);
notifier.sendNotification(title, message);
break;
}

View File

@@ -20,12 +20,15 @@ public class MessageManager {
return messages.getString("messages." + path, "");
}
public String formatMessage(String path, Player player) {
public String formatMessage(String path, Player player, String target) {
String message = getMessage(path);
if (player != null) {
message = message.replace("%player%", player.getName());
}
if (target != null) {
message = message.replace("%target%", target);
}
String serverName = plugin.getConfig().getString("server-name", "Minecraft Server");
message = message.replace("%server%", serverName);

View File

@@ -26,7 +26,7 @@ public class PlayerEventListener implements Listener {
if (config.getBoolean("notifications.join", true)) {
Player player = event.getPlayer();
String title = messageManager.getMessage("join.title");
String message = messageManager.formatMessage("join.message", player);
String message = messageManager.formatMessage("join.message", player, null);
notifier.sendNotification(title, message);
}
}
@@ -36,7 +36,7 @@ public class PlayerEventListener implements Listener {
if (config.getBoolean("notifications.quit", true)) {
Player player = event.getPlayer();
String title = messageManager.getMessage("quit.title");
String message = messageManager.formatMessage("quit.message", player);
String message = messageManager.formatMessage("quit.message", player, null);
notifier.sendNotification(title, message);
}
}

View File

@@ -10,16 +10,16 @@ messages:
message: "%player% issued /stop"
ban:
title: "Player Banned"
message: "%player% used /ban"
message: "%player% banned %target%"
kick:
title: "Player Kicked"
message: "%player% used /kick"
message: "%player% kicked %target%"
mute:
title: "Player Muted"
message: "%player% used /mute"
message: "%player% muted %target%"
warn:
title: "Player Warned"
message: "%player% used /warn"
message: "%player% warned %target%"
op:
title: "Player Opped"
message: "%player% used /op"
message: "%player% opped %target%"

View File

@@ -1,5 +1,5 @@
name: NTFYNotifier
version: 1.0.0
version: ${project.version}
main: com.minster586.ntfyplugin.Main
api-version: 1.14
author: minster586