Syntax error, insert "} " to complete ClassBody? Can't fix it! D:

Discussion in 'Plugin Development' started by NordisKFail, May 3, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    NordisKFail

    So i am programming a plugin for a server everything was going fine, no errors, until i got this:

    Syntax error, insert "} " to complete ClassBody

    at the bottom of the code, i will show you the code. (Yes, i am posting posts like this maybe all the time, but every post of mine is having it's own specific problem.)

    Code:
    package me.NordisKFail;
    
    import org.bukkit.Bukkit;
    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 GoliChat extends JavaPlugin implements JavaListener{
       
        public void onEnable() {
            getLogger().info(ChatColor.GRAY + "[" + ChatColor.DARK_AQUA + "GoliChat" + ChatColor.GRAY + "] " + ChatColor.YELLOW + "GoliChat er paa. :) (GoliChat av NordisKFail)");
        }
    
        public void onDisable() {
            getLogger().info(ChatColor.GRAY + "[" + ChatColor.DARK_AQUA + "GoliChat" + ChatColor.GRAY + "] " + ChatColor.YELLOW + "GoliChat stenger naa, hvis den ikke skulle det kontakt NordisKFail. :)");
        }
       
        public boolean onCommand (CommandSender sender, Command cmd, String label, String[] args) {
            Player player = (Player) sender;
            return true;
           
            if(cmd.getName().equalsIgnoreCase("cc")){
                if (player.hasPermission("eZChat.CC")) {
                   
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage(ChatColor.YELLOW + "Chatten din ble vasket opp");
                   
            }
           
            if(cmd.getName().equalsIgnoreCase("globalmute")){
                if(player.hasPermission("golichat.globalmute")) {
                   
                }
            }
                   
           
        }
       
    }
    
    Please don't post posts that doesen't have to do anything with the topic and don't say that i can't begin with coding yet before i have really studied "Java" for a long time. :)
     
  2. Offline

    mine-care

    @NordisKFail
    http://www.tutorialspoint.com/java/

    ---Optional---
    Class cast exception will be thrown once command is not ececuted by a player.
    Use a loop.
    Still that? where does that come from? does it work?
     
    Neonix likes this.
  3. Offline

    Neonix

    You can't code bukkit plugins if you don't know java. This is a java syntax error
    You're missing one bracket.

    Please learn java, as having a good understanding of brackets will help fix this error
     
    mine-care likes this.
  4. Offline

    NordisKFail

    *Ignoring that you said that i needed to learn more*

    And where would i put the "missing" bracket?
     
  5. Offline

    CoolGamerXD

    You must learn java before learning bukkit anyways, You must put return true at end of code whereas you have put it under onCommand. Following is a fixed code.


    Code:
     public void onEnable() {
               getLogger().info(ChatColor.GRAY + "[" + ChatColor.DARK_AQUA + "GoliChat" + ChatColor.GRAY + "] " + ChatColor.YELLOW + "GoliChat er paa. :) (GoliChat av NordisKFail)");
           }
        
           public void onDisable() {
               getLogger().info(ChatColor.GRAY + "[" + ChatColor.DARK_AQUA + "GoliChat" + ChatColor.GRAY + "] " + ChatColor.YELLOW + "GoliChat stenger naa, hvis den ikke skulle det kontakt NordisKFail. :)");
           }
        
           public boolean onCommand (CommandSender sender, Command cmd, String label, String[] args) {
               Player player = (Player) sender;
            
            
               if(cmd.getName().equalsIgnoreCase("cc")){
                   if (player.hasPermission("eZChat.CC")) {
                    
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage(ChatColor.YELLOW + "Chatten din ble vasket opp");
                    
               }
            
               if(cmd.getName().equalsIgnoreCase("globalmute")){
                   if(player.hasPermission("golichat.globalmute")) {
                    
                   }
               }
               }
                return true;
           }
    } 
     
  6. Offline

    bwfcwalshy Retired Staff

    @CoolGamerXD Best not to spoon feed people but it's good you didn't fix the rest of his code only his bracket.
     
    Last edited: May 3, 2015
    FisheyLP and mine-care like this.
  7. Offline

    mine-care

    @NordisKFail Okay ignore @Neonix or me, but do not wonder why people will ignore you afterwards. As i mentioned in your previus thread, but it wasnt clear obviusly, java is a Requierment for bukkit. Its like saying "i want to build a house without foundations" it will all be ok up untill a certain height where everything will colapse.
    So there are some key reasons why you SHOULD learn java before bukkit:
    1. to be able to understand what does what.
    2. to fix minor issues in an instant rather than have to wait for someone to solve it for you.
    3. to be able to add new features! (You have no idea how many features you can add even with the basic java knoledge)
    4. to make your code safe, relyable, readable, efficient ect.
    5. to save yourself time! your last question-thread took arround a day to be solved.
    6. to broaden your prospects! java is not just bukkit! its an awesome Object-Oriented language working on most well known operating systems.
    7. to be in a position to understand code and how it works!

    And lets consider that java is a fairly simple language especially the basics! for me personally it took arround a month to gain the basic knowledge and i am not the easyest learning person in the globe.
    Lastly we will be here to help with any problem you face along the way of learning java, What we wont be doing (or so i want to belive) is to give you the answer ready on a plate.
    ----

    @CoolGamerXD i don't think that spoonfeeding will help the op improve in any shape or form or pinpoint what is wrong and why. :3

    Heh nice one!
     
    Garnetty likes this.
  8. Offline

    FisheyLP

    I think there should be a simple quiz for java knowledge to register in this forum :p
     
    Neonix likes this.
  9. Offline

    NordisKFail

    And that does?
     
  10. Offline

    mine-care

    @FisheyLP Sounds nice but there is always the internet out there holding an answer for almost every question D:
     
  11. Offline

    BrickBoy55

    @mine-care The people that have extensive knowledge on java, could probably make that pretty easily.


    If this was a program...
     
  12. Offline

    mine-care

  13. Offline

    BrickBoy55

    @mine-care

    A quiz to test your programming knowledge.

    I think I tagged the wrong person.
     
  14. Offline

    FisheyLP

    Try it out :p
     
  15. Offline

    1Rogue Retired Staff

    Well that's nice, guess I can ignore helping on this thread
     
    Cirno, Garnetty, vhbob and 2 others like this.
  16. Offline

    NordisKFail

    It would be better if someone would help me with my question!
     
  17. Online

    timtower Moderator Moderator

    @NordisKFail You have a return in your code with code behind it, the code behind it will never run.
    And again: you aren't closing a certain if statement in your code, find it, close it.

    It is basic java and has nothing to do with Bukkit. Locked
     
    vhbob and 1Rogue like this.
Thread Status:
Not open for further replies.

Share This Page