did some updates
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/target
|
12
pom.xml
12
pom.xml
@@ -6,7 +6,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.minster586</groupId>
|
<groupId>com.minster586</groupId>
|
||||||
<artifactId>NTFYNotifier</artifactId>
|
<artifactId>NTFYNotifier</artifactId>
|
||||||
<version>1.0.0</version>
|
<version>1.0.1</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>NTFYNotifier</name>
|
<name>NTFYNotifier</name>
|
||||||
|
|
||||||
@@ -34,9 +34,19 @@
|
|||||||
|
|
||||||
<build>
|
<build>
|
||||||
<resources>
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
<includes>
|
||||||
|
<include>plugin.yml</include>
|
||||||
|
</includes>
|
||||||
|
</resource>
|
||||||
<resource>
|
<resource>
|
||||||
<directory>src/main/resources</directory>
|
<directory>src/main/resources</directory>
|
||||||
<filtering>false</filtering>
|
<filtering>false</filtering>
|
||||||
|
<excludes>
|
||||||
|
<exclude>plugin.yml</exclude>
|
||||||
|
</excludes>
|
||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
@@ -25,14 +25,16 @@ public class CommandMonitor implements Listener {
|
|||||||
public void onPlayerCommand(PlayerCommandPreprocessEvent event) {
|
public void onPlayerCommand(PlayerCommandPreprocessEvent event) {
|
||||||
if (!config.getBoolean("notifications.commands.enabled", true)) return;
|
if (!config.getBoolean("notifications.commands.enabled", true)) return;
|
||||||
|
|
||||||
String commandLine = event.getMessage().toLowerCase().trim();
|
String commandLine = event.getMessage().trim();
|
||||||
CommandSender sender = event.getPlayer();
|
CommandSender sender = event.getPlayer();
|
||||||
|
|
||||||
List<String> watched = config.getStringList("notifications.commands.watch");
|
List<String> watched = config.getStringList("notifications.commands.watch");
|
||||||
for (String keyword : watched) {
|
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 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);
|
notifier.sendNotification(title, message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -20,12 +20,15 @@ public class MessageManager {
|
|||||||
return messages.getString("messages." + path, "");
|
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);
|
String message = getMessage(path);
|
||||||
|
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
message = message.replace("%player%", player.getName());
|
message = message.replace("%player%", player.getName());
|
||||||
}
|
}
|
||||||
|
if (target != null) {
|
||||||
|
message = message.replace("%target%", target);
|
||||||
|
}
|
||||||
|
|
||||||
String serverName = plugin.getConfig().getString("server-name", "Minecraft Server");
|
String serverName = plugin.getConfig().getString("server-name", "Minecraft Server");
|
||||||
message = message.replace("%server%", serverName);
|
message = message.replace("%server%", serverName);
|
||||||
|
@@ -26,7 +26,7 @@ public class PlayerEventListener implements Listener {
|
|||||||
if (config.getBoolean("notifications.join", true)) {
|
if (config.getBoolean("notifications.join", true)) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
String title = messageManager.getMessage("join.title");
|
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);
|
notifier.sendNotification(title, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -36,7 +36,7 @@ public class PlayerEventListener implements Listener {
|
|||||||
if (config.getBoolean("notifications.quit", true)) {
|
if (config.getBoolean("notifications.quit", true)) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
String title = messageManager.getMessage("quit.title");
|
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);
|
notifier.sendNotification(title, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,16 +10,16 @@ messages:
|
|||||||
message: "%player% issued /stop"
|
message: "%player% issued /stop"
|
||||||
ban:
|
ban:
|
||||||
title: "Player Banned"
|
title: "Player Banned"
|
||||||
message: "%player% used /ban"
|
message: "%player% banned %target%"
|
||||||
kick:
|
kick:
|
||||||
title: "Player Kicked"
|
title: "Player Kicked"
|
||||||
message: "%player% used /kick"
|
message: "%player% kicked %target%"
|
||||||
mute:
|
mute:
|
||||||
title: "Player Muted"
|
title: "Player Muted"
|
||||||
message: "%player% used /mute"
|
message: "%player% muted %target%"
|
||||||
warn:
|
warn:
|
||||||
title: "Player Warned"
|
title: "Player Warned"
|
||||||
message: "%player% used /warn"
|
message: "%player% warned %target%"
|
||||||
op:
|
op:
|
||||||
title: "Player Opped"
|
title: "Player Opped"
|
||||||
message: "%player% used /op"
|
message: "%player% opped %target%"
|
@@ -1,5 +1,5 @@
|
|||||||
name: NTFYNotifier
|
name: NTFYNotifier
|
||||||
version: 1.0.0
|
version: ${project.version}
|
||||||
main: com.minster586.ntfyplugin.Main
|
main: com.minster586.ntfyplugin.Main
|
||||||
api-version: 1.14
|
api-version: 1.14
|
||||||
author: minster586
|
author: minster586
|
||||||
|
Reference in New Issue
Block a user