Skip to content

Commit

Permalink
Add option to set placeholder prefix and suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
ceze88 committed Aug 21, 2024
1 parent d2766ca commit 2fbdf10
Showing 1 changed file with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package com.craftaro.core.chat;

public class MiniMessagePlaceholder {

public static String PLACEHOLDER_PREFIX = "%";
public static String PLACEHOLDER_SUFFIX = "%";

private final String placeholder;
private final String value;

public MiniMessagePlaceholder(String placeholder, String value) {
this.placeholder = "%" + placeholder + "%";
this.placeholder = PLACEHOLDER_PREFIX + placeholder + PLACEHOLDER_SUFFIX;
this.value = value;
}

Expand All @@ -16,4 +20,38 @@ public String getPlaceholder() {
public String getValue() {
return this.value;
}

public static void setPlaceholderPrefix(String prefix) {
if (prefix == null) {
throw new IllegalArgumentException("Prefix cannot be null");
}
if (prefix.isEmpty()) {
throw new IllegalArgumentException("Prefix cannot be empty");
}
if (prefix.equals(PLACEHOLDER_SUFFIX)) {
throw new IllegalArgumentException("Prefix cannot be the same as the suffix");
}
PLACEHOLDER_PREFIX = prefix;
}

public static void setPlaceholderSuffix(String suffix) {
if (suffix == null) {
throw new IllegalArgumentException("Suffix cannot be null");
}
if (suffix.isEmpty()) {
throw new IllegalArgumentException("Suffix cannot be empty");
}
if (suffix.equals(PLACEHOLDER_PREFIX)) {
throw new IllegalArgumentException("Suffix cannot be the same as the prefix");
}
PLACEHOLDER_SUFFIX = suffix;
}

public static String getPlaceholderPrefix() {
return PLACEHOLDER_PREFIX;
}

public static String getPlaceholderSuffix() {
return PLACEHOLDER_SUFFIX;
}
}

0 comments on commit 2fbdf10

Please sign in to comment.