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

Correct Code?

Comments in 'Plugin Development' started by M4nt0s, Aug 21, 2016.

  1. M4nt0s
    Offline

    M4nt0s Active Member

    Joined:
    Sep 15, 2015
    Posts:
    49
    Minecraft User:
    M4nt0s
    <?php
    namespace ASETeleport;

    use pocketmine\plugin\PluginBase;
    use pocketmine\utils\TextFormat;
    use pocketmine\Player;
    use pocketmine\command\CommandSender;
    use pocketmine\command\Command;
    use pocketmine\event\entity\ProjectileHitEvent;
    use pocketmine\event\Listener;
    use pocketmine\event\player\PlayerChatEvent;
    use pocketmine\event\player\PlayerInteractEvent;

    class Main extends PluginBase implements Listener

    {

    public function onEnable(){
    $this->getLogger()->info("Das Plugin ASETeleport läuft ohne Probleme!");
    }

    public function onDisable(){
    $this->getLogger()->info("Das Plugin ASETeleport hat wohl einen Fehler!");
    }

    public function onTeleport(ProjectileHitEvent $event){
    $arrow = $event->getEntity();
    if($arrow instanceof Arrow){
    foreach($arrow->getViewers() as $player){
    if($player instanceof Player){
    $player->teleport(new Position($arrow->getX(), $arrow->getY(), $arrow->getZ()));
    $player->sendMessage(TextFormat::GREEN."Deine Position wurde verändert");
    }
    }
    }
    }
    }
    ?>
  2. JonsMC
    Offline

    JonsMC Active Member

    Joined:
    Jul 26, 2016
    Posts:
    107
    Minecraft User:
    JonsMC
    Why don't you test it :)
  3. JonsMC
    Offline

    JonsMC Active Member

    Joined:
    Jul 26, 2016
    Posts:
    107
    Minecraft User:
    JonsMC
    By the way, in Pocketmine plugins, we dont use ?> so dont add it
    - quote from PEMapModder
  4. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    You have to register the events in onEnable().
    PHP:
    $this->getServer()->getPluginManager()->registerEvents($this$this);
    Muqsit and MikkiMCPE like this.
  5. M4nt0s
    Offline

    M4nt0s Active Member

    Joined:
    Sep 15, 2015
    Posts:
    49
    Minecraft User:
    M4nt0s
    I test. There is not Error in Console!
  6. M4nt0s
    Offline

    M4nt0s Active Member

    Joined:
    Sep 15, 2015
    Posts:
    49
    Minecraft User:
    M4nt0s
    Where I have to place it? Sry im beginner.
  7. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    PluginBase::eek:nEnable()
  8. M4nt0s
    Offline

    M4nt0s Active Member

    Joined:
    Sep 15, 2015
    Posts:
    49
    Minecraft User:
    M4nt0s
    Where is there a PluginBase?
  9. ankitmaharjan252
    Offline

    ankitmaharjan252 New Member

    Joined:
    Mar 17, 2015
    Posts:
    5
    Minecraft User:
    AnkitM252
    Put it on here:
    public function onEnable(){
  10. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Your plugin is PluginBase
  11. MikkiMCPE
    Offline

    MikkiMCPE Active Member

    Joined:
    May 16, 2015
    Posts:
    125
    Minecraft User:
    MikkiMC
    may there is no error message on console, but your event function may not working before you add registerEvents()
    JonsMC likes this.
  12. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    "... in onEnable()"
  13. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Also, since I speak German:
    PHP:
    public function onDisable(){
    $this->getLogger()->info("Das Plugin ASETeleport hat wohl einen Fehler!");
    }
    You're saying that it has got an error here, but this is called when the server stops, not when the plugin has got an error.
  14. M4nt0s
    Offline

    M4nt0s Active Member

    Joined:
    Sep 15, 2015
    Posts:
    49
    Minecraft User:
    M4nt0s
    Oh...fail
  15. M4nt0s
    Offline

    M4nt0s Active Member

    Joined:
    Sep 15, 2015
    Posts:
    49
    Minecraft User:
    M4nt0s
    Is this now right? Line 17-19.

    Attached Files:

  16. PaulchenHD
    Offline

    PaulchenHD Active Member

    Joined:
    Jan 17, 2016
    Posts:
    111
    Minecraft User:
    Paulchen_HD
    yeah
  17. M4nt0s
    Offline

    M4nt0s Active Member

    Joined:
    Sep 15, 2015
    Posts:
    49
    Minecraft User:
    M4nt0s
    It do not work

    Es klappt trotzdem net
  18. M4nt0s
    Offline

    M4nt0s Active Member

    Joined:
    Sep 15, 2015
    Posts:
    49
    Minecraft User:
    M4nt0s
    it wont work

    Es klappt aber net
  19. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    And please do not develop plugins on mobile/small viewports. You need some oversight. Cropped lines are the root of many mistakes.
  20. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Off-topic: make font smaller and turn phone horizontally ;)

    I developed many plugins on phone when I didn't had this laptop yet.
    PaulchenHD and M4nt0s like this.

Share This Page

Advertisement