Giter VIP home page Giter VIP logo

Comments (21)

lucko avatar lucko commented on July 22, 2024 2

@PurpleIsEverything That's fine - I often store messages like that too. However, the color coded messages need to be deserialized using the appropriate method on the ComponentSerializers.LEGACY instance, not using LegacyChatColorUtils.

@astei No reason why plugin authors should be performing any sort of legacy text manipulation - the Velocity API accepts Components in all places. Soooo I still stand by my opinion that the class has no place being in the API at all 😄

from velocity.

astei avatar astei commented on July 22, 2024 2

By that, he means that in general, you should be working in the JSON world, and only use legacy text in limited situations (backwards compatibility, reading from configuration, ...) That is, only deserialize and serialize legacy text, never manipulate it.

from velocity.

astei avatar astei commented on July 22, 2024 1

ComponentSerializers.LEGACY does what most people need with components, especially since it takes in a custom format code. I will open a PR to remove the translate method.

I am keeping LegacyChatColorUtils#removeFormatting(): ComponentSerializers.PLAIN.serialize(ComponentSerializers.LEGACY.deserialize("")) isn't particularly concise and does more work than it needs to.

from velocity.

astei avatar astei commented on July 22, 2024 1

@DoNotSpamPls ComponentSerializers.LEGACY.deserialize(String, char) does what you need, just pass in '&'.

from velocity.

phase avatar phase commented on July 22, 2024

It is probably sending the message as 2 separate messages, which means that the second message doesn't have any color codes in front of it. An easy fix would to be to add color codes after the linebreak.

from velocity.

DoNotSpamPls avatar DoNotSpamPls commented on July 22, 2024

He's probably talking about the automatic line breaks when the message gets longer than 1 line. I fixed that by using the legacy ComponentSerializer (or whatever that is called). But yeah, it's a bit of an issue.

from velocity.

Leymooo avatar Leymooo commented on July 22, 2024

try use
ComponentSerializers.LEGACY.deserialize(message, '&');

from velocity.

astei avatar astei commented on July 22, 2024

This isn't an issue in Velocity, AFAIK. If there is a bug, it is in KyoriPowered/text.

from velocity.

lucko avatar lucko commented on July 22, 2024

@BukkitTNT Can you show the code you're using to send the message?

from velocity.

DoNotSpamPls avatar DoNotSpamPls commented on July 22, 2024

@lucko while I'm not mr. BukkitTNT, with this code you can see the bug for yourself, this is the result:

The raw TextComponent.builder() does not have this issue, so the issue I opened above is really invalid, it seems to be a bug with the LegacyChatColorsUtil.translate() thing

from velocity.

lucko avatar lucko commented on July 22, 2024

Your code doesn't compile.

Line 35:

@NonNull String message = ComponentSerializers.LEGACY.deserialize(builder.substring( 0, builder.length() - 1 ));

is not valid.

The deserialize method does not return a string.

from velocity.

lucko avatar lucko commented on July 22, 2024

LegacyChatColorUtils shouldn't really be in the Velocity API. It has no valid use in plugins.

The correct/improved version of the code you gave is as follows.

https://gist.github.com/lucko/cbef3c9e383201163371f68d6f4ea244

from velocity.

astei avatar astei commented on July 22, 2024

@lucko I really do agree with you here, but I'm loathe to make any more breaking API changes. I have two in the works already.

I do however find removeFormatting to be useful enough that it ought to stay.

from velocity.

lucko avatar lucko commented on July 22, 2024

Better to make breakages now as opposed to later.

I'd argue that any current usages of that class are by mistake - you're doing plugin authors a favour by removing it.

from velocity.

DoNotSpamPls avatar DoNotSpamPls commented on July 22, 2024

@lucko whoops, I meant to remove the ComponentSerializers part entirely, and just leave the LegacyChatColorUtils above.

from velocity.

lucko avatar lucko commented on July 22, 2024

You shouldn't be using LegacyChatColorUtils. I've posted the correct usage above.

As I said in the Kyori/text issue:

The 'white text after line break' issue usually occurs when legacy formatting codes are used inside the "text" component instead of using the color attribute.

which is exactly what you're doing. 😉

from velocity.

PurpleIsEverything avatar PurpleIsEverything commented on July 22, 2024

I personally very rarely hard-core chat messages so I do make use of the & color code deserialization.

from velocity.

DoNotSpamPls avatar DoNotSpamPls commented on July 22, 2024

@PurpleIsEverything lucko has a point though, there is zero need to use the LegacyChatColorUtils, because the legacy deserializer from Kyori/text can already handle that 😃

from velocity.

PurpleIsEverything avatar PurpleIsEverything commented on July 22, 2024

Sounds good to me too.

from velocity.

DoNotSpamPls avatar DoNotSpamPls commented on July 22, 2024

@lucko as a plugin author, I use the legacy deserializer to parse messages from the config that use the & color code, since having JSON monstrosities in the config isn't really very user-friendly. I'd much rather give them the option to just type "&e&lHello world!" and me parsing it from there 😛

from velocity.

DoNotSpamPls avatar DoNotSpamPls commented on July 22, 2024

Yes, I'm using that, I'm just talking about lucko's opinion that no reason why plugin authors should be performing any sort of legacy text manipulation. Otherwise I'm fine with the removal of the utility found in Velocity

from velocity.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.