Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Issues with my IDE(phpStorm) not automatically finding/suggesting methods

Comments in 'Plugin Development' started by args, Jun 17, 2014.

  1. args
    Offline

    args New Member

    Joined:
    Jun 14, 2014
    Posts:
    47
    Minecraft User:
    args
    Hey all,
    So I've been Developing for the last week with PHPStorm and the new API.

    When I start writing some methods, PHPStorm suggests some options that pocketmine offers.

    For example:
    autocomplete.png

    You can see it gives me about 11 options so that I can code faster, or see what things I am able to do.

    But there are some things missing. Like If i want to get the players X location, or their health, or ID, or get their inventory or an item, etc...

    But if I get a function from the Docs like this:
    playerX.png

    Even though there was no option to get X in the suggestions, the code still works and I can get X to display.
    But as you can see "X" is highlighted with a warning. Mouse over the warning reads "Field x not found in class pocketmine\command\commanSender"

    I'm wondering, why this is... Did i set up my External libraries incorrectly? or are they simply not even supposed to show up?... I ask because in Java it gives all the options and it makes coding a lot faster and simpler, And I'd really like to be able to see them in PHPStorm.

    Regards, Args
    thanks for reading :)
  2. iJoshuaHD
    Offline

    iJoshuaHD Notable Member Plugin Developer

    Joined:
    Nov 7, 2013
    Posts:
    1,196
    Plugins:
    4
    Minecraft User:
    iJoshuaHD
    where did you get the PocketMine IDE?
  3. args
    Offline

    args New Member

    Joined:
    Jun 14, 2014
    Posts:
    47
    Minecraft User:
    args
    I got the libraries from here: https://github.com/PocketMine/PocketMine-MP
    I downloaded the zip, extracted it and then added the folder to the external libraries section of PHPstorm
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Did you add a check if $sender is instance of Player? Because ConsoleCommandSender doesn't have x
  5. shoghicp
    Offline

    shoghicp Staff Member PocketMine Team

    Joined:
    Aug 22, 2013
    Posts:
    433
    Plugins:
    14
    Minecraft User:
    shoghicp
    CommandSender is not a Player. You can get command senders that are not players (like the console or RCon). To get proper hints and fix any errors that code can cause, use:

    PHP:
    if($sender instanceof Player){ //PhpStorm will autocomplete Player inside this if
    //Your code where $sender is a player
    }
    Falk, Comedyman937 and PEMapModder like this.
  6. args
    Offline

    args New Member

    Joined:
    Jun 14, 2014
    Posts:
    47
    Minecraft User:
    args
    Oh wow, So many options now :D thanks shoghicp and PeMapModder :p
    PEMapModder likes this.

Share This Page

Advertisement