3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-16 04:50:05 +01:00

SPIGOT-4074: Fix createBlockData succeeding on garbage

Dieser Commit ist enthalten in:
md_5 2018-07-20 10:20:15 +10:00
Ursprung c1d9f94223
Commit 49ac8a7446
2 geänderte Dateien mit 11 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -403,7 +403,10 @@ public class CraftBlockData implements BlockData {
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();
} catch (CommandSyntaxException ex) {
throw new IllegalArgumentException("Could not parse data: " + data, ex);

Datei anzeigen

@ -44,6 +44,13 @@ public class BlockDataTest extends AbstractTestingBase {
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
public void testClone() {
Cake cakeTest = (Cake) CraftBlockData.fromData(Blocks.CAKE.getBlockData().set(BlockCake.BITES, 3));