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

Define an event in a world?

Discussion in 'Development' started by MrGalletaYTPM, Jan 20, 2020.

  1. MrGalletaYTPM

    MrGalletaYTPM Spider

    Messages:
    9
    Hi, I want to make the event I am using only work in a certain world that I choose and not in all worlds can you help me?

    public function onEnable(){
    $this->getLogger()->info("ComboFFA - activated!");
    @mkdir($this->getDataFolder());
    $this->saveDefaultConfig();
    $this->getResource("config.yml"); $this->getServer()->getPluginManager()->registerEvents($this,$this);
    }

    public function onHit(EntityDamageByEntityEvent $event){
    $entity = $event->getEntity();
    $damager = $event->getDamager();
    if($entity instanceof Player && $damager instanceof Player){
    $event->setAttackCooldown(0);
    }
    }
    return false;

    public function onDeath(PlayerDeathEvent $event) {
    $player = $event->getPlayer();
    $name = $player->getName();
    $entity = $event->getEntity();
    if($entity instanceof Player){
    $event->setDrops([]);
    }
    }
     
  2. Provsnoobgaming

    Provsnoobgaming Baby Zombie

    Messages:
    134
    GitHub:
    provsalt
    if ($player->getLevel === $this->getServer()->getLevelByName($world)){
    //Do something
    }
     
  3. MrGalletaYTPM

    MrGalletaYTPM Spider

    Messages:
    9
    Will you go under the event?

    public function onHit(EntityDamageByEntityEvent $event){
    $entity = $event->getEntity();
    $damager = $event->getDamager();
    if($entity instanceof Player && $damager instanceof Player){
    $event->setAttackCooldown(0);
    if ($player->getLevel === $this->getServer()->getLevelByName($world)){
    //Do something
    }
    }
    }
     
  4. Provsnoobgaming

    Provsnoobgaming Baby Zombie

    Messages:
    134
    GitHub:
    provsalt
    public function onHit(EntityDamageByEntityEvent $event){
    $entity = $event->getEntity();
    $damager = $event->getDamager();
    if($entity instanceof Player && $damager instanceof Player){
    $event->setAttackCooldown(0);
    if ($player->getLevel() === $this->getServer()->getLevelByName($world)){
    //Do something
    }
    }
    }
    :spoonfed:
     
    HimbeersaftLP likes this.
  5. MrGalletaYTPM

    MrGalletaYTPM Spider

    Messages:
    9
    Excuse me what it means :spoonfed: ?
     
    HimbeersaftLP likes this.
  6. Provsnoobgaming

    Provsnoobgaming Baby Zombie

    Messages:
    134
    GitHub:
    provsalt
    Meaning you had to be treated like a baby and me holding the spoon into your mouth
     
    HimbeersaftLP likes this.
  7. MrGalletaYTPM

    MrGalletaYTPM Spider

    Messages:
    9
    the code on the $ player variable gave me an error
     
  8. Provsnoobgaming

    Provsnoobgaming Baby Zombie

    Messages:
    134
    GitHub:
    provsalt
    duh since you didnt define it.
     
  9. MrGalletaYTPM

    MrGalletaYTPM Spider

    Messages:
    9
    Yand how do I define it so that only in that world that I choose to execute that event and not in all the worlds?
     
  10. Provsnoobgaming

    Provsnoobgaming Baby Zombie

    Messages:
    134
    GitHub:
    provsalt
    Quit joking.I already gave you the full code and no im not going to help anymore.
     
  11. MrGalletaYTPM

    MrGalletaYTPM Spider

    Messages:
    9
    Thanks for helping me, I didn't think you were a delicate person, your help is appreciated, regards
     
  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.