9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-23 00:49:20 +00:00
This commit is contained in:
XiaoMoMi
2025-06-05 22:16:15 +08:00
parent fb49db6547
commit cb7548a193
2 changed files with 9 additions and 6 deletions

View File

@@ -20,8 +20,11 @@ public class SelfIncreaseIntTemplateArgument implements TemplateArgument {
@Override
public String get() {
String value = String.valueOf(current);
if (current < max) current += 1;
String value = String.valueOf(this.current);
if (this.current < this.max) this.current += 1;
else {
throw new IllegalStateException("SelfIncreaseInt " + this.current + " is already >= " + this.max);
}
return value;
}
@@ -31,15 +34,15 @@ public class SelfIncreaseIntTemplateArgument implements TemplateArgument {
}
public int current() {
return current;
return this.current;
}
public int min() {
return min;
return this.min;
}
public int max() {
return max;
return this.max;
}
public static class Factory implements TemplateArgumentFactory {

View File

@@ -452,7 +452,7 @@ public class TemplateManagerImpl implements TemplateManager {
String key = input.substring(1, input.length() - 1);
return Optional.ofNullable(arguments.get(key))
.map(TemplateArgument::get)
.orElse(replacePlaceholders(input, arguments));
.orElseGet(() -> replacePlaceholders(input, arguments));
}
return replacePlaceholders(input, arguments);
}