2011-10-09 21:57:43 +02:00
|
|
|
package com.massivecraft.factions.cmd;
|
2011-03-22 15:45:41 +01:00
|
|
|
|
2014-12-19 13:51:24 +01:00
|
|
|
import com.massivecraft.factions.Conf;
|
2011-07-18 22:06:02 +02:00
|
|
|
import com.massivecraft.factions.FPlayer;
|
2014-11-14 17:08:18 +01:00
|
|
|
import com.massivecraft.factions.FPlayers;
|
2019-09-14 21:13:01 +02:00
|
|
|
import com.massivecraft.factions.FactionsPlugin;
|
2011-10-09 14:53:38 +02:00
|
|
|
import com.massivecraft.factions.struct.Permission;
|
2018-08-05 03:32:36 +02:00
|
|
|
import com.massivecraft.factions.struct.Role;
|
|
|
|
import com.massivecraft.factions.zcore.fperms.Access;
|
|
|
|
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
2014-12-08 00:12:52 +01:00
|
|
|
import com.massivecraft.factions.zcore.util.TL;
|
2015-05-25 22:46:18 +02:00
|
|
|
import mkremins.fanciful.FancyMessage;
|
|
|
|
import org.bukkit.ChatColor;
|
2011-03-22 15:45:41 +01:00
|
|
|
|
2014-04-04 20:55:21 +02:00
|
|
|
public class CmdDeinvite extends FCommand {
|
|
|
|
|
2019-12-02 19:55:38 +01:00
|
|
|
/**
|
|
|
|
* @author FactionsUUID Team
|
|
|
|
*/
|
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
public CmdDeinvite() {
|
|
|
|
super();
|
2020-01-02 02:59:31 +01:00
|
|
|
this.aliases.addAll(Aliases.deinvite);
|
2019-09-15 11:19:06 +02:00
|
|
|
|
|
|
|
this.optionalArgs.put("player name", "name");
|
|
|
|
|
|
|
|
this.requirements = new CommandRequirements.Builder(Permission.DEINVITE)
|
|
|
|
.memberOnly()
|
|
|
|
.build();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void perform(CommandContext context) {
|
2020-01-18 08:18:38 +01:00
|
|
|
if (context.args.size() == 0) {
|
|
|
|
FancyMessage msg = new FancyMessage(TL.COMMAND_DEINVITE_CANDEINVITE.toString()).color(ChatColor.GOLD);
|
|
|
|
for (String id : context.faction.getInvites()) {
|
|
|
|
FPlayer fp = FPlayers.getInstance().getById(id);
|
|
|
|
String name = fp != null ? fp.getName() : id;
|
|
|
|
msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_DEINVITE_CLICKTODEINVITE.format(name)).command("/" + Conf.baseCommandAliases.get(0) + " deinvite " + name);
|
2019-09-15 11:19:06 +02:00
|
|
|
}
|
2020-01-18 08:18:38 +01:00
|
|
|
context.sendFancyMessage(msg);
|
|
|
|
return;
|
|
|
|
}
|
2019-09-15 11:19:06 +02:00
|
|
|
|
2020-01-18 08:18:38 +01:00
|
|
|
FPlayer you = context.argAsBestFPlayerMatch(0);
|
|
|
|
if (!context.fPlayer.isAdminBypassing()) {
|
|
|
|
Access access = context.faction.getAccess(context.fPlayer, PermissableAction.INVITE);
|
|
|
|
if (access != Access.ALLOW && context.fPlayer.getRole() != Role.LEADER) {
|
|
|
|
context.msg(TL.GENERIC_FPERM_NOPERMISSION, "manage invites");
|
2019-09-15 11:19:06 +02:00
|
|
|
return;
|
|
|
|
}
|
2020-01-18 08:18:38 +01:00
|
|
|
}
|
2019-09-15 11:19:06 +02:00
|
|
|
|
2020-01-18 08:18:38 +01:00
|
|
|
if (you == null) {
|
|
|
|
FancyMessage msg = new FancyMessage(TL.COMMAND_DEINVITE_CANDEINVITE.toString()).color(ChatColor.GOLD);
|
|
|
|
for (String id : context.faction.getInvites()) {
|
|
|
|
if (context.faction.getInvites().isEmpty()) return;
|
|
|
|
FPlayer fp = FPlayers.getInstance().getById(id);
|
|
|
|
String name = fp != null ? fp.getName() : id;
|
|
|
|
msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_DEINVITE_CLICKTODEINVITE.format(name)).command("/" + Conf.baseCommandAliases.get(0) + " deinvite " + name);
|
2019-09-15 11:19:06 +02:00
|
|
|
}
|
2020-01-18 08:18:38 +01:00
|
|
|
context.sendFancyMessage(msg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (you.getFaction() == context.faction) {
|
|
|
|
context.msg(TL.COMMAND_DEINVITE_ALREADYMEMBER, you.getName(), context.faction.getTag());
|
|
|
|
context.msg(TL.COMMAND_DEINVITE_MIGHTWANT, FactionsPlugin.getInstance().cmdBase.cmdKick.getUsageTemplate(context));
|
|
|
|
return;
|
|
|
|
}
|
2019-09-15 11:19:06 +02:00
|
|
|
|
2020-01-18 08:18:38 +01:00
|
|
|
context.faction.deinvite(you);
|
|
|
|
you.msg(TL.COMMAND_DEINVITE_REVOKED, context.fPlayer.describeTo(you), context.faction.describeTo(you));
|
|
|
|
context.faction.msg(TL.COMMAND_DEINVITE_REVOKES, context.fPlayer.describeTo(context.faction), you.describeTo(context.faction));
|
2019-09-15 11:19:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public TL getUsageTranslation() {
|
|
|
|
return TL.COMMAND_DEINVITE_DESCRIPTION;
|
|
|
|
}
|
2015-01-22 00:58:33 +01:00
|
|
|
|
2011-03-22 15:45:41 +01:00
|
|
|
}
|
2019-09-14 21:13:01 +02:00
|
|
|
|