MccooldownCommand.java 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package com.gmail.nossr50.commands.player;
  2. import com.gmail.nossr50.config.Config;
  3. import com.gmail.nossr50.datatypes.player.McMMOPlayer;
  4. import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
  5. import com.gmail.nossr50.locale.LocaleLoader;
  6. import com.gmail.nossr50.util.commands.CommandUtils;
  7. import com.gmail.nossr50.util.player.UserManager;
  8. import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
  9. import com.google.common.collect.ImmutableList;
  10. import org.bukkit.command.Command;
  11. import org.bukkit.command.CommandSender;
  12. import org.bukkit.command.TabExecutor;
  13. import org.bukkit.entity.Player;
  14. import org.jetbrains.annotations.NotNull;
  15. import java.util.List;
  16. public class MccooldownCommand implements TabExecutor {
  17. @Override
  18. public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
  19. if (CommandUtils.noConsoleUsage(sender)) {
  20. return true;
  21. }
  22. if (!CommandUtils.hasPlayerDataKey(sender)) {
  23. return true;
  24. }
  25. if (args.length == 0) {
  26. Player player = (Player) sender;
  27. if (Config.getInstance().getScoreboardsEnabled() && Config.getInstance().getCooldownUseBoard()) {
  28. ScoreboardManager.enablePlayerCooldownScoreboard(player);
  29. if (!Config.getInstance().getCooldownUseChat()) {
  30. return true;
  31. }
  32. }
  33. if (UserManager.getPlayer(player) == null) {
  34. player.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
  35. return true;
  36. }
  37. McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
  38. player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Header"));
  39. player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
  40. for (SuperAbilityType ability : SuperAbilityType.values()) {
  41. if (!ability.getPermissions(player)) {
  42. continue;
  43. }
  44. int seconds = mcMMOPlayer.calculateTimeRemaining(ability);
  45. if (seconds <= 0) {
  46. player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.Y", ability.getLocalizedName()));
  47. } else {
  48. player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.N", ability.getLocalizedName(), seconds));
  49. }
  50. }
  51. return true;
  52. }
  53. return false;
  54. }
  55. @Override
  56. public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
  57. return ImmutableList.of();
  58. }
  59. }