Quickfixed everything easy.

This commit is contained in:
Olof Larsson 2013-04-22 13:03:21 +02:00
parent 9fc75b1fcf
commit 61e8730495
52 changed files with 134 additions and 132 deletions

View File

@ -8,6 +8,8 @@ import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.massivecraft.factions.entity.FPlayer;
/**
* The ChatFormater is a system offered by factions for tag parsing.
*
@ -100,7 +102,7 @@ public class ChatFormatter
// FORMAT
// -------------------------------------------- //
public static String format(String msg, String senderId, String sendeeId, String recipientId)
public static String format(String msg, FPlayer fsender, FPlayer frecipient)
{
// We build the return value in this string buffer
StringBuffer ret = new StringBuffer();
@ -135,7 +137,7 @@ public class ChatFormatter
}
else
{
replacement = compute(tag, modifierIds, senderId, sendeeId, recipientId);
replacement = compute(tag, modifierIds, fsender, frecipient);
if (replacement == null)
{
// If a tag or modifier returns null it's the same as opting out.
@ -157,9 +159,9 @@ public class ChatFormatter
// TAG COMPUTE
// -------------------------------------------- //
public static String compute(ChatTag tag, List<String> modifierIds, String senderId, String sendeeId, String recipientId)
public static String compute(ChatTag tag, List<String> modifierIds, FPlayer fsender, FPlayer frecipient)
{
String ret = tag.getReplacement(senderId, sendeeId, recipientId);
String ret = tag.getReplacement(fsender, frecipient);
if (ret == null) return null;
for (String modifierId : modifierIds)
@ -170,7 +172,7 @@ public class ChatFormatter
// Modify and ignore change if null.
// Modifier can't get or return null.
String modified = modifier.getModified(ret, senderId, sendeeId, recipientId);
String modified = modifier.getModified(ret, fsender, frecipient);
if (modified == null) continue;
ret = modified;

View File

@ -1,10 +1,12 @@
package com.massivecraft.factions.chat;
import com.massivecraft.factions.entity.FPlayer;
public interface ChatModifier
{
public String getId();
public String getModified(String subject, String senderId, String sendeeId, String recipientId);
public String getModified(String subject, FPlayer fsender, FPlayer frecipient);
public boolean register();
public boolean unregister();
}

View File

@ -1,9 +1,11 @@
package com.massivecraft.factions.chat;
import com.massivecraft.factions.entity.FPlayer;
public interface ChatTag
{
public String getId();
public String getReplacement(String senderId, String sendeeId, String recipientId);
public String getReplacement(FPlayer fsender, FPlayer frecipient);
public boolean register();
public boolean unregister();
}

View File

@ -1,6 +1,7 @@
package com.massivecraft.factions.chat.modifier;
import com.massivecraft.factions.chat.ChatModifierAbstract;
import com.massivecraft.factions.entity.FPlayer;
public class ChatModifierLc extends ChatModifierAbstract
{
@ -17,7 +18,7 @@ public class ChatModifierLc extends ChatModifierAbstract
// -------------------------------------------- //
@Override
public String getModified(String subject, String senderId, String sendeeId, String recipientId)
public String getModified(String subject, FPlayer fsender, FPlayer frecipient)
{
return subject.toLowerCase();
}

View File

@ -1,6 +1,7 @@
package com.massivecraft.factions.chat.modifier;
import com.massivecraft.factions.chat.ChatModifierAbstract;
import com.massivecraft.factions.entity.FPlayer;
public class ChatModifierLp extends ChatModifierAbstract
@ -18,7 +19,7 @@ public class ChatModifierLp extends ChatModifierAbstract
// -------------------------------------------- //
@Override
public String getModified(String subject, String senderId, String sendeeId, String recipientId)
public String getModified(String subject, FPlayer fsender, FPlayer frecipient)
{
if (subject.equals("")) return subject;
return " "+subject;

View File

@ -1,6 +1,7 @@
package com.massivecraft.factions.chat.modifier;
import com.massivecraft.factions.chat.ChatModifierAbstract;
import com.massivecraft.factions.entity.FPlayer;
import com.massivecraft.mcore.util.Txt;
public class ChatModifierParse extends ChatModifierAbstract
@ -18,7 +19,7 @@ public class ChatModifierParse extends ChatModifierAbstract
// -------------------------------------------- //
@Override
public String getModified(String subject, String senderId, String sendeeId, String recipientId)
public String getModified(String subject, FPlayer fsender, FPlayer frecipient)
{
return Txt.parse(subject);
}

View File

@ -1,6 +1,7 @@
package com.massivecraft.factions.chat.modifier;
import com.massivecraft.factions.chat.ChatModifierAbstract;
import com.massivecraft.factions.entity.FPlayer;
public class ChatModifierRp extends ChatModifierAbstract
{
@ -17,7 +18,7 @@ public class ChatModifierRp extends ChatModifierAbstract
// -------------------------------------------- //
@Override
public String getModified(String subject, String senderId, String sendeeId, String recipientId)
public String getModified(String subject, FPlayer fsender, FPlayer frecipient)
{
if (subject.equals("")) return subject;
return subject+" ";

View File

@ -1,6 +1,7 @@
package com.massivecraft.factions.chat.modifier;
import com.massivecraft.factions.chat.ChatModifierAbstract;
import com.massivecraft.factions.entity.FPlayer;
public class ChatModifierUc extends ChatModifierAbstract
{
@ -17,7 +18,7 @@ public class ChatModifierUc extends ChatModifierAbstract
// -------------------------------------------- //
@Override
public String getModified(String subject, String senderId, String sendeeId, String recipientId)
public String getModified(String subject, FPlayer fsender, FPlayer frecipient)
{
return subject.toUpperCase();
}

View File

@ -1,6 +1,7 @@
package com.massivecraft.factions.chat.modifier;
import com.massivecraft.factions.chat.ChatModifierAbstract;
import com.massivecraft.factions.entity.FPlayer;
import com.massivecraft.mcore.util.Txt;
public class ChatModifierUcf extends ChatModifierAbstract
@ -18,7 +19,7 @@ public class ChatModifierUcf extends ChatModifierAbstract
// -------------------------------------------- //
@Override
public String getModified(String subject, String senderId, String sendeeId, String recipientId)
public String getModified(String subject, FPlayer fsender, FPlayer frecipient)
{
return Txt.upperCaseFirst(subject);
}

View File

@ -2,7 +2,6 @@ package com.massivecraft.factions.chat.tag;
import com.massivecraft.factions.chat.ChatTagAbstract;
import com.massivecraft.factions.entity.FPlayer;
import com.massivecraft.factions.entity.FPlayerColl;
public class ChatTagRelcolor extends ChatTagAbstract
{
@ -19,14 +18,8 @@ public class ChatTagRelcolor extends ChatTagAbstract
// -------------------------------------------- //
@Override
public String getReplacement(String senderId, String sendeeId, String recipientId)
public String getReplacement(FPlayer fsender, FPlayer frecipient)
{
if (senderId == null) return "";
if (recipientId == null) return "";
FPlayer fsender = FPlayerColl.get().get(senderId);
FPlayer frecipient = FPlayerColl.get().get(recipientId);
if (fsender == null) return "";
if (frecipient == null) return "";

View File

@ -2,7 +2,6 @@ package com.massivecraft.factions.chat.tag;
import com.massivecraft.factions.chat.ChatTagAbstract;
import com.massivecraft.factions.entity.FPlayer;
import com.massivecraft.factions.entity.FPlayerColl;
import com.massivecraft.mcore.util.Txt;
public class ChatTagRole extends ChatTagAbstract
@ -20,9 +19,8 @@ public class ChatTagRole extends ChatTagAbstract
// -------------------------------------------- //
@Override
public String getReplacement(String senderId, String sendeeId, String recipientId)
public String getReplacement(FPlayer fsender, FPlayer frecipient)
{
FPlayer fsender = FPlayerColl.get().get(senderId);
return Txt.upperCaseFirst(fsender.getRole().toString().toLowerCase());
}

View File

@ -2,7 +2,6 @@ package com.massivecraft.factions.chat.tag;
import com.massivecraft.factions.chat.ChatTagAbstract;
import com.massivecraft.factions.entity.FPlayer;
import com.massivecraft.factions.entity.FPlayerColl;
public class ChatTagRoleprefix extends ChatTagAbstract
{
@ -19,9 +18,8 @@ public class ChatTagRoleprefix extends ChatTagAbstract
// -------------------------------------------- //
@Override
public String getReplacement(String senderId, String sendeeId, String recipientId)
public String getReplacement(FPlayer fsender, FPlayer frecipient)
{
FPlayer fsender = FPlayerColl.get().get(senderId);
return fsender.getRole().getPrefix();
}

View File

@ -2,7 +2,6 @@ package com.massivecraft.factions.chat.tag;
import com.massivecraft.factions.chat.ChatTagAbstract;
import com.massivecraft.factions.entity.FPlayer;
import com.massivecraft.factions.entity.FPlayerColl;
public class ChatTagTag extends ChatTagAbstract
{
@ -19,9 +18,8 @@ public class ChatTagTag extends ChatTagAbstract
// -------------------------------------------- //
@Override
public String getReplacement(String senderId, String sendeeId, String recipientId)
public String getReplacement(FPlayer fsender, FPlayer frecipient)
{
FPlayer fsender = FPlayerColl.get().get(senderId);
if (!fsender.hasFaction()) return "";
return fsender.getFaction().getTag();
}

View File

@ -2,7 +2,6 @@ package com.massivecraft.factions.chat.tag;
import com.massivecraft.factions.chat.ChatTagAbstract;
import com.massivecraft.factions.entity.FPlayer;
import com.massivecraft.factions.entity.FPlayerColl;
public class ChatTagTagforce extends ChatTagAbstract
{
@ -19,9 +18,8 @@ public class ChatTagTagforce extends ChatTagAbstract
// -------------------------------------------- //
@Override
public String getReplacement(String senderId, String sendeeId, String recipientId)
public String getReplacement(FPlayer fsender, FPlayer frecipient)
{
FPlayer fsender = FPlayerColl.get().get(senderId);
return fsender.getFaction().getTag();
}

View File

@ -2,7 +2,6 @@ package com.massivecraft.factions.chat.tag;
import com.massivecraft.factions.chat.ChatTagAbstract;
import com.massivecraft.factions.entity.FPlayer;
import com.massivecraft.factions.entity.FPlayerColl;
public class ChatTagTitle extends ChatTagAbstract
{
@ -19,9 +18,8 @@ public class ChatTagTitle extends ChatTagAbstract
// -------------------------------------------- //
@Override
public String getReplacement(String senderId, String sendeeId, String recipientId)
public String getReplacement(FPlayer fsender, FPlayer frecipient)
{
FPlayer fsender = FPlayerColl.get().get(sendeeId);
return fsender.getTitle();
}

View File

@ -73,14 +73,14 @@ public class CmdFactionsAccess extends FCommand
if (doPlayer)
{
FPlayer targetPlayer = this.arg(1, ARFPlayer.getStartAny(), fme);
FPlayer targetPlayer = this.arg(1, ARFPlayer.getStartAny(fme), fme);
if (targetPlayer == null) return;
added = territory.toggleFPlayer(targetPlayer);
target = "Player \""+targetPlayer.getName()+"\"";
}
else
{
Faction targetFaction = this.arg(1, ARFaction.get(), myFaction);
Faction targetFaction = this.arg(1, ARFaction.get(myFaction), myFaction);
if (targetFaction == null) return;
added = territory.toggleFaction(targetFaction);
target = "Faction \""+targetFaction.getTag()+"\"";

View File

@ -23,7 +23,7 @@ public class CmdFactionsAutoClaim extends FCommand
@Override
public void perform()
{
Faction forFaction = this.arg(0, ARFaction.get(), myFaction);
Faction forFaction = this.arg(0, ARFaction.get(myFaction), myFaction);
if (forFaction == null || forFaction == fme.getAutoClaimFor())
{
fme.setAutoClaimFor(null);

View File

@ -30,7 +30,7 @@ public abstract class CmdFactionsCapeAbstract extends FCommand
return false;
}
this.capeFaction = this.arg(this.requiredArgs.size(), ARFaction.get(), this.myFaction);
this.capeFaction = this.arg(this.requiredArgs.size(), ARFaction.get(myFaction), myFaction);
if (this.capeFaction == null) return false;
// Do we have permission to manage the cape of that faction?

View File

@ -28,7 +28,7 @@ public class CmdFactionsClaim extends FCommand
@Override
public void perform()
{
final Faction forFaction = this.arg(0, ARFaction.get());
final Faction forFaction = this.arg(0, ARFaction.get(me));
if (forFaction == null) return;
Integer radius = this.arg(1, ARInteger.get(), 1);

View File

@ -6,9 +6,10 @@ import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.entity.FPlayer;
import com.massivecraft.factions.entity.FPlayerColl;
import com.massivecraft.factions.entity.FPlayerColls;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColl;
import com.massivecraft.factions.entity.FactionColls;
import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.event.FactionsEventCreate;
import com.massivecraft.factions.event.FactionsEventMembershipChange;
@ -39,7 +40,9 @@ public class CmdFactionsCreate extends FCommand
return;
}
if (FactionColl.get().isTagTaken(newTag))
FactionColl coll = FactionColls.get().get(fme);
if (coll.isTagTaken(newTag))
{
msg("<b>That tag is already in use.");
return;
@ -53,15 +56,15 @@ public class CmdFactionsCreate extends FCommand
}
// Pre-Generate Id
String factionId = FactionColl.get().getIdStrategy().generate(FactionColl.get());
String factionId = coll.getIdStrategy().generate(coll);
// Event
FactionsEventCreate createEvent = new FactionsEventCreate(sender, newTag, factionId);
FactionsEventCreate createEvent = new FactionsEventCreate(sender, coll.getUniverse(), factionId, newTag);
createEvent.run();
if (createEvent.isCancelled()) return;
// Apply
Faction faction = FactionColl.get().create(factionId);
Faction faction = coll.create(factionId);
faction.setTag(newTag);
fme.setRole(Rel.LEADER);
@ -72,7 +75,7 @@ public class CmdFactionsCreate extends FCommand
// NOTE: join event cannot be cancelled or you'll have an empty faction
// Inform
for (FPlayer follower : FPlayerColl.get().getAllOnline())
for (FPlayer follower : FPlayerColls.get().get(fme).getAllOnline())
{
follower.msg("%s<i> created a new faction %s", fme.describeTo(follower, true), faction.getTag(follower));
}

View File

@ -25,7 +25,7 @@ public class CmdFactionsDemote extends FCommand
@Override
public void perform()
{
FPlayer you = this.arg(0, ARFPlayer.getStartAny());
FPlayer you = this.arg(0, ARFPlayer.getStartAny(fme));
if (you == null) return;
if (you.getFaction() != myFaction)

View File

@ -2,9 +2,9 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.entity.FPlayer;
import com.massivecraft.factions.entity.FPlayerColl;
import com.massivecraft.factions.entity.FPlayerColls;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColl;
import com.massivecraft.factions.entity.FactionColls;
import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.event.FactionsEventDisband;
import com.massivecraft.factions.event.FactionsEventMembershipChange;
@ -33,7 +33,7 @@ public class CmdFactionsDisband extends FCommand
public void perform()
{
// Args
Faction faction = this.arg(0, ARFaction.get(), myFaction);
Faction faction = this.arg(0, ARFaction.get(fme), myFaction);
if (faction == null) return;
// FPerm
@ -56,12 +56,12 @@ public class CmdFactionsDisband extends FCommand
// Send FPlayerLeaveEvent for each player in the faction
for (FPlayer fplayer : faction.getFPlayers())
{
FactionsEventMembershipChange membershipChangeEvent = new FactionsEventMembershipChange(sender, fplayer, FactionColl.get().getNone(), MembershipChangeReason.DISBAND);
FactionsEventMembershipChange membershipChangeEvent = new FactionsEventMembershipChange(sender, fplayer, FactionColls.get().get(faction).getNone(), MembershipChangeReason.DISBAND);
membershipChangeEvent.run();
}
// Inform all players
for (FPlayer fplayer : FPlayerColl.get().getAllOnline())
for (FPlayer fplayer : FPlayerColls.get().get(fme).getAllOnline())
{
String who = fme.describeTo(fplayer);
if (fplayer.getFaction() == faction)

View File

@ -26,7 +26,7 @@ public class CmdFactionsFlag extends FCommand
@Override
public void perform()
{
Faction faction = this.arg(0, ARFaction.get(), myFaction);
Faction faction = this.arg(0, ARFaction.get(sender), myFaction);
if (faction == null) return;
if ( ! this.argIsSet(1))

View File

@ -12,7 +12,6 @@ import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
import com.massivecraft.factions.entity.BoardColls;
import com.massivecraft.factions.entity.FPlayer;
import com.massivecraft.factions.entity.FPlayerColl;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.event.FactionsEventHomeTeleport;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
@ -100,7 +99,7 @@ public class CmdFactionsHome extends FCommand
if (p == null || !p.isOnline() || p.isDead() || p == me || p.getWorld() != w)
continue;
FPlayer fp = FPlayerColl.get().get(p);
FPlayer fp = FPlayer.get(p);
if (fme.getRelationTo(fp) != Rel.ENEMY)
continue;

View File

@ -27,7 +27,7 @@ public class CmdFactionsInvite extends FCommand
public void perform()
{
// Args
FPlayer fplayer = this.arg(0, ARFPlayer.getStartAny());
FPlayer fplayer = this.arg(0, ARFPlayer.getStartAny(sender));
if (fplayer == null) return;
Boolean newInvited = this.arg(1, ARBoolean.get(), !myFaction.isInvited(fplayer));

View File

@ -28,10 +28,10 @@ public class CmdFactionsJoin extends FCommand
public void perform()
{
// Args
Faction faction = this.arg(0, ARFaction.get());
Faction faction = this.arg(0, ARFaction.get(sender));
if (faction == null) return;
FPlayer fplayer = this.arg(1, ARFPlayer.getStartAny(), fme);
FPlayer fplayer = this.arg(1, ARFPlayer.getStartAny(sender), fme);
if (fplayer == null) return;
boolean samePlayer = fplayer == fme;

View File

@ -8,7 +8,7 @@ import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.arg.ARFPlayer;
import com.massivecraft.factions.entity.FPlayer;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColl;
import com.massivecraft.factions.entity.FactionColls;
import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.event.FactionsEventMembershipChange;
import com.massivecraft.factions.event.FactionsEventMembershipChange.MembershipChangeReason;
@ -30,7 +30,7 @@ public class CmdFactionsKick extends FCommand
public void perform()
{
// Arg
FPlayer fplayer = this.arg(1, ARFPlayer.getStartAny());
FPlayer fplayer = this.arg(1, ARFPlayer.getStartAny(sender));
if (fplayer == null) return;
// Validate
@ -58,7 +58,7 @@ public class CmdFactionsKick extends FCommand
if (!FPerm.KICK.has(sender, fplayerFaction)) return;
// Event
FactionsEventMembershipChange event = new FactionsEventMembershipChange(sender, fplayer, FactionColl.get().getNone(), MembershipChangeReason.KICK);
FactionsEventMembershipChange event = new FactionsEventMembershipChange(sender, fplayer, FactionColls.get().get(fplayer).getNone(), MembershipChangeReason.KICK);
event.run();
if (event.isCancelled()) return;

View File

@ -5,7 +5,7 @@ import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.arg.ARFPlayer;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.entity.FPlayer;
import com.massivecraft.factions.entity.FPlayerColl;
import com.massivecraft.factions.entity.FPlayerColls;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.event.FactionsEventMembershipChange;
import com.massivecraft.factions.event.FactionsEventMembershipChange.MembershipChangeReason;
@ -28,10 +28,10 @@ public class CmdFactionsLeader extends FCommand
@Override
public void perform()
{
FPlayer newLeader = this.arg(0, ARFPlayer.getStartAny());
FPlayer newLeader = this.arg(0, ARFPlayer.getStartAny(sender));
if (newLeader == null) return;
Faction targetFaction = this.arg(1, ARFaction.get(), myFaction);
Faction targetFaction = this.arg(1, ARFaction.get(sender), myFaction);
if (targetFaction == null) return;
FPlayer targetFactionCurrentLeader = targetFaction.getLeader();
@ -90,7 +90,7 @@ public class CmdFactionsLeader extends FCommand
msg("<i>You have promoted %s<i> to the position of faction leader.", newLeader.describeTo(fme, true));
// Inform all players
for (FPlayer fplayer : FPlayerColl.get().getAllOnline())
for (FPlayer fplayer : FPlayerColls.get().get(sender).getAllOnline())
{
fplayer.msg("%s<i> gave %s<i> the leadership of %s<i>.", senderIsConsole ? "A server admin" : RelationUtil.describeThatToMe(fme, fplayer, true), newLeader.describeTo(fplayer), targetFaction.describeTo(fplayer));
}

View File

@ -6,7 +6,7 @@ import java.util.List;
import com.massivecraft.factions.FactionListComparator;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColl;
import com.massivecraft.factions.entity.FactionColls;
import com.massivecraft.mcore.cmd.arg.ARInteger;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
import com.massivecraft.mcore.util.Txt;
@ -33,7 +33,7 @@ public class CmdFactionsList extends FCommand
// Create Messages
List<String> lines = new ArrayList<String>();
ArrayList<Faction> factionList = new ArrayList<Faction>(FactionColl.get().getAll(null, FactionListComparator.get()));
ArrayList<Faction> factionList = new ArrayList<Faction>(FactionColls.get().get(sender).getAll(null, FactionListComparator.get()));
final int pageheight = 9;
@ -53,7 +53,7 @@ public class CmdFactionsList extends FCommand
{
if (faction.isNone())
{
lines.add(Txt.parse("<i>Factionless<i> %d online", FactionColl.get().getNone().getFPlayersWhereOnline(true).size()));
lines.add(Txt.parse("<i>Factionless<i> %d online", FactionColls.get().get(sender).getNone().getFPlayersWhereOnline(true).size()));
continue;
}
lines.add(Txt.parse("%s<i> %d/%d online, %d/%d/%d",

View File

@ -22,7 +22,7 @@ public class CmdFactionsMoneyBalance extends FCommand
@Override
public void perform()
{
Faction faction = this.arg(0, ARFaction.get(), myFaction);
Faction faction = this.arg(0, ARFaction.get(sender), myFaction);
if (faction == null) return;
if (faction != myFaction && ! Perm.MONEY_BALANCE_ANY.has(sender, true)) return;

View File

@ -35,7 +35,7 @@ public class CmdFactionsMoneyDeposit extends FCommand
Double amount = this.arg(0, ARDouble.get());
if (amount == null) return;
Faction faction = this.arg(1, ARFaction.get(), myFaction);
Faction faction = this.arg(1, ARFaction.get(sender), myFaction);
if (faction == null) return;
boolean success = Econ.transferMoney(fme, fme, faction, amount);

View File

@ -35,10 +35,10 @@ public class CmdFactionsMoneyTransferFf extends FCommand
Double amount = this.arg(0, ARDouble.get());
if (amount == null) return;
Faction from = this.arg(1, ARFaction.get());
Faction from = this.arg(1, ARFaction.get(sender));
if (from == null) return;
Faction to = this.arg(2, ARFaction.get());
Faction to = this.arg(2, ARFaction.get(sender));
if (to == null) return;
boolean success = Econ.transferMoney(fme, from, to, amount);

View File

@ -37,10 +37,10 @@ public class CmdFactionsMoneyTransferFp extends FCommand
Double amount = this.arg(0, ARDouble.get());
if (amount == null) return;
Faction from = this.arg(1, ARFaction.get());
Faction from = this.arg(1, ARFaction.get(sender));
if (from == null) return;
FPlayer to = this.arg(2, ARFPlayer.getStartAny());
FPlayer to = this.arg(2, ARFPlayer.getStartAny(sender));
if (to == null) return;
boolean success = Econ.transferMoney(fme, from, to, amount);

View File

@ -37,10 +37,10 @@ public class CmdFactionsMoneyTransferPf extends FCommand
Double amount = this.arg(0, ARDouble.get());
if (amount == null) return;
FPlayer from = this.arg(1, ARFPlayer.getStartAny());
FPlayer from = this.arg(1, ARFPlayer.getStartAny(sender));
if (from == null) return;
Faction to = this.arg(2, ARFaction.get());
Faction to = this.arg(2, ARFaction.get(sender));
if (to == null) return;
boolean success = Econ.transferMoney(fme, from, to, amount);

View File

@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
import com.massivecraft.factions.entity.FPlayer;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.Factions;
@ -34,14 +35,16 @@ public class CmdFactionsMoneyWithdraw extends FCommand
Double amount = this.arg(0, ARDouble.get());
if (amount == null) return;
Faction faction = this.arg(1, ARFaction.get(), myFaction);
if (faction == null) return;
Faction from = this.arg(1, ARFaction.get(sender), myFaction);
if (from == null) return;
boolean success = Econ.transferMoney(fme, faction, fme, amount);
FPlayer to = fme;
boolean success = Econ.transferMoney(fme, from, to, amount);
if (success && MConf.get().logMoneyTransactions)
{
Factions.get().log(ChatColor.stripColor(Txt.parse("%s withdrew %s from the faction bank: %s", fme.getName(), Money.format(faction, amount), faction.describeTo(null))));
Factions.get().log(ChatColor.stripColor(Txt.parse("%s withdrew %s from the faction bank: %s", fme.getName(), Money.format(from, amount), from.describeTo(null))));
}
}
}

View File

@ -22,7 +22,7 @@ public class CmdFactionsOfficer extends FCommand
@Override
public void perform()
{
FPlayer you = this.arg(0, ARFPlayer.getStartAny());
FPlayer you = this.arg(0, ARFPlayer.getStartAny(sender));
if (you == null) return;
boolean permAny = Perm.OFFICER_ANY.has(sender, false);

View File

@ -3,8 +3,6 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColl;
import com.massivecraft.factions.event.FactionsEventOpenChange;
import com.massivecraft.mcore.cmd.arg.ARBoolean;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
@ -40,14 +38,6 @@ public class CmdFactionsOpen extends FCommand
// Inform
String descTarget = myFaction.isOpen() ? "open" : "closed";
myFaction.msg("%s<i> changed the faction to <h>%s<i>.", fme.describeTo(myFaction, true), descTarget);
for (Faction faction : FactionColl.get().getAll())
{
if (faction == myFaction)
{
continue;
}
faction.msg("<i>The faction %s<i> is now %s", myFaction.getTag(faction), descTarget);
}
}
}

View File

@ -29,7 +29,7 @@ public class CmdFactionsPerm extends FCommand
@Override
public void perform()
{
Faction faction = this.arg(0, ARFaction.get(), myFaction);
Faction faction = this.arg(0, ARFaction.get(myFaction), myFaction);
if (faction == null) return;
if ( ! this.argIsSet(1))

View File

@ -20,7 +20,7 @@ public class CmdFactionsPower extends FCommand
@Override
public void perform()
{
FPlayer target = this.arg(0, ARFPlayer.getStartAny(), fme);
FPlayer target = this.arg(0, ARFPlayer.getStartAny(fme), fme);
if (target == null) return;
if (target != fme && ! Perm.POWER_ANY.has(sender, true)) return;

View File

@ -45,7 +45,7 @@ public class CmdFactionsPowerBoost extends FCommand
if (doPlayer)
{
FPlayer targetPlayer = this.arg(1, ARFPlayer.getStartAny());
FPlayer targetPlayer = this.arg(1, ARFPlayer.getStartAny(sender));
if (targetPlayer == null) return;
targetPlayer.setPowerBoost(targetPower);
@ -53,7 +53,7 @@ public class CmdFactionsPowerBoost extends FCommand
}
else
{
Faction targetFaction = this.arg(1, ARFaction.get());
Faction targetFaction = this.arg(1, ARFaction.get(sender));
if (targetFaction == null) return;
targetFaction.setPowerBoost(targetPower);

View File

@ -25,7 +25,7 @@ public class CmdFactionsPromote extends FCommand
@Override
public void perform()
{
FPlayer you = this.arg(0, ARFPlayer.getStartAny());
FPlayer you = this.arg(0, ARFPlayer.getStartAny(sender));
if (you == null) return;
if (you.getFaction() != myFaction)

View File

@ -27,7 +27,7 @@ public abstract class CmdFactionsRelationAbstract extends FCommand
public void perform()
{
// Args
Faction otherFaction = this.arg(0, ARFaction.get());
Faction otherFaction = this.arg(0, ARFaction.get(sender));
if (otherFaction == null) return;
Rel newRelation = targetRelation;

View File

@ -34,7 +34,7 @@ public class CmdFactionsSethome extends FCommand
}
// Args
Faction faction = this.arg(0, ARFaction.get(), myFaction);
Faction faction = this.arg(0, ARFaction.get(myFaction), myFaction);
if (faction == null) return;
PS newHome = PS.valueOf(me.getLocation());

View File

@ -32,7 +32,7 @@ public class CmdFactionsShow extends FCommand
@Override
public void perform()
{
Faction faction = this.arg(0, ARFaction.get(), myFaction);
Faction faction = this.arg(0, ARFaction.get(myFaction), myFaction);
if (faction == null) return;
Collection<FPlayer> leaders = faction.getFPlayersWhereRole(Rel.LEADER);

View File

@ -8,6 +8,7 @@ import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColl;
import com.massivecraft.factions.entity.FactionColls;
import com.massivecraft.factions.event.FactionsEventTagChange;
import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.factions.util.MiscUtil;
@ -33,7 +34,7 @@ public class CmdFactionsTag extends FCommand
String newTag = this.arg(0);
// TODO does not first test cover selfcase?
if (FactionColl.get().isTagTaken(newTag) && ! MiscUtil.getComparisonString(newTag).equals(myFaction.getComparisonTag()))
if (FactionColls.get().get(myFaction).isTagTaken(newTag) && ! MiscUtil.getComparisonString(newTag).equals(myFaction.getComparisonTag()))
{
msg("<b>That tag is already taken");
return;
@ -59,7 +60,7 @@ public class CmdFactionsTag extends FCommand
// Inform
myFaction.msg("%s<i> changed your faction tag to %s", fme.describeTo(myFaction, true), myFaction.getTag(myFaction));
for (Faction faction : FactionColl.get().getAll())
for (Faction faction : FactionColls.get().get(myFaction).getAll())
{
if (faction == myFaction)
{

View File

@ -28,7 +28,7 @@ public class CmdFactionsTitle extends FCommand
public void perform()
{
// Args
FPlayer you = this.arg(0, ARFPlayer.getStartAny());
FPlayer you = this.arg(0, ARFPlayer.getStartAny(sender));
if (you == null) return;
String newTitle = this.argConcatFrom(1, ARString.get(), "");

View File

@ -2,7 +2,6 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.entity.FPlayer;
import com.massivecraft.factions.entity.FPlayerColl;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.mcore.cmd.MCommand;
import com.massivecraft.mcore.util.Txt;
@ -15,7 +14,7 @@ public abstract class FCommand extends MCommand
@Override
public void fixSenderVars()
{
this.fme = FPlayerColl.get().get(this.sender);
this.fme = FPlayer.get(this.sender);
this.myFaction = this.fme.getFaction();
}

View File

@ -1,7 +1,7 @@
package com.massivecraft.factions.cmd.arg;
import com.massivecraft.factions.entity.FPlayer;
import com.massivecraft.factions.entity.FPlayerColl;
import com.massivecraft.factions.entity.FPlayerColls;
import com.massivecraft.mcore.cmd.arg.ARSenderEntity;
import com.massivecraft.mcore.cmd.arg.ArgReader;
@ -11,16 +11,12 @@ public class ARFPlayer
// INSTANCE
// -------------------------------------------- //
private static ArgReader<FPlayer> fullAny = ARSenderEntity.getFullAny(FPlayerColl.get());
public static ArgReader<FPlayer> getFullAny() { return fullAny; }
public static ArgReader<FPlayer> getFullAny(Object o) { return ARSenderEntity.getFullAny(FPlayerColls.get().get(o)); }
private static ArgReader<FPlayer> startAny = ARSenderEntity.getStartAny(FPlayerColl.get());
public static ArgReader<FPlayer> getStartAny() { return startAny; }
public static ArgReader<FPlayer> getStartAny(Object o) { return ARSenderEntity.getStartAny(FPlayerColls.get().get(o)); }
private static ArgReader<FPlayer> fullOnline = ARSenderEntity.getFullOnline(FPlayerColl.get());
public static ArgReader<FPlayer> getFullOnline() { return fullOnline; }
public static ArgReader<FPlayer> getFullOnline(Object o) { return ARSenderEntity.getFullOnline(FPlayerColls.get().get(o)); }
private static ArgReader<FPlayer> startOnline = ARSenderEntity.getStartOnline(FPlayerColl.get());
public static ArgReader<FPlayer> getStartOnline() { return startOnline; }
public static ArgReader<FPlayer> getStartOnline(Object o) { return ARSenderEntity.getStartOnline(FPlayerColls.get().get(o)); }
}

View File

@ -3,9 +3,10 @@ package com.massivecraft.factions.cmd.arg;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.entity.FPlayer;
import com.massivecraft.factions.entity.FPlayerColl;
import com.massivecraft.factions.entity.FPlayerColls;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColl;
import com.massivecraft.factions.entity.FactionColls;
import com.massivecraft.mcore.cmd.arg.ArgReaderAbstract;
import com.massivecraft.mcore.cmd.arg.ArgResult;
import com.massivecraft.mcore.util.Txt;
@ -16,8 +17,18 @@ public class ARFaction extends ArgReaderAbstract<Faction>
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static ARFaction i = new ARFaction();
public static ARFaction get() { return i; }
public static ARFaction get(Object o) { return new ARFaction(FactionColls.get().get(o)); }
private ARFaction(FactionColl coll)
{
this.coll = coll;
}
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
private final FactionColl coll;
public FactionColl getColl() { return this.coll;}
// -------------------------------------------- //
// OVERRIDE
@ -29,15 +40,15 @@ public class ARFaction extends ArgReaderAbstract<Faction>
ArgResult<Faction> result = new ArgResult<Faction>();
// Faction Tag Exact
result.setResult(FactionColl.get().getByTag(str));
result.setResult(this.getColl().getByTag(str));
if (result.hasResult()) return result;
// Faction Tag Match
result.setResult(FactionColl.get().getBestTagMatch(str));
result.setResult(this.getColl().getBestTagMatch(str));
if (result.hasResult()) return result;
// FPlayer Name Exact
FPlayer fplayer = FPlayerColl.get().get(str);
FPlayer fplayer = FPlayerColls.get().get(this.getColl()).get(str);
if (fplayer != null)
{
result.setResult(fplayer.getFaction());

View File

@ -17,23 +17,25 @@ public class FactionsEventCreate extends FactionsEventAbstractSender
// FIELDS
// -------------------------------------------- //
// TODO: How do we know what universe? Should we perhaps actually create the faction?
private final String universe;
public final String getUniverse() { return this.universe; }
private String factionTag;
public String getFactionTag() { return this.factionTag; }
private final String factionId;
public final String getFactionId() { return this.factionId; }
private String factionId;
public String getFactionId() { return this.factionId; }
private final String factionTag;
public final String getFactionTag() { return this.factionTag; }
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public FactionsEventCreate(CommandSender sender, String factionTag, String factionId)
public FactionsEventCreate(CommandSender sender, String universe, String factionId, String factionTag)
{
super(sender);
this.factionTag = factionTag;
this.universe = universe;
this.factionId = factionId;
this.factionTag = factionTag;
}
}

View File

@ -10,6 +10,7 @@ import com.dthielke.herochat.ChannelChatEvent;
import com.dthielke.herochat.Herochat;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.chat.ChatFormatter;
import com.massivecraft.factions.entity.FPlayer;
import com.massivecraft.factions.entity.MConf;
@ -52,7 +53,8 @@ public class HerochatEngine implements Listener
String format = event.getFormat();
format = format.replaceAll("&r", "§r");
format = ChatFormatter.format(format, event.getSender().getName(), null, null);
format = ChatFormatter.format(format, FPlayer.get(event.getSender().getPlayer()), null);
event.setFormat(format);
}

View File

@ -8,8 +8,8 @@ import org.bukkit.event.player.AsyncPlayerChatEvent;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.chat.ChatFormatter;
import com.massivecraft.factions.entity.FPlayer;
import com.massivecraft.factions.entity.MConf;
import com.massivecraft.mcore.util.SenderUtil;
public class FactionsListenerChat implements Listener
{
@ -95,7 +95,8 @@ public class FactionsListenerChat implements Listener
// ... then parse tags a.k.a. "format the format".
String format = event.getFormat();
format = ChatFormatter.format(format, SenderUtil.getSenderId(event.getPlayer()), null, null);
format = ChatFormatter.format(format, FPlayer.get(event.getPlayer()), null);
event.setFormat(format);
}