Hey, does anyone know how I can create flashing text? Not like in chat, I am using the barapi and I want the message to change colors every 2 seconds, but I am not sure how to do that. Can some explain how I can do that? I don't need the code I just want an explanation.
I suppose you could do this by making a runnable. Code: Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { @Override public void run() { //change color } }, 40L, 40L); 40L = 40 ticks, which is 2 seconds.
HelGod Nothing to explain... Just add 'ChatColor.RED' (or any color ofc) to the start of the string....
I believe there's something to explain. An efficient and coherent way to do so. If you want a particular and exact pattern, I'd recommend using a List of Strings and then making an Iterator of Strings that runs through that list. It could even be a List of chars and whatnot. Anyways, just store the pattern in which you want the colors: Code: private List<String> prefixes = Arrays.asList("c", "6", "e", "a", "b", "9", "1", "5", "d"); //Relative rainbow pattern private Iterator<String> prefixesIt = prefixes.iterator(); public String updateString(String s) { if(prefixIt.hasNext()) return "\u00A7" + prefixIt.next() + s; else { prefixIt = prefixes.iterator(); return "\u00A7" + prefixIt.next() + s; } return s; }
I'll be here for debugging. I assumed it worked, then. EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Drkmaster83 It works, thanks so much . I can change this method up for some other stuff I couldn't figure out to do