package com.massivecraft.factions.cmd; import com.massivecraft.factions.Perm; import com.massivecraft.factions.Rel; import com.massivecraft.factions.cmd.arg.ARUPlayer; import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.Faction; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; public class CmdFactionsOfficer extends FCommand { // -------------------------------------------- // // CONSTRUCT // -------------------------------------------- // public CmdFactionsOfficer() { // Aliases this.addAliases("officer"); // Args this.addRequiredArg("player"); // Requirements this.addRequirements(ReqHasPerm.get(Perm.OFFICER.node)); } // -------------------------------------------- // // OVERRIDE // -------------------------------------------- // @Override public void perform() { MPlayer you = this.arg(0, ARUPlayer.getAny()); if (you == null) return; boolean permAny = Perm.OFFICER_ANY.has(sender, false); Faction targetFaction = you.getFaction(); if (targetFaction != usenderFaction && !permAny) { msg("%s is not a member in your faction.", you.describeTo(usender, true)); return; } if (usender != null && usender.getRole() != Rel.LEADER && !permAny) { msg("You are not the faction leader."); return; } if (you == usender && !permAny) { msg("The target player musn't be yourself."); return; } if (you.getRole() == Rel.LEADER) { msg("The target player is a faction leader. Demote them first."); return; } if (you.getRole() == Rel.OFFICER) { // Revoke you.setRole(Rel.MEMBER); targetFaction.msg("%s is no longer officer in your faction.", you.describeTo(targetFaction, true)); msg("You have removed officer status from %s.", you.describeTo(usender, true)); } else { // Give you.setRole(Rel.OFFICER); targetFaction.msg("%s was promoted to officer in your faction.", you.describeTo(targetFaction, true)); msg("You have promoted %s to officer.", you.describeTo(usender, true)); } } }