mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-08 11:24:11 +01:00
SPIGOT-4074: Fix createBlockData succeeding on garbage
By: md_5 <git@md-5.net>
This commit is contained in:
parent
3b128c5dbf
commit
6826aaee8f
2 changed files with 11 additions and 1 deletions
|
@ -403,7 +403,10 @@ public class CraftBlockData implements BlockData {
|
||||||
data = Block.REGISTRY.b(block) + data;
|
data = Block.REGISTRY.b(block) + data;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArgumentBlock arg = new ArgumentBlock(new StringReader(data), false).a(false);
|
StringReader reader = new StringReader(data);
|
||||||
|
ArgumentBlock arg = new ArgumentBlock(reader, false).a(false);
|
||||||
|
Preconditions.checkArgument(!reader.canRead(), "Spurious trailing data");
|
||||||
|
|
||||||
blockData = arg.b();
|
blockData = arg.b();
|
||||||
} catch (CommandSyntaxException ex) {
|
} catch (CommandSyntaxException ex) {
|
||||||
throw new IllegalArgumentException("Could not parse data: " + data, ex);
|
throw new IllegalArgumentException("Could not parse data: " + data, ex);
|
||||||
|
|
|
@ -44,6 +44,13 @@ public class BlockDataTest extends AbstractTestingBase {
|
||||||
CraftBlockData.newData(Material.CAKE, "minecraft:cake[bites=3]");
|
CraftBlockData.newData(Material.CAKE, "minecraft:cake[bites=3]");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(expected = IllegalArgumentException.class)
|
||||||
|
public void testMistake() {
|
||||||
|
BlockData cakeTest = CraftBlockData.fromData(Blocks.CAKE.getBlockData().set(BlockCake.BITES, 3));
|
||||||
|
|
||||||
|
CraftBlockData.newData(Material.CAKE, cakeTest.toString());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testClone() {
|
public void testClone() {
|
||||||
Cake cakeTest = (Cake) CraftBlockData.fromData(Blocks.CAKE.getBlockData().set(BlockCake.BITES, 3));
|
Cake cakeTest = (Cake) CraftBlockData.fromData(Blocks.CAKE.getBlockData().set(BlockCake.BITES, 3));
|
||||||
|
|
Loading…
Reference in a new issue