mirror of
https://github.com/songoda/SongodaCore.git
synced 2024-11-25 03:25:16 +01:00
Add option to set placeholder prefix and suffix
This commit is contained in:
parent
d2766ca7c7
commit
2fbdf10627
@ -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;
|
||||
}
|
||||
|
||||
@ -16,4 +20,38 @@ public class MiniMessagePlaceholder {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user