Merge pull request #2 from MassiveCraft/master

Step 1 in many removing the universe system. Untested and lacking auto c...
This commit is contained in:
Mark Hughes 2014-09-17 21:24:56 +10:00
commit 3bac7390f7
99 changed files with 1789 additions and 2662 deletions

View File

@ -8,9 +8,7 @@ public class Const
public static final String COLLECTION_BOARD = BASENAME_+"board"; public static final String COLLECTION_BOARD = BASENAME_+"board";
public static final String COLLECTION_FACTION = BASENAME_+"faction"; public static final String COLLECTION_FACTION = BASENAME_+"faction";
public static final String COLLECTION_UPLAYER = BASENAME_+"uplayer";
public static final String COLLECTION_MPLAYER = BASENAME_+"mplayer"; public static final String COLLECTION_MPLAYER = BASENAME_+"mplayer";
public static final String COLLECTION_UCONF = BASENAME_+"uconf";
public static final String COLLECTION_MCONF = BASENAME_+"mconf"; public static final String COLLECTION_MCONF = BASENAME_+"mconf";
public static final String ASPECT = BASENAME; public static final String ASPECT = BASENAME;

View File

@ -1,125 +0,0 @@
package com.massivecraft.factions;
import java.util.Set;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.plugin.Plugin;
import com.massivecraft.factions.entity.Board;
import com.massivecraft.factions.entity.BoardColl;
import com.massivecraft.factions.entity.BoardColls;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColl;
import com.massivecraft.factions.entity.FactionColls;
import com.massivecraft.factions.entity.MPlayerColl;
import com.massivecraft.factions.entity.UPlayerColl;
import com.massivecraft.factions.entity.UPlayerColls;
import com.massivecraft.massivecore.EngineAbstract;
import com.massivecraft.massivecore.event.EventMassiveCoreUuidUpdate;
import com.massivecraft.massivecore.util.IdUpdateUtil;
import com.massivecraft.massivecore.util.MUtil;
public class EngineIdUpdate extends EngineAbstract
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static EngineIdUpdate i = new EngineIdUpdate();
public static EngineIdUpdate get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public Plugin getPlugin()
{
return Factions.get();
}
// -------------------------------------------- //
// LISTENER
// -------------------------------------------- //
@EventHandler(priority = EventPriority.MONITOR)
public void update(EventMassiveCoreUuidUpdate event)
{
for (FactionColl coll : FactionColls.get().getColls())
{
for (Faction entity : coll.getAll())
{
update(coll, entity);
}
}
IdUpdateUtil.update(MPlayerColl.get());
for (UPlayerColl coll : UPlayerColls.get().getColls())
{
IdUpdateUtil.update(coll);
}
for (BoardColl coll : BoardColls.get().getColls())
{
update(coll);
}
}
public static void update(FactionColl coll, Faction entity)
{
// Before and After
Set<String> before = entity.getInvitedPlayerIds();
if (before == null) return;
Set<String> after = IdUpdateUtil.update(before, true);
if (after == null) return;
// NoChange
if (MUtil.equals(before, after)) return;
// Apply
entity.setInvitedPlayerIds(after);
entity.sync();
}
public static void update(BoardColl coll)
{
for (Board board : coll.getAll())
{
update(board);
}
}
public static void update(Board board)
{
boolean changed = false;
for (TerritoryAccess ta : board.getMap().values())
{
changed |= update(ta);
}
if (changed)
{
board.changed();
board.sync();
}
}
public static boolean update(TerritoryAccess entity)
{
// Before and After
Set<String> before = entity.playerIds;
if (before == null) return false;
Set<String> after = IdUpdateUtil.update(before, true);
if (after == null) return false;
// NoChange
if (MUtil.equals(before, after)) return false;
// Apply
entity.playerIds = after;
//entity.sync();
return true;
}
}

View File

@ -3,7 +3,7 @@ package com.massivecraft.factions;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import com.massivecraft.factions.entity.UConf; import com.massivecraft.factions.entity.MConf;
/** /**
@ -67,9 +67,9 @@ public enum FFlag
// DEFAULTS // DEFAULTS
// -------------------------------------------- // // -------------------------------------------- //
public boolean getDefault(Object o) public boolean getDefault()
{ {
Boolean ret = UConf.get(o).defaultFactionFlags.get(this); Boolean ret = MConf.get().defaultFactionFlags.get(this);
if (ret == null) return this.getDefaultDefault(); if (ret == null) return this.getDefaultDefault();
return ret; return ret;
} }

View File

@ -7,10 +7,10 @@ import java.util.LinkedHashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import com.massivecraft.factions.entity.BoardColls; import com.massivecraft.factions.entity.BoardColl;
import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.UConf;
import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.ps.PS;
import com.massivecraft.massivecore.util.Txt; import com.massivecraft.massivecore.util.Txt;
@ -79,9 +79,9 @@ public enum FPerm
// DEFAULTS // DEFAULTS
// -------------------------------------------- // // -------------------------------------------- //
public Set<Rel> getDefault(Object o) public Set<Rel> getDefault()
{ {
Set<Rel> ret = UConf.get(o).defaultFactionPerms.get(this); Set<Rel> ret = MConf.get().defaultFactionPerms.get(this);
if (ret == null) return this.getDefaultDefault(); if (ret == null) return this.getDefaultDefault();
ret = new LinkedHashSet<Rel>(ret); ret = new LinkedHashSet<Rel>(ret);
return ret; return ret;
@ -125,7 +125,7 @@ public enum FPerm
// HAS? // HAS?
// -------------------------------------------- // // -------------------------------------------- //
public String createDeniedMessage(UPlayer uplayer, Faction hostFaction) public String createDeniedMessage(MPlayer uplayer, Faction hostFaction)
{ {
String ret = Txt.parse("%s<b> does not allow you to %s<b>.", hostFaction.describeTo(uplayer, true), this.getDescription()); String ret = Txt.parse("%s<b> does not allow you to %s<b>.", hostFaction.describeTo(uplayer, true), this.getDescription());
if (Perm.ADMIN.has(uplayer.getPlayer())) if (Perm.ADMIN.has(uplayer.getPlayer()))
@ -141,7 +141,7 @@ public enum FPerm
return hostFaction.getPermittedRelations(this).contains(rel); return hostFaction.getPermittedRelations(this).contains(rel);
} }
public boolean has(UPlayer uplayer, Faction hostFaction, boolean verboose) public boolean has(MPlayer uplayer, Faction hostFaction, boolean verboose)
{ {
if (uplayer.isUsingAdminMode()) return true; if (uplayer.isUsingAdminMode()) return true;
@ -153,11 +153,11 @@ public enum FPerm
return false; return false;
} }
public boolean has(UPlayer uplayer, PS ps, boolean verboose) public boolean has(MPlayer uplayer, PS ps, boolean verboose)
{ {
if (uplayer.isUsingAdminMode()) return true; if (uplayer.isUsingAdminMode()) return true;
TerritoryAccess ta = BoardColls.get().getTerritoryAccessAt(ps); TerritoryAccess ta = BoardColl.get().getTerritoryAccessAt(ps);
Faction hostFaction = ta.getHostFaction(ps); Faction hostFaction = ta.getHostFaction(ps);
if (this.isTerritoryPerm()) if (this.isTerritoryPerm())

View File

@ -4,7 +4,7 @@ import java.io.Serializable;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.massivecore.Predictate; import com.massivecraft.massivecore.Predictate;
@ -35,7 +35,7 @@ public class FactionEqualsPredictate implements Predictate<CommandSender>, Seria
@Override @Override
public boolean apply(CommandSender sender) public boolean apply(CommandSender sender)
{ {
UPlayer uplayer = UPlayer.get(sender); MPlayer uplayer = MPlayer.get(sender);
return this.factionId.equals(uplayer.getFactionId()); return this.factionId.equals(uplayer.getFactionId());
} }

View File

@ -22,12 +22,10 @@ import com.massivecraft.factions.chat.tag.ChatTagRoleprefixforce;
import com.massivecraft.factions.chat.tag.ChatTagTitle; import com.massivecraft.factions.chat.tag.ChatTagTitle;
import com.massivecraft.factions.cmd.*; import com.massivecraft.factions.cmd.*;
import com.massivecraft.factions.entity.Board; import com.massivecraft.factions.entity.Board;
import com.massivecraft.factions.entity.BoardColls; import com.massivecraft.factions.entity.BoardColl;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColl;
import com.massivecraft.factions.entity.MPlayerColl; import com.massivecraft.factions.entity.MPlayerColl;
import com.massivecraft.factions.entity.UConfColls;
import com.massivecraft.factions.entity.UPlayerColls;
import com.massivecraft.factions.entity.FactionColls;
import com.massivecraft.factions.entity.MConfColl; import com.massivecraft.factions.entity.MConfColl;
import com.massivecraft.factions.integration.dynmap.IntegrationDynmap; import com.massivecraft.factions.integration.dynmap.IntegrationDynmap;
import com.massivecraft.factions.integration.dynmap.IntegrationDynmapFactions; import com.massivecraft.factions.integration.dynmap.IntegrationDynmapFactions;
@ -117,11 +115,9 @@ public class Factions extends MassivePlugin
this.databaseInitialized = false; this.databaseInitialized = false;
MConfColl.get().init(); MConfColl.get().init();
MPlayerColl.get().init(); MPlayerColl.get().init();
UConfColls.get().init(); FactionColl.get().init();
UPlayerColls.get().init(); BoardColl.get().init();
FactionColls.get().init(); FactionColl.get().reindexUPlayers();
BoardColls.get().init();
FactionColls.get().reindexUPlayers();
this.databaseInitialized = true; this.databaseInitialized = true;
// Commands // Commands
@ -129,7 +125,6 @@ public class Factions extends MassivePlugin
this.outerCmdFactions.register(); this.outerCmdFactions.register();
// Setup Listeners // Setup Listeners
EngineIdUpdate.get().activate();
FactionsListenerMain.get().setup(); FactionsListenerMain.get().setup();
FactionsListenerChat.get().setup(); FactionsListenerChat.get().setup();
FactionsListenerExploit.get().setup(); FactionsListenerExploit.get().setup();

View File

@ -2,9 +2,9 @@ package com.massivecraft.factions;
import java.util.Comparator; import java.util.Comparator;
import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.MPlayer;
public class PlayerRoleComparator implements Comparator<UPlayer> public class PlayerRoleComparator implements Comparator<MPlayer>
{ {
// -------------------------------------------- // // -------------------------------------------- //
// INSTANCE & CONSTRUCT // INSTANCE & CONSTRUCT
@ -18,7 +18,7 @@ public class PlayerRoleComparator implements Comparator<UPlayer>
// -------------------------------------------- // // -------------------------------------------- //
@Override @Override
public int compare(UPlayer o1, UPlayer o2) public int compare(MPlayer o1, MPlayer o2)
{ {
int ret = 0; int ret = 0;

View File

@ -8,11 +8,8 @@ import java.util.Set;
import java.util.TreeSet; import java.util.TreeSet;
import com.massivecraft.factions.entity.FactionColl; import com.massivecraft.factions.entity.FactionColl;
import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColls;
import com.massivecraft.factions.entity.UPlayerColl;
import com.massivecraft.factions.entity.UPlayerColls;
public class TerritoryAccess public class TerritoryAccess
{ {
@ -99,16 +96,15 @@ public class TerritoryAccess
public Faction getHostFaction(Object universe) public Faction getHostFaction(Object universe)
{ {
return FactionColls.get().get(universe).get(this.getHostFactionId()); return FactionColl.get().get(this.getHostFactionId());
} }
public LinkedHashSet<UPlayer> getGrantedUPlayers(Object universe) public LinkedHashSet<MPlayer> getGrantedUPlayers(Object universe)
{ {
LinkedHashSet<UPlayer> ret = new LinkedHashSet<UPlayer>(); LinkedHashSet<MPlayer> ret = new LinkedHashSet<MPlayer>();
UPlayerColl coll = UPlayerColls.get().get(universe);
for (String playerId : this.getPlayerIds()) for (String playerId : this.getPlayerIds())
{ {
ret.add(coll.get(playerId)); ret.add(MPlayer.get(playerId));
} }
return ret; return ret;
} }
@ -116,10 +112,9 @@ public class TerritoryAccess
public LinkedHashSet<Faction> getGrantedFactions(Object universe) public LinkedHashSet<Faction> getGrantedFactions(Object universe)
{ {
LinkedHashSet<Faction> ret = new LinkedHashSet<Faction>(); LinkedHashSet<Faction> ret = new LinkedHashSet<Faction>();
FactionColl coll = FactionColls.get().get(universe);
for (String factionId : this.getFactionIds()) for (String factionId : this.getFactionIds())
{ {
ret.add(coll.get(factionId)); ret.add(FactionColl.get().get(factionId));
} }
return ret; return ret;
} }
@ -205,7 +200,7 @@ public class TerritoryAccess
// true means elevated access // true means elevated access
// false means decreased access // false means decreased access
// null means standard access // null means standard access
public Boolean hasTerritoryAccess(UPlayer uplayer) public Boolean hasTerritoryAccess(MPlayer uplayer)
{ {
if (this.getPlayerIds().contains(uplayer.getId())) return true; if (this.getPlayerIds().contains(uplayer.getId())) return true;

View File

@ -4,8 +4,7 @@ import org.bukkit.command.CommandSender;
import com.massivecraft.factions.chat.ChatTagAbstract; import com.massivecraft.factions.chat.ChatTagAbstract;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.UConf; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.UPlayer;
public class ChatTagName extends ChatTagAbstract public class ChatTagName extends ChatTagAbstract
{ {
@ -24,11 +23,8 @@ public class ChatTagName extends ChatTagAbstract
@Override @Override
public String getReplacement(CommandSender sender, CommandSender recipient) public String getReplacement(CommandSender sender, CommandSender recipient)
{ {
// Check disabled
if (UConf.isDisabled(sender)) return "";
// Get entities // Get entities
UPlayer usender = UPlayer.get(sender); MPlayer usender = MPlayer.get(sender);
// No "force" // No "force"
Faction faction = usender.getFaction(); Faction faction = usender.getFaction();

View File

@ -4,8 +4,7 @@ import org.bukkit.command.CommandSender;
import com.massivecraft.factions.chat.ChatTagAbstract; import com.massivecraft.factions.chat.ChatTagAbstract;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.UConf; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.UPlayer;
public class ChatTagNameforce extends ChatTagAbstract public class ChatTagNameforce extends ChatTagAbstract
{ {
@ -24,11 +23,8 @@ public class ChatTagNameforce extends ChatTagAbstract
@Override @Override
public String getReplacement(CommandSender sender, CommandSender recipient) public String getReplacement(CommandSender sender, CommandSender recipient)
{ {
// Check disabled
if (UConf.isDisabled(sender)) return "";
// Get entities // Get entities
UPlayer usender = UPlayer.get(sender); MPlayer usender = MPlayer.get(sender);
Faction faction = usender.getFaction(); Faction faction = usender.getFaction();
return faction.getName(); return faction.getName();

View File

@ -3,8 +3,7 @@ package com.massivecraft.factions.chat.tag;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.massivecraft.factions.chat.ChatTagAbstract; import com.massivecraft.factions.chat.ChatTagAbstract;
import com.massivecraft.factions.entity.UConf; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.UPlayer;
public class ChatTagRelcolor extends ChatTagAbstract public class ChatTagRelcolor extends ChatTagAbstract
{ {
@ -23,15 +22,12 @@ public class ChatTagRelcolor extends ChatTagAbstract
@Override @Override
public String getReplacement(CommandSender sender, CommandSender recipient) public String getReplacement(CommandSender sender, CommandSender recipient)
{ {
// Check disabled
if (UConf.isDisabled(sender)) return "";
// Opt out if no recipient // Opt out if no recipient
if (recipient == null) return null; if (recipient == null) return null;
// Get entities // Get entities
UPlayer usender = UPlayer.get(sender); MPlayer usender = MPlayer.get(sender);
UPlayer urecipient = UPlayer.get(recipient); MPlayer urecipient = MPlayer.get(recipient);
return urecipient.getRelationTo(usender).getColor().toString(); return urecipient.getRelationTo(usender).getColor().toString();
} }

View File

@ -3,8 +3,7 @@ package com.massivecraft.factions.chat.tag;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.massivecraft.factions.chat.ChatTagAbstract; import com.massivecraft.factions.chat.ChatTagAbstract;
import com.massivecraft.factions.entity.UConf; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.massivecore.util.Txt; import com.massivecraft.massivecore.util.Txt;
public class ChatTagRole extends ChatTagAbstract public class ChatTagRole extends ChatTagAbstract
@ -24,11 +23,8 @@ public class ChatTagRole extends ChatTagAbstract
@Override @Override
public String getReplacement(CommandSender sender, CommandSender recipient) public String getReplacement(CommandSender sender, CommandSender recipient)
{ {
// Check disabled
if (UConf.isDisabled(sender)) return "";
// Get entities // Get entities
UPlayer usender = UPlayer.get(sender); MPlayer usender = MPlayer.get(sender);
return Txt.upperCaseFirst(usender.getRole().toString().toLowerCase()); return Txt.upperCaseFirst(usender.getRole().toString().toLowerCase());
} }

View File

@ -4,8 +4,7 @@ import org.bukkit.command.CommandSender;
import com.massivecraft.factions.chat.ChatTagAbstract; import com.massivecraft.factions.chat.ChatTagAbstract;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.UConf; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.UPlayer;
public class ChatTagRoleprefix extends ChatTagAbstract public class ChatTagRoleprefix extends ChatTagAbstract
{ {
@ -24,11 +23,8 @@ public class ChatTagRoleprefix extends ChatTagAbstract
@Override @Override
public String getReplacement(CommandSender sender, CommandSender recipient) public String getReplacement(CommandSender sender, CommandSender recipient)
{ {
// Check disabled
if (UConf.isDisabled(sender)) return "";
// Get entities // Get entities
UPlayer usender = UPlayer.get(sender); MPlayer usender = MPlayer.get(sender);
// No "force" // No "force"
Faction faction = usender.getFaction(); Faction faction = usender.getFaction();

View File

@ -3,8 +3,7 @@ package com.massivecraft.factions.chat.tag;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.massivecraft.factions.chat.ChatTagAbstract; import com.massivecraft.factions.chat.ChatTagAbstract;
import com.massivecraft.factions.entity.UConf; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.UPlayer;
public class ChatTagRoleprefixforce extends ChatTagAbstract public class ChatTagRoleprefixforce extends ChatTagAbstract
{ {
@ -23,11 +22,8 @@ public class ChatTagRoleprefixforce extends ChatTagAbstract
@Override @Override
public String getReplacement(CommandSender sender, CommandSender recipient) public String getReplacement(CommandSender sender, CommandSender recipient)
{ {
// Check disabled
if (UConf.isDisabled(sender)) return "";
// Get entities // Get entities
UPlayer usender = UPlayer.get(sender); MPlayer usender = MPlayer.get(sender);
return usender.getRole().getPrefix(); return usender.getRole().getPrefix();
} }

View File

@ -3,8 +3,7 @@ package com.massivecraft.factions.chat.tag;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.massivecraft.factions.chat.ChatTagAbstract; import com.massivecraft.factions.chat.ChatTagAbstract;
import com.massivecraft.factions.entity.UConf; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.UPlayer;
public class ChatTagTitle extends ChatTagAbstract public class ChatTagTitle extends ChatTagAbstract
{ {
@ -23,11 +22,8 @@ public class ChatTagTitle extends ChatTagAbstract
@Override @Override
public String getReplacement(CommandSender sender, CommandSender recipient) public String getReplacement(CommandSender sender, CommandSender recipient)
{ {
// Check disabled
if (UConf.isDisabled(sender)) return "";
// Get entities // Get entities
UPlayer usender = UPlayer.get(sender); MPlayer usender = MPlayer.get(sender);
if (!usender.hasTitle()) return ""; if (!usender.hasTitle()) return "";
return usender.getTitle(); return usender.getTitle();

View File

@ -1,7 +1,6 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.massivecore.cmd.HelpCommand; import com.massivecraft.massivecore.cmd.HelpCommand;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
@ -32,7 +31,6 @@ public class CmdFactionsAccess extends FCommand
this.addAliases("access"); this.addAliases("access");
// Requirements // Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqIsPlayer.get()); this.addRequirements(ReqIsPlayer.get());
this.addRequirements(ReqHasPerm.get(Perm.ACCESS.node)); this.addRequirements(ReqHasPerm.get(Perm.ACCESS.node));
} }

View File

@ -6,8 +6,7 @@ import java.util.List;
import com.massivecraft.factions.RelationParticipator; import com.massivecraft.factions.RelationParticipator;
import com.massivecraft.factions.TerritoryAccess; import com.massivecraft.factions.TerritoryAccess;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.entity.BoardColl;
import com.massivecraft.factions.entity.BoardColls;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.ps.PS;
@ -32,7 +31,6 @@ public abstract class CmdFactionsAccessAbstract extends FCommand
public CmdFactionsAccessAbstract() public CmdFactionsAccessAbstract()
{ {
// Requirements // Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqIsPlayer.get()); this.addRequirements(ReqIsPlayer.get());
} }
@ -44,7 +42,7 @@ public abstract class CmdFactionsAccessAbstract extends FCommand
public void perform() public void perform()
{ {
chunk = PS.valueOf(me).getChunk(true); chunk = PS.valueOf(me).getChunk(true);
ta = BoardColls.get().getTerritoryAccessAt(chunk); ta = BoardColl.get().getTerritoryAccessAt(chunk);
hostFaction = ta.getHostFaction(usender); hostFaction = ta.getHostFaction(usender);
this.innerPerform(); this.innerPerform();

View File

@ -3,7 +3,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPerm; import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.entity.BoardColls; import com.massivecraft.factions.entity.BoardColl;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.massivecore.cmd.arg.ARBoolean; import com.massivecraft.massivecore.cmd.arg.ARBoolean;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
@ -35,7 +35,7 @@ public class CmdFactionsAccessFaction extends CmdFactionsAccessAbstract
public void innerPerform() public void innerPerform()
{ {
// Args // Args
Faction faction = this.arg(0, ARFaction.get(usender)); Faction faction = this.arg(0, ARFaction.get());
if (faction == null) return; if (faction == null) return;
Boolean newValue = this.arg(1, ARBoolean.get(), !ta.isFactionIdGranted(faction.getId())); Boolean newValue = this.arg(1, ARBoolean.get(), !ta.isFactionIdGranted(faction.getId()));
@ -46,7 +46,7 @@ public class CmdFactionsAccessFaction extends CmdFactionsAccessAbstract
// Apply // Apply
ta = ta.withFactionId(faction.getId(), newValue); ta = ta.withFactionId(faction.getId(), newValue);
BoardColls.get().setTerritoryAccessAt(chunk, ta); BoardColl.get().setTerritoryAccessAt(chunk, ta);
// Inform // Inform
this.sendAccessInfo(); this.sendAccessInfo();

View File

@ -3,8 +3,8 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPerm; import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARUPlayer; import com.massivecraft.factions.cmd.arg.ARUPlayer;
import com.massivecraft.factions.entity.BoardColls; import com.massivecraft.factions.entity.BoardColl;
import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.massivecore.cmd.arg.ARBoolean; import com.massivecraft.massivecore.cmd.arg.ARBoolean;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
@ -35,7 +35,7 @@ public class CmdFactionsAccessPlayer extends CmdFactionsAccessAbstract
public void innerPerform() public void innerPerform()
{ {
// Args // Args
UPlayer uplayer = this.arg(0, ARUPlayer.getAny(usender)); MPlayer uplayer = this.arg(0, ARUPlayer.getAny());
if (uplayer == null) return; if (uplayer == null) return;
Boolean newValue = this.arg(1, ARBoolean.get(), !ta.isPlayerIdGranted(uplayer.getId())); Boolean newValue = this.arg(1, ARBoolean.get(), !ta.isPlayerIdGranted(uplayer.getId()));
@ -46,7 +46,7 @@ public class CmdFactionsAccessPlayer extends CmdFactionsAccessAbstract
// Apply // Apply
ta = ta.withPlayerId(uplayer.getId(), newValue); ta = ta.withPlayerId(uplayer.getId(), newValue);
BoardColls.get().setTerritoryAccessAt(chunk, ta); BoardColl.get().setTerritoryAccessAt(chunk, ta);
// Inform // Inform
this.sendAccessInfo(); this.sendAccessInfo();

View File

@ -3,9 +3,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPerm; import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.UConf;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.ps.PS;
@ -25,7 +23,6 @@ public class CmdFactionsAutoClaim extends FCommand
this.addOptionalArg("faction", "you"); this.addOptionalArg("faction", "you");
// Requirements // Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.AUTOCLAIM.node)); this.addRequirements(ReqHasPerm.get(Perm.AUTOCLAIM.node));
this.addRequirements(ReqIsPlayer.get()); this.addRequirements(ReqIsPlayer.get());
} }
@ -37,11 +34,8 @@ public class CmdFactionsAutoClaim extends FCommand
@Override @Override
public void perform() public void perform()
{ {
// Check disabled
if (UConf.isDisabled(sender, sender)) return;
// Args // Args
Faction forFaction = this.arg(0, ARFaction.get(usenderFaction), usenderFaction); Faction forFaction = this.arg(0, ARFaction.get(), usenderFaction);
if (forFaction == null || forFaction == usender.getAutoClaimFaction()) if (forFaction == null || forFaction == usender.getAutoClaimFaction())
{ {

View File

@ -3,7 +3,6 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPerm; import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.task.SpiralTask; import com.massivecraft.factions.task.SpiralTask;
@ -29,7 +28,6 @@ public class CmdFactionsClaim extends FCommand
this.addOptionalArg("faction", "you"); this.addOptionalArg("faction", "you");
// Requirements // Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqIsPlayer.get()); this.addRequirements(ReqIsPlayer.get());
this.addRequirements(ReqHasPerm.get(Perm.CLAIM.node)); this.addRequirements(ReqHasPerm.get(Perm.CLAIM.node));
} }
@ -45,7 +43,7 @@ public class CmdFactionsClaim extends FCommand
Integer radius = this.arg(0, ARInteger.get(), 1); Integer radius = this.arg(0, ARInteger.get(), 1);
if (radius == null) return; if (radius == null) return;
final Faction forFaction = this.arg(1, ARFaction.get(me), usenderFaction); final Faction forFaction = this.arg(1, ARFaction.get(), usenderFaction);
if (forFaction == null) return; if (forFaction == null) return;
// FPerm // FPerm

View File

@ -5,14 +5,12 @@ import java.util.ArrayList;
import com.massivecraft.factions.Factions; import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel; import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.cmd.req.ReqHasntFaction; import com.massivecraft.factions.cmd.req.ReqHasntFaction;
import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.UPlayerColls;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColl; import com.massivecraft.factions.entity.FactionColl;
import com.massivecraft.factions.entity.FactionColls;
import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.entity.MPlayerColl;
import com.massivecraft.factions.event.EventFactionsCreate; import com.massivecraft.factions.event.EventFactionsCreate;
import com.massivecraft.factions.event.EventFactionsMembershipChange; import com.massivecraft.factions.event.EventFactionsMembershipChange;
import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason; import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason;
@ -34,7 +32,6 @@ public class CmdFactionsCreate extends FCommand
this.addRequiredArg("name"); this.addRequiredArg("name");
// Requirements // Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasntFaction.get()); this.addRequirements(ReqHasntFaction.get());
this.addRequirements(ReqHasPerm.get(Perm.CREATE.node)); this.addRequirements(ReqHasPerm.get(Perm.CREATE.node));
} }
@ -50,15 +47,13 @@ public class CmdFactionsCreate extends FCommand
String newName = this.arg(0); String newName = this.arg(0);
// Verify // Verify
FactionColl coll = FactionColls.get().get(usender); if (FactionColl.get().isNameTaken(newName))
if (coll.isNameTaken(newName))
{ {
msg("<b>That name is already in use."); msg("<b>That name is already in use.");
return; return;
} }
ArrayList<String> nameValidationErrors = coll.validateName(newName); ArrayList<String> nameValidationErrors = FactionColl.get().validateName(newName);
if (nameValidationErrors.size() > 0) if (nameValidationErrors.size() > 0)
{ {
sendMessage(nameValidationErrors); sendMessage(nameValidationErrors);
@ -69,12 +64,12 @@ public class CmdFactionsCreate extends FCommand
String factionId = MStore.createId(); String factionId = MStore.createId();
// Event // Event
EventFactionsCreate createEvent = new EventFactionsCreate(sender, coll.getUniverse(), factionId, newName); EventFactionsCreate createEvent = new EventFactionsCreate(sender, factionId, newName);
createEvent.run(); createEvent.run();
if (createEvent.isCancelled()) return; if (createEvent.isCancelled()) return;
// Apply // Apply
Faction faction = coll.create(factionId); Faction faction = FactionColl.get().create(factionId);
faction.setName(newName); faction.setName(newName);
usender.setRole(Rel.LEADER); usender.setRole(Rel.LEADER);
@ -85,7 +80,7 @@ public class CmdFactionsCreate extends FCommand
// NOTE: join event cannot be cancelled or you'll have an empty faction // NOTE: join event cannot be cancelled or you'll have an empty faction
// Inform // Inform
for (UPlayer follower : UPlayerColls.get().get(usender).getAllOnline()) for (MPlayer follower : MPlayerColl.get().getAllOnline())
{ {
follower.msg("%s<i> created a new faction %s", usender.describeTo(follower, true), faction.getName(follower)); follower.msg("%s<i> created a new faction %s", usender.describeTo(follower, true), faction.getName(follower));
} }

View File

@ -3,8 +3,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel; import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.arg.ARUPlayer; import com.massivecraft.factions.cmd.arg.ARUPlayer;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
public class CmdFactionsDemote extends FCommand public class CmdFactionsDemote extends FCommand
@ -22,7 +21,6 @@ public class CmdFactionsDemote extends FCommand
this.addRequiredArg("player"); this.addRequiredArg("player");
// Requirements // Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.DEMOTE.node)); this.addRequirements(ReqHasPerm.get(Perm.DEMOTE.node));
//To demote someone from member -> recruit you must be an officer. //To demote someone from member -> recruit you must be an officer.
@ -37,7 +35,7 @@ public class CmdFactionsDemote extends FCommand
@Override @Override
public void perform() public void perform()
{ {
UPlayer you = this.arg(0, ARUPlayer.getAny(usender)); MPlayer you = this.arg(0, ARUPlayer.getAny());
if (you == null) return; if (you == null) return;
if (you.getFaction() != usenderFaction) if (you.getFaction() != usenderFaction)

View File

@ -2,10 +2,9 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel; import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.cmd.req.ReqHasFaction; import com.massivecraft.factions.cmd.req.ReqHasFaction;
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast; import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.event.EventFactionsDescriptionChange; import com.massivecraft.factions.event.EventFactionsDescriptionChange;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.mixin.Mixin; import com.massivecraft.massivecore.mixin.Mixin;
@ -26,7 +25,6 @@ public class CmdFactionsDescription extends FCommand
this.setErrorOnToManyArgs(false); this.setErrorOnToManyArgs(false);
// Requirements // Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.DESCRIPTION.node)); this.addRequirements(ReqHasPerm.get(Perm.DESCRIPTION.node));
this.addRequirements(ReqHasFaction.get()); this.addRequirements(ReqHasFaction.get());
this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER)); this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER));
@ -52,7 +50,7 @@ public class CmdFactionsDescription extends FCommand
usenderFaction.setDescription(newDescription); usenderFaction.setDescription(newDescription);
// Inform // Inform
for (UPlayer follower : usenderFaction.getUPlayers()) for (MPlayer follower : usenderFaction.getUPlayers())
{ {
follower.msg("<i>%s <i>set your faction description to:\n%s", Mixin.getDisplayName(sender, follower), usenderFaction.getDescription()); follower.msg("<i>%s <i>set your faction description to:\n%s", Mixin.getDisplayName(sender, follower), usenderFaction.getDescription());
} }

View File

@ -1,12 +1,11 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.entity.FactionColl;
import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.UPlayerColls;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColls;
import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.entity.MPlayerColl;
import com.massivecraft.factions.event.EventFactionsDisband; import com.massivecraft.factions.event.EventFactionsDisband;
import com.massivecraft.factions.event.EventFactionsMembershipChange; import com.massivecraft.factions.event.EventFactionsMembershipChange;
import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason; import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason;
@ -33,7 +32,6 @@ public class CmdFactionsDisband extends FCommand
this.addOptionalArg("faction", "you"); this.addOptionalArg("faction", "you");
// Requirements // Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.DISBAND.node)); this.addRequirements(ReqHasPerm.get(Perm.DISBAND.node));
} }
@ -45,7 +43,7 @@ public class CmdFactionsDisband extends FCommand
public void perform() public void perform()
{ {
// Args // Args
Faction faction = this.arg(0, ARFaction.get(usender), usenderFaction); Faction faction = this.arg(0, ARFaction.get(), usenderFaction);
if (faction == null) return; if (faction == null) return;
// FPerm // FPerm
@ -66,14 +64,14 @@ public class CmdFactionsDisband extends FCommand
// Merged Apply and Inform // Merged Apply and Inform
// Run event for each player in the faction // Run event for each player in the faction
for (UPlayer uplayer : faction.getUPlayers()) for (MPlayer uplayer : faction.getUPlayers())
{ {
EventFactionsMembershipChange membershipChangeEvent = new EventFactionsMembershipChange(sender, uplayer, FactionColls.get().get(faction).getNone(), MembershipChangeReason.DISBAND); EventFactionsMembershipChange membershipChangeEvent = new EventFactionsMembershipChange(sender, uplayer, FactionColl.get().getNone(), MembershipChangeReason.DISBAND);
membershipChangeEvent.run(); membershipChangeEvent.run();
} }
// Inform all players // Inform all players
for (UPlayer uplayer : UPlayerColls.get().get(usender).getAllOnline()) for (MPlayer uplayer : MPlayerColl.get().getAllOnline())
{ {
String who = usender.describeTo(uplayer); String who = usender.describeTo(uplayer);
if (uplayer.getFaction() == faction) if (uplayer.getFaction() == faction)

View File

@ -7,9 +7,8 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.entity.UConf; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.event.EventFactionsChunkChangeType; import com.massivecraft.factions.event.EventFactionsChunkChangeType;
import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.integration.Econ;
@ -39,7 +38,6 @@ public class CmdFactionsFaction extends FCommand
this.addOptionalArg("faction", "you"); this.addOptionalArg("faction", "you");
// Requirements // Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.FACTION.node)); this.addRequirements(ReqHasPerm.get(Perm.FACTION.node));
} }
@ -51,11 +49,10 @@ public class CmdFactionsFaction extends FCommand
public void perform() public void perform()
{ {
// Args // Args
Faction faction = this.arg(0, ARFaction.get(usenderFaction), usenderFaction); Faction faction = this.arg(0, ARFaction.get(), usenderFaction);
if (faction == null) return; if (faction == null) return;
// Data precalculation // Data precalculation
UConf uconf = UConf.get(faction);
//boolean none = faction.isNone(); //boolean none = faction.isNone();
boolean normal = faction.isNormal(); boolean normal = faction.isNormal();
@ -82,13 +79,13 @@ public class CmdFactionsFaction extends FCommand
msg("<a>Land / Power / Maxpower: <i> %d/%d/%d %s", faction.getLandCount(), faction.getPowerRounded(), faction.getPowerMaxRounded(), boost); msg("<a>Land / Power / Maxpower: <i> %d/%d/%d %s", faction.getLandCount(), faction.getPowerRounded(), faction.getPowerMaxRounded(), boost);
// show the land value // show the land value
if (Econ.isEnabled(faction)) if (Econ.isEnabled())
{ {
long landCount = faction.getLandCount(); long landCount = faction.getLandCount();
for (EventFactionsChunkChangeType type : EventFactionsChunkChangeType.values()) for (EventFactionsChunkChangeType type : EventFactionsChunkChangeType.values())
{ {
Double money = uconf.econChunkCost.get(type); Double money = MConf.get().econChunkCost.get(type);
if (money == null) continue; if (money == null) continue;
if (money == 0D) continue; if (money == 0D) continue;
money *= landCount; money *= landCount;
@ -108,7 +105,7 @@ public class CmdFactionsFaction extends FCommand
} }
// Show bank contents // Show bank contents
if (UConf.get(faction).bankEnabled) if (MConf.get().bankEnabled)
{ {
msg("<a>Bank contains: <i>"+Money.format(Money.get(faction))); msg("<a>Bank contains: <i>"+Money.format(Money.get(faction)));
} }
@ -148,10 +145,10 @@ public class CmdFactionsFaction extends FCommand
List<String> followerNamesOnline = new ArrayList<String>(); List<String> followerNamesOnline = new ArrayList<String>();
List<String> followerNamesOffline = new ArrayList<String>(); List<String> followerNamesOffline = new ArrayList<String>();
List<UPlayer> followers = faction.getUPlayers(); List<MPlayer> followers = faction.getUPlayers();
Collections.sort(followers, PlayerRoleComparator.get()); Collections.sort(followers, PlayerRoleComparator.get());
for (UPlayer follower : followers) for (MPlayer follower : followers)
{ {
if (follower.isOnline() && Mixin.canSee(sender, follower.getId())) if (follower.isOnline() && Mixin.canSee(sender, follower.getId()))
{ {

View File

@ -4,7 +4,6 @@ import com.massivecraft.factions.FFlag;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFFlag; import com.massivecraft.factions.cmd.arg.ARFFlag;
import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.massivecore.cmd.arg.ARBoolean; import com.massivecraft.massivecore.cmd.arg.ARBoolean;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
@ -27,7 +26,6 @@ public class CmdFactionsFlag extends FCommand
this.addOptionalArg("yes/no", "read"); this.addOptionalArg("yes/no", "read");
// Requirements // Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.FLAG.node)); this.addRequirements(ReqHasPerm.get(Perm.FLAG.node));
} }
@ -38,7 +36,7 @@ public class CmdFactionsFlag extends FCommand
@Override @Override
public void perform() public void perform()
{ {
Faction faction = this.arg(0, ARFaction.get(sender), usenderFaction); Faction faction = this.arg(0, ARFaction.get(), usenderFaction);
if (faction == null) return; if (faction == null) return;
if ( ! this.argIsSet(1)) if ( ! this.argIsSet(1))

View File

@ -8,11 +8,10 @@ import com.massivecraft.factions.FFlag;
import com.massivecraft.factions.Factions; import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel; import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.cmd.req.ReqHasFaction; import com.massivecraft.factions.cmd.req.ReqHasFaction;
import com.massivecraft.factions.entity.BoardColls; import com.massivecraft.factions.entity.BoardColl;
import com.massivecraft.factions.entity.UConf; import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.event.EventFactionsHomeTeleport; import com.massivecraft.factions.event.EventFactionsHomeTeleport;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
@ -34,7 +33,6 @@ public class CmdFactionsHome extends FCommand
this.addAliases("home"); this.addAliases("home");
// Requirements // Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.HOME.node)); this.addRequirements(ReqHasPerm.get(Perm.HOME.node));
this.addRequirements(ReqHasFaction.get()); this.addRequirements(ReqHasFaction.get());
this.addRequirements(ReqIsPlayer.get()); this.addRequirements(ReqIsPlayer.get());
@ -47,16 +45,14 @@ public class CmdFactionsHome extends FCommand
@Override @Override
public void perform() public void perform()
{ {
UConf uconf = UConf.get(sender);
// TODO: Hide this command on help also. // TODO: Hide this command on help also.
if ( ! uconf.homesEnabled) if ( ! MConf.get().homesEnabled)
{ {
usender.msg("<b>Sorry, Faction homes are disabled on this server."); usender.msg("<b>Sorry, Faction homes are disabled on this server.");
return; return;
} }
if ( ! uconf.homesTeleportCommandEnabled) if ( ! MConf.get().homesTeleportCommandEnabled)
{ {
usender.msg("<b>Sorry, the ability to teleport to Faction homes is disabled on this server."); usender.msg("<b>Sorry, the ability to teleport to Faction homes is disabled on this server.");
return; return;
@ -69,26 +65,26 @@ public class CmdFactionsHome extends FCommand
return; return;
} }
if ( ! uconf.homesTeleportAllowedFromEnemyTerritory && usender.isInEnemyTerritory()) if ( ! MConf.get().homesTeleportAllowedFromEnemyTerritory && usender.isInEnemyTerritory())
{ {
usender.msg("<b>You cannot teleport to your faction home while in the territory of an enemy faction."); usender.msg("<b>You cannot teleport to your faction home while in the territory of an enemy faction.");
return; return;
} }
if (!uconf.homesTeleportAllowedFromDifferentWorld && !me.getWorld().getName().equalsIgnoreCase(usenderFaction.getHome().getWorld())) if ( ! MConf.get().homesTeleportAllowedFromDifferentWorld && !me.getWorld().getName().equalsIgnoreCase(usenderFaction.getHome().getWorld()))
{ {
usender.msg("<b>You cannot teleport to your faction home while in a different world."); usender.msg("<b>You cannot teleport to your faction home while in a different world.");
return; return;
} }
Faction faction = BoardColls.get().getFactionAt(PS.valueOf(me)); Faction faction = BoardColl.get().getFactionAt(PS.valueOf(me));
Location loc = me.getLocation().clone(); Location loc = me.getLocation().clone();
// if player is not in a safe zone or their own faction territory, only allow teleport if no enemies are nearby // if player is not in a safe zone or their own faction territory, only allow teleport if no enemies are nearby
if if
( (
uconf.homesTeleportAllowedEnemyDistance > 0 MConf.get().homesTeleportAllowedEnemyDistance > 0
&& &&
faction.getFlag(FFlag.PVP) faction.getFlag(FFlag.PVP)
&& &&
@ -98,7 +94,7 @@ public class CmdFactionsHome extends FCommand
( (
usender.isInOwnTerritory() usender.isInOwnTerritory()
&& &&
! uconf.homesTeleportIgnoreEnemiesIfInOwnTerritory ! MConf.get().homesTeleportIgnoreEnemiesIfInOwnTerritory
) )
) )
) )
@ -113,7 +109,7 @@ public class CmdFactionsHome extends FCommand
if (p == null || !p.isOnline() || p.isDead() || p == me || p.getWorld() != w) if (p == null || !p.isOnline() || p.isDead() || p == me || p.getWorld() != w)
continue; continue;
UPlayer fp = UPlayer.get(p); MPlayer fp = MPlayer.get(p);
if (usender.getRelationTo(fp) != Rel.ENEMY) if (usender.getRelationTo(fp) != Rel.ENEMY)
continue; continue;
@ -121,13 +117,13 @@ public class CmdFactionsHome extends FCommand
double dx = Math.abs(x - l.getX()); double dx = Math.abs(x - l.getX());
double dy = Math.abs(y - l.getY()); double dy = Math.abs(y - l.getY());
double dz = Math.abs(z - l.getZ()); double dz = Math.abs(z - l.getZ());
double max = uconf.homesTeleportAllowedEnemyDistance; double max = MConf.get().homesTeleportAllowedEnemyDistance;
// box-shaped distance check // box-shaped distance check
if (dx > max || dy > max || dz > max) if (dx > max || dy > max || dz > max)
continue; continue;
usender.msg("<b>You cannot teleport to your faction home while an enemy is within " + uconf.homesTeleportAllowedEnemyDistance + " blocks of you."); usender.msg("<b>You cannot teleport to your faction home while an enemy is within " + MConf.get().homesTeleportAllowedEnemyDistance + " blocks of you.");
return; return;
} }
} }

View File

@ -4,9 +4,8 @@ import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.Factions; import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARUPlayer; import com.massivecraft.factions.cmd.arg.ARUPlayer;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.cmd.req.ReqHasFaction; import com.massivecraft.factions.cmd.req.ReqHasFaction;
import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.event.EventFactionsInvitedChange; import com.massivecraft.factions.event.EventFactionsInvitedChange;
import com.massivecraft.massivecore.cmd.arg.ARBoolean; import com.massivecraft.massivecore.cmd.arg.ARBoolean;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
@ -28,7 +27,6 @@ public class CmdFactionsInvite extends FCommand
this.addOptionalArg("yes/no", "toggle"); this.addOptionalArg("yes/no", "toggle");
// Requirements // Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.INVITE.node)); this.addRequirements(ReqHasPerm.get(Perm.INVITE.node));
this.addRequirements(ReqHasFaction.get()); this.addRequirements(ReqHasFaction.get());
this.addRequirements(ReqIsPlayer.get()); this.addRequirements(ReqIsPlayer.get());
@ -42,7 +40,7 @@ public class CmdFactionsInvite extends FCommand
public void perform() public void perform()
{ {
// Args // Args
UPlayer uplayer = this.arg(0, ARUPlayer.getAny(sender)); MPlayer uplayer = this.arg(0, ARUPlayer.getAny());
if (uplayer == null) return; if (uplayer == null) return;
Boolean newInvited = this.arg(1, ARBoolean.get(), !usenderFaction.isInvited(uplayer)); Boolean newInvited = this.arg(1, ARBoolean.get(), !usenderFaction.isInvited(uplayer));

View File

@ -4,11 +4,9 @@ import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARUPlayer; import com.massivecraft.factions.cmd.arg.ARUPlayer;
import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.entity.UConf; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.event.EventFactionsMembershipChange; import com.massivecraft.factions.event.EventFactionsMembershipChange;
import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason; import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
@ -30,7 +28,6 @@ public class CmdFactionsJoin extends FCommand
this.addOptionalArg("player", "you"); this.addOptionalArg("player", "you");
// Requirements // Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.JOIN.node)); this.addRequirements(ReqHasPerm.get(Perm.JOIN.node));
} }
@ -42,10 +39,10 @@ public class CmdFactionsJoin extends FCommand
public void perform() public void perform()
{ {
// Args // Args
Faction faction = this.arg(0, ARFaction.get(sender)); Faction faction = this.arg(0, ARFaction.get());
if (faction == null) return; if (faction == null) return;
UPlayer uplayer = this.arg(1, ARUPlayer.getAny(sender), usender); MPlayer uplayer = this.arg(1, ARUPlayer.getAny(), usender);
if (uplayer == null) return; if (uplayer == null) return;
Faction uplayerFaction = uplayer.getFaction(); Faction uplayerFaction = uplayer.getFaction();
@ -64,9 +61,9 @@ public class CmdFactionsJoin extends FCommand
return; return;
} }
if (UConf.get(faction).factionMemberLimit > 0 && faction.getUPlayers().size() >= UConf.get(faction).factionMemberLimit) if (MConf.get().factionMemberLimit > 0 && faction.getUPlayers().size() >= MConf.get().factionMemberLimit)
{ {
msg(" <b>!<white> The faction %s is at the limit of %d members, so %s cannot currently join.", faction.getName(usender), UConf.get(faction).factionMemberLimit, uplayer.describeTo(usender, false)); msg(" <b>!<white> The faction %s is at the limit of %d members, so %s cannot currently join.", faction.getName(usender), MConf.get().factionMemberLimit, uplayer.describeTo(usender, false));
return; return;
} }
@ -76,7 +73,7 @@ public class CmdFactionsJoin extends FCommand
return; return;
} }
if (!UConf.get(faction).canLeaveWithNegativePower && uplayer.getPower() < 0) if (!MConf.get().canLeaveWithNegativePower && uplayer.getPower() < 0)
{ {
msg("<b>%s cannot join a faction with a negative power level.", uplayer.describeTo(usender, true)); msg("<b>%s cannot join a faction with a negative power level.", uplayer.describeTo(usender, true));
return; return;

View File

@ -5,12 +5,10 @@ import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel; import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.arg.ARUPlayer; import com.massivecraft.factions.cmd.arg.ARUPlayer;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.entity.FactionColl;
import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColls;
import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.entity.UConf;
import com.massivecraft.factions.event.EventFactionsMembershipChange; import com.massivecraft.factions.event.EventFactionsMembershipChange;
import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason; import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
@ -31,7 +29,6 @@ public class CmdFactionsKick extends FCommand
this.addRequiredArg("player"); this.addRequiredArg("player");
// Requirements // Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.KICK.node)); this.addRequirements(ReqHasPerm.get(Perm.KICK.node));
} }
@ -43,7 +40,7 @@ public class CmdFactionsKick extends FCommand
public void perform() public void perform()
{ {
// Arg // Arg
UPlayer uplayer = this.arg(0, ARUPlayer.getAny(sender)); MPlayer uplayer = this.arg(0, ARUPlayer.getAny());
if (uplayer == null) return; if (uplayer == null) return;
// Validate // Validate
@ -60,7 +57,7 @@ public class CmdFactionsKick extends FCommand
return; return;
} }
if ( ! UConf.get(uplayer).canLeaveWithNegativePower && uplayer.getPower() < 0) if ( ! MConf.get().canLeaveWithNegativePower && uplayer.getPower() < 0)
{ {
msg("<b>You cannot kick that member until their power is positive."); msg("<b>You cannot kick that member until their power is positive.");
return; return;
@ -71,7 +68,7 @@ public class CmdFactionsKick extends FCommand
if (!FPerm.KICK.has(usender, uplayerFaction, true)) return; if (!FPerm.KICK.has(usender, uplayerFaction, true)) return;
// Event // Event
EventFactionsMembershipChange event = new EventFactionsMembershipChange(sender, uplayer, FactionColls.get().get(uplayer).getNone(), MembershipChangeReason.KICK); EventFactionsMembershipChange event = new EventFactionsMembershipChange(sender, uplayer, FactionColl.get().getNone(), MembershipChangeReason.KICK);
event.run(); event.run();
if (event.isCancelled()) return; if (event.isCancelled()) return;

View File

@ -4,10 +4,9 @@ import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel; import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.arg.ARUPlayer; import com.massivecraft.factions.cmd.arg.ARUPlayer;
import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.UPlayerColls;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MPlayerColl;
import com.massivecraft.factions.event.EventFactionsMembershipChange; import com.massivecraft.factions.event.EventFactionsMembershipChange;
import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason; import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason;
import com.massivecraft.factions.util.RelationUtil; import com.massivecraft.factions.util.RelationUtil;
@ -29,7 +28,6 @@ public class CmdFactionsLeader extends FCommand
this.addOptionalArg("faction", "you"); this.addOptionalArg("faction", "you");
// Requirements // Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.LEADER.node)); this.addRequirements(ReqHasPerm.get(Perm.LEADER.node));
} }
@ -40,13 +38,13 @@ public class CmdFactionsLeader extends FCommand
@Override @Override
public void perform() public void perform()
{ {
UPlayer newLeader = this.arg(0, ARUPlayer.getAny(sender)); MPlayer newLeader = this.arg(0, ARUPlayer.getAny());
if (newLeader == null) return; if (newLeader == null) return;
Faction targetFaction = this.arg(1, ARFaction.get(sender), usenderFaction); Faction targetFaction = this.arg(1, ARFaction.get(), usenderFaction);
if (targetFaction == null) return; if (targetFaction == null) return;
UPlayer targetFactionCurrentLeader = targetFaction.getLeader(); MPlayer targetFactionCurrentLeader = targetFaction.getLeader();
// We now have uplayer and the target faction // We now have uplayer and the target faction
if (this.senderIsConsole || usender.isUsingAdminMode() || Perm.LEADER_ANY.has(sender, false)) if (this.senderIsConsole || usender.isUsingAdminMode() || Perm.LEADER_ANY.has(sender, false))
@ -102,7 +100,7 @@ public class CmdFactionsLeader extends FCommand
msg("<i>You have promoted %s<i> to the position of faction leader.", newLeader.describeTo(usender, true)); msg("<i>You have promoted %s<i> to the position of faction leader.", newLeader.describeTo(usender, true));
// Inform all players // Inform all players
for (UPlayer uplayer : UPlayerColls.get().get(sender).getAllOnline()) for (MPlayer uplayer : MPlayerColl.get().getAllOnline())
{ {
uplayer.msg("%s<i> gave %s<i> the leadership of %s<i>.", senderIsConsole ? "A server admin" : RelationUtil.describeThatToMe(usender, uplayer, true), newLeader.describeTo(uplayer), targetFaction.describeTo(uplayer)); uplayer.msg("%s<i> gave %s<i> the leadership of %s<i>.", senderIsConsole ? "A server admin" : RelationUtil.describeThatToMe(usender, uplayer, true), newLeader.describeTo(uplayer), targetFaction.describeTo(uplayer));
} }

View File

@ -1,7 +1,6 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.cmd.req.ReqHasFaction; import com.massivecraft.factions.cmd.req.ReqHasFaction;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
@ -17,7 +16,6 @@ public class CmdFactionsLeave extends FCommand
this.addAliases("leave"); this.addAliases("leave");
// Requirements // Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.LEAVE.node)); this.addRequirements(ReqHasPerm.get(Perm.LEAVE.node));
this.addRequirements(ReqHasFaction.get()); this.addRequirements(ReqHasFaction.get());
} }

View File

@ -5,9 +5,8 @@ import java.util.List;
import com.massivecraft.factions.FactionListComparator; import com.massivecraft.factions.FactionListComparator;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColls; import com.massivecraft.factions.entity.FactionColl;
import com.massivecraft.massivecore.cmd.arg.ARInteger; import com.massivecraft.massivecore.cmd.arg.ARInteger;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.util.Txt; import com.massivecraft.massivecore.util.Txt;
@ -28,7 +27,6 @@ public class CmdFactionsList extends FCommand
this.addOptionalArg("page", "1"); this.addOptionalArg("page", "1");
// Requirements // Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.LIST.node)); this.addRequirements(ReqHasPerm.get(Perm.LIST.node));
} }
@ -45,7 +43,7 @@ public class CmdFactionsList extends FCommand
// Create Messages // Create Messages
List<String> lines = new ArrayList<String>(); List<String> lines = new ArrayList<String>();
ArrayList<Faction> factionList = new ArrayList<Faction>(FactionColls.get().get(sender).getAll(null, FactionListComparator.get())); ArrayList<Faction> factionList = new ArrayList<Faction>(FactionColl.get().getAll(null, FactionListComparator.get()));
final int pageheight = 9; final int pageheight = 9;
@ -65,7 +63,7 @@ public class CmdFactionsList extends FCommand
{ {
if (faction.isNone()) if (faction.isNone())
{ {
lines.add(Txt.parse("<i>Factionless<i> %d online", FactionColls.get().get(sender).getNone().getUPlayersWhereOnline(true).size())); lines.add(Txt.parse("<i>Factionless<i> %d online", FactionColl.get().getNone().getUPlayersWhereOnline(true).size()));
continue; continue;
} }
lines.add(Txt.parse("%s<i> %d/%d online, %d/%d/%d", lines.add(Txt.parse("%s<i> %d/%d online, %d/%d/%d",

View File

@ -1,8 +1,7 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.entity.BoardColl;
import com.massivecraft.factions.entity.BoardColls;
import com.massivecraft.massivecore.cmd.arg.ARBoolean; import com.massivecraft.massivecore.cmd.arg.ARBoolean;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
@ -23,7 +22,6 @@ public class CmdFactionsMap extends FCommand
this.addOptionalArg("on/off", "once"); this.addOptionalArg("on/off", "once");
// Requirements // Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.MAP.node)); this.addRequirements(ReqHasPerm.get(Perm.MAP.node));
this.addRequirements(ReqIsPlayer.get()); this.addRequirements(ReqIsPlayer.get());
} }
@ -60,7 +58,7 @@ public class CmdFactionsMap extends FCommand
public void showMap() public void showMap()
{ {
sendMessage(BoardColls.get().getMap(usenderFaction, PS.valueOf(me), me.getLocation().getYaw())); sendMessage(BoardColl.get().getMap(usenderFaction, PS.valueOf(me), me.getLocation().getYaw()));
} }
} }

View File

@ -2,7 +2,6 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled; import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
public class CmdFactionsMoney extends FCommand public class CmdFactionsMoney extends FCommand
@ -36,7 +35,6 @@ public class CmdFactionsMoney extends FCommand
this.addAliases("money"); this.addAliases("money");
// Requirements // Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqBankCommandsEnabled.get()); this.addRequirements(ReqBankCommandsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.MONEY.node)); this.addRequirements(ReqHasPerm.get(Perm.MONEY.node));
} }

View File

@ -2,7 +2,6 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled; import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
@ -23,7 +22,6 @@ public class CmdFactionsMoneyBalance extends FCommand
this.addOptionalArg("faction", "you"); this.addOptionalArg("faction", "you");
// Requirements // Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.MONEY_BALANCE.node)); this.addRequirements(ReqHasPerm.get(Perm.MONEY_BALANCE.node));
this.addRequirements(ReqBankCommandsEnabled.get()); this.addRequirements(ReqBankCommandsEnabled.get());
} }
@ -35,7 +33,7 @@ public class CmdFactionsMoneyBalance extends FCommand
@Override @Override
public void perform() public void perform()
{ {
Faction faction = this.arg(0, ARFaction.get(sender), usenderFaction); Faction faction = this.arg(0, ARFaction.get(), usenderFaction);
if (faction == null) return; if (faction == null) return;
if (faction != usenderFaction && ! Perm.MONEY_BALANCE_ANY.has(sender, true)) return; if (faction != usenderFaction && ! Perm.MONEY_BALANCE_ANY.has(sender, true)) return;

View File

@ -4,7 +4,6 @@ import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled; import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.integration.Econ;
@ -31,7 +30,6 @@ public class CmdFactionsMoneyDeposit extends FCommand
this.addOptionalArg("faction", "you"); this.addOptionalArg("faction", "you");
// Requirements // Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.MONEY_DEPOSIT.node)); this.addRequirements(ReqHasPerm.get(Perm.MONEY_DEPOSIT.node));
this.addRequirements(ReqBankCommandsEnabled.get()); this.addRequirements(ReqBankCommandsEnabled.get());
} }
@ -46,7 +44,7 @@ public class CmdFactionsMoneyDeposit extends FCommand
Double amount = this.arg(0, ARDouble.get()); Double amount = this.arg(0, ARDouble.get());
if (amount == null) return; if (amount == null) return;
Faction faction = this.arg(1, ARFaction.get(sender), usenderFaction); Faction faction = this.arg(1, ARFaction.get(), usenderFaction);
if (faction == null) return; if (faction == null) return;
boolean success = Econ.transferMoney(usender, usender, faction, amount); boolean success = Econ.transferMoney(usender, usender, faction, amount);

View File

@ -3,7 +3,6 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled; import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.Factions; import com.massivecraft.factions.Factions;
@ -33,7 +32,6 @@ public class CmdFactionsMoneyTransferFf extends FCommand
this.addRequiredArg("faction"); this.addRequiredArg("faction");
// Requirements // Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.MONEY_F2F.node)); this.addRequirements(ReqHasPerm.get(Perm.MONEY_F2F.node));
this.addRequirements(ReqBankCommandsEnabled.get()); this.addRequirements(ReqBankCommandsEnabled.get());
} }
@ -48,10 +46,10 @@ public class CmdFactionsMoneyTransferFf extends FCommand
Double amount = this.arg(0, ARDouble.get()); Double amount = this.arg(0, ARDouble.get());
if (amount == null) return; if (amount == null) return;
Faction from = this.arg(1, ARFaction.get(sender)); Faction from = this.arg(1, ARFaction.get());
if (from == null) return; if (from == null) return;
Faction to = this.arg(2, ARFaction.get(sender)); Faction to = this.arg(2, ARFaction.get());
if (to == null) return; if (to == null) return;
boolean success = Econ.transferMoney(usender, from, to, amount); boolean success = Econ.transferMoney(usender, from, to, amount);

View File

@ -4,8 +4,7 @@ import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARUPlayer; import com.massivecraft.factions.cmd.arg.ARUPlayer;
import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled; import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.Factions; import com.massivecraft.factions.Factions;
@ -35,7 +34,6 @@ public class CmdFactionsMoneyTransferFp extends FCommand
this.addRequiredArg("player"); this.addRequiredArg("player");
// Requirements // Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.MONEY_F2P.node)); this.addRequirements(ReqHasPerm.get(Perm.MONEY_F2P.node));
this.addRequirements(ReqBankCommandsEnabled.get()); this.addRequirements(ReqBankCommandsEnabled.get());
} }
@ -50,10 +48,10 @@ public class CmdFactionsMoneyTransferFp extends FCommand
Double amount = this.arg(0, ARDouble.get()); Double amount = this.arg(0, ARDouble.get());
if (amount == null) return; if (amount == null) return;
Faction from = this.arg(1, ARFaction.get(sender)); Faction from = this.arg(1, ARFaction.get());
if (from == null) return; if (from == null) return;
UPlayer to = this.arg(2, ARUPlayer.getAny(sender)); MPlayer to = this.arg(2, ARUPlayer.getAny());
if (to == null) return; if (to == null) return;
boolean success = Econ.transferMoney(usender, from, to, amount); boolean success = Econ.transferMoney(usender, from, to, amount);

View File

@ -4,8 +4,7 @@ import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARUPlayer; import com.massivecraft.factions.cmd.arg.ARUPlayer;
import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled; import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.Factions; import com.massivecraft.factions.Factions;
@ -35,7 +34,6 @@ public class CmdFactionsMoneyTransferPf extends FCommand
this.addRequiredArg("faction"); this.addRequiredArg("faction");
// Requirements // Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.MONEY_P2F.node)); this.addRequirements(ReqHasPerm.get(Perm.MONEY_P2F.node));
this.addRequirements(ReqBankCommandsEnabled.get()); this.addRequirements(ReqBankCommandsEnabled.get());
} }
@ -50,10 +48,10 @@ public class CmdFactionsMoneyTransferPf extends FCommand
Double amount = this.arg(0, ARDouble.get()); Double amount = this.arg(0, ARDouble.get());
if (amount == null) return; if (amount == null) return;
UPlayer from = this.arg(1, ARUPlayer.getAny(sender)); MPlayer from = this.arg(1, ARUPlayer.getAny());
if (from == null) return; if (from == null) return;
Faction to = this.arg(2, ARFaction.get(sender)); Faction to = this.arg(2, ARFaction.get());
if (to == null) return; if (to == null) return;
boolean success = Econ.transferMoney(usender, from, to, amount); boolean success = Econ.transferMoney(usender, from, to, amount);

View File

@ -3,8 +3,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled; import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.Factions; import com.massivecraft.factions.Factions;
@ -33,7 +32,6 @@ public class CmdFactionsMoneyWithdraw extends FCommand
this.addOptionalArg("faction", "you"); this.addOptionalArg("faction", "you");
// Requirements // Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.MONEY_WITHDRAW.node)); this.addRequirements(ReqHasPerm.get(Perm.MONEY_WITHDRAW.node));
this.addRequirements(ReqBankCommandsEnabled.get()); this.addRequirements(ReqBankCommandsEnabled.get());
} }
@ -48,10 +46,10 @@ public class CmdFactionsMoneyWithdraw extends FCommand
Double amount = this.arg(0, ARDouble.get()); Double amount = this.arg(0, ARDouble.get());
if (amount == null) return; if (amount == null) return;
Faction from = this.arg(1, ARFaction.get(sender), usenderFaction); Faction from = this.arg(1, ARFaction.get(), usenderFaction);
if (from == null) return; if (from == null) return;
UPlayer to = usender; MPlayer to = usender;
boolean success = Econ.transferMoney(usender, from, to, amount); boolean success = Econ.transferMoney(usender, from, to, amount);

View File

@ -4,13 +4,11 @@ import java.util.ArrayList;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel; import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.cmd.req.ReqHasFaction; import com.massivecraft.factions.cmd.req.ReqHasFaction;
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast; import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColl; import com.massivecraft.factions.entity.FactionColl;
import com.massivecraft.factions.entity.FactionColls; import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.entity.UConf;
import com.massivecraft.factions.event.EventFactionsNameChange; import com.massivecraft.factions.event.EventFactionsNameChange;
import com.massivecraft.factions.util.MiscUtil; import com.massivecraft.factions.util.MiscUtil;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
@ -30,7 +28,6 @@ public class CmdFactionsName extends FCommand
this.addRequiredArg("new name"); this.addRequiredArg("new name");
// Requirements // Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.NAME.node)); this.addRequirements(ReqHasPerm.get(Perm.NAME.node));
this.addRequirements(ReqHasFaction.get()); this.addRequirements(ReqHasFaction.get());
this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER)); this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER));
@ -48,15 +45,14 @@ public class CmdFactionsName extends FCommand
// TODO does not first test cover selfcase? // TODO does not first test cover selfcase?
FactionColl factionColl = FactionColls.get().get(usenderFaction); if (FactionColl.get().isNameTaken(newName) && ! MiscUtil.getComparisonString(newName).equals(usenderFaction.getComparisonName()))
if (factionColl.isNameTaken(newName) && ! MiscUtil.getComparisonString(newName).equals(usenderFaction.getComparisonName()))
{ {
msg("<b>That name is already taken"); msg("<b>That name is already taken");
return; return;
} }
ArrayList<String> errors = new ArrayList<String>(); ArrayList<String> errors = new ArrayList<String>();
errors.addAll(factionColl.validateName(newName)); errors.addAll(FactionColl.get().validateName(newName));
if (errors.size() > 0) if (errors.size() > 0)
{ {
sendMessage(errors); sendMessage(errors);
@ -76,8 +72,8 @@ public class CmdFactionsName extends FCommand
// Inform // Inform
usenderFaction.msg("%s<i> changed your faction name to %s", usender.describeTo(usenderFaction, true), usenderFaction.getName(usenderFaction)); usenderFaction.msg("%s<i> changed your faction name to %s", usender.describeTo(usenderFaction, true), usenderFaction.getName(usenderFaction));
if (!UConf.get(usender).broadcastNameChange) return; if (!MConf.get().broadcastNameChange) return;
for (Faction faction : FactionColls.get().get(usenderFaction).getAll()) for (Faction faction : FactionColl.get().getAll())
{ {
if (faction == usenderFaction) if (faction == usenderFaction)
{ {

View File

@ -3,8 +3,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel; import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.arg.ARUPlayer; import com.massivecraft.factions.cmd.arg.ARUPlayer;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
@ -23,7 +22,6 @@ public class CmdFactionsOfficer extends FCommand
this.addRequiredArg("player"); this.addRequiredArg("player");
// Requirements // Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.OFFICER.node)); this.addRequirements(ReqHasPerm.get(Perm.OFFICER.node));
} }
@ -34,7 +32,7 @@ public class CmdFactionsOfficer extends FCommand
@Override @Override
public void perform() public void perform()
{ {
UPlayer you = this.arg(0, ARUPlayer.getAny(sender)); MPlayer you = this.arg(0, ARUPlayer.getAny());
if (you == null) return; if (you == null) return;
boolean permAny = Perm.OFFICER_ANY.has(sender, false); boolean permAny = Perm.OFFICER_ANY.has(sender, false);

View File

@ -2,7 +2,6 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel; import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.cmd.req.ReqHasFaction; import com.massivecraft.factions.cmd.req.ReqHasFaction;
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast; import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
import com.massivecraft.factions.event.EventFactionsOpenChange; import com.massivecraft.factions.event.EventFactionsOpenChange;
@ -24,7 +23,6 @@ public class CmdFactionsOpen extends FCommand
this.addOptionalArg("yes/no", "toggle"); this.addOptionalArg("yes/no", "toggle");
// Requirements // Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.OPEN.node)); this.addRequirements(ReqHasPerm.get(Perm.OPEN.node));
this.addRequirements(ReqHasFaction.get()); this.addRequirements(ReqHasFaction.get());
this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER)); this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER));

View File

@ -6,7 +6,6 @@ import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.arg.ARFPerm; import com.massivecraft.factions.cmd.arg.ARFPerm;
import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.arg.ARRel; import com.massivecraft.factions.cmd.arg.ARRel;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.massivecore.cmd.arg.ARBoolean; import com.massivecraft.massivecore.cmd.arg.ARBoolean;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
@ -31,7 +30,6 @@ public class CmdFactionsPerm extends FCommand
this.setErrorOnToManyArgs(false); this.setErrorOnToManyArgs(false);
// Requirements // Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.PERM.node)); this.addRequirements(ReqHasPerm.get(Perm.PERM.node));
} }
@ -42,7 +40,7 @@ public class CmdFactionsPerm extends FCommand
@Override @Override
public void perform() public void perform()
{ {
Faction faction = this.arg(0, ARFaction.get(usenderFaction), usenderFaction); Faction faction = this.arg(0, ARFaction.get(), usenderFaction);
if (faction == null) return; if (faction == null) return;
if ( ! this.argIsSet(1)) if ( ! this.argIsSet(1))
@ -88,7 +86,7 @@ public class CmdFactionsPerm extends FCommand
faction.setRelationPermitted(perm, rel, val); faction.setRelationPermitted(perm, rel, val);
// The following is to make sure the leader always has the right to change perms if that is our goal. // The following is to make sure the leader always has the right to change perms if that is our goal.
if (perm == FPerm.PERMS && FPerm.PERMS.getDefault(faction).contains(Rel.LEADER)) if (perm == FPerm.PERMS && FPerm.PERMS.getDefault().contains(Rel.LEADER))
{ {
faction.setRelationPermitted(FPerm.PERMS, Rel.LEADER, true); faction.setRelationPermitted(FPerm.PERMS, Rel.LEADER, true);
} }

View File

@ -4,8 +4,7 @@ import java.util.LinkedHashMap;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARUPlayer; import com.massivecraft.factions.cmd.arg.ARUPlayer;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.massivecore.Progressbar; import com.massivecraft.massivecore.Progressbar;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.util.TimeDiffUtil; import com.massivecraft.massivecore.util.TimeDiffUtil;
@ -27,7 +26,6 @@ public class CmdFactionsPlayer extends FCommand
this.addOptionalArg("player", "you"); this.addOptionalArg("player", "you");
// Requirements // Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.PLAYER.node)); this.addRequirements(ReqHasPerm.get(Perm.PLAYER.node));
} }
@ -39,7 +37,7 @@ public class CmdFactionsPlayer extends FCommand
public void perform() public void perform()
{ {
// Args // Args
UPlayer uplayer = this.arg(0, ARUPlayer.getAny(sender), usender); MPlayer uplayer = this.arg(0, ARUPlayer.getAny(), usender);
if (uplayer == null) return; if (uplayer == null) return;
// INFO: Title // INFO: Title

View File

@ -4,8 +4,7 @@ import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARUPlayer; import com.massivecraft.factions.cmd.arg.ARUPlayer;
import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.massivecore.cmd.arg.ARDouble; import com.massivecraft.massivecore.cmd.arg.ARDouble;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
@ -27,7 +26,6 @@ public class CmdFactionsPowerBoost extends FCommand
this.addRequiredArg("#"); this.addRequiredArg("#");
// Requirements // Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.POWERBOOST.node)); this.addRequirements(ReqHasPerm.get(Perm.POWERBOOST.node));
} }
@ -58,7 +56,7 @@ public class CmdFactionsPowerBoost extends FCommand
if (doPlayer) if (doPlayer)
{ {
UPlayer targetPlayer = this.arg(1, ARUPlayer.getAny(sender)); MPlayer targetPlayer = this.arg(1, ARUPlayer.getAny());
if (targetPlayer == null) return; if (targetPlayer == null) return;
targetPlayer.setPowerBoost(targetPower); targetPlayer.setPowerBoost(targetPower);
@ -66,7 +64,7 @@ public class CmdFactionsPowerBoost extends FCommand
} }
else else
{ {
Faction targetFaction = this.arg(1, ARFaction.get(sender)); Faction targetFaction = this.arg(1, ARFaction.get());
if (targetFaction == null) return; if (targetFaction == null) return;
targetFaction.setPowerBoost(targetPower); targetFaction.setPowerBoost(targetPower);

View File

@ -3,8 +3,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel; import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.arg.ARUPlayer; import com.massivecraft.factions.cmd.arg.ARUPlayer;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
public class CmdFactionsPromote extends FCommand public class CmdFactionsPromote extends FCommand
@ -22,7 +21,6 @@ public class CmdFactionsPromote extends FCommand
this.addRequiredArg("player"); this.addRequiredArg("player");
// Requirements // Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.PROMOTE.node)); this.addRequirements(ReqHasPerm.get(Perm.PROMOTE.node));
//To promote someone from recruit -> member you must be an officer. //To promote someone from recruit -> member you must be an officer.
@ -37,7 +35,7 @@ public class CmdFactionsPromote extends FCommand
@Override @Override
public void perform() public void perform()
{ {
UPlayer you = this.arg(0, ARUPlayer.getAny(sender)); MPlayer you = this.arg(0, ARUPlayer.getAny());
if (you == null) return; if (you == null) return;
if (you.getFaction() != usenderFaction) if (you.getFaction() != usenderFaction)

View File

@ -4,7 +4,6 @@ import com.massivecraft.factions.FFlag;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel; import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.cmd.req.ReqHasFaction; import com.massivecraft.factions.cmd.req.ReqHasFaction;
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast; import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
@ -26,7 +25,6 @@ public abstract class CmdFactionsRelationAbstract extends FCommand
this.addRequiredArg("faction"); this.addRequiredArg("faction");
// Requirements // Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.RELATION.node)); this.addRequirements(ReqHasPerm.get(Perm.RELATION.node));
this.addRequirements(ReqHasFaction.get()); this.addRequirements(ReqHasFaction.get());
this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER)); this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER));
@ -40,7 +38,7 @@ public abstract class CmdFactionsRelationAbstract extends FCommand
public void perform() public void perform()
{ {
// Args // Args
Faction otherFaction = this.arg(0, ARFaction.get(sender)); Faction otherFaction = this.arg(0, ARFaction.get());
if (otherFaction == null) return; if (otherFaction == null) return;
Rel newRelation = targetRelation; Rel newRelation = targetRelation;

View File

@ -4,9 +4,8 @@ import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.Factions; import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.UConf; import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.event.EventFactionsHomeChange; import com.massivecraft.factions.event.EventFactionsHomeChange;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
@ -27,7 +26,6 @@ public class CmdFactionsSethome extends FCommand
this.addOptionalArg("faction", "you"); this.addOptionalArg("faction", "you");
// Requirements // Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqIsPlayer.get()); this.addRequirements(ReqIsPlayer.get());
this.addRequirements(ReqHasPerm.get(Perm.SETHOME.node)); this.addRequirements(ReqHasPerm.get(Perm.SETHOME.node));
} }
@ -40,13 +38,13 @@ public class CmdFactionsSethome extends FCommand
public void perform() public void perform()
{ {
// Args // Args
Faction faction = this.arg(0, ARFaction.get(usenderFaction), usenderFaction); Faction faction = this.arg(0, ARFaction.get(), usenderFaction);
if (faction == null) return; if (faction == null) return;
PS newHome = PS.valueOf(me.getLocation()); PS newHome = PS.valueOf(me.getLocation());
// Validate // Validate
if ( ! UConf.get(faction).homesEnabled) if ( ! MConf.get().homesEnabled)
{ {
usender.msg("<b>Sorry, Faction homes are disabled on this server."); usender.msg("<b>Sorry, Faction homes are disabled on this server.");
return; return;

View File

@ -5,9 +5,8 @@ import org.bukkit.ChatColor;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel; import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.arg.ARUPlayer; import com.massivecraft.factions.cmd.arg.ARUPlayer;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast; import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.event.EventFactionsTitleChange; import com.massivecraft.factions.event.EventFactionsTitleChange;
import com.massivecraft.massivecore.cmd.arg.ARString; import com.massivecraft.massivecore.cmd.arg.ARString;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
@ -29,7 +28,6 @@ public class CmdFactionsTitle extends FCommand
this.addOptionalArg("title", ""); this.addOptionalArg("title", "");
// Requirements // Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.TITLE.node)); this.addRequirements(ReqHasPerm.get(Perm.TITLE.node));
this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER)); this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER));
} }
@ -42,7 +40,7 @@ public class CmdFactionsTitle extends FCommand
public void perform() public void perform()
{ {
// Args // Args
UPlayer you = this.arg(0, ARUPlayer.getAny(sender)); MPlayer you = this.arg(0, ARUPlayer.getAny());
if (you == null) return; if (you == null) return;
String newTitle = this.argConcatFrom(1, ARString.get(), ""); String newTitle = this.argConcatFrom(1, ARString.get(), "");

View File

@ -1,9 +1,8 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.cmd.req.ReqHasFaction; import com.massivecraft.factions.cmd.req.ReqHasFaction;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColls; import com.massivecraft.factions.entity.FactionColl;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
@ -21,7 +20,6 @@ public class CmdFactionsUnclaim extends FCommand
this.addAliases("unclaim"); this.addAliases("unclaim");
// Requirements // Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.UNCLAIM.node)); this.addRequirements(ReqHasPerm.get(Perm.UNCLAIM.node));
this.addRequirements(ReqHasFaction.get()); this.addRequirements(ReqHasFaction.get());
this.addRequirements(ReqIsPlayer.get()); this.addRequirements(ReqIsPlayer.get());
@ -36,7 +34,7 @@ public class CmdFactionsUnclaim extends FCommand
{ {
// Args // Args
PS chunk = PS.valueOf(me).getChunk(true); PS chunk = PS.valueOf(me).getChunk(true);
Faction newFaction = FactionColls.get().get(me).getNone(); Faction newFaction = FactionColl.get().getNone();
// Apply // Apply
if (usender.tryClaim(newFaction, chunk, true, true)) return; if (usender.tryClaim(newFaction, chunk, true, true)) return;

View File

@ -6,13 +6,11 @@ import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.Factions; import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel; import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.cmd.req.ReqHasFaction; import com.massivecraft.factions.cmd.req.ReqHasFaction;
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast; import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
import com.massivecraft.factions.entity.BoardColl; import com.massivecraft.factions.entity.BoardColl;
import com.massivecraft.factions.entity.BoardColls;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColls; import com.massivecraft.factions.entity.FactionColl;
import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.event.EventFactionsChunkChange; import com.massivecraft.factions.event.EventFactionsChunkChange;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
@ -30,7 +28,6 @@ public class CmdFactionsUnclaimall extends FCommand
this.addAliases("unclaimall"); this.addAliases("unclaimall");
// Requirements // Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.UNCLAIM_ALL.node)); this.addRequirements(ReqHasPerm.get(Perm.UNCLAIM_ALL.node));
this.addRequirements(ReqHasFaction.get()); this.addRequirements(ReqHasFaction.get());
this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER)); this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER));
@ -45,14 +42,13 @@ public class CmdFactionsUnclaimall extends FCommand
{ {
// Args // Args
Faction faction = usenderFaction; Faction faction = usenderFaction;
Faction newFaction = FactionColls.get().get(faction).getNone(); Faction newFaction = FactionColl.get().getNone();
// FPerm // FPerm
if (!FPerm.TERRITORY.has(usender, faction, true)) return; if (!FPerm.TERRITORY.has(usender, faction, true)) return;
// Apply // Apply
BoardColl boardColl = BoardColls.get().get(faction); Set<PS> chunks = BoardColl.get().getChunks(faction);
Set<PS> chunks = boardColl.getChunks(faction);
int countTotal = chunks.size(); int countTotal = chunks.size();
int countSuccess = 0; int countSuccess = 0;
int countFail = 0; int countFail = 0;
@ -67,7 +63,7 @@ public class CmdFactionsUnclaimall extends FCommand
else else
{ {
countSuccess++; countSuccess++;
boardColl.setFactionAt(chunk, newFaction); BoardColl.get().setFactionAt(chunk, newFaction);
} }
} }

View File

@ -2,8 +2,6 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Rel; import com.massivecraft.factions.Rel;
import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.UConf;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.massivecore.cmd.MassiveCommand; import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.util.Txt; import com.massivecraft.massivecore.util.Txt;
@ -15,7 +13,7 @@ public abstract class FCommand extends MassiveCommand
// -------------------------------------------- // // -------------------------------------------- //
public MPlayer msender; public MPlayer msender;
public UPlayer usender; public MPlayer usender;
public Faction usenderFaction; public Faction usenderFaction;
// -------------------------------------------- // // -------------------------------------------- //
@ -30,10 +28,7 @@ public abstract class FCommand extends MassiveCommand
this.usender = null; this.usender = null;
this.usenderFaction = null; this.usenderFaction = null;
// Check disabled this.usender = MPlayer.get(this.sender);
if (UConf.isDisabled(sender)) return;
this.usender = UPlayer.get(this.sender);
this.usenderFaction = this.usender.getFaction(); this.usenderFaction = this.usender.getFaction();
} }
@ -50,7 +45,7 @@ public abstract class FCommand extends MassiveCommand
// COMMONLY USED LOGIC // COMMONLY USED LOGIC
// -------------------------------------------- // // -------------------------------------------- //
public boolean canIAdministerYou(UPlayer i, UPlayer you) public boolean canIAdministerYou(MPlayer i, MPlayer you)
{ {
if ( ! i.getFaction().equals(you.getFaction())) if ( ! i.getFaction().equals(you.getFaction()))
{ {

View File

@ -2,11 +2,9 @@ package com.massivecraft.factions.cmd.arg;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.UPlayerColls;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColl; import com.massivecraft.factions.entity.FactionColl;
import com.massivecraft.factions.entity.FactionColls;
import com.massivecraft.massivecore.cmd.arg.ArgReaderAbstract; import com.massivecraft.massivecore.cmd.arg.ArgReaderAbstract;
import com.massivecraft.massivecore.cmd.arg.ArgResult; import com.massivecraft.massivecore.cmd.arg.ArgResult;
import com.massivecraft.massivecore.util.IdUtil; import com.massivecraft.massivecore.util.IdUtil;
@ -18,18 +16,8 @@ public class ARFaction extends ArgReaderAbstract<Faction>
// INSTANCE & CONSTRUCT // INSTANCE & CONSTRUCT
// -------------------------------------------- // // -------------------------------------------- //
public static ARFaction get(Object universe) { return new ARFaction(FactionColls.get().get(universe)); } private static ARFaction i = new ARFaction();
private ARFaction(FactionColl coll) public static ARFaction get() { return i; }
{
this.coll = coll;
}
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
private final FactionColl coll;
public FactionColl getColl() { return this.coll;}
// -------------------------------------------- // // -------------------------------------------- //
// OVERRIDE // OVERRIDE
@ -41,16 +29,16 @@ public class ARFaction extends ArgReaderAbstract<Faction>
ArgResult<Faction> result = new ArgResult<Faction>(); ArgResult<Faction> result = new ArgResult<Faction>();
// Faction Name Exact // Faction Name Exact
result.setResult(this.getColl().getByName(str)); result.setResult(FactionColl.get().getByName(str));
if (result.hasResult()) return result; if (result.hasResult()) return result;
// Faction Name Match // Faction Name Match
result.setResult(this.getColl().getBestNameMatch(str)); result.setResult(FactionColl.get().getBestNameMatch(str));
if (result.hasResult()) return result; if (result.hasResult()) return result;
// UPlayer Name Exact // UPlayer Name Exact
String id = IdUtil.getId(str); String id = IdUtil.getId(str);
UPlayer uplayer = UPlayerColls.get().get(this.getColl()).get(id); MPlayer uplayer = MPlayer.get(id);
if (uplayer != null) if (uplayer != null)
{ {
result.setResult(uplayer.getFaction()); result.setResult(uplayer.getFaction());

View File

@ -1,7 +1,7 @@
package com.massivecraft.factions.cmd.arg; package com.massivecraft.factions.cmd.arg;
import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.UPlayerColls; import com.massivecraft.factions.entity.MPlayerColl;
import com.massivecraft.massivecore.cmd.arg.ArgReader; import com.massivecraft.massivecore.cmd.arg.ArgReader;
public class ARUPlayer public class ARUPlayer
@ -10,8 +10,14 @@ public class ARUPlayer
// INSTANCE // INSTANCE
// -------------------------------------------- // // -------------------------------------------- //
public static ArgReader<UPlayer> getAny(Object o) { return UPlayerColls.get().get(o).getAREntity(); } public static ArgReader<MPlayer> getAny()
{
return MPlayerColl.get().getAREntity();
}
public static ArgReader<UPlayer> getOnline(Object o) { return UPlayerColls.get().get(o).getAREntity(true); } public static ArgReader<MPlayer> getOnline()
{
return MPlayerColl.get().getAREntity(true);
}
} }

View File

@ -2,7 +2,7 @@ package com.massivecraft.factions.cmd.req;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.massivecraft.factions.entity.UConf; import com.massivecraft.factions.entity.MConf;
import com.massivecraft.massivecore.cmd.MassiveCommand; import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.req.ReqAbstract; import com.massivecraft.massivecore.cmd.req.ReqAbstract;
import com.massivecraft.massivecore.util.Txt; import com.massivecraft.massivecore.util.Txt;
@ -25,18 +25,17 @@ public class ReqBankCommandsEnabled extends ReqAbstract
@Override @Override
public boolean apply(CommandSender sender, MassiveCommand command) public boolean apply(CommandSender sender, MassiveCommand command)
{ {
return UConf.get(sender).econEnabled && UConf.get(sender).bankEnabled; return MConf.get().econEnabled && MConf.get().bankEnabled;
} }
@Override @Override
public String createErrorMessage(CommandSender sender, MassiveCommand command) public String createErrorMessage(CommandSender sender, MassiveCommand command)
{ {
UConf uconf = UConf.get(sender); if (!MConf.get().bankEnabled)
if (!uconf.bankEnabled)
{ {
return Txt.parse("<b>Faction banks are disabled in the <h>%s <b>universe.", uconf.getUniverse()); return Txt.parse("<b>Faction banks are disabled.");
} }
return Txt.parse("<b>Faction economy features are disabled in the <h>%s <b>universe.", uconf.getUniverse()); return Txt.parse("<b>Faction economy features are disabled.");
} }
} }

View File

@ -1,36 +0,0 @@
package com.massivecraft.factions.cmd.req;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.entity.UConf;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.req.ReqAbstract;
public class ReqFactionsEnabled extends ReqAbstract
{
private static final long serialVersionUID = 1L;
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static ReqFactionsEnabled i = new ReqFactionsEnabled();
public static ReqFactionsEnabled get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public boolean apply(CommandSender sender, MassiveCommand command)
{
return !UConf.isDisabled(sender);
}
@Override
public String createErrorMessage(CommandSender sender, MassiveCommand command)
{
return UConf.getDisabledMessage(sender);
}
}

View File

@ -2,7 +2,7 @@ package com.massivecraft.factions.cmd.req;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.massivecore.cmd.MassiveCommand; import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.req.ReqAbstract; import com.massivecraft.massivecore.cmd.req.ReqAbstract;
import com.massivecraft.massivecore.util.Txt; import com.massivecraft.massivecore.util.Txt;
@ -25,7 +25,7 @@ public class ReqHasFaction extends ReqAbstract
@Override @Override
public boolean apply(CommandSender sender, MassiveCommand command) public boolean apply(CommandSender sender, MassiveCommand command)
{ {
return UPlayer.get(sender).hasFaction(); return MPlayer.get(sender).hasFaction();
} }
@Override @Override

View File

@ -2,7 +2,7 @@ package com.massivecraft.factions.cmd.req;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.massivecore.cmd.MassiveCommand; import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.req.ReqAbstract; import com.massivecraft.massivecore.cmd.req.ReqAbstract;
import com.massivecraft.massivecore.util.Txt; import com.massivecraft.massivecore.util.Txt;
@ -25,7 +25,7 @@ public class ReqHasntFaction extends ReqAbstract
@Override @Override
public boolean apply(CommandSender sender, MassiveCommand command) public boolean apply(CommandSender sender, MassiveCommand command)
{ {
return !UPlayer.get(sender).hasFaction(); return !MPlayer.get(sender).hasFaction();
} }
@Override @Override

View File

@ -3,7 +3,7 @@ package com.massivecraft.factions.cmd.req;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.massivecraft.factions.Rel; import com.massivecraft.factions.Rel;
import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.massivecore.cmd.MassiveCommand; import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.req.ReqAbstract; import com.massivecraft.massivecore.cmd.req.ReqAbstract;
import com.massivecraft.massivecore.util.Txt; import com.massivecraft.massivecore.util.Txt;
@ -33,7 +33,7 @@ public class ReqRoleIsAtLeast extends ReqAbstract
@Override @Override
public boolean apply(CommandSender sender, MassiveCommand command) public boolean apply(CommandSender sender, MassiveCommand command)
{ {
UPlayer uplayer = UPlayer.get(sender); MPlayer uplayer = MPlayer.get(sender);
return uplayer.getRole().isAtLeast(this.rel); return uplayer.getRole().isAtLeast(this.rel);
} }

View File

@ -32,7 +32,7 @@ public class Board extends Entity<Board> implements BoardInterface
public static Board get(Object oid) public static Board get(Object oid)
{ {
return BoardColls.get().get2(oid); return BoardColl.get().get(oid);
} }
// -------------------------------------------- // // -------------------------------------------- //
@ -90,7 +90,7 @@ public class Board extends Entity<Board> implements BoardInterface
if (ps == null) return null; if (ps == null) return null;
ps = ps.getChunkCoords(true); ps = ps.getChunkCoords(true);
TerritoryAccess ret = this.map.get(ps); TerritoryAccess ret = this.map.get(ps);
if (ret == null) ret = TerritoryAccess.valueOf(UConf.get(this).factionIdNone); if (ret == null) ret = TerritoryAccess.valueOf(MConf.get().factionIdNone);
return ret; return ret;
} }
@ -109,7 +109,7 @@ public class Board extends Entity<Board> implements BoardInterface
{ {
ps = ps.getChunkCoords(true); ps = ps.getChunkCoords(true);
if (territoryAccess == null || (territoryAccess.getHostFactionId().equals(UConf.get(this).factionIdNone) && territoryAccess.isDefault())) if (territoryAccess == null || (territoryAccess.getHostFactionId().equals(MConf.get().factionIdNone) && territoryAccess.isDefault()))
{ {
this.map.remove(ps); this.map.remove(ps);
} }
@ -159,13 +159,12 @@ public class Board extends Entity<Board> implements BoardInterface
@Override @Override
public void clean() public void clean()
{ {
FactionColl factionColl = FactionColls.get().get(this);
for (Entry<PS, TerritoryAccess> entry : this.map.entrySet()) for (Entry<PS, TerritoryAccess> entry : this.map.entrySet())
{ {
TerritoryAccess territoryAccess = entry.getValue(); TerritoryAccess territoryAccess = entry.getValue();
String factionId = territoryAccess.getHostFactionId(); String factionId = territoryAccess.getHostFactionId();
if (factionColl.containsId(factionId)) continue;
if (FactionColl.get().containsId(factionId)) continue;
PS ps = entry.getKey(); PS ps = entry.getKey();
this.removeAt(ps); this.removeAt(ps);

View File

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import com.massivecraft.factions.Const;
import com.massivecraft.factions.Factions; import com.massivecraft.factions.Factions;
import com.massivecraft.factions.RelationParticipator; import com.massivecraft.factions.RelationParticipator;
import com.massivecraft.factions.TerritoryAccess; import com.massivecraft.factions.TerritoryAccess;
@ -15,12 +16,14 @@ import com.massivecraft.massivecore.util.MUtil;
public class BoardColl extends Coll<Board> implements BoardInterface public class BoardColl extends Coll<Board> implements BoardInterface
{ {
// -------------------------------------------- // // -------------------------------------------- //
// CONSTRUCT // INSTANCE & CONSTRUCT
// -------------------------------------------- // // -------------------------------------------- //
public BoardColl(String name) private static BoardColl i = new BoardColl();
public static BoardColl get() { return i; }
private BoardColl()
{ {
super(name, Board.class, MStore.getDb(), Factions.get(), false, true, true); super(Const.COLLECTION_BOARD, Board.class, MStore.getDb(), Factions.get(), false, true, true);
} }
// -------------------------------------------- // // -------------------------------------------- //
@ -165,4 +168,51 @@ public class BoardColl extends Coll<Board> implements BoardInterface
return board.getMap(observer, centerPs, inDegrees); return board.getMap(observer, centerPs, inDegrees);
} }
/*
@Override
public void init()
{
super.init();
this.migrate();
}
// This method is for the 1.8.X --> 2.0.0 migration
public void migrate()
{
// Create file objects
File oldFile = new File(Factions.get().getDataFolder(), "board.json");
File newFile = new File(Factions.get().getDataFolder(), "board.json.migrated");
// Already migrated?
if ( ! oldFile.exists()) return;
// Read the file content through GSON.
Type type = new TypeToken<Map<String,Map<String,TerritoryAccess>>>(){}.getType();
Map<String,Map<String,TerritoryAccess>> worldCoordIds = Factions.get().gson.fromJson(DiscUtil.readCatch(oldFile), type);
// Set the data
for (Entry<String,Map<String,TerritoryAccess>> entry : worldCoordIds.entrySet())
{
String worldName = entry.getKey();
BoardColl boardColl = this.getForWorld(worldName);
Board board = boardColl.get(worldName);
for (Entry<String,TerritoryAccess> entry2 : entry.getValue().entrySet())
{
String[] ChunkCoordParts = entry2.getKey().trim().split("[,\\s]+");
int chunkX = Integer.parseInt(ChunkCoordParts[0]);
int chunkZ = Integer.parseInt(ChunkCoordParts[1]);
PS ps = new PSBuilder().chunkX(chunkX).chunkZ(chunkZ).build();
TerritoryAccess territoryAccess = entry2.getValue();
board.setTerritoryAccessAt(ps, territoryAccess);
}
}
// Mark as migrated
oldFile.renameTo(newFile);
}
*/
} }

