Skip to content

Commit

Permalink
Add unregister method
Browse files Browse the repository at this point in the history
  • Loading branch information
Owen1212055 committed Jun 28, 2023
1 parent 071e91c commit 5775ec0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,12 @@ public CustomName forEntity(Entity entity) {

return customName;
}

public void unregister(Entity entity) {
CustomName customName = this.storage.remove(entity.getUniqueId());
if (customName != null) {
// Remove from trackers
customName.setHidden(true);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ public void registerNew(UUID entityId, CustomName name) {
this.customPlayerNameMap.put(entityId, name);
}

public void remove(UUID uuid) {
@Nullable
public CustomName remove(UUID uuid) {
CustomName name = this.customPlayerNameMap.remove(uuid);
if (name != null) {
name.close();
}

return name;
}
}

0 comments on commit 5775ec0

Please sign in to comment.