mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-22 23:31:37 +01:00
Stacking rule can be changed now (#916)
This commit is contained in:
parent
19eae7ef93
commit
f1606362b7
@ -14,7 +14,21 @@ import java.util.function.Consumer;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
record ItemStackImpl(Material material, int amount, ItemMeta meta) implements ItemStack {
|
||||
static final @NotNull VanillaStackingRule DEFAULT_STACKING_RULE = new VanillaStackingRule();
|
||||
static final @NotNull StackingRule DEFAULT_STACKING_RULE;
|
||||
|
||||
static {
|
||||
final String stackingRuleProperty = System.getProperty("minestom.stacking-rule");
|
||||
if (stackingRuleProperty == null) {
|
||||
DEFAULT_STACKING_RULE = new VanillaStackingRule();
|
||||
} else {
|
||||
try {
|
||||
DEFAULT_STACKING_RULE = (StackingRule) ClassLoader.getSystemClassLoader()
|
||||
.loadClass(stackingRuleProperty).getConstructor().newInstance();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Could not instantiate default stacking rule", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static ItemStack create(Material material, int amount, ItemMeta meta) {
|
||||
if (amount <= 0) return AIR;
|
||||
|
Loading…
Reference in New Issue
Block a user