Skip to content

Commit

Permalink
2.1.1版本更新 修复 “OnNamePrefix” 为false时存在的报错现象
Browse files Browse the repository at this point in the history
  • Loading branch information
carm committed Oct 2, 2021
1 parent e14901a commit 41a9582
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>cc.carm.plugin</groupId>
<artifactId>UserPrefix</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>

<properties>
<maven.compiler.source>8</maven.compiler.source>
Expand Down
14 changes: 13 additions & 1 deletion src/main/java/cc/carm/plugin/userprefix/manager/UserManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,22 @@ public class UserManager {

public static HashSet<UUID> checkingPlayers = new HashSet<>();

@Nullable
public static UserNameTag getNameTag(Player player) {
return nameTags.get(player.getUniqueId());
if (!PrefixConfig.Functions.NAME_PREFIX.get()) {
if (nameTags.containsKey(player.getUniqueId())) {
return nameTags.get(player.getUniqueId());
} else {
return createNameTag(player);
}
} else {
return null;
}
}

@NotNull
public static UserNameTag createNameTag(Player player) {
if (nameTags.containsKey(player.getUniqueId())) return nameTags.get(player.getUniqueId());
UserNameTag nameTag = new UserNameTag(player);
nameTags.put(player.getUniqueId(), nameTag);
return nameTag;
Expand Down Expand Up @@ -56,6 +67,7 @@ public static void unloadPlayer(Player player) {
* @param loadOthers 是否为玩家更新其他人的前缀(一般用于加入游戏)
*/
public static void updatePrefixView(Player player, boolean loadOthers) {
if (!PrefixConfig.Functions.NAME_PREFIX.get()) return; //未启用的情况下,不需要进行任何操作。
ConfiguredPrefix playerPrefix = UserManager.getPrefix(player);

UserNameTag tag = getNameTag(player);
Expand Down

0 comments on commit 41a9582

Please sign in to comment.