Search in sources :

Example 1 with PartiesPlaceholder

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

the class PartiesPlaceholderTest method testPlaceholderTag.

@Test
public void testPlaceholderTag() {
    PartiesPlaceholder placeholder = PartiesPlaceholder.getPlaceholder("tag");
    assertEquals(PartiesPlaceholder.TAG, placeholder);
    assertEquals("", placeholder.formatPlaceholder(player1, party1, ""));
    party1.setAccessible(true);
    party1.setTag("tag");
    party1.setAccessible(false);
    assertEquals(party1.getTag(), placeholder.formatPlaceholder(player1, party1, ""));
}
Also used : PartiesPlaceholder(com.alessiodp.parties.common.addons.internal.PartiesPlaceholder) Test(org.junit.jupiter.api.Test)

Example 2 with PartiesPlaceholder

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

the class PartiesPlaceholderTest method testPlaceholderKills.

@Test
public void testPlaceholderKills() {
    PartiesPlaceholder placeholder = PartiesPlaceholder.getPlaceholder("kills");
    assertEquals(PartiesPlaceholder.KILLS, placeholder);
    assertEquals("0", placeholder.formatPlaceholder(player1, party1, "kills"));
    party1.setAccessible(true);
    party1.setKills(100);
    party1.setAccessible(false);
    assertEquals(Integer.toString(party1.getKills()), placeholder.formatPlaceholder(player1, party1, "kills"));
}
Also used : PartiesPlaceholder(com.alessiodp.parties.common.addons.internal.PartiesPlaceholder) Test(org.junit.jupiter.api.Test)

Example 3 with PartiesPlaceholder

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

the class PartiesPlaceholderTest method testPlaceholderPlayerNickname.

@Test
public void testPlaceholderPlayerNickname() {
    ConfigParties.ADDITIONAL_NICKNAME_FORMAT = "~%nickname%";
    PartiesPlaceholder placeholder = PartiesPlaceholder.getPlaceholder("player_nickname");
    assertEquals(PartiesPlaceholder.PLAYER_NICKNAME, placeholder);
    assertEquals(player1.getName(), placeholder.formatPlaceholder(player1, party1, ""));
    player1.setAccessible(true);
    player1.setNickname("newNickname");
    player1.setAccessible(false);
    assertEquals("~" + player1.getNickname(), placeholder.formatPlaceholder(player1, party1, ""));
}
Also used : PartiesPlaceholder(com.alessiodp.parties.common.addons.internal.PartiesPlaceholder) Test(org.junit.jupiter.api.Test)

Example 4 with PartiesPlaceholder

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

the class PartiesPlaceholderTest method testNullness.

@Test
public void testNullness() {
    PartiesPlaceholder placeholder = PartiesPlaceholder.getPlaceholder("impossible_placeholder");
    assertNull(placeholder);
}
Also used : PartiesPlaceholder(com.alessiodp.parties.common.addons.internal.PartiesPlaceholder) Test(org.junit.jupiter.api.Test)

Example 5 with PartiesPlaceholder

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

the class PartiesPlaceholderTest method testPlaceholderListRank.

@Test
public void testPlaceholderListRank() {
    RankManager mockRankManager = mock(RankManager.class);
    when(mockPlugin.getRankManager()).thenReturn(mockRankManager);
    when(mockRankManager.searchRankByHardName(any())).thenReturn(new PartyRankImpl("myrank", "myrank", "", 20, 0, null, Collections.emptyList(), true));
    when(mockMessageUtils.convertPlaceholders(any(), any(), any())).thenReturn("Dummy");
    PartiesPlaceholder placeholder = PartiesPlaceholder.getPlaceholder("list_rank_myrank");
    assertEquals(PartiesPlaceholder.LIST_RANK, placeholder);
    assertEquals(player1.getName(), placeholder.formatPlaceholder(null, party1, "list_rank_myrank"));
    placeholder = PartiesPlaceholder.getPlaceholder("list_rank_myrank_total");
    assertEquals(PartiesPlaceholder.LIST_RANK_TOTAL, placeholder);
    placeholder = PartiesPlaceholder.getPlaceholder("list_rank_myrank_1");
    assertEquals(PartiesPlaceholder.LIST_RANK_NUMBER, placeholder);
    placeholder = PartiesPlaceholder.getPlaceholder("list_rank_myrank_1_placeholder");
    assertEquals(PartiesPlaceholder.LIST_RANK_NUMBER_PLACEHOLDER, placeholder);
}
Also used : PartiesPlaceholder(com.alessiodp.parties.common.addons.internal.PartiesPlaceholder) PartyRankImpl(com.alessiodp.parties.common.players.objects.PartyRankImpl) RankManager(com.alessiodp.parties.common.players.RankManager) 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