mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-23 08:59:27 +00:00
难绷
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user