2014-04-11 15:24:44 +00:00
|
|
|
package me.StevenLawson.TotalFreedomMod;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.UUID;
|
|
|
|
import org.bukkit.configuration.ConfigurationSection;
|
|
|
|
|
2014-06-29 10:09:03 +00:00
|
|
|
public class TFM_Player
|
2014-04-11 15:24:44 +00:00
|
|
|
{
|
|
|
|
private final UUID uuid;
|
|
|
|
private String firstJoinName;
|
|
|
|
private String lastJoinName;
|
2014-08-02 14:27:43 +00:00
|
|
|
private long firstJoinUnix;
|
|
|
|
private long lastJoinUnix;
|
2014-04-11 15:24:44 +00:00
|
|
|
private final List<String> ips;
|
|
|
|
|
2014-06-29 10:09:03 +00:00
|
|
|
protected TFM_Player(UUID uuid, ConfigurationSection section)
|
2014-04-11 15:24:44 +00:00
|
|
|
{
|
|
|
|
this(uuid);
|
|
|
|
|
|
|
|
this.firstJoinName = section.getString("firstjoinname");
|
|
|
|
this.lastJoinName = section.getString("lastjoinname");
|
|
|
|
|
2014-08-02 14:27:43 +00:00
|
|
|
this.firstJoinUnix = section.getLong("firstjoinunix");
|
|
|
|
this.lastJoinUnix = section.getLong("lastjoinunix");
|
2014-04-11 15:24:44 +00:00
|
|
|
|
|
|
|
this.ips.addAll(section.getStringList("ips"));
|
|
|
|
}
|
|
|
|
|
2014-06-29 10:09:03 +00:00
|
|
|
protected TFM_Player(UUID uuid, String firstJoinName, String lastJoinName, long firstJoinUnix, long lastJoinUnix, List<String> ips)
|
|
|
|
{
|
|
|
|
this(uuid);
|
|
|
|
|
|
|
|
this.firstJoinName = firstJoinName;
|
|
|
|
this.lastJoinName = lastJoinName;
|
|
|
|
|
2014-08-02 14:27:43 +00:00
|
|
|
this.firstJoinUnix = firstJoinUnix;
|
|
|
|
this.lastJoinUnix = lastJoinUnix;
|
2014-06-29 10:09:03 +00:00
|
|
|
|
|
|
|
this.ips.addAll(ips);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected TFM_Player(UUID uuid)
|
2014-04-11 15:24:44 +00:00
|
|
|
{
|
2014-06-29 14:39:25 +00:00
|
|
|
if (uuid == null)
|
|
|
|
{
|
|
|
|
throw new IllegalArgumentException("UUID can not be null!");
|
|
|
|
}
|
|
|
|
|
2014-04-11 15:24:44 +00:00
|
|
|
this.uuid = uuid;
|
|
|
|
this.ips = new ArrayList<String>();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Getters / Setters below
|
|
|
|
public UUID getUniqueId()
|
|
|
|
{
|
|
|
|
return uuid;
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<String> getIps()
|
|
|
|
{
|
|
|
|
return Collections.unmodifiableList(ips);
|
|
|
|
}
|
|
|
|
|
2014-06-29 10:09:03 +00:00
|
|
|
public String getFirstLoginName()
|
2014-04-11 15:24:44 +00:00
|
|
|
{
|
|
|
|
return firstJoinName;
|
|
|
|
}
|
|
|
|
|
2014-06-29 10:09:03 +00:00
|
|
|
public void setFirstLoginName(String firstJoinName)
|
2014-04-11 15:24:44 +00:00
|
|
|
{
|
|
|
|
this.firstJoinName = firstJoinName;
|
|
|
|
}
|
|
|
|
|
2014-06-29 10:09:03 +00:00
|
|
|
public String getLastLoginName()
|
2014-04-11 15:24:44 +00:00
|
|
|
{
|
|
|
|
return lastJoinName;
|
|
|
|
}
|
|
|
|
|
2014-06-29 10:09:03 +00:00
|
|
|
public void setLastLoginName(String lastJoinName)
|
2014-04-11 15:24:44 +00:00
|
|
|
{
|
|
|
|
this.lastJoinName = lastJoinName;
|
|
|
|
}
|
|
|
|
|
2014-06-29 10:09:03 +00:00
|
|
|
public long getFirstLoginUnix()
|
2014-04-11 15:24:44 +00:00
|
|
|
{
|
2014-08-02 14:27:43 +00:00
|
|
|
return firstJoinUnix;
|
2014-04-11 15:24:44 +00:00
|
|
|
}
|
|
|
|
|
2014-06-29 10:09:03 +00:00
|
|
|
public void setFirstLoginUnix(long firstJoinUnix)
|
2014-04-11 15:24:44 +00:00
|
|
|
{
|
2014-08-02 14:27:43 +00:00
|
|
|
this.firstJoinUnix = firstJoinUnix;
|
2014-04-11 15:24:44 +00:00
|
|
|
}
|
|
|
|
|
2014-06-29 10:09:03 +00:00
|
|
|
public long getLastLoginUnix()
|
2014-04-11 15:24:44 +00:00
|
|
|
{
|
2014-08-02 14:27:43 +00:00
|
|
|
return lastJoinUnix;
|
2014-04-11 15:24:44 +00:00
|
|
|
}
|
|
|
|
|
2014-06-29 10:09:03 +00:00
|
|
|
public void setLastLoginUnix(long lastJoinUnix)
|
2014-04-11 15:24:44 +00:00
|
|
|
{
|
2014-08-02 14:27:43 +00:00
|
|
|
this.lastJoinUnix = lastJoinUnix;
|
2014-04-11 15:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean addIp(String ip)
|
|
|
|
{
|
|
|
|
if (!ips.contains(ip))
|
|
|
|
{
|
|
|
|
ips.add(ip);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-08-02 14:27:43 +00:00
|
|
|
public final boolean isComplete()
|
2014-04-11 15:24:44 +00:00
|
|
|
{
|
|
|
|
return firstJoinName != null
|
|
|
|
&& lastJoinName != null
|
2014-08-02 14:27:43 +00:00
|
|
|
&& firstJoinUnix != 0
|
|
|
|
&& lastJoinUnix != 0
|
2014-04-11 15:24:44 +00:00
|
|
|
&& !ips.isEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void save()
|
2014-07-30 02:38:08 +00:00
|
|
|
{
|
2014-08-02 14:27:43 +00:00
|
|
|
TFM_PlayerList.save(this);
|
2014-04-11 15:24:44 +00:00
|
|
|
}
|
|
|
|
}
|