Plugin and color

Discussion in 'Plugin Development' started by tomecki1, May 26, 2016.

Thread Status:
Not open for further replies.
  1. Hello,
    I have problem with color.
    I want to receive messages from the color with config.yml.
    e.g:
    I have in config.yml:
    text: '&6hello'
    And I want the message to show in the given color.
    Please help me and regards.
     
  2. Online

    timtower Administrator Administrator Moderator

  3. Offline

    Irantwomiles

  4. I still know nothing.
     
  5. Offline

    redtsch

    @tomecki1
    Yes, you can translate alternate color codes, but it is easier to just right '§6hello' if you know what I mean
    =P
     
  6. Yes, but not anyone wants to use the § the more there is no shortcut for this.
     
  7. Online

    timtower Administrator Administrator Moderator

    @tomecki1 That method changes any char to color codes.
    Try it, google the method if you need examples
     
  8. @timtower
    I made so:
    prefix = getConfig().getString("AutoMsg.prefix").replace("&", "§");
    but I have problem with list message:
    msgs = getConfig().getStringList("AutoMsg.listMsg").replaceAll("&","§");
     
  9. Online

    timtower Administrator Administrator Moderator

    @tomecki1 sendMessage(ChatColor.translateAlternateColorCode('&',string))
    And yeah, a method made for strings won't work on a list.
     
  10. @timtower
    How to make that work on list?
    One plugin works and colleague asked me I too did such a thing
     
  11. Online

    timtower Administrator Administrator Moderator

  12. Online

    timtower Administrator Administrator Moderator

    @tomecki1 A simple for loop will do.
    Basic java
     
  13. I don't know how.
    I know how to do loops, etc. but I do not know how to connect.
     
  14. Online

    timtower Administrator Administrator Moderator

    @tomecki1 Connect what?
    You are using a list already, so it is safe to assume that you are sending messages to the player.
    Do the ChatColor stuff in there.
     
  15. Offline

    I Al Istannen

    @tomecki1
    Like:
    Code:
    for message in list
      message = translateColorCodes (message)
      send message
    end for
    If you are not able to create such a loop, I would encourage you to follow timtowers advice and learn a bit more about Java. There is a small guide on where to learn here.
     
    timtower likes this.
  16. Offline

    MadMaxCookie

    Code:
    ArrayList<String> list = new ArrayList<String>();
    list.add("MadMaxCookie");
    list.add("loves");
    list.add("cookies");
    
      // s returns to MadMaxCookie , loves , cookies
      for(String s : list) {
         // send s as message to player with ChatColor 
    }
     
  17. But the player writes a list of config.yml so how do I know how many the message will add.
     
  18. Online

    timtower Administrator Administrator Moderator

    @tomecki1 list.size() ?
    I will repeat:
     
  19. Offline

    EmeraldRailsMC

    On a Mac, press option (alt)+6. Otherwise I'd Google "Section Sign" and copy it.
     
  20. Offline

    Betagear

    Don't use replaceAll. It's glitched. Use replace instead.
     
  21. Offline

    I Al Istannen

    @Betagear
    replaceALL is NOT glitched! It uses a RegEx to find out what to replace. This means you can have unexspected results if you pass it something that was not intended to be one.
     
    teej107 likes this.
  22. Offline

    TwistedLobby

    ChatColor.translateAlternateColorCodes('&', getConfig().getString("text"))
     
Thread Status:
Not open for further replies.

Share This Page