diff --git a/pom.xml b/pom.xml
index 379fe30..9c1dc02 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
com.noximity
remmychat
- 1.4.1
+ 1.4.2
jar
remmychat
diff --git a/src/main/java/com/noximity/remmyChat/commands/MessageCommand.java b/src/main/java/com/noximity/remmyChat/commands/MessageCommand.java
index b09e922..4c180ae 100644
--- a/src/main/java/com/noximity/remmyChat/commands/MessageCommand.java
+++ b/src/main/java/com/noximity/remmyChat/commands/MessageCommand.java
@@ -38,7 +38,19 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
return true;
}
- Player target = Bukkit.getPlayer(args[0]);
+ // First try to get an exact match to prevent partial matches
+ Player target = null;
+ String targetName = args[0];
+
+ // Check for exact match first
+ for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
+ if (onlinePlayer.getName().equalsIgnoreCase(targetName)) {
+ target = onlinePlayer;
+ break;
+ }
+ }
+
+ // If no exact match was found, show error
if (target == null || !target.isOnline()) {
player.sendMessage(plugin.getFormatService().formatSystemMessage("error.player-not-found",
Placeholder.parsed("player", args[0])));
@@ -46,8 +58,11 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
}
if (target.equals(player)) {
- player.sendMessage(plugin.getFormatService().formatSystemMessage("error.cannot-message-self"));
- return true;
+ // Only block self-messaging if not allowed in config
+ if (!plugin.getConfigManager().isAllowSelfMessaging()) {
+ player.sendMessage(plugin.getFormatService().formatSystemMessage("error.cannot-message-self"));
+ return true;
+ }
}
ChatUser targetUser = plugin.getChatService().getChatUser(target.getUniqueId());
@@ -100,4 +115,5 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
}
return new ArrayList<>();
}
-}
\ No newline at end of file
+}
+
diff --git a/src/main/java/com/noximity/remmyChat/config/ConfigManager.java b/src/main/java/com/noximity/remmyChat/config/ConfigManager.java
index d24ccfa..bae9cc1 100644
--- a/src/main/java/com/noximity/remmyChat/config/ConfigManager.java
+++ b/src/main/java/com/noximity/remmyChat/config/ConfigManager.java
@@ -21,6 +21,7 @@ public class ConfigManager {
private final Map nameStyleTemplates = new HashMap<>();
private boolean urlFormattingEnabled;
private boolean useGroupFormat;
+ private boolean allowSelfMessaging;
private String chatFormat;
private boolean debugEnabled;
private boolean verboseStartup;
@@ -43,6 +44,7 @@ private void loadConfig() {
loadGroupFormats();
loadUrlFormatting();
this.useGroupFormat = config.getBoolean("features.use-group-format", true);
+ this.allowSelfMessaging = config.getBoolean("features.allow-self-messaging", false);
this.chatFormat = config.getString("chat-format", "%channel_prefix% %group_prefix%%name%: %message%");
}
@@ -180,6 +182,7 @@ public void reloadConfig() {
loadGroupFormats();
loadUrlFormatting();
this.useGroupFormat = config.getBoolean("features.use-group-format", true);
+ this.allowSelfMessaging = config.getBoolean("features.allow-self-messaging", false);
this.chatFormat = config.getString("chat-format", "%channel_prefix% %group_prefix%%name%: %message%");
// Reload placeholders
@@ -250,4 +253,8 @@ public int getCooldown() {
public boolean isDebugEnabled() {
return debugEnabled;
}
+
+ public boolean isAllowSelfMessaging() {
+ return allowSelfMessaging;
+ }
}
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index 5c2bfd3..db770d8 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -30,6 +30,7 @@ features:
clickable-links: true
player-formatting: false # Whether players can use MiniMessage formatting
use-group-format: true # Whether to use group-based formatting
+ allow-self-messaging: false # Whether players can send messages to themselves
# Chat cooldown in seconds (0 to disable)
chat-cooldown: 3