Search in sources :

Example 16 with PartiesPlaceholder

use of com.alessiodp.parties.common.addons.internal.PartiesPlaceholder in project Parties by AlessioDP.

the class PartiesPlaceholderTest method testPlaceholderDesc.

@Test
public void testPlaceholderDesc() {
    PartiesPlaceholder placeholder = PartiesPlaceholder.getPlaceholder("desc");
    assertEquals(PartiesPlaceholder.DESC, placeholder);
    assertEquals("", placeholder.formatPlaceholder(player1, party1, "desc"));
    party1.setAccessible(true);
    party1.setDescription("123");
    party1.setAccessible(false);
    assertEquals(party1.getDescription(), placeholder.formatPlaceholder(player1, party1, "desc"));
}
Also used : PartiesPlaceholder(com.alessiodp.parties.common.addons.internal.PartiesPlaceholder) Test(org.junit.jupiter.api.Test)

Example 17 with PartiesPlaceholder

use of com.alessiodp.parties.common.addons.internal.PartiesPlaceholder in project Parties by AlessioDP.

the class PartiesPlaceholderTest method testPlaceholderColorCode.

@Test
public void testPlaceholderColorCode() {
    PartiesPlaceholder placeholder = PartiesPlaceholder.getPlaceholder("color_code");
    assertEquals(PartiesPlaceholder.COLOR_CODE, placeholder);
    assertEquals("", placeholder.formatPlaceholder(player1, party1, "color_code"));
    party1.setAccessible(true);
    party1.setColor(new PartyColorImpl("red", "123", "&c", 0, 0, 0));
    party1.setAccessible(false);
    assertEquals(party1.getColor().getCode(), placeholder.formatPlaceholder(player1, party1, "color_code"));
}
Also used : PartiesPlaceholder(com.alessiodp.parties.common.addons.internal.PartiesPlaceholder) PartyColorImpl(com.alessiodp.parties.common.parties.objects.PartyColorImpl) Test(org.junit.jupiter.api.Test)

Example 18 with PartiesPlaceholder

use of com.alessiodp.parties.common.addons.internal.PartiesPlaceholder in project Parties by AlessioDP.

the class PartiesPlaceholderTest method testPlaceholderExperience.

@Test
public void testPlaceholderExperience() {
    PartiesPlaceholder placeholder = PartiesPlaceholder.getPlaceholder("experience_total");
    assertEquals(PartiesPlaceholder.EXPERIENCE_TOTAL, placeholder);
    assertEquals("0", placeholder.formatPlaceholder(player1, party1, "experience_total"));
    party1.setAccessible(true);
    party1.setExperience(100);
    party1.setAccessible(false);
    assertEquals(Integer.toString((int) party1.getExperience()), placeholder.formatPlaceholder(player1, party1, "experience_total"));
    placeholder = PartiesPlaceholder.getPlaceholder("experience_level");
    assertEquals(PartiesPlaceholder.EXPERIENCE_LEVEL, placeholder);
    placeholder = PartiesPlaceholder.getPlaceholder("experience_level_roman");
    assertEquals(PartiesPlaceholder.EXPERIENCE_LEVEL_ROMAN, placeholder);
    placeholder = PartiesPlaceholder.getPlaceholder("experience_level_experience");
    assertEquals(PartiesPlaceholder.EXPERIENCE_LEVEL_EXPERIENCE, placeholder);
    placeholder = PartiesPlaceholder.getPlaceholder("experience_levelup_necessary");
    assertEquals(PartiesPlaceholder.EXPERIENCE_LEVELUP_NECESSARY, placeholder);
    placeholder = PartiesPlaceholder.getPlaceholder("experience_levelup_current");
    assertEquals(PartiesPlaceholder.EXPERIENCE_LEVELUP_CURRENT, placeholder);
}
Also used : PartiesPlaceholder(com.alessiodp.parties.common.addons.internal.PartiesPlaceholder) Test(org.junit.jupiter.api.Test)

