package com.lifeknight.relaymchub.commands.movement; import com.lifeknight.relaymchub.ExtraListeners; import com.lifeknight.relaymcutils.player.SmartPlayer; import com.lifeknight.relayutils.player.Group; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import static org.bukkit.ChatColor.GREEN; import static org.bukkit.ChatColor.RED; public class FlyCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (!(sender instanceof Player) || !command.getName().equalsIgnoreCase("fly")) { return true; } SmartPlayer smartPlayer = SmartPlayer.getSmartPlayer((Player) sender); if (smartPlayer.isInGroupOrHigher(Group.TIERI)) { if (ExtraListeners.isInArena(smartPlayer.getPlayer()) && !smartPlayer.isStaff()) { smartPlayer.sendErrorMessage("You cannot fly in the arena!"); return true; } boolean isFlying = smartPlayer.getAllowFlight(); smartPlayer.setAllowFlight(!isFlying); smartPlayer.sendSuccessMessage("Flying is now %s%s.", isFlying ? RED + "OFF" : GREEN + "ON", GREEN); } else { smartPlayer.sendChampionPurchaseMessage(); } return true; } }