Annoying Snyntax Error?

Discussion in 'Plugin Development' started by Veritas, Dec 22, 2014.

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

    Veritas

    Ok I have a syntax error in my code so my code is
    Code:
    package me.Veritas;
    
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.potion.PotionEffect;
    import org.bukkit.potion.PotionEffectType;
    
    public class Main extends JavaPlugin {
        
        @Override
        public void onEnable() {
            getLogger().info("Plugin Enabled");
        }
       
       
       
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
           
           
                   
                    {
                
            }
            if (cmd.getName().equalsIgnoreCase("Invincible") && sender instanceof Player) {
           
                Player player = (Player) sender;
                if(player.hasPermission("Invincible.use")){
    
            player.sendMessage("You are now Invincible");
            player.getWorld().strikeLightning(player.getLocation());
            player.setHealth(20F); player.setFoodLevel(20); player.setFireTicks(0);player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 999999, 50));
            player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 999999, 999));player.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, 999999, 999));
            player.addPotionEffect(new PotionEffect(PotionEffectType.WATER_BREATHING, 999999, 999));player.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 999999, 999));
            player.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, 999999, 999));player.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION, 999999, 999));
            player.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, 999999, 50)); player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 999999, 999));
            player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 999999, 999));player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 999999, 10));
            player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 999999, 999));player.addPotionEffect(new PotionEffect(PotionEffectType.SATURATION, 999999, 999));
           
           
            if (cmd.getName().equalsIgnoreCase("Human"))
                for(PotionEffect effect : player.getActivePotionEffects())
                    {
                    player.removePotionEffect(effect.getType());}
            player.sendMessage("You Are Now Human!");
                player.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 120, 50));
                ((Player) player).setFireTicks(80);
            return true;
            }
            return false;
            }
       
        @Override
        public void onDisable() {
            getLogger().info("Plugin Disabled");
        }
    }
    so my error is in the
    return true;
    }
    return false;
    }
    The semicolon after return false is underlined how do I get rid of that snytax error?
     
  2. Offline

    WesJD

    @Veritas
    Your if statements aren't even in the block. Please learn Java before working with the Bukkit API.
     
    Last edited: Dec 23, 2014
  3. Offline

    mythbusterma

    @Veritas

    Well first off, formatting your code correctly is exactly how you avoid this kind of issue. You might want to try that. Second off, this a Bukkit help forum, not a Java help forum. You should post your issue on a Java help forum.
     
  4. Offline

    Skionz

    Looks like a failed attempt at copy and pasting to me.
     
    Avygeil, es359, TGRHavoc and 5 others like this.
  5. Offline

    Funergy

    Skionz likes this.
  6. Offline

    Veritas

    @mythbusterma sorry thought I was in Java help forum. (Or whatever it's called) @Skionz I made this myself except for 1 line all I copied
    Code:
    if(player.hasPermission("Invincible.use")){
    That's what made the syntax error. @WesJD yes I still have very very much to learn I mean I just started about a week ago I just. I'm still looking at tutorials I just made it as a "test" plugin
     
  7. Offline

    _Filip

  8. Offline

    Skionz

    @Veritas So you wrote all of that outside the brackets and just ignored the lines of red on your screen? (Assuming you using a decent IDE) That would annoy the shit out of me xD
     
  9. Offline

    Veritas

    @Skionz Yeah I used eclipse and there were no erros
     
  10. Offline

    WesJD

    @Veritas There would be a lot of errors...
     
  11. Offline

    Rocoty

    What constructor?

    Actually, all the code looks to be properly inside methods to me. (The stray brackets at lines 23 and 25 may have confused you?)

    As stated by others. Indent and format your code correctly and the cause of your problems should be obvious. That is, assuming you have a basic understanding of programming. (You're missing a bracket.)
     
    Veritas and es359 like this.
  12. Offline

    Skionz

    @Rocoty Jesus I think your right, but what is up with these two random/pointless brackets?
    Code:
    {
              
            }
     
  13. Offline

    Rocoty

    @Skionz They do indeed look like the result of an attempt at copying and pasting fragments of code. Either that, or the developer lost track on what they were doing.
     
    Skionz likes this.
  14. Offline

    Veritas

    @Rocoty @Skionz as I said I made this for a test plugin. This is my 1st plugin and I've only took a few tutorials. So there's probably a ton of things wrong with that code
    EDIT: @Skionz I'm as confused as you now why I put those two brackets there...
     
  15. Offline

    nverdier

    Don't use Bukkit before you know how to use Java! Learn Java first!
     
  16. Offline

    Veritas

    @nverdier I've already known some Java prior to learning bukkit but I guess I should learn a lot more Java then...
     
  17. Offline

    timtower Administrator Administrator Moderator

    @Veritas In eclipse: ctrl-a, ctrl-i
    Makes it very easy to spot missing brackets.
     
Thread Status:
Not open for further replies.

Share This Page