Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Commands;
- import net.md_5.bungee.api.ChatColor;
- 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 Fly implements CommandExecutor {
- @Override
- public boolean onCommand(CommandSender sender, Command command, String label, String [] args){
- if (!(sender instanceof Player)) {
- sender.sendMessage("Only players can execute this command!");
- return true;
- }
- Player player = (Player) sender;
- if (args.length == 0) {
- Player target = Bukkit.getServer().getPlayer(args[0]);
- if (target.getAllowFlight()) {
- target.setAllowFlight(false);
- target.sendMessage(ChatColor.BOLD + "Flight is now " + ChatColor.RED + ChatColor.BOLD + "Disabled " + ChatColor.YELLOW + ChatColor.BOLD + "For " + args[0] + ".");
- return true;
- } else {
- target.setAllowFlight(true);
- target.sendMessage(ChatColor.YELLOW + "" + ChatColor.BOLD + "Flight is now" + ChatColor.GREEN + ChatColor.BOLD + " Enabled. " + ChatColor.YELLOW + ChatColor.BOLD + "For " + args[0] + ".");
- return true;
- }
- }
- else{
- if (player.getAllowFlight()) {
- player.setAllowFlight(false);
- player.sendMessage(ChatColor.YELLOW + "" + ChatColor.BOLD + "Flight is now" + ChatColor.RED + ChatColor.BOLD + " Disabled.");
- return true;
- }
- else {
- player.setAllowFlight(true);
- player.sendMessage(ChatColor.YELLOW + "" + ChatColor.BOLD + "Flight is now" + ChatColor.GREEN + ChatColor.BOLD + " Enabled.");
- return true;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement