use of com.alessiodp.parties.common.parties.objects.PartyColorImpl in project Parties by AlessioDP.
the class PartiesPlaceholderTest method testPlaceholderColorName.
@Test
public void testPlaceholderColorName() {
PartiesPlaceholder placeholder = PartiesPlaceholder.getPlaceholder("color_name");
assertEquals(PartiesPlaceholder.COLOR_NAME, placeholder);
assertEquals("", placeholder.formatPlaceholder(player1, party1, "color_name"));
party1.setAccessible(true);
party1.setColor(new PartyColorImpl("red", "123", "&c", 0, 0, 0));
party1.setAccessible(false);
assertEquals(party1.getColor().getName(), placeholder.formatPlaceholder(player1, party1, "color_name"));
}
use of com.alessiodp.parties.common.parties.objects.PartyColorImpl 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);
}
}
use of com.alessiodp.parties.common.parties.objects.PartyColorImpl in project Parties by AlessioDP.
the class ConfigParties method saveColors.
private void saveColors() {
if (ConfigParties.RAW_ADDITIONAL_COLOR_LIST != null) {
// Cleanup unused colors
for (String color : ConfigParties.RAW_ADDITIONAL_COLOR_LIST.getKeys(false)) {
boolean found = false;
for (PartyColorImpl partyColor : ((PartiesPlugin) plugin).getColorManager().getColorList()) {
if (partyColor.getName().equals(color)) {
found = true;
break;
}
}
if (!found) {
ConfigParties.RAW_ADDITIONAL_COLOR_LIST.remove(color);
}
}
// Update colors
for (PartyColorImpl partyColor : ((PartiesPlugin) plugin).getColorManager().getColorList()) {
ConfigParties.RAW_ADDITIONAL_COLOR_LIST.set(partyColor.getName() + ".command", partyColor.getCommand());
ConfigParties.RAW_ADDITIONAL_COLOR_LIST.set(partyColor.getName() + ".code", partyColor.getCode());
if (partyColor.getDynamicPriority() > 0 && partyColor.getDynamicKills() > 0 && partyColor.getDynamicMembers() > 0) {
ConfigParties.RAW_ADDITIONAL_COLOR_LIST.set(partyColor.getName() + ".dynamic.priority", partyColor.getDynamicPriority());
ConfigParties.RAW_ADDITIONAL_COLOR_LIST.set(partyColor.getName() + ".dynamic.kills", partyColor.getDynamicKills());
ConfigParties.RAW_ADDITIONAL_COLOR_LIST.set(partyColor.getName() + ".dynamic.members", partyColor.getDynamicMembers());
}
}
}
}
use of com.alessiodp.parties.common.parties.objects.PartyColorImpl in project Parties by AlessioDP.
the class ConfigParties method loadDefaults.
@Override
public void loadDefaults() {
loadDefaultConfigOptions();
RANK_LIST = new HashSet<>();
PartyRankImpl rankMember = new PartyRankImpl("member", "Member", "&bMember", 5, 0, null, Arrays.asList("party.sendmessage", "party.home", "party.desc", "party.motd", "party.claim"), true);
PartyRankImpl rankModerator = new PartyRankImpl("moderator", "Moderator", "&cModerator", 10, 0, rankMember, Arrays.asList("party.ask.accept", "party.ask.deny", "party.invite", "party.kick"), false);
PartyRankImpl rankLeader = new PartyRankImpl("member", "Member", "&bMember", 5, 0, null, Collections.singletonList("*"), true);
RANK_LIST.add(rankMember);
RANK_LIST.add(rankModerator);
RANK_LIST.add(rankLeader);
RANK_SET_DEFAULT = 5;
RANK_SET_HIGHER = 20;
ADDITIONAL_COLOR_LIST = new HashSet<>(Arrays.asList(new PartyColorImpl("red", "red", "&c", -1, -1, -1), new PartyColorImpl("green", "green", "&a", -1, -1, -1), new PartyColorImpl("yourcustomcolor", "special", "&9&n", -1, -1, -1)));
}
use of com.alessiodp.parties.common.parties.objects.PartyColorImpl in project Parties by AlessioDP.
the class ConfigParties method handleColors.
private void handleColors() {
Set<PartyColorImpl> colors = new HashSet<>();
if (ConfigParties.RAW_ADDITIONAL_COLOR_LIST != null) {
for (String key : ConfigParties.RAW_ADDITIONAL_COLOR_LIST.getKeys(false)) {
PartyColorImpl color = new PartyColorImpl(key);
color.setCommand(ConfigParties.RAW_ADDITIONAL_COLOR_LIST.getString(key + ".command", ""));
color.setCode(ConfigParties.RAW_ADDITIONAL_COLOR_LIST.getString(key + ".code", ""));
color.setDynamicPriority(ConfigParties.RAW_ADDITIONAL_COLOR_LIST.getInt(key + ".dynamic.priority", -1));
color.setDynamicMembers(ConfigParties.RAW_ADDITIONAL_COLOR_LIST.getInt(key + ".dynamic.members", -1));
color.setDynamicKills(ConfigParties.RAW_ADDITIONAL_COLOR_LIST.getInt(key + ".dynamic.kills", -1));
colors.add(color);
}
ConfigParties.ADDITIONAL_COLOR_LIST = colors;
} else {
plugin.getLoggerManager().logError(PartiesConstants.DEBUG_CONFIG_FAILED_COLOR_NOTFOUND);
}
ConfigParties.ADDITIONAL_COLOR_LIST.stream().findFirst().get().setDynamicMembers(15);
}
Aggregations