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); } }
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.
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.
RRL213 Code:Java new Runnable(){ private int counter = 0; @Override public void run() { // TODO: logic }}
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.