Rename and relocate Comparators and Predicates
This commit is contained in:
		@@ -0,0 +1,44 @@
 | 
			
		||||
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.getFactionId());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,36 @@
 | 
			
		||||
package com.massivecraft.factions.predicate;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Rel;
 | 
			
		||||
import com.massivecraft.factions.entity.MPlayer;
 | 
			
		||||
import com.massivecraft.massivecore.predicate.Predicate;
 | 
			
		||||
 | 
			
		||||
public class PredicateMPlayerRole implements Predicate<MPlayer>
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// FIELDS
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	private final Rel role;
 | 
			
		||||
	public Rel getRole() { return this.role; }
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// INSTANCE AND CONTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public static PredicateMPlayerRole get(Rel role) { return new PredicateMPlayerRole(role); }
 | 
			
		||||
	public PredicateMPlayerRole(Rel role)
 | 
			
		||||
	{
 | 
			
		||||
		this.role = role;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public boolean apply(MPlayer mplayer)
 | 
			
		||||
	{
 | 
			
		||||
		if (mplayer == null) return false;
 | 
			
		||||
		return mplayer.getRole() == this.role;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user