Where I failed?

Discussion in 'Spigot Plugin Development' started by Hangar555, May 25, 2016.

  1. What's wrong here?:
    Code (Text):
    package project.gui.test;


    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.enchantments.Enchantment;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.inventory.InventoryClickEvent;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.inventory.Inventory;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.meta.ItemMeta;
    import org.bukkit.plugin.Plugin;
    import org.bukkit.plugin.java.JavaPlugin;

    public class GUI extends JavaPlugin implements Listener {

        public void onEnable() {
            getServer().getPluginManager().registerEvents(this, this);
         
            public boolean onCommand(CommandSender sender, Command cmd, String label, String args[]) {
             Player player = (Player) sender;
             if(commandLabel.equalsignoreCase("SetStart")){
                 if(args.length == 0){
                     player.sendMessage(ChatColor.RED + "/setStart ");
                 } else {
                     Location location = player.getLocation();
                     if (!(StartCounter > 1)){
                         StartLocation[StartCounter] = location;
                         StartNames[StartCounter] args[0];
                         StartCounter++;
                         player.sendMessage(ChatColor.GREEN + "Start Set As: " + args [0]);
                     }else{
                         player.sendMessage (ChatColor.RED + "There Are Enough Starts, no more needed!");
                     }
                   }
         }else if(commandName.equalIgnoreCase("TeleStart")) {
             for (int i = 0; i < warpNames.lenght; i++) {
                 String warpName = warpName[i];
                 if  (args [0].equalsIgnoreCase(StartName)) {
                     Location warpLocation = warpLocation[i];
                     player.teleport(StartLocation);
                     player.sendMessage(ChatColor.DARK_GREEN + "teleported To " + StartName);
                     break;
                 }
             }
         }else if (commandLabel.equalignoreCase("SeeStarts"))
             String Starts = "";
             for (int i = 0; i < StartNames.lenght; i++){
                 if (i != warpNames.lenght){
                     warps += warpNames[i] + ",".reaplace("null","");
                 }else{
                     player.sendMessage(ChatColor.DARK_GRAY + "Showing The Starts:" + ChatColor.GRAY + starts);
                 }
             }
             }
        }
    }
           
       
     
    THANKS :D Please, don't be rude, I know I'm noob :p
     
  2. Does it shows any error or what is your mistake?
     
  3. ERRORS
    1st
    Code (Text):
    7 Syntax errors+ illegal modifier + invalid args: public boolean onCommand(CommandSender sender, Command cmd, String label, String args[]) {
    2nd
    Code (Text):
     Syntax error (AssignmentOperator expected) StartNames[StartCounter] args[0];
    3rd
    Code (Text):
    Syntax error (Identifier or new, insert ';' , "AssignmentOperator Expression" to complete Assignment):
    String Starts = "";
     
  4. @Hangar555 you put a method in another method
     
    • Agree Agree x 2
    • Winner Winner x 1
  5. You put onCommand() inside onEnable() (add a curly brace after you register you events).
     
    • Winner Winner x 1
  6. I would strongly recommend using an IDE like Eclipse. One of the benefits of programming in a strongly-typed language like Java is there are tools that tell you ahead of time about syntax errors.
     
    • Agree Agree x 3
  7. And syntax formatting, the code as it is now is near unreadble.
     
    • Agree Agree x 1
    • Winner Winner x 1
  8. So much...
     
    • Agree Agree x 1
  9. man !!! what you've done its messed around do some space to know what you're doing is clearly.
     
  10. Thanks :D