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

Banned?

Comments in 'Plugin Development' started by Legoboy0215, Jul 21, 2015.

  1. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,747
    Minecraft User:
    Legoboy0215
    I tried this:
    PHP:
                                    $this->getServer()->getPlayer($name)->kick(TextFormat::RED "You are banned."false);
                                    
    $this->getServer()->getPlayer($name)->setBanned(true);
    It will crash by saying setBanned() on null. How can I fix this code?
  2. aliuly
    Offline

    aliuly Notable Member Plugin Developer

    Joined:
    Feb 8, 2014
    Posts:
    1,086
    Plugins:
    17
    First ban then kick.

    The first getPlayer($name) works because the player is still around.
    The second getPlayer($name) fails because the player was kicked (is no longer around).
    PEMapModder likes this.
  3. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,747
    Minecraft User:
    Legoboy0215
    IK... I was told to kick then ban. Thanks!
  4. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,747
    Minecraft User:
    Legoboy0215
    But I though setBanned will kick the player?
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You shouldn't search the player twice. Search (getPlayer) once, save it in a variable and call functions upon it.
    Searching it multiple times is kind of laggy anyway.

Share This Page

Advertisement