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

PlayerBanEvent

Comments in 'Plugin Development' started by LDX, Apr 17, 2015.

  1. LDX
    Offline

    LDX Notable Member Plugin Developer

    Joined:
    Oct 2, 2013
    Posts:
    1,397
    Plugins:
    14
    While I realize that PlayerBanEvents aren't real, I would like to know how to program the equivalent of one. How can I tell when a player is banned or unbanned?
  2. xFlare
    Offline

    xFlare Active Member Plugin Developer

    Joined:
    Sep 28, 2014
    Posts:
    199
    Plugins:
    1
    Minecraft User:
    xFlare
    Well, we can code a work around :D

    Here is what I came up with in 5 minutes :p

    PHP:
    public function onPlayerCommand(PlayerCommandPreprocessEvent $event){
            
    $player$event->getPlayer();
            
    $message $event->getMessage();
            
    $command substr($message1);
            
    $args explode(" "$command);
            if(
    $args[0] === "ban-ip" or $args[0] === "ban"){ //commands
                
    if (substr($message01) === '/') { //Double check to make sure its a command.
                    
    $event->getPlayer()->sendMessage("- xFlare stoped this command with magic.");
                    
    $event->setCancelled(true);
                    return 
    true;
  3. iJoshuaHD
    Offline

    iJoshuaHD Notable Member Plugin Developer

    Joined:
    Nov 7, 2013
    Posts:
    1,167
    Plugins:
    4
    Minecraft User:
    iJoshuaHD
    He wants to know how to to get if player is banned or not.
  4. LDX
    Offline

    LDX Notable Member Plugin Developer

    Joined:
    Oct 2, 2013
    Posts:
    1,397
    Plugins:
    14
    That works for the ban command, but I also want to catch when a plugin calls the Player::setBanned() method.

    No, he had it right. You can check if a player is banned by calling the Player::isBanned() method.
  5. iJoshuaHD
    Offline

    iJoshuaHD Notable Member Plugin Developer

    Joined:
    Nov 7, 2013
    Posts:
    1,167
    Plugins:
    4
    Minecraft User:
    iJoshuaHD
    Then why ask if u know -,-
  6. LDX
    Offline

    LDX Notable Member Plugin Developer

    Joined:
    Oct 2, 2013
    Posts:
    1,397
    Plugins:
    14
    When, not if. ;^) #MajorLeagueEnglish
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    PlayerKickEvent::getReason() or something like that.

Share This Page

Advertisement