Example 19 with PartiesPlaceholder

use of com.alessiodp.parties.common.addons.internal.PartiesPlaceholder in project Parties by AlessioDP.

the class PartiesPlaceholderTest method testPlayerInParty.

@Test
public void testPlayerInParty() {
    Messages.PARTIES_OUT_PARTY = "out";
    PartiesPlaceholder placeholder = PartiesPlaceholder.getPlaceholder("out_party");
    assertEquals(PartiesPlaceholder.OUT_PARTY, placeholder);
    assertEquals(Messages.PARTIES_OUT_PARTY, placeholder.formatPlaceholder(player1, null, ""));
    assertEquals("", placeholder.formatPlaceholder(player1, party1, ""));
}
Also used : PartiesPlaceholder(com.alessiodp.parties.common.addons.internal.PartiesPlaceholder) Test(org.junit.jupiter.api.Test)

Example 20 with PartiesPlaceholder

use of com.alessiodp.parties.common.addons.internal.PartiesPlaceholder in project Parties by AlessioDP.

the class PartiesPlaceholderTest method testPlaceholderListPartiesByName.

@Test
public void testPlaceholderListPartiesByName() {
    doAnswer(args -> {
        if (((int) args.getArgument(2)) == 0)
            return Sets.newSet(party1);
        else if (((int) args.getArgument(2)) == 1)
            return Sets.newSet(party2);
        else if (((int) args.getArgument(2)) == 2)
            return Sets.newSet(party3);
        return Sets.newSet();
    }).when(mockDatabaseManager).getListParties(eq(PartiesDatabaseManager.ListOrder.NAME), anyInt(), anyInt());
    PartiesPlaceholder placeholder = PartiesPlaceholder.getPlaceholder("list_parties_by_name_1");
    assertEquals(PartiesPlaceholder.LIST_PARTIES_BY_NAME_NUMBER, placeholder);
    assertEquals(party1.getName(), placeholder.formatPlaceholder(null, null, "list_parties_by_name_1"));
    placeholder = PartiesPlaceholder.getPlaceholder("list_parties_by_name_2");
    assertEquals(PartiesPlaceholder.LIST_PARTIES_BY_NAME_NUMBER, placeholder);
    assertEquals(party2.getName(), placeholder.formatPlaceholder(null, null, "list_parties_by_name_2"));
    // No more parties
    placeholder = PartiesPlaceholder.getPlaceholder("list_parties_by_name_4");
    assertEquals(PartiesPlaceholder.LIST_PARTIES_BY_NAME_NUMBER, placeholder);
    assertEquals("", placeholder.formatPlaceholder(null, null, "list_parties_by_name_4"));
    // Placeholder
    placeholder = PartiesPlaceholder.getPlaceholder("list_parties_by_name_1_id");
    assertEquals(PartiesPlaceholder.LIST_PARTIES_BY_NAME_NUMBER_PLACEHOLDER, placeholder);
    assertEquals(party1.getId().toString(), placeholder.formatPlaceholder(null, null, "list_parties_by_name_1_id"));
}
Also used : PartiesPlaceholder(com.alessiodp.parties.common.addons.internal.PartiesPlaceholder) Test(org.junit.jupiter.api.Test)

Aggregations

PartiesPlaceholder (com.alessiodp.parties.common.addons.internal.PartiesPlaceholder)24 Test (org.junit.jupiter.api.Test)21 PartyColorImpl (com.alessiodp.parties.common.parties.objects.PartyColorImpl)3 PartyImpl (com.alessiodp.parties.common.parties.objects.PartyImpl)2 PartyPlayerImpl (com.alessiodp.parties.common.players.objects.PartyPlayerImpl)2 Matcher (java.util.regex.Matcher)2 RankManager (com.alessiodp.parties.common.players.RankManager)1 PartyRankImpl (com.alessiodp.parties.common.players.objects.PartyRankImpl)1 EventHandler (org.bukkit.event.EventHandler)1