Solved Flashing Text

Discussion in 'Plugin Development' started by HelGod, Jan 11, 2014.

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

    HelGod

    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.
     
  2. Offline

    Stealth2800

    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.
     
  3. Offline

    HelGod

    Stealth2800
    Yeah I know I would need to make a runnable I want to know the color changing part :)
     
  4. Offline

    newboyhun

    HelGod
    Nothing to explain...
    Just add 'ChatColor.RED' (or any color ofc) to the start of the string....
     
  5. Offline

    Drkmaster83

    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;
    }
    
     
  6. Offline

    HelGod

    Drkmaster83
    This looks like it might work :) I will give it a try.
     
  7. Offline

    Drkmaster83

    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.
     
    Last edited by a moderator: Jun 6, 2016
  8. Offline

    HelGod

    Drkmaster83
    It works, thanks so much :). I can change this method up for some other stuff I couldn't figure out to do
     
  9. Offline

    Drkmaster83

    No problem :)
     
Thread Status:
Not open for further replies.

Share This Page