2015-08-08 20:58:45 +00:00
|
|
|
package tk.sznp.thebuttonautoflair;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
2015-10-17 00:06:32 +00:00
|
|
|
import java.util.UUID;
|
2015-08-08 20:58:45 +00:00
|
|
|
|
2015-10-02 22:15:13 +00:00
|
|
|
import org.bukkit.Location;
|
2015-10-17 00:06:32 +00:00
|
|
|
import org.bukkit.configuration.ConfigurationSection;
|
|
|
|
import org.bukkit.configuration.file.YamlConfiguration;
|
2015-10-02 22:15:13 +00:00
|
|
|
|
2015-08-31 19:21:20 +00:00
|
|
|
public class MaybeOfflinePlayer { // 2015.08.08.
|
2015-08-08 20:58:45 +00:00
|
|
|
public String PlayerName;
|
|
|
|
public String UserName;
|
2015-08-31 19:21:20 +00:00
|
|
|
public String Flair; // If the user comments their name, it gets set, it
|
|
|
|
// doesn't matter if they accepted it or not
|
2015-08-08 20:58:45 +00:00
|
|
|
public boolean AcceptedFlair;
|
|
|
|
public boolean IgnoredFlair;
|
2015-11-20 22:02:22 +00:00
|
|
|
public boolean FlairDecided; // 2015.08.09. //TODO: Detect date
|
2015-08-31 19:21:20 +00:00
|
|
|
public boolean FlairRecognised; // 2015.08.10.
|
|
|
|
public boolean CommentedOnReddit; // 2015.08.10.
|
|
|
|
public boolean RPMode; // 2015.08.25.
|
2015-10-17 00:06:32 +00:00
|
|
|
public boolean PressedF; // 2015.09.18.
|
|
|
|
public Location SavedLocation; // 2015.10.02.
|
2015-08-31 19:21:20 +00:00
|
|
|
|
2015-10-17 00:06:32 +00:00
|
|
|
public UUID UUID;
|
|
|
|
|
|
|
|
public static HashMap<UUID, MaybeOfflinePlayer> AllPlayers = new HashMap<>();
|
|
|
|
|
|
|
|
public static MaybeOfflinePlayer AddPlayerIfNeeded(UUID uuid) {
|
|
|
|
if (!AllPlayers.containsKey(uuid)) {
|
2015-08-31 19:21:20 +00:00
|
|
|
MaybeOfflinePlayer player = new MaybeOfflinePlayer();
|
2015-10-17 00:06:32 +00:00
|
|
|
// player.PlayerName = playername;
|
|
|
|
player.UUID = uuid;
|
2015-08-31 19:21:20 +00:00
|
|
|
player.Flair = ""; // 2015.08.10.
|
2015-10-17 00:06:32 +00:00
|
|
|
AllPlayers.put(uuid, player);
|
2015-08-31 19:21:20 +00:00
|
|
|
return player;
|
2015-08-08 20:58:45 +00:00
|
|
|
}
|
2015-10-17 00:06:32 +00:00
|
|
|
return AllPlayers.get(uuid);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void Load(YamlConfiguration yc) {
|
|
|
|
ConfigurationSection cs = yc.getConfigurationSection("players");
|
|
|
|
for (String key : cs.getKeys(false)) {
|
|
|
|
ConfigurationSection cs2 = cs.getConfigurationSection(key);
|
|
|
|
MaybeOfflinePlayer mp = AddPlayerIfNeeded(java.util.UUID
|
|
|
|
.fromString(cs2.getString("uuid")));
|
|
|
|
mp.UserName = cs2.getString("username");
|
|
|
|
mp.Flair = cs2.getString("flair");
|
|
|
|
mp.AcceptedFlair = cs2.getBoolean("acceptedflair");
|
|
|
|
mp.IgnoredFlair = cs2.getBoolean("ignoredflair");
|
|
|
|
mp.FlairDecided = cs2.getBoolean("flairdecided");
|
|
|
|
mp.FlairRecognised = cs2.getBoolean("flairrecognised");
|
|
|
|
mp.CommentedOnReddit = cs2.getBoolean("commentedonreddit");
|
|
|
|
mp.PlayerName = cs2.getString("playername");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void Save(YamlConfiguration yc) {
|
|
|
|
ConfigurationSection cs = yc
|
|
|
|
.createSection("players");
|
|
|
|
for (MaybeOfflinePlayer mp : MaybeOfflinePlayer.AllPlayers.values()) {
|
|
|
|
ConfigurationSection cs2 = cs.createSection(mp.UUID.toString());
|
|
|
|
cs2.set("playername", mp.PlayerName);
|
|
|
|
cs2.set("username", mp.UserName);
|
|
|
|
cs2.set("flair", mp.Flair);
|
|
|
|
cs2.set("acceptedflair", mp.AcceptedFlair);
|
|
|
|
cs2.set("ignoredflair", mp.IgnoredFlair);
|
|
|
|
cs2.set("flairdecided", mp.FlairDecided);
|
|
|
|
cs2.set("flairrecognised", mp.FlairRecognised);
|
|
|
|
cs2.set("commentedonreddit", mp.CommentedOnReddit);
|
|
|
|
cs2.set("uuid", mp.UUID.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static MaybeOfflinePlayer GetFromName(String name)
|
|
|
|
{
|
|
|
|
for(MaybeOfflinePlayer mp : AllPlayers.values())
|
|
|
|
if(mp.PlayerName.equalsIgnoreCase(name))
|
|
|
|
return mp;
|
|
|
|
return null;
|
2015-08-31 19:21:20 +00:00
|
|
|
}
|
2015-08-08 20:58:45 +00:00
|
|
|
}
|