Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.Envy.plugs;
- import org.bukkit.ChatColor;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- import org.bukkit.plugin.java.JavaPlugin;
- public class basics extends JavaPlugin{
- public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
- if(commandLabel.equalsIgnoreCase("fly")){
- if(sender instanceof Player){ // Check if the sender is a player
- if(args.length == 1){ // Check if argument on/off is given, length 1 means given
- Player player = (Player) sender; // Cast the sender to a player
- if(args[0].equalsIgnoreCase("on")){ // Check if first argument is on
- player.setAllowFlight(true); // Allow them to fly
- player.sendMessage(ChatColor.GREEN + "Fly enabled!");
- }else if(args[0].equalsIgnoreCase("off")){ // Check if first argument is off
- player.setAllowFlight(false); // Disallow them to fly
- player.sendMessage(ChatColor.GREEN + "Fly disabled!");
- }else{ // First argument incorrect
- sender.sendMessage(ChatColor.RED + "/fly <on/off>");
- }
- }else{ // Correct length not given
- sender.sendMessage(ChatColor.RED + "/fly <on/off>");
- }
- }else{
- sender.sendMessage(ChatColor.RED + "Only players can use that command."); // If not, tell them
- }
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement