Factions3/src/com/massivecraft/factions/cmd/req/ReqRoleIsAtLeast.java
2015-05-16 14:30:49 +02:00

50 lines
1.5 KiB
Java

package com.massivecraft.factions.cmd.req;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.req.ReqAbstract;
import com.massivecraft.massivecore.util.MUtil;
import com.massivecraft.massivecore.util.Txt;
public class ReqRoleIsAtLeast extends ReqAbstract
{
private static final long serialVersionUID = 1L;
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
private final Rel rel;
public Rel getRel() { return this.rel; }
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
public static ReqRoleIsAtLeast get(Rel rel) { return new ReqRoleIsAtLeast(rel); }
private ReqRoleIsAtLeast(Rel rel) { this.rel = rel; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public boolean apply(CommandSender sender, MassiveCommand command)
{
if (MUtil.isntSender(sender)) return false;
MPlayer mplayer = MPlayer.get(sender);
return mplayer.getRole().isAtLeast(this.rel);
}
@Override
public String createErrorMessage(CommandSender sender, MassiveCommand command)
{
return Txt.parse("<b>You must be <h>%s <b>or higher to "+(command == null ? "do that" : command.getDesc())+".", Txt.getNicedEnum(this.rel));
}
}