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

deOP(); ?? help please, got a issue

Comments in 'Plugin Development' started by dxm_hippie, Aug 9, 2015.

Thread Status:
Not open for further replies.
  1. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    How can i deop players on join? i tried

    PHP:
    public function onPlayerJoin(PlayerJoinEvent $event){
            
    $player $event->getPlayer()->getName();
            if(
    $player->isOp(){
            
    $this->getServer()->dispatchCommand(new ConsoleCommandSender(), deop($player));
    }
    }
    But ehh,,no luck im getting random ops on my server and i have no clue why! none of my staff have op command. IDK what happened but i need this to work ):
    Last edited: Aug 9, 2015
  2. Xenturio
    Offline

    Xenturio Active Member

    Joined:
    Sep 19, 2014
    Posts:
    333
    Minecraft User:
    Xenturio
  3. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    I don't have a plugin giving op to players..idk if its a new pm bug or pureperms bug but it just started happening about the same time I updated.
  4. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Since when is deop($player) a command?!
  5. Xenturio
    Offline

    Xenturio Active Member

    Joined:
    Sep 19, 2014
    Posts:
    333
    Minecraft User:
    Xenturio
    try
    PHP:
    $player $event->getPlayer()->getName();
    $i "deop $player";
    $this->getServer()->dispatchCommand(new ConsoleCommandSender(),$i));
    dxm_hippie likes this.
  6. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    idk how to make a plugin rin commands -_- not very good at this..lol but /deop $player is a command, i thought i was at least close XD
  7. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    Thank you!
  8. Xenturio
    Offline

    Xenturio Active Member

    Joined:
    Sep 19, 2014
    Posts:
    333
    Minecraft User:
    Xenturio
  9. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    or
    PHP:
    public $ops;

    public function 
    onEnable(){
    $this->ops = (new Config($this->getDataFolder()."ops.yml"Config::YAML)->getAll();
    }

    public function 
    onDisable(){
    $this->ops = new Config($this->getDataFolder()."ops.yml"Config::YAML$this->ops);
    }

    public function 
    onJoin(PlayerJoinEvent $event){
    if(
    $event->getPlayer()->isOp() || !(array_key_exists(strtolower($event->getPlayer()->getName())))){
    $event->getPlayer()->setOp(false);
    }
    }
    If you use this code then add your real ops in ops.yml (all lower case)
    Last edited: Aug 9, 2015
    Xenturio likes this.
  10. Xenturio
    Offline

    Xenturio Active Member

    Joined:
    Sep 19, 2014
    Posts:
    333
    Minecraft User:
    Xenturio
  11. Gamecrafter
    Offline

    Gamecrafter Notable Member Plugin Developer

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Yes, or $server->removeOp($name).
    Xenturio likes this.
  12. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    This will be more safe :)
  13. Gamecrafter
    Offline

    Gamecrafter Notable Member Plugin Developer

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Syntax error on the 12th line.
    Primus likes this.
  14. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    PHP:
    if($event->getPlayer()->isOp() || !(array_key_exists(strtolower($event->getPlayer()->getName())))){
    Sorry my bad :D
    Xenturio likes this.
  15. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    What? Why array_key_exists with no array at all?
    CraftYourBukkit likes this.
  16. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    CraftYourBukkit likes this.
  17. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    No, it doesn't work because it won't recalculate the player permissions.
  18. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
Thread Status:
Not open for further replies.

Share This Page

Advertisement