use of com.alessiodp.parties.parties.objects.PartyEntity in project Parties by AlessioDP.
the class CommandMotd 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.MOTD.toString())) {
pp.sendNoPermission(PartiesPermission.MOTD);
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_MOTD))
return false;
if (commandData.getArgs().length < 2) {
pp.sendMessage(Messages.ADDCMD_MOTD_WRONGCMD);
return false;
}
commandData.setPlayer(player);
commandData.setPartyPlayer(pp);
commandData.setParty(party);
return true;
}
use of com.alessiodp.parties.parties.objects.PartyEntity in project Parties by AlessioDP.
the class CommandAccept method onCommand.
@Override
public void onCommand(CommandData commandData) {
PartyPlayerEntity pp = commandData.getPartyPlayer();
PartyEntity party = plugin.getPartyManager().getParty(pp.getLastInvite());
if (party == null) {
pp.sendMessage(Messages.MAINCMD_ACCEPT_NOEXISTS);
return;
}
if ((ConfigParties.GENERAL_MEMBERSLIMIT != -1) && (party.getMembers().size() >= ConfigParties.GENERAL_MEMBERSLIMIT)) {
pp.sendMessage(Messages.PARTIES_COMMON_PARTYFULL);
return;
}
/*
* Command starts
*/
party.acceptInvite(pp.getPlayerUUID());
LoggerManager.log(LogLevel.MEDIUM, Constants.DEBUG_CMD_ACCEPT.replace("{player}", pp.getName()).replace("{party}", party.getName()), true);
}
use of com.alessiodp.parties.parties.objects.PartyEntity in project Parties by AlessioDP.
the class CommandClaim method onCommand.
@Override
public void onCommand(CommandData commandData) {
PartyPlayerEntity pp = commandData.getPartyPlayer();
PartyEntity party = commandData.getParty();
/*
* Command handling
*/
if (commandData.getArgs().length != 2) {
pp.sendMessage(Messages.ADDCMD_CLAIM_WRONGCMD);
return;
}
Selection selection = Selection.FAILED_GENERAL;
if (commandData.getArgs()[1].equalsIgnoreCase(ConfigMain.ADDONS_GRIEFPREVENTION_CMD_TRUST))
selection = Selection.TRUST;
else if (commandData.getArgs()[1].equalsIgnoreCase(ConfigMain.ADDONS_GRIEFPREVENTION_CMD_CONTAINER))
selection = Selection.CONTAINER;
else if (commandData.getArgs()[1].equalsIgnoreCase(ConfigMain.ADDONS_GRIEFPREVENTION_CMD_ACCESS))
selection = Selection.ACCESS;
else if (commandData.getArgs()[1].equalsIgnoreCase(ConfigMain.ADDONS_GRIEFPREVENTION_CMD_REMOVE))
selection = Selection.REMOVE;
if (!selection.equals(Selection.FAILED_GENERAL)) {
Result res = GriefPreventionHandler.isManager(commandData.getPlayer());
switch(res) {
case NOEXIST:
selection = Selection.FAILED_NOEXIST;
break;
case NOMANAGER:
selection = Selection.FAILED_NOMANAGER;
break;
default:
// Success, selection it's okay
break;
}
}
if (VaultHandler.payCommand(VaultHandler.VaultCommand.CLAIM, pp, commandData.getCommandLabel(), commandData.getArgs()))
return;
/*
* Command starts
*/
switch(selection) {
case FAILED_NOEXIST:
// Return: No exist claim
pp.sendMessage(Messages.ADDCMD_CLAIM_CLAIMNOEXISTS);
break;
case FAILED_NOMANAGER:
// Return: No manager
pp.sendMessage(Messages.ADDCMD_CLAIM_NOMANAGER);
break;
case FAILED_GENERAL:
// Return: Wrong command
pp.sendMessage(Messages.ADDCMD_CLAIM_WRONGCMD);
break;
default:
GriefPreventionHandler.addPartyPermission(commandData.getPlayer(), party, selection.getGPPermission());
pp.sendMessage(Messages.ADDCMD_CLAIM_CLAIMED);
LoggerManager.log(LogLevel.MEDIUM, Constants.DEBUG_CMD_CLAIM.replace("{player}", pp.getName()).replace("{value}", commandData.getArgs()[1].toLowerCase()), true);
}
}
use of com.alessiodp.parties.parties.objects.PartyEntity in project Parties by AlessioDP.
the class CommandDeny method onCommand.
@Override
public void onCommand(CommandData commandData) {
PartyPlayerEntity pp = commandData.getPartyPlayer();
PartyEntity party = commandData.getParty();
/*
* Command starts
*/
party.denyInvite(pp.getPlayerUUID());
LoggerManager.log(LogLevel.MEDIUM, Constants.DEBUG_CMD_DENY.replace("{player}", pp.getName()).replace("{party}", party.getName()), true);
}
use of com.alessiodp.parties.parties.objects.PartyEntity in project Parties by AlessioDP.
the class CommandHome method onCommand.
@Override
public void onCommand(CommandData commandData) {
PartyPlayerEntity pp = commandData.getPartyPlayer();
/*
* Command handling
*/
PartyEntity party;
if (commandData.getArgs().length > 1)
party = plugin.getPartyManager().getParty(commandData.getArgs()[1]);
else
party = plugin.getPartyManager().getParty(pp.getPartyName());
if (party == null) {
if (commandData.getArgs().length > 1)
pp.sendMessage(Messages.ADDCMD_HOME_NOEXISTS);
else
pp.sendMessage(Messages.PARTIES_COMMON_NOTINPARTY);
return;
}
if (commandData.getArgs().length == 1 && !PartiesUtils.checkPlayerRankAlerter(pp, PartiesPermission.PRIVATE_HOME))
return;
if (party.getHome() == null) {
pp.sendMessage(Messages.ADDCMD_HOME_NOHOME, party);
return;
}
if (VaultHandler.payCommand(VaultHandler.VaultCommand.HOME, pp, commandData.getCommandLabel(), commandData.getArgs()))
return;
/*
* Command starts
*/
int delay = ConfigParties.HOME_DELAY;
for (PermissionAttachmentInfo pa : commandData.getPlayer().getEffectivePermissions()) {
String perm = pa.getPermission();
if (perm.startsWith("parties.home.")) {
String[] splitted = perm.split("\\.");
try {
delay = Integer.parseInt(splitted[2]);
} catch (Exception ex) {
}
}
}
if (delay > 0) {
pp.setHomeFrom(commandData.getPlayer().getLocation());
plugin.getPlayerManager().addHomeCount();
BukkitTask it = new HomeTask(plugin, pp, party.getHome()).runTaskLater(plugin, delay * 20);
pp.setHomeTask(it.getTaskId());
pp.sendMessage(Messages.ADDCMD_HOME_TELEPORTIN.replace("%time%", Integer.toString(delay)));
} else {
plugin.getPartiesScheduler().runSync(() -> {
commandData.getPlayer().teleport(party.getHome());
});
pp.sendMessage(Messages.ADDCMD_HOME_TELEPORTED);
}
LoggerManager.log(LogLevel.MEDIUM, Constants.DEBUG_CMD_HOME.replace("{player}", pp.getName()).replace("{party}", party.getName()), true);
}
Aggregations