Solved Commands | SImple help needed!

Discussion in 'Plugin Development' started by legostarwarszach, Apr 30, 2013.

Thread Status:
Not open for further replies.
  1. Last edited by a moderator: Jun 1, 2016
  2. Offline

    kamakarzy

    Code:
       
     
        package me.zach.to;
       
        import java.util.logging.Logger;
       
        import org.bukkit.ChatColor;
        import org.bukkit.command.Command;
        import org.bukkit.command.CommandSender;
        import org.bukkit.entity.Player;
        import org.bukkit.plugin.PluginDescriptionFile;
        import org.bukkit.plugin.java.JavaPlugin;
       
        public class commands extends JavaPlugin{
                public final Logger logger = Logger.getLogger("Minecraft");
                public static commands plugin;
     
                @Override
                public void onDisable()  {
                        PluginDescriptionFile pdfFile = this.getDescription();
                        this.logger.info(pdfFile.getName() + "Disabled");     
                }
     
                @Override
                public void onEnable()  {
                        PluginDescriptionFile pdfFile = this.getDescription();
                        this.logger.info(pdfFile.getName() + " " + pdfFile.getVersion() + " Enabled");
                }
                public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] arges){
                        Player player = (Player) sender;
                        if(commandLabel.equalsIgnoreCase("telep")){
                                if(args.length==0){
                                        player.sendMessage(ChatColor.AQUA + "Teleporter V.Beta 1.0");
                                        player.sendMessage(ChatColor.AQUA + "Plugin made by: Zach Farley");
                                }else if(args.length == 1){
                                        player.sendMessage("It works!");
                                }else if(args.length>1){
                                        player.sendMessage(ChatColor.DARK_RED + "Too many arges!");
                                }
                                     
                        }
                        return false;
                     
                }
             
        }
     
    
     
  3. Offline

    kamakarzy

    are you using console to send the command
     
  4. Offline

    kamakarzy

    well try it with a player instead the command your using is getting the player and you cnt teleport a console can you​
     
    legostarwarszach likes this.
  5. Offline

    soulofw0lf

    if you do figure out how to teleport consoles i could use a new ps3 and 360...
     
  6. Offline

    kamakarzy

    np and i agree with soulofw0lf i could do with ps3 :)
     
  7. Offline

    MeZTech

    Code:
    package me.zach.to;
     
        import java.util.logging.Logger;
     
        import org.bukkit.ChatColor;
        import org.bukkit.command.Command;
        import org.bukkit.command.CommandSender;
        import org.bukkit.entity.Player;
        import org.bukkit.plugin.PluginDescriptionFile;
        import org.bukkit.plugin.java.JavaPlugin;
     
        public class commands extends JavaPlugin{
                public final Logger logger = Logger.getLogger("Minecraft");
                public static commands plugin;
     
                @Override
                public void onDisable()  {
                        PluginDescriptionFile pdfFile = this.getDescription();
                        this.logger.info(pdfFile.getName() + "Disabled");   
                }
     
                @Override
                public void onEnable()  {
                        PluginDescriptionFile pdfFile = this.getDescription();
                        this.logger.info(pdfFile.getName() + " " + pdfFile.getVersion() + " Enabled");
                }
                public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] arges){
                        Player player = (Player) sender;
                        if(commandLabel.equalsIgnoreCase("telep")){
                                if(args.length==0){
                                        player.sendMessage(ChatColor.AQUA + "Teleporter V.Beta 1.0");
                                        player.sendMessage(ChatColor.AQUA + "Plugin made by: Zach Farley");
                                }else if(args.length == 1){
                                        player.sendMessage("It works!");
                                        Player targetTeleportPlayer = getServer().getPlayer(args[0]);
                                        Location targetPlayerLocation = targetTeleportPlayer.getLocation();
                                        player.teleport(targetPlayerLocation); 
                                        //This teleports the player
                                }else if(args.length > 1){ //Has to be a space before and after the ">"
                                        player.sendMessage(ChatColor.DARK_RED + "Too many arges!");
                                }
                                   
                        }
                        return false;
                   
                }
           
        }
    For more information
     
Thread Status:
Not open for further replies.

Share This Page