2013-04-17 13:16:22 +02:00
|
|
|
package com.massivecraft.factions;
|
|
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
|
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
|
2014-09-17 13:17:33 +02:00
|
|
|
import com.massivecraft.factions.entity.MPlayer;
|
2013-04-22 09:37:53 +02:00
|
|
|
import com.massivecraft.factions.entity.Faction;
|
2016-02-03 05:06:49 +01:00
|
|
|
import com.massivecraft.massivecore.predicate.Predicate;
|
2015-05-16 12:19:36 +02:00
|
|
|
import com.massivecraft.massivecore.util.MUtil;
|
2013-04-17 13:16:22 +02:00
|
|
|
|
2015-10-21 19:35:41 +02:00
|
|
|
public class FactionEqualsPredicate implements Predicate<CommandSender>, Serializable
|
2013-04-17 13:16:22 +02:00
|
|
|
{
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
|
|
|
|
// -------------------------------------------- //
|
|
|
|
// FIELDS
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
|
|
|
private final String factionId;
|
|
|
|
public String getFactionId() { return this.factionId; }
|
|
|
|
|
|
|
|
// -------------------------------------------- //
|
|
|
|
// CONSTRUCT
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
2015-10-21 19:35:41 +02:00
|
|
|
public FactionEqualsPredicate(Faction faction)
|
2013-04-17 13:16:22 +02:00
|
|
|
{
|
|
|
|
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());
|
2013-04-17 13:16:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|