use of com.alessiodp.parties.common.commands.utils.PartiesCommandData 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.commands.utils.PartiesCommandData 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.commands.utils.PartiesCommandData 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.commands.utils.PartiesCommandData in project Parties by AlessioDP.
the class CommandChat method onCommand.
@Override
public void onCommand(@NotNull CommandData commandData) {
User sender = commandData.getSender();
PartyPlayerImpl partyPlayer = ((PartiesCommandData) commandData).getPartyPlayer();
// Command handling
Boolean chat = plugin.getCommandManager().getCommandUtils().handleOnOffCommand(partyPlayer.isChatParty(), commandData.getArgs());
if (chat == null) {
sendMessage(sender, partyPlayer, Messages.PARTIES_SYNTAX_WRONG_MESSAGE.replace("%syntax%", syntax));
return;
}
// Command starts
partyPlayer.setChatParty(chat);
if (chat) {
sendMessage(sender, partyPlayer, Messages.MAINCMD_CHAT_ENABLED);
} else {
sendMessage(sender, partyPlayer, Messages.MAINCMD_CHAT_DISABLED);
}
plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_CMD_CHAT, partyPlayer.getName(), chat), true);
}
use of com.alessiodp.parties.common.commands.utils.PartiesCommandData in project Parties by AlessioDP.
the class CommandColor 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
Set<PartyColorImpl> availableColors = getPlugin().getColorManager().getAvailableColors(sender);
if (commandData.getArgs().length == 1) {
if (party.getColor() != null)
sendMessage(sender, partyPlayer, parseWithAvailableColors(Messages.ADDCMD_COLOR_INFO, availableColors));
else
sendMessage(sender, partyPlayer, parseWithAvailableColors(Messages.ADDCMD_COLOR_EMPTY, availableColors));
return;
}
boolean isRemove = false;
PartyColor color = null;
if (commandData.getArgs()[1].equalsIgnoreCase(ConfigMain.COMMANDS_MISC_REMOVE)) {
// Remove command
isRemove = true;
} else {
// Normal command
for (PartyColorImpl pc : availableColors) {
if (pc.getCommand().equalsIgnoreCase(commandData.getArgs()[1])) {
color = pc;
break;
}
}
if (color == null) {
// Color doesn't exist
sendMessage(sender, partyPlayer, parseWithAvailableColors(Messages.ADDCMD_COLOR_WRONGCOLOR, availableColors));
return;
}
if (getPlugin().getEconomyManager().payCommand(EconomyManager.PaidCommand.COLOR, partyPlayer, commandData.getCommandLabel(), commandData.getArgs()))
return;
}
// Command starts
party.setColor(color);
if (isRemove) {
sendMessage(sender, partyPlayer, parseWithAvailableColors(Messages.ADDCMD_COLOR_REMOVED, availableColors));
plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_CMD_COLOR_REM, partyPlayer.getName(), party.getName() != null ? party.getName() : "_"), true);
} else {
sendMessage(sender, partyPlayer, parseWithAvailableColors(Messages.ADDCMD_COLOR_CHANGED, availableColors), party);
party.broadcastMessage(parseWithAvailableColors(Messages.ADDCMD_COLOR_BROADCAST, availableColors), partyPlayer);
plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_CMD_COLOR, partyPlayer.getName(), party.getName() != null ? party.getName() : "_", color.getName()), true);
}
}
Aggregations