Search in sources :

Example 1 with TestAudience

use of me.dreamerzero.miniplaceholders.testobjects.TestAudience in project MiniPlaceholders by 4drian3d.

the class PlaceholderTest method filteredExpansion.

@Test
@DisplayName("Filtered Expansion")
void filteredExpansion() {
    Expansion expansion = Expansion.builder("filter").audiencePlaceholder("name", (aud, queue, ctx) -> Tag.selfClosingInserting(Component.text(((TestAudience) aud).getName()))).filter(TestAudience.class).build();
    Audience player = new TestAudience("TestPlayer04");
    Audience emptyAudience = Audience.empty();
    String string = "Player Name: <filter_name>";
    Component playerExpected = Component.text("Player Name: TestPlayer04");
    Component emptyExpected = Component.text("Player Name: <filter_name>");
    assertEquals(playerExpected, MiniMessage.miniMessage().deserialize(string, expansion.audiencePlaceholders(player)));
    assertEquals(emptyExpected, MiniMessage.miniMessage().deserialize(string, expansion.audiencePlaceholders(emptyAudience)));
}
Also used : TestAudience(me.dreamerzero.miniplaceholders.testobjects.TestAudience) Audience(net.kyori.adventure.audience.Audience) TestAudience(me.dreamerzero.miniplaceholders.testobjects.TestAudience) Component(net.kyori.adventure.text.Component) Expansion(me.dreamerzero.miniplaceholders.api.Expansion) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 2 with TestAudience

use of me.dreamerzero.miniplaceholders.testobjects.TestAudience in project MiniPlaceholders by 4drian3d.

the class PlaceholderTest method audienceExpansionPlaceholdersTest.

@Test
@DisplayName("Audience Placeholder Test")
void audienceExpansionPlaceholdersTest() {
    TestAudience player = new TestAudience("4drian3d");
    Expansion expansion = Expansion.builder("example").audiencePlaceholder("name", (aud, queue, ctx) -> Tag.selfClosingInserting(Component.text(((TestAudience) aud).getName()))).build();
    final Component expected = Component.text("Player Name: 4drian3d");
    final Component result = MiniMessage.miniMessage().deserialize("Player Name: <example_name>", expansion.audiencePlaceholders(player));
    assertEquals(expected, result);
}
Also used : TestAudience(me.dreamerzero.miniplaceholders.testobjects.TestAudience) Test(org.junit.jupiter.api.Test) Tag(net.kyori.adventure.text.minimessage.tag.Tag) MiniPlaceholders(me.dreamerzero.miniplaceholders.api.MiniPlaceholders) Audience(net.kyori.adventure.audience.Audience) PlainTextComponentSerializer(net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer) Component(net.kyori.adventure.text.Component) TestAudience(me.dreamerzero.miniplaceholders.testobjects.TestAudience) MiniMessage(net.kyori.adventure.text.minimessage.MiniMessage) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Expansion(me.dreamerzero.miniplaceholders.api.Expansion) NamedTextColor(net.kyori.adventure.text.format.NamedTextColor) DisplayName(org.junit.jupiter.api.DisplayName) Component(net.kyori.adventure.text.Component) Expansion(me.dreamerzero.miniplaceholders.api.Expansion) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 3 with TestAudience

use of me.dreamerzero.miniplaceholders.testobjects.TestAudience in project MiniPlaceholders by 4drian3d.

the class PlaceholderTest method relationalExpansionPlaceholdersTest.

@Test
@DisplayName("Relational Placeholder Test")
void relationalExpansionPlaceholdersTest() {
    Audience p1 = new TestAudience("PlayerOne");
    Audience p2 = new TestAudience("PlayerTwo");
    Expansion expansion = Expansion.builder("relational").relationalPlaceholder("enemy", (aud, otheraud, queue, ctx) -> Tag.selfClosingInserting(this.isEnemy(((TestAudience) aud), ((TestAudience) otheraud)) ? Component.text("Enemy", NamedTextColor.RED) : Component.text("Neutral", NamedTextColor.GREEN))).build();
    assertEquals(MiniMessage.miniMessage().deserialize("You are <red>Enemy"), MiniMessage.miniMessage().deserialize("You are <relational_rel_enemy>", expansion.relationalPlaceholders(p1, p2)));
}
Also used : TestAudience(me.dreamerzero.miniplaceholders.testobjects.TestAudience) Test(org.junit.jupiter.api.Test) Tag(net.kyori.adventure.text.minimessage.tag.Tag) MiniPlaceholders(me.dreamerzero.miniplaceholders.api.MiniPlaceholders) Audience(net.kyori.adventure.audience.Audience) PlainTextComponentSerializer(net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer) Component(net.kyori.adventure.text.Component) TestAudience(me.dreamerzero.miniplaceholders.testobjects.TestAudience) MiniMessage(net.kyori.adventure.text.minimessage.MiniMessage) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Expansion(me.dreamerzero.miniplaceholders.api.Expansion) NamedTextColor(net.kyori.adventure.text.format.NamedTextColor) DisplayName(org.junit.jupiter.api.DisplayName) Audience(net.kyori.adventure.audience.Audience) TestAudience(me.dreamerzero.miniplaceholders.testobjects.TestAudience) Expansion(me.dreamerzero.miniplaceholders.api.Expansion) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

Expansion (me.dreamerzero.miniplaceholders.api.Expansion)3 TestAudience (me.dreamerzero.miniplaceholders.testobjects.TestAudience)3 Audience (net.kyori.adventure.audience.Audience)3 Component (net.kyori.adventure.text.Component)3 DisplayName (org.junit.jupiter.api.DisplayName)3 Test (org.junit.jupiter.api.Test)3 MiniPlaceholders (me.dreamerzero.miniplaceholders.api.MiniPlaceholders)2 NamedTextColor (net.kyori.adventure.text.format.NamedTextColor)2 MiniMessage (net.kyori.adventure.text.minimessage.MiniMessage)2 Tag (net.kyori.adventure.text.minimessage.tag.Tag)2 PlainTextComponentSerializer (net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer)2 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)2