Actually not an off by one

This commit is contained in:
fullwall 2023-02-10 23:44:54 +08:00
parent 0f6842991b
commit dddabd13b8

View File

@ -671,7 +671,7 @@ public class CommandTrait extends Trait {
} }
trait.globalCooldowns.remove(commandKey); trait.globalCooldowns.remove(commandKey);
} }
int timesUsed = nUsed.getOrDefault(commandKey, 0) + 1; int timesUsed = nUsed.getOrDefault(commandKey, 0);
if (command.n > 0 && command.n <= timesUsed) { if (command.n > 0 && command.n <= timesUsed) {
trait.sendErrorMessage(player, CommandTraitError.MAXIMUM_TIMES_USED, null, command.n); trait.sendErrorMessage(player, CommandTraitError.MAXIMUM_TIMES_USED, null, command.n);
return false; return false;
@ -683,7 +683,7 @@ public class CommandTrait extends Trait {
trait.globalCooldowns.put(commandKey, currentTimeSec); trait.globalCooldowns.put(commandKey, currentTimeSec);
} }
if (command.n > 0) { if (command.n > 0) {
nUsed.put(commandKey, timesUsed); nUsed.put(commandKey, timesUsed + 1);
} }
lastUsedId = command.id; lastUsedId = command.id;
return true; return true;