View File

@ -1,215 +0,0 @@
package com.massivecraft.factions.entity;
import java.io.File;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
import com.massivecraft.factions.Const;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.RelationParticipator;
import com.massivecraft.factions.TerritoryAccess;
import com.massivecraft.massivecore.Aspect;
import com.massivecraft.massivecore.ps.PS;
import com.massivecraft.massivecore.ps.PSBuilder;
import com.massivecraft.massivecore.util.DiscUtil;
import com.massivecraft.massivecore.xlib.gson.reflect.TypeToken;
public class BoardColls extends XColls<BoardColl, Board> implements BoardInterface
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static BoardColls i = new BoardColls();
public static BoardColls get() { return i; }
// -------------------------------------------- //
// OVERRIDE: COLLS
// -------------------------------------------- //
@Override
public BoardColl createColl(String collName)
{
return new BoardColl(collName);
}
@Override
public Aspect getAspect()
{
return Factions.get().getAspect();
}
@Override
public String getBasename()
{
return Const.COLLECTION_BOARD;
}
@Override
public void init()
{
super.init();
this.migrate();
}
// This method is for the 1.8.X --> 2.0.0 migration
public void migrate()
{
// Create file objects
File oldFile = new File(Factions.get().getDataFolder(), "board.json");
File newFile = new File(Factions.get().getDataFolder(), "board.json.migrated");
// Already migrated?
if ( ! oldFile.exists()) return;
// Read the file content through GSON.
Type type = new TypeToken<Map<String,Map<String,TerritoryAccess>>>(){}.getType();
Map<String,Map<String,TerritoryAccess>> worldCoordIds = Factions.get().gson.fromJson(DiscUtil.readCatch(oldFile), type);
// Set the data
for (Entry<String,Map<String,TerritoryAccess>> entry : worldCoordIds.entrySet())
{
String worldName = entry.getKey();
BoardColl boardColl = this.getForWorld(worldName);
Board board = boardColl.get(worldName);
for (Entry<String,TerritoryAccess> entry2 : entry.getValue().entrySet())
{
String[] ChunkCoordParts = entry2.getKey().trim().split("[,\\s]+");
int chunkX = Integer.parseInt(ChunkCoordParts[0]);
int chunkZ = Integer.parseInt(ChunkCoordParts[1]);
PS ps = new PSBuilder().chunkX(chunkX).chunkZ(chunkZ).build();
TerritoryAccess territoryAccess = entry2.getValue();
board.setTerritoryAccessAt(ps, territoryAccess);
}
}
// Mark as migrated
oldFile.renameTo(newFile);
}
// -------------------------------------------- //
// OVERRIDE: BOARD
// -------------------------------------------- //
@Override
public TerritoryAccess getTerritoryAccessAt(PS ps)
{
BoardColl coll = this.getForWorld(ps.getWorld());
if (coll == null) return null;
return coll.getTerritoryAccessAt(ps);
}
@Override
public Faction getFactionAt(PS ps)
{
BoardColl coll = this.getForWorld(ps.getWorld());
if (coll == null) return null;
return coll.getFactionAt(ps);
}
// SET
@Override
public void setTerritoryAccessAt(PS ps, TerritoryAccess territoryAccess)
{
BoardColl coll = this.getForWorld(ps.getWorld());
if (coll == null) return;
coll.setTerritoryAccessAt(ps, territoryAccess);
}
@Override
public void setFactionAt(PS ps, Faction faction)
{
BoardColl coll = this.getForWorld(ps.getWorld());
if (coll == null) return;
coll.setFactionAt(ps, faction);
}
// REMOVE
@Override
public void removeAt(PS ps)
{
BoardColl coll = this.getForWorld(ps.getWorld());
if (coll == null) return;
coll.removeAt(ps);
}
@Override
public void removeAll(Faction faction)
{
for (BoardColl coll : this.getColls())
{
coll.removeAll(faction);
}
}
@Override
public void clean()
{
for (BoardColl coll : this.getColls())
{
coll.clean();
}
}
// CHUNKS
@Override
public Set<PS> getChunks(Faction faction)
{
Set<PS> ret = new HashSet<PS>();
for (BoardColl coll : this.getColls())
{
ret.addAll(coll.getChunks(faction));
}
return ret;
}
// COUNT
@Override
public int getCount(Faction faction)
{
int ret = 0;
for (BoardColl coll : this.getColls())
{
ret += coll.getCount(faction);
}
return ret;
}
// NEARBY DETECTION
@Override
public boolean isBorderPs(PS ps)
{
BoardColl coll = this.getForWorld(ps.getWorld());
if (coll == null) return false;
return coll.isBorderPs(ps);
}
@Override
public boolean isConnectedPs(PS ps, Faction faction)
{
BoardColl coll = this.getForWorld(ps.getWorld());
if (coll == null) return false;
return coll.isConnectedPs(ps, faction);
}
// MAP GENERATION
@Override
public ArrayList<String> getMap(RelationParticipator observer, PS centerPs, double inDegrees)
{
BoardColl coll = this.getForWorld(centerPs.getWorld());
if (coll == null) return null;
return coll.getMap(observer, centerPs, inDegrees);
}
}

View File

