use of com.alessiodp.parties.common.addons.internal.PartiesPlaceholder in project Parties by AlessioDP.
the class PartiesPlaceholderTest method testPlaceholderListPartiesByOthers.
@Test
public void testPlaceholderListPartiesByOthers() {
PartiesPlaceholder placeholder = PartiesPlaceholder.getPlaceholder("list_parties_by_members_1");
assertEquals(PartiesPlaceholder.LIST_PARTIES_BY_MEMBERS_NUMBER, placeholder);
placeholder = PartiesPlaceholder.getPlaceholder("list_parties_by_members_1_id");
assertEquals(PartiesPlaceholder.LIST_PARTIES_BY_MEMBERS_NUMBER_PLACEHOLDER, placeholder);
placeholder = PartiesPlaceholder.getPlaceholder("list_parties_by_kills_1");
assertEquals(PartiesPlaceholder.LIST_PARTIES_BY_KILLS_NUMBER, placeholder);
placeholder = PartiesPlaceholder.getPlaceholder("list_parties_by_kills_1_id");
assertEquals(PartiesPlaceholder.LIST_PARTIES_BY_KILLS_NUMBER_PLACEHOLDER, placeholder);
placeholder = PartiesPlaceholder.getPlaceholder("list_parties_by_experience_1");
assertEquals(PartiesPlaceholder.LIST_PARTIES_BY_EXPERIENCE_NUMBER, placeholder);
placeholder = PartiesPlaceholder.getPlaceholder("list_parties_by_experience_1_id");
assertEquals(PartiesPlaceholder.LIST_PARTIES_BY_EXPERIENCE_NUMBER_PLACEHOLDER, placeholder);
}
use of com.alessiodp.parties.common.addons.internal.PartiesPlaceholder in project Parties by AlessioDP.
the class PartiesPlaceholderTest method testPlaceholderMotd.
@Test
public void testPlaceholderMotd() {
PartiesPlaceholder placeholder = PartiesPlaceholder.getPlaceholder("motd");
assertEquals(PartiesPlaceholder.MOTD, placeholder);
assertEquals("", placeholder.formatPlaceholder(player1, party1, "motd"));
party1.setAccessible(true);
party1.setMotd("motd");
party1.setAccessible(false);
assertEquals(party1.getMotd(), placeholder.formatPlaceholder(player1, party1, "motd"));
}
use of com.alessiodp.parties.common.addons.internal.PartiesPlaceholder in project Parties by AlessioDP.
the class PartiesPlaceholderTest method testPlaceholderLeaderName.
@Test
public void testPlaceholderLeaderName() {
PartiesPlaceholder placeholder = PartiesPlaceholder.getPlaceholder("leader_name");
assertEquals(PartiesPlaceholder.LEADER_NAME, placeholder);
assertEquals("Dummy", placeholder.formatPlaceholder(player1, party1, "leader_name"));
}
use of com.alessiodp.parties.common.addons.internal.PartiesPlaceholder in project Parties by AlessioDP.
the class MessageUtils method convertPlaceholders.
public String convertPlaceholders(String message, PartyPlayerImpl player, PartyImpl party, String emptyPlaceholder) {
String ret = message;
String replacement;
Matcher matcher = PLACEHOLDER_PATTERN.matcher(ret);
while (matcher.find()) {
String identifier = matcher.group(1);
// Match basic placeholders
switch(CommonUtils.toLowerCase(identifier)) {
case "%player%":
case "%user%":
if (player != null) {
replacement = player.getName();
ret = ret.replace(identifier, replacement);
}
break;
// Nothing to do
default:
}
PartiesPlaceholder placeholder = PartiesPlaceholder.getPlaceholder(stripPlaceholder(identifier));
if (placeholder != null) {
replacement = placeholder.formatPlaceholder(player, party, stripPlaceholder(identifier), emptyPlaceholder);
if (replacement != null)
ret = ret.replace(identifier, replacement);
}
}
return ret;
}
Aggregations