2011-10-08 22:03:44 +02:00
|
|
|
package com.massivecraft.factions;
|
|
|
|
|
2014-10-25 20:22:41 +02:00
|
|
|
import com.google.gson.reflect.TypeToken;
|
2014-04-04 20:55:21 +02:00
|
|
|
import com.massivecraft.factions.zcore.persist.PlayerEntityCollection;
|
|
|
|
|
2011-10-08 22:03:44 +02:00
|
|
|
import java.io.File;
|
|
|
|
import java.lang.reflect.Type;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.concurrent.ConcurrentSkipListMap;
|
|
|
|
import java.util.concurrent.CopyOnWriteArrayList;
|
|
|
|
|
2014-04-04 20:55:21 +02:00
|
|
|
public class FPlayers extends PlayerEntityCollection<FPlayer> {
|
2014-08-05 17:17:27 +02:00
|
|
|
|
2014-04-04 20:55:21 +02:00
|
|
|
public static FPlayers i = new FPlayers();
|
|
|
|
|
|
|
|
P p = P.p;
|
|
|
|
|
|
|
|
private FPlayers() {
|
2014-07-01 21:52:40 +02:00
|
|
|
super(FPlayer.class, new CopyOnWriteArrayList<FPlayer>(), new ConcurrentSkipListMap<String, FPlayer>(String.CASE_INSENSITIVE_ORDER), new File(P.p.getDataFolder(), "players.json"), P.p.gson);
|
2014-04-04 20:55:21 +02:00
|
|
|
|
|
|
|
this.setCreative(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Type getMapType() {
|
2014-07-01 22:10:18 +02:00
|
|
|
return new TypeToken<Map<String, FPlayer>>() {
|
|
|
|
}.getType();
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
2011-10-08 22:03:44 +02:00
|
|
|
|
2014-04-04 20:55:21 +02:00
|
|
|
public void clean() {
|
|
|
|
for (FPlayer fplayer : this.get()) {
|
|
|
|
if (!Factions.i.exists(fplayer.getFactionId())) {
|
|
|
|
p.log("Reset faction data (invalid faction) for player " + fplayer.getName());
|
|
|
|
fplayer.resetFactionData(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-10-08 22:03:44 +02:00
|
|
|
}
|