mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-23 17:09:19 +00:00
难绷
This commit is contained in:
@@ -20,8 +20,11 @@ public class SelfIncreaseIntTemplateArgument implements TemplateArgument {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String get() {
|
public String get() {
|
||||||
String value = String.valueOf(current);
|
String value = String.valueOf(this.current);
|
||||||
if (current < max) current += 1;
|
if (this.current < this.max) this.current += 1;
|
||||||
|
else {
|
||||||
|
throw new IllegalStateException("SelfIncreaseInt " + this.current + " is already >= " + this.max);
|
||||||
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,15 +34,15 @@ public class SelfIncreaseIntTemplateArgument implements TemplateArgument {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int current() {
|
public int current() {
|
||||||
return current;
|
return this.current;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int min() {
|
public int min() {
|
||||||
return min;
|
return this.min;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int max() {
|
public int max() {
|
||||||
return max;
|
return this.max;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Factory implements TemplateArgumentFactory {
|
public static class Factory implements TemplateArgumentFactory {
|
||||||
|
|||||||
@@ -452,7 +452,7 @@ public class TemplateManagerImpl implements TemplateManager {
|
|||||||
String key = input.substring(1, input.length() - 1);
|
String key = input.substring(1, input.length() - 1);
|
||||||
return Optional.ofNullable(arguments.get(key))
|
return Optional.ofNullable(arguments.get(key))
|
||||||
.map(TemplateArgument::get)
|
.map(TemplateArgument::get)
|
||||||
.orElse(replacePlaceholders(input, arguments));
|
.orElseGet(() -> replacePlaceholders(input, arguments));
|
||||||
}
|
}
|
||||||
return replacePlaceholders(input, arguments);
|
return replacePlaceholders(input, arguments);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user