mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-02-02 21:41:43 +01:00
Fix off by one command nUsed
This commit is contained in:
parent
41ca21a131
commit
0f6842991b
@ -671,8 +671,8 @@ public class CommandTrait extends Trait {
|
||||
}
|
||||
trait.globalCooldowns.remove(commandKey);
|
||||
}
|
||||
int previouslyUsed = nUsed.getOrDefault(commandKey, 0);
|
||||
if (command.n > 0 && command.n <= previouslyUsed) {
|
||||
int timesUsed = nUsed.getOrDefault(commandKey, 0) + 1;
|
||||
if (command.n > 0 && command.n <= timesUsed) {
|
||||
trait.sendErrorMessage(player, CommandTraitError.MAXIMUM_TIMES_USED, null, command.n);
|
||||
return false;
|
||||
}
|
||||
@ -683,7 +683,7 @@ public class CommandTrait extends Trait {
|
||||
trait.globalCooldowns.put(commandKey, currentTimeSec);
|
||||
}
|
||||
if (command.n > 0) {
|
||||
nUsed.put(commandKey, previouslyUsed + 1);
|
||||
nUsed.put(commandKey, timesUsed);
|
||||
}
|
||||
lastUsedId = command.id;
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user