Saber-Factions/src/main/java/com/massivecraft/factions/FPlayers.java

45 lines
1.3 KiB
Java
Raw Normal View History

package com.massivecraft.factions;
2014-04-04 20:55:21 +02:00
import com.massivecraft.factions.zcore.persist.PlayerEntityCollection;
import org.bukkit.craftbukkit.libs.com.google.gson.reflect.TypeToken;
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> {
public static FPlayers i = new FPlayers();
P p = P.p;
private FPlayers() {
super
(
FPlayer.class,
new CopyOnWriteArrayList<FPlayer>(),
new ConcurrentSkipListMap<String, FPlayer>(String.CASE_INSENSITIVE_ORDER),
new File(P.p.getDataFolder(), "players.json"),
P.p.gson
);
this.setCreative(true);
}
@Override
public Type getMapType() {
return new TypeToken<Map<String, FPlayer>>() {
}.getType();
}
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);
}
}
}
}