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

70 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() {
2014-07-01 22:10:18 +02:00
super();
this.aliases.add("mod");
2014-04-04 20:55:21 +02:00
this.requiredArgs.add("player name");
//this.optionalArgs.put("", "");
2014-07-01 22:10:18 +02:00
this.permission = Permission.MOD.node;
this.disableOnLock = true;
2014-04-04 20:55:21 +02:00
2014-07-01 22:10:18 +02:00
senderMustBePlayer = false;
senderMustBeMember = false;
senderMustBeModerator = false;
2014-04-04 20:55:21 +02:00
senderMustBeAdmin = false;
}
@Override
public void perform() {
2014-07-01 22:10:18 +02:00
FPlayer you = this.argAsBestFPlayerMatch(0);
if (you == null) {
return;
}
2014-04-04 20:55:21 +02:00
2014-07-01 22:10:18 +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) {
2014-07-01 22:10:18 +02:00
msg("%s<b> is not a member in your faction.", you.describeTo(fme, true));
return;
2014-04-04 20:55:21 +02:00
}
2014-04-04 20:55:21 +02:00
if (fme != null && fme.getRole() != Role.ADMIN && !permAny) {
2014-07-01 22:10:18 +02:00
msg("<b>You are not the faction admin.");
return;
2014-04-04 20:55:21 +02:00
}
2014-04-04 20:55:21 +02:00
if (you == fme && !permAny) {
2014-07-01 22:10:18 +02:00
msg("<b>The target player musn't be yourself.");
return;
2014-04-04 20:55:21 +02:00
}
2014-04-04 20:55:21 +02:00
if (you.getRole() == Role.ADMIN) {
2014-07-01 22:10:18 +02:00
msg("<b>The target player is a faction admin. Demote them first.");
return;
2014-04-04 20:55:21 +02:00
}
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:52:40 +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));
}
}
}