Skip to content

Commit

Permalink
PlayerTag: track id internally, not OfflinePlayer
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Aug 8, 2022
1 parent b1d7517 commit 196166c
Showing 1 changed file with 10 additions and 19 deletions.
Expand Up @@ -208,11 +208,11 @@ public static boolean playerNameIsValid(String name) {
/////////////////

public PlayerTag(OfflinePlayer player) {
offlinePlayer = player;
this(player.getUniqueId());
}

public PlayerTag(UUID uuid) {
offlinePlayer = Bukkit.getOfflinePlayer(uuid);
this.uuid = uuid;
}

public PlayerTag(Player player) {
Expand All @@ -236,28 +236,22 @@ public void reapplyTracker(AbstractFlagTracker tracker) {
// Nothing to do.
}

OfflinePlayer offlinePlayer;
UUID uuid;

public boolean isValid() {
return getPlayerEntity() != null || getOfflinePlayer() != null;
}

public Player getPlayerEntity() {
if (offlinePlayer == null) {
return null;
}
return Bukkit.getPlayer(offlinePlayer.getUniqueId());
return Bukkit.getPlayer(uuid);
}

public UUID getUUID() {
if (offlinePlayer == null) {
return null;
}
return offlinePlayer.getUniqueId();
return uuid;
}

public OfflinePlayer getOfflinePlayer() {
return offlinePlayer;
return Bukkit.getOfflinePlayer(uuid);
}

public ImprovedOfflinePlayer getNBTEditor() {
Expand All @@ -280,10 +274,7 @@ public NPCTag getSelectedNPC() {
}

public String getName() {
if (offlinePlayer == null) {
return null;
}
return offlinePlayer.getName();
return getOfflinePlayer().getName();
}

@Override
Expand Down Expand Up @@ -579,7 +570,7 @@ public PlayerTag setPrefix(String prefix) {

@Override
public String debuggable() {
return "<LG>p@<Y>" + offlinePlayer.getUniqueId() + "<GR> (" + offlinePlayer.getName() + ")";
return "<LG>p@<Y>" + uuid + "<GR> (" + getOfflinePlayer().getName() + ")";
}

@Override
Expand All @@ -594,12 +585,12 @@ public String getObjectType() {

@Override
public String identify() {
return "p@" + offlinePlayer.getUniqueId();
return "p@" + uuid;
}

@Override
public String identifySimple() {
return "p@" + offlinePlayer.getName();
return "p@" + getOfflinePlayer().getName();
}

@Override
Expand Down

0 comments on commit 196166c

Please sign in to comment.