mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 15:30:19 +01:00
Validate speed for tool component rule (#10923)
This commit is contained in:
parent
461f02dce2
commit
26fd1c1b56
1 changed files with 36 additions and 0 deletions
|
@ -1518,6 +1518,42 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
List<FoodProperties.PossibleEffect> effects = new ArrayList<>(this.handle.effects());
|
||||
|
||||
FoodProperties.PossibleEffect newEffect = new net.minecraft.world.food.FoodProperties.PossibleEffect(CraftPotionUtil.fromBukkit(effect), probability);
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftToolComponent.java b/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftToolComponent.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftToolComponent.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftToolComponent.java
|
||||
@@ -0,0 +0,0 @@ public final class CraftToolComponent implements ToolComponent {
|
||||
public ToolRule addRule(Material block, Float speed, Boolean correctForDrops) {
|
||||
Preconditions.checkArgument(block != null, "block must not be null");
|
||||
Preconditions.checkArgument(block.isBlock(), "block must be a block type, given %s", block.getKey());
|
||||
+ Preconditions.checkArgument(speed == null || speed > 0, "speed must be positive"); // Paper - validate speed
|
||||
|
||||
Holder.Reference<Block> nmsBlock = CraftBlockType.bukkitToMinecraft(block).builtInRegistryHolder();
|
||||
return this.addRule(HolderSet.direct(nmsBlock), speed, correctForDrops);
|
||||
@@ -0,0 +0,0 @@ public final class CraftToolComponent implements ToolComponent {
|
||||
|
||||
@Override
|
||||
public ToolRule addRule(Collection<Material> blocks, Float speed, Boolean correctForDrops) {
|
||||
+ Preconditions.checkArgument(speed == null || speed > 0, "speed must be positive"); // Paper - validate speed
|
||||
List<Holder.Reference<Block>> nmsBlocks = new ArrayList<>(blocks.size());
|
||||
|
||||
for (Material material : blocks) {
|
||||
@@ -0,0 +0,0 @@ public final class CraftToolComponent implements ToolComponent {
|
||||
@Override
|
||||
public ToolRule addRule(Tag<Material> tag, Float speed, Boolean correctForDrops) {
|
||||
Preconditions.checkArgument(tag instanceof CraftBlockTag, "tag must be a block tag");
|
||||
+ Preconditions.checkArgument(speed == null || speed > 0, "speed must be positive"); // Paper - validate speed
|
||||
return this.addRule(((CraftBlockTag) tag).getHandle(), speed, correctForDrops);
|
||||
}
|
||||
|
||||
@@ -0,0 +0,0 @@ public final class CraftToolComponent implements ToolComponent {
|
||||
|
||||
@Override
|
||||
public void setSpeed(Float speed) {
|
||||
+ Preconditions.checkArgument(speed == null || speed > 0, "speed must be positive"); // Paper - validate speed
|
||||
this.handle = new Tool.Rule(this.handle.blocks(), Optional.ofNullable(speed), this.handle.correctForDrops());
|
||||
}
|
||||
|
||||
diff --git a/src/test/java/org/bukkit/craftbukkit/inventory/DeprecatedItemMetaCustomValueTest.java b/src/test/java/org/bukkit/craftbukkit/inventory/DeprecatedItemMetaCustomValueTest.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/test/java/org/bukkit/craftbukkit/inventory/DeprecatedItemMetaCustomValueTest.java
|
||||
|
|
Loading…
Reference in a new issue