@@ -212,7 +212,7 @@ private Map.Entry<Command, Map.Entry<Method, Object>> getAssociatedCommand(@NotN
212
212
public static String ONLY_BY_CONSOLE = ChatColor .RED + "This command is only executable by console!" ;
213
213
public static String NO_PERMISSION = ChatColor .RED + "You don't have enough permission to execute this command!" ;
214
214
public static String SHORT_OR_LONG_ARG_SIZE = ChatColor .RED + "Required argument length is less or greater than needed!" ;
215
- public static String WAIT_BEFORE_USING_AGAIN = ChatColor .RED + "You have to wait before using this command again!" ;
215
+ public static String WAIT_BEFORE_USING_AGAIN = ChatColor .RED + "You have to wait %ds before using this command again!" ;
216
216
217
217
@ Override
218
218
public boolean onCommand (@ NotNull CommandSender sender , @ NotNull org .bukkit .command .Command cmd , @ NotNull String label , String [] args ) {
@@ -244,11 +244,13 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull org.bukkit.comm
244
244
}
245
245
246
246
if (cooldowns .containsKey (sender )) {
247
- if (command .cooldown () > 0 && ((System .currentTimeMillis () - cooldowns .get (sender )) / 1000 ) % 60 <= command .cooldown ()) {
248
- sender .sendMessage (WAIT_BEFORE_USING_AGAIN );
247
+ final int remainingTime = (int ) ((System .currentTimeMillis () - cooldowns .get (sender )) / 1000 ) % 60 ;
248
+
249
+ if (command .cooldown () > 0 && remainingTime <= command .cooldown ()) {
250
+ sender .sendMessage (String .format (WAIT_BEFORE_USING_AGAIN , command .cooldown () - remainingTime ));
249
251
return true ;
250
252
} else {
251
- cooldowns .remove (sender );
253
+ cooldowns .put (sender , System . currentTimeMillis () );
252
254
}
253
255
} else {
254
256
cooldowns .put (sender , System .currentTimeMillis ());
@@ -297,7 +299,7 @@ public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull org.bu
297
299
@ NotNull
298
300
public List <Command > getCommands () {
299
301
List <Command > commands = new ArrayList <>(this .commands .keySet ());
300
- commands .addAll (subCommands .keySet ());
302
+ commands .addAll (this . subCommands .keySet ());
301
303
302
304
return commands ;
303
305
}
0 commit comments