Can't Fix this Internal Error...

Discussion in 'Plugin Development' started by shadrxninga, Apr 24, 2011.

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

    shadrxninga

    I made a simple messaging plugin. It worked perfectly. But I wanted to add a feature so if the player you were messaging wasn't online it would say "Sorry <Player> is not Online"

    It now sends a Message if the Player is Online and If a Player is no online it gives an Internal Error...


    Here is the code

    Code:
    public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
            Player player = (Player)sender;
    
            if (cmd.getName().equalsIgnoreCase("msg")){
    
                int i = 0;
                String text = "";
                for (String str : args){
                if (i >=1){
                    text += " " + str;
                    }
                i += 1;
    
                }
                String p = args[0];
                Player R = this.getServer().getPlayer(p);
    
            if(!R.isOnline()){
                getServer().broadcastMessage("Sorry" + p + "Is Not Online");
            }else{
                    R.sendMessage("[MSG]" + text);}
                }
    
            return false;
    
        }
    }
    Why is this?

    Thanks.
     
  2. Offline

    Trucaur

  3. Offline

    Carnes

    My first guess..
    Code:
    Player R = this.getServer().getPlayer(p);
    R could be null if the player doesn't exist, right? Check to make sure R isn't null before you do an R.isOnline()

    EDIT: Ninja'd by @Trucaur : )
     
Thread Status:
Not open for further replies.

Share This Page