-
-
Notifications
You must be signed in to change notification settings - Fork 344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added a system for creating chat messages with a style. #15
Conversation
haha...you don't have the licenses in. Make sure to run gradle :p |
*/ | ||
@Override | ||
public ChatAction getAction() { | ||
// TODO Auto-generated method stub |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure to get rid of these
Fixed the licences and moved everything to a util package. No point in it being in the api package if it's a utility. |
Looks good :) It may require some work to implement, but it'll be worth of it, in my opinion. |
Sponge should be as lightweight as possible. No need to clutter it with extras. Plugins should be good enough to add this sort of functionality. Think fast. Think efficient. |
@unenergizer what API would you expect a plugin to need in order to do this? |
*/ | ||
void setStyle(ChatStyle style); | ||
|
||
IChatMessage createCopy(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing javadoc ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also this could simply be copy or implement Cloneable and call it clone()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should also be made clear whether this is a shallow copy or a deep copy.
Plugins cant do this without nms unless we add sendRawMessage |
This is what I hated about bukkit. "Let plugins implement this, let plugins implement that". Led to a huge clusterduck that is permissions. Also why would you leave something as essential as this up to plugins? |
SHOW_TEXT("show_text", ActionType.HOVER), | ||
SHOW_ACHIVEMENT("show_achivement", ActionType.HOVER), | ||
SHOW_ITEM("show_item", ActionType.HOVER), | ||
; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we not use enums for actions? Like as a rule? They've very limiting, and while I can't think of a reason why that is bad here, for example in bukkit you could not provide custom teleport reasons because they were restricted to the enum.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case it makes sense. Minecraft cannot have more hover actions than already listed. If Minecraft adds more then the enum can be updated to match.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now yes, but if we ever also modify the client... Just... ugh enums are bad for dynamic content.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, yes, I forgot Sponge is both. This should be changed to a final class
with constants perhaps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I see things like this more of a quick and easy access thing. They shouldn't be a limiting factor.
Perhaps the same concept should apply to the colors as well, something else might add more colors. |
I've seen other implementations of this idea and I'll say the same thing I've said in the past: _Why are the _ChatMessage* interface's methods not fluent?* The underlying ChatMessageComponent API is fluent so wrapping an API around it which is not is a step backwards. appendSibling is bad and appendSiblings is frankly stupid and there should instead be simple overloads for appending components, I'd suggest following the established and well-known pattern used by StringBuilder of multiple overloads all called append which simply take different arguments and provide a fluent interface:
Using fluent interface allows use of both fluent and non-fluent usage so there's no excuse not to have appender methods return the original object reference. |
package org.spongepowered.util.chat; | ||
|
||
import org.spongepowered.util.chat.ChatAction.ActionType; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be a javadoc here.
What is the point of providing both an interface and an implementation in the API? |
@unenergizer Actually, for Sponge to be more efficient, it should add APIs like these. Stops 5 different plugins including their own APIs and possibly not as well optimized as the Sponge one could be. |
@iKeirNez he wasn't saying this API shouldn't exist, he was saying that this PR pulls implementation into the API, which is a huge no-no. Once @killjoy1221 revises this into a sensible PR containing an API and another with implementation, then it can be considered. |
If someone can suggest a way for devs to create a new chat message without implementing it themselves, I'm all ears. Maybe a method somewhere else that creates a blank message? |
@killjoy1221 what do you mean? The implementation should be in Sponge not in SpongeAPI. You have implementation in an API project and the chances of this being pulled are pretty much zero until you fix that. |
@Mumfrey So in general every plugin which needs to use |
I moved things back into api and removed the implementation. I'm expecting someone else to create a class to create new instances of a lot of this. I also changed most enums into final classes / fields. Plugin devs can create their own now. In the ChatMessage, there's more append methods and it behaves like StringBuilder. I removed the change in Game in order to avoid merge conflicts. |
@MazeXD I'm not sure you understand the concept of an API, just because the implementation is elsewhere does not mean you can't rely on the API. This is why factory and builder pattern are important, plus provider. For example, you may have access to an IChatMessageFactory via your plugin, or via a general provider interface, you don't go new ChatMessage() instead you go WhateverProvider.getChatMessageFactory().createChatMessage() which returns the interface and then you work with that (for example). It's perfectly possible and normal to abstract this way. It's then up to the implementation to actually flesh out the provider, the factory and the chat message instance itself. |
@Mumfrey This would be called a Factory or Repository pattern then I think.
|
Fixed that NPE and added a factory. |
* Gets the text to be inserted in chat when shift clicked. | ||
* | ||
* @return The text to be inserted | ||
* @since 1.8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
Remove some methods in TextMessage in favor of MessageBuilder Signed-off-by: Matthew Messinger <mattmess1221@gmail.com>
…o chat Conflicts: src/main/java/org/spongepowered/api/Game.java
(going to all chat formatting PR's) |
@killjoy1221 Please identify how this PR is better/worse than #47 and why it should be pulled, thanks! |
@turt2live aside from the fact that that PR doesn't pass the build, I'm set for 1.8. #47 uses lots of enums and final classes. I use final classes (previously enums for extensibility) and interfaces. 47 was filled with implementation. My messages are general purpose, so we can support most types of messages (text, translate, score, selector). Additionally, I provide a builder. You're free to use it for your entity component system if that's how it works. |
/** | ||
* Builder for easily creating messages. | ||
*/ | ||
public interface MessageBuilder extends Builder<MessageBuilder, TextMessage> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious; but why are you using "append" and not "add"? Because the StringBuilder names it like that as well?
I tend to try to use shorter names when I do "chainable" classes/interfaces, since I don't want to get over my 100 character limit per line ;)
Can you please give me a hint what i have to add to provide 1.8 support? |
Insertions, score messages, and selector messages. See http://wiki.vg/Chat |
Thanks for pointing that out. i will look into that, it shouldn't be that hard to implement |
Usually their used in commands. They include @A, @p, @r, @e. On Sunday, September 14, 2014, ST-DDT notifications@github.com wrote:
|
I have never used them myself, will |
Experiment with them using /tellraw. On Sunday, September 14, 2014, ST-DDT notifications@github.com wrote:
|
Well those selectors aren't really chat format things -- they're command On Sun, Sep 14, 2014 at 02:07:32PM -0700, ST-DDT wrote:
|
@zml2008 They are relevant, because you can send them as chat message. |
Added a FactoryProvider Added parameters when making a new translated message Signed-off-by: Matthew Messinger <mattmess1221@gmail.com>
@killjoy1221 Please fix the mergability concerns for further review, thanks. |
Please see my comment on the other chat PR for updates on how this API is progressing. I'm going to close this PR for now since it seems to have stagnated. |
Supports colors, fancy stylings, and click/hover events.
The sooner we don't need to use legacy chat the better.