2018-03-27 01:42:26 +02:00
|
|
|
package com.massivecraft.factions.cmd;
|
|
|
|
|
|
|
|
import com.massivecraft.factions.Conf;
|
|
|
|
import com.massivecraft.factions.FPlayer;
|
|
|
|
import com.massivecraft.factions.Faction;
|
2019-12-25 04:19:49 +01:00
|
|
|
import com.massivecraft.factions.FactionsPlugin;
|
|
|
|
import com.massivecraft.factions.cmd.audit.FLogType;
|
2018-03-27 01:42:26 +02:00
|
|
|
import com.massivecraft.factions.struct.Permission;
|
|
|
|
import com.massivecraft.factions.struct.Role;
|
|
|
|
import com.massivecraft.factions.zcore.util.TL;
|
|
|
|
import mkremins.fanciful.FancyMessage;
|
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
|
|
|
|
public class CmdColeader extends FCommand {
|
2019-12-02 19:55:38 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @author FactionsUUID Team
|
|
|
|
*/
|
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
public CmdColeader() {
|
|
|
|
super();
|
2020-01-02 02:59:31 +01:00
|
|
|
this.aliases.addAll(Aliases.coleader);
|
2019-08-24 19:18:50 +02:00
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
this.optionalArgs.put("player name", "name");
|
2019-08-24 19:18:50 +02:00
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
this.requirements = new CommandRequirements.Builder(Permission.COLEADER)
|
|
|
|
.memberOnly()
|
|
|
|
.withRole(Role.LEADER)
|
|
|
|
.build();
|
|
|
|
}
|
2019-08-24 19:18:50 +02:00
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
@Override
|
|
|
|
public void perform(CommandContext context) {
|
|
|
|
FPlayer you = context.argAsBestFPlayerMatch(0);
|
|
|
|
if (you == null) {
|
|
|
|
FancyMessage msg = new FancyMessage(TL.COMMAND_COLEADER_CANDIDATES.toString()).color(ChatColor.GOLD);
|
|
|
|
for (FPlayer player : context.faction.getFPlayersWhereRole(Role.NORMAL)) {
|
|
|
|
String s = player.getName();
|
|
|
|
msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_MOD_CLICKTOPROMOTE.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " coleader " + s);
|
|
|
|
}
|
|
|
|
for (FPlayer player : context.faction.getFPlayersWhereRole(Role.MODERATOR)) {
|
|
|
|
String s = player.getName();
|
|
|
|
msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_MOD_CLICKTOPROMOTE.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " coleader " + s);
|
|
|
|
}
|
2019-08-24 19:18:50 +02:00
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
context.sendFancyMessage(msg);
|
|
|
|
return;
|
|
|
|
}
|
2019-08-24 19:18:50 +02:00
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
boolean permAny = Permission.COLEADER_ANY.has(context.sender, false);
|
|
|
|
Faction targetFaction = you.getFaction();
|
2019-08-24 19:18:50 +02:00
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
if (targetFaction != context.faction && !permAny) {
|
|
|
|
context.msg(TL.COMMAND_MOD_NOTMEMBER, you.describeTo(context.fPlayer, true));
|
|
|
|
return;
|
|
|
|
}
|
2019-08-24 19:18:50 +02:00
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
if (context.fPlayer != null && context.fPlayer.getRole() != Role.LEADER && !permAny) {
|
|
|
|
context.msg(TL.COMMAND_COLEADER_NOTADMIN);
|
|
|
|
return;
|
|
|
|
}
|
2019-08-24 19:18:50 +02:00
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
if (you == context.fPlayer && !permAny) {
|
|
|
|
context.msg(TL.COMMAND_COLEADER_SELF);
|
|
|
|
return;
|
|
|
|
}
|
2019-08-24 19:18:50 +02:00
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
if (you.getRole() == Role.LEADER) {
|
|
|
|
context.msg(TL.COMMAND_COLEADER_TARGETISADMIN);
|
|
|
|
return;
|
|
|
|
}
|
2019-08-24 19:18:50 +02:00
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
if (you.getRole() == Role.COLEADER) {
|
|
|
|
// Revoke
|
|
|
|
you.setRole(Role.MODERATOR);
|
|
|
|
targetFaction.msg(TL.COMMAND_COLEADER_REVOKED, you.describeTo(targetFaction, true));
|
|
|
|
context.msg(TL.COMMAND_COLEADER_REVOKES, you.describeTo(context.fPlayer, true));
|
|
|
|
} else {
|
|
|
|
// Give
|
|
|
|
you.setRole(Role.COLEADER);
|
|
|
|
targetFaction.msg(TL.COMMAND_COLEADER_PROMOTED, you.describeTo(targetFaction, true));
|
|
|
|
context.msg(TL.COMMAND_COLEADER_PROMOTES, you.describeTo(context.fPlayer, true));
|
2019-12-25 04:19:49 +01:00
|
|
|
FactionsPlugin.instance.getFlogManager().log(targetFaction, FLogType.RANK_EDIT, context.fPlayer.getName(), you.getName(), ChatColor.RED + "Co-Leader");
|
2019-09-15 11:19:06 +02:00
|
|
|
}
|
|
|
|
}
|
2019-08-24 19:18:50 +02:00
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
@Override
|
|
|
|
public TL getUsageTranslation() {
|
|
|
|
return TL.COMMAND_COLEADER_DESCRIPTION;
|
|
|
|
}
|
2018-03-27 01:42:26 +02:00
|
|
|
}
|
2019-09-14 21:13:01 +02:00
|
|
|
|