Zach443

Untitled

Mar 3rd, 2014
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.34 KB | None | 0 0
  1. package me.zach.CrucialCommands.commands;
  2.  
  3. import me.zach.CrucialCommands.CrucialCommands;
  4.  
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.command.Command;
  7. import org.bukkit.command.CommandExecutor;
  8. import org.bukkit.command.CommandSender;
  9. import org.bukkit.entity.Player;
  10.  
  11. public  class CommandFly implements CommandExecutor {
  12.     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  13.         if (sender instanceof Player) {
  14.             Player player = (Player) sender;
  15.             if(cmd.getName().equalsIgnoreCase("fly")){
  16.                 if(player.hasPermission("crucial.fly")) {
  17.                     if(args.length == 0) {
  18.                         if(player.isFlying() == false) {
  19.                             player.setAllowFlight(true);
  20.                             player.setFlying(true);
  21.                         } else {
  22.                             player.setAllowFlight(false);
  23.                             player.setFlying(false);
  24.                         }
  25.                     } else if(args.length == 1){
  26.                         Player target = Bukkit.getServer().getPlayer(args[1]);
  27.                         if(target.isFlying() == false) {
  28.                             target.setFlying(true);
  29.                             target.setAllowFlight(true);
  30.                         } else {
  31.                             target.setFlying(false);
  32.                             target.setAllowFlight(false);
  33.                         }
  34.                     }
  35.                 } else {
  36.                     player.sendMessage(CrucialCommands.noPermission + "You do not have permission to do that.");
  37.                 }
  38.             }
  39.         } else {
  40.             sender.sendMessage("You must be a player to do this.");
  41.         }
  42.         return false;
  43.     }
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment