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

Solved Need help with iProtector Plugin

Discussion in 'Plugin Help' started by WinterBuild7074, Apr 14, 2017.

  1. Matthew

    Matthew Baby Zombie

    Messages:
    167
    GitHub:
    matthww
    Weird, and you don't have any other plugins interfering with iProtector?
     
  2. WinterBuild7074

    WinterBuild7074 Zombie Pigman

    Messages:
    693
    GitHub:
    winterbuild7074
    I only have one protector plugin.
    Plus, I think I really need to edit the .php because it is turning on edit-protection in areas. I'll try and do the same thing on god mode, turn it on too. But I'm not sure how.
     
  3. WinterBuild7074

    WinterBuild7074 Zombie Pigman

    Messages:
    693
    GitHub:
    winterbuild7074
    I think I need to change something in the PHP:
    PHP:
    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;
      }
     
  4. WinterBuild7074

    WinterBuild7074 Zombie Pigman

    Messages:
    693
    GitHub:
    winterbuild7074
    Can anyone help?
     
  5. WinterBuild7074

    WinterBuild7074 Zombie Pigman

    Messages:
    693
    GitHub:
    winterbuild7074
    I tried turning god to true and false in the config and also in the areas.json, but nothing worked. I experimented around and tried everything, but it won't let me do this: god mode on in protected areas, god mode off in unprotected areas.
    I think there must be something wrong with the whole plugin, or the .php file (see code above). Or maybe I'm not using the newest version?
     
  6. WinterBuild7074

    WinterBuild7074 Zombie Pigman

    Messages:
    693
    GitHub:
    winterbuild7074
    I need to fix this or PvP won't work correctly and etc.
    Please help me fix this. There must be a way.
     
  7. WinterBuild7074

    WinterBuild7074 Zombie Pigman

    Messages:
    693
    GitHub:
    winterbuild7074
    I was testing really around a lot. I finally fixed the problem by doing this (at bit confusing with all these true and false).

    In Main.php:
    PHP:
      public function onHurt(EntityDamageEvent $event) {
        if(
    $event->getEntity() instanceof Player) {
          
    $p $event->getEntity();
          
    $x false;
          if(
    $this->canGetHurt($p)) { // removed the ! (not)
            
    $event->setCancelled();
          }
        }
      }
    In config.yml:
    (I'm changing settings for the worlds on my server: PvP1 and Farming)
    Code:
    # Settings for unprotected areas in individual worlds:
    Worlds:
      PvP1:
        # Keep players from getting hurt?
        God: true    # here, 'true' means "false"
        # Keep players from editing the world?
        Edit: true
        # Keep players from touching blocks and activating things like chests?
        Touch: false
      Farming:
        # Keep players from getting hurt?
        God: true     # here, 'true' means "false"
        # Keep players from editing the world?
        Edit: false
        # Keep players from touching blocks and activating things like chests?
        Touch: false
    

    In areas.json:
    I set God-Mode to true.

    I don't really understand it, but at least it works now. iProtector is a bit glitchy with God-Mode.
     
  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.