Solved JSON in an action bar?

Discussion in 'Plugin Development' started by bowlerguy66, Nov 25, 2017.

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

    bowlerguy66

    I'm looking to put something in the action bar (image) but the api I'm using requires a JSON object to have colors and italics. My question is how do I create a JSON object?
     
  2. Offline

    Unknown123

    Please give us more Informations. With API are you using? You should be able to use § codes in jsom too.
     
  3. JSON should be able to use a string, so if you use the JSON Syntax with ChatColor.translateAlternateColorCodes('&', "&4TEST"); it should work since that method returns a string.
     
  4. Offline

    bowlerguy66

  5. Offline

    Unknown123

  6. May I ask why not? If Bukkit built something in specifically to make it more user friendly to use ‘&’ then why ignore it? It makes writing configs and everything a lot more user friendly.
     
    timtower likes this.
  7. Offline

    Unknown123

    @OfficerDeveloper I meant that if you hard code the string, you should use § directly. And translateAlternateColorCodes is unnecessary because you can just replace it with &. So you will never need the ChatColor class.
     
  8. @Unknown123 If you meant hard coding it, then my argument still applies. You're either going to use what I said or use a '&' symbol in your string but do .replaceAll('&', '§') which is still inefficient because it isn't a key on a keyboard that's readily available. The method that comes along with ChatColor uses all of Minecraft's color codes exactly like the symbol § would, if not more efficiently.

    And if the OP wanted that message to be customizable in the config, it would be a lot more efficient to use the translate method.

    [​IMG]
     
  9. Offline

    Unknown123

  10. Point is why would I go through that effort if I can use an easier resource provided to me .-.
     
  11. Offline

    Unknown123

    @OfficerDeveloper If you can make a plugin, you should also know the color codes. And it is shorter.
     
  12. It's not a matter of "knowing color codes" you still need to know the color codes to do \u00A7 or §7.

    In any plugin, I do what would save me time and is correct. Having a compiler allows me to do Chatcolor. and autocomplete the method and have me type one single character to make it more friendly, I would rather do that.

    Also using \u00A7 is not shorter because it requires me to go through every chat color placed and replace it with that.

    [​IMG]

    Those codes apply no matter whether it is a & a \u00A or a § so it's not a matter of knowing color codes, that was never part of the point.

    You're bringing up empty points to keep trying to prove your point instead of admitting that I was correct .-.
     
  13. Offline

    Unknown123

    @OfficerDeveloper ChatColor. Is a little bit slower than specify the color directly
     
  14. Online

    timtower Administrator Administrator Moderator

    And how much then? Is it noticeable?
    Java is generally also more resource intensive than c++, do you want to switch languages as well?
    And it also depends on how often you call it, if you call it once in the onEnable then the startup takes a couple extra nanoseconds but no difference besides that.
     
  15. Offline

    Unknown123

Thread Status:
Not open for further replies.

Share This Page