use of com.alessiodp.parties.common.players.objects.PartyPlayerImpl in project Parties by AlessioDP.
the class PAPIHook method onRequest.
@Override
public String onRequest(OfflinePlayer offlinePlayer, String identifier) {
if (offlinePlayer != null) {
PartyPlayerImpl partyPlayer = plugin.getPlayerManager().getPlayer(offlinePlayer.getUniqueId());
PartyImpl party = plugin.getPartyManager().getParty(partyPlayer.getPartyId());
PartiesPlaceholder placeholder = PartiesPlaceholder.getPlaceholder(identifier);
return placeholder != null ? placeholder.formatPlaceholder(partyPlayer, party, identifier) : null;
}
return null;
}
use of com.alessiodp.parties.common.players.objects.PartyPlayerImpl in project Parties by AlessioDP.
the class EssentialsChatHandler method onChatPlayer.
@EventHandler
public void onChatPlayer(AsyncPlayerChatEvent event) {
String old = event.getFormat();
if (CommonUtils.toLowerCase(old).contains("{parties_")) {
// Bypass useless checks if this isn't an Parties placeholder
boolean somethingChanged = false;
PartyPlayerImpl partyPlayer = plugin.getPlayerManager().getPlayer(event.getPlayer().getUniqueId());
PartyImpl party = plugin.getPartyManager().getParty(partyPlayer.getPartyId());
Matcher mat = PATTERN.matcher(old);
while (mat.find()) {
String base = mat.group(0);
String identifier = mat.group(1);
if (identifier != null) {
identifier = CommonUtils.toLowerCase(identifier);
PartiesPlaceholder placeholder = PartiesPlaceholder.getPlaceholder(identifier);
if (placeholder != null) {
String parsed = placeholder.formatPlaceholder(partyPlayer, party, identifier);
if (parsed != null) {
old = old.replace(base, Color.translateAlternateColorCodes(parsed));
somethingChanged = true;
}
}
}
}
if (somethingChanged)
event.setFormat(old);
}
}
use of com.alessiodp.parties.common.players.objects.PartyPlayerImpl in project Parties by AlessioDP.
the class MythicMobsHandler method onMythicMobDeath.
@EventHandler
public void onMythicMobDeath(MythicMobLootDropEvent event) {
if (active && event.getKiller() instanceof Player) {
Entity killedEntity = event.getEntity();
if (event.getKiller() != null) {
PartyPlayerImpl killer = plugin.getPlayerManager().getPlayer(event.getKiller().getUniqueId());
if (killer.isInParty()) {
plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_EXP_MMHANDLING, event.getMobType().getInternalName(), killer.getName(), killer.getPlayerUUID().toString()), true);
double vanillaExp = 0;
double skillapiExp = 0;
if (BukkitConfigMain.ADDITIONAL_EXP_DROP_GET_NORMAL)
vanillaExp = event.getExp();
if (BukkitConfigMain.ADDITIONAL_EXP_DROP_GET_SKILLAPI) {
for (Drop drop : event.getDrops().getDrops()) {
if (drop instanceof SkillAPIDrop) {
skillapiExp += drop.getAmount();
}
}
}
ExpDrop drop = new ExpDrop(killer, killedEntity, vanillaExp, skillapiExp);
boolean result = ((BukkitExpManager) plugin.getExpManager()).distributeExp(drop);
if (result && BukkitConfigMain.ADDITIONAL_EXP_DROP_CONVERT_REMOVEREALEXP) {
// Remove exp from the event if hooked
if (BukkitConfigMain.ADDITIONAL_EXP_DROP_GET_NORMAL) {
// Be sure that we are removing exp from intangible drops
for (Drop d : event.getDrops().getLootTableIntangible().values()) {
if (d instanceof ExperienceDrop) {
d.setAmount(0);
}
}
// Add it to an array list that contains a list of entities
// that we need to manually remove drop experience
mobsExperienceToSuppress.add(event.getEntity().getUniqueId());
}
// Remove skillapi exp from the event if hooked
if (BukkitConfigMain.ADDITIONAL_EXP_DROP_GET_SKILLAPI) {
event.getDrops().getLootTableIntangible().remove(SkillAPIDrop.class);
}
}
}
}
}
}
use of com.alessiodp.parties.common.players.objects.PartyPlayerImpl in project Parties by AlessioDP.
the class BukkitCommandTeleport method performTeleport.
@Override
public void performTeleport(PartyImpl party, PartyPlayerImpl player, int delay) {
if (ConfigParties.ADDITIONAL_TELEPORT_ACCEPT_REQUEST_ENABLE)
player.sendMessage(Messages.ADDCMD_TELEPORT_ACCEPT_REQUEST_SENT);
else
player.sendMessage(Messages.ADDCMD_TELEPORT_TELEPORTING.replace("%seconds%", Integer.toString(delay)));
for (PartyPlayer onlinePlayer : party.getOnlineMembers(true)) {
if (!onlinePlayer.getPlayerUUID().equals(player.getPlayerUUID())) {
if (ConfigParties.ADDITIONAL_TELEPORT_ACCEPT_REQUEST_ENABLE) {
BukkitPartyTeleportRequest request = new BukkitPartyTeleportRequest((PartiesPlugin) plugin, (PartyPlayerImpl) onlinePlayer, player);
((PartyPlayerImpl) onlinePlayer).getPendingTeleportRequests().add(request);
((PartyPlayerImpl) onlinePlayer).sendMessage(Messages.ADDCMD_TELEPORT_ACCEPT_REQUEST_RECEIVED, player, party);
plugin.getScheduler().scheduleAsyncLater(request::timeout, ConfigParties.ADDITIONAL_TELEPORT_ACCEPT_REQUEST_TIME, TimeUnit.SECONDS);
} else {
handleSinglePlayerTeleport((PartiesPlugin) plugin, (PartyPlayerImpl) onlinePlayer, player, delay);
}
}
}
}
use of com.alessiodp.parties.common.players.objects.PartyPlayerImpl in project Parties by AlessioDP.
the class RankManagerTest method testCheckPlayerRankAlerter.
@Test
public void testCheckPlayerRankAlerter() {
Messages.PARTIES_PERM_NORANK_UPRANK = "";
Messages.PARTIES_PERM_NORANK_GENERAL = "";
PartyPlayerImpl player = mock(PartyPlayerImpl.class);
doNothing().when(player).sendMessage(anyString());
User user = mock(User.class);
when(user.hasPermission(anyString())).thenReturn(true);
when(mockPlugin.getPlayer(any())).thenReturn(user);
when(player.getRank()).thenReturn(1);
assertTrue(rankManager.checkPlayerRankAlerter(player, PartiesPermission.PRIVATE_EDIT_COLOR));
verify(player, times(0)).sendMessage(anyString());
assertTrue(rankManager.checkPlayerRankAlerter(player, PartiesPermission.PRIVATE_EDIT_DESC));
verify(player, times(0)).sendMessage(anyString());
assertFalse(rankManager.checkPlayerRankAlerter(player, PartiesPermission.PRIVATE_EDIT_FOLLOW));
verify(player, times(1)).sendMessage(anyString());
assertFalse(rankManager.checkPlayerRankAlerter(player, PartiesPermission.PRIVATE_EDIT_HOME));
verify(player, times(2)).sendMessage(anyString());
assertFalse(rankManager.checkPlayerRankAlerter(player, PartiesPermission.PRIVATE_EDIT_MOTD));
verify(player, times(3)).sendMessage(anyString());
}
Aggregations