-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix some tag's arguments not running through parser
- Loading branch information
Showing
4 changed files
with
71 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/main/java/eu/pb4/placeholders/api/node/parent/DynamicColorNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package eu.pb4.placeholders.api.node.parent; | ||
|
||
import eu.pb4.placeholders.api.ParserContext; | ||
import eu.pb4.placeholders.api.node.TextNode; | ||
import eu.pb4.placeholders.api.parsers.NodeParser; | ||
import net.minecraft.text.Style; | ||
import net.minecraft.text.TextColor; | ||
|
||
import java.util.Arrays; | ||
|
||
public final class DynamicColorNode extends SimpleStylingNode { | ||
private final TextNode color; | ||
|
||
public DynamicColorNode(TextNode[] children, TextNode color) { | ||
super(children); | ||
this.color = color; | ||
} | ||
|
||
@Override | ||
public boolean isDynamicNoChildren() { | ||
return this.color.isDynamic(); | ||
} | ||
|
||
@Override | ||
protected Style style(ParserContext context) { | ||
var c = TextColor.parse(color.toText(context).getString()); | ||
return c.result().map(Style.EMPTY::withColor).orElse(Style.EMPTY); | ||
} | ||
|
||
@Override | ||
public ParentTextNode copyWith(TextNode[] children) { | ||
return new DynamicColorNode(children, this.color); | ||
} | ||
|
||
@Override | ||
public ParentTextNode copyWith(TextNode[] children, NodeParser parser) { | ||
return new DynamicColorNode(children, parser.parseNode(color)); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "ColorNode{" + | ||
"color=" + color + | ||
", children=" + Arrays.toString(children) + | ||
'}'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters