Update T2Creplace.java

add  public static Object replace(Object object,String placeholder,String replacement)
This commit is contained in:
JaTiTV 2023-07-08 19:42:48 +02:00
parent 567b0a2442
commit e97fadfbec

View File

@ -171,4 +171,19 @@ public class T2Creplace {
.replace("&o", "<italic>").replace("§o", "<italic>")
.replace("&r", "<reset>").replace("§r", "<reset>");
}
public static Object replace(Object object,String placeholder,String replacement) {
if (object instanceof String) {
object = ((String) object).replace(placeholder, replacement);
}
if ((object instanceof List) || (object instanceof ArrayList)) {
List<String> in = (List<String>) object;
List<String> output = new ArrayList<>();
for (String input : in) {
output.add(input.replace(placeholder, replacement));
}
object = output;
}
return object;
}
}