fix issue where matcher would match partial commands

This commit is contained in:
ayunami2000 2022-04-10 14:21:34 -04:00
parent 0fc2aa68b0
commit 8866f44aa2

View File

@ -7,6 +7,7 @@ import dev.plex.command.blocker.MatchCommand;
import dev.plex.command.blocker.RegexCommand; import dev.plex.command.blocker.RegexCommand;
import dev.plex.listener.PlexListener; import dev.plex.listener.PlexListener;
import dev.plex.player.PlexPlayer; import dev.plex.player.PlexPlayer;
import dev.plex.util.PlexLog;
import dev.plex.util.PlexUtils; import dev.plex.util.PlexUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -55,7 +56,7 @@ public class CommandListener extends PlexListener
} }
else if (blockedCommand instanceof MatchCommand matchCommand) else if (blockedCommand instanceof MatchCommand matchCommand)
{ {
if (message.toLowerCase().startsWith(matchCommand.getMatch().toLowerCase())) if (message.equalsIgnoreCase(matchCommand.getMatch()) || message.toLowerCase().startsWith(matchCommand.getMatch().toLowerCase() + " "))
{ {
isBlocked = true; isBlocked = true;
} }
@ -63,7 +64,7 @@ public class CommandListener extends PlexListener
if (isBlocked) if (isBlocked)
{ {
event.setCancelled(true); event.setCancelled(true);
//PlexLog.debug("Command blocked."); PlexLog.debug("Command blocked: " + blockedCommand);
player.sendMessage(PlexUtils.mmDeserialize(blockedCommand.getMessage())); player.sendMessage(PlexUtils.mmDeserialize(blockedCommand.getMessage()));
return; return;
} }