BarAPI

Discussion in 'Plugin Development' started by RRL213, Aug 2, 2014.

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

    RRL213

    I currently have this, I have it almost completed I just would like to know how to make it so the list goes in order, does anyone know how to do that?
    Code:
    public void onEnable() {
            getServer().getPluginManager().registerEvents(this, this);
        }
       
        @EventHandler
        public void onJoin(PlayerJoinEvent e){
            Player p = e.getPlayer();
            // BarAPI.setMessage(p, "Ryguy is testing something out!");
            showBarChanging(p);
        }
       
        public void showBarChanging(final Player p){
            getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){
                public void run(){
                    Random random = new Random();
                    List<String> list = new ArrayList<>();
                    list.add("§cWelcome to Thinghunter!");
                    list.add("§fTo vote goto §ewww.thinghunter.com §fand click on vote!");
                    list.add("§fVote for us everyday! Earn §e$200! §feach time!");
                    list.add("§fThere are various worlds ranging from §4PvP §fto §ePvE§f!");
                    list.add("§fWant to have some fun? Goto the §9Mini_Games §fworld!");
                    list.add("§fType §c/pb §fto join a painball match and fight to the death!");
                    list.add("§fLike Parkour? Try out the §eObstacle course!");
                    list.add("§fLike to §4PvP§f? Goto the §9Horde §fworld!");
                    list.add("§fYou may obtain §eDiplomat §fstatus for §e$10 §fUSD!");
                    list.add("§fWant to claim your land, but dont know how? Type §e/resinfo§f!");
                    String message = (String) list.get(random.nextInt(list.size()));
                    BarAPI.setMessage(p, message);
                }
               
            }, 0L, 1 * 50);
        }
     
    }
    
     
  2. Offline

    fireblast709

    RRL213 create an int field in the anonymous Runnable (outside the run() method) and increment that each time you use it. If it's >= list.size(), set it back to 0, get the String at the indec., and display it.
     
  3. Offline

    RRL213

    Thanks ;)

    Can you edit the code? I can't seem to find what you're talking about sorry if I seem stupid xD
    fireblast709

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  4. Offline

    fireblast709

    RRL213
    Code:Java
    1. new Runnable()
    2. {
    3. private int counter = 0;
    4.  
    5. @Override
    6. public void run()
    7. {
    8. // TODO: logic
    9. }
    10. }
     
  5. Offline

    RRL213

    could you possible add that to the code I have already done? thanks :D fireblast709
     
  6. Offline

    fireblast709

    RRL213 no, for two reasons. a) it's pretty straightforward. You should be perfectly fine with the implentation since it is basic java knowledge. b) it would be spoonfeeding.
     
    TigerHix and leon3001 like this.
Thread Status:
Not open for further replies.

Share This Page