@ -33,7 +33,7 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
public static Faction get(Object oid) public static Faction get(Object oid)
{ {
return FactionColls.get().get2(oid); return FactionColl.get().get(oid);
} }
// -------------------------------------------- // // -------------------------------------------- //
@ -62,13 +62,11 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
{ {
Money.set(this, null, 0); Money.set(this, null, 0);
String universe = this.getUniverse();
// Clean the board // Clean the board
BoardColls.get().getForUniverse(universe).clean(); BoardColl.get().clean();
// Clean the uplayers // Clean the mplayers
UPlayerColls.get().getForUniverse(universe).clean(); MPlayerColl.get().clean();
} }
// -------------------------------------------- // // -------------------------------------------- //
@ -132,7 +130,7 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
public boolean isNone() public boolean isNone()
{ {
return this.getId().equals(UConf.get(this).factionIdNone); return this.getId().equals(MConf.get().factionIdNone);
} }
public boolean isNormal() public boolean isNormal()
@ -150,8 +148,7 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
{ {
String ret = this.name; String ret = this.name;
UConf uconf = UConf.get(this); if (MConf.get().factionNameForceUpperCase)
if (uconf != null && UConf.get(this).factionNameForceUpperCase)
{ {
ret = ret.toUpperCase(); ret = ret.toUpperCase();
} }
@ -277,8 +274,8 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
public boolean isValidHome(PS ps) public boolean isValidHome(PS ps)
{ {
if (ps == null) return true; if (ps == null) return true;
if (!UConf.get(this).homesMustBeInClaimedTerritory) return true; if (!MConf.get().homesMustBeInClaimedTerritory) return true;
if (BoardColls.get().getFactionAt(ps) == this) return true; if (BoardColl.get().getFactionAt(ps) == this) return true;
return false; return false;
} }
@ -338,9 +335,7 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
public boolean isDefaultOpen() public boolean isDefaultOpen()
{ {
UConf uconf = UConf.get(this); return MConf.get().defaultFactionOpen;
if (uconf == null) return false;
return uconf.defaultFactionOpen;
} }
public boolean isOpen() public boolean isOpen()
@ -412,7 +407,7 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
return this.getInvitedPlayerIds().contains(playerId); return this.getInvitedPlayerIds().contains(playerId);
} }
public boolean isInvited(UPlayer uplayer) public boolean isInvited(MPlayer uplayer)
{ {
return this.isInvited(uplayer.getId()); return this.isInvited(uplayer.getId());
} }
@ -434,7 +429,7 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
} }
public void setInvited(UPlayer uplayer, boolean invited) public void setInvited(MPlayer uplayer, boolean invited)
{ {
this.setInvited(uplayer.getId(), invited); this.setInvited(uplayer.getId(), invited);
} }
@ -523,7 +518,7 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
{ {
ret.put(rel, new ArrayList<String>()); ret.put(rel, new ArrayList<String>());
} }
for (Faction faction : FactionColls.get().get(this).getAll()) for (Faction faction : FactionColl.get().getAll())
{ {
Rel relation = faction.getRelationTo(this); Rel relation = faction.getRelationTo(this);
if (onlyNonNeutral && relation == Rel.NEUTRAL) continue; if (onlyNonNeutral && relation == Rel.NEUTRAL) continue;
@ -544,7 +539,7 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
for (FFlag fflag : FFlag.values()) for (FFlag fflag : FFlag.values())
{ {
ret.put(fflag, fflag.getDefault(this)); ret.put(fflag, fflag.getDefault());
} }
if (this.flags != null) if (this.flags != null)
@ -576,7 +571,7 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
while (iter.hasNext()) while (iter.hasNext())
{ {
Entry<FFlag, Boolean> entry = iter.next(); Entry<FFlag, Boolean> entry = iter.next();
if (entry.getKey().getDefault(this) == entry.getValue()) if (entry.getKey().getDefault() == entry.getValue())
{ {
iter.remove(); iter.remove();
} }
@ -621,7 +616,7 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
for (FPerm fperm : FPerm.values()) for (FPerm fperm : FPerm.values())
{ {
ret.put(fperm, fperm.getDefault(this)); ret.put(fperm, fperm.getDefault());
} }
if (this.perms != null) if (this.perms != null)
@ -667,7 +662,7 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
continue; continue;
} }
Set<Rel> keyDefault = key.getDefault(this); Set<Rel> keyDefault = key.getDefault();
Set<Rel> value = entry.getValue(); Set<Rel> value = entry.getValue();
if (keyDefault.equals(value)) if (keyDefault.equals(value))
@ -779,12 +774,12 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
if (this.getFlag(FFlag.INFPOWER)) return 999999; if (this.getFlag(FFlag.INFPOWER)) return 999999;
double ret = 0; double ret = 0;
for (UPlayer uplayer : this.getUPlayers()) for (MPlayer uplayer : this.getUPlayers())
{ {
ret += uplayer.getPower(); ret += uplayer.getPower();
} }
double factionPowerMax = UConf.get(this).factionPowerMax; double factionPowerMax = MConf.get().factionPowerMax;
if (factionPowerMax > 0 && ret > factionPowerMax) if (factionPowerMax > 0 && ret > factionPowerMax)
{ {
ret = factionPowerMax; ret = factionPowerMax;
@ -800,12 +795,12 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
if (this.getFlag(FFlag.INFPOWER)) return 999999; if (this.getFlag(FFlag.INFPOWER)) return 999999;
double ret = 0; double ret = 0;
for (UPlayer uplayer : this.getUPlayers()) for (MPlayer uplayer : this.getUPlayers())
{ {
ret += uplayer.getPowerMax(); ret += uplayer.getPowerMax();
} }
double factionPowerMax = UConf.get(this).factionPowerMax; double factionPowerMax = MConf.get().factionPowerMax;
if (factionPowerMax > 0 && ret > factionPowerMax) if (factionPowerMax > 0 && ret > factionPowerMax)
{ {
ret = factionPowerMax; ret = factionPowerMax;
@ -828,7 +823,7 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
public int getLandCount() public int getLandCount()
{ {
return BoardColls.get().get(this).getCount(this); return BoardColl.get().getCount(this);
} }
public int getLandCountInWorld(String worldName) public int getLandCountInWorld(String worldName)
{ {
@ -844,7 +839,7 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
// FOREIGN KEY: UPLAYER // FOREIGN KEY: UPLAYER
// -------------------------------------------- // // -------------------------------------------- //
protected transient List<UPlayer> uplayers = new ArrayList<UPlayer>(); protected transient List<MPlayer> uplayers = new ArrayList<MPlayer>();
public void reindexUPlayers() public void reindexUPlayers()
{ {
this.uplayers.clear(); this.uplayers.clear();
@ -852,10 +847,10 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
String factionId = this.getId(); String factionId = this.getId();
if (factionId == null) return; if (factionId == null) return;
for (UPlayer uplayer : UPlayerColls.get().get(this).getAll()) for (MPlayer mplayer : MPlayerColl.get().getAll())
{ {
if (!MUtil.equals(factionId, uplayer.getFactionId())) continue; if (!MUtil.equals(factionId, mplayer.getFactionId())) continue;
this.uplayers.add(uplayer); this.uplayers.add(mplayer);
} }
} }
@ -863,10 +858,10 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
// TODO: Find the bug causing non-attached UPlayers to be present in the index. // TODO: Find the bug causing non-attached UPlayers to be present in the index.
private void checkUPlayerIndex() private void checkUPlayerIndex()
{ {
Iterator<UPlayer> iter = this.uplayers.iterator(); Iterator<MPlayer> iter = this.uplayers.iterator();
while (iter.hasNext()) while (iter.hasNext())
{ {
UPlayer uplayer = iter.next(); MPlayer uplayer = iter.next();
if (!uplayer.attached()) if (!uplayer.attached())
{ {
String msg = Txt.parse("<rose>WARN: <i>Faction <h>%s <i>aka <h>%s <i>had unattached uplayer in index:", this.getName(), this.getId()); String msg = Txt.parse("<rose>WARN: <i>Faction <h>%s <i>aka <h>%s <i>had unattached uplayer in index:", this.getName(), this.getId());
@ -877,19 +872,19 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
} }
} }
public List<UPlayer> getUPlayers() public List<MPlayer> getUPlayers()
{ {
this.checkUPlayerIndex(); this.checkUPlayerIndex();
return new ArrayList<UPlayer>(this.uplayers); return new ArrayList<MPlayer>(this.uplayers);
} }
public List<UPlayer> getUPlayersWhereOnline(boolean online) public List<MPlayer> getUPlayersWhereOnline(boolean online)
{ {
List<UPlayer> ret = this.getUPlayers(); List<MPlayer> ret = this.getUPlayers();
Iterator<UPlayer> iter = ret.iterator(); Iterator<MPlayer> iter = ret.iterator();
while (iter.hasNext()) while (iter.hasNext())
{ {
UPlayer uplayer = iter.next(); MPlayer uplayer = iter.next();
if (uplayer.isOnline() != online) if (uplayer.isOnline() != online)
{ {
iter.remove(); iter.remove();
@ -898,13 +893,13 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
return ret; return ret;
} }
public List<UPlayer> getUPlayersWhereRole(Rel role) public List<MPlayer> getUPlayersWhereRole(Rel role)
{ {
List<UPlayer> ret = this.getUPlayers(); List<MPlayer> ret = this.getUPlayers();
Iterator<UPlayer> iter = ret.iterator(); Iterator<MPlayer> iter = ret.iterator();
while (iter.hasNext()) while (iter.hasNext())
{ {
UPlayer uplayer = iter.next(); MPlayer uplayer = iter.next();
if (uplayer.getRole() != role) if (uplayer.getRole() != role)
{ {
iter.remove(); iter.remove();
@ -913,13 +908,13 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
return ret; return ret;
} }
public UPlayer getLeader() public MPlayer getLeader()
{ {
List<UPlayer> ret = this.getUPlayers(); List<MPlayer> ret = this.getUPlayers();
Iterator<UPlayer> iter = ret.iterator(); Iterator<MPlayer> iter = ret.iterator();
while (iter.hasNext()) while (iter.hasNext())
{ {
UPlayer uplayer = iter.next(); MPlayer uplayer = iter.next();
if (uplayer.getRole() == Rel.LEADER) if (uplayer.getRole() == Rel.LEADER)
{ {
return uplayer; return uplayer;
@ -933,7 +928,7 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
List<CommandSender> ret = new ArrayList<CommandSender>(); List<CommandSender> ret = new ArrayList<CommandSender>();
for (CommandSender player : IdUtil.getOnlineSenders()) for (CommandSender player : IdUtil.getOnlineSenders())
{ {
UPlayer uplayer = UPlayer.get(player); MPlayer uplayer = MPlayer.get(player);
if (!MUtil.equals(uplayer.getUniverse(), this.getUniverse())) continue; if (!MUtil.equals(uplayer.getUniverse(), this.getUniverse())) continue;
if (uplayer.getFaction() != this) continue; if (uplayer.getFaction() != this) continue;
ret.add(player); ret.add(player);
@ -946,7 +941,7 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
List<Player> ret = new ArrayList<Player>(); List<Player> ret = new ArrayList<Player>();
for (Player player : Bukkit.getOnlinePlayers()) for (Player player : Bukkit.getOnlinePlayers())
{ {
UPlayer uplayer = UPlayer.get(player); MPlayer uplayer = MPlayer.get(player);
if (!MUtil.equals(uplayer.getUniverse(), this.getUniverse())) continue; if (!MUtil.equals(uplayer.getUniverse(), this.getUniverse())) continue;
if (uplayer.getFaction() != this) continue; if (uplayer.getFaction() != this) continue;
ret.add(player); ret.add(player);
@ -958,12 +953,12 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
public void promoteNewLeader() public void promoteNewLeader()
{ {
if ( ! this.isNormal()) return; if ( ! this.isNormal()) return;
if (this.getFlag(FFlag.PERMANENT) && UConf.get(this).permanentFactionsDisableLeaderPromotion) return; if (this.getFlag(FFlag.PERMANENT) && MConf.get().permanentFactionsDisableLeaderPromotion) return;
UPlayer oldLeader = this.getLeader(); MPlayer oldLeader = this.getLeader();
// get list of officers, or list of normal members if there are no officers // get list of officers, or list of normal members if there are no officers
List<UPlayer> replacements = this.getUPlayersWhereRole(Rel.OFFICER); List<MPlayer> replacements = this.getUPlayersWhereRole(Rel.OFFICER);
if (replacements == null || replacements.isEmpty()) if (replacements == null || replacements.isEmpty())
{ {
replacements = this.getUPlayersWhereRole(Rel.MEMBER); replacements = this.getUPlayersWhereRole(Rel.MEMBER);
@ -988,9 +983,9 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
Factions.get().log("The faction "+this.getName()+" ("+this.getId()+") has been disbanded since it has no members left."); Factions.get().log("The faction "+this.getName()+" ("+this.getId()+") has been disbanded since it has no members left.");
} }
for (UPlayer uplayer : UPlayerColls.get().get(this).getAllOnline()) for (MPlayer mplayer : MPlayerColl.get().getAllOnline())
{ {
uplayer.msg("<i>The faction %s<i> was disbanded.", this.getName(uplayer)); mplayer.msg("<i>The faction %s<i> was disbanded.", this.getName(mplayer));
} }
this.detach(); this.detach();

View File

@ -7,6 +7,7 @@ import org.bukkit.ChatColor;
import com.massivecraft.massivecore.store.Coll; import com.massivecraft.massivecore.store.Coll;
import com.massivecraft.massivecore.store.MStore; import com.massivecraft.massivecore.store.MStore;
import com.massivecraft.massivecore.util.Txt; import com.massivecraft.massivecore.util.Txt;
import com.massivecraft.factions.Const;
import com.massivecraft.factions.FFlag; import com.massivecraft.factions.FFlag;
import com.massivecraft.factions.FPerm; import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.Factions; import com.massivecraft.factions.Factions;
@ -17,12 +18,14 @@ import com.massivecraft.factions.util.MiscUtil;
public class FactionColl extends Coll<Faction> public class FactionColl extends Coll<Faction>
{ {
// -------------------------------------------- // // -------------------------------------------- //
// CONSTRUCT // INSTANCE & CONSTRUCT
// -------------------------------------------- // // -------------------------------------------- //
public FactionColl(String name) private static FactionColl i = new FactionColl();
public static FactionColl get() { return i; }
private FactionColl()
{ {
super(name, Faction.class, MStore.getDb(), Factions.get()); super(Const.COLLECTION_FACTION, Faction.class, MStore.getDb(), Factions.get());
} }
// -------------------------------------------- // // -------------------------------------------- //
@ -50,8 +53,8 @@ public class FactionColl extends Coll<Faction>
String message = Txt.parse("<b>Non existing factionId <h>%s <b>requested. <i>Cleaning all boards and uplayers.", this.fixId(oid)); String message = Txt.parse("<b>Non existing factionId <h>%s <b>requested. <i>Cleaning all boards and uplayers.", this.fixId(oid));
Factions.get().log(message); Factions.get().log(message);
BoardColls.get().clean(); BoardColl.get().clean();
UPlayerColls.get().clean(); MPlayerColl.get().clean();
} }
return ret; return ret;
@ -82,7 +85,7 @@ public class FactionColl extends Coll<Faction>
public Faction getNone() public Faction getNone()
{ {
String id = UConf.get(this).factionIdNone; String id = MConf.get().factionIdNone;
Faction faction = this.get(id); Faction faction = this.get(id);
if (faction != null) return faction; if (faction != null) return faction;
@ -115,7 +118,7 @@ public class FactionColl extends Coll<Faction>
public Faction getSafezone() public Faction getSafezone()
{ {
String id = UConf.get(this).factionIdSafezone; String id = MConf.get().factionIdSafezone;
Faction faction = this.get(id); Faction faction = this.get(id);
if (faction != null) return faction; if (faction != null) return faction;
@ -148,7 +151,7 @@ public class FactionColl extends Coll<Faction>
public Faction getWarzone() public Faction getWarzone()
{ {
String id = UConf.get(this).factionIdWarzone; String id = MConf.get().factionIdWarzone;
Faction faction = this.get(id); Faction faction = this.get(id);
if (faction != null) return faction; if (faction != null) return faction;
@ -185,9 +188,9 @@ public class FactionColl extends Coll<Faction>
public void econLandRewardRoutine() public void econLandRewardRoutine()
{ {
if (!Econ.isEnabled(this.getUniverse())) return; if (!Econ.isEnabled()) return;
double econLandReward = UConf.get(this).econLandReward; double econLandReward = MConf.get().econLandReward;
if (econLandReward == 0.0) return; if (econLandReward == 0.0) return;
Factions.get().log("Running econLandRewardRoutine..."); Factions.get().log("Running econLandRewardRoutine...");
@ -196,10 +199,10 @@ public class FactionColl extends Coll<Faction>
int landCount = faction.getLandCount(); int landCount = faction.getLandCount();
if (!faction.getFlag(FFlag.PEACEFUL) && landCount > 0) if (!faction.getFlag(FFlag.PEACEFUL) && landCount > 0)
{ {
List<UPlayer> players = faction.getUPlayers(); List<MPlayer> players = faction.getUPlayers();
int playerCount = players.size(); int playerCount = players.size();
double reward = econLandReward * landCount / playerCount; double reward = econLandReward * landCount / playerCount;
for (UPlayer player : players) for (MPlayer player : players)
{ {
Econ.modifyMoney(player, reward, "own " + landCount + " faction land divided among " + playerCount + " members"); Econ.modifyMoney(player, reward, "own " + landCount + " faction land divided among " + playerCount + " members");
} }
@ -215,14 +218,14 @@ public class FactionColl extends Coll<Faction>
{ {
ArrayList<String> errors = new ArrayList<String>(); ArrayList<String> errors = new ArrayList<String>();
if (MiscUtil.getComparisonString(str).length() < UConf.get(this).factionNameLengthMin) if (MiscUtil.getComparisonString(str).length() < MConf.get().factionNameLengthMin)
{ {
errors.add(Txt.parse("<i>The faction name can't be shorter than <h>%s<i> chars.", UConf.get(this).factionNameLengthMin)); errors.add(Txt.parse("<i>The faction name can't be shorter than <h>%s<i> chars.", MConf.get().factionNameLengthMin));
} }
if (str.length() > UConf.get(this).factionNameLengthMax) if (str.length() > MConf.get().factionNameLengthMax)
{ {
errors.add(Txt.parse("<i>The faction name can't be longer than <h>%s<i> chars.", UConf.get(this).factionNameLengthMax)); errors.add(Txt.parse("<i>The faction name can't be longer than <h>%s<i> chars.", MConf.get().factionNameLengthMax));
} }
for (char c : str.toCharArray()) for (char c : str.toCharArray())
@ -269,4 +272,61 @@ public class FactionColl extends Coll<Faction>
return this.getByName(str) != null; return this.getByName(str) != null;
} }
/*
@Override
public void init()
{
super.init();
this.migrate();
}
// This method is for the 1.8.X --> 2.0.0 migration
public void migrate()
{
// Create file objects
File oldFile = new File(Factions.get().getDataFolder(), "factions.json");
File newFile = new File(Factions.get().getDataFolder(), "factions.json.migrated");
// Already migrated?
if ( ! oldFile.exists()) return;
// Faction ids /delete
// For simplicity we just drop the old special factions.
// They will be replaced with new autogenerated ones per universe.
Set<String> factionIdsToDelete = MUtil.set("0", "-1", "-2");
// Read the file content through GSON.
Type type = new TypeToken<Map<String, Faction>>(){}.getType();
Map<String, Faction> id2faction = Factions.get().gson.fromJson(DiscUtil.readCatch(oldFile), type);
// The Coll
FactionColl coll = this.getForUniverse(MassiveCore.DEFAULT);
// Set the data
for (Entry<String, Faction> entry : id2faction.entrySet())
{
String factionId = entry.getKey();
if (factionIdsToDelete.contains(factionId)) continue;
Faction faction = entry.getValue();
coll.attach(faction, factionId);
}
// Mark as migrated
oldFile.renameTo(newFile);
}
// -------------------------------------------- //
// INDEX
// -------------------------------------------- //
public void reindexUPlayers()
{
for (FactionColl coll : this.getColls())
{
coll.reindexUPlayers();
}
}
*/
} }

View File

@ -1,103 +0,0 @@
package com.massivecraft.factions.entity;
import java.io.File;
import java.lang.reflect.Type;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import com.massivecraft.factions.Const;
import com.massivecraft.factions.Factions;
import com.massivecraft.massivecore.Aspect;
import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.util.DiscUtil;
import com.massivecraft.massivecore.util.MUtil;
import com.massivecraft.massivecore.xlib.gson.reflect.TypeToken;
public class FactionColls extends XColls<FactionColl, Faction>
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static FactionColls i = new FactionColls();
public static FactionColls get() { return i; }
// -------------------------------------------- //
// OVERRIDE: COLLS
// -------------------------------------------- //
@Override
public FactionColl createColl(String collName)
{
return new FactionColl(collName);
}
@Override
public Aspect getAspect()
{
return Factions.get().getAspect();
}
@Override
public String getBasename()
{
return Const.COLLECTION_FACTION;
}
@Override
public void init()
{
super.init();
this.migrate();
}
// This method is for the 1.8.X --> 2.0.0 migration
public void migrate()
{
// Create file objects
File oldFile = new File(Factions.get().getDataFolder(), "factions.json");
File newFile = new File(Factions.get().getDataFolder(), "factions.json.migrated");
// Already migrated?
if ( ! oldFile.exists()) return;
// Faction ids /delete
// For simplicity we just drop the old special factions.
// They will be replaced with new autogenerated ones per universe.
Set<String> factionIdsToDelete = MUtil.set("0", "-1", "-2");
// Read the file content through GSON.
Type type = new TypeToken<Map<String, Faction>>(){}.getType();
Map<String, Faction> id2faction = Factions.get().gson.fromJson(DiscUtil.readCatch(oldFile), type);
// The Coll
FactionColl coll = this.getForUniverse(MassiveCore.DEFAULT);
// Set the data
for (Entry<String, Faction> entry : id2faction.entrySet())
{
String factionId = entry.getKey();
if (factionIdsToDelete.contains(factionId)) continue;
Faction faction = entry.getValue();
coll.attach(faction, factionId);
}
// Mark as migrated
oldFile.renameTo(newFile);
}
// -------------------------------------------- //
// INDEX
// -------------------------------------------- //
public void reindexUPlayers()
{
for (FactionColl coll : this.getColls())
{
coll.reindexUPlayers();
}
}
}

View File

@ -1,18 +1,24 @@
package com.massivecraft.factions.entity; package com.massivecraft.factions.entity;
import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.TreeSet; import java.util.TreeSet;
import java.util.UUID;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import com.massivecraft.factions.FFlag;
import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.Factions; import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.event.EventFactionsChunkChangeType;
import com.massivecraft.factions.integration.dynmap.DynmapStyle; import com.massivecraft.factions.integration.dynmap.DynmapStyle;
import com.massivecraft.factions.listeners.FactionsListenerChat; import com.massivecraft.factions.listeners.FactionsListenerChat;
import com.massivecraft.massivecore.store.Entity; import com.massivecraft.massivecore.store.Entity;
@ -64,6 +70,54 @@ public class MConf extends Entity<MConf>
public boolean removePlayerDataWhenBanned = true; public boolean removePlayerDataWhenBanned = true;
public double removePlayerDataAfterInactiveDays = 20.0; public double removePlayerDataAfterInactiveDays = 20.0;
// -------------------------------------------- //
// SPECIAL FACTION IDS
// -------------------------------------------- //
public String factionIdNone = UUID.randomUUID().toString();
public String factionIdSafezone = UUID.randomUUID().toString();
public String factionIdWarzone = UUID.randomUUID().toString();
// -------------------------------------------- //
// DEFAULTS
// -------------------------------------------- //
public String defaultPlayerFactionId = this.factionIdNone;
public Rel defaultPlayerRole = Rel.RECRUIT;
public double defaultPlayerPower = 0.0;
public boolean defaultFactionOpen = false;
public Map<FFlag, Boolean> defaultFactionFlags = FFlag.getDefaultDefaults();
public Map<FPerm, Set<Rel>> defaultFactionPerms = FPerm.getDefaultDefaults();
// -------------------------------------------- //
// POWER
// -------------------------------------------- //
public double powerMax = 10.0;
public double powerMin = 0.0;
public double powerPerHour = 2.0;
public double powerPerDeath = -2.0;
public boolean canLeaveWithNegativePower = true;
// -------------------------------------------- //
// CORE
// -------------------------------------------- //
public int factionMemberLimit = 0;
public double factionPowerMax = 0.0;
public int factionNameLengthMin = 3;
public int factionNameLengthMax = 16;
public boolean factionNameForceUpperCase = false;
// -------------------------------------------- //
// MESSAGES
// -------------------------------------------- //
public boolean broadcastNameChange = false;
// -------------------------------------------- // // -------------------------------------------- //
// CLAIM LIMITS // CLAIM LIMITS
// -------------------------------------------- // // -------------------------------------------- //
@ -74,6 +128,110 @@ public class MConf extends Entity<MConf>
// the maximum radius allowed when using the claim command. // the maximum radius allowed when using the claim command.
public int radiusClaimRadiusLimit = 5; public int radiusClaimRadiusLimit = 5;
// -------------------------------------------- //
// CLAIMS
// -------------------------------------------- //
public boolean claimsMustBeConnected = true;
public boolean claimingFromOthersAllowed = true;
public boolean claimsCanBeUnconnectedIfOwnedByOtherFaction = false;
public int claimsRequireMinFactionMembers = 1;
public int claimedLandsMax = 0;
// -------------------------------------------- //
// HOMES
// -------------------------------------------- //
public boolean homesEnabled = true;
public boolean homesMustBeInClaimedTerritory = true;
public boolean homesTeleportCommandEnabled = true;
public boolean homesTeleportAllowedFromEnemyTerritory = true;
public boolean homesTeleportAllowedFromDifferentWorld = true;
public double homesTeleportAllowedEnemyDistance = 32.0;
public boolean homesTeleportIgnoreEnemiesIfInOwnTerritory = true;
public boolean homesTeleportToOnDeathActive = false;
public EventPriority homesTeleportToOnDeathPriority = EventPriority.NORMAL;
// -------------------------------------------- //
// ASSORTED
// -------------------------------------------- //
public boolean permanentFactionsDisableLeaderPromotion = false;
public double actionDeniedPainAmount = 2.0D;
public boolean disablePVPForFactionlessPlayers = false;
public boolean enablePVPAgainstFactionlessInAttackersLand = false;
public double territoryShieldFactor = 0.3D;
// -------------------------------------------- //
// DENY COMMANDS
// -------------------------------------------- //
// commands which will be prevented if the player is a member of a permanent faction
public List<String> denyCommandsPermanentFactionMember = new ArrayList<String>();
// commands which will be prevented when in claimed territory of another faction
public Map<Rel, List<String>> denyCommandsTerritoryRelation = MUtil.map(
Rel.ENEMY, MUtil.list(
// Essentials commands
"home",
"homes",
"sethome",
"createhome",
"tpahere",
"tpaccept",
"tpyes",
"tpa",
"call",
"tpask",
"warp",
"warps",
"spawn",
// Essentials e-alliases
"ehome",
"ehomes",
"esethome",
"ecreatehome",
"etpahere",
"etpaccept",
"etpyes",
"etpa",
"ecall",
"etpask",
"ewarp",
"ewarps",
"espawn",
// Essentials fallback alliases
"essentials:home",
"essentials:homes",
"essentials:sethome",
"essentials:createhome",
"essentials:tpahere",
"essentials:tpaccept",
"essentials:tpyes",
"essentials:tpa",
"essentials:call",
"essentials:tpask",
"essentials:warp",
"essentials:warps",
"essentials:spawn",
// Other plugins
"wtp",
"uspawn",
"utp",
"mspawn",
"mtp",
"fspawn",
"ftp",
"jspawn",
"jtp"
),
Rel.NEUTRAL, new ArrayList<String>(),
Rel.TRUCE, new ArrayList<String>(),
Rel.ALLY, new ArrayList<String>(),
Rel.MEMBER, new ArrayList<String>()
);
// -------------------------------------------- // // -------------------------------------------- //
// CHAT // CHAT
// -------------------------------------------- // // -------------------------------------------- //
@ -87,28 +245,6 @@ public class MConf extends Entity<MConf>
public boolean chatParseTags = true; public boolean chatParseTags = true;
public EventPriority chatParseTagsAt = EventPriority.LOW; public EventPriority chatParseTagsAt = EventPriority.LOW;
// HeroChat: The Faction Channel
public String herochatFactionName = "Faction";
public String herochatFactionNick = "F";
public String herochatFactionFormat = "{color}[&l{nick}&r{color} &l{factions_roleprefix}&r{color}{factions_title|rp}{sender}{color}] &f{msg}";
public ChatColor herochatFactionColor = ChatColor.GREEN;
public int herochatFactionDistance = 0;
public boolean herochatFactionIsShortcutAllowed = false;
public boolean herochatFactionCrossWorld = true;
public boolean herochatFactionMuted = false;
public Set<String> herochatFactionWorlds = new HashSet<String>();
// HeroChat: The Allies Channel
public String herochatAlliesName = "Allies";
public String herochatAlliesNick = "A";
public String herochatAlliesFormat = "{color}[&l{nick}&r&f {factions_relcolor}&l{factions_roleprefix}&r{factions_relcolor}{factions_name|rp}{sender}{color}] &f{msg}";
public ChatColor herochatAlliesColor = ChatColor.DARK_PURPLE;
public int herochatAlliesDistance = 0;
public boolean herochatAlliesIsShortcutAllowed = false;
public boolean herochatAlliesCrossWorld = true;
public boolean herochatAlliesMuted = false;
public Set<String> herochatAlliesWorlds = new HashSet<String>();
// -------------------------------------------- // // -------------------------------------------- //
// COLORS // COLORS
// -------------------------------------------- // // -------------------------------------------- //
@ -250,7 +386,88 @@ public class MConf extends Entity<MConf>
); );
// -------------------------------------------- // // -------------------------------------------- //
// DYNMAP // INTEGRATION: HeroChat
// -------------------------------------------- //
// HeroChat: The Faction Channel
public String herochatFactionName = "Faction";
public String herochatFactionNick = "F";
public String herochatFactionFormat = "{color}[&l{nick}&r{color} &l{factions_roleprefix}&r{color}{factions_title|rp}{sender}{color}] &f{msg}";
public ChatColor herochatFactionColor = ChatColor.GREEN;
public int herochatFactionDistance = 0;
public boolean herochatFactionIsShortcutAllowed = false;
public boolean herochatFactionCrossWorld = true;
public boolean herochatFactionMuted = false;
public Set<String> herochatFactionWorlds = new HashSet<String>();
// HeroChat: The Allies Channel
public String herochatAlliesName = "Allies";
public String herochatAlliesNick = "A";
public String herochatAlliesFormat = "{color}[&l{nick}&r&f {factions_relcolor}&l{factions_roleprefix}&r{factions_relcolor}{factions_name|rp}{sender}{color}] &f{msg}";
public ChatColor herochatAlliesColor = ChatColor.DARK_PURPLE;
public int herochatAlliesDistance = 0;
public boolean herochatAlliesIsShortcutAllowed = false;
public boolean herochatAlliesCrossWorld = true;
public boolean herochatAlliesMuted = false;
public Set<String> herochatAlliesWorlds = new HashSet<String>();
// -------------------------------------------- //
// INTEGRATION: LWC
// -------------------------------------------- //
public Map<EventFactionsChunkChangeType, Boolean> lwcRemoveOnChange = MUtil.map(
EventFactionsChunkChangeType.BUY, false,
EventFactionsChunkChangeType.SELL, false,
EventFactionsChunkChangeType.CONQUER, false,
EventFactionsChunkChangeType.PILLAGE, false
);
// -------------------------------------------- //
// INTEGRATION: ECONOMY
// -------------------------------------------- //
public boolean econEnabled = false;
// TODO: Rename to include unit.
public double econLandReward = 0.00;
public String econUniverseAccount = "";
public Map<EventFactionsChunkChangeType, Double> econChunkCost = MUtil.map(
EventFactionsChunkChangeType.BUY, 30.0,
EventFactionsChunkChangeType.SELL, -20.0,
EventFactionsChunkChangeType.CONQUER, -10.0,
EventFactionsChunkChangeType.PILLAGE, -10.0
);
public double econCostCreate = 200.0;
public double econCostSethome = 0.0;
public double econCostJoin = 0.0;
public double econCostLeave = 0.0;
public double econCostKick = 0.0;
public double econCostInvite = 0.0;
public double econCostDeinvite = 0.0;
public double econCostHome = 0.0;
public double econCostName = 0.0;
public double econCostDescription = 0.0;
public double econCostTitle = 0.0;
public double econCostOpen = 0.0;
public Map<Rel, Double> econRelCost = MUtil.map(
Rel.ENEMY, 0.0,
Rel.ALLY, 0.0,
Rel.TRUCE, 0.0,
Rel.NEUTRAL, 0.0
);
//Faction banks, to pay for land claiming and other costs instead of individuals paying for them
public boolean bankEnabled = true;
//public static boolean bankMembersCanWithdraw = false; //Have to be at least moderator to withdraw or pay money to another faction
public boolean bankFactionPaysCosts = true; //The faction pays for faction command costs, such as sethome
public boolean bankFactionPaysLandCosts = true; //The faction pays for land claiming costs.
// -------------------------------------------- //
// INTEGRATION: DYNMAP
// -------------------------------------------- // // -------------------------------------------- //
// Should the dynmap intagration be used? // Should the dynmap intagration be used?

View File

@ -27,7 +27,6 @@ public class MConfColl extends Coll<MConf>
public void init() public void init()
{ {
super.init(); super.init();
MConf.i = this.get(MassiveCore.INSTANCE, true); MConf.i = this.get(MassiveCore.INSTANCE, true);
} }

View File

@ -1,9 +1,33 @@
package com.massivecraft.factions.entity; package com.massivecraft.factions.entity;
import com.massivecraft.factions.Perm; import java.util.HashSet;
import com.massivecraft.massivecore.store.SenderEntity; import java.util.Set;
public class MPlayer extends SenderEntity<MPlayer> import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import com.massivecraft.factions.EconomyParticipator;
import com.massivecraft.factions.FFlag;
import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Lang;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.RelationParticipator;
import com.massivecraft.factions.event.EventFactionsChunkChange;
import com.massivecraft.factions.event.EventFactionsMembershipChange;
import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason;
import com.massivecraft.factions.util.RelationUtil;
import com.massivecraft.massivecore.mixin.Mixin;
import com.massivecraft.massivecore.ps.PS;
import com.massivecraft.massivecore.ps.PSFormatHumanSpace;
import com.massivecraft.massivecore.store.SenderEntity;
import com.massivecraft.massivecore.util.IdUtil;
import com.massivecraft.massivecore.util.MUtil;
import com.massivecraft.massivecore.util.Txt;
public class MPlayer extends SenderEntity<MPlayer> implements EconomyParticipator
{ {
// -------------------------------------------- // // -------------------------------------------- //
// META // META
@ -15,14 +39,19 @@ public class MPlayer extends SenderEntity<MPlayer>
} }
// -------------------------------------------- // // -------------------------------------------- //
// OVERRIDE // OVERRIDE: ENTITY
// -------------------------------------------- // // -------------------------------------------- //
@Override @Override
public MPlayer load(MPlayer that) public MPlayer load(MPlayer that)
{ {
this.mapAutoUpdating = that.mapAutoUpdating; this.setFactionId(that.factionId);
this.usingAdminMode = that.usingAdminMode; this.setRole(that.role);
this.setTitle(that.title);
this.setPowerBoost(that.powerBoost);
this.setPower(that.power);
this.setMapAutoUpdating(that.mapAutoUpdating);
this.setUsingAdminMode(that.usingAdminMode);
return this; return this;
} }
@ -30,30 +59,770 @@ public class MPlayer extends SenderEntity<MPlayer>
@Override @Override
public boolean isDefault() public boolean isDefault()
{ {
if (this.hasFaction()) return false;
// Role means nothing without a faction.
// Title means nothing without a faction.
if (this.getPowerRounded() != (int) Math.round(MConf.get().defaultPlayerPower)) return false;
if (this.isMapAutoUpdating()) return false; if (this.isMapAutoUpdating()) return false;
if (this.isUsingAdminMode()) return false; if (this.isUsingAdminMode()) return false;
return true; return true;
} }
@Override
public void postAttach(String id)
{
// If inited ...
if (!Factions.get().isDatabaseInitialized()) return;
// ... update the index.
Faction faction = this.getFaction();
faction.uplayers.add(this);
//Factions.get().log(Txt.parse("<g>postAttach added <h>%s <i>aka <h>%s <i>to <h>%s <i>aka <h>%s<i>.", id, Mixin.getDisplayName(id), faction.getId(), faction.getName()));
}
@Override
public void preDetach(String id)
{
// If inited ...
if (!Factions.get().isDatabaseInitialized()) return;
// ... update the index.
Faction faction = this.getFaction();
faction.uplayers.remove(this);
//Factions.get().log(Txt.parse("<b>preDetach removed <h>%s <i>aka <h>%s <i>to <h>%s <i>aka <h>%s<i>.", id, Mixin.getDisplayName(id), faction.getId(), faction.getName()));
}
// -------------------------------------------- // // -------------------------------------------- //
// FIELDS // FIELDS: RAW
// -------------------------------------------- //
// In this section of the source code we place the field declarations only.
// Each field has it's own section further down since just the getter and setter logic takes up quite some place.
// This is a foreign key.
// Each player belong to a faction.
// Null means default for the universe.
private String factionId = null;
// What role does the player have in the faction?
// Null means default for the universe.
private Rel role = null;
// What title does the player have in the faction?
// The title is just for fun. It's not connected to any game mechanic.
// The player title is similar to the faction description.
//
// Question: Can the title contain chat colors?
// Answer: Yes but in such case the policy is that they already must be parsed using Txt.parse.
// If the title contains raw markup, such as "<white>" instead of "§f" it will not be parsed and "<white>" will be displayed.
//
// Null means the player has no title.
private String title = null;
// Player usually do not have a powerboost. It defaults to 0.
// The powerBoost is a custom increase/decrease to default and maximum power.
// Note that player powerBoost and faction powerBoost are very similar.
private Double powerBoost = null;
// Each player has an individual power level.
// The power level for online players is occasionally updated by a recurring task and the power should stay the same for offline players.
// For that reason the value is to be considered correct when you pick it. Do not call the power update method.
// Null means default for the universe.
private Double power = null;
// Has this player requested an auto-updating ascii art map?
// Null means false
private Boolean mapAutoUpdating = null;
// Is this player using admin mode?
// Null means false
private Boolean usingAdminMode = null;
// The id for the faction this uplayer is currently autoclaiming for.
// NOTE: This field will not be saved to the database ever.
// Null means the player isn't auto claiming.
private transient Faction autoClaimFaction = null;
public Faction getAutoClaimFaction() { return this.autoClaimFaction; }
public void setAutoClaimFaction(Faction autoClaimFaction) { this.autoClaimFaction = autoClaimFaction; }
// -------------------------------------------- //
// CORE UTILITIES
// -------------------------------------------- // // -------------------------------------------- //
private boolean mapAutoUpdating = false; public void resetFactionData()
public boolean isMapAutoUpdating() { return this.mapAutoUpdating; } {
public void setMapAutoUpdating(boolean mapAutoUpdating) { this.mapAutoUpdating = mapAutoUpdating; this.changed(); } // The default neutral faction
this.setFactionId(null);
this.setRole(null);
this.setTitle(null);
this.setAutoClaimFaction(null);
}
// -------------------------------------------- //
// FIELD: factionId
// -------------------------------------------- //
public String getDefaultFactionId()
{
return MConf.get().defaultPlayerFactionId;
}
// This method never returns null
public String getFactionId()
{
if (this.factionId == null) return this.getDefaultFactionId();
return this.factionId;
}
// This method never returns null
public Faction getFaction()
{
Faction ret = Faction.get(this.getFactionId());
if (ret == null) ret = Faction.get(MConf.get().defaultPlayerFactionId);
return ret;
}
public boolean hasFaction()
{
return !this.getFactionId().equals(MConf.get().factionIdNone);
}
// This setter is so long because it search for default/null case and takes care of updating the faction member index
public void setFactionId(String factionId)
{
// Clean input
String target = factionId;
// Detect Nochange
if (MUtil.equals(this.factionId, target)) return;
// Get the raw old value
String oldFactionId = this.factionId;
// Apply
this.factionId = target;
// Must be attached and initialized
if (!this.attached()) return;
if (!Factions.get().isDatabaseInitialized()) return;
if (oldFactionId == null) oldFactionId = this.getDefaultFactionId();
// Update index
Faction oldFaction = Faction.get(oldFactionId);
Faction faction = this.getFaction();
if (oldFaction != null) oldFaction.uplayers.remove(this);
if (faction != null) faction.uplayers.add(this);
String oldFactionIdDesc = "NULL";
String oldFactionNameDesc = "NULL";
if (oldFaction != null)
{
oldFactionIdDesc = oldFaction.getId();
oldFactionNameDesc = oldFaction.getName();
}
String factionIdDesc = "NULL";
String factionNameDesc = "NULL";
if (faction != null)
{
factionIdDesc = faction.getId();
factionNameDesc = faction.getName();
}
Factions.get().log(Txt.parse("<i>setFactionId moved <h>%s <i>aka <h>%s <i>from <h>%s <i>aka <h>%s <i>to <h>%s <i>aka <h>%s<i>.", this.getId(), this.getDisplayName(IdUtil.getConsole()), oldFactionIdDesc, oldFactionNameDesc, factionIdDesc, factionNameDesc));
// Mark as changed
this.changed();
}
public void setFaction(Faction faction)
{
this.setFactionId(faction.getId());
}
// -------------------------------------------- //
// FIELD: role
// -------------------------------------------- //
public Rel getDefaultRole()
{
return MConf.get().defaultPlayerRole;
}
public Rel getRole()
{
if (this.role == null) return this.getDefaultRole();
return this.role;
}
public void setRole(Rel role)
{
// Clean input
Rel target = role;
// Detect Nochange
if (MUtil.equals(this.role, target)) return;
// Apply
this.role = target;
// Mark as changed
this.changed();
}
// -------------------------------------------- //
// FIELD: title
// -------------------------------------------- //
public boolean hasTitle()
{
return this.title != null;
}
public String getTitle()
{
if (this.hasTitle()) return this.title;
return Lang.PLAYER_NOTITLE;
}
public void setTitle(String title)
{
// Clean input
String target = title;
if (target != null)
{
target = target.trim();
if (target.length() == 0)
{
target = null;
}
}
// NOTE: That we parse the title here is considered part of the 1.8 --> 2.0 migration.
// This should be removed once the migration phase is considered to be over.
if (target != null)
{
target = Txt.parse(target);
}
// Detect Nochange
if (MUtil.equals(this.title, target)) return;
// Apply
this.title = target;
// Mark as changed
this.changed();
}
// -------------------------------------------- //
// FIELD: powerBoost
// -------------------------------------------- //
public double getPowerBoost()
{
Double ret = this.powerBoost;
if (ret == null) ret = 0D;
return ret;
}
public void setPowerBoost(Double powerBoost)
{
// Clean input
Double target = powerBoost;
if (target == null || target == 0) target = null;
// Detect Nochange
if (MUtil.equals(this.powerBoost, target)) return;
// Apply
this.powerBoost = target;
// Mark as changed
this.changed();
}
public boolean hasPowerBoost()
{
return this.getPowerBoost() != 0D;
}
// -------------------------------------------- //
// FIELD: power
// -------------------------------------------- //
// MIXIN: RAW
public double getPowerMaxUniversal()
{
return Factions.get().getPowerMixin().getMaxUniversal(this);
}
public double getPowerMax()
{
return Factions.get().getPowerMixin().getMax(this);
}
public double getPowerMin()
{
return Factions.get().getPowerMixin().getMin(this);
}
public double getPowerPerHour()
{
return Factions.get().getPowerMixin().getPerHour(this);
}
public double getPowerPerDeath()
{
return Factions.get().getPowerMixin().getPerDeath(this);
}
// MIXIN: FINER
public double getLimitedPower(double power)
{
power = Math.max(power, this.getPowerMin());
power = Math.min(power, this.getPowerMax());
return power;
}
public int getPowerMaxRounded()
{
return (int) Math.round(this.getPowerMax());
}
public int getPowerMinRounded()
{
return (int) Math.round(this.getPowerMin());
}
public int getPowerMaxUniversalRounded()
{
return (int) Math.round(this.getPowerMaxUniversal());
}
// RAW
public double getDefaultPower()
{
return MConf.get().defaultPlayerPower;
}
public double getPower()
{
Double ret = this.power;
if (ret == null) ret = this.getDefaultPower();
ret = this.getLimitedPower(ret);
return ret;
}
public void setPower(Double power)
{
// Clean input
Double target = power;
// Detect Nochange
if (MUtil.equals(this.power, target)) return;
// Apply
this.power = target;
// Mark as changed
this.changed();
}
// FINER
public int getPowerRounded()
{
return (int) Math.round(this.getPower());
}
// -------------------------------------------- //
// FIELD: mapAutoUpdating
// -------------------------------------------- //
public boolean isMapAutoUpdating()
{
if (this.mapAutoUpdating == null) return false;
if (this.mapAutoUpdating == false) return false;
return true;
}
public void setMapAutoUpdating(Boolean mapAutoUpdating)
{
// Clean input
Boolean target = mapAutoUpdating;
if (target == false) target = null;
// Detect Nochange
if (MUtil.equals(this.mapAutoUpdating, target)) return;
// Apply
this.mapAutoUpdating = target;
// Mark as changed
this.changed();
}
// -------------------------------------------- //
// FIELD: usingAdminMode
// -------------------------------------------- //
private boolean usingAdminMode = false;
public boolean isUsingAdminMode() public boolean isUsingAdminMode()
{ {
if (this.usingAdminMode && this.getSender() != null && !Perm.ADMIN.has(this.getSender(), false)) if (this.usingAdminMode == null) return false;
if (this.usingAdminMode == false) return false;
// Deactivate admin mode if we don't have permissions for it.
if (this.getSender() != null && !Perm.ADMIN.has(this.getSender(), false))
{ {
// If we are using admin mode but don't have permissions for it we deactivate it.
this.setUsingAdminMode(false); this.setUsingAdminMode(false);
} }
return this.usingAdminMode;
return true;
}
public void setUsingAdminMode(Boolean usingAdminMode)
{
// Clean input
Boolean target = usingAdminMode;
if (target == false) target = null;
// Detect Nochange
if (MUtil.equals(this.usingAdminMode, target)) return;
// Apply
this.usingAdminMode = target;
// Mark as changed
this.changed();
}
// -------------------------------------------- //
// TITLE, NAME, FACTION NAME AND CHAT
// -------------------------------------------- //
public String getFactionName()
{
Faction faction = this.getFaction();
if (faction.isNone()) return "";
return faction.getName();
}
// Base concatenations:
public String getNameAndSomething(String color, String something)
{
String ret = "";
ret += color;
ret += this.getRole().getPrefix();
if (something != null && something.length() > 0)
{
ret += something;
ret += " ";
ret += color;
}
ret += this.getName();
return ret;
}
public String getNameAndFactionName()
{
return this.getNameAndSomething("", this.getFactionName());
}
public String getNameAndTitle(String color)
{
if (this.hasTitle())
{
return this.getNameAndSomething(color, this.getTitle());
}
else
{
return this.getNameAndSomething(color, null);
}
}
// Colored concatenations:
// These are used in information messages
public String getNameAndTitle(Faction faction)
{
return this.getNameAndTitle(this.getColorTo(faction).toString());
}
public String getNameAndTitle(MPlayer uplayer)
{
return this.getNameAndTitle(this.getColorTo(uplayer).toString());
}
// -------------------------------------------- //
// RELATION AND RELATION COLORS
// -------------------------------------------- //
@Override
public String describeTo(RelationParticipator observer, boolean ucfirst)
{
return RelationUtil.describeThatToMe(this, observer, ucfirst);
}
@Override
public String describeTo(RelationParticipator observer)
{
return RelationUtil.describeThatToMe(this, observer);
}
@Override
public Rel getRelationTo(RelationParticipator observer)
{
return RelationUtil.getRelationOfThatToMe(this, observer);
}
@Override
public Rel getRelationTo(RelationParticipator observer, boolean ignorePeaceful)
{
return RelationUtil.getRelationOfThatToMe(this, observer, ignorePeaceful);
}
@Override
public ChatColor getColorTo(RelationParticipator observer)
{
return RelationUtil.getColorOfThatToMe(this, observer);
}
// -------------------------------------------- //
// HEALTH
// -------------------------------------------- //
public void heal(int amnt)
{
Player player = this.getPlayer();
if (player == null)
{
return;
}
player.setHealth(player.getHealth() + amnt);
}
// -------------------------------------------- //
// TERRITORY
// -------------------------------------------- //
public boolean isInOwnTerritory()
{
PS ps = Mixin.getSenderPs(this.getId());
if (ps == null) return false;
return BoardColl.get().getFactionAt(ps) == this.getFaction();
}
public boolean isInEnemyTerritory()
{
PS ps = Mixin.getSenderPs(this.getId());
if (ps == null) return false;
return BoardColl.get().getFactionAt(ps).getRelationTo(this) == Rel.ENEMY;
}
// -------------------------------------------- //
// ACTIONS
// -------------------------------------------- //
public void leave()
{
Faction myFaction = this.getFaction();
boolean permanent = myFaction.getFlag(FFlag.PERMANENT);
if (myFaction.getUPlayers().size() > 1)
{
if (!permanent && this.getRole() == Rel.LEADER)
{
msg("<b>You must give the leader role to someone else first.");
return;
}
if (!MConf.get().canLeaveWithNegativePower && this.getPower() < 0)
{
msg("<b>You cannot leave until your power is positive.");
return;
}
}
// Event
EventFactionsMembershipChange membershipChangeEvent = new EventFactionsMembershipChange(this.getSender(), this, myFaction, MembershipChangeReason.LEAVE);
membershipChangeEvent.run();
if (membershipChangeEvent.isCancelled()) return;
if (myFaction.isNormal())
{
for (MPlayer uplayer : myFaction.getUPlayersWhereOnline(true))
{
uplayer.msg("%s<i> left %s<i>.", this.describeTo(uplayer, true), myFaction.describeTo(uplayer));
}
if (MConf.get().logFactionLeave)
{
Factions.get().log(this.getName()+" left the faction: "+myFaction.getName());
}
}
this.resetFactionData();
if (myFaction.isNormal() && !permanent && myFaction.getUPlayers().isEmpty())
{
// Remove this faction
for (MPlayer mplayer : MPlayerColl.get().getAllOnline())
{
mplayer.msg("<i>%s<i> was disbanded.", myFaction.describeTo(mplayer, true));
}
if (MConf.get().logFactionDisband)
{
Factions.get().log("The faction "+myFaction.getName()+" ("+myFaction.getId()+") was disbanded due to the last player ("+this.getName()+") leaving.");
}
myFaction.detach();
}
}
public boolean tryClaim(Faction newFaction, PS ps, boolean verbooseChange, boolean verbooseSame)
{
PS chunk = ps.getChunk(true);
Faction oldFaction = BoardColl.get().getFactionAt(chunk);
MConf mconf = MConf.get();
// Validate
if (newFaction == oldFaction)
{
msg("%s<i> already owns this land.", newFaction.describeTo(this, true));
return true;
}
if (!this.isUsingAdminMode())
{
if (newFaction.isNormal())
{
if (mconf.getWorldsNoClaiming().contains(ps.getWorld()))
{
msg("<b>Sorry, this world has land claiming disabled.");
return false;
}
if (!FPerm.TERRITORY.has(this, newFaction, true))
{
return false;
}
if (newFaction.getUPlayers().size() < mconf.claimsRequireMinFactionMembers)
{
msg("Factions must have at least <h>%s<b> members to claim land.", mconf.claimsRequireMinFactionMembers);
return false;
}
int ownedLand = newFaction.getLandCount();
if (mconf.claimedLandsMax != 0 && ownedLand >= mconf.claimedLandsMax && ! newFaction.getFlag(FFlag.INFPOWER))
{
msg("<b>Limit reached. You can't claim more land.");
return false;
}
if (ownedLand >= newFaction.getPowerRounded())
{
msg("<b>You can't claim more land. You need more power.");
return false;
}
if
(
mconf.claimsMustBeConnected
&&
newFaction.getLandCountInWorld(ps.getWorld()) > 0
&&
!BoardColl.get().isConnectedPs(chunk, newFaction)
&&
(!mconf.claimsCanBeUnconnectedIfOwnedByOtherFaction || oldFaction.isNone())
)
{
if (mconf.claimsCanBeUnconnectedIfOwnedByOtherFaction)
{
msg("<b>You can only claim additional land which is connected to your first claim or controlled by another faction!");
}
else
{
msg("<b>You can only claim additional land which is connected to your first claim!");
}
return false;
}
}
if (oldFaction.isNormal())
{
if (!FPerm.TERRITORY.has(this, oldFaction, false))
{
if (!mconf.claimingFromOthersAllowed)
{
msg("<b>You may not claim land from others.");
return false;
}
if (oldFaction.getRelationTo(newFaction).isAtLeast(Rel.TRUCE))
{
msg("<b>You can't claim this land due to your relation with the current owner.");
return false;
}
if (!oldFaction.hasLandInflation())
{
msg("%s<i> owns this land and is strong enough to keep it.", oldFaction.getName(this));
return false;
}
if ( ! BoardColl.get().isBorderPs(chunk))
{
msg("<b>You must start claiming land at the border of the territory.");
return false;
}
}
}
}
// Event
EventFactionsChunkChange event = new EventFactionsChunkChange(this.getSender(), chunk, newFaction);
event.run();
if (event.isCancelled()) return false;
// Apply
BoardColl.get().setFactionAt(chunk, newFaction);
// Inform
Set<MPlayer> informees = new HashSet<MPlayer>();
informees.add(this);
if (newFaction.isNormal())
{
informees.addAll(newFaction.getUPlayers());
}
if (oldFaction.isNormal())
{
informees.addAll(oldFaction.getUPlayers());
}
if (MConf.get().logLandClaims)
{
informees.add(MPlayer.get(IdUtil.getConsole()));
}
String chunkString = chunk.toString(PSFormatHumanSpace.get());
String typeString = event.getType().toString().toLowerCase();
for (MPlayer informee : informees)
{
informee.msg("<h>%s<i> did %s %s <i>for <h>%s<i> from <h>%s<i>.", this.describeTo(informee, true), typeString, chunkString, newFaction.describeTo(informee), oldFaction.describeTo(informee));
}
return true;
} }
public void setUsingAdminMode(boolean usingAdminMode) { this.usingAdminMode = usingAdminMode; this.changed(); }
} }

View File

@ -2,8 +2,13 @@ package com.massivecraft.factions.entity;
import com.massivecraft.factions.Const; import com.massivecraft.factions.Const;
import com.massivecraft.factions.Factions; import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Rel;
import com.massivecraft.massivecore.mixin.Mixin;
import com.massivecraft.massivecore.store.MStore; import com.massivecraft.massivecore.store.MStore;
import com.massivecraft.massivecore.store.SenderColl; import com.massivecraft.massivecore.store.SenderColl;
import com.massivecraft.massivecore.util.IdUtil;
import com.massivecraft.massivecore.util.TimeUnit;
import com.massivecraft.massivecore.util.Txt;
public class MPlayerColl extends SenderColl<MPlayer> public class MPlayerColl extends SenderColl<MPlayer>
{ {
@ -18,4 +23,101 @@ public class MPlayerColl extends SenderColl<MPlayer>
super(Const.COLLECTION_MPLAYER, MPlayer.class, MStore.getDb(), Factions.get()); super(Const.COLLECTION_MPLAYER, MPlayer.class, MStore.getDb(), Factions.get());
} }
// -------------------------------------------- //
// EXTRAS
// -------------------------------------------- //
public void clean()
{
String universe = this.getUniverse();
for (MPlayer uplayer : this.getAll())
{
String factionId = uplayer.getFactionId();
if (FactionColl.get().containsId(factionId)) continue;
uplayer.resetFactionData();
String message = Txt.parse("<i>Reset data for <h>%s <i>in <h>%s <i>universe. Unknown factionId <h>%s", uplayer.getDisplayName(IdUtil.getConsole()), universe, factionId);
Factions.get().log(message);
}
}
public void removePlayerDataAfterInactiveDaysRoutine()
{
if (MConf.get().removePlayerDataAfterInactiveDays <= 0.0) return;
long now = System.currentTimeMillis();
double toleranceMillis = MConf.get().removePlayerDataAfterInactiveDays * TimeUnit.MILLIS_PER_DAY;
for (MPlayer uplayer : this.getAll())
{
Long lastPlayed = Mixin.getLastPlayed(uplayer.getId());
if (lastPlayed == null) continue;
if (uplayer.isOnline()) continue;
if (now - lastPlayed <= toleranceMillis) continue;
if (MConf.get().logFactionLeave || MConf.get().logFactionKick)
{
Factions.get().log("Player "+uplayer.getName()+" was auto-removed due to inactivity.");
}
// if player is faction leader, sort out the faction since he's going away
if (uplayer.getRole() == Rel.LEADER)
{
Faction faction = uplayer.getFaction();
if (faction != null)
{
uplayer.getFaction().promoteNewLeader();
}
}
uplayer.leave();
uplayer.detach();
}
}
/*
// This method is for the 1.8.X --> 2.0.0 migration
public void migrate()
{
// Create file objects
File oldFile = new File(Factions.get().getDataFolder(), "players.json");
File newFile = new File(Factions.get().getDataFolder(), "players.json.migrated");
// Already migrated?
if ( ! oldFile.exists()) return;
// Read the file content through GSON.
Type type = new TypeToken<Map<String, UPlayer>>(){}.getType();
Map<String, UPlayer> id2uplayer = Factions.get().gson.fromJson(DiscUtil.readCatch(oldFile), type);
// The Coll
UPlayerColl coll = this.getForUniverse(MassiveCore.DEFAULT);
// Set the data
for (Entry<String, UPlayer> entry : id2uplayer.entrySet())
{
String playerId = entry.getKey();
UPlayer uplayer = entry.getValue();
coll.attach(uplayer, playerId);
}
// Mark as migrated
oldFile.renameTo(newFile);
}
// -------------------------------------------- //
// EXTRAS
// -------------------------------------------- //
public void clean()
{
for (UPlayerColl coll : this.getColls())
{
coll.clean();
}
}
*/
} }

View File

@ -1,273 +0,0 @@
package com.massivecraft.factions.entity;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import org.bukkit.command.CommandSender;
import org.bukkit.event.EventPriority;
import com.massivecraft.factions.FFlag;
import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.event.EventFactionsChunkChangeType;
import com.massivecraft.massivecore.store.Entity;
import com.massivecraft.massivecore.store.SenderEntity;
import com.massivecraft.massivecore.util.MUtil;
import com.massivecraft.massivecore.util.Txt;
public class UConf extends Entity<UConf>
{
// -------------------------------------------- //
// META
// -------------------------------------------- //
public static UConf get(Object oid)
{
return UConfColls.get().get2(oid);
}
// -------------------------------------------- //
// UNIVERSE ENABLE SWITCH
// -------------------------------------------- //
public boolean enabled = true;
public static boolean isDisabled(Object universe)
{
return isDisabled(universe, null);
}
public static String getDisabledMessage(Object universe)
{
UConf uconf = UConf.get(universe);
return Txt.parse("<i>Factions are disabled in the <h>%s <i>universe.", uconf.getUniverse());
}
public static boolean isDisabled(Object universe, Object inform)
{
UConf uconf = UConf.get(universe);
if (uconf.enabled) return false;
if (inform instanceof CommandSender)
{
((CommandSender)inform).sendMessage(getDisabledMessage(universe));
}
else if (inform instanceof SenderEntity)
{
((SenderEntity<?>)inform).sendMessage(getDisabledMessage(universe));
}
return true;
}
// -------------------------------------------- //
// SPECIAL FACTION IDS
// -------------------------------------------- //
public String factionIdNone = UUID.randomUUID().toString();
public String factionIdSafezone = UUID.randomUUID().toString();
public String factionIdWarzone = UUID.randomUUID().toString();
// -------------------------------------------- //
// DEFAULTS
// -------------------------------------------- //
public String defaultPlayerFactionId = this.factionIdNone;
public Rel defaultPlayerRole = Rel.RECRUIT;
public double defaultPlayerPower = 0.0;
public boolean defaultFactionOpen = false;
public Map<FFlag, Boolean> defaultFactionFlags = FFlag.getDefaultDefaults();
public Map<FPerm, Set<Rel>> defaultFactionPerms = FPerm.getDefaultDefaults();
// -------------------------------------------- //
// MESSAGES
// -------------------------------------------- //
public boolean broadcastNameChange = false;
// -------------------------------------------- //
// POWER
// -------------------------------------------- //
public double powerMax = 10.0;
public double powerMin = 0.0;
public double powerPerHour = 2.0;
public double powerPerDeath = -2.0;
public boolean canLeaveWithNegativePower = true;
// -------------------------------------------- //
// CORE
// -------------------------------------------- //
public int factionMemberLimit = 0;
public double factionPowerMax = 0.0;
public int factionNameLengthMin = 3;
public int factionNameLengthMax = 16;
public boolean factionNameForceUpperCase = false;
// -------------------------------------------- //
// CLAIMS
// -------------------------------------------- //
public boolean claimsMustBeConnected = true;
public boolean claimingFromOthersAllowed = true;
public boolean claimsCanBeUnconnectedIfOwnedByOtherFaction = false;
public int claimsRequireMinFactionMembers = 1;
public int claimedLandsMax = 0;
// -------------------------------------------- //
// HOMES
// -------------------------------------------- //
public boolean homesEnabled = true;
public boolean homesMustBeInClaimedTerritory = true;
public boolean homesTeleportCommandEnabled = true;
public boolean homesTeleportAllowedFromEnemyTerritory = true;
public boolean homesTeleportAllowedFromDifferentWorld = true;
public double homesTeleportAllowedEnemyDistance = 32.0;
public boolean homesTeleportIgnoreEnemiesIfInOwnTerritory = true;
public boolean homesTeleportToOnDeathActive = false;
public EventPriority homesTeleportToOnDeathPriority = EventPriority.NORMAL;
// -------------------------------------------- //
// ASSORTED
// -------------------------------------------- //
public boolean permanentFactionsDisableLeaderPromotion = false;
public double actionDeniedPainAmount = 2.0D;
public boolean disablePVPForFactionlessPlayers = false;
public boolean enablePVPAgainstFactionlessInAttackersLand = false;
public double territoryShieldFactor = 0.3D;
// -------------------------------------------- //
// DENY COMMANDS
// -------------------------------------------- //
// commands which will be prevented if the player is a member of a permanent faction
public List<String> denyCommandsPermanentFactionMember = new ArrayList<String>();
// commands which will be prevented when in claimed territory of another faction
public Map<Rel, List<String>> denyCommandsTerritoryRelation = MUtil.map(
Rel.ENEMY, MUtil.list(
// Essentials commands
"home",
"homes",
"sethome",
"createhome",
"tpahere",
"tpaccept",
"tpyes",
"tpa",
"call",
"tpask",
"warp",
"warps",
"spawn",
// Essentials e-alliases
"ehome",
"ehomes",
"esethome",
"ecreatehome",
"etpahere",
"etpaccept",
"etpyes",
"etpa",
"ecall",
"etpask",
"ewarp",
"ewarps",
"espawn",
// Essentials fallback alliases
"essentials:home",
"essentials:homes",
"essentials:sethome",
"essentials:createhome",
"essentials:tpahere",
"essentials:tpaccept",
"essentials:tpyes",
"essentials:tpa",
"essentials:call",
"essentials:tpask",
"essentials:warp",
"essentials:warps",
"essentials:spawn",
// Other plugins
"wtp",
"uspawn",
"utp",
"mspawn",
"mtp",
"fspawn",
"ftp",
"jspawn",
"jtp"
),
Rel.NEUTRAL, new ArrayList<String>(),
Rel.TRUCE, new ArrayList<String>(),
Rel.ALLY, new ArrayList<String>(),
Rel.MEMBER, new ArrayList<String>()
);
// -------------------------------------------- //
// INTEGRATION: LWC
// -------------------------------------------- //
public Map<EventFactionsChunkChangeType, Boolean> lwcRemoveOnChange = MUtil.map(
EventFactionsChunkChangeType.BUY, false,
EventFactionsChunkChangeType.SELL, false,
EventFactionsChunkChangeType.CONQUER, false,
EventFactionsChunkChangeType.PILLAGE, false
);
// -------------------------------------------- //
// INTEGRATION: ECONOMY
// -------------------------------------------- //
public boolean econEnabled = false;
// TODO: Rename to include unit.
public double econLandReward = 0.00;
public String econUniverseAccount = "";
public Map<EventFactionsChunkChangeType, Double> econChunkCost = MUtil.map(
EventFactionsChunkChangeType.BUY, 30.0,
EventFactionsChunkChangeType.SELL, -20.0,
EventFactionsChunkChangeType.CONQUER, -10.0,
EventFactionsChunkChangeType.PILLAGE, -10.0
);
public double econCostCreate = 200.0;
public double econCostSethome = 0.0;
public double econCostJoin = 0.0;
public double econCostLeave = 0.0;
public double econCostKick = 0.0;
public double econCostInvite = 0.0;
public double econCostDeinvite = 0.0;
public double econCostHome = 0.0;
public double econCostName = 0.0;
public double econCostDescription = 0.0;
public double econCostTitle = 0.0;
public double econCostOpen = 0.0;
public Map<Rel, Double> econRelCost = MUtil.map(
Rel.ENEMY, 0.0,
Rel.ALLY, 0.0,
Rel.TRUCE, 0.0,
Rel.NEUTRAL, 0.0
);
//Faction banks, to pay for land claiming and other costs instead of individuals paying for them
public boolean bankEnabled = true;
//public static boolean bankMembersCanWithdraw = false; //Have to be at least moderator to withdraw or pay money to another faction
public boolean bankFactionPaysCosts = true; //The faction pays for faction command costs, such as sethome
public boolean bankFactionPaysLandCosts = true; //The faction pays for land claiming costs.
}

View File

@ -1,30 +0,0 @@
package com.massivecraft.factions.entity;
import com.massivecraft.factions.Factions;
import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.store.Coll;
import com.massivecraft.massivecore.store.MStore;
public class UConfColl extends Coll<UConf>
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public UConfColl(String name)
{
super(name, UConf.class, MStore.getDb(), Factions.get());
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void init()
{
super.init();
this.get(MassiveCore.INSTANCE, true);
}
}

View File

@ -1,48 +0,0 @@
package com.massivecraft.factions.entity;
import com.massivecraft.factions.Const;
import com.massivecraft.factions.Factions;
import com.massivecraft.massivecore.Aspect;
import com.massivecraft.massivecore.MassiveCore;
public class UConfColls extends XColls<UConfColl, UConf>
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static UConfColls i = new UConfColls();
public static UConfColls get() { return i; }
// -------------------------------------------- //
// OVERRIDE: COLLS
// -------------------------------------------- //
@Override
public UConfColl createColl(String collName)
{
return new UConfColl(collName);
}
@Override
public Aspect getAspect()
{
return Factions.get().getAspect();
}
@Override
public String getBasename()
{
return Const.COLLECTION_UCONF;
}
@Override
public UConf get2(Object worldNameExtractable)
{
UConfColl coll = this.get(worldNameExtractable);
if (coll == null) return null;
return coll.get(MassiveCore.INSTANCE);
}
}

View File

@ -1,796 +0,0 @@
package com.massivecraft.factions.entity;
import java.util.HashSet;
import java.util.Set;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import com.massivecraft.factions.EconomyParticipator;
import com.massivecraft.factions.FFlag;
import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Lang;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.RelationParticipator;
import com.massivecraft.factions.event.EventFactionsChunkChange;
import com.massivecraft.factions.event.EventFactionsMembershipChange;
import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason;
import com.massivecraft.factions.util.RelationUtil;
import com.massivecraft.massivecore.mixin.Mixin;
import com.massivecraft.massivecore.ps.PS;
import com.massivecraft.massivecore.ps.PSFormatHumanSpace;
import com.massivecraft.massivecore.store.SenderEntity;
import com.massivecraft.massivecore.util.IdUtil;
import com.massivecraft.massivecore.util.MUtil;
import com.massivecraft.massivecore.util.Txt;
public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipator
{
// -------------------------------------------- //
// META
// -------------------------------------------- //
public static UPlayer get(Object oid)
{
return UPlayerColls.get().get2(oid);
}
// -------------------------------------------- //
// OVERRIDE: ENTITY
// -------------------------------------------- //
@Override
public UPlayer load(UPlayer that)
{
this.setFactionId(that.factionId);
this.setRole(that.role);
this.setTitle(that.title);
this.setPowerBoost(that.powerBoost);
this.setPower(that.power);
return this;
}
@Override
public boolean isDefault()
{
if (this.hasFaction()) return false;
// Role means nothing without a faction.
// Title means nothing without a faction.
if (this.getPowerRounded() != (int) Math.round(UConf.get(this).defaultPlayerPower)) return false;
return true;
}
@Override
public void postAttach(String id)
{
// If inited ...
if (!Factions.get().isDatabaseInitialized()) return;
// ... update the index.
Faction faction = this.getFaction();
faction.uplayers.add(this);
//Factions.get().log(Txt.parse("<g>postAttach added <h>%s <i>aka <h>%s <i>to <h>%s <i>aka <h>%s<i>.", id, Mixin.getDisplayName(id), faction.getId(), faction.getName()));
}
@Override
public void preDetach(String id)
{
// If inited ...
if (!Factions.get().isDatabaseInitialized()) return;
// ... update the index.
Faction faction = this.getFaction();
faction.uplayers.remove(this);
//Factions.get().log(Txt.parse("<b>preDetach removed <h>%s <i>aka <h>%s <i>to <h>%s <i>aka <h>%s<i>.", id, Mixin.getDisplayName(id), faction.getId(), faction.getName()));
}
// -------------------------------------------- //
// FIELDS: RAW
// -------------------------------------------- //
// In this section of the source code we place the field declarations only.
// Each field has it's own section further down since just the getter and setter logic takes up quite some place.
// This is a foreign key.
// Each player belong to a faction.
// Null means default for the universe.
private String factionId = null;
// What role does the player have in the faction?
// Null means default for the universe.
private Rel role = null;
// What title does the player have in the faction?
// The title is just for fun. It's not connected to any game mechanic.
// The player title is similar to the faction description.
//
// Question: Can the title contain chat colors?
// Answer: Yes but in such case the policy is that they already must be parsed using Txt.parse.
// If the title contains raw markup, such as "<white>" instead of "§f" it will not be parsed and "<white>" will be displayed.
//
// Null means the player has no title.
private String title = null;
// Player usually do not have a powerboost. It defaults to 0.
// The powerBoost is a custom increase/decrease to default and maximum power.
// Note that player powerBoost and faction powerBoost are very similar.
private Double powerBoost = null;
// Each player has an individual power level.
// The power level for online players is occasionally updated by a recurring task and the power should stay the same for offline players.
// For that reason the value is to be considered correct when you pick it. Do not call the power update method.
// Null means default for the universe.
private Double power = null;
// The id for the faction this uplayer is currently autoclaiming for.
// NOTE: This field will not be saved to the database ever.
// Null means the player isn't auto claiming.
private transient Faction autoClaimFaction = null;
public Faction getAutoClaimFaction() { return this.autoClaimFaction; }
public void setAutoClaimFaction(Faction autoClaimFaction) { this.autoClaimFaction = autoClaimFaction; }
// -------------------------------------------- //
// FIELDS: MULTIVERSE PROXY
// -------------------------------------------- //
public boolean isMapAutoUpdating() { return MPlayer.get(this).isMapAutoUpdating(); }
public void setMapAutoUpdating(boolean mapAutoUpdating) { MPlayer.get(this).setMapAutoUpdating(mapAutoUpdating); }
public boolean isUsingAdminMode() { return MPlayer.get(this).isUsingAdminMode(); }
public void setUsingAdminMode(boolean usingAdminMode) { MPlayer.get(this).setUsingAdminMode(usingAdminMode); }
// -------------------------------------------- //
// CORE UTILITIES
// -------------------------------------------- //
public void resetFactionData()
{
// The default neutral faction
this.setFactionId(null);
this.setRole(null);
this.setTitle(null);
this.setAutoClaimFaction(null);
}
/*
public boolean isPresent(boolean requireFetchable)
{
if (!this.isOnline()) return false;
if (requireFetchable)
{
}
else
{
}
PS ps = Mixin.getSenderPs(this.getId());
if (ps == null) return false;
String psUniverse = Factions.get().getMultiverse().getUniverseForWorldName(ps.getWorld());
if (!psUniverse.equals(this.getUniverse())) return false;
if (!requireFetchable) return true;
Player player = this.getPlayer();
if (player == null) return false;
if (player.isDead()) return false;
return true;
}
*/
// -------------------------------------------- //
// FIELD: factionId
// -------------------------------------------- //
public String getDefaultFactionId()
{
return UConf.get(this).defaultPlayerFactionId;
}
// This method never returns null
public String getFactionId()
{
if (this.factionId == null) return this.getDefaultFactionId();
return this.factionId;
}
// This method never returns null
public Faction getFaction()
{
Faction ret = FactionColls.get().get(this).get(this.getFactionId());
if (ret == null) ret = FactionColls.get().get(this).get(UConf.get(this).defaultPlayerFactionId);
return ret;
}
public boolean hasFaction()
{
return !this.getFactionId().equals(UConf.get(this).factionIdNone);
}
// This setter is so long because it search for default/null case and takes care of updating the faction member index
public void setFactionId(String factionId)
{
// Clean input
String target = factionId;
// Detect Nochange
if (MUtil.equals(this.factionId, target)) return;
// Get the raw old value
String oldFactionId = this.factionId;
// Apply
this.factionId = target;
// Must be attached and initialized
if (!this.attached()) return;
if (!Factions.get().isDatabaseInitialized()) return;
if (oldFactionId == null) oldFactionId = this.getDefaultFactionId();
// Update index
Faction oldFaction = FactionColls.get().get(this).get(oldFactionId);
Faction faction = this.getFaction();
if (oldFaction != null) oldFaction.uplayers.remove(this);
if (faction != null) faction.uplayers.add(this);
String oldFactionIdDesc = "NULL";
String oldFactionNameDesc = "NULL";
if (oldFaction != null)
{
oldFactionIdDesc = oldFaction.getId();
oldFactionNameDesc = oldFaction.getName();
}
String factionIdDesc = "NULL";
String factionNameDesc = "NULL";
if (faction != null)
{
factionIdDesc = faction.getId();
factionNameDesc = faction.getName();
}
Factions.get().log(Txt.parse("<i>setFactionId moved <h>%s <i>aka <h>%s <i>from <h>%s <i>aka <h>%s <i>to <h>%s <i>aka <h>%s<i>.", this.getId(), this.getDisplayName(IdUtil.getConsole()), oldFactionIdDesc, oldFactionNameDesc, factionIdDesc, factionNameDesc));
// Mark as changed
this.changed();
}
public void setFaction(Faction faction)
{
this.setFactionId(faction.getId());
}
// -------------------------------------------- //
// FIELD: role
// -------------------------------------------- //
public Rel getDefaultRole()
{
return UConf.get(this).defaultPlayerRole;
}
public Rel getRole()
{
if (this.role == null) return this.getDefaultRole();
return this.role;
}
public void setRole(Rel role)
{
// Clean input
Rel target = role;
// Detect Nochange
if (MUtil.equals(this.role, target)) return;
// Apply
this.role = target;
// Mark as changed
this.changed();
}
// -------------------------------------------- //
// FIELD: title
// -------------------------------------------- //
public boolean hasTitle()
{
return this.title != null;
}
public String getTitle()
{
if (this.hasTitle()) return this.title;
return Lang.PLAYER_NOTITLE;
}
public void setTitle(String title)
{
// Clean input
String target = title;
if (target != null)
{
target = target.trim();
if (target.length() == 0)
{
target = null;
}
}
// NOTE: That we parse the title here is considered part of the 1.8 --> 2.0 migration.
// This should be removed once the migration phase is considered to be over.
if (target != null)
{
target = Txt.parse(target);
}
// Detect Nochange
if (MUtil.equals(this.title, target)) return;
// Apply
this.title = target;
// Mark as changed
this.changed();
}
// -------------------------------------------- //
// FIELD: powerBoost
// -------------------------------------------- //
public double getPowerBoost()
{
Double ret = this.powerBoost;
if (ret == null) ret = 0D;
return ret;
}
public void setPowerBoost(Double powerBoost)
{
// Clean input
Double target = powerBoost;
if (target == null || target == 0) target = null;
// Detect Nochange
if (MUtil.equals(this.powerBoost, target)) return;
// Apply
this.powerBoost = target;
// Mark as changed
this.changed();
}
public boolean hasPowerBoost()
{
return this.getPowerBoost() != 0D;
}
// -------------------------------------------- //
// FIELD: power
// -------------------------------------------- //
// MIXIN: RAW
public double getPowerMaxUniversal()
{
return Factions.get().getPowerMixin().getMaxUniversal(this);
}
public double getPowerMax()
{
return Factions.get().getPowerMixin().getMax(this);
}
public double getPowerMin()
{
return Factions.get().getPowerMixin().getMin(this);
}
public double getPowerPerHour()
{
return Factions.get().getPowerMixin().getPerHour(this);
}
public double getPowerPerDeath()
{
return Factions.get().getPowerMixin().getPerDeath(this);
}
// MIXIN: FINER
public double getLimitedPower(double power)
{
power = Math.max(power, this.getPowerMin());
power = Math.min(power, this.getPowerMax());
return power;
}
public int getPowerMaxRounded()
{
return (int) Math.round(this.getPowerMax());
}
public int getPowerMinRounded()
{
return (int) Math.round(this.getPowerMin());
}
public int getPowerMaxUniversalRounded()
{
return (int) Math.round(this.getPowerMaxUniversal());
}
// RAW
public double getDefaultPower()
{
return UConf.get(this).defaultPlayerPower;
}
public double getPower()
{
Double ret = this.power;
if (ret == null) ret = this.getDefaultPower();
ret = this.getLimitedPower(ret);
return ret;
}
public void setPower(Double power)
{
// Clean input
Double target = power;
// Detect Nochange
if (MUtil.equals(this.power, target)) return;
// Apply
this.power = target;
// Mark as changed
this.changed();
}
// FINER
public int getPowerRounded()
{
return (int) Math.round(this.getPower());
}
// -------------------------------------------- //
// TITLE, NAME, FACTION NAME AND CHAT
// -------------------------------------------- //
public String getFactionName()
{
Faction faction = this.getFaction();
if (faction.isNone()) return "";
return faction.getName();
}
// Base concatenations:
public String getNameAndSomething(String color, String something)
{
String ret = "";
ret += color;
ret += this.getRole().getPrefix();
if (something != null && something.length() > 0)
{
ret += something;
ret += " ";
ret += color;
}
ret += this.getName();
return ret;
}
public String getNameAndFactionName()
{
return this.getNameAndSomething("", this.getFactionName());
}
public String getNameAndTitle(String color)
{
if (this.hasTitle())
{
return this.getNameAndSomething(color, this.getTitle());
}
else
{
return this.getNameAndSomething(color, null);
}
}
// Colored concatenations:
// These are used in information messages
public String getNameAndTitle(Faction faction)
{
return this.getNameAndTitle(this.getColorTo(faction).toString());
}
public String getNameAndTitle(UPlayer uplayer)
{
return this.getNameAndTitle(this.getColorTo(uplayer).toString());
}
// -------------------------------------------- //
// RELATION AND RELATION COLORS
// -------------------------------------------- //
@Override
public String describeTo(RelationParticipator observer, boolean ucfirst)
{
return RelationUtil.describeThatToMe(this, observer, ucfirst);
}
@Override
public String describeTo(RelationParticipator observer)
{
return RelationUtil.describeThatToMe(this, observer);
}
@Override
public Rel getRelationTo(RelationParticipator observer)
{
return RelationUtil.getRelationOfThatToMe(this, observer);
}
@Override
public Rel getRelationTo(RelationParticipator observer, boolean ignorePeaceful)
{
return RelationUtil.getRelationOfThatToMe(this, observer, ignorePeaceful);
}
@Override
public ChatColor getColorTo(RelationParticipator observer)
{
return RelationUtil.getColorOfThatToMe(this, observer);
}
// -------------------------------------------- //
// HEALTH
// -------------------------------------------- //
public void heal(int amnt)
{
Player player = this.getPlayer();
if (player == null)
{
return;
}
player.setHealth(player.getHealth() + amnt);
}
// -------------------------------------------- //
// TERRITORY
// -------------------------------------------- //
public boolean isInOwnTerritory()
{
PS ps = Mixin.getSenderPs(this.getId());
if (ps == null) return false;
return BoardColls.get().getFactionAt(ps) == this.getFaction();
}
public boolean isInEnemyTerritory()
{
PS ps = Mixin.getSenderPs(this.getId());
if (ps == null) return false;
return BoardColls.get().getFactionAt(ps).getRelationTo(this) == Rel.ENEMY;
}
// -------------------------------------------- //
// ACTIONS
// -------------------------------------------- //
public void leave()
{
Faction myFaction = this.getFaction();
boolean permanent = myFaction.getFlag(FFlag.PERMANENT);
if (myFaction.getUPlayers().size() > 1)
{
if (!permanent && this.getRole() == Rel.LEADER)
{
msg("<b>You must give the leader role to someone else first.");
return;
}
if (!UConf.get(myFaction).canLeaveWithNegativePower && this.getPower() < 0)
{
msg("<b>You cannot leave until your power is positive.");
return;
}
}
// Event
EventFactionsMembershipChange membershipChangeEvent = new EventFactionsMembershipChange(this.getSender(), this, myFaction, MembershipChangeReason.LEAVE);
membershipChangeEvent.run();
if (membershipChangeEvent.isCancelled()) return;
if (myFaction.isNormal())
{
for (UPlayer uplayer : myFaction.getUPlayersWhereOnline(true))
{
uplayer.msg("%s<i> left %s<i>.", this.describeTo(uplayer, true), myFaction.describeTo(uplayer));
}
if (MConf.get().logFactionLeave)
{
Factions.get().log(this.getName()+" left the faction: "+myFaction.getName());
}
}
this.resetFactionData();
if (myFaction.isNormal() && !permanent && myFaction.getUPlayers().isEmpty())
{
// Remove this faction
for (UPlayer uplayer : UPlayerColls.get().get(this).getAllOnline())
{
uplayer.msg("<i>%s<i> was disbanded.", myFaction.describeTo(uplayer, true));
}
if (MConf.get().logFactionDisband)
{
Factions.get().log("The faction "+myFaction.getName()+" ("+myFaction.getId()+") was disbanded due to the last player ("+this.getName()+") leaving.");
}
myFaction.detach();
}
}
public boolean tryClaim(Faction newFaction, PS ps, boolean verbooseChange, boolean verbooseSame)
{
PS chunk = ps.getChunk(true);
Faction oldFaction = BoardColls.get().getFactionAt(chunk);
UConf uconf = UConf.get(newFaction);
MConf mconf = MConf.get();
// Validate
if (newFaction == oldFaction)
{
msg("%s<i> already owns this land.", newFaction.describeTo(this, true));
return true;
}
if (!this.isUsingAdminMode())
{
if (newFaction.isNormal())
{
if (mconf.getWorldsNoClaiming().contains(ps.getWorld()))
{
msg("<b>Sorry, this world has land claiming disabled.");
return false;
}
if (!FPerm.TERRITORY.has(this, newFaction, true))
{
return false;
}
if (newFaction.getUPlayers().size() < uconf.claimsRequireMinFactionMembers)
{
msg("Factions must have at least <h>%s<b> members to claim land.", uconf.claimsRequireMinFactionMembers);
return false;
}
int ownedLand = newFaction.getLandCount();
if (uconf.claimedLandsMax != 0 && ownedLand >= uconf.claimedLandsMax && ! newFaction.getFlag(FFlag.INFPOWER))
{
msg("<b>Limit reached. You can't claim more land.");
return false;
}
if (ownedLand >= newFaction.getPowerRounded())
{
msg("<b>You can't claim more land. You need more power.");
return false;
}
if
(
uconf.claimsMustBeConnected
&&
newFaction.getLandCountInWorld(ps.getWorld()) > 0
&&
!BoardColls.get().isConnectedPs(chunk, newFaction)
&&
(!uconf.claimsCanBeUnconnectedIfOwnedByOtherFaction || oldFaction.isNone())
)
{
if (uconf.claimsCanBeUnconnectedIfOwnedByOtherFaction)
{
msg("<b>You can only claim additional land which is connected to your first claim or controlled by another faction!");
}
else
{
msg("<b>You can only claim additional land which is connected to your first claim!");
}
return false;
}
}
if (oldFaction.isNormal())
{
if (!FPerm.TERRITORY.has(this, oldFaction, false))
{
if (!uconf.claimingFromOthersAllowed)
{
msg("<b>You may not claim land from others.");
return false;
}
if (oldFaction.getRelationTo(newFaction).isAtLeast(Rel.TRUCE))
{
msg("<b>You can't claim this land due to your relation with the current owner.");
return false;
}
if (!oldFaction.hasLandInflation())
{
msg("%s<i> owns this land and is strong enough to keep it.", oldFaction.getName(this));
return false;
}
if ( ! BoardColls.get().isBorderPs(chunk))
{
msg("<b>You must start claiming land at the border of the territory.");
return false;
}
}
}
}
// Event
EventFactionsChunkChange event = new EventFactionsChunkChange(this.getSender(), chunk, newFaction);
event.run();
if (event.isCancelled()) return false;
// Apply
BoardColls.get().setFactionAt(chunk, newFaction);
// Inform
Set<UPlayer> informees = new HashSet<UPlayer>();
informees.add(this);
if (newFaction.isNormal())
{
informees.addAll(newFaction.getUPlayers());
}
if (oldFaction.isNormal())
{
informees.addAll(oldFaction.getUPlayers());
}
if (MConf.get().logLandClaims)
{
informees.add(UPlayer.get(IdUtil.getConsole()));
}
String chunkString = chunk.toString(PSFormatHumanSpace.get());
String typeString = event.getType().toString().toLowerCase();
for (UPlayer informee : informees)
{
informee.msg("<h>%s<i> did %s %s <i>for <h>%s<i> from <h>%s<i>.", this.describeTo(informee, true), typeString, chunkString, newFaction.describeTo(informee), oldFaction.describeTo(informee));
}
return true;
}
}

View File

@ -1,77 +0,0 @@
package com.massivecraft.factions.entity;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Rel;
import com.massivecraft.massivecore.mixin.Mixin;
import com.massivecraft.massivecore.store.MStore;
import com.massivecraft.massivecore.store.SenderColl;
import com.massivecraft.massivecore.util.IdUtil;
import com.massivecraft.massivecore.util.TimeUnit;
import com.massivecraft.massivecore.util.Txt;
public class UPlayerColl extends SenderColl<UPlayer>
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public UPlayerColl(String name)
{
super(name, UPlayer.class, MStore.getDb(), Factions.get());
}
// -------------------------------------------- //
// EXTRAS
// -------------------------------------------- //
public void clean()
{
FactionColl factionColl = FactionColls.get().get(this);
String universe = this.getUniverse();
for (UPlayer uplayer : this.getAll())
{
String factionId = uplayer.getFactionId();
if (factionColl.containsId(factionId)) continue;
uplayer.resetFactionData();
String message = Txt.parse("<i>Reset data for <h>%s <i>in <h>%s <i>universe. Unknown factionId <h>%s", uplayer.getDisplayName(IdUtil.getConsole()), universe, factionId);
Factions.get().log(message);
}
}
public void removePlayerDataAfterInactiveDaysRoutine()
{
if (MConf.get().removePlayerDataAfterInactiveDays <= 0.0) return;
long now = System.currentTimeMillis();
double toleranceMillis = MConf.get().removePlayerDataAfterInactiveDays * TimeUnit.MILLIS_PER_DAY;
for (UPlayer uplayer : this.getAll())
{
Long lastPlayed = Mixin.getLastPlayed(uplayer.getId());
if (lastPlayed == null) continue;
if (uplayer.isOnline()) continue;
if (now - lastPlayed <= toleranceMillis) continue;
if (MConf.get().logFactionLeave || MConf.get().logFactionKick)
{
Factions.get().log("Player "+uplayer.getName()+" was auto-removed due to inactivity.");
}
// if player is faction leader, sort out the faction since he's going away
if (uplayer.getRole() == Rel.LEADER)
{
Faction faction = uplayer.getFaction();
if (faction != null)
{
uplayer.getFaction().promoteNewLeader();
}
}
uplayer.leave();
uplayer.detach();
}
}
}

View File

@ -1,95 +0,0 @@
package com.massivecraft.factions.entity;
import java.io.File;
import java.lang.reflect.Type;
import java.util.Map;
import java.util.Map.Entry;
import com.massivecraft.factions.Const;
import com.massivecraft.factions.Factions;
import com.massivecraft.massivecore.Aspect;
import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.util.DiscUtil;
import com.massivecraft.massivecore.xlib.gson.reflect.TypeToken;
public class UPlayerColls extends XColls<UPlayerColl, UPlayer>
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static UPlayerColls i = new UPlayerColls();
public static UPlayerColls get() { return i; }
// -------------------------------------------- //
// OVERRIDE: COLLS
// -------------------------------------------- //
@Override
public UPlayerColl createColl(String collName)
{
return new UPlayerColl(collName);
}
@Override
public Aspect getAspect()
{
return Factions.get().getAspect();
}
@Override
public String getBasename()
{
return Const.COLLECTION_UPLAYER;
}
@Override
public void init()
{
super.init();
this.migrate();
}
// This method is for the 1.8.X --> 2.0.0 migration
public void migrate()
{
// Create file objects
File oldFile = new File(Factions.get().getDataFolder(), "players.json");
File newFile = new File(Factions.get().getDataFolder(), "players.json.migrated");
// Already migrated?
if ( ! oldFile.exists()) return;
// Read the file content through GSON.
Type type = new TypeToken<Map<String, UPlayer>>(){}.getType();
Map<String, UPlayer> id2uplayer = Factions.get().gson.fromJson(DiscUtil.readCatch(oldFile), type);
// The Coll
UPlayerColl coll = this.getForUniverse(MassiveCore.DEFAULT);
// Set the data
for (Entry<String, UPlayer> entry : id2uplayer.entrySet())
{
String playerId = entry.getKey();
UPlayer uplayer = entry.getValue();
coll.attach(uplayer, playerId);
}
// Mark as migrated
oldFile.renameTo(newFile);
}
// -------------------------------------------- //
// EXTRAS
// -------------------------------------------- //
public void clean()
{
for (UPlayerColl coll : this.getColls())
{
coll.clean();
}
}
}

View File

@ -1,42 +0,0 @@
package com.massivecraft.factions.entity;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.massivecraft.massivecore.store.Coll;
import com.massivecraft.massivecore.store.Colls;
import com.massivecraft.massivecore.store.Entity;
import com.massivecraft.massivecore.util.MUtil;
public abstract class XColls<C extends Coll<E>, E> extends Colls<C, E>
{
@Override
public C get(Object o)
{
if (o == null) return null;
if (o instanceof Entity)
{
String universe = ((Entity<?>)o).getUniverse();
if (universe == null) return null;
return this.getForUniverse(universe);
}
if (o instanceof Coll)
{
String universe = ((Coll<?>)o).getUniverse();
if (universe == null) return null;
return this.getForUniverse(universe);
}
if ((o instanceof CommandSender) && !(o instanceof Player))
{
return this.getForWorld(Bukkit.getWorlds().get(0).getName());
}
String worldName = MUtil.extract(String.class, "worldName", o);
if (worldName == null) return null;
return this.getForWorld(worldName);
}
}

View File

@ -2,7 +2,7 @@ package com.massivecraft.factions.event;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.massivecore.event.EventMassiveCore; import com.massivecraft.massivecore.event.EventMassiveCore;
public abstract class EventFactionsAbstractSender extends EventMassiveCore public abstract class EventFactionsAbstractSender extends EventMassiveCore
@ -13,7 +13,7 @@ public abstract class EventFactionsAbstractSender extends EventMassiveCore
private final CommandSender sender; private final CommandSender sender;
public CommandSender getSender() { return this.sender; } public CommandSender getSender() { return this.sender; }
public UPlayer getUSender() { return this.sender == null ? null : UPlayer.get(this.sender); } public MPlayer getUSender() { return this.sender == null ? null : MPlayer.get(this.sender); }
// -------------------------------------------- // // -------------------------------------------- //
// CONSTRUCT // CONSTRUCT

View File

@ -3,9 +3,9 @@ package com.massivecraft.factions.event;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import com.massivecraft.factions.entity.BoardColls; import com.massivecraft.factions.entity.BoardColl;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.ps.PS;
public class EventFactionsChunkChange extends EventFactionsAbstractSender public class EventFactionsChunkChange extends EventFactionsAbstractSender
@ -37,7 +37,7 @@ public class EventFactionsChunkChange extends EventFactionsAbstractSender
{ {
super(sender); super(sender);
this.chunk = chunk.getChunk(true); this.chunk = chunk.getChunk(true);
this.currentFaction = BoardColls.get().getFactionAt(chunk); this.currentFaction = BoardColl.get().getFactionAt(chunk);
this.newFaction = newFaction; this.newFaction = newFaction;
} }
@ -50,7 +50,7 @@ public class EventFactionsChunkChange extends EventFactionsAbstractSender
if (currentFaction.isNone()) return EventFactionsChunkChangeType.BUY; if (currentFaction.isNone()) return EventFactionsChunkChangeType.BUY;
if (newFaction.isNormal()) return EventFactionsChunkChangeType.CONQUER; if (newFaction.isNormal()) return EventFactionsChunkChangeType.CONQUER;
UPlayer usender = this.getUSender(); MPlayer usender = this.getUSender();
if (usender != null && usender.getFaction() == currentFaction) return EventFactionsChunkChangeType.SELL; if (usender != null && usender.getFaction() == currentFaction) return EventFactionsChunkChangeType.SELL;
return EventFactionsChunkChangeType.PILLAGE; return EventFactionsChunkChangeType.PILLAGE;

View File

@ -17,9 +17,6 @@ public class EventFactionsCreate extends EventFactionsAbstractSender
// FIELDS // FIELDS
// -------------------------------------------- // // -------------------------------------------- //
private final String universe;
public final String getUniverse() { return this.universe; }
private final String factionId; private final String factionId;
public final String getFactionId() { return this.factionId; } public final String getFactionId() { return this.factionId; }
@ -30,10 +27,9 @@ public class EventFactionsCreate extends EventFactionsAbstractSender
// CONSTRUCT // CONSTRUCT
// -------------------------------------------- // // -------------------------------------------- //
public EventFactionsCreate(CommandSender sender, String universe, String factionId, String factionName) public EventFactionsCreate(CommandSender sender, String factionId, String factionName)
{ {
super(sender); super(sender);
this.universe = universe;
this.factionId = factionId; this.factionId = factionId;
this.factionName = factionName; this.factionName = factionName;
} }

View File

@ -3,7 +3,7 @@ package com.massivecraft.factions.event;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
public class EventFactionsInvitedChange extends EventFactionsAbstractSender public class EventFactionsInvitedChange extends EventFactionsAbstractSender
@ -20,8 +20,8 @@ public class EventFactionsInvitedChange extends EventFactionsAbstractSender
// FIELDS // FIELDS
// -------------------------------------------- // // -------------------------------------------- //
private final UPlayer uplayer; private final MPlayer uplayer;
public UPlayer getUPlayer() { return this.uplayer; } public MPlayer getUPlayer() { return this.uplayer; }
private final Faction faction; private final Faction faction;
public Faction getFaction() { return this.faction; } public Faction getFaction() { return this.faction; }
@ -34,7 +34,7 @@ public class EventFactionsInvitedChange extends EventFactionsAbstractSender
// CONSTRUCT // CONSTRUCT
// -------------------------------------------- // // -------------------------------------------- //
public EventFactionsInvitedChange(CommandSender sender, UPlayer uplayer, Faction faction, boolean newInvited) public EventFactionsInvitedChange(CommandSender sender, MPlayer uplayer, Faction faction, boolean newInvited)
{ {
super(sender); super(sender);
this.uplayer = uplayer; this.uplayer = uplayer;

View File

@ -3,7 +3,7 @@ package com.massivecraft.factions.event;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
public class EventFactionsMembershipChange extends EventFactionsAbstractSender public class EventFactionsMembershipChange extends EventFactionsAbstractSender
@ -27,8 +27,8 @@ public class EventFactionsMembershipChange extends EventFactionsAbstractSender
super.setCancelled(cancelled); super.setCancelled(cancelled);
} }
private final UPlayer uplayer; private final MPlayer uplayer;
public UPlayer getUPlayer() { return this.uplayer; } public MPlayer getUPlayer() { return this.uplayer; }
private final Faction newFaction; private final Faction newFaction;
public Faction getNewFaction() { return this.newFaction; } public Faction getNewFaction() { return this.newFaction; }
@ -40,7 +40,7 @@ public class EventFactionsMembershipChange extends EventFactionsAbstractSender
// CONSTRUCT // CONSTRUCT
// -------------------------------------------- // // -------------------------------------------- //
public EventFactionsMembershipChange(CommandSender sender, UPlayer uplayer, Faction newFaction, MembershipChangeReason reason) public EventFactionsMembershipChange(CommandSender sender, MPlayer uplayer, Faction newFaction, MembershipChangeReason reason)
{ {
super(sender); super(sender);
this.uplayer = uplayer; this.uplayer = uplayer;

View File

@ -3,7 +3,7 @@ package com.massivecraft.factions.event;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.MPlayer;
public class EventFactionsPowerChange extends EventFactionsAbstractSender public class EventFactionsPowerChange extends EventFactionsAbstractSender
{ {
@ -19,8 +19,8 @@ public class EventFactionsPowerChange extends EventFactionsAbstractSender
// FIELDS // FIELDS
// -------------------------------------------- // // -------------------------------------------- //
private final UPlayer uplayer; private final MPlayer uplayer;
public UPlayer getUPlayer() { return this.uplayer; } public MPlayer getUPlayer() { return this.uplayer; }
private final PowerChangeReason reason; private final PowerChangeReason reason;
public PowerChangeReason getReason() { return this.reason; } public PowerChangeReason getReason() { return this.reason; }
@ -33,7 +33,7 @@ public class EventFactionsPowerChange extends EventFactionsAbstractSender
// CONSTRUCT // CONSTRUCT
// -------------------------------------------- // // -------------------------------------------- //
public EventFactionsPowerChange(CommandSender sender, UPlayer uplayer, PowerChangeReason reason, double newPower) public EventFactionsPowerChange(CommandSender sender, MPlayer uplayer, PowerChangeReason reason, double newPower)
{ {
super(sender); super(sender);
this.uplayer = uplayer; this.uplayer = uplayer;

View File

@ -4,7 +4,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.MPlayer;
/** /**
* This event is fired when PVP is disallowed between players due to any rules in Factions. * This event is fired when PVP is disallowed between players due to any rules in Factions.
@ -29,11 +29,11 @@ public class EventFactionsPvpDisallowed extends EventFactionsAbstract
private final Player attacker; private final Player attacker;
public Player getAttacker() { return this.attacker; } public Player getAttacker() { return this.attacker; }
public UPlayer getUAttacker() { return this.attacker == null ? null : UPlayer.get(this.attacker); } public MPlayer getUAttacker() { return this.attacker == null ? null : MPlayer.get(this.attacker); }
private final Player defender; private final Player defender;
public Player getDefender() { return this.defender; } public Player getDefender() { return this.defender; }
public UPlayer getUDefender() { return this.defender == null ? null : UPlayer.get(this.defender); } public MPlayer getUDefender() { return this.defender == null ? null : MPlayer.get(this.defender); }
private final EntityDamageByEntityEvent event; private final EntityDamageByEntityEvent event;
public EntityDamageByEntityEvent getEvent() { return this.event; } public EntityDamageByEntityEvent getEvent() { return this.event; }

View File

@ -3,7 +3,7 @@ package com.massivecraft.factions.event;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.MPlayer;
public class EventFactionsTitleChange extends EventFactionsAbstractSender public class EventFactionsTitleChange extends EventFactionsAbstractSender
{ {
@ -19,8 +19,8 @@ public class EventFactionsTitleChange extends EventFactionsAbstractSender
// FIELDS // FIELDS
// -------------------------------------------- // // -------------------------------------------- //
private final UPlayer uplayer; private final MPlayer uplayer;
public UPlayer getUPlayer() { return this.uplayer; } public MPlayer getUPlayer() { return this.uplayer; }
private String newTitle; private String newTitle;
public String getNewTitle() { return this.newTitle; } public String getNewTitle() { return this.newTitle; }
@ -30,7 +30,7 @@ public class EventFactionsTitleChange extends EventFactionsAbstractSender
// CONSTRUCT // CONSTRUCT
// -------------------------------------------- // // -------------------------------------------- //
public EventFactionsTitleChange(CommandSender sender, UPlayer uplayer, String newTitle) public EventFactionsTitleChange(CommandSender sender, MPlayer uplayer, String newTitle)
{ {
super(sender); super(sender);
this.uplayer = uplayer; this.uplayer = uplayer;

View File

@ -5,8 +5,8 @@ import java.util.Set;
import com.massivecraft.factions.EconomyParticipator; import com.massivecraft.factions.EconomyParticipator;
import com.massivecraft.factions.FPerm; import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.entity.UConf; import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.util.RelationUtil; import com.massivecraft.factions.util.RelationUtil;
import com.massivecraft.massivecore.money.Money; import com.massivecraft.massivecore.money.Money;
@ -17,27 +17,25 @@ public class Econ
// STATE // STATE
// -------------------------------------------- // // -------------------------------------------- //
// TODO: Do we really need that config option? public static boolean isEnabled()
// TODO: Could we not have it enabled as long as Money.enabled is true?
public static boolean isEnabled(Object universe)
{ {
return UConf.get(universe).econEnabled && Money.enabled(); return MConf.get().econEnabled && Money.enabled();
} }
// -------------------------------------------- // // -------------------------------------------- //
// UTIL // UTIL
// -------------------------------------------- // // -------------------------------------------- //
public static boolean payForAction(double cost, UPlayer usender, String actionDescription) public static boolean payForAction(double cost, MPlayer usender, String actionDescription)
{ {
if (!isEnabled(usender)) return true; if (!isEnabled()) return true;
if (cost == 0D) return true; if (cost == 0D) return true;
if (usender.isUsingAdminMode()) return true; if (usender.isUsingAdminMode()) return true;
UConf uconf = UConf.get(usender);
Faction usenderFaction = usender.getFaction(); Faction usenderFaction = usender.getFaction();
if (uconf.bankEnabled && uconf.bankFactionPaysCosts && usenderFaction.isNormal()) if (MConf.get().bankEnabled && MConf.get().bankFactionPaysCosts && usenderFaction.isNormal())
{ {
return modifyMoney(usenderFaction, -cost, actionDescription); return modifyMoney(usenderFaction, -cost, actionDescription);
} }
@ -53,18 +51,17 @@ public class Econ
public static void modifyUniverseMoney(Object universe, double delta) public static void modifyUniverseMoney(Object universe, double delta)
{ {
if (!isEnabled(universe)) return; if (!isEnabled()) return;
UConf uconf = UConf.get(universe);
if (uconf.econUniverseAccount == null) return; if (MConf.get().econUniverseAccount == null) return;
if (uconf.econUniverseAccount.length() == 0) return; if (MConf.get().econUniverseAccount.length() == 0) return;
if (!Money.exists(uconf.econUniverseAccount)) return; if (!Money.exists(MConf.get().econUniverseAccount)) return;
Money.spawn(uconf.econUniverseAccount, null, delta); Money.spawn(MConf.get().econUniverseAccount, null, delta);
} }
public static void sendBalanceInfo(UPlayer to, EconomyParticipator about) public static void sendBalanceInfo(MPlayer to, EconomyParticipator about)
{ {
to.msg("<a>%s's<i> balance is <h>%s<i>.", about.describeTo(to, true), Money.format(Money.get(about))); to.msg("<a>%s's<i> balance is <h>%s<i>.", about.describeTo(to, true), Money.format(Money.get(about)));
} }
@ -78,7 +75,7 @@ public class Econ
if (fI == null) return true; if (fI == null) return true;
// Bypassing players can do any kind of transaction // Bypassing players can do any kind of transaction
if (i instanceof UPlayer && ((UPlayer)i).isUsingAdminMode()) return true; if (i instanceof MPlayer && ((MPlayer)i).isUsingAdminMode()) return true;
// You can deposit to anywhere you feel like. It's your loss if you can't withdraw it again. // You can deposit to anywhere you feel like. It's your loss if you can't withdraw it again.
if (i == you) return true; if (i == you) return true;
@ -92,7 +89,7 @@ public class Econ
if (you instanceof Faction) if (you instanceof Faction)
{ {
if (i instanceof Faction && FPerm.WITHDRAW.has((Faction)i, fYou)) return true; if (i instanceof Faction && FPerm.WITHDRAW.has((Faction)i, fYou)) return true;
if (i instanceof UPlayer && FPerm.WITHDRAW.has((UPlayer)i, fYou, false)) return true; if (i instanceof MPlayer && FPerm.WITHDRAW.has((MPlayer)i, fYou, false)) return true;
} }
// Otherwise you may not! ;,,; // Otherwise you may not! ;,,;
@ -105,7 +102,7 @@ public class Econ
} }
public static boolean transferMoney(EconomyParticipator from, EconomyParticipator to, EconomyParticipator by, double amount, boolean notify) public static boolean transferMoney(EconomyParticipator from, EconomyParticipator to, EconomyParticipator by, double amount, boolean notify)
{ {
if (!isEnabled(from)) return false; if (!isEnabled()) return false;
// The amount must be positive. // The amount must be positive.
// If the amount is negative we must flip and multiply amount with -1. // If the amount is negative we must flip and multiply amount with -1.
@ -155,17 +152,17 @@ public class Econ
} }
} }
public static Set<UPlayer> getUPlayers(EconomyParticipator ep) public static Set<MPlayer> getUPlayers(EconomyParticipator ep)
{ {
Set<UPlayer> uplayers = new HashSet<UPlayer>(); Set<MPlayer> uplayers = new HashSet<MPlayer>();
if (ep == null) if (ep == null)
{ {
// Add nothing // Add nothing
} }
else if (ep instanceof UPlayer) else if (ep instanceof MPlayer)
{ {
uplayers.add((UPlayer)ep); uplayers.add((MPlayer)ep);
} }
else if (ep instanceof Faction) else if (ep instanceof Faction)
{ {
@ -177,35 +174,35 @@ public class Econ
public static void sendTransferInfo(EconomyParticipator invoker, EconomyParticipator from, EconomyParticipator to, double amount) public static void sendTransferInfo(EconomyParticipator invoker, EconomyParticipator from, EconomyParticipator to, double amount)
{ {
Set<UPlayer> recipients = new HashSet<UPlayer>(); Set<MPlayer> recipients = new HashSet<MPlayer>();
recipients.addAll(getUPlayers(invoker)); recipients.addAll(getUPlayers(invoker));
recipients.addAll(getUPlayers(from)); recipients.addAll(getUPlayers(from));
recipients.addAll(getUPlayers(to)); recipients.addAll(getUPlayers(to));
if (invoker == null) if (invoker == null)
{ {
for (UPlayer recipient : recipients) for (MPlayer recipient : recipients)
{ {
recipient.msg("<h>%s<i> was transfered from <h>%s<i> to <h>%s<i>.", Money.format(amount), from.describeTo(recipient), to.describeTo(recipient)); recipient.msg("<h>%s<i> was transfered from <h>%s<i> to <h>%s<i>.", Money.format(amount), from.describeTo(recipient), to.describeTo(recipient));
} }
} }
else if (invoker == from) else if (invoker == from)
{ {
for (UPlayer recipient : recipients) for (MPlayer recipient : recipients)
{ {
recipient.msg("<h>%s<i> <h>gave %s<i> to <h>%s<i>.", from.describeTo(recipient, true), Money.format(amount), to.describeTo(recipient)); recipient.msg("<h>%s<i> <h>gave %s<i> to <h>%s<i>.", from.describeTo(recipient, true), Money.format(amount), to.describeTo(recipient));
} }
} }
else if (invoker == to) else if (invoker == to)
{ {
for (UPlayer recipient : recipients) for (MPlayer recipient : recipients)
{ {
recipient.msg("<h>%s<i> <h>took %s<i> from <h>%s<i>.", to.describeTo(recipient, true), Money.format(amount), from.describeTo(recipient)); recipient.msg("<h>%s<i> <h>took %s<i> from <h>%s<i>.", to.describeTo(recipient, true), Money.format(amount), from.describeTo(recipient));
} }
} }
else else
{ {
for (UPlayer recipient : recipients) for (MPlayer recipient : recipients)
{ {
recipient.msg("<h>%s<i> transfered <h>%s<i> from <h>%s<i> to <h>%s<i>.", invoker.describeTo(recipient, true), Money.format(amount), from.describeTo(recipient), to.describeTo(recipient)); recipient.msg("<h>%s<i> transfered <h>%s<i> from <h>%s<i> to <h>%s<i>.", invoker.describeTo(recipient, true), Money.format(amount), from.describeTo(recipient), to.describeTo(recipient));
} }
@ -214,7 +211,7 @@ public class Econ
public static boolean hasAtLeast(EconomyParticipator ep, double delta, String toDoThis) public static boolean hasAtLeast(EconomyParticipator ep, double delta, String toDoThis)
{ {
if (!isEnabled(ep)) return true; if (!isEnabled()) return true;
if (Money.get(ep) < delta) if (Money.get(ep) < delta)
{ {
@ -229,7 +226,7 @@ public class Econ
public static boolean modifyMoney(EconomyParticipator ep, double delta, String actionDescription) public static boolean modifyMoney(EconomyParticipator ep, double delta, String actionDescription)
{ {
if (!isEnabled(ep)) return false; if (!isEnabled()) return false;
if (delta == 0) return true; if (delta == 0) return true;
String You = ep.describeTo(ep, true); String You = ep.describeTo(ep, true);

View File

@ -28,13 +28,10 @@ import com.massivecraft.factions.Rel;
import com.massivecraft.factions.TerritoryAccess; import com.massivecraft.factions.TerritoryAccess;
import com.massivecraft.factions.entity.Board; import com.massivecraft.factions.entity.Board;
import com.massivecraft.factions.entity.BoardColl; import com.massivecraft.factions.entity.BoardColl;
import com.massivecraft.factions.entity.BoardColls;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColl; import com.massivecraft.factions.entity.FactionColl;
import com.massivecraft.factions.entity.FactionColls;
import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.entity.UConf; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.massivecore.EngineAbstract; import com.massivecraft.massivecore.EngineAbstract;
import com.massivecraft.massivecore.money.Money; import com.massivecraft.massivecore.money.Money;
import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.ps.PS;
@ -241,28 +238,25 @@ public class EngineDynmap extends EngineAbstract
Map<String, TempMarker> ret = new HashMap<String, TempMarker>(); Map<String, TempMarker> ret = new HashMap<String, TempMarker>();
// Loop current factions // Loop current factions
for (FactionColl coll : FactionColls.get().getColls()) for (Faction faction : FactionColl.get().getAll())
{ {
for (Faction faction : coll.getAll()) PS ps = faction.getHome();
{ if (ps == null) continue;
PS ps = faction.getHome();
if (ps == null) continue;
DynmapStyle style = getStyle(faction); DynmapStyle style = getStyle(faction);
String markerId = FACTIONS_HOME_ + faction.getId(); String markerId = FACTIONS_HOME_ + faction.getId();
TempMarker temp = new TempMarker(); TempMarker temp = new TempMarker();
temp.label = ChatColor.stripColor(faction.getName()); temp.label = ChatColor.stripColor(faction.getName());
temp.world = ps.getWorld(); temp.world = ps.getWorld();
temp.x = ps.getLocationX(); temp.x = ps.getLocationX();
temp.y = ps.getLocationY(); temp.y = ps.getLocationY();
temp.z = ps.getLocationZ(); temp.z = ps.getLocationZ();
temp.iconName = style.getHomeMarker(); temp.iconName = style.getHomeMarker();
temp.description = getDescription(faction); temp.description = getDescription(faction);
ret.put(markerId, temp); ret.put(markerId, temp);
}
} }
return ret; return ret;
@ -327,42 +321,41 @@ public class EngineDynmap extends EngineAbstract
{ {
// Create map "world name --> faction --> set of chunk coords" // Create map "world name --> faction --> set of chunk coords"
Map<String, Map<Faction, Set<PS>>> worldFactionChunks = new HashMap<String, Map<Faction, Set<PS>>>(); Map<String, Map<Faction, Set<PS>>> worldFactionChunks = new HashMap<String, Map<Faction, Set<PS>>>();
for (BoardColl coll : BoardColls.get().getColls())
// Note: The board is the world. The board id is the world name.
for (Board board : BoardColl.get().getAll())
{ {
// Note: The board is the world. The board id is the world name. String world = board.getId();
for (Board board : coll.getAll())
// Get the factionChunks creatively.
Map<Faction, Set<PS>> factionChunks = worldFactionChunks.get(world);
if (factionChunks == null)
{ {
String world = board.getId(); factionChunks = new HashMap<Faction, Set<PS>>();
worldFactionChunks.put(world, factionChunks);
}
// Get the factionChunks creatively. // Populate the factionChunks
Map<Faction, Set<PS>> factionChunks = worldFactionChunks.get(world); for (Entry<PS, TerritoryAccess> entry : board.getMap().entrySet())
if (factionChunks == null) {
PS chunk = entry.getKey();
TerritoryAccess territoryAccess = entry.getValue();
String factionId = territoryAccess.getHostFactionId();
Faction faction = Faction.get(factionId);
if (faction == null) continue;
// Get the chunks creatively.
Set<PS> chunks = factionChunks.get(faction);
if (chunks == null)
{ {
factionChunks = new HashMap<Faction, Set<PS>>(); chunks = new HashSet<PS>();
worldFactionChunks.put(world, factionChunks); factionChunks.put(faction, chunks);
} }
// Populate the factionChunks chunks.add(chunk);
for (Entry<PS, TerritoryAccess> entry : board.getMap().entrySet())
{
PS chunk = entry.getKey();
TerritoryAccess territoryAccess = entry.getValue();
String factionId = territoryAccess.getHostFactionId();
Faction faction = FactionColls.get().getForWorld(world).get(factionId);
if (faction == null) continue;
// Get the chunks creatively.
Set<PS> chunks = factionChunks.get(faction);
if (chunks == null)
{
chunks = new HashSet<PS>();
factionChunks.put(faction, chunks);
}
chunks.add(chunk);
}
} }
} }
return worldFactionChunks; return worldFactionChunks;
} }
@ -659,7 +652,7 @@ public class EngineDynmap extends EngineAbstract
Set<String> ret = new HashSet<String>(); Set<String> ret = new HashSet<String>();
for (UPlayer uplayer : faction.getUPlayers()) for (MPlayer uplayer : faction.getUPlayers())
{ {
// NOTE: We add both UUID and name. This might be a good idea for future proofing. // NOTE: We add both UUID and name. This might be a good idea for future proofing.
ret.add(uplayer.getId()); ret.add(uplayer.getId());
@ -676,16 +669,13 @@ public class EngineDynmap extends EngineAbstract
Map<String, Set<String>> ret = new HashMap<String, Set<String>>(); Map<String, Set<String>> ret = new HashMap<String, Set<String>>();
for (FactionColl coll : FactionColls.get().getColls()) for (Faction faction : FactionColl.get().getAll())
{ {
for (Faction faction : coll.getAll()) String playersetId = createPlayersetId(faction);
{ if (playersetId == null) continue;
String playersetId = createPlayersetId(faction); Set<String> playerIds = createPlayerset(faction);
if (playersetId == null) continue; if (playerIds == null) continue;
Set<String> playerIds = createPlayerset(faction); ret.put(playersetId, playerIds);
if (playerIds == null) continue;
ret.put(playersetId, playerIds);
}
} }
return ret; return ret;
@ -761,7 +751,7 @@ public class EngineDynmap extends EngineAbstract
// Money // Money
String money = "unavailable"; String money = "unavailable";
if (UConf.get(faction).bankEnabled && MConf.get().dynmapDescriptionMoney) if (MConf.get().bankEnabled && MConf.get().dynmapDescriptionMoney)
{ {
money = Money.format(Money.get(faction)); money = Money.format(Money.get(faction));
} }
@ -789,22 +779,22 @@ public class EngineDynmap extends EngineAbstract
} }
// Players // Players
List<UPlayer> playersList = faction.getUPlayers(); List<MPlayer> playersList = faction.getUPlayers();
String playersCount = String.valueOf(playersList.size()); String playersCount = String.valueOf(playersList.size());
String players = getPlayerString(playersList); String players = getPlayerString(playersList);
UPlayer playersLeaderObject = faction.getLeader(); MPlayer playersLeaderObject = faction.getLeader();
String playersLeader = getPlayerName(playersLeaderObject); String playersLeader = getPlayerName(playersLeaderObject);
List<UPlayer> playersOfficersList = faction.getUPlayersWhereRole(Rel.OFFICER); List<MPlayer> playersOfficersList = faction.getUPlayersWhereRole(Rel.OFFICER);
String playersOfficersCount = String.valueOf(playersOfficersList.size()); String playersOfficersCount = String.valueOf(playersOfficersList.size());
String playersOfficers = getPlayerString(playersOfficersList); String playersOfficers = getPlayerString(playersOfficersList);
List<UPlayer> playersMembersList = faction.getUPlayersWhereRole(Rel.MEMBER); List<MPlayer> playersMembersList = faction.getUPlayersWhereRole(Rel.MEMBER);
String playersMembersCount = String.valueOf(playersMembersList.size()); String playersMembersCount = String.valueOf(playersMembersList.size());
String playersMembers = getPlayerString(playersMembersList); String playersMembers = getPlayerString(playersMembersList);
List<UPlayer> playersRecruitsList = faction.getUPlayersWhereRole(Rel.RECRUIT); List<MPlayer> playersRecruitsList = faction.getUPlayersWhereRole(Rel.RECRUIT);
String playersRecruitsCount = String.valueOf(playersRecruitsList.size()); String playersRecruitsCount = String.valueOf(playersRecruitsList.size());
String playersRecruits = getPlayerString(playersRecruitsList); String playersRecruits = getPlayerString(playersRecruitsList);
@ -822,10 +812,10 @@ public class EngineDynmap extends EngineAbstract
return ret; return ret;
} }
public static String getPlayerString(List<UPlayer> uplayers) public static String getPlayerString(List<MPlayer> uplayers)
{ {
String ret = ""; String ret = "";
for (UPlayer uplayer : uplayers) for (MPlayer uplayer : uplayers)
{ {
if (ret.length() > 0) ret += ", "; if (ret.length() > 0) ret += ", ";
ret += getPlayerName(uplayer); ret += getPlayerName(uplayer);
@ -833,7 +823,7 @@ public class EngineDynmap extends EngineAbstract
return ret; return ret;
} }
public static String getPlayerName(UPlayer uplayer) public static String getPlayerName(MPlayer uplayer)
{ {
if (uplayer == null) return "none"; if (uplayer == null) return "none";
return escapeHtml(uplayer.getName()); return escapeHtml(uplayer.getName());

View File

@ -23,7 +23,7 @@ import com.dthielke.herochat.Herochat;
import com.dthielke.herochat.MessageFormatSupplier; import com.dthielke.herochat.MessageFormatSupplier;
import com.dthielke.herochat.MessageNotFoundException; import com.dthielke.herochat.MessageNotFoundException;
import com.massivecraft.factions.Rel; import com.massivecraft.factions.Rel;
import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
public abstract class ChannelFactionsAbstract implements Channel public abstract class ChannelFactionsAbstract implements Channel
@ -228,13 +228,13 @@ public abstract class ChannelFactionsAbstract implements Channel
{ {
Set<Player> ret = new HashSet<Player>(); Set<Player> ret = new HashSet<Player>();
UPlayer fpsender = UPlayer.get(sender); MPlayer fpsender = MPlayer.get(sender);
Faction faction = fpsender.getFaction(); Faction faction = fpsender.getFaction();
String universe = fpsender.getUniverse(); String universe = fpsender.getUniverse();
for (Player player : Bukkit.getOnlinePlayers()) for (Player player : Bukkit.getOnlinePlayers())
{ {
UPlayer frecipient = UPlayer.get(player); MPlayer frecipient = MPlayer.get(player);
if (!frecipient.getUniverse().equals(universe)) continue; if (!frecipient.getUniverse().equals(universe)) continue;
if (!this.getTargetRelations().contains(faction.getRelationTo(frecipient))) continue; if (!this.getTargetRelations().contains(faction.getRelationTo(frecipient))) continue;
ret.add(player); ret.add(player);

View File

@ -17,8 +17,8 @@ import com.griefcraft.lwc.LWC;
import com.griefcraft.model.Protection; import com.griefcraft.model.Protection;
import com.massivecraft.factions.Factions; import com.massivecraft.factions.Factions;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.UConf; import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.event.EventFactionsChunkChange; import com.massivecraft.factions.event.EventFactionsChunkChange;
import com.massivecraft.factions.event.EventFactionsChunkChangeType; import com.massivecraft.factions.event.EventFactionsChunkChangeType;
import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.ps.PS;
@ -57,9 +57,8 @@ public class EngineLwc implements Listener
{ {
// If we are supposed to clear at this chunk change type ... // If we are supposed to clear at this chunk change type ...
Faction newFaction = event.getNewFaction(); Faction newFaction = event.getNewFaction();
UConf uconf = UConf.get(newFaction);
EventFactionsChunkChangeType type = event.getType(); EventFactionsChunkChangeType type = event.getType();
Boolean remove = uconf.lwcRemoveOnChange.get(type); Boolean remove = MConf.get().lwcRemoveOnChange.get(type);
if (remove == null) return; if (remove == null) return;
if (remove == false) return; if (remove == false) return;
@ -73,10 +72,10 @@ public class EngineLwc implements Listener
public static void removeAlienProtections(PS chunkPs, Faction faction) public static void removeAlienProtections(PS chunkPs, Faction faction)
{ {
List<UPlayer> nonAliens = faction.getUPlayers(); List<MPlayer> nonAliens = faction.getUPlayers();
for (Protection protection : getProtectionsInChunk(chunkPs)) for (Protection protection : getProtectionsInChunk(chunkPs))
{ {
UPlayer owner = UPlayer.get(protection.getOwner()); MPlayer owner = MPlayer.get(protection.getOwner());
if (nonAliens.contains(owner)) continue; if (nonAliens.contains(owner)) continue;
protection.remove(); protection.remove();
} }

View File

@ -7,8 +7,8 @@ import org.bukkit.event.Listener;
import com.massivecraft.factions.Factions; import com.massivecraft.factions.Factions;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.UConf; import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.event.EventFactionsAbstractSender; import com.massivecraft.factions.event.EventFactionsAbstractSender;
import com.massivecraft.factions.event.EventFactionsChunkChange; import com.massivecraft.factions.event.EventFactionsChunkChange;
import com.massivecraft.factions.event.EventFactionsChunkChangeType; import com.massivecraft.factions.event.EventFactionsChunkChangeType;
@ -57,7 +57,7 @@ public class FactionsListenerEcon implements Listener
if (event.getReason() != MembershipChangeReason.LEAVE) return; if (event.getReason() != MembershipChangeReason.LEAVE) return;
// ... and that player was the last one in the faction ... // ... and that player was the last one in the faction ...
UPlayer uplayer = event.getUPlayer(); MPlayer uplayer = event.getUPlayer();
Faction oldFaction = uplayer.getFaction(); Faction oldFaction = uplayer.getFaction();
if (oldFaction.getUPlayers().size() > 1) return; if (oldFaction.getUPlayers().size() > 1) return;
@ -73,11 +73,11 @@ public class FactionsListenerEcon implements Listener
public void takeOnDisband(EventFactionsDisband event) public void takeOnDisband(EventFactionsDisband event)
{ {
// If there is a usender ... // If there is a usender ...
UPlayer usender = event.getUSender(); MPlayer usender = event.getUSender();
if (usender == null) return; if (usender == null) return;
// ... and economy is enabled ... // ... and economy is enabled ...
if (!Econ.isEnabled(usender)) return; if (!Econ.isEnabled()) return;
// ... then transfer all the faction money to the sender. // ... then transfer all the faction money to the sender.
Faction faction = event.getFaction(); Faction faction = event.getFaction();
@ -98,7 +98,7 @@ public class FactionsListenerEcon implements Listener
public static void payForAction(EventFactionsAbstractSender event, Double cost, String desc) public static void payForAction(EventFactionsAbstractSender event, Double cost, String desc)
{ {
// If there is a sender ... // If there is a sender ...
UPlayer usender = event.getUSender(); MPlayer usender = event.getUSender();
if (usender == null) return; if (usender == null) return;
// ... and there is a cost ... // ... and there is a cost ...
@ -115,10 +115,8 @@ public class FactionsListenerEcon implements Listener
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void payForAction(EventFactionsChunkChange event) public void payForAction(EventFactionsChunkChange event)
{ {
Faction newFaction = event.getNewFaction();
UConf uconf = UConf.get(newFaction);
EventFactionsChunkChangeType type = event.getType(); EventFactionsChunkChangeType type = event.getType();
Double cost = uconf.econChunkCost.get(type); Double cost = MConf.get().econChunkCost.get(type);
String desc = type.toString().toLowerCase() + " this land"; String desc = type.toString().toLowerCase() + " this land";
@ -131,22 +129,19 @@ public class FactionsListenerEcon implements Listener
Double cost = null; Double cost = null;
String desc = null; String desc = null;
UConf uconf = UConf.get(event.getSender());
if (uconf == null) return;
if (event.getReason() == MembershipChangeReason.JOIN) if (event.getReason() == MembershipChangeReason.JOIN)
{ {
cost = uconf.econCostJoin; cost = MConf.get().econCostJoin;
desc = "join a faction"; desc = "join a faction";
} }
else if (event.getReason() == MembershipChangeReason.LEAVE) else if (event.getReason() == MembershipChangeReason.LEAVE)
{ {
cost = uconf.econCostLeave; cost = MConf.get().econCostLeave;
desc = "leave a faction"; desc = "leave a faction";
} }
else if (event.getReason() == MembershipChangeReason.KICK) else if (event.getReason() == MembershipChangeReason.KICK)
{ {
cost = uconf.econCostKick; cost = MConf.get().econCostKick;
desc = "kick someone from a faction"; desc = "kick someone from a faction";
} }
else else
@ -160,7 +155,7 @@ public class FactionsListenerEcon implements Listener
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void payForCommand(EventFactionsRelationChange event) public void payForCommand(EventFactionsRelationChange event)
{ {
Double cost = UConf.get(event.getSender()).econRelCost.get(event.getNewRelation()); Double cost = MConf.get().econRelCost.get(event.getNewRelation());
String desc = Factions.get().getOuterCmdFactions().cmdFactionsRelationNeutral.getDesc(); String desc = Factions.get().getOuterCmdFactions().cmdFactionsRelationNeutral.getDesc();
payForAction(event, cost, desc); payForAction(event, cost, desc);
@ -169,7 +164,7 @@ public class FactionsListenerEcon implements Listener
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void payForCommand(EventFactionsHomeChange event) public void payForCommand(EventFactionsHomeChange event)
{ {
Double cost = UConf.get(event.getSender()).econCostSethome; Double cost = MConf.get().econCostSethome;
String desc = Factions.get().getOuterCmdFactions().cmdFactionsSethome.getDesc(); String desc = Factions.get().getOuterCmdFactions().cmdFactionsSethome.getDesc();
payForAction(event, cost, desc); payForAction(event, cost, desc);
@ -178,7 +173,7 @@ public class FactionsListenerEcon implements Listener
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void payForCommand(EventFactionsCreate event) public void payForCommand(EventFactionsCreate event)
{ {
Double cost = UConf.get(event.getSender()).econCostCreate; Double cost = MConf.get().econCostCreate;
String desc = Factions.get().getOuterCmdFactions().cmdFactionsCreate.getDesc(); String desc = Factions.get().getOuterCmdFactions().cmdFactionsCreate.getDesc();
payForAction(event, cost, desc); payForAction(event, cost, desc);
@ -187,7 +182,7 @@ public class FactionsListenerEcon implements Listener
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void payForCommand(EventFactionsDescriptionChange event) public void payForCommand(EventFactionsDescriptionChange event)
{ {
Double cost = UConf.get(event.getSender()).econCostDescription; Double cost = MConf.get().econCostDescription;
String desc = Factions.get().getOuterCmdFactions().cmdFactionsDescription.getDesc(); String desc = Factions.get().getOuterCmdFactions().cmdFactionsDescription.getDesc();
payForAction(event, cost, desc); payForAction(event, cost, desc);
@ -196,7 +191,7 @@ public class FactionsListenerEcon implements Listener
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void payForCommand(EventFactionsNameChange event) public void payForCommand(EventFactionsNameChange event)
{ {
Double cost = UConf.get(event.getSender()).econCostName; Double cost = MConf.get().econCostName;
String desc = Factions.get().getOuterCmdFactions().cmdFactionsName.getDesc(); String desc = Factions.get().getOuterCmdFactions().cmdFactionsName.getDesc();
payForAction(event, cost, desc); payForAction(event, cost, desc);
@ -205,7 +200,7 @@ public class FactionsListenerEcon implements Listener
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void payForCommand(EventFactionsTitleChange event) public void payForCommand(EventFactionsTitleChange event)
{ {
Double cost = UConf.get(event.getSender()).econCostTitle; Double cost = MConf.get().econCostTitle;
String desc = Factions.get().getOuterCmdFactions().cmdFactionsTitle.getDesc(); String desc = Factions.get().getOuterCmdFactions().cmdFactionsTitle.getDesc();
payForAction(event, cost, desc); payForAction(event, cost, desc);
@ -214,7 +209,7 @@ public class FactionsListenerEcon implements Listener
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void payForCommand(EventFactionsOpenChange event) public void payForCommand(EventFactionsOpenChange event)
{ {
Double cost = UConf.get(event.getSender()).econCostOpen; Double cost = MConf.get().econCostOpen;
String desc = Factions.get().getOuterCmdFactions().cmdFactionsOpen.getDesc(); String desc = Factions.get().getOuterCmdFactions().cmdFactionsOpen.getDesc();
payForAction(event, cost, desc); payForAction(event, cost, desc);
@ -223,7 +218,7 @@ public class FactionsListenerEcon implements Listener
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void payForCommand(EventFactionsInvitedChange event) public void payForCommand(EventFactionsInvitedChange event)
{ {
Double cost = event.isNewInvited() ? UConf.get(event.getSender()).econCostInvite : UConf.get(event.getSender()).econCostDeinvite; Double cost = event.isNewInvited() ? MConf.get().econCostInvite : MConf.get().econCostDeinvite;
String desc = Factions.get().getOuterCmdFactions().cmdFactionsInvite.getDesc(); String desc = Factions.get().getOuterCmdFactions().cmdFactionsInvite.getDesc();
payForAction(event, cost, desc); payForAction(event, cost, desc);
@ -232,7 +227,7 @@ public class FactionsListenerEcon implements Listener
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void payForCommand(EventFactionsHomeTeleport event) public void payForCommand(EventFactionsHomeTeleport event)
{ {
Double cost = UConf.get(event.getSender()).econCostHome; Double cost = MConf.get().econCostHome;
String desc = Factions.get().getOuterCmdFactions().cmdFactionsHome.getDesc(); String desc = Factions.get().getOuterCmdFactions().cmdFactionsHome.getDesc();
payForAction(event, cost, desc); payForAction(event, cost, desc);

View File

@ -59,13 +59,11 @@ import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.Factions; import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Rel; import com.massivecraft.factions.Rel;
import com.massivecraft.factions.TerritoryAccess; import com.massivecraft.factions.TerritoryAccess;
import com.massivecraft.factions.entity.BoardColls; import com.massivecraft.factions.entity.BoardColl;
import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.entity.UConf; import com.massivecraft.factions.entity.MPlayerColl;
import com.massivecraft.factions.entity.UPlayerColl;
import com.massivecraft.factions.entity.UPlayerColls;
import com.massivecraft.factions.event.EventFactionsPvpDisallowed; import com.massivecraft.factions.event.EventFactionsPvpDisallowed;
import com.massivecraft.factions.event.EventFactionsPowerChange; import com.massivecraft.factions.event.EventFactionsPowerChange;
import com.massivecraft.factions.event.EventFactionsPowerChange.PowerChangeReason; import com.massivecraft.factions.event.EventFactionsPowerChange.PowerChangeReason;
@ -105,33 +103,30 @@ public class FactionsListenerMain implements Listener
if (MUtil.isSameChunk(event)) return; if (MUtil.isSameChunk(event)) return;
Player player = event.getPlayer(); Player player = event.getPlayer();
// Check Disabled
if (UConf.isDisabled(player)) return;
// ... gather info on the player and the move ... // ... gather info on the player and the move ...
UPlayer uplayer = UPlayerColls.get().get(event.getTo()).get(player); MPlayer mplayer = MPlayer.get(player);
PS chunkFrom = PS.valueOf(event.getFrom()).getChunk(true); PS chunkFrom = PS.valueOf(event.getFrom()).getChunk(true);
PS chunkTo = PS.valueOf(event.getTo()).getChunk(true); PS chunkTo = PS.valueOf(event.getTo()).getChunk(true);
Faction factionFrom = BoardColls.get().getFactionAt(chunkFrom); Faction factionFrom = BoardColl.get().getFactionAt(chunkFrom);
Faction factionTo = BoardColls.get().getFactionAt(chunkTo); Faction factionTo = BoardColl.get().getFactionAt(chunkTo);
// ... and send info onwards. // ... and send info onwards.
this.chunkChangeTerritoryInfo(uplayer, player, chunkFrom, chunkTo, factionFrom, factionTo); this.chunkChangeTerritoryInfo(mplayer, player, chunkFrom, chunkTo, factionFrom, factionTo);
this.chunkChangeAutoClaim(uplayer, chunkTo); this.chunkChangeAutoClaim(mplayer, chunkTo);
} }
// -------------------------------------------- // // -------------------------------------------- //
// CHUNK CHANGE: TERRITORY INFO // CHUNK CHANGE: TERRITORY INFO
// -------------------------------------------- // // -------------------------------------------- //
public void chunkChangeTerritoryInfo(UPlayer uplayer, Player player, PS chunkFrom, PS chunkTo, Faction factionFrom, Faction factionTo) public void chunkChangeTerritoryInfo(MPlayer uplayer, Player player, PS chunkFrom, PS chunkTo, Faction factionFrom, Faction factionTo)
{ {
// send host faction info updates // send host faction info updates
if (uplayer.isMapAutoUpdating()) if (uplayer.isMapAutoUpdating())
{ {
uplayer.sendMessage(BoardColls.get().getMap(uplayer, chunkTo, player.getLocation().getYaw())); uplayer.sendMessage(BoardColl.get().getMap(uplayer, chunkTo, player.getLocation().getYaw()));
} }
else if (factionFrom != factionTo) else if (factionFrom != factionTo)
{ {
@ -144,10 +139,10 @@ public class FactionsListenerMain implements Listener
} }
// Show access level message if it changed. // Show access level message if it changed.
TerritoryAccess accessFrom = BoardColls.get().getTerritoryAccessAt(chunkFrom); TerritoryAccess accessFrom = BoardColl.get().getTerritoryAccessAt(chunkFrom);
Boolean hasTerritoryAccessFrom = accessFrom.hasTerritoryAccess(uplayer); Boolean hasTerritoryAccessFrom = accessFrom.hasTerritoryAccess(uplayer);
TerritoryAccess accessTo = BoardColls.get().getTerritoryAccessAt(chunkTo); TerritoryAccess accessTo = BoardColl.get().getTerritoryAccessAt(chunkTo);
Boolean hasTerritoryAccessTo = accessTo.hasTerritoryAccess(uplayer); Boolean hasTerritoryAccessTo = accessTo.hasTerritoryAccess(uplayer);
if (!MUtil.equals(hasTerritoryAccessFrom, hasTerritoryAccessTo)) if (!MUtil.equals(hasTerritoryAccessFrom, hasTerritoryAccessTo))
@ -171,7 +166,7 @@ public class FactionsListenerMain implements Listener
// CHUNK CHANGE: AUTO CLAIM // CHUNK CHANGE: AUTO CLAIM
// -------------------------------------------- // // -------------------------------------------- //
public void chunkChangeAutoClaim(UPlayer uplayer, PS chunkTo) public void chunkChangeAutoClaim(MPlayer uplayer, PS chunkTo)
{ {
// If the player is auto claiming ... // If the player is auto claiming ...
Faction autoClaimFaction = uplayer.getAutoClaimFaction(); Faction autoClaimFaction = uplayer.getAutoClaimFaction();
@ -195,39 +190,36 @@ public class FactionsListenerMain implements Listener
// (yeah other plugins can case death event to fire twice the same tick) // (yeah other plugins can case death event to fire twice the same tick)
if (PlayerUtil.isDuplicateDeathEvent(event)) return; if (PlayerUtil.isDuplicateDeathEvent(event)) return;
// Check Disabled MPlayer mplayer = MPlayer.get(player);
if (UConf.isDisabled(player)) return;
UPlayer uplayer = UPlayer.get(player);
// ... and powerloss can happen here ... // ... and powerloss can happen here ...
Faction faction = BoardColls.get().getFactionAt(PS.valueOf(player)); Faction faction = BoardColl.get().getFactionAt(PS.valueOf(player));
if (!faction.getFlag(FFlag.POWERLOSS)) if (!faction.getFlag(FFlag.POWERLOSS))
{ {
uplayer.msg("<i>You didn't lose any power since the territory you died in works that way."); mplayer.msg("<i>You didn't lose any power since the territory you died in works that way.");
return; return;
} }
if (MConf.get().getWorldsNoPowerLoss().contains(player.getWorld().getName())) if (MConf.get().getWorldsNoPowerLoss().contains(player.getWorld().getName()))
{ {
uplayer.msg("<i>You didn't lose any power due to the world you died in."); mplayer.msg("<i>You didn't lose any power due to the world you died in.");
return; return;
} }
// ... alter the power ... // ... alter the power ...
double newPower = uplayer.getPower() + uplayer.getPowerPerDeath(); double newPower = mplayer.getPower() + mplayer.getPowerPerDeath();
EventFactionsPowerChange powerChangeEvent = new EventFactionsPowerChange(null, uplayer, PowerChangeReason.DEATH, newPower); EventFactionsPowerChange powerChangeEvent = new EventFactionsPowerChange(null, mplayer, PowerChangeReason.DEATH, newPower);
powerChangeEvent.run(); powerChangeEvent.run();
if (powerChangeEvent.isCancelled()) return; if (powerChangeEvent.isCancelled()) return;
newPower = powerChangeEvent.getNewPower(); newPower = powerChangeEvent.getNewPower();
uplayer.setPower(newPower); mplayer.setPower(newPower);
// ... and inform the player. // ... and inform the player.
// TODO: A progress bar here would be epic :) // TODO: A progress bar here would be epic :)
uplayer.msg("<i>Your power is now <h>%.2f / %.2f", newPower, uplayer.getPowerMax()); mplayer.msg("<i>Your power is now <h>%.2f / %.2f", newPower, mplayer.getPowerMax());
} }
// -------------------------------------------- // // -------------------------------------------- //
@ -292,10 +284,7 @@ public class FactionsListenerMain implements Listener
Entity edefender = event.getEntity(); Entity edefender = event.getEntity();
if (!(edefender instanceof Player)) return true; if (!(edefender instanceof Player)) return true;
Player defender = (Player)edefender; Player defender = (Player)edefender;
UPlayer udefender = UPlayer.get(edefender); MPlayer udefender = MPlayer.get(edefender);
// Check Disabled
if (UConf.isDisabled(defender)) return true;
// ... and the attacker is someone else ... // ... and the attacker is someone else ...
Entity eattacker = MUtil.getLiableDamager(event); Entity eattacker = MUtil.getLiableDamager(event);
@ -306,7 +295,7 @@ public class FactionsListenerMain implements Listener
// ... gather defender PS and faction information ... // ... gather defender PS and faction information ...
PS defenderPs = PS.valueOf(defender); PS defenderPs = PS.valueOf(defender);
Faction defenderPsFaction = BoardColls.get().getFactionAt(defenderPs); Faction defenderPsFaction = BoardColl.get().getFactionAt(defenderPs);
// ... PVP flag may cause a damage block ... // ... PVP flag may cause a damage block ...
if (defenderPsFaction.getFlag(FFlag.PVP) == false) if (defenderPsFaction.getFlag(FFlag.PVP) == false)
@ -322,7 +311,7 @@ public class FactionsListenerMain implements Listener
ret = falseUnlessDisallowedPvpEventCancelled((Player)eattacker, defender, event); ret = falseUnlessDisallowedPvpEventCancelled((Player)eattacker, defender, event);
if (!ret && notify) if (!ret && notify)
{ {
UPlayer attacker = UPlayer.get(eattacker); MPlayer attacker = MPlayer.get(eattacker);
attacker.msg("<i>PVP is disabled in %s.", defenderPsFaction.describeTo(attacker)); attacker.msg("<i>PVP is disabled in %s.", defenderPsFaction.describeTo(attacker));
} }
return ret; return ret;
@ -333,14 +322,14 @@ public class FactionsListenerMain implements Listener
// ... and if the attacker is a player ... // ... and if the attacker is a player ...
if (!(eattacker instanceof Player)) return true; if (!(eattacker instanceof Player)) return true;
Player attacker = (Player)eattacker; Player attacker = (Player)eattacker;
UPlayer uattacker = UPlayer.get(attacker); MPlayer uattacker = MPlayer.get(attacker);
// ... does this player bypass all protection? ... // ... does this player bypass all protection? ...
if (MConf.get().playersWhoBypassAllProtection.contains(attacker.getName())) return true; if (MConf.get().playersWhoBypassAllProtection.contains(attacker.getName())) return true;
// ... gather attacker PS and faction information ... // ... gather attacker PS and faction information ...
PS attackerPs = PS.valueOf(attacker); PS attackerPs = PS.valueOf(attacker);
Faction attackerPsFaction = BoardColls.get().getFactionAt(attackerPs); Faction attackerPsFaction = BoardColl.get().getFactionAt(attackerPs);
// ... PVP flag may cause a damage block ... // ... PVP flag may cause a damage block ...
// (just checking the defender as above isn't enough. What about the attacker? It could be in a no-pvp area) // (just checking the defender as above isn't enough. What about the attacker? It could be in a no-pvp area)
@ -357,9 +346,8 @@ public class FactionsListenerMain implements Listener
Faction defendFaction = udefender.getFaction(); Faction defendFaction = udefender.getFaction();
Faction attackFaction = uattacker.getFaction(); Faction attackFaction = uattacker.getFaction();
UConf uconf = UConf.get(attackFaction);
if (attackFaction.isNone() && uconf.disablePVPForFactionlessPlayers) if (attackFaction.isNone() && MConf.get().disablePVPForFactionlessPlayers)
{ {
ret = falseUnlessDisallowedPvpEventCancelled(attacker, defender, event); ret = falseUnlessDisallowedPvpEventCancelled(attacker, defender, event);
if (!ret && notify) uattacker.msg("<i>You can't hurt other players until you join a faction."); if (!ret && notify) uattacker.msg("<i>You can't hurt other players until you join a faction.");
@ -367,12 +355,12 @@ public class FactionsListenerMain implements Listener
} }
else if (defendFaction.isNone()) else if (defendFaction.isNone())
{ {
if (defenderPsFaction == attackFaction && uconf.enablePVPAgainstFactionlessInAttackersLand) if (defenderPsFaction == attackFaction && MConf.get().enablePVPAgainstFactionlessInAttackersLand)
{ {
// Allow PVP vs. Factionless in attacker's faction territory // Allow PVP vs. Factionless in attacker's faction territory
return true; return true;
} }
else if (uconf.disablePVPForFactionlessPlayers) else if (MConf.get().disablePVPForFactionlessPlayers)
{ {
ret = falseUnlessDisallowedPvpEventCancelled(attacker, defender, event); ret = falseUnlessDisallowedPvpEventCancelled(attacker, defender, event);
if (!ret && notify) uattacker.msg("<i>You can't hurt players who are not currently in a faction."); if (!ret && notify) uattacker.msg("<i>You can't hurt players who are not currently in a faction.");
@ -406,15 +394,15 @@ public class FactionsListenerMain implements Listener
// Damage will be dealt. However check if the damage should be reduced. // Damage will be dealt. However check if the damage should be reduced.
double damage = event.getDamage(); double damage = event.getDamage();
if (damage > 0.0 && udefender.hasFaction() && ownTerritory && uconf.territoryShieldFactor > 0) if (damage > 0.0 && udefender.hasFaction() && ownTerritory && MConf.get().territoryShieldFactor > 0)
{ {
double newDamage = damage * (1D - uconf.territoryShieldFactor); double newDamage = damage * (1D - MConf.get().territoryShieldFactor);
event.setDamage(newDamage); event.setDamage(newDamage);
// Send message // Send message
if (notify) if (notify)
{ {
String perc = MessageFormat.format("{0,number,#%}", (uconf.territoryShieldFactor)); // TODO does this display correctly?? String perc = MessageFormat.format("{0,number,#%}", (MConf.get().territoryShieldFactor)); // TODO does this display correctly??
udefender.msg("<i>Enemy damage reduced by <rose>%s<i>.", perc); udefender.msg("<i>Enemy damage reduced by <rose>%s<i>.", perc);
} }
} }
@ -440,18 +428,16 @@ public class FactionsListenerMain implements Listener
if (!MConf.get().removePlayerDataWhenBanned) return; if (!MConf.get().removePlayerDataWhenBanned) return;
// ... get rid of their stored info. // ... get rid of their stored info.
for (UPlayerColl coll : UPlayerColls.get().getColls()) MPlayer mplayer = MPlayerColl.get().get(player, false);
{ if (mplayer == null) return;
UPlayer uplayer = coll.get(player, false);
if (uplayer == null) continue;
if (uplayer.getRole() == Rel.LEADER) if (mplayer.getRole() == Rel.LEADER)
{ {
uplayer.getFaction().promoteNewLeader(); mplayer.getFaction().promoteNewLeader();
}
uplayer.leave();
uplayer.detach();
} }
mplayer.leave();
mplayer.detach();
} }
// -------------------------------------------- // // -------------------------------------------- //
@ -476,10 +462,7 @@ public class FactionsListenerMain implements Listener
// If a player is trying to run a command ... // If a player is trying to run a command ...
Player player = event.getPlayer(); Player player = event.getPlayer();
// Check Disabled MPlayer uplayer = MPlayer.get(player);
if (UConf.isDisabled(player)) return;
UPlayer uplayer = UPlayer.get(player);
// ... and the player does not have adminmode ... // ... and the player does not have adminmode ...
if (uplayer.isUsingAdminMode()) return; if (uplayer.isUsingAdminMode()) return;
@ -491,7 +474,7 @@ public class FactionsListenerMain implements Listener
command = command.trim(); command = command.trim();
// ... the command may be denied for members of permanent factions ... // ... the command may be denied for members of permanent factions ...
if (uplayer.hasFaction() && uplayer.getFaction().getFlag(FFlag.PERMANENT) && containsCommand(command, UConf.get(player).denyCommandsPermanentFactionMember)) if (uplayer.hasFaction() && uplayer.getFaction().getFlag(FFlag.PERMANENT) && containsCommand(command, MConf.get().denyCommandsPermanentFactionMember))
{ {
uplayer.msg("<b>You can't use \"<h>/%s<b>\" as member of a permanent faction.", command); uplayer.msg("<b>You can't use \"<h>/%s<b>\" as member of a permanent faction.", command);
event.setCancelled(true); event.setCancelled(true);
@ -500,13 +483,13 @@ public class FactionsListenerMain implements Listener
// ... if there is a faction at the players location ... // ... if there is a faction at the players location ...
PS ps = PS.valueOf(player).getChunk(true); PS ps = PS.valueOf(player).getChunk(true);
Faction factionAtPs = BoardColls.get().getFactionAt(ps); Faction factionAtPs = BoardColl.get().getFactionAt(ps);
if (factionAtPs.isNone()) return; // TODO: An NPE can arise here? Why? if (factionAtPs.isNone()) return; // TODO: An NPE can arise here? Why?
// ... the command may be denied in the territory of this relation type ... // ... the command may be denied in the territory of this relation type ...
Rel rel = factionAtPs.getRelationTo(uplayer); Rel rel = factionAtPs.getRelationTo(uplayer);
List<String> deniedCommands = UConf.get(player).denyCommandsTerritoryRelation.get(rel); List<String> deniedCommands = MConf.get().denyCommandsTerritoryRelation.get(rel);
if (deniedCommands == null) return; if (deniedCommands == null) return;
if (!containsCommand(command, deniedCommands)) return; if (!containsCommand(command, deniedCommands)) return;
@ -542,12 +525,9 @@ public class FactionsListenerMain implements Listener
// If a monster is spawning ... // If a monster is spawning ...
if ( ! MConf.get().entityTypesMonsters.contains(event.getEntityType())) return; if ( ! MConf.get().entityTypesMonsters.contains(event.getEntityType())) return;
// Check Disabled
if (UConf.isDisabled(event.getLocation())) return;
// ... at a place where monsters are forbidden ... // ... at a place where monsters are forbidden ...
PS ps = PS.valueOf(event.getLocation()); PS ps = PS.valueOf(event.getLocation());
Faction faction = BoardColls.get().getFactionAt(ps); Faction faction = BoardColl.get().getFactionAt(ps);
if (faction.getFlag(FFlag.MONSTERS)) return; if (faction.getFlag(FFlag.MONSTERS)) return;
// ... block the spawn. // ... block the spawn.
@ -564,12 +544,9 @@ public class FactionsListenerMain implements Listener
Entity target = event.getTarget(); Entity target = event.getTarget();
if (target == null) return; if (target == null) return;
// Check Disabled
if (UConf.isDisabled(target)) return;
// ... at a place where monsters are forbidden ... // ... at a place where monsters are forbidden ...
PS ps = PS.valueOf(target); PS ps = PS.valueOf(target);
Faction faction = BoardColls.get().getFactionAt(ps); Faction faction = BoardColl.get().getFactionAt(ps);
if (faction.getFlag(FFlag.MONSTERS)) return; if (faction.getFlag(FFlag.MONSTERS)) return;
// ... then if ghast target nothing ... // ... then if ghast target nothing ...
@ -594,11 +571,8 @@ public class FactionsListenerMain implements Listener
if (event.getCause() != RemoveCause.EXPLOSION) return; if (event.getCause() != RemoveCause.EXPLOSION) return;
Entity entity = event.getEntity(); Entity entity = event.getEntity();
// Check Disabled
if (UConf.isDisabled(entity)) return;
// ... and the faction there has explosions disabled ... // ... and the faction there has explosions disabled ...
Faction faction = BoardColls.get().getFactionAt(PS.valueOf(entity)); Faction faction = BoardColl.get().getFactionAt(PS.valueOf(entity));
if (faction.isExplosionsAllowed()) return; if (faction.isExplosionsAllowed()) return;
// ... then cancel. // ... then cancel.
@ -619,11 +593,8 @@ public class FactionsListenerMain implements Listener
// If an explosion occurs at a location ... // If an explosion occurs at a location ...
Location location = event.getLocation(); Location location = event.getLocation();
// Check Disabled
if (UConf.isDisabled(location)) return;
// Check the entity. Are explosions disabled there? // Check the entity. Are explosions disabled there?
faction = BoardColls.get().getFactionAt(PS.valueOf(location)); faction = BoardColl.get().getFactionAt(PS.valueOf(location));
allowed = faction.isExplosionsAllowed(); allowed = faction.isExplosionsAllowed();
if (allowed == false) if (allowed == false)
{ {
@ -637,7 +608,7 @@ public class FactionsListenerMain implements Listener
while (iter.hasNext()) while (iter.hasNext())
{ {
Block block = iter.next(); Block block = iter.next();
faction = BoardColls.get().getFactionAt(PS.valueOf(block)); faction = BoardColl.get().getFactionAt(PS.valueOf(block));
allowed = faction2allowed.get(faction); allowed = faction2allowed.get(faction);
if (allowed == null) if (allowed == null)
{ {
@ -656,12 +627,9 @@ public class FactionsListenerMain implements Listener
Entity entity = event.getEntity(); Entity entity = event.getEntity();
if (!(entity instanceof Wither)) return; if (!(entity instanceof Wither)) return;
// Check Disabled
if (UConf.isDisabled(entity)) return;
// ... and the faction there has explosions disabled ... // ... and the faction there has explosions disabled ...
PS ps = PS.valueOf(event.getBlock()); PS ps = PS.valueOf(event.getBlock());
Faction faction = BoardColls.get().getFactionAt(ps); Faction faction = BoardColl.get().getFactionAt(ps);
if (faction.isExplosionsAllowed()) return; if (faction.isExplosionsAllowed()) return;
@ -680,12 +648,9 @@ public class FactionsListenerMain implements Listener
Entity entity = event.getEntity(); Entity entity = event.getEntity();
if (!(entity instanceof Enderman)) return; if (!(entity instanceof Enderman)) return;
// Check Disabled
if (UConf.isDisabled(entity)) return;
// ... and the faction there has endergrief disabled ... // ... and the faction there has endergrief disabled ...
PS ps = PS.valueOf(event.getBlock()); PS ps = PS.valueOf(event.getBlock());
Faction faction = BoardColls.get().getFactionAt(ps); Faction faction = BoardColl.get().getFactionAt(ps);
if (faction.getFlag(FFlag.ENDERGRIEF)) return; if (faction.getFlag(FFlag.ENDERGRIEF)) return;
// ... stop the block alteration. // ... stop the block alteration.
@ -698,12 +663,9 @@ public class FactionsListenerMain implements Listener
public void blockFireSpread(Block block, Cancellable cancellable) public void blockFireSpread(Block block, Cancellable cancellable)
{ {
// Check Disabled
if (UConf.isDisabled(block)) return;
// If the faction at the block has firespread disabled ... // If the faction at the block has firespread disabled ...
PS ps = PS.valueOf(block); PS ps = PS.valueOf(block);
Faction faction = BoardColls.get().getFactionAt(ps); Faction faction = BoardColl.get().getFactionAt(ps);
if (faction.getFlag(FFlag.FIRESPREAD)) return; if (faction.getFlag(FFlag.FIRESPREAD)) return;
@ -750,16 +712,16 @@ public class FactionsListenerMain implements Listener
String name = player.getName(); String name = player.getName();
if (MConf.get().playersWhoBypassAllProtection.contains(name)) return true; if (MConf.get().playersWhoBypassAllProtection.contains(name)) return true;
UPlayer uplayer = UPlayer.get(player); MPlayer uplayer = MPlayer.get(player);
if (uplayer.isUsingAdminMode()) return true; if (uplayer.isUsingAdminMode()) return true;
if (!FPerm.BUILD.has(uplayer, ps, false) && FPerm.PAINBUILD.has(uplayer, ps, false)) if (!FPerm.BUILD.has(uplayer, ps, false) && FPerm.PAINBUILD.has(uplayer, ps, false))
{ {
if (verboose) if (verboose)
{ {
Faction hostFaction = BoardColls.get().getFactionAt(ps); Faction hostFaction = BoardColl.get().getFactionAt(ps);
uplayer.msg("<b>It is painful to build in the territory of %s<b>.", hostFaction.describeTo(uplayer)); uplayer.msg("<b>It is painful to build in the territory of %s<b>.", hostFaction.describeTo(uplayer));
player.damage(UConf.get(player).actionDeniedPainAmount); player.damage(MConf.get().actionDeniedPainAmount);
} }
return true; return true;
} }
@ -844,13 +806,13 @@ public class FactionsListenerMain implements Listener
{ {
Block block = event.getBlock(); Block block = event.getBlock();
Faction pistonFaction = BoardColls.get().getFactionAt(PS.valueOf(block)); Faction pistonFaction = BoardColl.get().getFactionAt(PS.valueOf(block));
// target end-of-the-line empty (air) block which is being pushed into, including if piston itself would extend into air // target end-of-the-line empty (air) block which is being pushed into, including if piston itself would extend into air
Block targetBlock = block.getRelative(event.getDirection(), event.getLength() + 1); Block targetBlock = block.getRelative(event.getDirection(), event.getLength() + 1);
// members of faction might not have build rights in their own territory, but pistons should still work regardless; so, address that corner case // members of faction might not have build rights in their own territory, but pistons should still work regardless; so, address that corner case
Faction targetFaction = BoardColls.get().getFactionAt(PS.valueOf(targetBlock)); Faction targetFaction = BoardColl.get().getFactionAt(PS.valueOf(targetBlock));
if (targetFaction == pistonFaction) return; if (targetFaction == pistonFaction) return;
// if potentially pushing into air/water/lava in another territory, we need to check it out // if potentially pushing into air/water/lava in another territory, we need to check it out
@ -878,10 +840,10 @@ public class FactionsListenerMain implements Listener
// if potentially retracted block is just air/water/lava, no worries // if potentially retracted block is just air/water/lava, no worries
if (retractBlock.isEmpty() || retractBlock.isLiquid()) return; if (retractBlock.isEmpty() || retractBlock.isLiquid()) return;
Faction pistonFaction = BoardColls.get().getFactionAt(PS.valueOf(event.getBlock())); Faction pistonFaction = BoardColl.get().getFactionAt(PS.valueOf(event.getBlock()));
// members of faction might not have build rights in their own territory, but pistons should still work regardless; so, address that corner case // members of faction might not have build rights in their own territory, but pistons should still work regardless; so, address that corner case
Faction targetFaction = BoardColls.get().getFactionAt(retractPs); Faction targetFaction = BoardColl.get().getFactionAt(retractPs);
if (targetFaction == pistonFaction) return; if (targetFaction == pistonFaction) return;
if (!FPerm.BUILD.has(pistonFaction, targetFaction)) if (!FPerm.BUILD.has(pistonFaction, targetFaction))
@ -929,7 +891,7 @@ public class FactionsListenerMain implements Listener
String name = player.getName(); String name = player.getName();
if (MConf.get().playersWhoBypassAllProtection.contains(name)) return true; if (MConf.get().playersWhoBypassAllProtection.contains(name)) return true;
UPlayer uplayer = UPlayer.get(player); MPlayer uplayer = MPlayer.get(player);
if (uplayer.isUsingAdminMode()) return true; if (uplayer.isUsingAdminMode()) return true;
return FPerm.BUILD.has(uplayer, ps, !justCheck); return FPerm.BUILD.has(uplayer, ps, !justCheck);
@ -940,7 +902,7 @@ public class FactionsListenerMain implements Listener
String name = player.getName(); String name = player.getName();
if (MConf.get().playersWhoBypassAllProtection.contains(name)) return true; if (MConf.get().playersWhoBypassAllProtection.contains(name)) return true;
UPlayer me = UPlayer.get(player); MPlayer me = MPlayer.get(player);
if (me.isUsingAdminMode()) return true; if (me.isUsingAdminMode()) return true;
PS ps = PS.valueOf(block); PS ps = PS.valueOf(block);
@ -986,13 +948,12 @@ public class FactionsListenerMain implements Listener
{ {
// If a player is respawning ... // If a player is respawning ...
final Player player = event.getPlayer(); final Player player = event.getPlayer();
final UPlayer uplayer = UPlayer.get(player); final MPlayer uplayer = MPlayer.get(player);
final UConf uconf = UConf.get(player);
// ... homes are enabled, active and at this priority ... // ... homes are enabled, active and at this priority ...
if (!uconf.homesEnabled) return; if (!MConf.get().homesEnabled) return;
if (!uconf.homesTeleportToOnDeathActive) return; if (!MConf.get().homesTeleportToOnDeathActive) return;
if (uconf.homesTeleportToOnDeathPriority != priority) return; if (MConf.get().homesTeleportToOnDeathPriority != priority) return;
// ... and the player has a faction ... // ... and the player has a faction ...
final Faction faction = uplayer.getFaction(); final Faction faction = uplayer.getFaction();

View File

@ -1,12 +1,12 @@
package com.massivecraft.factions.mixin; package com.massivecraft.factions.mixin;
import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.MPlayer;
public interface PowerMixin public interface PowerMixin
{ {
public double getMaxUniversal(UPlayer uplayer); public double getMaxUniversal(MPlayer uplayer);
public double getMax(UPlayer uplayer); public double getMax(MPlayer uplayer);
public double getMin(UPlayer uplayer); public double getMin(MPlayer uplayer);
public double getPerHour(UPlayer uplayer); public double getPerHour(MPlayer uplayer);
public double getPerDeath(UPlayer uplayer); public double getPerDeath(MPlayer uplayer);
} }

View File

@ -1,7 +1,7 @@
package com.massivecraft.factions.mixin; package com.massivecraft.factions.mixin;
import com.massivecraft.factions.entity.UConf; import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.MPlayer;
public class PowerMixinDefault implements PowerMixin public class PowerMixinDefault implements PowerMixin
{ {
@ -17,33 +17,33 @@ public class PowerMixinDefault implements PowerMixin
// -------------------------------------------- // // -------------------------------------------- //
@Override @Override
public double getMaxUniversal(UPlayer uplayer) public double getMaxUniversal(MPlayer mplayer)
{ {
return this.getMax(uplayer); return this.getMax(mplayer);
} }
@Override @Override
public double getMax(UPlayer uplayer) public double getMax(MPlayer mplayer)
{ {
return UConf.get(uplayer).powerMax + uplayer.getPowerBoost(); return MConf.get().powerMax + mplayer.getPowerBoost();
} }
@Override @Override
public double getMin(UPlayer uplayer) public double getMin(MPlayer mplayer)
{ {
return UConf.get(uplayer).powerMin; return MConf.get().powerMin;
} }
@Override @Override
public double getPerHour(UPlayer uplayer) public double getPerHour(MPlayer mplayer)
{ {
return UConf.get(uplayer).powerPerHour; return MConf.get().powerPerHour;
} }
@Override @Override
public double getPerDeath(UPlayer uplayer) public double getPerDeath(MPlayer mplayer)
{ {
return UConf.get(uplayer).powerPerDeath; return MConf.get().powerPerDeath;
} }
} }

View File

@ -1,9 +1,7 @@
package com.massivecraft.factions.task; package com.massivecraft.factions.task;
import com.massivecraft.factions.entity.FactionColl; import com.massivecraft.factions.entity.FactionColl;
import com.massivecraft.factions.entity.FactionColls;
import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.entity.UConf;
import com.massivecraft.massivecore.ModuloRepeatTask; import com.massivecraft.massivecore.ModuloRepeatTask;
import com.massivecraft.massivecore.util.TimeUnit; import com.massivecraft.massivecore.util.TimeUnit;
@ -35,13 +33,7 @@ public class TaskEconLandReward extends ModuloRepeatTask
@Override @Override
public void invoke(long now) public void invoke(long now)
{ {
for (FactionColl coll : FactionColls.get().getColls()) FactionColl.get().econLandRewardRoutine();
{
// Check disabled
if (UConf.isDisabled(coll)) continue;
coll.econLandRewardRoutine();
}
} }
} }

View File

@ -1,9 +1,7 @@
package com.massivecraft.factions.task; package com.massivecraft.factions.task;
import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.entity.UConf; import com.massivecraft.factions.entity.MPlayerColl;
import com.massivecraft.factions.entity.UPlayerColl;
import com.massivecraft.factions.entity.UPlayerColls;
import com.massivecraft.massivecore.ModuloRepeatTask; import com.massivecraft.massivecore.ModuloRepeatTask;
import com.massivecraft.massivecore.util.TimeUnit; import com.massivecraft.massivecore.util.TimeUnit;
@ -35,13 +33,7 @@ public class TaskPlayerDataRemove extends ModuloRepeatTask
@Override @Override
public void invoke(long now) public void invoke(long now)
{ {
for (UPlayerColl coll : UPlayerColls.get().getColls()) MPlayerColl.get().removePlayerDataAfterInactiveDaysRoutine();
{
// Check disabled
if (UConf.isDisabled(coll)) continue;
coll.removePlayerDataAfterInactiveDaysRoutine();
}
} }
} }

View File

@ -4,8 +4,7 @@ import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.entity.UConf; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.event.EventFactionsPowerChange; import com.massivecraft.factions.event.EventFactionsPowerChange;
import com.massivecraft.factions.event.EventFactionsPowerChange.PowerChangeReason; import com.massivecraft.factions.event.EventFactionsPowerChange.PowerChangeReason;
import com.massivecraft.massivecore.ModuloRepeatTask; import com.massivecraft.massivecore.ModuloRepeatTask;
@ -43,20 +42,17 @@ public class TaskPlayerPowerUpdate extends ModuloRepeatTask
for (Player player : Bukkit.getOnlinePlayers()) for (Player player : Bukkit.getOnlinePlayers())
{ {
// Check disabled
if (UConf.isDisabled(player)) continue;
if (player.isDead()) continue; if (player.isDead()) continue;
UPlayer uplayer = UPlayer.get(player); MPlayer mplayer = MPlayer.get(player);
double newPower = uplayer.getPower() + uplayer.getPowerPerHour() * millis / TimeUnit.MILLIS_PER_HOUR; double newPower = mplayer.getPower() + mplayer.getPowerPerHour() * millis / TimeUnit.MILLIS_PER_HOUR;
EventFactionsPowerChange event = new EventFactionsPowerChange(null, uplayer, PowerChangeReason.TIME, newPower); EventFactionsPowerChange event = new EventFactionsPowerChange(null, mplayer, PowerChangeReason.TIME, newPower);
event.run(); event.run();
if (event.isCancelled()) continue; if (event.isCancelled()) continue;
newPower = event.getNewPower(); newPower = event.getNewPower();
uplayer.setPower(newPower); mplayer.setPower(newPower);
} }
} }

View File

@ -5,7 +5,7 @@ import org.bukkit.ChatColor;
import com.massivecraft.factions.FFlag; import com.massivecraft.factions.FFlag;
import com.massivecraft.factions.Rel; import com.massivecraft.factions.Rel;
import com.massivecraft.factions.RelationParticipator; import com.massivecraft.factions.RelationParticipator;
import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.MConf;
import com.massivecraft.massivecore.util.Txt; import com.massivecraft.massivecore.util.Txt;
@ -29,7 +29,7 @@ public class RelationUtil
if (that instanceof Faction) if (that instanceof Faction)
{ {
if (me instanceof UPlayer && myFaction == thatFaction) if (me instanceof MPlayer && myFaction == thatFaction)
{ {
ret = "your faction"; ret = "your faction";
} }
@ -38,9 +38,9 @@ public class RelationUtil
ret = thatFaction.getName(); ret = thatFaction.getName();
} }
} }
else if (that instanceof UPlayer) else if (that instanceof MPlayer)
{ {
UPlayer uplayerthat = (UPlayer) that; MPlayer uplayerthat = (MPlayer) that;
if (that == me) if (that == me)
{ {
ret = "you"; ret = "you";
@ -98,9 +98,9 @@ public class RelationUtil
ret = Rel.MEMBER; ret = Rel.MEMBER;
// Do officer and leader check // Do officer and leader check
//P.p.log("getRelationOfThatToMe the factions are the same for "+that.getClass().getSimpleName()+" and observer "+me.getClass().getSimpleName()); //P.p.log("getRelationOfThatToMe the factions are the same for "+that.getClass().getSimpleName()+" and observer "+me.getClass().getSimpleName());
if (that instanceof UPlayer) if (that instanceof MPlayer)
{ {
ret = ((UPlayer)that).getRole(); ret = ((MPlayer)that).getRole();
//P.p.log("getRelationOfThatToMe it was a player and role is "+ret); //P.p.log("getRelationOfThatToMe it was a player and role is "+ret);
} }
} }
@ -119,9 +119,9 @@ public class RelationUtil
return (Faction) rp; return (Faction) rp;
} }
if (rp instanceof UPlayer) if (rp instanceof MPlayer)
{ {
return ((UPlayer) rp).getFaction(); return ((MPlayer) rp).getFaction();
} }
// ERROR // ERROR