Factions Cleanup - Database lazy cleaning
This commit is contained in:
		@@ -157,32 +157,6 @@ public class Board extends Entity<Board> implements BoardInterface
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// Removes orphaned foreign keys
 | 
			
		||||
	@Override
 | 
			
		||||
	public int clean()
 | 
			
		||||
	{
 | 
			
		||||
		int ret = 0;
 | 
			
		||||
		
 | 
			
		||||
		if (!FactionColl.get().isActive()) return ret;
 | 
			
		||||
		
 | 
			
		||||
		for (Entry<PS, TerritoryAccess> entry : this.map.entrySet())
 | 
			
		||||
		{
 | 
			
		||||
			TerritoryAccess territoryAccess = entry.getValue();
 | 
			
		||||
			String factionId = territoryAccess.getHostFactionId();
 | 
			
		||||
			
 | 
			
		||||
			if (FactionColl.get().containsId(factionId)) continue;
 | 
			
		||||
			
 | 
			
		||||
			PS ps = entry.getKey();
 | 
			
		||||
			this.removeAt(ps);
 | 
			
		||||
			
 | 
			
		||||
			ret += 0;
 | 
			
		||||
			
 | 
			
		||||
			Factions.get().log("Board cleaner removed "+factionId+" from "+ps);
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		return ret;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// CHUNKS
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
 
 | 
			
		||||
@@ -117,19 +117,6 @@ public class BoardColl extends Coll<Board> implements BoardInterface
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public int clean()
 | 
			
		||||
	{
 | 
			
		||||
		int ret = 0;
 | 
			
		||||
		
 | 
			
		||||
		for (Board board : this.getAll())
 | 
			
		||||
		{
 | 
			
		||||
			ret += board.clean();
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		return ret;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// CHUNKS
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
 
 | 
			
		||||
@@ -21,7 +21,6 @@ public interface BoardInterface
 | 
			
		||||
	// REMOVE
 | 
			
		||||
	void removeAt(PS ps);
 | 
			
		||||
	void removeAll(Faction faction);
 | 
			
		||||
	int clean();
 | 
			
		||||
 | 
			
		||||
	// CHUNKS
 | 
			
		||||
	Set<PS> getChunks(Faction faction);
 | 
			
		||||
 
 | 
			
		||||
@@ -10,9 +10,10 @@ import com.massivecraft.factions.predicate.PredicateMPlayerRole;
 | 
			
		||||
import com.massivecraft.factions.util.MiscUtil;
 | 
			
		||||
import com.massivecraft.factions.util.RelationUtil;
 | 
			
		||||
import com.massivecraft.massivecore.collections.MassiveList;
 | 
			
		||||
import com.massivecraft.massivecore.collections.MassiveMap;
 | 
			
		||||
import com.massivecraft.massivecore.collections.MassiveMapDef;
 | 
			
		||||
import com.massivecraft.massivecore.collections.MassiveTreeSetDef;
 | 
			
		||||
import com.massivecraft.massivecore.comparator.ComparatorCaseInsensitive;
 | 
			
		||||
import com.massivecraft.massivecore.collections.MassiveSet;
 | 
			
		||||
import com.massivecraft.massivecore.collections.MassiveSetDef;
 | 
			
		||||
import com.massivecraft.massivecore.mixin.MixinMessage;
 | 
			
		||||
import com.massivecraft.massivecore.money.Money;
 | 
			
		||||
import com.massivecraft.massivecore.predicate.Predicate;
 | 
			
		||||
@@ -28,18 +29,14 @@ import org.bukkit.ChatColor;
 | 
			
		||||
import org.bukkit.command.CommandSender;
 | 
			
		||||
import org.bukkit.entity.Player;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
import java.util.Collection;
 | 
			
		||||
import java.util.HashSet;
 | 
			
		||||
import java.util.Iterator;
 | 
			
		||||
import java.util.LinkedHashMap;
 | 
			
		||||
import java.util.LinkedHashSet;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.Map.Entry;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
import java.util.TreeSet;
 | 
			
		||||
 | 
			
		||||
public class Faction extends Entity<Faction> implements FactionsParticipator
 | 
			
		||||
{
 | 
			
		||||
@@ -83,9 +80,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
 | 
			
		||||
	@Override
 | 
			
		||||
	public void preDetach(String id)
 | 
			
		||||
	{
 | 
			
		||||
		// The database must be fully inited.
 | 
			
		||||
		// We may move factions around during upgrades.
 | 
			
		||||
		if (!Factions.get().isDatabaseInitialized()) return;
 | 
			
		||||
		if (!this.isLive()) return;
 | 
			
		||||
		
 | 
			
		||||
		// NOTE: Existence check is required for compatibility with some plugins.
 | 
			
		||||
		// If they have money ...
 | 
			
		||||
@@ -94,12 +89,6 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
 | 
			
		||||
			// ... remove it.
 | 
			
		||||
			Money.set(this, null, 0);	
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Clean the board
 | 
			
		||||
		BoardColl.get().clean();
 | 
			
		||||
		
 | 
			
		||||
		// Clean the mplayers
 | 
			
		||||
		MPlayerColl.get().clean();
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
@@ -146,7 +135,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
 | 
			
		||||
	// This is the ids of the invited players.
 | 
			
		||||
	// They are actually "senderIds" since you can invite "@console" to your faction.
 | 
			
		||||
	// Null means no one is invited
 | 
			
		||||
	private MassiveTreeSetDef<String, ComparatorCaseInsensitive> invitedPlayerIds = new MassiveTreeSetDef<>(ComparatorCaseInsensitive.get());
 | 
			
		||||
	private MassiveSetDef<String> invitedPlayerIds = new MassiveSetDef<>();
 | 
			
		||||
	
 | 
			
		||||
	// The keys in this map are factionIds.
 | 
			
		||||
	// Null means no special relation whishes.
 | 
			
		||||
@@ -252,8 +241,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
 | 
			
		||||
		if (target != null)
 | 
			
		||||
		{
 | 
			
		||||
			target = target.trim();
 | 
			
		||||
			// This code should be kept for a while to clean out the previous default text that was actually stored in the database.
 | 
			
		||||
			if (target.length() == 0 || target.equals("Default faction description :("))
 | 
			
		||||
			if (target.isEmpty())
 | 
			
		||||
			{
 | 
			
		||||
				target = null;
 | 
			
		||||
			}
 | 
			
		||||
@@ -293,7 +281,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
 | 
			
		||||
		if (target != null)
 | 
			
		||||
		{
 | 
			
		||||
			target = target.trim();
 | 
			
		||||
			if (target.length() == 0)
 | 
			
		||||
			if (target.isEmpty())
 | 
			
		||||
			{
 | 
			
		||||
				target = null;
 | 
			
		||||
			}
 | 
			
		||||
@@ -463,7 +451,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
 | 
			
		||||
	
 | 
			
		||||
	// RAW
 | 
			
		||||
	
 | 
			
		||||
	public TreeSet<String> getInvitedPlayerIds()
 | 
			
		||||
	public Set<String> getInvitedPlayerIds()
 | 
			
		||||
	{
 | 
			
		||||
		return this.invitedPlayerIds;
 | 
			
		||||
	}
 | 
			
		||||
@@ -471,14 +459,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
 | 
			
		||||
	public void setInvitedPlayerIds(Collection<String> invitedPlayerIds)
 | 
			
		||||
	{
 | 
			
		||||
		// Clean input
 | 
			
		||||
		MassiveTreeSetDef<String, ComparatorCaseInsensitive> target = new MassiveTreeSetDef<>(ComparatorCaseInsensitive.get());
 | 
			
		||||
		if (invitedPlayerIds != null)
 | 
			
		||||
		{
 | 
			
		||||
			for (String invitedPlayerId : invitedPlayerIds)
 | 
			
		||||
			{
 | 
			
		||||
				target.add(invitedPlayerId.toLowerCase());
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		MassiveSetDef<String> target = new MassiveSetDef<>(invitedPlayerIds);
 | 
			
		||||
		
 | 
			
		||||
		// Detect Nochange
 | 
			
		||||
		if (MUtil.equals(this.invitedPlayerIds, target)) return;
 | 
			
		||||
@@ -504,7 +485,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
 | 
			
		||||
	
 | 
			
		||||
	public boolean setInvited(String playerId, boolean invited)
 | 
			
		||||
	{
 | 
			
		||||
		List<String> invitedPlayerIds = new ArrayList<>(this.getInvitedPlayerIds());
 | 
			
		||||
		List<String> invitedPlayerIds = new MassiveList<>(this.getInvitedPlayerIds());
 | 
			
		||||
		boolean ret;
 | 
			
		||||
		if (invited)
 | 
			
		||||
		{
 | 
			
		||||
@@ -516,7 +497,6 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
 | 
			
		||||
		}
 | 
			
		||||
		this.setInvitedPlayerIds(invitedPlayerIds);
 | 
			
		||||
		return ret;
 | 
			
		||||
		
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public void setInvited(MPlayer mplayer, boolean invited)
 | 
			
		||||
@@ -526,13 +506,14 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
 | 
			
		||||
	
 | 
			
		||||
	public List<MPlayer> getInvitedMPlayers()
 | 
			
		||||
	{
 | 
			
		||||
		List<MPlayer> mplayers = new ArrayList<>();
 | 
			
		||||
		List<MPlayer> mplayers = new MassiveList<>();
 | 
			
		||||
		
 | 
			
		||||
		for (String id : this.getInvitedPlayerIds())
 | 
			
		||||
		{	
 | 
			
		||||
			MPlayer mplayer = MPlayer.get(id);
 | 
			
		||||
			mplayers.add(mplayer);
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		return mplayers;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
@@ -604,7 +585,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
 | 
			
		||||
	public Map<MFlag, Boolean> getFlags()
 | 
			
		||||
	{
 | 
			
		||||
		// We start with default values ...
 | 
			
		||||
		Map<MFlag, Boolean> ret = new LinkedHashMap<>();
 | 
			
		||||
		Map<MFlag, Boolean> ret = new MassiveMap<>();
 | 
			
		||||
		for (MFlag mflag : MFlag.getAll())
 | 
			
		||||
		{
 | 
			
		||||
			ret.put(mflag, mflag.isStandard());
 | 
			
		||||
@@ -638,7 +619,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
 | 
			
		||||
	
 | 
			
		||||
	public void setFlags(Map<MFlag, Boolean> flags)
 | 
			
		||||
	{
 | 
			
		||||
		Map<String, Boolean> flagIds = new LinkedHashMap<>();
 | 
			
		||||
		Map<String, Boolean> flagIds = new MassiveMap<>();
 | 
			
		||||
		for (Entry<MFlag, Boolean> entry : flags.entrySet())
 | 
			
		||||
		{
 | 
			
		||||
			flagIds.put(entry.getKey().getId(), entry.getValue());
 | 
			
		||||
@@ -730,10 +711,10 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
 | 
			
		||||
	public Map<MPerm, Set<Rel>> getPerms()
 | 
			
		||||
	{
 | 
			
		||||
		// We start with default values ...
 | 
			
		||||
		Map<MPerm, Set<Rel>> ret = new LinkedHashMap<>();
 | 
			
		||||
		Map<MPerm, Set<Rel>> ret = new MassiveMap<>();
 | 
			
		||||
		for (MPerm mperm : MPerm.getAll())
 | 
			
		||||
		{
 | 
			
		||||
			ret.put(mperm, new LinkedHashSet<>(mperm.getStandard()));
 | 
			
		||||
			ret.put(mperm, new MassiveSet<>(mperm.getStandard()));
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// ... and if anything is explicitly set we use that info ...
 | 
			
		||||
@@ -755,7 +736,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
 | 
			
		||||
			MPerm mperm = MPerm.get(id);
 | 
			
		||||
			if (mperm == null) continue;
 | 
			
		||||
			
 | 
			
		||||
			ret.put(mperm, new LinkedHashSet<>(entry.getValue()));
 | 
			
		||||
			ret.put(mperm, new MassiveSet<>(entry.getValue()));
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		return ret;
 | 
			
		||||
@@ -763,7 +744,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
 | 
			
		||||
	
 | 
			
		||||
	public void setPerms(Map<MPerm, Set<Rel>> perms)
 | 
			
		||||
	{
 | 
			
		||||
		Map<String, Set<Rel>> permIds = new LinkedHashMap<>();
 | 
			
		||||
		Map<String, Set<Rel>> permIds = new MassiveMap<>();
 | 
			
		||||
		for (Entry<MPerm, Set<Rel>> entry : perms.entrySet())
 | 
			
		||||
		{
 | 
			
		||||
			permIds.put(entry.getKey().getId(), entry.getValue());
 | 
			
		||||
@@ -1054,7 +1035,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
 | 
			
		||||
	public List<CommandSender> getOnlineCommandSenders()
 | 
			
		||||
	{
 | 
			
		||||
		// Create Ret
 | 
			
		||||
		List<CommandSender> ret = new ArrayList<>();
 | 
			
		||||
		List<CommandSender> ret = new MassiveList<>();
 | 
			
		||||
		
 | 
			
		||||
		// Fill Ret
 | 
			
		||||
		for (CommandSender sender : IdUtil.getLocalSenders())
 | 
			
		||||
@@ -1074,7 +1055,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
 | 
			
		||||
	public List<Player> getOnlinePlayers()
 | 
			
		||||
	{
 | 
			
		||||
		// Create Ret
 | 
			
		||||
		List<Player> ret = new ArrayList<>();
 | 
			
		||||
		List<Player> ret = new MassiveList<>();
 | 
			
		||||
		
 | 
			
		||||
		// Fill Ret
 | 
			
		||||
		for (Player player : MUtil.getOnlinePlayers())
 | 
			
		||||
 
 | 
			
		||||
@@ -47,26 +47,6 @@ public class FactionColl extends Coll<Faction>
 | 
			
		||||
		this.createSpecialFactions();
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public Faction get(Object oid)
 | 
			
		||||
	{
 | 
			
		||||
		Faction ret = super.get(oid);
 | 
			
		||||
		
 | 
			
		||||
		// We should only trigger automatic clean if the whole database system is initialized.
 | 
			
		||||
		// A cleaning can only be successful if all data is available.
 | 
			
		||||
		// Example Reason: When creating the special factions for the first time "createSpecialFactions" a clean would be triggered otherwise.
 | 
			
		||||
		if (ret == null && Factions.get().isDatabaseInitialized())
 | 
			
		||||
		{
 | 
			
		||||
			String message = Txt.parse("<b>Non existing factionId <h>%s <b>requested. <i>Cleaning all boards and mplayers.", this.fixId(oid));
 | 
			
		||||
			Factions.get().log(message);
 | 
			
		||||
			
 | 
			
		||||
			BoardColl.get().clean();
 | 
			
		||||
			MPlayerColl.get().clean();
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		return ret;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// SPECIAL FACTIONS
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
 
 | 
			
		||||
@@ -27,6 +27,7 @@ import org.bukkit.ChatColor;
 | 
			
		||||
import org.bukkit.command.CommandSender;
 | 
			
		||||
import org.bukkit.entity.Player;
 | 
			
		||||
 | 
			
		||||
import java.lang.ref.WeakReference;
 | 
			
		||||
import java.util.Collection;
 | 
			
		||||
import java.util.HashSet;
 | 
			
		||||
import java.util.Iterator;
 | 
			
		||||
@@ -166,13 +167,20 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
 | 
			
		||||
	// Null means default specified in MConf.
 | 
			
		||||
	private Boolean territoryInfoTitles = null;
 | 
			
		||||
 | 
			
		||||
	// The id for the faction this player is currently autoclaiming for.
 | 
			
		||||
	// The Faction this player is currently autoclaiming for.
 | 
			
		||||
	// Null means the player isn't auto claiming.
 | 
			
		||||
	// NOTE: This field will not be saved to the database ever.
 | 
			
		||||
	private transient Faction autoClaimFaction = null;
 | 
			
		||||
	private transient WeakReference<Faction> autoClaimFaction = new WeakReference<>(null);
 | 
			
		||||
 | 
			
		||||
	public Faction getAutoClaimFaction() { return this.autoClaimFaction; }
 | 
			
		||||
	public void setAutoClaimFaction(Faction autoClaimFaction) { this.autoClaimFaction = autoClaimFaction; }
 | 
			
		||||
	public Faction getAutoClaimFaction()
 | 
			
		||||
	{
 | 
			
		||||
		if (this.isFactionOrphan()) return null;
 | 
			
		||||
		Faction ret = this.autoClaimFaction.get();
 | 
			
		||||
		if (ret == null) return null;
 | 
			
		||||
		if (ret.detached()) return null;
 | 
			
		||||
		return ret;
 | 
			
		||||
	}
 | 
			
		||||
	public void setAutoClaimFaction(Faction autoClaimFaction) { this.autoClaimFaction = new WeakReference<>(autoClaimFaction); }
 | 
			
		||||
 | 
			
		||||
	// Does the player have /f seechunk activated?
 | 
			
		||||
	// NOTE: This field will not be saved to the database ever.
 | 
			
		||||
@@ -225,31 +233,43 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// FIELD: factionId
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
 | 
			
		||||
	@Deprecated
 | 
			
		||||
	public String getDefaultFactionId()
 | 
			
		||||
	
 | 
			
		||||
	private Faction getFactionInternal()
 | 
			
		||||
	{
 | 
			
		||||
		return MConf.get().defaultPlayerFactionId;
 | 
			
		||||
		String effectiveFactionId = this.convertGet(this.factionId, MConf.get().defaultPlayerFactionId);
 | 
			
		||||
		return Faction.get(effectiveFactionId);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public boolean isFactionOrphan()
 | 
			
		||||
	{
 | 
			
		||||
		return this.getFactionInternal() == null;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// This method never returns null
 | 
			
		||||
	@Deprecated
 | 
			
		||||
	public String getFactionId()
 | 
			
		||||
	{
 | 
			
		||||
		if (this.factionId == null) return MConf.get().defaultPlayerFactionId;
 | 
			
		||||
		return this.factionId;
 | 
			
		||||
		return this.getFaction().getId();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// This method never returns null
 | 
			
		||||
	public Faction getFaction()
 | 
			
		||||
	{
 | 
			
		||||
		Faction ret = Faction.get(this.getFactionId());
 | 
			
		||||
		if (ret == null) ret = Faction.get(MConf.get().defaultPlayerFactionId);
 | 
			
		||||
		Faction ret;
 | 
			
		||||
		
 | 
			
		||||
		ret = this.getFactionInternal();
 | 
			
		||||
		
 | 
			
		||||
		// Adopt orphans
 | 
			
		||||
		if (ret == null)
 | 
			
		||||
		{
 | 
			
		||||
			ret = FactionColl.get().getNone();
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		return ret;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
	public boolean hasFaction()
 | 
			
		||||
	{
 | 
			
		||||
		return !this.getFactionId().equals(Factions.ID_NONE);
 | 
			
		||||
		return !this.getFaction().isNone();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// This setter is so long because it search for default/null case and takes
 | 
			
		||||
@@ -284,14 +304,10 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
 | 
			
		||||
	// FIELD: role
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
 | 
			
		||||
	@Deprecated
 | 
			
		||||
	public Rel getDefaultRole()
 | 
			
		||||
	{
 | 
			
		||||
		return MConf.get().defaultPlayerRole;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public Rel getRole()
 | 
			
		||||
	{
 | 
			
		||||
		if (this.isFactionOrphan()) return Rel.RECRUIT;
 | 
			
		||||
		
 | 
			
		||||
		if (this.role == null) return MConf.get().defaultPlayerRole;
 | 
			
		||||
		return this.role;
 | 
			
		||||
	}
 | 
			
		||||
@@ -314,15 +330,20 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// FIELD: title
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
 | 
			
		||||
	// TODO: Improve upon the has and get stuff.
 | 
			
		||||
	// TODO: Has should depend on get. Visualisation should be done elsewhere.
 | 
			
		||||
	
 | 
			
		||||
	public boolean hasTitle()
 | 
			
		||||
	{
 | 
			
		||||
		return this.title != null;
 | 
			
		||||
		return !this.isFactionOrphan() && this.title != null;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public String getTitle()
 | 
			
		||||
	{
 | 
			
		||||
		if (this.isFactionOrphan()) return NOTITLE;
 | 
			
		||||
		
 | 
			
		||||
		if (this.hasTitle()) return this.title;
 | 
			
		||||
		
 | 
			
		||||
		return NOTITLE;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -339,15 +360,6 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// 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;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -2,8 +2,6 @@ package com.massivecraft.factions.entity;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Factions;
 | 
			
		||||
import com.massivecraft.massivecore.store.SenderColl;
 | 
			
		||||
import com.massivecraft.massivecore.util.IdUtil;
 | 
			
		||||
import com.massivecraft.massivecore.util.Txt;
 | 
			
		||||
import org.bukkit.Bukkit;
 | 
			
		||||
 | 
			
		||||
import java.util.Collection;
 | 
			
		||||
@@ -31,31 +29,6 @@ public class MPlayerColl extends SenderColl<MPlayer>
 | 
			
		||||
	// EXTRAS
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public int clean()
 | 
			
		||||
	{
 | 
			
		||||
		int ret = 0;
 | 
			
		||||
		
 | 
			
		||||
		if (!FactionColl.get().isActive()) return ret;
 | 
			
		||||
		
 | 
			
		||||
		// For each player ...
 | 
			
		||||
		for (MPlayer mplayer : this.getAll())
 | 
			
		||||
		{
 | 
			
		||||
			// ... who doesn't have a valid faction ...
 | 
			
		||||
			String factionId = mplayer.getFactionId();
 | 
			
		||||
			if (FactionColl.get().containsId(factionId)) continue;
 | 
			
		||||
			
 | 
			
		||||
			// ... reset their faction data ...
 | 
			
		||||
			mplayer.resetFactionData();
 | 
			
		||||
			ret += 1;
 | 
			
		||||
			
 | 
			
		||||
			// ... and log.
 | 
			
		||||
			String message = Txt.parse("<i>Reset data for <h>%s <i>. Unknown factionId <h>%s", mplayer.getDisplayName(IdUtil.getConsole()), factionId);
 | 
			
		||||
			Factions.get().log(message);
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		return ret;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public void considerRemovePlayerMillis()
 | 
			
		||||
	{
 | 
			
		||||
		// If the config option is 0 or below that means the server owner want it disabled.
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user