Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.zach.CrucialCommands.commands;
- import me.zach.CrucialCommands.CrucialCommands;
- import org.bukkit.Bukkit;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandExecutor;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- public class CommandFly implements CommandExecutor {
- public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
- if (sender instanceof Player) {
- Player player = (Player) sender;
- if(cmd.getName().equalsIgnoreCase("fly")){
- if(player.hasPermission("crucial.fly")) {
- if(args.length == 0) {
- if(player.isFlying() == false) {
- player.setAllowFlight(true);
- player.setFlying(true);
- } else {
- player.setAllowFlight(false);
- player.setFlying(false);
- }
- } else if(args.length == 1){
- Player target = Bukkit.getServer().getPlayer(args[1]);
- if(target.isFlying() == false) {
- target.setFlying(true);
- target.setAllowFlight(true);
- } else {
- target.setFlying(false);
- target.setAllowFlight(false);
- }
- }
- } else {
- player.sendMessage(CrucialCommands.noPermission + "You do not have permission to do that.");
- }
- }
- } else {
- sender.sendMessage("You must be a player to do this.");
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment