Skip to content
This repository has been archived by the owner on Aug 31, 2019. It is now read-only.

Custom text rendering API #225

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Custom text rendering API #225

wants to merge 1 commit into from

Conversation

jedediah
Copy link
Member

Implements OvercastNetwork/minecraft-api#6

RenderableComponent holds an original BaseComponent and a map of UUID -> BaseComponent rendered for each viewer. It also implements IChatBaseComponent, so it can be smuggled through without adding any fields to packets. The packets that use it implement Renderable, which PlayerConnection calls to render the text for each viewer, on the main thread, just before sending the packet. The player's UUID is stored in PacketDataSerializer, and used to lookup the rendered text on the I/O thread.

@@ -18,12 +18,14 @@
+ public SocketAddress l;
+ public java.util.UUID spoofedUUID;
+ public com.mojang.authlib.properties.Property[] spoofedProfile;
+
+ public int protocolVersion = Protocol.LATEST;
+ public java.util.UUID playerId;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this

+
+ @Override
+ public void render(Player viewer) {
+ ((RenderableComponent) a).render(viewer);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RenderableComponent.render()

for(Plugin plugin : getPluginManager().getPlugins()) {
if(plugin.isEnabled()) {
for(Provider<TextRenderer> renderer : plugin.textRenderers()) {
text = renderer.get().render(this, text, viewer);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

catch exceptions


import org.bukkit.entity.Player;

public interface Renderable {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename this to something more specific


import static com.google.common.base.Preconditions.checkNotNull;

public class RenderableComponent extends ChatBaseComponent {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs docs

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant