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)));
}
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);
}
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)));
}
Aggregations