staff chat "IF" Problem

Discussion in 'Plugin Development' started by Felixbakkum, Feb 7, 2015.

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

    Felixbakkum

    Code:
    package me.felixbakkum.staffchat;
    
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    
    public class CommandListener implements CommandExecutor{
      
        public Main plugin;
        private Player sender;
      
        public CommandListener(Main instance){
            plugin = instance;
        }
      
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
            if (!(sender instanceof Player))
                sender.sendMessage("§cOnly players can toggle staffchat!");
            return true;
        }   
         Player p = (Player) sender;
        if plugin.getConfig().getString(p.getName() + ".stafchat").equalsIgnoreCase("true")){
             p.sendMessage("§6Staff Chat Disable");
        }
        return true;
      
        }
       
    
    }
    
      
    
    
    Hmmm the "if" think dosen't work
     
  2. Offline

    SuperOriginal

    Your instanceof block has a closing bracket but no opening bracket.
     
    GrandmaJam likes this.
  3. Offline

    Felixbakkum

    What do you mean explain better pl0x
     
  4. Offline

    ZanderMan9

    @Felixbakkum Are you used to programming in something like Python? If that's the case you're going to have to get used to java's very strict syntax. We don't use indentation to indicate blocks, we explicitly state them with {}. (But convention does say to indent things, which you aren't doing correctly in many places)
    Code:
    if (condition)
    {
       // do things
    }
     
  5. Offline

    Felixbakkum

    I'm coding plugins dude
     
  6. Offline

    ZanderMan9

    @Felixbakkum
    I said "used to". The way you indented without braces looked like someone who had gotten used to Python.
     
  7. Offline

    SuperOriginal

    I'm not sure how I can explain the problem any easier
     
  8. Offline

    Felixbakkum

    I did pm you
     
  9. Offline

    Rocoty

    You could start with learning how the Java syntax works...
     
    flash1110 and GrandmaJam like this.
  10. Offline

    SuperOriginal

    Keep discussion here.
     
  11. Offline

    Felixbakkum

    Add me on skype
     
  12. Offline

    SuperOriginal

    ...
     
  13. Offline

    Felixbakkum

    I did pm you my skype
     
  14. Offline

    teej107

    @Felixbakkum
    The entire part isn't in a method.
     
  15. Offline

    Evaluations

    if (), not if )

    Why are you using files to handle something that can easily and way more efficiently be done with an ArrayList or something?
     
  16. Offline

    BagduFagdu

    1. if(plugin.getConfig().getString(p.getName() + ".stafchat").equalsIgnoreCase("true")) {
    2. p.sendMessage("§6Staff Chat Disable");
    3. }
     
    GrandmaJam likes this.
Thread Status:
Not open for further replies.

Share This Page