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 ChatAPI #47
Added ChatAPI #47
Conversation
This wont work, it still uses Bukkit classes and uses dependencies that don't exist in this project. |
i replaced the Bukkit code, with none existing classes because there aren't any replacements available. |
But it won't build, because ConfigurationSerializable, Achievement and ItemStack don't exist in sponge. |
Shall i comment them all out or strip them entirely? I will update this PR if replacement classes are (partially) available and if someone makes a descission to either add the missing dependencies (tell me how i can add them properly) or states that the dependencies won't be added. Don't try to compile it, look at it. |
Copy pasting is not the same as relicensing. |
Can you please explain my mistake to me? |
You took the code from other authors without permission and claimed it as yours in the commit. By open source logic, you have declared the other 2 authors involved as non-existent simply because they are not authors on the commit (which is not possible anyways). |
We need them (the other authors) to come here and specifically say that they'll accept this is basically what turt is saying. |
Is listing them as authors not enough? |
This |
Well, I contributed to the first pr. I only reviewed/merged the second one. So I don't mind ST-DDT taking credit for that. @Ribesg would be the one to ask. |
c368a6d
to
b1babf2
Compare
fc421d8
to
74766ec
Compare
I made the original PR with the help of @ST-DDT and @bendem, this second one is also done by us 3, based on this original PR and on @feildmaster's work. I think that there is not much more than the 4 Yeah, I'm not going to work on Sponge at the moment I think. Note that the Bukkit PR will be added to Glowkit and implemented into Glowstone, but it may be extended with 1.8 features as Glowstone targets 1.8. Afaik Sponge will try to support 1.7, so maybe it isn't needed here. Also note that keeping the 4 main classes as they are will help implementing SpongeAPI in Glowstone at a later point. |
duplication of #15 |
It would be duplicated if it was the same implementation, this is another one and it is worth comparing them imo. |
@ST-DDT The build failed to complete. Please resolve this issue to have the PR reviewed further. Formatting will be checked. |
import java.util.regex.Pattern; | ||
|
||
/** | ||
* All supported formatting options for chat and other styled messages |
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 period
@ryantheleach Is there somewhere an definition page with the |
I've ripped them straight from 1.8 mcp pre release code. Change_Page is used in books as links that change pages, and TWITCH_USER_INFO I assume is used for bringing up options for twitch users. Change_Page is currently not used by chat at all, but is this API for text components or chat components? Should there be yet more interfaces for chat components that inherit from text components? Twitch_User_Info is used by chat, but doesn't get sent by the server in normal circumstances, instead it is added to the chat window by the twitch integration. Regardless, the server still contains the code relating to this click event, so am unsure what the result would be of a server sending a twitch click event. This should probably be tested. |
TWITCH_USER_INFO and OPEN_FILE are unusable from the server under normal circumstances. The client is set to ignore anything with those actions coming from the server. CHANGE_PAGE is used in book display, but has no function in chat. |
This PR being originally a Bukkit PR, there was no client-side things in it. I'm not much into Sponge, but as Sponge will be on top of Forge AFAIK, I don't know if they should be added or not. |
@ryantheleach Can you please lookup the data value classes? I will add them using the following assumptions: |
@Kobata You are absolutely right. I missed that method. for some reason change_page is allowed in chat however... @ST-DDT Minecraft uses strings for all the click events, regardless of type, I'm unsure if this would be wise to replicate, or if it could prove to be a problem in the future if something changes. The twitch string is a twitch username, instead of a minecraft username as well. I can't find an instance of change_page where it is used in the code where the field is populated with data, I assume the only place would be if a click event was generated by json de-serialization, or edited externally... but as I said earlier clickevent only ever uses strings. |
@ryantheleach ok i will change the data class of Twitch to String. Change Page stays as it is. |
I have a proposal on how to implement the score and selector message parts (mostly used by client) First i will move the (localized) text stuff to a new class Inheritance Overview This will also allow custom message types. Message Serialization
Example Implementation: Feedback appreciated |
What's the point of an empty interface if all the implementations extend only one abstract class? Just have |
Custom implementations may not need all the extra data that can be connected to a MessagePart (namely TextHover, TextClickAction, (insertion and extra)) |
@ST-DDT when you say custom components, do you mean true custom components that would be sent to the client? Or would the custom components be able to be evaluated server side before sending to the client? I had an idea that player specific formatting could be implemented as custom components by a plugin, then evaluated at the last moment by the server. |
Yes truly custom components. Ill start writing the code for TextFormatting handler soon. |
In order to consolidate this and other chat formatting PRs, I've decided to work on this on a branch of Sponge API at feature/chat. Specifically, most changes are in org.spongepowered.api.chat. I've made sure to keep account of all features in the current PRs, as well as simplify things a bit. Here's what it will look like eventually: RawMessage myMessage = new RawMessageBuilder()
.setText("myText")
.setStyle(TextStyle.AQUA.and(TextStyle.UNDERLINE).and(TextStyle.ITALICS))
.setClickAction(clickActionFactory.openUrl("http://example.com/"))
.addExtra(
new RawMessageBuilder()
.setText("otherText")
.setStyle(TextStyle.RESET)
.build()
)
.build(); I will also eventually replicate some of your |
Suggestion for a text/chat API supporting all features introduced in 1.7 and later:
Bukkit/Bukkit#1111
Added integration to
Title
API.This API is also meant to be used with other features introduced in 1.8 (signs, books...).
All authors gave permission to relicence it under MIT.
Due to a lack of matching classes i copy/pasted it just yet.
Any suggestions for improvements?
PR Breakdown:
This PR adds a builder interface based on a
Message
to which you appendMessagePart
s to build a rich chat message containing (or not):TextFormatting
compatible text, a localized text, anEntity
name, anItemStack
name or anAchievement
name ;TextHover
text (showing a multi-color multi-line text, anAchievement
description, anEntity
description or anItemStack
description) ;TextClickAction
(executing commands / sending chat message, proposing commands / proposing chat message, or opening urls (actually opens the prompt), ...).These messages handle colors and formatting using
TextFormatting
just like standard messages.Many (many) shortcuts have been added to
Message
to make it easier to append specific elements, seeMessage
static constructors, append methods and insert methods.Authors: