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

How permissions work??

Comments in 'Plugin Development' started by asters, Jul 31, 2016.

  1. asters
    Offline

    asters Active Member

    Joined:
    Jul 2, 2015
    Posts:
    52
    Minecraft User:
    aster
    in pocketmine.yml:
    permissions:
    reserveslots.player:
    default: false
    in main.php just code that wont work:
    if(!$event->getPlayer()->hasPermission("reserveslots.player")){
    $event->getPlayer()->kick("§9Server Full!! §a Only players with permission can join now!");
    $event->setCancelled();
    }

    I added permision with pureperms!! I did many tests! It just wont work!!
    Can someone tell me why? Or how does permission work??
    Even if i give me permission using pureperms , it wont work at all !!! :(
  2. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    You should do $event-setCancelled() when the player has the permission, not when he doesn't.
    applqpak likes this.
  3. asters
    Offline

    asters Active Member

    Joined:
    Jul 2, 2015
    Posts:
    52
    Minecraft User:
    aster
    I wanna to do!! If player does not have permission !!! He gets kicked!!!
    But the permission is ok?? It just wont work!! I get kicked even if i have permission!! Idk what to do!!!Im Blocked!!
    I just cant understand these perms!! :( !!!
    Im sure i did it ok!!
  4. asters
    Offline

    asters Active Member

    Joined:
    Jul 2, 2015
    Posts:
    52
    Minecraft User:
    aster
    Is onplayerprelogin event!!
  5. SOFe
    Offline

    SOFe Banned

    Joined:
    May 28, 2016
    Posts:
    386
    Minecraft User:
    Herobrine
    Maybe PurePerms hasn't load the permission data about the player when he is still logging in?
  6. asters
    Offline

    asters Active Member

    Joined:
    Jul 2, 2015
    Posts:
    52
    Minecraft User:
    aster
    Nope ! I add perm to a group!! :( !
    So , nothing wrong with these codes?
    Edit:Hmm!! If i think about it! Maybe u right!! :0
    Edit again: I will do a .txt file , were i can add players to bypass this :) !!

    Im making a reserve slots!! You take , for example (in config) , 10 slots from your total, and reserve them for vips, that u add , manually in a .txt file (idk if i will add a command) !!

    Tests are done , and work but i had problems with da perms :0 !!! Well , i will just do with files and done!!

    So i have 80 players ! Only 70 players can login , becouse 10 slots are reserved for vips :3 !!
    Last edited: Jul 31, 2016
  7. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    Have you fixed the problem he mentioned?
  8. rinkuno
    Offline

    rinkuno Active Member

    Joined:
    Oct 8, 2014
    Posts:
    59
    Minecraft User:
    rinku
    Well the code ur kicking ur self lemme give u a sample code

    PHP:
    <?php

    //
    //
    //Copy Right EmeraldLordYT
    //
    //


    namespace plugin;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\event\block\BlockBreakEvent;
    use 
    pocketmine\event\block\BlockPlaceEvent;
    use 
    pocketmine\utils\TextFormat as TF;
    use 
    pocketmine\event\player\PlayerInteractEvent;

    class 
    MainBase extends PluginBase implements Listener {
        public function 
    onEnable() {
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
        }

        public function 
    onBlockBreakEvent(BlockBreakEvent $event) {
               if(
    $event->getPlayer()->hasPermission('plugincustom.break')){
                
    $event->setCancelled(false);
        }else{
            
    $event->setCancelled(true);
            
    $event->getPlayer()->sendPopup(TF::RED "Hey! You are not allowed to break");
                  
                    }
            }
        public function 
    onBlockPlaceEvent(BlockPlaceEvent $event) {
               if(
    $event->getPlayer()->hasPermission('plugincustom.place')){
                
    $event->setCancelled(false);
        }else{
             
    $event->setCancelled(true);
            
    $event->getPlayer()->sendPopup(TF::RED "Hey! You are not allowed to place");

              
        
        }
      
        }
      
    }
    Well u gatto fix it if there are errors:p
  9. rinkuno
    Offline

    rinkuno Active Member

    Joined:
    Oct 8, 2014
    Posts:
    59
    Minecraft User:
    rinku
    Don't yell to us
  10. SOFe
    Offline

    SOFe Banned

    Joined:
    May 28, 2016
    Posts:
    386
    Minecraft User:
    Herobrine
    I still think this is the real reason.
    According to PurePerms source code, player data is only loaded in PlayerLoginEvent, and the permissions are probably initialized after that.
    Therefore, calling hasPermission() in PlayerPreLoginEvent will not receive any effect from PurePerms.
  11. SOFe
    Offline

    SOFe Banned

    Joined:
    May 28, 2016
    Posts:
    386
    Minecraft User:
    Herobrine
    It seems that you are not responding to the indicated problem...

Share This Page

Advertisement