use of com.alessiodp.parties.players.objects.PartyPlayerEntity in project Parties by AlessioDP.
the class CommandSetHome method onCommand.
@Override
public void onCommand(CommandData commandData) {
PartyPlayerEntity pp = commandData.getPartyPlayer();
PartyEntity party = commandData.getParty();
/*
* Command handling
*/
boolean isRemove = false;
Location home = null;
if (commandData.getArgs().length > 1 && commandData.getArgs()[1].equalsIgnoreCase(ConfigMain.COMMANDS_SUB_REMOVE)) {
// Remove command
isRemove = true;
} else {
// Normal command
if (VaultHandler.payCommand(VaultHandler.VaultCommand.SETHOME, pp, commandData.getCommandLabel(), commandData.getArgs()))
return;
home = commandData.getPlayer().getLocation();
}
/*
* Command starts
*/
party.setHome(home);
party.updateParty();
if (isRemove) {
pp.sendMessage(Messages.ADDCMD_SETHOME_REMOVED);
LoggerManager.log(LogLevel.MEDIUM, Constants.DEBUG_CMD_SETHOME_REM.replace("{player}", pp.getName()).replace("{party}", party.getName()), true);
} else {
pp.sendMessage(Messages.ADDCMD_SETHOME_CHANGED);
party.sendBroadcast(pp, Messages.ADDCMD_SETHOME_BROADCAST);
LoggerManager.log(LogLevel.MEDIUM, Constants.DEBUG_CMD_SETHOME.replace("{player}", pp.getName()).replace("{party}", party.getName()), true);
}
}
use of com.alessiodp.parties.players.objects.PartyPlayerEntity in project Parties by AlessioDP.
the class CommandSuffix method onCommand.
@Override
public void onCommand(CommandData commandData) {
PartyPlayerEntity pp = commandData.getPartyPlayer();
PartyEntity party = commandData.getParty();
/*
* Command handling
*/
boolean isRemove = false;
String prefix = "";
if (commandData.getArgs()[1].equalsIgnoreCase(ConfigMain.COMMANDS_SUB_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]);
}
if (!Pattern.compile(ConfigMain.ADDITIONAL_TAG_CUSTOM_ALLOWEDCHARS).matcher(sb.toString()).matches() || (sb.toString().length() > ConfigMain.ADDITIONAL_TAG_CUSTOM_MAXLENGTH) || (sb.toString().length() < ConfigMain.ADDITIONAL_TAG_CUSTOM_MINLENGTH)) {
pp.sendMessage(Messages.ADDCMD_SUFFIX_INVALID);
return;
}
if (PartiesUtils.checkCensor(sb.toString())) {
pp.sendMessage(Messages.ADDCMD_SUFFIX_CENSORED);
return;
}
if (VaultHandler.payCommand(VaultHandler.VaultCommand.SUFFIX, pp, commandData.getCommandLabel(), commandData.getArgs()))
return;
prefix = sb.toString();
}
/*
* Command starts
*/
party.setSuffix(prefix);
party.updateParty();
if (isRemove) {
pp.sendMessage(Messages.ADDCMD_SUFFIX_REMOVED);
LoggerManager.log(LogLevel.MEDIUM, Constants.DEBUG_CMD_SUFFIX_REM.replace("{player}", pp.getName()).replace("{party}", party.getName()), true);
} else {
pp.sendMessage(Messages.ADDCMD_SUFFIX_CHANGED);
party.sendBroadcast(pp, Messages.ADDCMD_SUFFIX_BROADCAST);
LoggerManager.log(LogLevel.MEDIUM, Constants.DEBUG_CMD_SUFFIX.replace("{player}", pp.getName()).replace("{party}", party.getName()), true);
}
}
use of com.alessiodp.parties.players.objects.PartyPlayerEntity in project Parties by AlessioDP.
the class CommandClaim method preRequisites.
@Override
public boolean preRequisites(CommandData commandData) {
Player player = (Player) commandData.getSender();
PartyPlayerEntity pp = plugin.getPlayerManager().getPlayer(player.getUniqueId());
/*
* Checks for command prerequisites
*/
if (!player.hasPermission(PartiesPermission.CLAIM.toString())) {
pp.sendNoPermission(PartiesPermission.CLAIM);
;
return false;
}
PartyEntity party = pp.getPartyName().isEmpty() ? null : plugin.getPartyManager().getParty(pp.getPartyName());
if (party == null) {
pp.sendMessage(Messages.PARTIES_COMMON_NOTINPARTY);
return false;
}
if (!PartiesUtils.checkPlayerRankAlerter(pp, PartiesPermission.PRIVATE_CLAIM))
return false;
commandData.setPlayer(player);
commandData.setPartyPlayer(pp);
commandData.setParty(party);
return true;
}
use of com.alessiodp.parties.players.objects.PartyPlayerEntity in project Parties by AlessioDP.
the class CommandColor method preRequisites.
@Override
public boolean preRequisites(CommandData commandData) {
Player player = (Player) commandData.getSender();
PartyPlayerEntity pp = plugin.getPlayerManager().getPlayer(player.getUniqueId());
/*
* Checks for command prerequisites
*/
if (!player.hasPermission(PartiesPermission.COLOR.toString())) {
pp.sendNoPermission(PartiesPermission.COLOR);
return false;
}
PartyEntity party = pp.getPartyName().isEmpty() ? null : plugin.getPartyManager().getParty(pp.getPartyName());
if (party == null) {
pp.sendMessage(Messages.PARTIES_COMMON_NOTINPARTY);
return false;
}
if (!PartiesUtils.checkPlayerRankAlerter(pp, PartiesPermission.PRIVATE_EDIT_COLOR))
return false;
if (commandData.getArgs().length > 2) {
pp.sendMessage(Messages.ADDCMD_COLOR_WRONGCMD);
return false;
}
commandData.setPlayer(player);
commandData.setPartyPlayer(pp);
commandData.setParty(party);
return true;
}
use of com.alessiodp.parties.players.objects.PartyPlayerEntity in project Parties by AlessioDP.
the class CommandColor method onCommand.
@Override
public void onCommand(CommandData commandData) {
PartyPlayerEntity pp = commandData.getPartyPlayer();
PartyEntity party = commandData.getParty();
/*
* Command handling
*/
if (commandData.getArgs().length == 1) {
// Automatically pp.sendMessage put color placeholders
if (party.getColor() != null)
pp.sendMessage(Messages.ADDCMD_COLOR_INFO);
else
pp.sendMessage(Messages.ADDCMD_COLOR_EMPTY);
return;
}
boolean isRemove = false;
Color color = null;
if (commandData.getArgs()[1].equalsIgnoreCase(ConfigMain.COMMANDS_SUB_REMOVE)) {
// Remove command
isRemove = true;
} else {
// Normal command
color = plugin.getColorManager().searchColorByCommand(commandData.getArgs()[1]);
if (color == null) {
// Color doesn't exist
pp.sendMessage(Messages.ADDCMD_COLOR_WRONGCOLOR);
return;
}
if (VaultHandler.payCommand(VaultHandler.VaultCommand.COLOR, pp, commandData.getCommandLabel(), commandData.getArgs()))
return;
}
/*
* Command starts
*/
party.setColor(color);
party.updateParty();
party.callChange();
if (isRemove) {
pp.sendMessage(Messages.ADDCMD_COLOR_REMOVED);
LoggerManager.log(LogLevel.MEDIUM, Constants.DEBUG_CMD_COLOR_REM.replace("{player}", pp.getName()).replace("{party}", party.getName()), true);
} else {
pp.sendMessage(Messages.ADDCMD_COLOR_CHANGED, party);
party.sendBroadcast(pp, Messages.ADDCMD_COLOR_BROADCAST);
LoggerManager.log(LogLevel.MEDIUM, Constants.DEBUG_CMD_COLOR.replace("{player}", pp.getName()).replace("{party}", party.getName()).replace("{value}", color.getName()), true);
}
}
Aggregations