2018-09-21 08:28:20 +02:00
|
|
|
package com.massivecraft.factions.cmd;
|
|
|
|
|
2019-07-04 07:12:39 +02:00
|
|
|
import com.massivecraft.factions.Faction;
|
2019-09-14 21:13:01 +02:00
|
|
|
import com.massivecraft.factions.FactionsPlugin;
|
2018-09-21 08:29:28 +02:00
|
|
|
import com.massivecraft.factions.struct.Permission;
|
2019-11-01 21:35:32 +01:00
|
|
|
import com.massivecraft.factions.struct.Role;
|
2018-09-21 08:29:28 +02:00
|
|
|
import com.massivecraft.factions.zcore.util.TL;
|
|
|
|
|
2018-11-07 06:38:43 +01:00
|
|
|
public class CmdPaypalSet extends FCommand {
|
2018-09-21 08:29:28 +02:00
|
|
|
|
2019-12-02 20:03:27 +01:00
|
|
|
/**
|
|
|
|
* @author Driftay
|
|
|
|
*/
|
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
public CmdPaypalSet() {
|
2020-01-02 02:59:31 +01:00
|
|
|
this.aliases.addAll(Aliases.paypal_set);
|
2019-07-04 07:12:39 +02:00
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
this.optionalArgs.put("faction", "yours");
|
2019-07-04 07:12:39 +02:00
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
this.requiredArgs.add("email");
|
2019-07-04 07:12:39 +02:00
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
this.requirements = new CommandRequirements.Builder(Permission.PAYPALSET)
|
|
|
|
.playerOnly()
|
|
|
|
.memberOnly()
|
|
|
|
.build();
|
2019-07-04 07:12:39 +02:00
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
}
|
2019-07-04 07:12:39 +02:00
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
@Override
|
|
|
|
public void perform(CommandContext context) {
|
|
|
|
if (!FactionsPlugin.getInstance().getConfig().getBoolean("fpaypal.Enabled")) {
|
2019-12-03 11:16:37 +01:00
|
|
|
context.fPlayer.msg(TL.GENERIC_DISABLED, "Faction Paypals");
|
2019-09-15 11:19:06 +02:00
|
|
|
return;
|
|
|
|
}
|
2019-11-01 21:35:32 +01:00
|
|
|
if (context.fPlayer.getRole() != Role.LEADER && !context.fPlayer.isAdminBypassing()) {
|
|
|
|
//TODO: Create f perm for this
|
|
|
|
context.msg(TL.GENERIC_NOPERMISSION, "set your factions PayPal!");
|
|
|
|
return;
|
|
|
|
}
|
2019-07-04 07:12:39 +02:00
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
if (context.args.size() == 1) {
|
|
|
|
if (isEmail(context.argAsString(0))) {
|
|
|
|
context.fPlayer.getFaction().paypalSet(context.argAsString(0));
|
|
|
|
context.msg(TL.COMMAND_PAYPALSET_SUCCESSFUL, context.argAsString(0));
|
|
|
|
} else {
|
|
|
|
context.msg(TL.COMMAND_PAYPALSET_NOTEMAIL, context.argAsString(0));
|
|
|
|
}
|
|
|
|
} else if (context.args.size() == 2) {
|
|
|
|
if (context.fPlayer.isAdminBypassing()) {
|
|
|
|
Faction faction = context.argAsFaction(1);
|
|
|
|
if (faction != null) {
|
|
|
|
if (isEmail(context.argAsString(0))) {
|
|
|
|
context.fPlayer.getFaction().paypalSet(context.argAsString(0));
|
|
|
|
context.msg(TL.COMMAND_PAYPALSET_ADMIN_SUCCESSFUL, faction.getTag(), context.argAsString(0));
|
|
|
|
} else {
|
|
|
|
context.msg(TL.COMMAND_PAYPALSET_ADMIN_FAILED, context.argAsString(0));
|
2019-07-04 07:12:39 +02:00
|
|
|
}
|
2019-09-15 11:19:06 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
context.msg(TL.GENERIC_NOPERMISSION, "set another factions paypal!");
|
|
|
|
}
|
|
|
|
} else {
|
2019-09-15 22:33:22 +02:00
|
|
|
context.msg(FactionsPlugin.getInstance().cmdBase.cmdPaypalSet.getUsageTemplate(context));
|
2019-09-15 11:19:06 +02:00
|
|
|
}
|
|
|
|
}
|
2019-07-04 07:12:39 +02:00
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
private boolean isEmail(String email) {
|
|
|
|
return email.contains("@") && email.contains(".");
|
|
|
|
}
|
2019-07-04 07:12:39 +02:00
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
@Override
|
|
|
|
public TL getUsageTranslation() {
|
|
|
|
return TL.COMMAND_PAYPALSET_DESCRIPTION;
|
|
|
|
}
|
2018-09-21 08:28:20 +02:00
|
|
|
}
|
2018-09-21 08:29:28 +02:00
|
|
|
|