1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Solved Cancel Damage in a single World

Discussion in 'Development' started by driver1848, May 4, 2020.

  1. driver1848

    driver1848 Spider Jockey

    Messages:
    35
    GitHub:
    driver1848
    Hi,
    im developing a plugin for my hub on my server, wich disable any Damage, but it dont disable the dmg only in one world, rather in all worlds... Id tried this...
    PHP:
    //NoDMG
        
    public function NoDMG(EntityDamageEvent $event){
            if(
    $this->getServer()->getLevelByName("HUB")){
                
    $event->setCancelled();
            }
        }
    This cancel the DMG in all Worlds at my Server... Edit: Cause tht check if the lvl exist
    Is tht right?
    PHP:
    //NoDMG
        
    public function NoDMG(EntityDamageEvent $event){
            
    $p $event->getEntity();
            
    $lvl $this->getServer()->getLevelByName("HUB");
            if (
    $p->getLevel($lvl)){
                
    $event->setCancelled();
            }
        }
    I dont tried it, but i think tht make no sense... (idk why)
    Or does a PlayerDamageEvent exist?

    Thx for Help!
     
    Last edited: May 4, 2020
  2. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    You need to compare the player's level to the level you want, please learn the basics of programming before writing a plugin.

    PHP:
    if ($p->getLevel()->getFolderName() === "blah") {
    // do stuff
    }
     
  3. driver1848

    driver1848 Spider Jockey

    Messages:
    35
    GitHub:
    driver1848
    thx
     
    HimbeersaftLP likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.