use of com.alessiodp.parties.common.commands.utils.PartiesCommandData in project Parties by AlessioDP.
the class CommandRename method preRequisites.
@Override
public boolean preRequisites(CommandData commandData) {
User sender = commandData.getSender();
if (sender.isPlayer()) {
PartyPlayerImpl partyPlayer = getPlugin().getPlayerManager().getPlayer(sender.getUUID());
// Checks for command prerequisites
if (!sender.hasPermission(permission)) {
sendNoPermissionMessage(partyPlayer, permission);
return false;
}
if (!sender.hasPermission(PartiesPermission.ADMIN_RENAME_OTHERS)) {
if (!partyPlayer.isInParty()) {
sendMessage(sender, partyPlayer, Messages.PARTIES_COMMON_NOTINPARTY);
return false;
}
// Not using handlePreRequesitesFull for this
if (!getPlugin().getRankManager().checkPlayerRankAlerter(partyPlayer, RankPermission.ADMIN_RENAME))
return false;
if (commandData.getArgs().length != 2) {
sendMessage(sender, partyPlayer, Messages.PARTIES_SYNTAX_WRONG_MESSAGE.replace("%syntax%", syntax));
return false;
}
}
if (commandData.getArgs().length < 2 || commandData.getArgs().length > 3) {
sendMessage(sender, partyPlayer, Messages.PARTIES_SYNTAX_WRONG_MESSAGE.replace("%syntax%", syntax));
return false;
}
((PartiesCommandData) commandData).setPartyPlayer(partyPlayer);
commandData.addPermission(PartiesPermission.ADMIN_RENAME_OTHERS);
commandData.addPermission(PartiesPermission.ADMIN_COOLDOWN_RENAME_BYPASS);
} else {
if (commandData.getArgs().length != 3) {
sendMessage(sender, null, Messages.PARTIES_SYNTAX_WRONG_MESSAGE.replace("%syntax%", syntax));
return false;
}
}
return true;
}
use of com.alessiodp.parties.common.commands.utils.PartiesCommandData in project Parties by AlessioDP.
the class CommandVersion method onCommand.
@Override
public void onCommand(@NotNull CommandData commandData) {
User sender = commandData.getSender();
PartyPlayerImpl partyPlayer = ((PartiesCommandData) commandData).getPartyPlayer();
// Command starts
String version = plugin.getVersion();
String newVersion = plugin.getAdpUpdater().getFoundVersion().isEmpty() ? version : plugin.getAdpUpdater().getFoundVersion();
String message = version.equals(newVersion) ? Messages.MAINCMD_VERSION_UPDATED : Messages.MAINCMD_VERSION_OUTDATED;
sendMessage(sender, partyPlayer, message.replace("%version%", version).replace("%newversion%", newVersion).replace("%platform%", plugin.getPlatform().getName()));
}
use of com.alessiodp.parties.common.commands.utils.PartiesCommandData in project Parties by AlessioDP.
the class BukkitCommandClaim method onCommand.
@Override
public void onCommand(CommandData commandData) {
User sender = commandData.getSender();
PartyPlayerImpl partyPlayer = ((PartiesCommandData) commandData).getPartyPlayer();
PartyImpl party = ((PartiesCommandData) commandData).getParty();
// Command handling
Selection selection = Selection.FAILED_GENERAL;
if (commandData.getArgs()[1].equalsIgnoreCase(BukkitConfigMain.ADDONS_CLAIM_CMD_TRUST))
selection = Selection.TRUST;
else if (commandData.getArgs()[1].equalsIgnoreCase(BukkitConfigMain.ADDONS_CLAIM_CMD_CONTAINER))
selection = Selection.CONTAINER;
else if (commandData.getArgs()[1].equalsIgnoreCase(BukkitConfigMain.ADDONS_CLAIM_CMD_ACCESS))
selection = Selection.ACCESS;
else if (commandData.getArgs()[1].equalsIgnoreCase(BukkitConfigMain.ADDONS_CLAIM_CMD_MANAGER) && ClaimHandler.canChangeManager())
selection = Selection.MANAGER;
else if (commandData.getArgs()[1].equalsIgnoreCase(BukkitConfigMain.ADDONS_CLAIM_CMD_REMOVE))
selection = Selection.REMOVE;
if (!selection.equals(Selection.FAILED_GENERAL)) {
Player bukkitSender = Bukkit.getPlayer(sender.getUUID());
if (bukkitSender == null)
return;
ClaimHandler.Result res = ClaimHandler.isManager(bukkitSender);
switch(res) {
case NOEXIST:
selection = Selection.FAILED_NOEXIST;
break;
case NOMANAGER:
selection = Selection.FAILED_NOMANAGER;
break;
default:
// Success, selection it's okay
break;
}
}
if (getPlugin().getEconomyManager().payCommand(EconomyManager.PaidCommand.CLAIM, partyPlayer, commandData.getCommandLabel(), commandData.getArgs()))
return;
// Command starts
switch(selection) {
case FAILED_NOEXIST:
// Return: No exist claim
sendMessage(sender, partyPlayer, BukkitMessages.ADDCMD_CLAIM_CLAIMNOEXISTS);
break;
case FAILED_NOMANAGER:
// Return: No manager
sendMessage(sender, partyPlayer, BukkitMessages.ADDCMD_CLAIM_NOMANAGER);
break;
case FAILED_GENERAL:
// Return: Wrong command
sendMessage(sender, partyPlayer, Messages.PARTIES_SYNTAX_WRONG_MESSAGE.replace("%syntax%", syntax));
sendMessage(sender, partyPlayer, BukkitMessages.ADDCMD_CLAIM_ALLOWED_PERMISSIONS);
break;
default:
ClaimHandler.addPartyPermission(Bukkit.getPlayer(commandData.getSender().getUUID()), party, selection.getPermission());
sendMessage(sender, partyPlayer, selection.getPermission().isRemove() ? BukkitMessages.ADDCMD_CLAIM_REMOVED : BukkitMessages.ADDCMD_CLAIM_CLAIMED);
plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_CMD_CLAIM, partyPlayer.getName(), selection.name()), true);
break;
}
}
use of com.alessiodp.parties.common.commands.utils.PartiesCommandData in project Parties by AlessioDP.
the class CommandCreate method onCommand.
@Override
public void onCommand(@NotNull CommandData commandData) {
User sender = commandData.getSender();
PartyPlayerImpl partyPlayer = ((PartiesCommandData) commandData).getPartyPlayer();
// Command handling
String partyName;
if (commandData.getArgs().length > 1) {
if (!ConfigParties.GENERAL_NAME_DYNAMIC_ENABLE || ConfigParties.GENERAL_NAME_DYNAMIC_ALLOW_IN_CREATE) {
partyName = commandData.getArgs()[1];
if (!checkName(this, sender, partyPlayer, partyName))
return;
} else {
sendMessage(sender, partyPlayer, Messages.PARTIES_SYNTAX_WRONG_MESSAGE.replace("%syntax%", syntax));
return;
}
} else {
if (!ConfigParties.GENERAL_NAME_DYNAMIC_ENABLE) {
sendMessage(sender, partyPlayer, Messages.PARTIES_SYNTAX_WRONG_MESSAGE.replace("%syntax%", syntax));
return;
}
partyName = generateDynamicName(getPlugin(), partyPlayer);
}
if (getPlugin().getPartyManager().existsParty(partyName)) {
sendMessage(sender, partyPlayer, Messages.MAINCMD_CREATE_NAMEEXISTS.replace("%party%", partyName));
return;
}
if (partyPlayer != null && getPlugin().getEconomyManager().payCommand(EconomyManager.PaidCommand.CREATE, partyPlayer, commandData.getCommandLabel(), commandData.getArgs()))
return;
// Command starts
createParty((PartiesPlugin) plugin, this, sender, partyPlayer, partyName, false);
}
use of com.alessiodp.parties.common.commands.utils.PartiesCommandData in project Parties by AlessioDP.
the class CommandCreateFixed method onCommand.
@Override
public void onCommand(@NotNull CommandData commandData) {
User sender = commandData.getSender();
PartyPlayerImpl partyPlayer = ((PartiesCommandData) commandData).getPartyPlayer();
// Command handling
String partyName = commandData.getArgs()[1];
if (!CommandCreate.checkName(this, sender, partyPlayer, partyName))
return;
if (getPlugin().getPartyManager().existsParty(partyName)) {
sendMessage(sender, partyPlayer, Messages.MAINCMD_CREATE_NAMEEXISTS.replace("%party%", partyName));
return;
}
// Command starts
CommandCreate.createParty((PartiesPlugin) plugin, this, sender, partyPlayer, partyName, true);
}
Aggregations