Taking data from command

Discussion in 'Plugin Development' started by Rich Boos, Nov 28, 2012.

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

    Rich Boos

    Hello,

    I am trying to get the new version of MyWarp to allowing giving a warp to offline players. I have been doing some trial and error but wind up with null pointers.

    The source of the command is here:
    here https://github.com/TheE/MyWarp/blob.../taylorkelly/mywarp/commands/GiveCommand.java

    The actual command is
    /warp give richboos disneyworld

    I am thinking at line 33 if I could set Player givee to equal richboos, that the rest of the command would function. What I need help with is, how do I get the third "argument" of the above command (in this case, richboos) to be on the right side of the equals sign on line 33.

    Regards,

    RB
     
  2. Offline

    fireblast709

    if the player is not online, there is no Player object (so it always will be null). Also, to get that argument (which is the 2nd one btw) do args[1]
     
  3. Wanted to do a pull request helping, but as you use getLocation(), getWorld() and so on which isn't possible on a OfflinePlayer I stopped. But here's my start:
    Code:java
    1. OfflinePlayer givee = plugin.getServer().getPlayer(args[0]);
    2.  
    3. if (givee == null) {
    4. executor.sendMessage(LanguageManager.getString("error.playerOffline.give").replaceAll("%player%", args[0]));
    5. givee = plugin.getServer().getOfflinePlayer(args[0]);
    6. if(!givee.hasPlayedBefore())
    7. {
    8. executor.sendMessage(LanguageManager.getString("error.playerOffline.give").replaceAll("%player%", args[0]));
    9. return true;
    10. }
    11. }
     
    Rich Boos likes this.
  4. Offline

    Rich Boos

    Thank you guys.

    V10lator, I don't see getLocation and getWorld in the linked page. Would it cause even if it was in another class file?
     
  5. It seems like you give the Player (that you have to change to OfflinePlayer) to other classes. So yes, it will cause. I didn't check deeply enough to see if this is needed. After all it's your code so you know best.
     
  6. Offline

    Rich Boos

    Ha, oh my goodness this isn't my plugin. I couldn't program a java plugin outside of HelloWorld :p
     
Thread Status:
Not open for further replies.

Share This Page