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

Change the "Server Is full" message

Comments in 'Plugin Development' started by TonyDroidd, Apr 24, 2015.

  1. TonyDroidd
    Offline

    TonyDroidd Active Member

    Joined:
    Sep 6, 2014
    Posts:
    180
    Minecraft User:
    TonyDroidd
    How i can change the "Server is full" message??
    i need the code...
  2. DA_Swagnemite
    Offline

    DA_Swagnemite Notable Member Plugin Developer

    Joined:
    Nov 17, 2013
    Posts:
    386
    Plugins:
    7
    Minecraft User:
    DA_SWAGNEMITE
    I think you might just be able to use the player connect event then check if the server is full manually and if so kick the player with a custom message.
    Im not sure that will work but it might.
  3. TonyDroidd
    Offline

    TonyDroidd Active Member

    Joined:
    Sep 6, 2014
    Posts:
    180
    Minecraft User:
    TonyDroidd
    emm... how?
  4. RekkuzaRage
    Offline

    RekkuzaRage Active Member

    Joined:
    Apr 15, 2014
    Posts:
    251
    Minecraft User:
    RekkuzaRage
    I think you have to use the player login event and check if the server is full, etc. I currently don't have 0.11.0 beta or PM 1.5.
  5. RekkuzaRage
    Offline

    RekkuzaRage Active Member

    Joined:
    Apr 15, 2014
    Posts:
    251
    Minecraft User:
    RekkuzaRage
    I just saw your post, I didn't see it, oops. Similar what I just said. I think the correct event is PlayerLoginEvent.
  6. DA_Swagnemite
    Offline

    DA_Swagnemite Notable Member Plugin Developer

    Joined:
    Nov 17, 2013
    Posts:
    386
    Plugins:
    7
    Minecraft User:
    DA_SWAGNEMITE
    Something like
    PHP:
    onPlayerLogin(PlayerLoginEvent $event) {
        if(
    $this->getServer()->getMaxPlayers() === count($this->plugin->getServer()->getOnlinePlayers())) {
            
    $event->setKickMessage("The server is full");
            
    $event->setCancelled();
        }
    }
    TonyDroidd likes this.
  7. TonyDroidd
    Offline

    TonyDroidd Active Member

    Joined:
    Sep 6, 2014
    Posts:
    180
    Minecraft User:
    TonyDroidd
    I'll try...
  8. RekkuzaRage
    Offline

    RekkuzaRage Active Member

    Joined:
    Apr 15, 2014
    Posts:
    251
    Minecraft User:
    RekkuzaRage
    Don't use the setCancelled(); method, it will just cancel the event.
  9. DA_Swagnemite
    Offline

    DA_Swagnemite Notable Member Plugin Developer

    Joined:
    Nov 17, 2013
    Posts:
    386
    Plugins:
    7
    Minecraft User:
    DA_SWAGNEMITE
    So itd be $event->getPlayer()->close();?
    TonyDroidd likes this.
  10. RekkuzaRage
    Offline

    RekkuzaRage Active Member

    Joined:
    Apr 15, 2014
    Posts:
    251
    Minecraft User:
    RekkuzaRage
    I think you return it true.
    PHP:
    return true;
    Corrected code.
    PHP:
    onPlayerLogin(PlayerLoginEvent $event) {
        if(
    $this->getServer()->getMaxPlayers() === count($this->plugin->getServer()->getOnlinePlayers())) {
            
    $event->setKickMessage("The server is full");
            return 
    true;
        }
    }
    Last edited: Apr 25, 2015
  11. DA_Swagnemite
    Offline

    DA_Swagnemite Notable Member Plugin Developer

    Joined:
    Nov 17, 2013
    Posts:
    386
    Plugins:
    7
    Minecraft User:
    DA_SWAGNEMITE
    If that were the case you wouldnt need to include return true... Im pretty sure all that does is continue the event normally and if so you dont need that line.
  12. TonyDroidd
    Offline

    TonyDroidd Active Member

    Joined:
    Sep 6, 2014
    Posts:
    180
    Minecraft User:
    TonyDroidd
    which is as represents 'plugin' on this:
    if($this->getServer()->getMaxPlayers() === count($this->plugin->getServer()->getOnlinePlayers())) {{

    ???
  13. RekkuzaRage
    Offline

    RekkuzaRage Active Member

    Joined:
    Apr 15, 2014
    Posts:
    251
    Minecraft User:
    RekkuzaRage
    Yeah, it will still run correctly without the return, just checked.
  14. DA_Swagnemite
    Offline

    DA_Swagnemite Notable Member Plugin Developer

    Joined:
    Nov 17, 2013
    Posts:
    386
    Plugins:
    7
    Minecraft User:
    DA_SWAGNEMITE
    $this->plugin would be used if you were in a second class and if that were the case $this->getServer() would be $this->plugin->getServer()
    RekkuzaRage and TonyDroidd like this.
  15. RekkuzaRage
    Offline

    RekkuzaRage Active Member

    Joined:
    Apr 15, 2014
    Posts:
    251
    Minecraft User:
    RekkuzaRage
    Ahh okay. Didn't know that.
  16. TonyDroidd
    Offline

    TonyDroidd Active Member

    Joined:
    Sep 6, 2014
    Posts:
    180
    Minecraft User:
    TonyDroidd
    i got this log

    [CRITICAL] ClassNotFoundException: "Class TDroidd\CKR\Main not found" (EXCEPTION) in "/src/spl/BaseClassLoader" at line 131
  17. Artide
    Offline

    Artide Active Member

    Joined:
    Apr 20, 2015
    Posts:
    214
    Minecraft User:
    Artide5
    Upload the crashdump
  18. DA_Swagnemite
    Offline

    DA_Swagnemite Notable Member Plugin Developer

    Joined:
    Nov 17, 2013
    Posts:
    386
    Plugins:
    7
    Minecraft User:
    DA_SWAGNEMITE
    Make sure your MainClass in your plugin.yml is correct
    PEMapModder and RekkuzaRage like this.
  19. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    For the billionth time, event handlers don't need to return any values and any return values will be ignored.
    That comes from the translation in your MCPE client.
    EvolSoft and iksaku like this.
  20. Artide
    Offline

    Artide Active Member

    Joined:
    Apr 20, 2015
    Posts:
    214
    Minecraft User:
    Artide5
    May I use it, MapModder?

Share This Page

Advertisement