Skip to content

Commit

Permalink
Fixed detection of command cooldowns (#1262)
Browse files Browse the repository at this point in the history
  • Loading branch information
OmerBenGera committed Jul 14, 2022
1 parent d8ad2b8 commit 007dafc
Showing 1 changed file with 14 additions and 4 deletions.
Expand Up @@ -250,14 +250,14 @@ public boolean execute(CommandSender sender, String label, String[] args) {
return false;
}

String commandLabel = command.getAliases().get(0);

if (sender instanceof Player) {
UUID uuid = ((Player) sender).getUniqueId();
SuperiorPlayer superiorPlayer = plugin.getPlayers().getSuperiorPlayer(uuid);
if (!superiorPlayer.hasPermission("superior.admin.bypass.cooldowns")) {
Pair<Integer, String> commandCooldown = plugin.getSettings().getCommandsCooldown().get(commandLabel);
Pair<Integer, String> commandCooldown = getCooldown(command);
if (commandCooldown != null) {
String commandLabel = command.getAliases().get(0);

Map<String, Long> playerCooldowns = commandsCooldown.get(uuid);
long timeNow = System.currentTimeMillis();

Expand Down Expand Up @@ -308,7 +308,6 @@ public boolean execute(CommandSender sender, String label, String[] args) {
return false;
}


@Override
public List<String> tabComplete(CommandSender sender, String label, String[] args) {
if (args.length > 0) {
Expand Down Expand Up @@ -338,4 +337,15 @@ public List<String> tabComplete(CommandSender sender, String label, String[] arg

}

@Nullable
private Pair<Integer, String> getCooldown(SuperiorCommand command) {
for (String alias : command.getAliases()) {
Pair<Integer, String> commandCooldown = plugin.getSettings().getCommandsCooldown().get(alias);
if (commandCooldown != null)
return commandCooldown;
}

return null;
}

}

0 comments on commit 007dafc

Please sign in to comment.