use of com.alessiodp.parties.addons.internal.PartiesPlaceholder in project Parties by AlessioDP.
the class EssentialsChatHandler method onChatPlayer.
@EventHandler
public void onChatPlayer(AsyncPlayerChatEvent event) {
String old = event.getFormat();
if (old.toLowerCase().contains("{parties_")) {
// Bypass useless checks if parties doesn't exist
boolean somethingChanged = false;
PartyPlayerEntity pp = plugin.getPlayerManager().getPlayer(event.getPlayer().getUniqueId());
PartyEntity party = plugin.getPartyManager().getParty(pp.getPartyName());
Pattern pat = Pattern.compile("\\{parties_([a-z\\_]+)\\}", Pattern.CASE_INSENSITIVE);
Matcher mat = pat.matcher(old);
while (mat.find()) {
String base = mat.group(0);
String identifier = mat.group(1);
if (identifier != null) {
PartiesPlaceholder ph = PartiesPlaceholder.getPlaceholder(identifier);
if (ph != null) {
old = old.replace(base, ph.formatPlaceholder(pp, party));
somethingChanged = true;
}
}
}
if (somethingChanged)
event.setFormat(old);
}
}
use of com.alessiodp.parties.addons.internal.PartiesPlaceholder in project Parties by AlessioDP.
the class PAPIHook method onPlaceholderRequest.
@Override
public String onPlaceholderRequest(Player p, String identifier) {
PartyPlayerEntity pp = plugin.getPlayerManager().getPlayer(p.getUniqueId());
PartyEntity party = plugin.getPartyManager().getParty(pp.getPartyName());
PartiesPlaceholder ph = PartiesPlaceholder.getPlaceholder(identifier);
return ph != null ? ph.formatPlaceholder(pp, party) : "";
}
Aggregations