Saber-Factions/src/main/java/com/massivecraft/factions/cmd/CmdMod.java

96 lines
2.5 KiB
Java
Raw Normal View History

2011-10-09 21:57:43 +02:00
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Conf;
2011-07-18 22:06:02 +02:00
import com.massivecraft.factions.FPlayer;
2014-04-04 20:55:21 +02:00
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.Permission;
2011-07-18 22:06:02 +02:00
import com.massivecraft.factions.struct.Role;
import com.massivecraft.factions.zcore.util.TL;
import mkremins.fanciful.FancyMessage;
import org.bukkit.ChatColor;
2014-04-04 20:55:21 +02:00
public class CmdMod extends FCommand {
public CmdMod() {
super();
this.aliases.add("mod");
this.aliases.add("setmod");
this.aliases.add("officer");
this.aliases.add("setofficer");
this.optionalArgs.put("player name", "name");
//this.optionalArgs.put("", "");
this.permission = Permission.MOD.node;
this.disableOnLock = true;
senderMustBePlayer = false;
senderMustBeMember = true;
senderMustBeModerator = false;
senderMustBeColeader = true;
senderMustBeAdmin = false;
}
@Override
public void perform() {
FPlayer you = this.argAsBestFPlayerMatch(0);
if (you == null) {
FancyMessage msg = new FancyMessage(TL.COMMAND_MOD_CANDIDATES.toString()).color(ChatColor.GOLD);
for (FPlayer player : myFaction.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) + " mod " + s);
}
sendFancyMessage(msg);
return;
}
boolean permAny = Permission.MOD_ANY.has(sender, false);
Faction targetFaction = you.getFaction();
if(you.isAlt()){
msg(ChatColor.RED + "You can not promote alt accounts.");
return;
}
if (targetFaction != myFaction && !permAny) {
msg(TL.COMMAND_MOD_NOTMEMBER, you.describeTo(fme, true));
return;
}
if (fme != null && fme.getRole() != Role.LEADER && !permAny) {
msg(TL.COMMAND_MOD_NOTADMIN);
return;
}
if (you == fme && !permAny) {
msg(TL.COMMAND_MOD_SELF);
return;
}
if (you.getRole() == Role.LEADER) {
msg(TL.COMMAND_MOD_TARGETISADMIN);
return;
}
if (you.getRole() == Role.MODERATOR) {
// Revoke
you.setRole(Role.NORMAL);
targetFaction.msg(TL.COMMAND_MOD_REVOKED, you.describeTo(targetFaction, true));
msg(TL.COMMAND_MOD_REVOKES, you.describeTo(fme, true));
} else {
// Give
you.setRole(Role.MODERATOR);
targetFaction.msg(TL.COMMAND_MOD_PROMOTED, you.describeTo(targetFaction, true));
msg(TL.COMMAND_MOD_PROMOTES, you.describeTo(fme, true));
}
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_MOD_DESCRIPTION;
}
}