use of com.alessiodp.parties.api.interfaces.PartyColor 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