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

Per area effect

Comments in 'Plugin Development' started by dxm_hippie, Sep 19, 2015.

  1. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    That explains... Why didn't you say you were editing iProtector and not making a new plugin?
  2. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    IT is on the main that does implement listener..like i said it does work but only for the last area i make with the plugin i used the messages to make sure it was getting all the information right for the effect and it does for multiple areas. Witch has got meh stumped.
  3. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    Just show all the code... This is ridiculous
  4. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    main.php

    PHP:
    <?php

    namespace LDX\iProtector;

    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandExecutor;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\Player;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\utils\TextFormat;
    use 
    pocketmine\utils\Config;
    use 
    pocketmine\event\entity\EntityDamageEvent;
    use 
    pocketmine\event\player\PlayerInteractEvent;
    use 
    pocketmine\event\block\BlockPlaceEvent;
    use 
    pocketmine\event\block\BlockBreakEvent;
    use 
    pocketmine\event\player\PlayerMoveEvent;
    use 
    pocketmine\entity\InstantEffect;
    use 
    pocketmine\entity\Effect;

    class 
    Main extends PluginBase implements Listener {

      public function 
    onEnable() {
        
    $this->getServer()->getPluginManager()->registerEvents($this,$this);
        if(!
    is_dir($this->getDataFolder())) {
          
    mkdir($this->getDataFolder());
        }
        if(!
    file_exists($this->getDataFolder() . "areas.json")) {
          
    file_put_contents($this->getDataFolder() . "areas.json","[]");
        }
        if(!
    file_exists($this->getDataFolder() . "config.yml")) {
          
    $c $this->getResource("config.yml");
          
    $o stream_get_contents($c);
          
    fclose($c);
          
    file_put_contents($this->getDataFolder() . "config.yml",str_replace("DEFAULT",$this->getServer()->getDefaultLevel()->getName(),$o));
        }
        
    $this->areas = array();
        
    $data json_decode(file_get_contents($this->getDataFolder() . "areas.json"),true);
        foreach(
    $data as $datum) {
          
    $area = new Area($datum["name"],$datum["flags"],$datum["pos1"],$datum["pos2"],$datum["level"],$datum["whitelist"],$this);
        }
        
    $c yaml_parse(file_get_contents($this->getDataFolder() . "config.yml"));
        
    $this->config = new Config($this->getDataFolder()."config.yml"Config::YAML, array());
        
    $this->god $c["Default"]["God"];
        
    $this->edit $c["Default"]["Edit"];
        
    $this->touch $c["Default"]["Touch"];
        
    $this->levels = array();
        foreach(
    $c["Worlds"] as $level => $flags) {
          
    $this->levels[$level] = $flags;
        }
      }

      public function 
    onCommand(CommandSender $p,Command $cmd,$label,array $args) {
        if(!(
    $p instanceof Player)) {
          
    $p->sendMessage(TextFormat::RED "Command must be used in-game.");
          return 
    true;
        }
        if(!isset(
    $args[0])) {
          return 
    false;
        }
        
    $n strtolower($p->getName());
        
    $action strtolower($args[0]);
        switch(
    $action) {
          case 
    "pos1":
            if(
    $p->hasPermission("iprotector") || $p->hasPermission("iprotector.command") || $p->hasPermission("iprotector.command.area") || $p->hasPermission("iprotector.command.area.pos1")) {
              if(isset(
    $this->sel1[$n]) || isset($this->sel2[$n])) {
                
    $o "You're already selecting a position!";
              } else {
                
    $this->sel1[$n] = true;
                
    $o "Please place or break the first position.";
              }
            } else {
              
    $o "You do not have permission to use this subcommand.";
            }
          break;
          case 
    "pos2":
            if(
    $p->hasPermission("iprotector") || $p->hasPermission("iprotector.command") || $p->hasPermission("iprotector.command.area") || $p->hasPermission("iprotector.command.area.pos2")) {
              if(isset(
    $this->sel1[$n]) || isset($this->sel2[$n])) {
                
    $o "You're already selecting a position!";
              } else {
                
    $this->sel2[$n] = true;
                
    $o "Please place or break the second position.";
              }
            } else {
              
    $o "You do not have permission to use this subcommand.";
            }
          break;
          case 
    "create":
            if(
    $p->hasPermission("iprotector") || $p->hasPermission("iprotector.command") || $p->hasPermission("iprotector.command.area") || $p->hasPermission("iprotector.command.area.create")) {
              if(isset(
    $args[1])) {
                if(isset(
    $this->pos1[$n]) && isset($this->pos2[$n])) {
                  if(!isset(
    $this->areas[strtolower($args[1])])) {
                    
    $area = new Area(strtolower($args[1]),array("edit" => true,"god" => false,"touch" => true),array($this->pos1[$n]->getX(),$this->pos1[$n]->getY(),$this->pos1[$n]->getZ()),array($this->pos2[$n]->getX(),$this->pos2[$n]->getY(),$this->pos2[$n]->getZ()),$p->getLevel()->getName(),array($n),$this);
                    
    $this->saveAreas();
                    unset(
    $this->pos1[$n]);
                    unset(
    $this->pos2[$n]);
                    
    $o "Area created!";
                  } else {
                    
    $o "An area with that name already exists.";
                  }
                } else {
                  
    $o "Please select both positions first.";
                }
              } else {
                
    $o "Please specify a name for this area.";
              }
            } else {
              
    $o "You do not have permission to use this subcommand.";
            }
          break;
          case 
    "list":
            if(
    $p->hasPermission("iprotector") || $p->hasPermission("iprotector.command") || $p->hasPermission("iprotector.command.area") || $p->hasPermission("iprotector.command.area.list")) {
              
    $o "Areas:";
              foreach(
    $this->areas as $area) {
                
    $o $o " " $area->getName() . ";";
              }
            }
          break;
          case 
    "flag":
            if(
    $p->hasPermission("iprotector") || $p->hasPermission("iprotector.command") || $p->hasPermission("iprotector.command.area") || $p->hasPermission("iprotector.command.area.flag")) {
              if(isset(
    $args[1])) {
                if(isset(
    $this->areas[strtolower($args[1])])) {
                  
    $area $this->areas[strtolower($args[1])];
                  if(isset(
    $args[2])) {
                    if(isset(
    $area->flags[strtolower($args[2])])) {
                      
    $flag strtolower($args[2]);
                      if(isset(
    $args[3])) {
                        
    $mode strtolower($args[3]);
                        if(
    $mode == "true" || $mode == "on") {
                          
    $mode true;
                        } else {
                          
    $mode false;
                        }
                        
    $area->setFlag($flag,$mode);
                      } else {
                        
    $area->toggleFlag($flag);
                      }
                      if(
    $area->getFlag($flag)) {
                        
    $status "on";
                      } else {
                        
    $status "off";
                      }
                      
    $o "Flag " $flag " set to " $status " for area " $area->getName() . "!";
                    } else {
                      
    $o "Flag not found. (Flags: edit, god, touch)";
                    }
                  } else {
                    
    $o "Please specify a flag. (Flags: edit, god, touch)";
                  }
                } else {
                  
    $o "Area doesn't exist.";
                }
              } else {
                
    $o "Please specify the area you would like to flag.";
              }
            } else {
              
    $o "You do not have permission to use this subcommand.";
            }
          break;
          case 
    "delete":
            if(
    $p->hasPermission("iprotector") || $p->hasPermission("iprotector.command") || $p->hasPermission("iprotector.command.area") || $p->hasPermission("iprotector.command.area.delete")) {
              if(isset(
    $args[1])) {
                if(isset(
    $this->areas[strtolower($args[1])])) {
                  
    $area $this->areas[strtolower($args[1])];
                  
    $area->delete();
                  
    $o "Area deleted!";
                } else {
                  
    $o "Area does not exist.";
                }
              } else {
                
    $o "Please specify an area to delete.";
              }
            } else {
              
    $o "You do not have permission to use this subcommand.";
            }
          break;
          case 
    "whitelist":
            if(
    $p->hasPermission("iprotector") || $p->hasPermission("iprotector.command") || $p->hasPermission("iprotector.command.area") || $p->hasPermission("iprotector.command.area.delete")) {
              if(isset(
    $args[1]) && isset($this->areas[strtolower($args[1])])) {
                
    $area $this->areas[strtolower($args[1])];
                if(isset(
    $args[2])) {
                  
    $action strtolower($args[2]);
                  switch(
    $action) {
                    case 
    "add":
                      
    $w = ($this->getServer()->getPlayer($args[3]) instanceof Player strtolower($this->getServer()->getPlayer($args[3])->getName()) : strtolower($args[3]));
                      if(!
    $area->isWhitelisted($w)) {
                        
    $area->setWhitelisted($w);
                        
    $o "Player $w has been whitelisted in area " $area->getName() . ".";
                      } else {
                        
    $o "Player $w is already whitelisted in area " $area->getName() . ".";
                      }
                    break;
                    case 
    "list":
                      
    $o "Area " $area->getName() . "'s whitelist:";
                      foreach(
    $area->getWhitelist() as $w) {
                        
    $o .= $w;";
                      }
                    break;
                    case 
    "delete":
                    case 
    "remove":
                      
    $w = ($this->getServer()->getPlayer($args[3]) instanceof Player strtolower($this->getServer()->getPlayer($args[3])->getName()) : strtolower($args[3]));
                      if(
    $area->isWhitelisted($w)) {
                        
    $area->setWhitelisted($w,false);
                        
    $o "Player $w has been unwhitelisted in area " $area->getName() . ".";
                      } else {
                        
    $o "Player $w is already unwhitelisted in area " $area->getName() . ".";
                      }
                    break;
                    default:
                      
    $o "Please specify a valid action. Usage: /area whitelist " $area->getName() . " <add/list/remove> [player]";
                    break;
                  }
                } else {
                  
    $o "Please specify an action. Usage: /area whitelist " $area->getName() . " <add/list/remove> [player]";
                }
              } else {
                
    $o "Area doesn't exist. Usage: /area whitelist <area> <add/list/remove> [player]";
              }
            } else {
              
    $o "You do not have permission to use this subcommand.";
            }
          break;
          default:
            return 
    false;
          break;
        }
        
    $p->sendMessage($o);
        return 
    true;
      }

      public function 
    onHurt(EntityDamageEvent $event) {
        if(
    $event->getEntity() instanceof Player) {
          
    $p $event->getEntity();
          
    $x false;
          if(!
    $this->canGetHurt($p)) {
            
    $event->setCancelled();
          }
        }
      }

      public function 
    onBlockBreak(BlockBreakEvent $event) {
        
    $b $event->getBlock();
        
    $p $event->getPlayer();
        
    $n strtolower($p->getName());
        if(isset(
    $this->sel1[$n])) {
          unset(
    $this->sel1[$n]);
          
    $this->pos1[$n] = new Vector3($b->getX(),$b->getY(),$b->getZ());
          
    $p->sendMessage("Position 1 set to: (" $this->pos1[$n]->getX() . ", " $this->pos1[$n]->getY() . ", " $this->pos1[$n]->getZ() . ")");
          
    $event->setCancelled();
        } else if(isset(
    $this->sel2[$n])) {
          unset(
    $this->sel2[$n]);
          
    $this->pos2[$n] = new Vector3($b->getX(),$b->getY(),$b->getZ());
          
    $p->sendMessage("Position 2 set to: (" $this->pos2[$n]->getX() . ", " $this->pos2[$n]->getY() . ", " $this->pos2[$n]->getZ() . ")");
          
    $event->setCancelled();
        } else {
          if(!
    $this->canEdit($p,$b)) {
              
    $block $b->getName();
            
    $p->sendMessage(TextFormat::BOLD ."§4Please dont break my §3$block §d)§6:");
            
    $event->setCancelled();
          }
        }
      }

      public function 
    onBlockPlace(BlockPlaceEvent $event) {
        
    $b $event->getBlock();
        
    $p $event->getPlayer();
        
    $n strtolower($p->getName());
        if(isset(
    $this->sel1[$n])) {
          unset(
    $this->sel1[$n]);
          
    $this->pos1[$n] = new Vector3($b->getX(),$b->getY(),$b->getZ());
          
    $p->sendMessage("Position 1 set to: (" $this->pos1[$n]->getX() . ", " $this->pos1[$n]->getY() . ", " $this->pos1[$n]->getZ() . ")");
          
    $event->setCancelled();
        } else if(isset(
    $this->sel2[$n])) {
          unset(
    $this->sel2[$n]);
          
    $this->pos2[$n] = new Vector3($b->getX(),$b->getY(),$b->getZ());
          
    $p->sendMessage("Position 2 set to: (" $this->pos2[$n]->getX() . ", " $this->pos2[$n]->getY() . ", " $this->pos2[$n]->getZ() . ")");
          
    $event->setCancelled();
        } else {
          if(!
    $this->canEdit($p,$b)) {
              
    $block $b->getName();
            
    $p->sendMessage(TextFormat::BOLD."§4You can not place your §3$block §4here.");
            
    $event->setCancelled();
          }
        }
      }

      public function 
    onBlockTouch(PlayerInteractEvent $event) {
        
    $b $event->getBlock();
        
    $p $event->getPlayer();
        if(!
    $this->canTouch($p,$b)) {
          
    $event->setCancelled();
        }
      }

      public function 
    saveAreas() {
        
    $areas = array();
        foreach(
    $this->areas as $area) {
          
    $areas[] = array("name" => $area->getName(),"flags" => $area->getFlags(),"pos1" => $area->getPos1(),"pos2" => $area->getPos2(),"level" => $area->getLevel(),"whitelist" => $area->getWhitelist());
        }
        
    file_put_contents($this->getDataFolder() . "areas.json",json_encode($areas));
      }

      public function 
    canEdit($p,$t) {
        if(
    $p->hasPermission("iprotector") || $p->hasPermission("iprotector.access")) {
          return 
    true;
        }
        
    $o true;
        
    $g = (isset($this->levels[$t->getLevel()->getName()]) ? $this->levels[$t->getLevel()->getName()]["Edit"] : $this->edit);
        if(
    $g) {
          
    $o false;
        }
        foreach(
    $this->areas as $area) {
          if(
    $area->contains(new Vector3($t->getX(),$t->getY(),$t->getZ()),$t->getLevel()->getName())) {
            if(
    $area->getFlag("edit")) {
              
    $o false;
            }
            if(
    $area->isWhitelisted(strtolower($p->getName()))) {
              
    $o true;
              break;
            }
            if(!
    $area->getFlag("edit") && $g) {
              
    $o true;
              break;
            }
          }
        }
        return 
    $o;
      }

      public function 
    canTouch($p,$t) {
        if(
    $p->hasPermission("iprotector") || $p->hasPermission("iprotector.access")) {
          return 
    true;
        }
        
    $o true;
        
    $g = (isset($this->levels[$t->getLevel()->getName()]) ? $this->levels[$t->getLevel()->getName()]["Touch"] : $this->touch);
        if(
    $g) {
          
    $o false;
        }
        foreach(
    $this->areas as $area) {
          if(
    $area->contains(new Vector3($t->getX(),$t->getY(),$t->getZ()),$t->getLevel()->getName())) {
            if(
    $area->getFlag("touch")) {
              
    $o false;
            }
            if(
    $area->isWhitelisted(strtolower($p->getName()))) {
              
    $o true;
              break;
            }
            if(!
    $area->getFlag("touch") && $g) {
              
    $o true;
              break;
            }
          }
        }
        return 
    $o;
      }

      public function 
    canGetHurt($p) {
        
    $o true;
        
    $g = (isset($this->levels[$p->getLevel()->getName()]) ? $this->levels[$p->getLevel()->getName()]["God"] : $this->god);
        if(
    $g) {
          
    $o false;
        }
        foreach(
    $this->areas as $area) {
          if(
    $area->contains(new Vector3($p->getX(),$p->getY(),$p->getZ()),$p->getLevel()->getName())) {
            if(!
    $area->getFlag("god") && $g) {
              
    $o true;
              break;
            }
            if(
    $area->getFlag("god")) {
              
    $o false;
            }
          }
        }
        return 
    $o;
      }

      public function 
    onMove(playerMoveEvent $event){
          foreach(
    $this->areas as $area) {
              
    $p $event->getPlayer();
             
              
    $areaName = ($area->getName());
              
    $ID $this->config->get($areaName);
             
          if(
    $area->contains(new Vector3($p->getX(),$p->getY(),$p->getZ()),$p->getLevel()->getName() and $ID != NULL)) {
             
              
    $effect Effect::getEffect($ID);
              
    $boost $this->config->get($areaName."-Amplifier");
          
          if(!
    $p->hasEffect($ID)){
           
    $effect->setAmplifier($boost);
           
    $effect->setVisible(false);
           
    $effect->setDuration(999999);
          
            
               
    $event->getPlayer()->addEffect($effect);
               
    $p->sendMessage($ID);
               
    $p->sendMessage($areaName);
               
    $p->sendMessage($boost);
          }
        
        }else{
        
    $p->removeAllEffects();
       }
      }
    }
    }
    Area.php
    PHP:
    <?php

    namespace LDX\iProtector;

    use 
    pocketmine\math\Vector3;

    class 
    Area {

      private 
    $name;
      public 
    $flags;
      private 
    $pos1;
      private 
    $pos2;
      private 
    $level;
      private 
    $whitelist;
      private 
    $plugin;

      public function 
    __construct($name,$flags,$pos1,$pos2,$level,$whitelist,$plugin) {
        
    $this->name strtolower($name);
        
    $this->flags $flags;
        
    $this->pos1 = new Vector3($pos1[0],$pos1[1],$pos1[2]);
        
    $this->pos2 = new Vector3($pos2[0],$pos2[1],$pos2[2]);
        
    $this->level $level;
        
    $this->whitelist $whitelist;
        
    $this->plugin $plugin;
        
    $this->save();
      }

      public function 
    getName() {
        return 
    $this->name;
      }

      public function 
    getPos1() {
        return array(
    $this->pos1->getX(),$this->pos1->getY(),$this->pos1->getZ());
      }

      public function 
    getPos2() {
        return array(
    $this->pos2->getX(),$this->pos2->getY(),$this->pos2->getZ());
      }

      public function 
    getFlags() {
        return 
    $this->flags;
      }

      public function 
    getFlag($flag) {
        if(isset(
    $this->flags[$flag])) {
          return 
    $this->flags[$flag];
        }
        return 
    false;
      }

      public function 
    setFlag($flag,$value) {
        if(isset(
    $this->flags[$flag])) {
          
    $this->flags[$flag] = $value;
          
    $this->plugin->saveAreas();
          return 
    true;
        }
        return 
    false;
      }

      public function 
    contains($pos,$level) {
        if((
    min($this->pos1->getX(),$this->pos2->getX()) <= $pos->getX()) && (max($this->pos1->getX(),$this->pos2->getX()) >= $pos->getX()) && (min($this->pos1->getY(),$this->pos2->getY()) <= $pos->getY()) && (max($this->pos1->getY(),$this->pos2->getY()) >= $pos->getY()) && (min($this->pos1->getZ(),$this->pos2->getZ()) <= $pos->getZ()) && (max($this->pos1->getZ(),$this->pos2->getZ()) >= $pos->getZ()) && ($this->level == $level)) {
          return 
    true;
        }
        return 
    false;
      }

      public function 
    toggleFlag($flag) {
        if(isset(
    $this->flags[$flag])) {
          
    $this->flags[$flag] = !$this->flags[$flag];
          
    $this->plugin->saveAreas();
          return 
    $this->flags[$flag];
        }
        return 
    false;
      }

      public function 
    getLevel() {
        return 
    $this->level;
      }

      public function 
    isWhitelisted($n) {
        if(
    in_array($n,$this->whitelist)) {
          return 
    true;
        }
        return 
    false;
      }

      public function 
    setWhitelisted($n,$v true) {
        if(
    $v) {
          if(!
    in_array($n,$this->whitelist)) {
            
    array_push($this->whitelist,$n);
            
    $this->plugin->saveAreas();
            return 
    true;
          }
        } else {
          if(
    in_array($n,$this->whitelist)) {
            
    $key array_search($n,$this->whitelist);
            
    array_splice($this->whitelist,$key,1);
            
    $this->plugin->saveAreas();
            return 
    true;
          }
        }
        return 
    false;
      }

      public function 
    getWhitelist() {
        return 
    $this->whitelist;
      }

      public function 
    save() {
        
    $this->plugin->areas[$this->name] = $this;
        return 
    true;
      }

      public function 
    delete() {
        unset(
    $this->plugin->areas[$this->getName()]);
        
    $this->plugin->saveAreas();
        return 
    true;
      }

    }
    config..
    Code:
    # Config file for iProtector by LDX;
    
    # Settings for unprotected areas in worlds without specific settings:
    Default:
    
      # Keep players from getting hurt?
      God: false
    
      # Keep players from editing the world?
      Edit: false
    
      # Keep players from touching blocks and activating things like chests?
      Touch: false
    
    # Settings for unprotected areas in individual worlds:
    Worlds:
    
      lobby:
    
        # Keep players from getting hurt?
        God: true
    
        # Keep players from editing the world?
        Edit: true
    
        # Keep players from touching blocks and activating things like chests?
        Touch: true
    # Settings for each areas effects
    
    #SPEED = 1
    #SLOWNESS = 2
    #HASTE = 3
    #SWIFTNESS = 3
    #FATIGUE = 4
    #MINING_FATIGUE = 4
    #STRENGTH = 5
    #JUMP = 8
    #NAUSEA = 9
    #CONFUSION = 9
    #REGENERATION = 10
    #DAMAGE_RESISTANCE = 11
    #FIRE_RESISTANCE = 12
    #WATER_BREATHING = 13
    #INVISIBILITY = 14
    #WEAKNESS = 18
    #POISON = 19
    #WITHER = 20
    #HEALTH_BOOST = 2
    test2: 3
    test2-Amplifier: 20
    
    test: 2 
    test-Amplifier: 5
    
    arena: 20
    arena-Amplifier: 5
  5. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    Maybe use
    if($area>getName() === "whatever"){
    if($area->contains($p){
    //blahblahblah
    }
    }
  6. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    I thought about that but then i wont be able to change it in the config..ill have to add my area names in the code /:
  7. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    I figured out the problem..tis the way i take away the effect. I got rid of that and i would get set with each effect when walking into diffrent areas only problem is i need to figure out how to take them away now -_-
  8. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    or tis $area..boo this is driving me crazy lol IT SHOULD WORK..
  9. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    I got it :D thanks for trying anyway!
    PHP:
    public function onMove(playerMoveEvent $event){
          foreach(
    $this->areas as $area) {
              
    $p $event->getPlayer();
              
    $s = ($area->contains(new Vector3($p->getX(),$p->getY(),$p->getZ()),$p->getLevel()->getName()));
             
         
          if(
    $s){
              
    $areaName $area->getName();
               
    $ID $this->config->get($areaName);
                
    $effect Effect::getEffect($ID);
                  
    $boost $this->config->get($areaName."-Amplifier");
             
         
           
    $effect->setAmplifier($boost);
            
    $effect->setVisible(false);
             
    $effect->setDuration(999999);
               
    $p->addEffect($effect);
               break;
          }
          if(!
    $s){
              
    $p->removeAllEffects();
        }
       }
      }
  10. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    Nice.
  11. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    While your here..is there any teleport function? like playerTeleportEvent or somthing i was looking at the api anc cant find it /: would be usefull for this also tho to take effects on tp
  12. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    EntityTeleportEvent.
    dxm_hippie likes this.
  13. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Or EntitLevelChangeEvent if you switch worlds.
  14. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    Na the problem i got now is when they are in a "area" and warp to another "area" they keep the effect from the last area..or anyway i can get all effects a player has as id?
  15. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    But if they leave a area or go to a area that has no effect set it will remove it..just need a way to compare all players effects with the $id they should have..or somthing along them lines
  16. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    I tried and it said that don't exist. I used the listener also..well kinda guesses with
    listener. pocketmine \Entity\EntityTeleportEvernt?
  17. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
  18. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    lol sorry forgot to say i found it no need to yell i did read the docs and couldnt find it at first
    Legoboy0215 likes this.
  19. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Not yelling... *Looks Away*

Share This Page

Advertisement