jonassvensson4

Bukkit plugin /fly

Jul 6th, 2014
689
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.26 KB | None | 0 0
  1. package me.jonas.main;
  2.  
  3. import org.bukkit.ChatColor;
  4. import org.bukkit.command.Command;
  5. import org.bukkit.command.CommandSender;
  6. import org.bukkit.entity.Player;
  7. import org.bukkit.plugin.java.JavaPlugin;
  8.  
  9. public class fly extends JavaPlugin {
  10.    
  11.     @Override
  12.     public void onEnable() {
  13.         getLogger().info("Fly plugin has been Enabled");
  14.     }
  15.    
  16.     @Override
  17.     public void onDisable() {
  18.         getLogger().info("Fly plugin has been Disabled");
  19.     }
  20.    
  21.     public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
  22.         if (!(sender instanceof Player)) {
  23.             sender.sendMessage("Player command only");
  24.             return true;
  25.         }
  26.         Player player = (Player)sender;
  27.         // enable fly
  28.         if(commandLabel.equalsIgnoreCase("efly")) {
  29.             if(sender.hasPermission("fly.efly")) {
  30.             player.setAllowFlight(true);
  31.             player.sendMessage(ChatColor.GREEN + "Fly enabled");
  32.             }else{
  33.                 player.sendMessage(ChatColor.RED + "You dont have permission");
  34.             }
  35.         }
  36.         // disable fly
  37.         if(commandLabel.equalsIgnoreCase("dfly")) {
  38.             if(sender.hasPermission("fly.dfly")) {
  39.             player.setAllowFlight(false);
  40.             player.sendMessage(ChatColor.RED + "Fly Disabled");
  41.             }else{
  42.                 player.sendMessage(ChatColor.RED + "You dont have permission");
  43.             }
  44.         }
  45.         return true;
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment