Factions3/src/com/massivecraft/factions/predicate/PredicateCommandSenderFaction.java
2017-03-24 22:59:44 +01:00

45 lines
1.2 KiB
Java

package com.massivecraft.factions.predicate;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.massivecore.predicate.Predicate;
import com.massivecraft.massivecore.util.MUtil;
import org.bukkit.command.CommandSender;
import java.io.Serializable;
public class PredicateCommandSenderFaction implements Predicate<CommandSender>, Serializable
{
private static final long serialVersionUID = 1L;
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
private final String factionId;
public String getFactionId() { return this.factionId; }
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public PredicateCommandSenderFaction(Faction faction)
{
this.factionId = faction.getId();
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public boolean apply(CommandSender sender)
{
if (MUtil.isntSender(sender)) return false;
MPlayer mplayer = MPlayer.get(sender);
return this.factionId.equals(mplayer.getFaction().getId());
}
}