From d07a78b1f3aa79945600e5e07d5a457909480b40 Mon Sep 17 00:00:00 2001 From: md_5 Date: Sat, 9 May 2020 16:12:18 +1000 Subject: [PATCH] SPIGOT-5716: Clarify documentation of MultipleFacing --- .../craftbukkit/block/data/CraftMultipleFacing.java | 12 ++++++++++-- .../craftbukkit/block/impl/CraftChorusFruit.java | 12 ++++++++++-- .../craftbukkit/block/impl/CraftCobbleWall.java | 12 ++++++++++-- .../bukkit/craftbukkit/block/impl/CraftFence.java | 12 ++++++++++-- .../org/bukkit/craftbukkit/block/impl/CraftFire.java | 12 ++++++++++-- .../craftbukkit/block/impl/CraftHugeMushroom.java | 12 ++++++++++-- .../bukkit/craftbukkit/block/impl/CraftIronBars.java | 12 ++++++++++-- .../block/impl/CraftStainedGlassPane.java | 12 ++++++++++-- .../bukkit/craftbukkit/block/impl/CraftTripwire.java | 12 ++++++++++-- .../org/bukkit/craftbukkit/block/impl/CraftVine.java | 12 ++++++++++-- 10 files changed, 100 insertions(+), 20 deletions(-) diff --git a/src/main/java/org/bukkit/craftbukkit/block/data/CraftMultipleFacing.java b/src/main/java/org/bukkit/craftbukkit/block/data/CraftMultipleFacing.java index 5d2cc2a9fa..ac2a335f92 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/data/CraftMultipleFacing.java +++ b/src/main/java/org/bukkit/craftbukkit/block/data/CraftMultipleFacing.java @@ -10,12 +10,20 @@ public abstract class CraftMultipleFacing extends CraftBlockData implements Mult @Override public boolean hasFace(org.bukkit.block.BlockFace face) { - return get(FACES[face.ordinal()]); + net.minecraft.server.BlockStateBoolean state = FACES[face.ordinal()]; + if (state == null) { + throw new IllegalArgumentException("Non-allowed face " + face + ". Check MultipleFacing.getAllowedFaces."); + } + return get(state); } @Override public void setFace(org.bukkit.block.BlockFace face, boolean has) { - set(FACES[face.ordinal()], has); + net.minecraft.server.BlockStateBoolean state = FACES[face.ordinal()]; + if (state == null) { + throw new IllegalArgumentException("Non-allowed face " + face + ". Check MultipleFacing.getAllowedFaces."); + } + set(state, has); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftChorusFruit.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftChorusFruit.java index 27ae41a929..b367f275b5 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftChorusFruit.java +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftChorusFruit.java @@ -21,12 +21,20 @@ public final class CraftChorusFruit extends org.bukkit.craftbukkit.block.data.Cr @Override public boolean hasFace(org.bukkit.block.BlockFace face) { - return get(FACES[face.ordinal()]); + net.minecraft.server.BlockStateBoolean state = FACES[face.ordinal()]; + if (state == null) { + throw new IllegalArgumentException("Non-allowed face " + face + ". Check MultipleFacing.getAllowedFaces."); + } + return get(state); } @Override public void setFace(org.bukkit.block.BlockFace face, boolean has) { - set(FACES[face.ordinal()], has); + net.minecraft.server.BlockStateBoolean state = FACES[face.ordinal()]; + if (state == null) { + throw new IllegalArgumentException("Non-allowed face " + face + ". Check MultipleFacing.getAllowedFaces."); + } + set(state, has); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCobbleWall.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCobbleWall.java index b1acc7c441..f77b551286 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCobbleWall.java +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCobbleWall.java @@ -21,12 +21,20 @@ public final class CraftCobbleWall extends org.bukkit.craftbukkit.block.data.Cra @Override public boolean hasFace(org.bukkit.block.BlockFace face) { - return get(FACES[face.ordinal()]); + net.minecraft.server.BlockStateBoolean state = FACES[face.ordinal()]; + if (state == null) { + throw new IllegalArgumentException("Non-allowed face " + face + ". Check MultipleFacing.getAllowedFaces."); + } + return get(state); } @Override public void setFace(org.bukkit.block.BlockFace face, boolean has) { - set(FACES[face.ordinal()], has); + net.minecraft.server.BlockStateBoolean state = FACES[face.ordinal()]; + if (state == null) { + throw new IllegalArgumentException("Non-allowed face " + face + ". Check MultipleFacing.getAllowedFaces."); + } + set(state, has); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFence.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFence.java index 1333b997f0..0be4d836c7 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFence.java +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFence.java @@ -21,12 +21,20 @@ public final class CraftFence extends org.bukkit.craftbukkit.block.data.CraftBlo @Override public boolean hasFace(org.bukkit.block.BlockFace face) { - return get(FACES[face.ordinal()]); + net.minecraft.server.BlockStateBoolean state = FACES[face.ordinal()]; + if (state == null) { + throw new IllegalArgumentException("Non-allowed face " + face + ". Check MultipleFacing.getAllowedFaces."); + } + return get(state); } @Override public void setFace(org.bukkit.block.BlockFace face, boolean has) { - set(FACES[face.ordinal()], has); + net.minecraft.server.BlockStateBoolean state = FACES[face.ordinal()]; + if (state == null) { + throw new IllegalArgumentException("Non-allowed face " + face + ". Check MultipleFacing.getAllowedFaces."); + } + set(state, has); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFire.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFire.java index a580935527..a4ae33f840 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFire.java +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFire.java @@ -40,12 +40,20 @@ public final class CraftFire extends org.bukkit.craftbukkit.block.data.CraftBloc @Override public boolean hasFace(org.bukkit.block.BlockFace face) { - return get(FACES[face.ordinal()]); + net.minecraft.server.BlockStateBoolean state = FACES[face.ordinal()]; + if (state == null) { + throw new IllegalArgumentException("Non-allowed face " + face + ". Check MultipleFacing.getAllowedFaces."); + } + return get(state); } @Override public void setFace(org.bukkit.block.BlockFace face, boolean has) { - set(FACES[face.ordinal()], has); + net.minecraft.server.BlockStateBoolean state = FACES[face.ordinal()]; + if (state == null) { + throw new IllegalArgumentException("Non-allowed face " + face + ". Check MultipleFacing.getAllowedFaces."); + } + set(state, has); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftHugeMushroom.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftHugeMushroom.java index fb6e205077..3170a234dc 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftHugeMushroom.java +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftHugeMushroom.java @@ -21,12 +21,20 @@ public final class CraftHugeMushroom extends org.bukkit.craftbukkit.block.data.C @Override public boolean hasFace(org.bukkit.block.BlockFace face) { - return get(FACES[face.ordinal()]); + net.minecraft.server.BlockStateBoolean state = FACES[face.ordinal()]; + if (state == null) { + throw new IllegalArgumentException("Non-allowed face " + face + ". Check MultipleFacing.getAllowedFaces."); + } + return get(state); } @Override public void setFace(org.bukkit.block.BlockFace face, boolean has) { - set(FACES[face.ordinal()], has); + net.minecraft.server.BlockStateBoolean state = FACES[face.ordinal()]; + if (state == null) { + throw new IllegalArgumentException("Non-allowed face " + face + ". Check MultipleFacing.getAllowedFaces."); + } + set(state, has); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftIronBars.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftIronBars.java index cf6da2dfed..e69ec75bb4 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftIronBars.java +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftIronBars.java @@ -21,12 +21,20 @@ public final class CraftIronBars extends org.bukkit.craftbukkit.block.data.Craft @Override public boolean hasFace(org.bukkit.block.BlockFace face) { - return get(FACES[face.ordinal()]); + net.minecraft.server.BlockStateBoolean state = FACES[face.ordinal()]; + if (state == null) { + throw new IllegalArgumentException("Non-allowed face " + face + ". Check MultipleFacing.getAllowedFaces."); + } + return get(state); } @Override public void setFace(org.bukkit.block.BlockFace face, boolean has) { - set(FACES[face.ordinal()], has); + net.minecraft.server.BlockStateBoolean state = FACES[face.ordinal()]; + if (state == null) { + throw new IllegalArgumentException("Non-allowed face " + face + ". Check MultipleFacing.getAllowedFaces."); + } + set(state, has); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStainedGlassPane.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStainedGlassPane.java index 0eb5c66071..2fc25359cd 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStainedGlassPane.java +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStainedGlassPane.java @@ -21,12 +21,20 @@ public final class CraftStainedGlassPane extends org.bukkit.craftbukkit.block.da @Override public boolean hasFace(org.bukkit.block.BlockFace face) { - return get(FACES[face.ordinal()]); + net.minecraft.server.BlockStateBoolean state = FACES[face.ordinal()]; + if (state == null) { + throw new IllegalArgumentException("Non-allowed face " + face + ". Check MultipleFacing.getAllowedFaces."); + } + return get(state); } @Override public void setFace(org.bukkit.block.BlockFace face, boolean has) { - set(FACES[face.ordinal()], has); + net.minecraft.server.BlockStateBoolean state = FACES[face.ordinal()]; + if (state == null) { + throw new IllegalArgumentException("Non-allowed face " + face + ". Check MultipleFacing.getAllowedFaces."); + } + set(state, has); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTripwire.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTripwire.java index e39e79c42f..cfce50fcc4 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTripwire.java +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTripwire.java @@ -49,12 +49,20 @@ public final class CraftTripwire extends org.bukkit.craftbukkit.block.data.Craft @Override public boolean hasFace(org.bukkit.block.BlockFace face) { - return get(FACES[face.ordinal()]); + net.minecraft.server.BlockStateBoolean state = FACES[face.ordinal()]; + if (state == null) { + throw new IllegalArgumentException("Non-allowed face " + face + ". Check MultipleFacing.getAllowedFaces."); + } + return get(state); } @Override public void setFace(org.bukkit.block.BlockFace face, boolean has) { - set(FACES[face.ordinal()], has); + net.minecraft.server.BlockStateBoolean state = FACES[face.ordinal()]; + if (state == null) { + throw new IllegalArgumentException("Non-allowed face " + face + ". Check MultipleFacing.getAllowedFaces."); + } + set(state, has); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftVine.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftVine.java index 90e025cef0..98a7542892 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftVine.java +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftVine.java @@ -21,12 +21,20 @@ public final class CraftVine extends org.bukkit.craftbukkit.block.data.CraftBloc @Override public boolean hasFace(org.bukkit.block.BlockFace face) { - return get(FACES[face.ordinal()]); + net.minecraft.server.BlockStateBoolean state = FACES[face.ordinal()]; + if (state == null) { + throw new IllegalArgumentException("Non-allowed face " + face + ". Check MultipleFacing.getAllowedFaces."); + } + return get(state); } @Override public void setFace(org.bukkit.block.BlockFace face, boolean has) { - set(FACES[face.ordinal()], has); + net.minecraft.server.BlockStateBoolean state = FACES[face.ordinal()]; + if (state == null) { + throw new IllegalArgumentException("Non-allowed face " + face + ". Check MultipleFacing.getAllowedFaces."); + } + set(state, has); } @Override