use of com.alessiodp.parties.common.parties.objects.PartyImpl in project Parties by AlessioDP.
the class CommandCreate method createParty.
public static PartyImpl createParty(PartiesPlugin plugin, PartiesSubCommand subCommand, User sender, PartyPlayerImpl partyPlayer, String partyName, boolean fixed) {
PartyImpl ret = null;
IPartyPreCreateEvent partiesPreEvent = plugin.getEventManager().preparePartyPreCreateEvent(partyPlayer, partyName, fixed);
plugin.getEventManager().callEvent(partiesPreEvent);
String newPartyName = partiesPreEvent.getPartyName();
boolean isFixed = partiesPreEvent.isFixed();
if (!partiesPreEvent.isCancelled() && (isFixed || partyPlayer != null)) {
PartyImpl party = plugin.getPartyManager().initializeParty();
party.create(newPartyName, isFixed ? null : partyPlayer, partyPlayer);
if (isFixed) {
subCommand.sendMessage(sender, partyPlayer, Messages.MAINCMD_CREATE_CREATEDFIXED, party);
plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_CMD_CREATE_FIXED, sender.getName(), party.getName() != null ? party.getName() : "_"), true);
} else {
subCommand.sendMessage(sender, partyPlayer, Messages.MAINCMD_CREATE_CREATED, party);
plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_CMD_CREATE, sender.getName(), party.getName() != null ? party.getName() : "_"), true);
}
ret = party;
} else {
plugin.getLoggerManager().log(String.format(PartiesConstants.DEBUG_API_CREATEEVENT_DENY, partyName, sender.getName(), sender.getUUID().toString()), true);
}
return ret;
}
use of com.alessiodp.parties.common.parties.objects.PartyImpl in project Parties by AlessioDP.
the class CommandDelete method onCommand.
@Override
public void onCommand(@NotNull CommandData commandData) {
User sender = commandData.getSender();
PartyPlayerImpl partyPlayer = ((PartiesCommandData) commandData).getPartyPlayer();
// Command handling
PartyImpl party = getPlugin().getPartyManager().getParty(commandData.getArgs()[1]);
if (party == null) {
sendMessage(sender, partyPlayer, Messages.PARTIES_COMMON_PARTYNOTFOUND.replace("%party%", commandData.getArgs()[1]));
return;
}
boolean isSilent = false;
if (commandData.getArgs().length == 3) {
if (commandData.havePermission(PartiesPermission.ADMIN_DELETE_SILENT) && commandData.getArgs()[2].equalsIgnoreCase(ConfigMain.COMMANDS_MISC_SILENT)) {
isSilent = true;
} else {
sendMessage(sender, ((PartiesCommandData) commandData).getPartyPlayer(), Messages.PARTIES_SYNTAX_WRONG_MESSAGE.replace("%syntax%", getSyntaxForUser(sender)));
return;
}
}
// Command starts
// Calling Pre API event
IPartyPreDeleteEvent partiesPreDeleteEvent = getPlugin().getEventManager().preparePartyPreDeleteEvent(party, DeleteCause.DELETE, null, partyPlayer);
getPlugin().getEventManager().callEvent(partiesPreDeleteEvent);
if (!partiesPreDeleteEvent.isCancelled()) {
if (isSilent) {
sendMessage(sender, partyPlayer, Messages.MAINCMD_DELETE_DELETEDSILENTLY, party);
} else {
sendMessage(sender, partyPlayer, Messages.MAINCMD_DELETE_DELETED, party);
party.broadcastMessage(Messages.MAINCMD_DELETE_BROADCAST, partyPlayer);
}
party.delete(DeleteCause.DELETE, null, partyPlayer);
plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_CMD_DELETE, sender.getName(), party.getName() != null ? party.getName() : "_"), true);
} else {
plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_API_DELETEEVENT_DENY, party.getId(), sender.getName(), sender.getUUID().toString()), true);
}
}
use of com.alessiodp.parties.common.parties.objects.PartyImpl in project Parties by AlessioDP.
the class CommandFollow method onCommand.
@Override
public void onCommand(@NotNull CommandData commandData) {
User sender = commandData.getSender();
PartyPlayerImpl partyPlayer = ((PartiesCommandData) commandData).getPartyPlayer();
PartyImpl party = ((PartiesCommandData) commandData).getParty();
// Command handling
Boolean follow = plugin.getCommandManager().getCommandUtils().handleOnOffCommand(party.isFollowEnabled(), commandData.getArgs());
if (follow == null) {
sendMessage(sender, partyPlayer, Messages.PARTIES_SYNTAX_WRONG_MESSAGE.replace("%syntax%", syntax));
return;
}
if (follow && getPlugin().getEconomyManager().payCommand(EconomyManager.PaidCommand.FOLLOW, partyPlayer, commandData.getCommandLabel(), commandData.getArgs()))
return;
// Command starts
party.setFollowEnabled(follow);
if (follow)
sendMessage(sender, partyPlayer, Messages.ADDCMD_FOLLOW_ON);
else
sendMessage(sender, partyPlayer, Messages.ADDCMD_FOLLOW_OFF);
plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_CMD_FOLLOW, partyPlayer.getName(), follow, party.getName() != null ? party.getName() : "_"), true);
}
use of com.alessiodp.parties.common.parties.objects.PartyImpl in project Parties by AlessioDP.
the class CommandInfo method onCommand.
@Override
public void onCommand(@NotNull CommandData commandData) {
User sender = commandData.getSender();
PartyPlayerImpl partyPlayer = ((PartiesCommandData) commandData).getPartyPlayer();
PartyImpl party;
// Command handling
if (commandData.getArgs().length == 1 && sender.isPlayer()) {
party = getPlugin().getPartyManager().getPartyOfPlayer(partyPlayer);
} else if (commandData.getArgs().length == 2 && commandData.havePermission(PartiesPermission.USER_INFO_OTHERS)) {
party = getPlugin().getPartyManager().getParty(commandData.getArgs()[1]);
} else {
sendMessage(sender, partyPlayer, Messages.PARTIES_SYNTAX_WRONG_MESSAGE.replace("%syntax%", getSyntaxForUser(sender)));
return;
}
if (party == null) {
if (commandData.getArgs().length > 1)
sendMessage(sender, partyPlayer, Messages.PARTIES_COMMON_PARTYNOTFOUND.replace("%party%", commandData.getArgs()[1]));
else
sendMessage(sender, partyPlayer, Messages.PARTIES_COMMON_NOTINPARTY);
return;
}
// Command starts
for (String line : Messages.MAINCMD_INFO_CONTENT) {
line = getPlugin().getMessageUtils().convertPlaceholders(line, partyPlayer, party, Messages.PARTIES_LIST_MISSING);
sendMessage(sender, partyPlayer, line);
}
plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_CMD_INFO, sender.getName(), party.getName() != null ? party.getName() : "_"), true);
}
use of com.alessiodp.parties.common.parties.objects.PartyImpl in project Parties by AlessioDP.
the class BukkitFightListener method onEntityDieKill.
@EventHandler(ignoreCancelled = true)
public void onEntityDieKill(EntityDeathEvent event) {
if (BukkitConfigParties.ADDITIONAL_KILLS_ENABLE && event.getEntity().getKiller() != null) {
Player killer = event.getEntity().getKiller();
PartyPlayerImpl ppKiller = plugin.getPlayerManager().getPlayer(killer.getUniqueId());
PartyImpl party = plugin.getPartyManager().getParty(ppKiller.getPartyId());
if (party != null) {
boolean gotKill = false;
if (BukkitConfigParties.ADDITIONAL_KILLS_MOB_HOSTILE && event.getEntity() instanceof Monster)
gotKill = true;
else if (BukkitConfigParties.ADDITIONAL_KILLS_MOB_NEUTRAL && event.getEntity() instanceof Animals)
gotKill = true;
else if (BukkitConfigParties.ADDITIONAL_KILLS_MOB_PLAYERS && event.getEntity() instanceof Player)
gotKill = true;
if (gotKill) {
party.setKills(party.getKills() + 1);
plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_KILL_ADD, party.getId(), killer.getUniqueId()), true);
}
}
}
}
Aggregations