Halfway through adding in universe support

This commit is contained in:
Olof Larsson
2013-04-22 12:26:13 +02:00
parent de703d3461
commit 9fc75b1fcf
25 changed files with 593 additions and 270 deletions

View File

@@ -11,7 +11,7 @@ import com.massivecraft.factions.entity.MConf;
public class FactionChannel extends FactionsChannelAbstract
{
public static final Set<Rel> targetRelations = EnumSet.of(Rel.MEMBER);
public static final Set<Rel> targetRelations = EnumSet.of(Rel.MEMBER, Rel.RECRUIT);
@Override public Set<Rel> getTargetRelations() { return targetRelations; }
@Override public String getName() { return MConf.get().herochatFactionName; }

View File

@@ -24,7 +24,6 @@ import com.dthielke.herochat.MessageNotFoundException;
import com.dthielke.herochat.util.Messaging;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.entity.FPlayer;
import com.massivecraft.factions.entity.FPlayerColl;
import com.massivecraft.factions.entity.Faction;
public abstract class FactionsChannelAbstract implements Channel
@@ -206,30 +205,27 @@ public abstract class FactionsChannelAbstract implements Channel
return this.getMutes().contains(name.toLowerCase());
}
public abstract Set<Rel> getTargetRelations();
// TODO: When I add in universes I will need to separate the channel per universe.
public Set<Player> getRecipients(Player sender)
{
Set<Player> ret = new HashSet<Player>();
FPlayer fpsender = FPlayerColl.get().get(sender);
Faction faction = fpsender.getFaction();
ret.addAll(faction.getOnlinePlayers());
FPlayer fpsender = FPlayer.get(sender);
Faction faction = fpsender.getFaction();
String universe = fpsender.getUniverse();
for (FPlayer fplayer : FPlayerColl.get().getAllOnline())
for (Player player : Bukkit.getOnlinePlayers())
{
if(this.getTargetRelations().contains(faction.getRelationTo(fplayer)))
{
ret.add(fplayer.getPlayer());
}
FPlayer frecipient = FPlayer.get(player);
if (!frecipient.getUniverse().equals(universe)) continue;
if (!this.getTargetRelations().contains(faction.getRelationTo(frecipient))) continue;
ret.add(player);
}
return ret;
}
@Override
public void processChat(ChannelChatEvent event)
{