Factions/src/com/massivecraft/factions/FactionEqualsPredicate.java

45 lines
1.2 KiB
Java
Raw Normal View History

package com.massivecraft.factions;
import java.io.Serializable;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.entity.MPlayer;
2013-04-22 09:37:53 +02:00
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.massivecore.predicate.Predicate;
2015-05-16 12:19:36 +02:00
import com.massivecraft.massivecore.util.MUtil;
public class FactionEqualsPredicate implements Predicate<CommandSender>, Serializable
{
private static final long serialVersionUID = 1L;
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
private final String factionId;
public String getFactionId() { return this.factionId; }
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public FactionEqualsPredicate(Faction faction)
{
this.factionId = faction.getId();
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public boolean apply(CommandSender sender)
{
2015-05-16 14:30:49 +02:00
if (MUtil.isntSender(sender)) return false;
2014-09-17 13:29:58 +02:00
MPlayer mplayer = MPlayer.get(sender);
return this.factionId.equals(mplayer.getFactionId());
}
}