Random MOTD

Discussion in 'Plugin Development' started by XxZHALO13Xx, May 19, 2014.

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

    XxZHALO13Xx

    Hi there, how would i make a auto changing motd? like when u hit refresh the msg of the day changes? any help will be awesome! thanks
     
  2. Offline

    Glumpz

    XxZHALO13Xx Use the ServerListPingEvent and set the Event#setMotd(String motd).
     
  3. Offline

    EnchantedMiners

    XxZHALO13Xx
    you will need to create a Random() int on the ServerListPingEvent
    Code:java
    1. @EventHandler
    2. public void serverListPing(ServerListPingEvet e){
    3. }

    When you have the event created then
    the random motd code :
    Code:java
    1. Random rand = new Random();
    2. int random = rand.nextInt(2);
    3.  
    4. if(random == 0){
    5. e.setMotd("Hello and this is MOTD 1");
    6. } else if(random == 1){
    7. e.setMotd("Hello and this is MOTD 2");
    8. } else if(random == 2){
    9. e.setMotd("Hello and this is MOTD 3");
    10. }
    11.  
    12. /* Remember that 0 = 1, 1 = 2, 2 = 3
    13. * you put this on ServerListPingEvent
    14. */
    15.  
     
  4. Offline

    FireBreath14

    Haha thats so awesome, my server does that! I fill it with stupid random messages / movie references. Kinda like the Minecraft MOTD on the title screen
     
Thread Status:
Not open for further replies.

Share This Page