Comments (11)
Appears that colorize(�)
does work, but is not documented. That reforms the feature request to updating the colorize()
documentation.
from commandhelper.
The issue I'm having...
from a YML file, I have:
niceName: '&#FF00BBTest &1T&2e&3s&4t 󙀸Test'
Then I read it in:
@char = read('./rpgClasses/'.@class)
@char = yml_decode(@char)
Then I print it:
ptellraw(@player, array(array(text: colorize(@char['niceName']))))
But it looks like:
https://i.imgur.com/1AI5GY2.png
The first word is a completely wrong color (looks like AQUA), and the 3rd word looks more like DARK_GRAY on my screenshot, and more like GRAY on yours. The hex colors are becoming the "standard" minecraft/terminal colors for me
from commandhelper.
Oh, that's because you're using ptellraw(), which doesn't really support hex colors in the text value. (it seems to be using the last color code from the hex code, in this case: 'B') Use text component colors there instead.
from commandhelper.
e.g. ptellraw(@player, array(array(color: '#FF00BB', text: 'Test')))
from commandhelper.
What about trying to do multiple fancy color codes?
&#FF0000T&#BB0000e󖶀s񐤐t
I would still like to be able to easily do that
edit: oh wait, are you saying i should reopen this as a feature request to ptellraw?
from commandhelper.
Multiple colors would require multiple text components.
ptellraw(@player, array(array(color: '#FF0000', text: 'T'), array(color: '#BB0000, text: 'e'), array(color: '#880000', text: 's'), array(color: '#330000', text: 't')))
This is just the json text format mojang uses. https://minecraft.fandom.com/wiki/Raw_JSON_text_format
from commandhelper.
So are you saying I can't have a feature request to simplify this process?
Like how would I store a complicated colored name in a yaml file? I mean since ptellraw supports standard color codes already, I feel it should also support hex.
from commandhelper.
It's complicated. You're using ptellraw(), which expects a specific vanilla format. The hex code format was never vanilla to begin with. So while the client can still handle the old color codes, the hex format is not supported. It only works with msg() because Spigot converts hex color codes to the json format before sending it to the client. I wrote some rough code on my server to approximately convert to mojang json text format, but an alternative some people are using is minimessage() in CHPaper. It's more 1:1 with the json format. https://docs.advntr.dev/minimessage/format.html
from commandhelper.
Oh wow okay, I'm using CHPaper already and I see that minimessage() is supported there... would that more or less be able to fully replace ptellraw() for me?
from commandhelper.
Yes. It supports all the most common features that you'd likely use. There's pros and cons to each approach, but I think minimessage would fit your use case quite well, if you like the format.
from commandhelper.
We should still update the docs for colorize to indicate that they support hex colors.
from commandhelper.
Related Issues (20)
- Core exception when using stop_named_sound
- Provide schema for Persistence Network
- Provide `nocatch` keyword HOT 4
- ba_get_bytes() (always?) returns a zero-size byte_array
- [Feature request] has_inventory
- pfacing resets player velocity to 0 HOT 2
- entity_spec and set_entity_spec do not have support for InLove
- Possible EOFException in SerializedPersistence during recompile HOT 2
- add support for tools/items in break_block
- [BUG] set_pinv(pinv()) clears BlockStateTag values
- item_swap event docs don't match actual behavior HOT 1
- set_pinv(pinv()) clears EntityTag values HOT 3
- False BlockState default values (also enforced after set_pinv(pinv()) ) HOT 1
- Using switch_ic the break() function gives a compile error HOT 1
- [Feature request] InventoryPickupItemEvent and InventoryMoveItemEvent
- Errors with persistence can leak DB password in error messages
- Using unexisting functions in `foreach(... in ...) {}` syntax results in unexpected additional compile errors
- "@var was already defined" runtime error on typed foreach loop variable HOT 1
- Improve handling of offline players during events HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from commandhelper.