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

Error in my plugin?!?

Comments in 'Plugin Development' started by JackboyPlay, Feb 17, 2016.

  1. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    PHP:
    public function onSchaden(EntityDamageEvent $event){
    $conf $this->getConfig();
    if(
    $event->getCause() == && $conf->get("FallDMG") == 0){
    $event->setCancelled();
    }
    if(
    $event->getCause() == && $conf->get("WallDMG") == 0){
    $event->setCancelled();
    }
    if(
    $event->getCause() == && $conf->get("LavaDMG") == 0){
    $event->setCancelled();
    }
    if(
    $event->getCause() == && $conf->get("DrownDMG") == 0){
    $event->setCancelled();
    }
    if(
    $event->getCause() == && $conf->get("FireDMG") == || $event->getCause() == && $conf->get("FireDMG") == 0){
    $event->setCancelled();
    }
    if(
    $event->getCause() == 11 && $conf->get("VoidDMG") == 0){
    $event->setCancelled();
    }
    }
    BUt it cancells all Events like the cactus damage and if in the config get VoidDMG = 1 the Player don't get damage on Void the same with the anothers
  2. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    This is because you're cancelling EntityDamageEvent, not the cause.
    Last edited: Feb 18, 2016
  3. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    whats $cause?
  4. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    @AndrewBit can you send me a corrected Version of the Code i dont know where I must place it
  5. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Took some code from my project:
    Code aus meinem Projekt:

    PHP:
    public function onDamage(EntityDamageEvent $event){
    if(
    $event instanceof EntityDamageByEntityEvent){
    if(
    $event->getCause() == EntityDamageByEntityEvent::CAUSE_FALL){
    $event->setCancelled();
    }}}
  6. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    PHP:
    public function onSchaden(EntityDamageEvent $event){
    $conf $this->getConfig();
    if(
    $event->getCause() == EntityDamageByEntityEvent::CAUSE_FALL && $conf->get("FallDMG") == 0){
    $event->setCancelled();
    }
    if(
    $event->getCause() == EntityDamageByEntityEvent::CAUSE_SUFFOCATION && $conf->get("WallDMG") == 0){
    $event->setCancelled();
    }
    if(
    $event->getCause() == EntityDamageByEntityEvent::CAUSE_LAVA && $conf->get("LavaDMG") == 0){
    $event->setCancelled();
    }
    if(
    $event->getCause() == EntityDamageByEntityEvent::CAUSE_DROWNING && $conf->get("DrownDMG") == 0){
    $event->setCancelled();
    }
    if(
    $event->getCause() == EntityDamageByEntityEvent::CAUSE_FIRE && $conf->get("FireDMG") == || $event->getCause() == EntityDamageByEntityEvent::CAUSE_FIRE_TICK && $conf->get("FireDMG") == 0){
    $event->setCancelled();
    }
    if(
    $event->getCause() == EntityDamageByEntityEvent::CAUSE_VOID && $conf->get("VoidDMG") == 0){
    $event->setCancelled();
    }
    }
    Doesnt work...
    Funktioniert nicht...
    @MyNameIsTriXz @AndrewBit
  7. PauloErmittelt
    Offline

    PauloErmittelt New Member

    Joined:
    Oct 23, 2015
    Posts:
    1
    Minecraft User:
    Paulo
    was bekommst du den für ne Fehlermeldung angezeigt
  8. musaichi
    Offline

    musaichi New Member

    Joined:
    Mar 2, 2015
    Posts:
    33
    Minecraft User:
    musaichi
    try to use it.
    PHP:
    function onDamage(EntityDamageEvent $e){
     
    $c $this->getConfig();
     if(
    $e instanceof EntityDamageByEntityEvent){
      if(
    $e->getCause() === EntityDamageByEntityEvent::CAUSE_FALL && $c->get("FallDMG") === 0){
       
    $e->setCancelled();
      }
     }
    }
    PEMapModder and thebigsmileXD like this.
  9. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    $event->getCause()
  10. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    What?
    1. EntityDamageByEntityEvent is a class name reference. You can't assign a variable with it.
    2. $event->getCause() is an int, not an object. https://github.com/PocketMine/Pocke...etmine/event/entity/EntityDamageEvent.php#L90

    Please avoid posting wrong answers if you are not sure on the topic.
    PocketKiller and Vaivez66 like this.
  11. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    Yes I've made it so but forgot to send it here but i doesnt work...
    @PauloErmittelt No it givent any Errors in the log
    German: Nein es gibt keine Fehler die mir Angezeigt werden!
  12. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Not you... you are a pathetic griefer
  13. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    You haven't even posted an actual solution ;)

    This looks good.
  14. amiremad
    Offline

    amiremad Active Member

    Joined:
    Sep 8, 2015
    Posts:
    192
    Minecraft User:
    amir107
    english please
  15. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    Everything needed was translated. Anyways: What error do you get

Share This Page

Advertisement