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

69 lines
2.1 KiB
Java
Raw Normal View History

2011-10-09 21:57:43 +02:00
package com.massivecraft.factions.cmd;
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;
2014-04-04 20:55:21 +02:00
public class CmdMod extends FCommand {
public CmdMod() {
super();
this.aliases.add("mod");
this.requiredArgs.add("player name");
//this.optionalArgs.put("", "");
this.permission = Permission.MOD.node;
this.disableOnLock = true;
senderMustBePlayer = false;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = false;
}
@Override
public void perform() {
FPlayer you = this.argAsBestFPlayerMatch(0);
2014-07-01 21:49:42 +02:00
if (you == null) { return; }
2014-04-04 20:55:21 +02:00
boolean permAny = Permission.MOD_ANY.has(sender, false);
Faction targetFaction = you.getFaction();
2014-04-04 20:55:21 +02:00
if (targetFaction != myFaction && !permAny) {
msg("%s<b> is not a member in your faction.", you.describeTo(fme, true));
return;
}
2014-04-04 20:55:21 +02:00
if (fme != null && fme.getRole() != Role.ADMIN && !permAny) {
msg("<b>You are not the faction admin.");
return;
}
2014-04-04 20:55:21 +02:00
if (you == fme && !permAny) {
msg("<b>The target player musn't be yourself.");
return;
}
2014-04-04 20:55:21 +02:00
if (you.getRole() == Role.ADMIN) {
msg("<b>The target player is a faction admin. Demote them first.");
return;
}
2014-04-04 20:55:21 +02:00
if (you.getRole() == Role.MODERATOR) {
// Revoke
you.setRole(Role.NORMAL);
targetFaction.msg("%s<i> is no longer moderator in your faction.", you.describeTo(targetFaction, true));
msg("<i>You have removed moderator status from %s<i>.", you.describeTo(fme, true));
2014-07-01 21:49:42 +02:00
}
else {
2014-04-04 20:55:21 +02:00
// Give
you.setRole(Role.MODERATOR);
targetFaction.msg("%s<i> was promoted to moderator in your faction.", you.describeTo(targetFaction, true));
msg("<i>You have promoted %s<i> to moderator.", you.describeTo(fme, true));
}
}
}