Development Assistance Plugin Coding Problem

Discussion in 'Plugin Help/Development/Requests' started by mc_myster, Jan 28, 2015.

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

    mc_myster

    I am creating a plugin, i need more than 1 color for it, the code for a normal command such as "/server" which says to you "Hi (Player) welcome to the server!" in a certain color the code would be "sender.sendMessage(ChatClor.(COLOR) + "Hi (Player) welcome to the server!")); but how would i make it multiple colors such as "Hi (Player) welcome to the server!" AND also when i allow people to modify what it says to you in a config they can add in color with &(color) how do i let them ?
     
  2. Offline

    timtower Administrator Administrator Moderator

    @mc_myster ChatColor.translateAlternateColorCode('&',<string here>);
    Changed prefix btw.
     
  3. Offline

    pie_flavor

    @mc_myster Or, for your original problem, it helps to remember that ChatColor.<color> is a String. So you can do ChatColor.AQUA + "Hi "+ ChatColor.BLUE + player.getName() + ChatColor.AQUA + " welcome to the server!"
     
  4. Offline

    mc_myster

    Oh yeh thx allot, i forgot about that !

    Thanks allot :)

    EDIT by Timtower: merged posts
     
    Last edited by a moderator: Jan 28, 2015
  5. Offline

    DoggyCode™

    @mc_myster

    You don't need to use color codes anymore in general color messages, you can use:

    sender.sendMessage("§<color integer from minecraft><message> §<color integer from minecraft><message>");

    § Is used the exact same way in Bukkit coding, as & ingame.
     
  6. Offline

    timtower Administrator Administrator Moderator

  7. Offline

    DoggyCode™

    @timtower

    Minecraft very rarely changes it, all the time I have played minecraft (2 years about)... Minecraft has never changed it... It only makes the job easier to use the method I stated...
     
  8. Offline

    timtower Administrator Administrator Moderator

    @DoggyCode™ Then why did they make the ChatColor enum in the first place? Also with the ChatColor you don't need to remember colors with their numbers.
     
  9. Offline

    pie_flavor

    @timtower ChatColor enum was made because people would rather use an enum than memorize the color codes and use the US-International keyboard to type or copy/paste the § symbol. However, if your keyboard is set up that way already or you don't mind, and you've already memorized the hex sequence for colors, then it'd be a good idea to just use that because Minecraft has NEVER changed it, and it takes up less space.
     
Thread Status:
Not open for further replies.

Share This Page