diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/render/AnsiComponentAppendable.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/render/AnsiComponentAppendable.java index 9505a8b2..129c297a 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/render/AnsiComponentAppendable.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/render/AnsiComponentAppendable.java @@ -48,6 +48,11 @@ final class AnsiComponentAppendable implements ComponentAppendable { this.provider = provider; } + @Override + public MetadataContainer getContext() { + return context; + } + @Override public ComponentAppendable append(final Component component) { escape(); @@ -62,7 +67,7 @@ public ComponentAppendable append(final Component component) { } final var renderer = provider.getRenderer(component); - if (renderer != null) renderer.render(component, this, context); + if (renderer != null) renderer.render(component, this); { final var popped = styles.pop(); diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/render/ComponentAppendable.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/render/ComponentAppendable.java index 4672f872..c044c364 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/render/ComponentAppendable.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/render/ComponentAppendable.java @@ -50,6 +50,8 @@ static ComponentAppendable mindustry(final MetadataContainer metadata) { metadata, DistributorProvider.get().getComponentRendererProvider()); } + MetadataContainer getContext(); + ComponentAppendable append(final Component component); @Override diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/render/ComponentRenderer.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/render/ComponentRenderer.java index eb1e34dd..f6c2f640 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/render/ComponentRenderer.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/render/ComponentRenderer.java @@ -19,13 +19,12 @@ package com.xpdustry.distributor.api.component.render; import com.xpdustry.distributor.api.component.Component; -import com.xpdustry.distributor.api.metadata.MetadataContainer; public interface ComponentRenderer { static ComponentRenderer noop() { - return (component, appendable, metadata) -> {}; + return (component, appendable) -> {}; } - void render(final T component, final ComponentAppendable appendable, final MetadataContainer metadata); + void render(final T component, final ComponentAppendable appendable); } diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/render/MindustryComponentAppendable.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/render/MindustryComponentAppendable.java index 728387f6..6811afd7 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/render/MindustryComponentAppendable.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/render/MindustryComponentAppendable.java @@ -35,6 +35,11 @@ final class MindustryComponentAppendable implements ComponentAppendable { this.provider = provider; } + @Override + public MetadataContainer getContext() { + return context; + } + @Override public ComponentAppendable append(final Component component) { { @@ -48,7 +53,7 @@ public ComponentAppendable append(final Component component) { } final var renderer = provider.getRenderer(component); - if (renderer != null) renderer.render(component, this, context); + if (renderer != null) renderer.render(component, this); { final var popped = colors.pop(); diff --git a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/render/PlainComponentAppendable.java b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/render/PlainComponentAppendable.java index 43b4600f..41c9a3df 100644 --- a/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/render/PlainComponentAppendable.java +++ b/distributor-common-api/src/main/java/com/xpdustry/distributor/api/component/render/PlainComponentAppendable.java @@ -33,10 +33,15 @@ public PlainComponentAppendable(final MetadataContainer context, final Component this.provider = provider; } + @Override + public MetadataContainer getContext() { + return context; + } + @Override public ComponentAppendable append(final Component component) { final var renderer = this.provider.getRenderer(component); - if (renderer != null) renderer.render(component, this, this.context); + if (renderer != null) renderer.render(component, this); return this; } diff --git a/distributor-common/src/main/java/com/xpdustry/distributor/common/component/render/StandardComponentRendererProvider.java b/distributor-common/src/main/java/com/xpdustry/distributor/common/component/render/StandardComponentRendererProvider.java index f404faf1..a01952a3 100644 --- a/distributor-common/src/main/java/com/xpdustry/distributor/common/component/render/StandardComponentRendererProvider.java +++ b/distributor-common/src/main/java/com/xpdustry/distributor/common/component/render/StandardComponentRendererProvider.java @@ -29,7 +29,6 @@ import com.xpdustry.distributor.api.component.render.ComponentAppendable; import com.xpdustry.distributor.api.component.render.ComponentRenderer; import com.xpdustry.distributor.api.component.render.ComponentRendererProvider; -import com.xpdustry.distributor.api.metadata.MetadataContainer; import com.xpdustry.distributor.api.translation.ComponentAwareTranslation; import java.time.ZoneId; import java.util.Locale; @@ -60,8 +59,7 @@ private static final class TextComponentRenderer implements ComponentRenderer component, - final ComponentAppendable appendable, - final MetadataContainer metadata) { + public void render(final ValueComponent component, final ComponentAppendable appendable) { appendable.append(component.getValue().toString()); } }