use of com.alessiodp.parties.common.parties.objects.PartyImpl in project Parties by AlessioDP.
the class CommandDeny method onCommand.
@Override
public void onCommand(@NotNull CommandData commandData) {
User sender = commandData.getSender();
PartyPlayerImpl partyPlayer = ((PartiesCommandData) commandData).getPartyPlayer();
// Command handling
if (partyPlayer.isInParty()) {
boolean noPendingRequests = false;
if (ConfigParties.ADDITIONAL_ASK_ENABLE) {
// Deny ask request
PartyImpl party = ((PartiesCommandData) commandData).getParty();
HashMap<String, PartyAskRequest> pendingAskRequests = new HashMap<>();
party.getAskRequests().forEach(pv -> pendingAskRequests.put(CommonUtils.toLowerCase(pv.getAsker().getName()), pv));
if (commandData.getArgs().length > 1 && !pendingAskRequests.containsKey(CommonUtils.toLowerCase(commandData.getArgs()[1]))) {
noPendingRequests = true;
} else {
PartyAskRequest partyAskRequest = null;
if (pendingAskRequests.size() > 0) {
if (pendingAskRequests.size() == 1) {
partyAskRequest = pendingAskRequests.values().iterator().next();
} else if (commandData.getArgs().length > 1) {
partyAskRequest = pendingAskRequests.get(CommonUtils.toLowerCase(commandData.getArgs()[1]));
} else {
// Missing player
sendMessage(sender, partyPlayer, Messages.MAINCMD_DENY_MULTIPLEREQUESTS);
for (Map.Entry<String, PartyAskRequest> entry : pendingAskRequests.entrySet()) {
sendMessage(sender, partyPlayer, Messages.MAINCMD_DENY_MULTIPLEREQUESTS_PLAYER.replace("%player%", entry.getValue().getAsker().getName()), (PartyImpl) entry.getValue().getParty());
}
return;
}
} else {
noPendingRequests = true;
}
if (partyAskRequest != null) {
// Command starts
partyAskRequest.deny(partyPlayer);
plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_CMD_DENY_ASK, partyPlayer.getName(), partyAskRequest.getAsker().getName(), partyAskRequest.getParty().getName() != null ? partyAskRequest.getParty().getName() : "_"), true);
return;
}
}
}
if (ConfigParties.ADDITIONAL_TELEPORT_ENABLE && ConfigParties.ADDITIONAL_TELEPORT_ACCEPT_REQUEST_ENABLE) {
// Accept teleport request
HashMap<String, PartyTeleportRequest> pendingTeleportRequests = new HashMap<>();
partyPlayer.getPendingTeleportRequests().forEach(pv -> pendingTeleportRequests.put(CommonUtils.toLowerCase(pv.getRequester().getName()), pv));
if (commandData.getArgs().length > 1 && !pendingTeleportRequests.containsKey(CommonUtils.toLowerCase(commandData.getArgs()[1]))) {
noPendingRequests = true;
} else {
PartyTeleportRequest partyTeleportRequest = null;
if (pendingTeleportRequests.size() > 0) {
if (pendingTeleportRequests.size() == 1) {
partyTeleportRequest = pendingTeleportRequests.values().iterator().next();
} else if (commandData.getArgs().length > 1) {
partyTeleportRequest = pendingTeleportRequests.get(CommonUtils.toLowerCase(commandData.getArgs()[1]));
} else {
// Missing player
sendMessage(sender, partyPlayer, Messages.MAINCMD_DENY_MULTIPLEREQUESTS);
for (Map.Entry<String, PartyTeleportRequest> entry : pendingTeleportRequests.entrySet()) {
sendMessage(sender, partyPlayer, Messages.MAINCMD_DENY_MULTIPLEREQUESTS_PLAYER.replace("%player%", entry.getValue().getRequester().getName()));
}
return;
}
} else {
noPendingRequests = true;
}
if (partyTeleportRequest != null) {
// Command starts
partyTeleportRequest.deny();
plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_CMD_DENY_TELEPORT, partyPlayer.getName(), partyTeleportRequest.getRequester().getName()), true);
return;
}
}
}
if (noPendingRequests) {
if (commandData.getArgs().length > 1) {
sendMessage(sender, partyPlayer, Messages.MAINCMD_DENY_NOEXISTS);
} else {
sendMessage(sender, partyPlayer, Messages.MAINCMD_DENY_NOREQUEST);
}
return;
}
// No ask and no teleport - already in party
sendMessage(sender, partyPlayer, Messages.PARTIES_COMMON_ALREADYINPARTY);
} else {
// Deny invite request
HashMap<String, PartyInvite> pendingInvites = new HashMap<>();
partyPlayer.getPendingInvites().stream().filter(pv -> pv.getParty().getName() != null).forEach(pv -> pendingInvites.put(CommonUtils.toLowerCase(pv.getParty().getName()), pv));
if (commandData.getArgs().length > 1 && !pendingInvites.containsKey(CommonUtils.toLowerCase(commandData.getArgs()[1]))) {
sendMessage(sender, partyPlayer, Messages.MAINCMD_DENY_NOEXISTS);
return;
}
PartyInvite partyInvite;
if (pendingInvites.size() > 0) {
if (pendingInvites.size() == 1) {
partyInvite = pendingInvites.values().iterator().next();
} else if (commandData.getArgs().length > 1) {
partyInvite = pendingInvites.get(CommonUtils.toLowerCase(commandData.getArgs()[1]));
} else {
// Missing party
sendMessage(sender, partyPlayer, Messages.MAINCMD_DENY_MULTIPLEREQUESTS);
for (Map.Entry<String, PartyInvite> entry : pendingInvites.entrySet()) {
sendMessage(sender, partyPlayer, Messages.MAINCMD_DENY_MULTIPLEREQUESTS_PARTY.replace("%party%", entry.getKey()), (PartyImpl) entry.getValue().getParty());
}
return;
}
} else {
sendMessage(sender, partyPlayer, Messages.MAINCMD_DENY_NOREQUEST);
return;
}
if (partyInvite == null) {
sendMessage(sender, partyPlayer, Messages.MAINCMD_DENY_NOEXISTS);
return;
}
// Command starts
partyInvite.deny();
plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_CMD_DENY_INVITE, partyPlayer.getName(), partyInvite.getParty().getName() != null ? partyInvite.getParty().getName() : "_"), true);
}
}
use of com.alessiodp.parties.common.parties.objects.PartyImpl in project Parties by AlessioDP.
the class CommandDesc 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 isRemove = false;
String description = "";
if (commandData.getArgs()[1].equalsIgnoreCase(ConfigMain.COMMANDS_MISC_REMOVE)) {
// Remove command
isRemove = true;
} else {
// Normal command
StringBuilder sb = new StringBuilder();
for (int word = 1; word < commandData.getArgs().length; word++) {
if (sb.length() > 0)
sb.append(" ");
sb.append(commandData.getArgs()[word]);
}
description = sb.toString();
if (!CensorUtils.checkAllowedCharacters(ConfigParties.ADDITIONAL_DESC_ALLOWEDCHARS, description, PartiesConstants.DEBUG_CMD_DESC_REGEXERROR_ALLOWEDCHARS) || (description.length() > ConfigParties.ADDITIONAL_DESC_MAXLENGTH) || (description.length() < ConfigParties.ADDITIONAL_DESC_MINLENGTH)) {
sendMessage(sender, partyPlayer, Messages.ADDCMD_DESC_INVALID);
return;
}
if (CensorUtils.checkCensor(ConfigParties.ADDITIONAL_DESC_CENSORREGEX, description, PartiesConstants.DEBUG_CMD_DESC_REGEXERROR_CENSORED)) {
sendMessage(sender, partyPlayer, Messages.ADDCMD_DESC_CENSORED);
return;
}
if (getPlugin().getEconomyManager().payCommand(EconomyManager.PaidCommand.DESC, partyPlayer, commandData.getCommandLabel(), commandData.getArgs()))
return;
}
// Command starts
party.setDescription(description);
if (isRemove) {
sendMessage(sender, partyPlayer, Messages.ADDCMD_DESC_REMOVED);
plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_CMD_DESC_REM, partyPlayer.getName(), party.getName() != null ? party.getName() : "_"), true);
} else {
sendMessage(sender, partyPlayer, Messages.ADDCMD_DESC_CHANGED);
party.broadcastMessage(Messages.ADDCMD_DESC_BROADCAST, partyPlayer);
plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_CMD_DESC, partyPlayer.getName(), party.getName() != null ? party.getName() : "_"), true);
}
}
use of com.alessiodp.parties.common.parties.objects.PartyImpl in project Parties by AlessioDP.
the class CommandHome method onCommand.
@Override
public void onCommand(@NotNull CommandData commandData) {
User sender = commandData.getSender();
PartyPlayerImpl partyPlayer = ((PartiesCommandData) commandData).getPartyPlayer();
PartyImpl party = getPlugin().getPartyManager().getPartyOfPlayer(partyPlayer);
// Command handling
PartyHomeImpl partyHome = null;
if (commandData.getArgs().length == 1) {
if (party == null) {
sendMessage(sender, partyPlayer, Messages.PARTIES_COMMON_NOTINPARTY);
return;
}
if (party.getHomes().size() == 0) {
sendMessage(sender, partyPlayer, Messages.ADDCMD_HOME_NOHOME, party);
return;
}
}
if (ConfigParties.ADDITIONAL_HOME_MAX_HOMES > 1) {
// Multiple home
if (commandData.getArgs().length == 1) {
if (party.getHomes().size() > 1) {
sendMessage(sender, partyPlayer, Messages.ADDCMD_HOME_MUST_SELECT_HOME, party);
printValidHomes(sender, partyPlayer, party);
return;
}
Optional<PartyHome> opt = party.getHomes().stream().findFirst();
if (opt.isPresent())
partyHome = (PartyHomeImpl) opt.get();
else {
sendMessage(sender, partyPlayer, Messages.ADDCMD_HOME_NOHOME, party);
printValidHomes(sender, partyPlayer, party);
return;
}
} else if (commandData.getArgs().length == 2) {
// Not admin - Not in party
if (!commandData.havePermission(PartiesPermission.ADMIN_HOME_OTHERS) && party == null) {
sendMessage(sender, partyPlayer, Messages.PARTIES_COMMON_NOTINPARTY);
return;
}
// Get the partyHome of the current party
if (party != null) {
Optional<PartyHome> opt = party.getHomes().stream().filter((ph) -> ph.getName() != null && ph.getName().equalsIgnoreCase(commandData.getArgs()[1])).findAny();
if (opt.isPresent())
partyHome = (PartyHomeImpl) opt.get();
}
// If no home but home.others permission
if (partyHome == null && commandData.havePermission(PartiesPermission.ADMIN_HOME_OTHERS)) {
party = getPlugin().getPartyManager().getParty(commandData.getArgs()[1]);
if (party != null) {
if (party.getHomes().size() > 1) {
sendMessage(sender, partyPlayer, Messages.ADDCMD_HOME_MUST_SELECT_HOME, party);
printValidHomes(sender, partyPlayer, party);
return;
}
Optional<PartyHome> opt = party.getHomes().stream().findFirst();
if (opt.isPresent())
partyHome = (PartyHomeImpl) opt.get();
}
}
// Not in party
if (party == null) {
sendMessage(sender, partyPlayer, Messages.PARTIES_COMMON_NOTINPARTY);
return;
}
// No party home found
if (partyHome == null) {
sendMessage(sender, partyPlayer, Messages.ADDCMD_HOME_INVALID_HOME, party);
printValidHomes(sender, partyPlayer, party);
return;
}
} else if (commandData.getArgs().length == 3 && commandData.havePermission(PartiesPermission.ADMIN_HOME_OTHERS)) {
party = getPlugin().getPartyManager().getParty(commandData.getArgs()[1]);
if (party != null) {
Optional<PartyHome> opt = party.getHomes().stream().filter((ph) -> ph.getName() != null && ph.getName().equalsIgnoreCase(commandData.getArgs()[1])).findAny();
if (opt.isPresent())
partyHome = (PartyHomeImpl) opt.get();
else {
sendMessage(sender, partyPlayer, Messages.ADDCMD_HOME_NOHOME, party);
printValidHomes(sender, partyPlayer, party);
return;
}
} else {
sendMessage(sender, partyPlayer, Messages.PARTIES_COMMON_PARTYNOTFOUND.replace("%party%", commandData.getArgs()[1]));
return;
}
} else {
sendMessage(sender, partyPlayer, Messages.PARTIES_SYNTAX_WRONG_MESSAGE.replace("%syntax%", getSyntaxForUser(sender)));
return;
}
} else {
// Single home
if (commandData.getArgs().length == 1) {
Optional<PartyHome> opt = party.getHomes().stream().findFirst();
if (opt.isPresent())
partyHome = (PartyHomeImpl) opt.get();
else {
sendMessage(sender, partyPlayer, Messages.ADDCMD_HOME_NOHOME, party);
return;
}
} else if (commandData.getArgs().length == 2 && commandData.havePermission(PartiesPermission.ADMIN_HOME_OTHERS)) {
party = getPlugin().getPartyManager().getParty(commandData.getArgs()[1]);
if (party != null) {
Optional<PartyHome> opt = party.getHomes().stream().findFirst();
if (opt.isPresent())
partyHome = (PartyHomeImpl) opt.get();
else {
sendMessage(sender, partyPlayer, Messages.ADDCMD_HOME_NOHOME, party);
return;
}
} else {
sendMessage(sender, partyPlayer, Messages.PARTIES_COMMON_PARTYNOTFOUND.replace("%party%", commandData.getArgs()[1]));
return;
}
} else {
sendMessage(sender, partyPlayer, Messages.PARTIES_SYNTAX_WRONG_MESSAGE.replace("%syntax%", getSyntaxForUser(sender)));
return;
}
}
if (!commandData.havePermission(PartiesPermission.ADMIN_HOME_OTHERS) && !getPlugin().getRankManager().checkPlayerRankAlerter(partyPlayer, RankPermission.HOME))
return;
if (partyPlayer.getPendingHomeDelay() != null) {
sendMessage(sender, partyPlayer, Messages.ADDCMD_HOME_TELEPORTWAITING, party);
return;
}
boolean mustStartCooldown = false;
if (ConfigParties.ADDITIONAL_HOME_COOLDOWN_HOME > 0 && !commandData.havePermission(PartiesPermission.ADMIN_COOLDOWN_HOME_BYPASS)) {
mustStartCooldown = true;
long remainingCooldown = getPlugin().getCooldownManager().canAction(CooldownManager.Action.HOME, sender.getUUID(), ConfigParties.ADDITIONAL_HOME_COOLDOWN_HOME);
if (remainingCooldown > 0) {
sendMessage(sender, partyPlayer, Messages.ADDCMD_HOME_COOLDOWN.replace("%seconds%", String.valueOf(remainingCooldown)));
return;
}
}
if (getPlugin().getEconomyManager().payCommand(EconomyManager.PaidCommand.HOME, partyPlayer, commandData.getCommandLabel(), commandData.getArgs()))
return;
if (mustStartCooldown)
getPlugin().getCooldownManager().startAction(CooldownManager.Action.HOME, sender.getUUID(), ConfigParties.ADDITIONAL_HOME_COOLDOWN_HOME);
// Command starts
int delay = ConfigParties.ADDITIONAL_HOME_DELAY;
String homeDelayPermission = sender.getDynamicPermission(PartiesPermission.USER_HOME + ".");
if (homeDelayPermission != null) {
try {
delay = Integer.parseInt(homeDelayPermission);
} catch (Exception ignored) {
}
}
if (delay > 0) {
HomeDelayTask homeDelayTask = teleportPlayerWithDelay(partyPlayer, partyHome, delay);
CancellableTask task = plugin.getScheduler().scheduleAsyncRepeating(homeDelayTask, 0, 300, TimeUnit.MILLISECONDS);
partyPlayer.setPendingHomeDelay(task);
sendMessage(sender, partyPlayer, Messages.ADDCMD_HOME_TELEPORTIN.replace("%seconds%", Integer.toString(delay)));
} else {
teleportPlayer(sender, partyPlayer, partyHome);
}
plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_CMD_HOME, partyPlayer.getName(), party.getName() != null ? party.getName() : "_", CommonUtils.getNoEmptyOr(partyHome.getName(), "default")), true);
}
use of com.alessiodp.parties.common.parties.objects.PartyImpl in project Parties by AlessioDP.
the class CommandIgnore method onCommand.
@Override
public void onCommand(@NotNull CommandData commandData) {
User sender = commandData.getSender();
PartyPlayerImpl partyPlayer = ((PartiesCommandData) commandData).getPartyPlayer();
// Command handling
boolean isPrompt = false;
String ignoredParty = "";
if (commandData.getArgs().length == 1) {
// Shows ignore list
isPrompt = true;
} else {
// Edit party ignore
if (commandData.getArgs().length > 2) {
sendMessage(sender, partyPlayer, Messages.PARTIES_SYNTAX_WRONG_MESSAGE.replace("%syntax%", syntax));
return;
}
ignoredParty = commandData.getArgs()[1];
if (!getPlugin().getPartyManager().existsParty(ignoredParty)) {
sendMessage(sender, partyPlayer, Messages.PARTIES_COMMON_PARTYNOTFOUND.replace("%party%", ignoredParty));
return;
}
}
// Command starts
if (isPrompt) {
StringBuilder builder = new StringBuilder();
for (UUID uuid : partyPlayer.getIgnoredParties()) {
if (builder.length() > 0) {
builder.append(Messages.MAINCMD_IGNORE_LIST_SEPARATOR);
}
PartyImpl party = getPlugin().getPartyManager().getParty(uuid);
if (party != null) {
builder.append(Messages.MAINCMD_IGNORE_LIST_PARTYPREFIX).append(party.getName());
} else {
partyPlayer.getIgnoredParties().remove(uuid);
}
}
String ignores = builder.toString();
if (partyPlayer.getIgnoredParties().size() == 0)
ignores = Messages.MAINCMD_IGNORE_LIST_EMPTY;
sendMessage(sender, partyPlayer, Messages.MAINCMD_IGNORE_LIST_HEADER.replace("%number%", Integer.toString(partyPlayer.getIgnoredParties().size())));
sendMessage(sender, partyPlayer, ignores);
} else {
PartyImpl party = getPlugin().getPartyManager().getParty(ignoredParty);
if (party != null) {
if (partyPlayer.getIgnoredParties().contains(party.getId())) {
// Remove
partyPlayer.getIgnoredParties().remove(party.getId());
sendMessage(sender, partyPlayer, Messages.MAINCMD_IGNORE_STOP.replace("%party%", ignoredParty));
plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_CMD_IGNORE_START, partyPlayer.getName(), party.getName() != null ? party.getName() : "_"), true);
} else {
// Add
partyPlayer.getIgnoredParties().add(party.getId());
sendMessage(sender, partyPlayer, Messages.MAINCMD_IGNORE_START.replace("%party%", ignoredParty));
plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_CMD_IGNORE_STOP, partyPlayer.getName(), party.getName() != null ? party.getName() : "_"), true);
}
}
}
}
use of com.alessiodp.parties.common.parties.objects.PartyImpl in project Parties by AlessioDP.
the class CommandAccept method onCommand.
@Override
public void onCommand(CommandData commandData) {
User sender = commandData.getSender();
PartyPlayerImpl partyPlayer = ((PartiesCommandData) commandData).getPartyPlayer();
// Command handling
if (partyPlayer.isInParty()) {
boolean noPendingRequests = false;
if (ConfigParties.ADDITIONAL_ASK_ENABLE) {
// Accept ask request
PartyImpl party = ((PartiesCommandData) commandData).getParty();
HashMap<String, PartyAskRequest> pendingAskRequests = new HashMap<>();
party.getAskRequests().forEach(pv -> pendingAskRequests.put(CommonUtils.toLowerCase(pv.getAsker().getName()), pv));
if (commandData.getArgs().length > 1 && !pendingAskRequests.containsKey(CommonUtils.toLowerCase(commandData.getArgs()[1]))) {
noPendingRequests = true;
} else {
PartyAskRequest partyAskRequest = null;
if (pendingAskRequests.size() > 0) {
if (pendingAskRequests.size() == 1) {
partyAskRequest = pendingAskRequests.values().iterator().next();
} else if (commandData.getArgs().length > 1) {
partyAskRequest = pendingAskRequests.get(CommonUtils.toLowerCase(commandData.getArgs()[1]));
} else {
// Missing player
sendMessage(sender, partyPlayer, Messages.MAINCMD_ACCEPT_MULTIPLEREQUESTS);
for (Map.Entry<String, PartyAskRequest> entry : pendingAskRequests.entrySet()) {
sendMessage(sender, partyPlayer, Messages.MAINCMD_ACCEPT_MULTIPLEREQUESTS_PLAYER.replace("%player%", entry.getValue().getAsker().getName()), (PartyImpl) entry.getValue().getParty());
}
return;
}
} else {
noPendingRequests = true;
}
if (partyAskRequest != null) {
// Command starts
partyAskRequest.accept(partyPlayer);
plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_CMD_ACCEPT_ASK, partyPlayer.getName(), partyAskRequest.getAsker().getName(), partyAskRequest.getParty().getName() != null ? partyAskRequest.getParty().getName() : "_"), true);
return;
}
}
}
if (ConfigParties.ADDITIONAL_TELEPORT_ENABLE && ConfigParties.ADDITIONAL_TELEPORT_ACCEPT_REQUEST_ENABLE) {
// Accept teleport request
HashMap<String, PartyTeleportRequest> pendingTeleportRequests = new HashMap<>();
partyPlayer.getPendingTeleportRequests().forEach(pv -> pendingTeleportRequests.put(CommonUtils.toLowerCase(pv.getRequester().getName()), pv));
if (commandData.getArgs().length > 1 && !pendingTeleportRequests.containsKey(CommonUtils.toLowerCase(commandData.getArgs()[1]))) {
noPendingRequests = true;
} else {
PartyTeleportRequest partyTeleportRequest = null;
if (pendingTeleportRequests.size() > 0) {
if (pendingTeleportRequests.size() == 1) {
partyTeleportRequest = pendingTeleportRequests.values().iterator().next();
} else if (commandData.getArgs().length > 1) {
partyTeleportRequest = pendingTeleportRequests.get(CommonUtils.toLowerCase(commandData.getArgs()[1]));
} else {
// Missing player
sendMessage(sender, partyPlayer, Messages.MAINCMD_ACCEPT_MULTIPLEREQUESTS);
for (Map.Entry<String, PartyTeleportRequest> entry : pendingTeleportRequests.entrySet()) {
sendMessage(sender, partyPlayer, Messages.MAINCMD_ACCEPT_MULTIPLEREQUESTS_PLAYER.replace("%player%", entry.getValue().getRequester().getName()));
}
return;
}
} else {
noPendingRequests = true;
}
if (partyTeleportRequest != null) {
// Command starts
partyTeleportRequest.accept();
plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_CMD_ACCEPT_TELEPORT, partyPlayer.getName(), partyTeleportRequest.getRequester().getName()), true);
return;
}
}
}
if (noPendingRequests) {
if (commandData.getArgs().length > 1) {
sendMessage(sender, partyPlayer, Messages.MAINCMD_ACCEPT_NOEXISTS);
} else {
sendMessage(sender, partyPlayer, Messages.MAINCMD_ACCEPT_NOREQUEST);
}
return;
}
// No ask and no teleport - already in party
sendMessage(sender, partyPlayer, Messages.PARTIES_COMMON_ALREADYINPARTY);
} else {
// Accept invite request
HashMap<String, PartyInvite> pendingInvites = new HashMap<>();
partyPlayer.getPendingInvites().stream().filter(pv -> pv.getParty().getName() != null).forEach(pv -> pendingInvites.put(CommonUtils.toLowerCase(pv.getParty().getName()), pv));
if (commandData.getArgs().length > 1 && !pendingInvites.containsKey(CommonUtils.toLowerCase(commandData.getArgs()[1]))) {
sendMessage(sender, partyPlayer, Messages.MAINCMD_ACCEPT_NOEXISTS);
return;
}
PartyInvite partyInvite;
if (pendingInvites.size() > 0) {
if (pendingInvites.size() == 1) {
partyInvite = pendingInvites.values().iterator().next();
} else if (commandData.getArgs().length > 1) {
partyInvite = pendingInvites.get(CommonUtils.toLowerCase(commandData.getArgs()[1]));
} else {
// Missing party
sendMessage(sender, partyPlayer, Messages.MAINCMD_ACCEPT_MULTIPLEREQUESTS);
for (Map.Entry<String, PartyInvite> entry : pendingInvites.entrySet()) {
sendMessage(sender, partyPlayer, Messages.MAINCMD_ACCEPT_MULTIPLEREQUESTS_PARTY.replace("%party%", entry.getKey()), (PartyImpl) entry.getValue().getParty());
}
return;
}
} else {
sendMessage(sender, partyPlayer, Messages.MAINCMD_ACCEPT_NOREQUEST);
return;
}
if (partyInvite == null) {
sendMessage(sender, partyPlayer, Messages.MAINCMD_ACCEPT_NOEXISTS);
return;
}
// Command starts
partyInvite.accept();
plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_CMD_ACCEPT_INVITE, partyPlayer.getName(), partyInvite.getParty().getName() != null ? partyInvite.getParty().getName() : "_"), true);
}
}
Aggregations