[Bleeding] Prepared TFM_UserList for UUID switchover

This commit is contained in:
unknown 2014-04-04 14:03:48 +02:00
parent a3a484dc58
commit d087dc1148
8 changed files with 25 additions and 31 deletions

View File

@ -30,7 +30,7 @@ public class Command_findip extends TFM_Command
return true; return true;
} }
playerMsg("Player IPs: " + StringUtils.join(TFM_UserList.getInstance(TotalFreedomMod.plugin).getEntry(player).getIpAddresses(), ", ")); playerMsg("Player IPs: " + StringUtils.join(TFM_UserList.getInstance().getEntry(player).getIpAddresses(), ", "));
return true; return true;
} }

View File

@ -31,7 +31,7 @@ public class Command_glist extends TFM_Command
//Purge does not clear the banlist! This is not for clearing bans! This is for clearing the yaml file that stores the player/IP database! //Purge does not clear the banlist! This is not for clearing bans! This is for clearing the yaml file that stores the player/IP database!
if (TFM_SuperadminList.isSeniorAdmin(sender)) if (TFM_SuperadminList.isSeniorAdmin(sender))
{ {
TFM_UserList.getInstance(plugin).purge(); TFM_UserList.getInstance().purge();
} }
else else
{ {
@ -58,7 +58,7 @@ public class Command_glist extends TFM_Command
} }
catch (PlayerNotFoundException ex) catch (PlayerNotFoundException ex)
{ {
TFM_UserListEntry entry = TFM_UserList.getInstance(plugin).getEntry(args[1]); TFM_UserListEntry entry = TFM_UserList.getInstance().getEntry(args[1]);
if (entry == null) if (entry == null)
{ {

View File

@ -99,7 +99,7 @@ public class Command_rollback extends TFM_Command
if (playerName == null) if (playerName == null)
{ {
playerName = TFM_UserList.getInstance(plugin).searchByPartialName(playerNameInput); playerName = TFM_UserList.getInstance().searchByPartialName(playerNameInput);
} }
return playerName; return playerName;

View File

@ -692,10 +692,9 @@ public class TFM_PlayerListener implements Listener
playerdata.setSuperadminIdVerified(null); playerdata.setSuperadminIdVerified(null);
final String IP = player.getAddress().getAddress().getHostAddress().trim(); final String IP = player.getAddress().getAddress().getHostAddress().trim();
// Log join message, as 1.7 doesn't log it anymore TFM_Log.info("[JOIN] " + player.getName() + " (" + player.getUniqueId() + ") joined the game with IP address: " + IP, true);
TFM_Log.info("[JOIN] " + player.getName() + " joined the game with IP address: " + IP, true);
TFM_UserList.getInstance(TotalFreedomMod.plugin).addUser(player); TFM_UserList.getInstance().addUser(player);
final boolean impostor = TFM_SuperadminList.isSuperadminImpostor(player); final boolean impostor = TFM_SuperadminList.isSuperadminImpostor(player);

View File

@ -1,5 +1,6 @@
package me.StevenLawson.TotalFreedomMod; package me.StevenLawson.TotalFreedomMod;
import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import net.minecraft.util.org.apache.commons.lang3.StringUtils; import net.minecraft.util.org.apache.commons.lang3.StringUtils;
@ -71,7 +72,7 @@ public class TFM_Superadmin
public List<String> getIps() public List<String> getIps()
{ {
return ips; return Collections.unmodifiableList(ips);
} }
public Date getLastLogin() public Date getLastLogin()

View File

@ -3,6 +3,7 @@ package me.StevenLawson.TotalFreedomMod;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
@ -35,22 +36,22 @@ public class TFM_SuperadminList
public static List<String> getSuperadminIPs() public static List<String> getSuperadminIPs()
{ {
return superadminIPs; return Collections.unmodifiableList(superadminIPs);
} }
public static List<String> getSuperadminNames() public static List<String> getSuperadminNames()
{ {
return superadminNames; return Collections.unmodifiableList(superadminNames);
} }
public static List<String> getTelnetadminNames() public static List<String> getTelnetadminNames()
{ {
return telnetadminNames; return Collections.unmodifiableList(telnetadminNames);
} }
public static List<String> getSenioradminNames() public static List<String> getSenioradminNames()
{ {
return senioradminNames; return Collections.unmodifiableList(senioradminNames);
} }
public static void loadSuperadminList() public static void loadSuperadminList()

View File

@ -8,31 +8,28 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import net.minecraft.util.org.apache.commons.lang3.StringUtils; import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class TFM_UserList public class TFM_UserList
{ {
private static final TFM_UserList INSTANCE = new TFM_UserList();
private static final String USERLIST_FILENAME = "userlist.yml"; private static final String USERLIST_FILENAME = "userlist.yml";
private static TFM_UserList instance = null;
private Map<String, TFM_UserListEntry> userlist = new HashMap<String, TFM_UserListEntry>(); private Map<String, TFM_UserListEntry> userlist = new HashMap<String, TFM_UserListEntry>();
private final TotalFreedomMod plugin;
protected TFM_UserList(TotalFreedomMod plugin) private TFM_UserList()
{ {
this.plugin = plugin;
primeList();
} }
private void primeList() protected void primeList()
{ {
try try
{ {
userlist.clear(); userlist.clear();
FileConfiguration savedUserlist = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), USERLIST_FILENAME)); FileConfiguration savedUserlist = YamlConfiguration.loadConfiguration(new File(TotalFreedomMod.plugin.getDataFolder(), USERLIST_FILENAME));
for (String username : savedUserlist.getKeys(false)) for (String username : savedUserlist.getKeys(false))
{ {
@ -40,7 +37,7 @@ public class TFM_UserList
userlist.put(username, entry); userlist.put(username, entry);
} }
for (Player player : plugin.getServer().getOnlinePlayers()) for (Player player : Bukkit.getOnlinePlayers())
{ {
addUser(player); addUser(player);
} }
@ -56,7 +53,7 @@ public class TFM_UserList
private void exportList() private void exportList()
{ {
FileConfiguration newUserlist = new YamlConfiguration(); final FileConfiguration newUserlist = new YamlConfiguration();
for (TFM_UserListEntry entry : userlist.values()) for (TFM_UserListEntry entry : userlist.values())
{ {
@ -65,7 +62,7 @@ public class TFM_UserList
try try
{ {
newUserlist.save(new File(plugin.getDataFolder(), USERLIST_FILENAME)); newUserlist.save(new File(TotalFreedomMod.plugin.getDataFolder(), USERLIST_FILENAME));
} }
catch (IOException ex) catch (IOException ex)
{ {
@ -73,13 +70,9 @@ public class TFM_UserList
} }
} }
public static TFM_UserList getInstance(TotalFreedomMod plugin) public static TFM_UserList getInstance()
{ {
if (instance == null) return INSTANCE;
{
instance = new TFM_UserList(plugin);
}
return instance;
} }
public void addUser(Player player) public void addUser(Player player)
@ -119,7 +112,7 @@ public class TFM_UserList
{ {
userlist.clear(); userlist.clear();
for (Player player : plugin.getServer().getOnlinePlayers()) for (Player player : Bukkit.getOnlinePlayers())
{ {
addUser(player); addUser(player);
} }

View File

@ -87,7 +87,7 @@ public class TotalFreedomMod extends JavaPlugin
loadSuperadminConfig(); loadSuperadminConfig();
loadPermbanConfig(); loadPermbanConfig();
TFM_UserList.getInstance(plugin); TFM_UserList.getInstance().primeList();
registerEventHandlers(); registerEventHandlers();