Skip to content

Commit

Permalink
Added MCPlayer#isOnline
Browse files Browse the repository at this point in the history
  • Loading branch information
xDec0de committed Nov 5, 2024
1 parent 5c034c0 commit 528a3a8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ public String getName() {
return handle.getName();
}

@Override
public boolean isOnline() {
return handle.isOnline();
}

// Messages //

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ public String getName() {
return handle.getUsername();
}

@Override
public boolean isOnline() {
return handle.isActive();
}

// Messages //

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ public interface MCPlayer extends MessageReceiver, Replacement {
@NotNull
String getName();

boolean isOnline();

/*
* Legacy actionbar messages (String)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ public abstract class PlayerProvider<T> {
@Nullable
public MCPlayer getPlayer(@NotNull UUID uuid) {
MCPlayer player = playerCache.get(uuid);
if (player != null)
return player;
if (player != null) {
if (player.isOnline())
return player;
playerCache.remove(uuid);
}
player = fetchPlayer(uuid);
if (player != null)
playerCache.put(uuid, player);
Expand Down

0 comments on commit 528a3a8

Please sign in to comment.