Skip to content

Commit

Permalink
Add target.hasPlayedBefore() check to the Set command
Browse files Browse the repository at this point in the history
  • Loading branch information
Refrac committed Jan 3, 2024
1 parent e3b6ec8 commit 5b7ed4b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>me.refracdevelopment</groupId>
<artifactId>SimpleTags</artifactId>
<version>1.3</version>
<version>1.4</version>
<packaging>jar</packaging>

<name>SimpleTags</name>
Expand Down Expand Up @@ -130,7 +130,7 @@
<dependency>
<groupId>com.github.cryptomorin</groupId>
<artifactId>XSeries</artifactId>
<version>9.8.0</version>
<version>9.8.1</version>
</dependency>
<dependency>
<groupId>me.clip</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public void perform(CommandSender commandSender, String[] args) {

Color.sendMessage(commandSender, "tag-set", placeholders);
Color.sendMessage(profile.getPlayer(), "tag-updated", placeholders);
} else {
} else if (target.hasPlayedBefore()) {
Tag tag = SimpleTags.getInstance().getTagManager().getCachedTag(configName);

StringPlaceholders placeholders = StringPlaceholders.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,25 @@ public boolean persist() {
public String onPlaceholderRequest(Player player, @NotNull String params) {
ProfileData profile = SimpleTags.getInstance().getProfileManager().getProfile(player.getUniqueId()).getData();

if (params.equalsIgnoreCase("tag")) {
if (profile == null) {
return "";
}
if (profile.getTagPrefix().equals("")) {
return "";
}
return Color.translate(profile.getTagPrefix());
switch (params) {
case "tag-prefix":
case "tag":
if (profile == null) {
return "N/A";
}
if (profile.getTagPrefix().isEmpty()) {
return "N/A";
}
return Color.translate(profile.getTagPrefix());
case "tag-name":
case "identifier":
if (profile == null) {
return "N/A";
}
if (profile.getTag().isEmpty()) {
return "N/A";
}
return profile.getTag();
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ public static String setPlaceholders(CommandSender sender, String placeholder) {
placeholder = placeholder.replace("%player%", player.getName());
placeholder = placeholder.replace("%displayname%", player.getDisplayName());
if (SimpleTags.getInstance().getTagManager().getCachedTag(profile.getTag()) != null) {
placeholder = placeholder.replace("%identifier%", profile.getTag());
placeholder = placeholder.replace("%tag%", profile.getTagPrefix());
placeholder = placeholder.replace("%tag-name%", profile.getTag());
placeholder = placeholder.replace("%tag-prefix%", profile.getTagPrefix());
} else {
placeholder = placeholder.replace("%identifier%", "");
placeholder = placeholder.replace("%tag%", "");
placeholder = placeholder.replace("%tag-name%", "");
placeholder = placeholder.replace("%tag-prefix%", "");
}
Expand Down

0 comments on commit 5b7ed4b

Please sign in to comment.