Factions3/src/main/java/net/knarcraft/factions/cmd/CmdFactionsDescription.java

56 lines
1.8 KiB
Java

package net.knarcraft.factions.cmd;
import net.knarcraft.factions.cmd.req.ReqHasFaction;
import net.knarcraft.factions.entity.MPerm;
import net.knarcraft.factions.entity.MPlayer;
import net.knarcraft.factions.event.EventFactionsDescriptionChange;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.command.type.primitive.TypeString;
import com.massivecraft.massivecore.mixin.MixinDisplayName;
public class CmdFactionsDescription extends FactionsCommand {
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsDescription() {
// Parameters
this.addParameter(TypeString.get(), "desc", true).setDesc("the new faction desciption");
// Requirements
this.addRequirements(ReqHasFaction.get());
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform() throws MassiveException {
// Args
String newDescription = this.readArg();
// MPerm
if (!MPerm.getPermDesc().has(msender, msenderFaction, true)) {
return;
}
// Event
EventFactionsDescriptionChange event = new EventFactionsDescriptionChange(sender, msenderFaction, newDescription);
event.run();
if (event.isCancelled()) {
return;
}
newDescription = event.getNewDescription();
// Apply
msenderFaction.setDescription(newDescription);
// Inform
for (MPlayer follower : msenderFaction.getMPlayers()) {
follower.msg("<i>%s <i>set your faction description to:\n%s", MixinDisplayName.get().getDisplayName(sender, follower), msenderFaction.getDescriptionDesc());
}
}
}