Factions/src/com/massivecraft/factions/cmd/CmdFactionsDescription.java

62 lines
1.8 KiB
Java
Raw Normal View History

2011-10-09 21:57:43 +02:00
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.req.ReqHasFaction;
import com.massivecraft.factions.entity.MPerm;
import com.massivecraft.factions.entity.MPlayer;
2014-06-04 16:47:01 +02:00
import com.massivecraft.factions.event.EventFactionsDescriptionChange;
2015-05-06 17:04:35 +02:00
import com.massivecraft.massivecore.MassiveException;
2015-11-06 02:10:29 +01:00
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.type.primitive.TypeString;
2014-06-04 14:02:23 +02:00
import com.massivecraft.massivecore.mixin.Mixin;
2014-09-18 13:41:20 +02:00
public class CmdFactionsDescription extends FactionsCommand
{
2013-11-11 09:31:04 +01:00
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
2013-04-10 13:12:22 +02:00
public CmdFactionsDescription()
{
2013-11-11 09:31:04 +01:00
// Aliases
2015-10-21 21:18:00 +02:00
this.addAliases("description");
2013-11-11 09:31:04 +01:00
// Parameters
this.addParameter(TypeString.get(), "desc", true);
2013-11-11 09:31:04 +01:00
// Requirements
2015-11-06 02:10:29 +01:00
this.addRequirements(RequirementHasPerm.get(Perm.DESCRIPTION.node));
this.addRequirements(ReqHasFaction.get());
}
2013-11-11 09:31:04 +01:00
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
2015-05-06 17:04:35 +02:00
public void perform() throws MassiveException
2013-04-25 13:25:15 +02:00
{
// Args
2015-05-06 17:04:35 +02:00
String newDescription = this.readArg();
// MPerm
if ( ! MPerm.getPermDesc().has(msender, msenderFaction, true)) return;
// Event
2014-09-18 13:41:20 +02:00
EventFactionsDescriptionChange event = new EventFactionsDescriptionChange(sender, msenderFaction, newDescription);
event.run();
if (event.isCancelled()) return;
newDescription = event.getNewDescription();
// Apply
2014-09-18 13:41:20 +02:00
msenderFaction.setDescription(newDescription);
// Inform
2014-09-18 13:41:20 +02:00
for (MPlayer follower : msenderFaction.getMPlayers())
2014-06-21 19:03:39 +02:00
{
2014-09-18 13:41:20 +02:00
follower.msg("<i>%s <i>set your faction description to:\n%s", Mixin.getDisplayName(sender, follower), msenderFaction.getDescription());
2014-06-21 19:03:39 +02:00
}
}
}