Results 1 to 14 of 14
  1. #1
    Skater1024 is offline Member
    Join Date
    Nov 2015
    Posts
    7
    Rep Power
    0

    Default Please help me! Basic java coding error!

    Please help! I'm new to Java coding and I can't figure out this problem. Its a basic syntax error I think!


    package me.bukkit.Skater1024;

    import java.security.Permission;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.potion.PotionEffect;
    import org.bukkit.potion.PotionEffectType;

    public class BukkitPlugin extends JavaPlugin {

    public Permission playerPermission = (new Permission("NV.enable") {

    @Override
    public void onEnable() {
    getLogger().info("Plugin has been Enabled!");
    PluginManager pm = getServer().getPluginManager();
    pm.addPermission(playerPermission);

    }
    @Override
    public void onDisable() {
    getLogger().info("Plugin has been Disabled!");

    }

    public boolean onComand(CommandSender sender, Command cmd, String label, String[] args) {

    Player p = (Player)sender; {



    if (cmd.getName().equalsIgnoreCase("Nv") && sender instanceof Player) {
    if (p.hasPermission("NV.enable" || p.isOp())) {
    p.sendMessage("You Have Permission");
    } else
    {
    p.sendMessage(ChatColor.RED + "Invalid Permissions");
    }

    Player player = (Player) sender;

    player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION,120, 1 )); {
    }
    }

    return false;
    }
    }
    Last edited by Skater1024; 11-08-2015 at 01:44 AM.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: Please help me! Basic java coding error!

    Its a basic syntax error I think!
    Please copy the full text of the error message and paste it here. It has important info about the error.

    Please edit your post and wrap the code in code tags.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    Skater1024 is offline Member
    Join Date
    Nov 2015
    Posts
    7
    Rep Power
    0

    Default Re: Please help me! Basic java coding error!

    I couldn't get the code tags to work so here is the right format, you don't have to download if you don't want to(There is an online preview). http://www.mediafire.com/view/b2hd834rdwunli0/Code.txt
    The error was at the end like the 50 and 51. That bracket had the error, but I tried many different things, and even what the program said was the problem. You can put it in the program and see if you want. Here was the error: Syntax error, insert "}" to complete ClassBody, but when I insert "}" it says insert ";" to complete ClassBody declarations, and so on. I'm not sure if I even formatted the code properly, I just kinda fit it in with a tutorial because I don't know too much. Thanks!

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: Please help me! Basic java coding error!

    he error was at the end like the 50 and 51.
    Please copy full text of the compiler's error message and paste it here.
    The message should show the source with a ^ under the location of the error.
    Here is a sample from the javac compiler:
    Java Code:
    TestSorts.java:138: cannot find symbol
    symbol  : variable var
    location: class TestSorts
             var = 2;
             ^
    I couldn't get the code tags to work
    See BB Code List - Java Programming Forum - Learn Java Programming
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    Skater1024 is offline Member
    Join Date
    Nov 2015
    Posts
    7
    Rep Power
    0

    Default Re: Please help me! Basic java coding error!

    The thing is, its a file that runs in a minecraft server. It cannot be run by itself in the program so I cant get the output error message.

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: Please help me! Basic java coding error!

    Try compiling it with the javac compiler to get error messages that can be posted here.

    Otherwise try asking on a a minecraft server forum about how to compile programs with their product.
    If you don't understand my response, don't ignore it, ask a question.

  7. #7
    Skater1024 is offline Member
    Join Date
    Nov 2015
    Posts
    7
    Rep Power
    0

    Default Re: Please help me! Basic java coding error!

    I'm running it with eclipse and I can't fine the compile thing, I looked it up also. Can't find it. Would you know where to fine the compile setting?

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    27

    Default Re: Please help me! Basic java coding error!

    Eclipse highlights the error in red, and will list the errors in the errors tab, or if you hover over the red error symbol.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  9. #9
    Skater1024 is offline Member
    Join Date
    Nov 2015
    Posts
    7
    Rep Power
    0

    Default Re: Please help me! Basic java coding error!

    There we more problems than I thought :P

    Description Resource Path Location Type
    Project 'NewPlugin' is missing required library: 'C:\Users\Joey-and-Jono\Desktop\craftbukkit.jar' NewPlugin Build path Build Path Problem
    Syntax error on token "package", import expected TestPugin.java /Test Plugin/src/me/bukkit/Skater1024/TestPlugin line 3 Java Problem
    Syntax error, insert ";" to complete ClassBodyDeclarations BukkitPlugin.java /BukkitPlugin1.0/src/me/bukkit/Skater1024 line 53 Java Problem
    Syntax error, insert ")" to complete Expression BukkitPlugin.java /BukkitPlugin1.0/src/me/bukkit/Skater1024 line 53 Java Problem
    Syntax error, insert "}" to complete ClassBody BukkitPlugin.java /BukkitPlugin1.0/src/me/bukkit/Skater1024 line 53 Java Problem
    The project cannot be built until build path errors are resolved NewPlugin Unknown Java Problem
    The type Date is already defined DateAndTime.java /Date/src/Date line 6 Java Problem

  10. #10
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: Please help me! Basic java coding error!

    Those are not standard javac error messages. The program you are using needs to have some documentation on what the error messages mean.

    The error messages suggests some changes: "insert ";" to complete ClassBodyDeclarations BukkitPlugin.java /BukkitPlugin1.0/src/me/bukkit/Skater1024 line 53 "
    Did you try what it recommended?

    error on token "package", import expected
    Try commenting out the package statement
    Last edited by Norm; 11-09-2015 at 06:55 PM.
    If you don't understand my response, don't ignore it, ask a question.

  11. #11
    Skater1024 is offline Member
    Join Date
    Nov 2015
    Posts
    7
    Rep Power
    0

    Default Re: Please help me! Basic java coding error!

    I tried putting ; but than it says put ( than another ( and never ends :/ Not sure exactly what to do, I could probably start over but I would rather not do that.

  12. #12
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: Please help me! Basic java coding error!

    Try using the javac command to compile the code. It has good error messages. Do you have the jar file with the bukkit packages? Put it on the javac command's classpath (after the -cp option)
    Here is a sample commandline using the javac command with the -cp option.
    D:\Java\jdk1.7.0_45\bin\javac.exe -Xlint:all -cp .;jsoup-1.8.3.jar TestCode21.java

    Replace the path to the javac.exe file with the path on your PC


    I could probably start over
    Sometimes that is the only way. Your code is very short. You should enter a few lines and compile, fix the errors and add a few more, compile, fix, etc.
    The few lines always need to be sure to have matching {}s and ()s
    Last edited by Norm; 11-09-2015 at 07:52 PM.
    If you don't understand my response, don't ignore it, ask a question.

  13. #13
    Skater1024 is offline Member
    Join Date
    Nov 2015
    Posts
    7
    Rep Power
    0

    Default Re: Please help me! Basic java coding error!

    Are you too busy or could you give me any suggestions on how to make this the proper way?

  14. #14
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: Please help me! Basic java coding error!

    Try this; You should enter a few lines and compile, fix the errors and add a few more, compile, fix, etc.
    The few lines always need to be sure to have matching {}s and ()s
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. New to JAVA, and coding error
    By -Lucius- in forum New To Java
    Replies: 2
    Last Post: 11-09-2012, 12:49 PM
  2. Basic Java coding help needed
    By sungju1203 in forum New To Java
    Replies: 2
    Last Post: 05-07-2012, 11:52 AM
  3. A newbie to Java needing help on coding error
    By Turo in forum New To Java
    Replies: 5
    Last Post: 08-28-2011, 05:11 AM
  4. Compilation Error in basic java class
    By ruchir123 in forum New To Java
    Replies: 7
    Last Post: 11-21-2010, 11:23 PM
  5. Basic Java applet error, cant figure it out!
    By alacn in forum Java Applets
    Replies: 3
    Last Post: 08-03-2010, 06:25 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •