Moved Faction entity to useage of MStore as well.

This commit is contained in:
Olof Larsson
2013-04-12 09:47:43 +02:00
parent 76f3f044ca
commit 3036b0a157
24 changed files with 265 additions and 904 deletions

View File

@ -44,7 +44,7 @@ public class CmdFactionsCreate extends FCommand
return;
}
if (FactionColl.i.isTagTaken(tag))
if (FactionColl.get().isTagTaken(tag))
{
msg("<b>That tag is already in use.");
return;
@ -61,14 +61,16 @@ public class CmdFactionsCreate extends FCommand
if ( ! canAffordCommand(ConfServer.econCostCreate, "to create a new faction")) return;
// trigger the faction creation event (cancellable)
FactionCreateEvent createEvent = new FactionCreateEvent(me, tag);
String factionId = FactionColl.get().getIdStrategy().generate(FactionColl.get());
FactionCreateEvent createEvent = new FactionCreateEvent(me, tag, factionId);
Bukkit.getServer().getPluginManager().callEvent(createEvent);
if(createEvent.isCancelled()) return;
// then make 'em pay (if applicable)
if ( ! payForCommand(ConfServer.econCostCreate, "to create a new faction", "for creating a new faction")) return;
Faction faction = FactionColl.i.create();
Faction faction = FactionColl.get().create(factionId);
// TODO: Why would this even happen??? Auto increment clash??
if (faction == null)

View File

@ -37,9 +37,9 @@ public class CmdFactionsList extends FCommand
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if ( ! payForCommand(ConfServer.econCostList, "to list the factions", "for listing the factions")) return;
ArrayList<Faction> factionList = new ArrayList<Faction>(FactionColl.i.get());
ArrayList<Faction> factionList = new ArrayList<Faction>(FactionColl.get().getAll());
factionList.remove(FactionColl.i.getNone());
factionList.remove(FactionColl.get().getNone());
// TODO: Add flag SECRET To factions instead.
//factionList.remove(Factions.i.getSafeZone());
//factionList.remove(Factions.i.getWarZone());
@ -91,7 +91,7 @@ public class CmdFactionsList extends FCommand
sendMessage(Txt.getPage(lines, this.argAsInt(0, 1), "Faction List"));
*/
factionList.add(0, FactionColl.i.getNone());
factionList.add(0, FactionColl.get().getNone());
final int pageheight = 9;
int pagenumber = this.argAsInt(0, 1);
@ -111,7 +111,7 @@ public class CmdFactionsList extends FCommand
{
if (faction.isNone())
{
lines.add(Txt.parse("<i>Factionless<i> %d online", FactionColl.i.getNone().getFPlayersWhereOnline(true).size()));
lines.add(Txt.parse("<i>Factionless<i> %d online", FactionColl.get().getNone().getFPlayersWhereOnline(true).size()));
continue;
}
lines.add(Txt.parse("%s<i> %d/%d online, %d/%d/%d",

View File

@ -35,7 +35,7 @@ public class CmdFactionsOpen extends FCommand
// Inform
myFaction.msg("%s<i> changed the faction to <h>%s<i>.", fme.describeTo(myFaction, true), open);
for (Faction faction : FactionColl.i.get())
for (Faction faction : FactionColl.get().getAll())
{
if (faction == myFaction)
{

View File

@ -36,7 +36,7 @@ public class CmdFactionsTag extends FCommand
String tag = this.argAsString(0);
// TODO does not first test cover selfcase?
if (FactionColl.i.isTagTaken(tag) && ! MiscUtil.getComparisonString(tag).equals(myFaction.getComparisonTag()))
if (FactionColl.get().isTagTaken(tag) && ! MiscUtil.getComparisonString(tag).equals(myFaction.getComparisonTag()))
{
msg("<b>That tag is already taken");
return;
@ -66,7 +66,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.i.get())
for (Faction faction : FactionColl.get().getAll())
{
if (faction == myFaction)
{

View File

@ -229,13 +229,13 @@ public abstract class FCommand extends MCommand<Factions>
// First we try an exact match
if (faction == null)
{
faction = FactionColl.i.getByTag(name);
faction = FactionColl.get().getByTag(name);
}
// Next we match faction tags
if (faction == null)
{
faction = FactionColl.i.getBestTagMatch(name);
faction = FactionColl.get().getBestTagMatch(name);
}
// Next we match player names