Skip to content

Commit

Permalink
Fix /npc command gcooldown
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Feb 13, 2022
1 parent 3ca6576 commit 676590f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ public void collidable(CommandContext args, CommandSender sender, NPC npc) throw

@Command(
aliases = { "npc" },
usage = "command|cmd (add [command] | remove [id] | permissions [permissions] | sequential | random | (exp|item)cost [cost]) (-l[eft]/-r[ight]) (-p[layer] -o[p]), --cooldown [seconds] --delay [ticks] --permissions [perms] --n [max # of uses]",
usage = "command|cmd (add [command] | remove [id] | permissions [permissions] | sequential | random | (exp|item)cost [cost]) (-l[eft]/-r[ight]) (-p[layer] -o[p]), --(g)cooldown [seconds] --delay [ticks] --permissions [perms] --n [max # of uses]",
desc = "Controls commands which will be run when clicking on an NPC",
help = Messages.NPC_COMMAND_HELP,
modifiers = { "command", "cmd" },
Expand Down
7 changes: 5 additions & 2 deletions main/src/main/java/net/citizensnpcs/trait/CommandTrait.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,10 @@ public void describe(CommandSender sender) {

private String describe(NPCCommand command) {
String output = "<br> - [" + StringHelper.wrap(command.id) + "]: " + command.command + " ["
+ StringHelper.wrap(command.cooldown + "s") + "]";
+ StringHelper.wrap(command.cooldown) + "s]";
if (command.globalCooldown > 0) {
output += "[global " + StringHelper.wrap(command.globalCooldown) + "s]";
}
if (command.op) {
output += " -o";
}
Expand Down Expand Up @@ -615,7 +618,7 @@ public boolean canUse(CommandTrait trait, Player player, NPCCommand command) {
lastUsed.remove(commandKey);
}
if (command.globalCooldown > 0 && trait.globalCooldowns.containsKey(commandKey)) {
long deadline = ((Number) trait.globalCooldowns.get(commandKey)).longValue() + command.cooldown;
long deadline = ((Number) trait.globalCooldowns.get(commandKey)).longValue() + command.globalCooldown;
if (currentTimeSec < deadline) {
long seconds = deadline - currentTimeSec;
trait.sendErrorMessage(player, CommandTraitMessages.ON_GLOBAL_COOLDOWN,
Expand Down

0 comments on commit 676590f

Please sign in to comment.