mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-04 23:47:59 +01:00
Merge pull request #374 from Project-Cepi/vanillaStackingRuleEquals
Add #equals method to VanillaStackingRule
This commit is contained in:
commit
7944977cd5
@ -31,6 +31,8 @@ public final class ItemStack implements TagReadable, HoverEventSource<HoverEvent
|
|||||||
*/
|
*/
|
||||||
public static final @NotNull ItemStack AIR = ItemStack.of(Material.AIR);
|
public static final @NotNull ItemStack AIR = ItemStack.of(Material.AIR);
|
||||||
|
|
||||||
|
private static final @NotNull VanillaStackingRule DEFAULT_STACKING_RULE = new VanillaStackingRule();
|
||||||
|
|
||||||
private final StackingRule stackingRule;
|
private final StackingRule stackingRule;
|
||||||
|
|
||||||
private final Material material;
|
private final Material material;
|
||||||
@ -43,7 +45,7 @@ public final class ItemStack implements TagReadable, HoverEventSource<HoverEvent
|
|||||||
this.material = material;
|
this.material = material;
|
||||||
this.amount = amount;
|
this.amount = amount;
|
||||||
this.meta = meta;
|
this.meta = meta;
|
||||||
this.stackingRule = Objects.requireNonNullElseGet(stackingRule, VanillaStackingRule::new);
|
this.stackingRule = Objects.requireNonNullElse(stackingRule, DEFAULT_STACKING_RULE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Contract(value = "_ -> new", pure = true)
|
@Contract(value = "_ -> new", pure = true)
|
||||||
|
@ -33,4 +33,11 @@ public class VanillaStackingRule implements StackingRule {
|
|||||||
public int getMaxSize(@NotNull ItemStack itemStack) {
|
public int getMaxSize(@NotNull ItemStack itemStack) {
|
||||||
return itemStack.getMaterial().getMaxDefaultStackSize();
|
return itemStack.getMaterial().getMaxDefaultStackSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj) return true;
|
||||||
|
|
||||||
|
return obj != null && getClass() == obj.getClass();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user