Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.noximity</groupId>
<artifactId>remmychat</artifactId>
<version>1.4.1</version>
<version>1.4.2</version>
<packaging>jar</packaging>

<name>remmychat</name>
Expand Down
24 changes: 20 additions & 4 deletions src/main/java/com/noximity/remmyChat/commands/MessageCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,31 @@ 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])));
return true;
}

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());
Expand Down Expand Up @@ -100,4 +115,5 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
}
return new ArrayList<>();
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class ConfigManager {
private final Map<String, String> nameStyleTemplates = new HashMap<>();
private boolean urlFormattingEnabled;
private boolean useGroupFormat;
private boolean allowSelfMessaging;
private String chatFormat;
private boolean debugEnabled;
private boolean verboseStartup;
Expand All @@ -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%");
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -250,4 +253,8 @@ public int getCooldown() {
public boolean isDebugEnabled() {
return debugEnabled;
}

public boolean isAllowSelfMessaging() {
return allowSelfMessaging;
}
}
1 change: 1 addition & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading