Random MOTD color not working

Discussion in 'Plugin Development' started by monkeymanboy, Sep 7, 2013.

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

    monkeymanboy

    im trying to make the motd be color changing here is the code im using
    Code:
        int i = 1;
        @EventHandler
        public void onServerListPing(ServerListPingEvent event){
        String color = "" + i;
        if(i < 10){
        event.setMotd("§" + color + "Test");
        i = i+1;
        } else {
        i = 1;
        }
        }
    it just says whatever motd is in the properties
     
  2. Offline

    Deleted user

    monkeymanboy
    You probably want to make a config file
    There they can set the motds they want to alternate

    Then take that list and assign number calues to them
    Then create a random and have the max be the last number value (add one if not arraylist)

    Then set the motd to one of the conig values every time
     
  3. Offline

    monkeymanboy

    JHG0
    this is for personal use and i will have a config though this is just a test
     
  4. Offline

    BajanAmerican

    monkeymanboy
    Use this method somewhere in your class:
    Code:
        public static int getRandomNumberInRange(int Max, int Min) {
            return Min + (int)(Math.random() * ((Max - Min) + 1));
            }
    Then do this:

    Code:
     @EventHandler
        public void onServerListPing(ServerListPingEvent event){
        event.setMotd("§" + getRandomNumberInRange(10, 1) + "Test");
        }
     
  5. Offline

    monkeymanboy

    BajanAmerican likes this.
Thread Status:
Not open for further replies.

Share This Page