This commit is contained in:
Video 2022-09-11 06:04:01 -06:00
parent 4d98108a46
commit 0dd7bc06eb
2 changed files with 10 additions and 15 deletions

View File

@ -16,6 +16,7 @@ import org.bukkit.scheduler.BukkitTask;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID;
public class FPlayer public class FPlayer
{ {
@ -26,7 +27,7 @@ public class FPlayer
private final TotalFreedomMod plugin; private final TotalFreedomMod plugin;
private final String name; private final String name;
private final UUID uuid;
private final String ip; private final String ip;
// //
private final FreezeData freezeData = new FreezeData(this); private final FreezeData freezeData = new FreezeData(this);
@ -70,12 +71,13 @@ public class FPlayer
public FPlayer(TotalFreedomMod plugin, Player player) public FPlayer(TotalFreedomMod plugin, Player player)
{ {
this(plugin, player.getName(), FUtil.getIp(player)); this(plugin, player.getUniqueId(), player.getName(), FUtil.getIp(player));
} }
private FPlayer(TotalFreedomMod plugin, String name, String ip) private FPlayer(TotalFreedomMod plugin, UUID uuid, String name, String ip)
{ {
this.plugin = plugin; this.plugin = plugin;
this.uuid = uuid;
this.name = name; this.name = name;
this.ip = ip; this.ip = ip;
} }
@ -94,14 +96,7 @@ public class FPlayer
if (player == null) if (player == null)
{ {
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) player = Bukkit.getPlayer(uuid);
{
if (FUtil.getIp(onlinePlayer).equals(ip))
{
player = onlinePlayer;
break;
}
}
} }
return player; return player;

View File

@ -17,7 +17,7 @@ import org.bukkit.entity.Player;
public class PlayerList extends FreedomService public class PlayerList extends FreedomService
{ {
public final Map<String, FPlayer> playerMap = Maps.newHashMap(); // ip,dataMap public final Map<UUID, FPlayer> playerMap = Maps.newHashMap(); // uuid, dataMap
public final Map<UUID, PlayerData> dataMap = Maps.newHashMap(); // uuid, data public final Map<UUID, PlayerData> dataMap = Maps.newHashMap(); // uuid, data
@Override @Override
@ -107,14 +107,14 @@ public class PlayerList extends FreedomService
// May not return null // May not return null
public FPlayer getPlayer(Player player) public FPlayer getPlayer(Player player)
{ {
FPlayer tPlayer = playerMap.get(FUtil.getIp(player)); FPlayer tPlayer = playerMap.get(player.getUniqueId());
if (tPlayer != null) if (tPlayer != null)
{ {
return tPlayer; return tPlayer;
} }
tPlayer = new FPlayer(plugin, player); tPlayer = new FPlayer(plugin, player);
playerMap.put(FUtil.getIp(player), tPlayer); playerMap.put(player.getUniqueId(), tPlayer);
return tPlayer; return tPlayer;
} }
@ -233,7 +233,7 @@ public class PlayerList extends FreedomService
return player; return player;
} }
public Map<String, FPlayer> getPlayerMap() public Map<UUID, FPlayer> getPlayerMap()
{ {
return playerMap; return playerMap;
} }