PowerLevelCommand.java 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package com.gmail.nossr50.commands.skills;
  2. import co.aikar.commands.BaseCommand;
  3. import co.aikar.commands.BukkitCommandIssuer;
  4. import co.aikar.commands.annotation.CommandAlias;
  5. import co.aikar.commands.annotation.CommandPermission;
  6. import co.aikar.commands.annotation.Conditions;
  7. import co.aikar.commands.annotation.Default;
  8. import com.gmail.nossr50.commands.CommandManager;
  9. import com.gmail.nossr50.datatypes.player.McMMOPlayer;
  10. import com.gmail.nossr50.mcMMO;
  11. import com.gmail.nossr50.util.player.UserManager;
  12. import org.bukkit.ChatColor;
  13. import org.bukkit.entity.Player;
  14. import org.jetbrains.annotations.NotNull;
  15. @CommandPermission("mcmmo.commands.mmopower")
  16. @CommandAlias("mmopower|mmopowerlevel|powerlevel")
  17. public class PowerLevelCommand extends BaseCommand {
  18. private final @NotNull mcMMO pluginRef;
  19. public PowerLevelCommand(@NotNull mcMMO pluginRef) {
  20. this.pluginRef = pluginRef;
  21. }
  22. @Default
  23. @Conditions(CommandManager.POWER_LEVEL_CONDITION)
  24. public void processCommand(String[] args) {
  25. BukkitCommandIssuer bukkitCommandIssuer = (BukkitCommandIssuer) getCurrentCommandIssuer();
  26. Player player = bukkitCommandIssuer.getPlayer();
  27. McMMOPlayer mmoPlayer = UserManager.getPlayer(player); //Should never be null at this point because its caught in an ACF validation
  28. if (mmoPlayer == null) {
  29. return;
  30. }
  31. int powerLevel = mmoPlayer.getPowerLevel();
  32. mmoPlayer.getPlayer().sendMessage(ChatColor.DARK_AQUA + "Your " + ChatColor.GOLD + "[mcMMO]" + ChatColor.DARK_AQUA + " power level is: " + ChatColor.GREEN + powerLevel);
  33. }
  34. }