tweaks a bit map appender, add range annotations and preconditions

Previously this would throw a NPE/IndexOutOfBoundsException
for those invalid cases
This commit is contained in:
Lulu13022002 2024-03-13 22:30:50 +01:00
parent 75f4fa5413
commit c6fe0211b2
No known key found for this signature in database
GPG Key ID: 491C8F0B8ACDEB01
150 changed files with 852 additions and 124 deletions

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.AmethystClusterBlock;
@ -28,6 +29,8 @@ public class CraftAmethystCluster extends CraftBlockData implements AmethystClus
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian(), "Invalid face, only cartesian face are allowed for this property!");
this.set(FACING, blockFace);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.AnvilBlock;
@ -25,6 +26,8 @@ public class CraftAnvil extends CraftBlockData implements Directional {
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!");
this.set(FACING, blockFace);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.AttachedStemBlock;
@ -25,6 +26,8 @@ public class CraftAttachedStem extends CraftBlockData implements Directional {
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!");
this.set(FACING, blockFace);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import net.minecraft.world.level.block.BambooStalkBlock;
import net.minecraft.world.level.block.state.BlockState;
@ -8,6 +9,7 @@ import net.minecraft.world.level.block.state.properties.EnumProperty;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import org.bukkit.block.data.type.Bamboo;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.jetbrains.annotations.Range;
@GeneratedFrom("1.20.4")
@SuppressWarnings("unused")
@ -23,12 +25,16 @@ public class CraftBambooStalk extends CraftBlockData implements Bamboo {
}
@Override
@Range(
from = 0,
to = 1
)
public int getAge() {
return this.get(AGE);
}
@Override
public void setAge(final int age) {
public void setAge(@Range(from = 0, to = 1) final int age) {
this.set(AGE, age);
}
@ -44,16 +50,21 @@ public class CraftBambooStalk extends CraftBlockData implements Bamboo {
@Override
public void setLeaves(final Bamboo.Leaves leaves) {
Preconditions.checkArgument(leaves != null, "leaves cannot be null!");
this.set(LEAVES, leaves);
}
@Override
@Range(
from = 0,
to = 1
)
public int getStage() {
return this.get(STAGE);
}
@Override
public void setStage(final int stage) {
public void setStage(@Range(from = 0, to = 1) final int stage) {
this.set(STAGE, stage);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import net.minecraft.world.level.block.BannerBlock;
import net.minecraft.world.level.block.state.BlockState;
@ -26,6 +27,8 @@ public class CraftBanner extends CraftBlockData implements Rotatable {
@Override
public void setRotation(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace != BlockFace.SELF && blockFace.getModY() == 0, "Invalid face, only horizontal face are allowed for this property!");
Vector dir = blockFace.getDirection();
float angle = (float) -Math.toDegrees(Math.atan2(dir.getX(), dir.getZ()));
this.set(ROTATION, RotationSegment.convertToSegment(angle));

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.BarrelBlock;
@ -28,6 +29,8 @@ public class CraftBarrel extends CraftBlockData implements Barrel {
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian(), "Invalid face, only cartesian face are allowed for this property!");
this.set(FACING, blockFace);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.BaseCoralWallFanBlock;
@ -28,6 +29,8 @@ public class CraftBaseCoralWallFan extends CraftBlockData implements CoralWallFa
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!");
this.set(FACING, blockFace);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.BedBlock;
@ -32,6 +33,8 @@ public class CraftBed extends CraftBlockData implements Bed {
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!");
this.set(FACING, blockFace);
}
@ -57,6 +60,7 @@ public class CraftBed extends CraftBlockData implements Bed {
@Override
public void setPart(final Bed.Part part) {
Preconditions.checkArgument(part != null, "part cannot be null!");
this.set(PART, part);
}
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.BeehiveBlock;
@ -9,6 +10,7 @@ import net.minecraft.world.level.block.state.properties.IntegerProperty;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.type.Beehive;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.jetbrains.annotations.Range;
@GeneratedFrom("1.20.4")
@SuppressWarnings("unused")
@ -28,6 +30,8 @@ public class CraftBeehive extends CraftBlockData implements Beehive {
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!");
this.set(FACING, blockFace);
}
@ -37,12 +41,16 @@ public class CraftBeehive extends CraftBlockData implements Beehive {
}
@Override
@Range(
from = 0,
to = 5
)
public int getHoneyLevel() {
return this.get(HONEY_LEVEL);
}
@Override
public void setHoneyLevel(final int honeyLevel) {
public void setHoneyLevel(@Range(from = 0, to = 5) final int honeyLevel) {
this.set(HONEY_LEVEL, honeyLevel);
}

View File

@ -6,6 +6,7 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import org.bukkit.block.data.Ageable;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.jetbrains.annotations.Range;
@GeneratedFrom("1.20.4")
@SuppressWarnings("unused")
@ -17,12 +18,16 @@ public class CraftBeetroot extends CraftBlockData implements Ageable {
}
@Override
@Range(
from = 0,
to = 3
)
public int getAge() {
return this.get(AGE);
}
@Override
public void setAge(final int age) {
public void setAge(@Range(from = 0, to = 3) final int age) {
this.set(AGE, age);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.BellBlock;
@ -32,6 +33,7 @@ public class CraftBell extends CraftBlockData implements Bell {
@Override
public void setAttachment(final Bell.Attachment attachment) {
Preconditions.checkArgument(attachment != null, "attachment cannot be null!");
this.set(ATTACHMENT, attachment);
}
@ -42,6 +44,8 @@ public class CraftBell extends CraftBlockData implements Bell {
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!");
this.set(FACING, blockFace);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.BigDripleafBlock;
@ -32,6 +33,8 @@ public class CraftBigDripleaf extends CraftBlockData implements BigDripleaf {
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!");
this.set(FACING, blockFace);
}
@ -47,6 +50,7 @@ public class CraftBigDripleaf extends CraftBlockData implements BigDripleaf {
@Override
public void setTilt(final BigDripleaf.Tilt tilt) {
Preconditions.checkArgument(tilt != null, "tilt cannot be null!");
this.set(TILT, tilt);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.BigDripleafStemBlock;
@ -29,6 +30,8 @@ public class CraftBigDripleafStem extends CraftBlockData implements Dripleaf {
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!");
this.set(FACING, blockFace);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.BlastFurnaceBlock;
@ -28,6 +29,8 @@ public class CraftBlastFurnace extends CraftBlockData implements Furnace {
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!");
this.set(FACING, blockFace);
}

View File

@ -6,6 +6,7 @@ import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import org.bukkit.block.data.Brushable;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.jetbrains.annotations.Range;
@GeneratedFrom("1.20.4")
@SuppressWarnings("unused")
@ -17,12 +18,16 @@ public class CraftBrushable extends CraftBlockData implements Brushable {
}
@Override
@Range(
from = 0,
to = 3
)
public int getDusted() {
return this.get(DUSTED);
}
@Override
public void setDusted(final int dusted) {
public void setDusted(@Range(from = 0, to = 3) final int dusted) {
this.set(DUSTED, dusted);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.ButtonBlock;
@ -33,6 +34,7 @@ public class CraftButton extends CraftBlockData implements Switch {
@Override
public void setAttachedFace(
final org.bukkit.block.data.FaceAttachable.AttachedFace attachedFace) {
Preconditions.checkArgument(attachedFace != null, "attachedFace cannot be null!");
this.set(FACE, attachedFace);
}
@ -43,6 +45,8 @@ public class CraftButton extends CraftBlockData implements Switch {
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!");
this.set(FACING, blockFace);
}

View File

@ -6,6 +6,7 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import org.bukkit.block.data.Ageable;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.jetbrains.annotations.Range;
@GeneratedFrom("1.20.4")
@SuppressWarnings("unused")
@ -17,12 +18,16 @@ public class CraftCactus extends CraftBlockData implements Ageable {
}
@Override
@Range(
from = 0,
to = 15
)
public int getAge() {
return this.get(AGE);
}
@Override
public void setAge(final int age) {
public void setAge(@Range(from = 0, to = 15) final int age) {
this.set(AGE, age);
}

View File

@ -6,6 +6,7 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import org.bukkit.block.data.type.Cake;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.jetbrains.annotations.Range;
@GeneratedFrom("1.20.4")
@SuppressWarnings("unused")
@ -17,12 +18,16 @@ public class CraftCake extends CraftBlockData implements Cake {
}
@Override
@Range(
from = 0,
to = 6
)
public int getBites() {
return this.get(BITES);
}
@Override
public void setBites(final int bites) {
public void setBites(@Range(from = 0, to = 6) final int bites) {
this.set(BITES, bites);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.CalibratedSculkSensorBlock;
@ -12,6 +13,7 @@ import net.minecraft.world.level.block.state.properties.SculkSensorPhase;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.type.CalibratedSculkSensor;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.jetbrains.annotations.Range;
@GeneratedFrom("1.20.4")
@SuppressWarnings("unused")
@ -35,6 +37,8 @@ public class CraftCalibratedSculkSensor extends CraftBlockData implements Calibr
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!");
this.set(FACING, blockFace);
}
@ -44,12 +48,16 @@ public class CraftCalibratedSculkSensor extends CraftBlockData implements Calibr
}
@Override
@Range(
from = 0,
to = 15
)
public int getPower() {
return this.get(POWER);
}
@Override
public void setPower(final int power) {
public void setPower(@Range(from = 0, to = 15) final int power) {
this.set(POWER, power);
}
@ -65,6 +73,7 @@ public class CraftCalibratedSculkSensor extends CraftBlockData implements Calibr
@Override
public void setSculkSensorPhase(final org.bukkit.block.data.type.SculkSensor.Phase phase) {
Preconditions.checkArgument(phase != null, "phase cannot be null!");
this.set(PHASE, phase);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.CampfireBlock;
@ -32,6 +33,8 @@ public class CraftCampfire extends CraftBlockData implements Campfire {
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!");
this.set(FACING, blockFace);
}

View File

@ -7,6 +7,7 @@ import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import org.bukkit.block.data.type.Candle;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.jetbrains.annotations.Range;
@GeneratedFrom("1.20.4")
@SuppressWarnings("unused")
@ -22,12 +23,16 @@ public class CraftCandle extends CraftBlockData implements Candle {
}
@Override
@Range(
from = 1,
to = 4
)
public int getCandles() {
return this.get(CANDLES);
}
@Override
public void setCandles(final int candles) {
public void setCandles(@Range(from = 1, to = 4) final int candles) {
this.set(CANDLES, candles);
}

View File

@ -6,6 +6,7 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import org.bukkit.block.data.Ageable;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.jetbrains.annotations.Range;
@GeneratedFrom("1.20.4")
@SuppressWarnings("unused")
@ -17,12 +18,16 @@ public class CraftCarrot extends CraftBlockData implements Ageable {
}
@Override
@Range(
from = 0,
to = 7
)
public int getAge() {
return this.get(AGE);
}
@Override
public void setAge(final int age) {
public void setAge(@Range(from = 0, to = 7) final int age) {
this.set(AGE, age);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.CarvedPumpkinBlock;
@ -25,6 +26,8 @@ public class CraftCarvedPumpkin extends CraftBlockData implements Directional {
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!");
this.set(FACING, blockFace);
}

View File

@ -7,6 +7,7 @@ import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import org.bukkit.block.data.type.CaveVines;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.jetbrains.annotations.Range;
@GeneratedFrom("1.20.4")
@SuppressWarnings("unused")
@ -20,12 +21,16 @@ public class CraftCaveVines extends CraftBlockData implements CaveVines {
}
@Override
@Range(
from = 0,
to = 25
)
public int getAge() {
return this.get(AGE);
}
@Override
public void setAge(final int age) {
public void setAge(@Range(from = 0, to = 25) final int age) {
this.set(AGE, age);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import net.minecraft.world.level.block.CeilingHangingSignBlock;
import net.minecraft.world.level.block.state.BlockState;
@ -41,6 +42,8 @@ public class CraftCeilingHangingSign extends CraftBlockData implements HangingSi
@Override
public void setRotation(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace != BlockFace.SELF && blockFace.getModY() == 0, "Invalid face, only horizontal face are allowed for this property!");
Vector dir = blockFace.getDirection();
float angle = (float) -Math.toDegrees(Math.atan2(dir.getX(), dir.getZ()));
this.set(ROTATION, RotationSegment.convertToSegment(angle));

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.core.Direction;
@ -29,6 +30,7 @@ public class CraftChain extends CraftBlockData implements Chain {
@Override
public void setAxis(final Axis axis) {
Preconditions.checkArgument(axis != null, "axis cannot be null!");
this.set(AXIS, axis);
}

View File

@ -7,6 +7,7 @@ import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import org.bukkit.block.data.type.Leaves;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.jetbrains.annotations.Range;
@GeneratedFrom("1.20.4")
@SuppressWarnings("unused")
@ -22,12 +23,16 @@ public class CraftCherryLeaves extends CraftBlockData implements Leaves {
}
@Override
@Range(
from = 1,
to = 7
)
public int getDistance() {
return this.get(DISTANCE);
}
@Override
public void setDistance(final int distance) {
public void setDistance(@Range(from = 1, to = 7) final int distance) {
this.set(DISTANCE, distance);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.ChestBlock;
@ -32,6 +33,8 @@ public class CraftChest extends CraftBlockData implements Chest {
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!");
this.set(FACING, blockFace);
}
@ -47,6 +50,7 @@ public class CraftChest extends CraftBlockData implements Chest {
@Override
public void setType(final Chest.Type type) {
Preconditions.checkArgument(type != null, "type cannot be null!");
this.set(TYPE, type);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.List;
@ -31,6 +32,8 @@ public class CraftChiseledBookShelf extends CraftBlockData implements ChiseledBo
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!");
this.set(HORIZONTAL_FACING, blockFace);
}

View File

@ -6,6 +6,7 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import org.bukkit.block.data.Ageable;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.jetbrains.annotations.Range;
@GeneratedFrom("1.20.4")
@SuppressWarnings("unused")
@ -17,12 +18,16 @@ public class CraftChorusFlower extends CraftBlockData implements Ageable {
}
@Override
@Range(
from = 0,
to = 5
)
public int getAge() {
return this.get(AGE);
}
@Override
public void setAge(final int age) {
public void setAge(@Range(from = 0, to = 5) final int age) {
this.set(AGE, age);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Collections;
@ -26,20 +27,26 @@ public class CraftChorusPlant extends CraftBlockData implements MultipleFacing {
@Override
public boolean hasFace(final BlockFace blockFace) {
return this.get(PROPERTY_BY_DIRECTION.get(blockFace));
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
BooleanProperty property = PROPERTY_BY_DIRECTION.get(blockFace);
Preconditions.checkArgument(property != null, "Invalid %s, only %s are allowed!".formatted("blockFace", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))));
return this.get(property);
}
@Override
public void setFace(final BlockFace blockFace, final boolean face) {
this.set(PROPERTY_BY_DIRECTION.get(blockFace), face);
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
BooleanProperty property = PROPERTY_BY_DIRECTION.get(blockFace);
Preconditions.checkArgument(property != null, "Invalid %s, only %s are allowed!".formatted("blockFace", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))));
this.set(property, face);
}
@Override
public Set<BlockFace> getFaces() {
ImmutableSet.Builder<BlockFace> faces = ImmutableSet.builder();
for (BlockFace blockFace : PROPERTY_BY_DIRECTION.keySet()) {
if (this.get(PROPERTY_BY_DIRECTION.get(blockFace))) {
faces.add(blockFace);
for (Map.Entry<BlockFace, BooleanProperty> entry : PROPERTY_BY_DIRECTION.entrySet()) {
if (this.get(entry.getValue())) {
faces.add(entry.getKey());
}
}
return faces.build();

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.CocoaBlock;
@ -9,6 +10,7 @@ import net.minecraft.world.level.block.state.properties.IntegerProperty;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.type.Cocoa;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.jetbrains.annotations.Range;
@GeneratedFrom("1.20.4")
@SuppressWarnings("unused")
@ -22,12 +24,16 @@ public class CraftCocoa extends CraftBlockData implements Cocoa {
}
@Override
@Range(
from = 0,
to = 2
)
public int getAge() {
return this.get(AGE);
}
@Override
public void setAge(final int age) {
public void setAge(@Range(from = 0, to = 2) final int age) {
this.set(AGE, age);
}
@ -43,6 +49,8 @@ public class CraftCocoa extends CraftBlockData implements Cocoa {
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!");
this.set(FACING, blockFace);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.state.BlockState;
@ -37,6 +38,8 @@ public class CraftCommandBlock extends CraftBlockData implements CommandBlock {
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian(), "Invalid face, only cartesian face are allowed for this property!");
this.set(FACING, blockFace);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.ComparatorBlock;
@ -32,6 +33,8 @@ public class CraftComparator extends CraftBlockData implements Comparator {
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!");
this.set(FACING, blockFace);
}
@ -47,6 +50,7 @@ public class CraftComparator extends CraftBlockData implements Comparator {
@Override
public void setMode(final Comparator.Mode mode) {
Preconditions.checkArgument(mode != null, "mode cannot be null!");
this.set(MODE, mode);
}

View File

@ -6,6 +6,7 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import org.bukkit.block.data.Levelled;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.jetbrains.annotations.Range;
@GeneratedFrom("1.20.4")
@SuppressWarnings("unused")
@ -17,12 +18,16 @@ public class CraftComposter extends CraftBlockData implements Levelled {
}
@Override
@Range(
from = 0,
to = 8
)
public int getLevel() {
return this.get(LEVEL);
}
@Override
public void setLevel(final int level) {
public void setLevel(@Range(from = 0, to = 8) final int level) {
this.set(LEVEL, level);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.CoralWallFanBlock;
@ -28,6 +29,8 @@ public class CraftCoralWallFan extends CraftBlockData implements CoralWallFan {
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!");
this.set(FACING, blockFace);
}

View File

@ -6,6 +6,7 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import org.bukkit.block.data.Ageable;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.jetbrains.annotations.Range;
@GeneratedFrom("1.20.4")
@SuppressWarnings("unused")
@ -17,12 +18,16 @@ public class CraftCrop extends CraftBlockData implements Ageable {
}
@Override
@Range(
from = 0,
to = 7
)
public int getAge() {
return this.get(AGE);
}
@Override
public void setAge(final int age) {
public void setAge(@Range(from = 0, to = 7) final int age) {
this.set(AGE, age);
}

View File

@ -7,6 +7,7 @@ import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import org.bukkit.block.data.type.DaylightDetector;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.jetbrains.annotations.Range;
@GeneratedFrom("1.20.4")
@SuppressWarnings("unused")
@ -30,12 +31,16 @@ public class CraftDaylightDetector extends CraftBlockData implements DaylightDet
}
@Override
@Range(
from = 0,
to = 15
)
public int getPower() {
return this.get(POWER);
}
@Override
public void setPower(final int power) {
public void setPower(@Range(from = 0, to = 15) final int power) {
this.set(POWER, power);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.DecoratedPotBlock;
@ -41,6 +42,8 @@ public class CraftDecoratedPot extends CraftBlockData implements DecoratedPot {
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!");
this.set(HORIZONTAL_FACING, blockFace);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.DetectorRailBlock;
@ -40,6 +41,8 @@ public class CraftDetectorRail extends CraftBlockData implements RedstoneRail {
@Override
public void setShape(final org.bukkit.block.data.Rail.Shape shape) {
Preconditions.checkArgument(shape != null, "shape cannot be null!");
Preconditions.checkArgument(shape != org.bukkit.block.data.Rail.Shape.NORTH_EAST && shape != org.bukkit.block.data.Rail.Shape.NORTH_WEST && shape != org.bukkit.block.data.Rail.Shape.SOUTH_EAST && shape != org.bukkit.block.data.Rail.Shape.SOUTH_WEST, "Invalid rail shape, only straight rail are allowed for this property!");
this.set(SHAPE, shape);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.DispenserBlock;
@ -28,6 +29,8 @@ public class CraftDispenser extends CraftBlockData implements Dispenser {
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian(), "Invalid face, only cartesian face are allowed for this property!");
this.set(FACING, blockFace);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.DoorBlock;
@ -37,6 +38,8 @@ public class CraftDoor extends CraftBlockData implements Door {
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!");
this.set(FACING, blockFace);
}
@ -52,6 +55,7 @@ public class CraftDoor extends CraftBlockData implements Door {
@Override
public void setHalf(final org.bukkit.block.data.Bisected.Half half) {
Preconditions.checkArgument(half != null, "half cannot be null!");
this.set(HALF, half);
}
@ -62,6 +66,7 @@ public class CraftDoor extends CraftBlockData implements Door {
@Override
public void setHinge(final Door.Hinge hinge) {
Preconditions.checkArgument(hinge != null, "hinge cannot be null!");
this.set(HINGE, hinge);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import net.minecraft.world.level.block.DoublePlantBlock;
import net.minecraft.world.level.block.state.BlockState;
@ -24,6 +25,7 @@ public class CraftDoublePlant extends CraftBlockData implements Bisected {
@Override
public void setHalf(final Bisected.Half half) {
Preconditions.checkArgument(half != null, "half cannot be null!");
this.set(HALF, half);
}
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.DropperBlock;
@ -28,6 +29,8 @@ public class CraftDropper extends CraftBlockData implements Dispenser {
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian(), "Invalid face, only cartesian face are allowed for this property!");
this.set(FACING, blockFace);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.EndPortalFrameBlock;
@ -38,6 +39,8 @@ public class CraftEndPortalFrame extends CraftBlockData implements EndPortalFram
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!");
this.set(FACING, blockFace);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.EndRodBlock;
@ -25,6 +26,8 @@ public class CraftEndRod extends CraftBlockData implements Directional {
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian(), "Invalid face, only cartesian face are allowed for this property!");
this.set(FACING, blockFace);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.EnderChestBlock;
@ -28,6 +29,8 @@ public class CraftEnderChest extends CraftBlockData implements EnderChest {
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!");
this.set(FACING, blockFace);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.EquipableCarvedPumpkinBlock;
@ -25,6 +26,8 @@ public class CraftEquipableCarvedPumpkin extends CraftBlockData implements Direc
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!");
this.set(FACING, blockFace);
}

View File

@ -6,6 +6,7 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import org.bukkit.block.data.type.Farmland;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.jetbrains.annotations.Range;
@GeneratedFrom("1.20.4")
@SuppressWarnings("unused")
@ -17,12 +18,16 @@ public class CraftFarm extends CraftBlockData implements Farmland {
}
@Override
@Range(
from = 0,
to = 7
)
public int getMoisture() {
return this.get(MOISTURE);
}
@Override
public void setMoisture(final int moisture) {
public void setMoisture(@Range(from = 0, to = 7) final int moisture) {
this.set(MOISTURE, moisture);
}

View File

@ -1,10 +1,12 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import net.minecraft.world.level.block.FenceBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
@ -40,20 +42,26 @@ public class CraftFence extends CraftBlockData implements Fence {
@Override
public boolean hasFace(final BlockFace blockFace) {
return this.get(PROPERTY_BY_DIRECTION.get(blockFace));
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
BooleanProperty property = PROPERTY_BY_DIRECTION.get(blockFace);
Preconditions.checkArgument(property != null, "Invalid %s, only %s are allowed!".formatted("blockFace", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))));
return this.get(property);
}
@Override
public void setFace(final BlockFace blockFace, final boolean face) {
this.set(PROPERTY_BY_DIRECTION.get(blockFace), face);
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
BooleanProperty property = PROPERTY_BY_DIRECTION.get(blockFace);
Preconditions.checkArgument(property != null, "Invalid %s, only %s are allowed!".formatted("blockFace", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))));
this.set(property, face);
}
@Override
public Set<BlockFace> getFaces() {
ImmutableSet.Builder<BlockFace> faces = ImmutableSet.builder();
for (BlockFace blockFace : PROPERTY_BY_DIRECTION.keySet()) {
if (this.get(PROPERTY_BY_DIRECTION.get(blockFace))) {
faces.add(blockFace);
for (Map.Entry<BlockFace, BooleanProperty> entry : PROPERTY_BY_DIRECTION.entrySet()) {
if (this.get(entry.getValue())) {
faces.add(entry.getKey());
}
}
return faces.build();

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.FenceGateBlock;
@ -32,6 +33,8 @@ public class CraftFenceGate extends CraftBlockData implements Gate {
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!");
this.set(FACING, blockFace);
}

View File

@ -1,10 +1,12 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import net.minecraft.world.level.block.FireBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
@ -12,6 +14,7 @@ import net.minecraft.world.level.block.state.properties.IntegerProperty;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.type.Fire;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.jetbrains.annotations.Range;
@GeneratedFrom("1.20.4")
@SuppressWarnings("unused")
@ -31,12 +34,16 @@ public class CraftFire extends CraftBlockData implements Fire {
}
@Override
@Range(
from = 0,
to = 15
)
public int getAge() {
return this.get(AGE);
}
@Override
public void setAge(final int age) {
public void setAge(@Range(from = 0, to = 15) final int age) {
this.set(AGE, age);
}
@ -47,20 +54,26 @@ public class CraftFire extends CraftBlockData implements Fire {
@Override
public boolean hasFace(final BlockFace blockFace) {
return this.get(PROPERTY_BY_DIRECTION.get(blockFace));
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
BooleanProperty property = PROPERTY_BY_DIRECTION.get(blockFace);
Preconditions.checkArgument(property != null, "Invalid %s, only %s are allowed!".formatted("blockFace", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))));
return this.get(property);
}
@Override
public void setFace(final BlockFace blockFace, final boolean face) {
this.set(PROPERTY_BY_DIRECTION.get(blockFace), face);
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
BooleanProperty property = PROPERTY_BY_DIRECTION.get(blockFace);
Preconditions.checkArgument(property != null, "Invalid %s, only %s are allowed!".formatted("blockFace", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))));
this.set(property, face);
}
@Override
public Set<BlockFace> getFaces() {
ImmutableSet.Builder<BlockFace> faces = ImmutableSet.builder();
for (BlockFace blockFace : PROPERTY_BY_DIRECTION.keySet()) {
if (this.get(PROPERTY_BY_DIRECTION.get(blockFace))) {
faces.add(blockFace);
for (Map.Entry<BlockFace, BooleanProperty> entry : PROPERTY_BY_DIRECTION.entrySet()) {
if (this.get(entry.getValue())) {
faces.add(entry.getKey());
}
}
return faces.build();

View File

@ -6,6 +6,7 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import org.bukkit.block.data.Ageable;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.jetbrains.annotations.Range;
@GeneratedFrom("1.20.4")
@SuppressWarnings("unused")
@ -17,12 +18,16 @@ public class CraftFrostedIce extends CraftBlockData implements Ageable {
}
@Override
@Range(
from = 0,
to = 3
)
public int getAge() {
return this.get(AGE);
}
@Override
public void setAge(final int age) {
public void setAge(@Range(from = 0, to = 3) final int age) {
this.set(AGE, age);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.FurnaceBlock;
@ -28,6 +29,8 @@ public class CraftFurnace extends CraftBlockData implements Furnace {
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!");
this.set(FACING, blockFace);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.GlazedTerracottaBlock;
@ -25,6 +26,8 @@ public class CraftGlazedTerracotta extends CraftBlockData implements Directional
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!");
this.set(FACING, blockFace);
}

View File

@ -1,10 +1,12 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
@ -42,20 +44,26 @@ public class CraftGlowLichen extends CraftBlockData implements GlowLichen {
@Override
public boolean hasFace(final BlockFace blockFace) {
return this.get(PROPERTY_BY_DIRECTION.get(blockFace));
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
BooleanProperty property = PROPERTY_BY_DIRECTION.get(blockFace);
Preconditions.checkArgument(property != null, "Invalid %s, only %s are allowed!".formatted("blockFace", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))));
return this.get(property);
}
@Override
public void setFace(final BlockFace blockFace, final boolean face) {
this.set(PROPERTY_BY_DIRECTION.get(blockFace), face);
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
BooleanProperty property = PROPERTY_BY_DIRECTION.get(blockFace);
Preconditions.checkArgument(property != null, "Invalid %s, only %s are allowed!".formatted("blockFace", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))));
this.set(property, face);
}
@Override
public Set<BlockFace> getFaces() {
ImmutableSet.Builder<BlockFace> faces = ImmutableSet.builder();
for (BlockFace blockFace : PROPERTY_BY_DIRECTION.keySet()) {
if (this.get(PROPERTY_BY_DIRECTION.get(blockFace))) {
faces.add(blockFace);
for (Map.Entry<BlockFace, BooleanProperty> entry : PROPERTY_BY_DIRECTION.entrySet()) {
if (this.get(entry.getValue())) {
faces.add(entry.getKey());
}
}
return faces.build();

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.GrindstoneBlock;
@ -30,6 +31,7 @@ public class CraftGrindstone extends CraftBlockData implements Grindstone {
@Override
public void setAttachedFace(
final org.bukkit.block.data.FaceAttachable.AttachedFace attachedFace) {
Preconditions.checkArgument(attachedFace != null, "attachedFace cannot be null!");
this.set(FACE, attachedFace);
}
@ -40,6 +42,8 @@ public class CraftGrindstone extends CraftBlockData implements Grindstone {
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!");
this.set(FACING, blockFace);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.core.Direction;
@ -26,6 +27,7 @@ public class CraftHay extends CraftBlockData implements Orientable {
@Override
public void setAxis(final Axis axis) {
Preconditions.checkArgument(axis != null, "axis cannot be null!");
this.set(AXIS, axis);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.HopperBlock;
@ -38,6 +39,8 @@ public class CraftHopper extends CraftBlockData implements Hopper {
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian() && blockFace != BlockFace.UP, "Invalid face, only cartesian face (excluding UP) are allowed for this property!");
this.set(FACING, blockFace);
}

View File

@ -1,10 +1,12 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import net.minecraft.world.level.block.HugeMushroomBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
@ -30,20 +32,26 @@ public class CraftHugeMushroom extends CraftBlockData implements MultipleFacing
@Override
public boolean hasFace(final BlockFace blockFace) {
return this.get(PROPERTY_BY_DIRECTION.get(blockFace));
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
BooleanProperty property = PROPERTY_BY_DIRECTION.get(blockFace);
Preconditions.checkArgument(property != null, "Invalid %s, only %s are allowed!".formatted("blockFace", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))));
return this.get(property);
}
@Override
public void setFace(final BlockFace blockFace, final boolean face) {
this.set(PROPERTY_BY_DIRECTION.get(blockFace), face);
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
BooleanProperty property = PROPERTY_BY_DIRECTION.get(blockFace);
Preconditions.checkArgument(property != null, "Invalid %s, only %s are allowed!".formatted("blockFace", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))));
this.set(property, face);
}
@Override
public Set<BlockFace> getFaces() {
ImmutableSet.Builder<BlockFace> faces = ImmutableSet.builder();
for (BlockFace blockFace : PROPERTY_BY_DIRECTION.keySet()) {
if (this.get(PROPERTY_BY_DIRECTION.get(blockFace))) {
faces.add(blockFace);
for (Map.Entry<BlockFace, BooleanProperty> entry : PROPERTY_BY_DIRECTION.entrySet()) {
if (this.get(entry.getValue())) {
faces.add(entry.getKey());
}
}
return faces.build();

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.core.Direction;
@ -26,6 +27,7 @@ public class CraftInfestedRotatedPillar extends CraftBlockData implements Orient
@Override
public void setAxis(final Axis axis) {
Preconditions.checkArgument(axis != null, "axis cannot be null!");
this.set(AXIS, axis);
}

View File

@ -1,10 +1,12 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import net.minecraft.world.level.block.IronBarsBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
@ -40,20 +42,26 @@ public class CraftIronBars extends CraftBlockData implements Fence {
@Override
public boolean hasFace(final BlockFace blockFace) {
return this.get(PROPERTY_BY_DIRECTION.get(blockFace));
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
BooleanProperty property = PROPERTY_BY_DIRECTION.get(blockFace);
Preconditions.checkArgument(property != null, "Invalid %s, only %s are allowed!".formatted("blockFace", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))));
return this.get(property);
}
@Override
public void setFace(final BlockFace blockFace, final boolean face) {
this.set(PROPERTY_BY_DIRECTION.get(blockFace), face);
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
BooleanProperty property = PROPERTY_BY_DIRECTION.get(blockFace);
Preconditions.checkArgument(property != null, "Invalid %s, only %s are allowed!".formatted("blockFace", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))));
this.set(property, face);
}
@Override
public Set<BlockFace> getFaces() {
ImmutableSet.Builder<BlockFace> faces = ImmutableSet.builder();
for (BlockFace blockFace : PROPERTY_BY_DIRECTION.keySet()) {
if (this.get(PROPERTY_BY_DIRECTION.get(blockFace))) {
faces.add(blockFace);
for (Map.Entry<BlockFace, BooleanProperty> entry : PROPERTY_BY_DIRECTION.entrySet()) {
if (this.get(entry.getValue())) {
faces.add(entry.getKey());
}
}
return faces.build();

View File

@ -6,6 +6,7 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import org.bukkit.block.data.Ageable;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.jetbrains.annotations.Range;
@GeneratedFrom("1.20.4")
@SuppressWarnings("unused")
@ -17,12 +18,16 @@ public class CraftKelp extends CraftBlockData implements Ageable {
}
@Override
@Range(
from = 0,
to = 25
)
public int getAge() {
return this.get(AGE);
}
@Override
public void setAge(final int age) {
public void setAge(@Range(from = 0, to = 25) final int age) {
this.set(AGE, age);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.LadderBlock;
@ -28,6 +29,8 @@ public class CraftLadder extends CraftBlockData implements Ladder {
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!");
this.set(FACING, blockFace);
}

View File

@ -6,6 +6,7 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import org.bukkit.block.data.Levelled;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.jetbrains.annotations.Range;
@GeneratedFrom("1.20.4")
@SuppressWarnings("unused")
@ -17,12 +18,16 @@ public class CraftLayeredCauldron extends CraftBlockData implements Levelled {
}
@Override
@Range(
from = 1,
to = 3
)
public int getLevel() {
return this.get(LEVEL);
}
@Override
public void setLevel(final int level) {
public void setLevel(@Range(from = 1, to = 3) final int level) {
this.set(LEVEL, level);
}

View File

@ -7,6 +7,7 @@ import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import org.bukkit.block.data.type.Leaves;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.jetbrains.annotations.Range;
@GeneratedFrom("1.20.4")
@SuppressWarnings("unused")
@ -22,12 +23,16 @@ public class CraftLeaves extends CraftBlockData implements Leaves {
}
@Override
@Range(
from = 1,
to = 7
)
public int getDistance() {
return this.get(DISTANCE);
}
@Override
public void setDistance(final int distance) {
public void setDistance(@Range(from = 1, to = 7) final int distance) {
this.set(DISTANCE, distance);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.LecternBlock;
@ -30,6 +31,8 @@ public class CraftLectern extends CraftBlockData implements Lectern {
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!");
this.set(FACING, blockFace);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.LeverBlock;
@ -33,6 +34,7 @@ public class CraftLever extends CraftBlockData implements Switch {
@Override
public void setAttachedFace(
final org.bukkit.block.data.FaceAttachable.AttachedFace attachedFace) {
Preconditions.checkArgument(attachedFace != null, "attachedFace cannot be null!");
this.set(FACE, attachedFace);
}
@ -43,6 +45,8 @@ public class CraftLever extends CraftBlockData implements Switch {
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!");
this.set(FACING, blockFace);
}

View File

@ -7,6 +7,7 @@ import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import org.bukkit.block.data.type.Light;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.jetbrains.annotations.Range;
@GeneratedFrom("1.20.4")
@SuppressWarnings("unused")
@ -20,12 +21,16 @@ public class CraftLight extends CraftBlockData implements Light {
}
@Override
@Range(
from = 0,
to = 15
)
public int getLevel() {
return this.get(LEVEL);
}
@Override
public void setLevel(final int level) {
public void setLevel(@Range(from = 0, to = 15) final int level) {
this.set(LEVEL, level);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.LightningRodBlock;
@ -30,6 +31,8 @@ public class CraftLightningRod extends CraftBlockData implements LightningRod {
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian(), "Invalid face, only cartesian face are allowed for this property!");
this.set(FACING, blockFace);
}

View File

@ -6,6 +6,7 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import org.bukkit.block.data.Levelled;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.jetbrains.annotations.Range;
@GeneratedFrom("1.20.4")
@SuppressWarnings("unused")
@ -17,12 +18,16 @@ public class CraftLiquid extends CraftBlockData implements Levelled {
}
@Override
@Range(
from = 0,
to = 15
)
public int getLevel() {
return this.get(LEVEL);
}
@Override
public void setLevel(final int level) {
public void setLevel(@Range(from = 0, to = 15) final int level) {
this.set(LEVEL, level);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.LoomBlock;
@ -25,6 +26,8 @@ public class CraftLoom extends CraftBlockData implements Directional {
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!");
this.set(FACING, blockFace);
}

View File

@ -7,6 +7,7 @@ import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import org.bukkit.block.data.type.Leaves;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.jetbrains.annotations.Range;
@GeneratedFrom("1.20.4")
@SuppressWarnings("unused")
@ -22,12 +23,16 @@ public class CraftMangroveLeaves extends CraftBlockData implements Leaves {
}
@Override
@Range(
from = 1,
to = 7
)
public int getDistance() {
return this.get(DISTANCE);
}
@Override
public void setDistance(final int distance) {
public void setDistance(@Range(from = 1, to = 7) final int distance) {
this.set(DISTANCE, distance);
}

View File

@ -8,6 +8,7 @@ import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import org.bukkit.block.data.type.MangrovePropagule;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.jetbrains.annotations.Range;
@GeneratedFrom("1.20.4")
@SuppressWarnings("unused")
@ -25,12 +26,16 @@ public class CraftMangrovePropagule extends CraftBlockData implements MangrovePr
}
@Override
@Range(
from = 0,
to = 4
)
public int getAge() {
return this.get(AGE);
}
@Override
public void setAge(final int age) {
public void setAge(@Range(from = 0, to = 4) final int age) {
this.set(AGE, age);
}
@ -50,12 +55,16 @@ public class CraftMangrovePropagule extends CraftBlockData implements MangrovePr
}
@Override
@Range(
from = 0,
to = 1
)
public int getStage() {
return this.get(STAGE);
}
@Override
public void setStage(final int stage) {
public void setStage(@Range(from = 0, to = 1) final int stage) {
this.set(STAGE, stage);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.piston.MovingPistonBlock;
@ -29,6 +30,8 @@ public class CraftMovingPiston extends CraftBlockData implements TechnicalPiston
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian(), "Invalid face, only cartesian face are allowed for this property!");
this.set(FACING, blockFace);
}
@ -44,6 +47,7 @@ public class CraftMovingPiston extends CraftBlockData implements TechnicalPiston
@Override
public void setType(final TechnicalPiston.Type type) {
Preconditions.checkArgument(type != null, "type cannot be null!");
this.set(TYPE, type);
}
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.core.Direction;
@ -26,6 +27,8 @@ public class CraftNetherPortal extends CraftBlockData implements Orientable {
@Override
public void setAxis(final Axis axis) {
Preconditions.checkArgument(axis != null, "axis cannot be null!");
Preconditions.checkArgument(axis == Axis.X || axis == Axis.Z, "Invalid axis, only horizontal axis are allowed for this property!");
this.set(AXIS, axis);
}

View File

@ -6,6 +6,7 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import org.bukkit.block.data.Ageable;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.jetbrains.annotations.Range;
@GeneratedFrom("1.20.4")
@SuppressWarnings("unused")
@ -17,12 +18,16 @@ public class CraftNetherWart extends CraftBlockData implements Ageable {
}
@Override
@Range(
from = 0,
to = 3
)
public int getAge() {
return this.get(AGE);
}
@Override
public void setAge(final int age) {
public void setAge(@Range(from = 0, to = 3) final int age) {
this.set(AGE, age);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
@ -31,6 +32,7 @@ public class CraftNoteBlock extends CraftBlockData implements NoteBlock {
@Override
public void setInstrument(final Instrument instrument) {
Preconditions.checkArgument(instrument != null, "instrument cannot be null!");
this.set(INSTRUMENT, instrument);
}
@ -41,6 +43,7 @@ public class CraftNoteBlock extends CraftBlockData implements NoteBlock {
@Override
public void setNote(final Note note) {
Preconditions.checkArgument(note != null, "note cannot be null!");
this.set(NOTE, (int) note.getId());
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.ObserverBlock;
@ -28,6 +29,8 @@ public class CraftObserver extends CraftBlockData implements Observer {
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian(), "Invalid face, only cartesian face are allowed for this property!");
this.set(FACING, blockFace);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.PiglinWallSkullBlock;
@ -28,6 +29,8 @@ public class CraftPiglinWallSkull extends CraftBlockData implements SkullWall {
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!");
this.set(FACING, blockFace);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.PinkPetalsBlock;
@ -9,6 +10,7 @@ import net.minecraft.world.level.block.state.properties.IntegerProperty;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.type.PinkPetals;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.jetbrains.annotations.Range;
@GeneratedFrom("1.20.4")
@SuppressWarnings("unused")
@ -28,6 +30,8 @@ public class CraftPinkPetals extends CraftBlockData implements PinkPetals {
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!");
this.set(FACING, blockFace);
}
@ -37,12 +41,16 @@ public class CraftPinkPetals extends CraftBlockData implements PinkPetals {
}
@Override
@Range(
from = 1,
to = 4
)
public int getFlowerAmount() {
return this.get(AMOUNT);
}
@Override
public void setFlowerAmount(final int flowerAmount) {
public void setFlowerAmount(@Range(from = 1, to = 4) final int flowerAmount) {
this.set(AMOUNT, flowerAmount);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.piston.PistonBaseBlock;
@ -38,6 +39,8 @@ public class CraftPistonBase extends CraftBlockData implements Piston {
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian(), "Invalid face, only cartesian face are allowed for this property!");
this.set(FACING, blockFace);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.piston.PistonHeadBlock;
@ -32,6 +33,8 @@ public class CraftPistonHead extends CraftBlockData implements PistonHead {
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian(), "Invalid face, only cartesian face are allowed for this property!");
this.set(FACING, blockFace);
}
@ -57,6 +60,7 @@ public class CraftPistonHead extends CraftBlockData implements PistonHead {
@Override
public void setType(final org.bukkit.block.data.type.TechnicalPiston.Type type) {
Preconditions.checkArgument(type != null, "type cannot be null!");
this.set(TYPE, type);
}
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import net.minecraft.world.level.block.PitcherCropBlock;
import net.minecraft.world.level.block.state.BlockState;
@ -8,6 +9,7 @@ import net.minecraft.world.level.block.state.properties.EnumProperty;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import org.bukkit.block.data.type.PitcherCrop;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.jetbrains.annotations.Range;
@GeneratedFrom("1.20.4")
@SuppressWarnings("unused")
@ -21,12 +23,16 @@ public class CraftPitcherCrop extends CraftBlockData implements PitcherCrop {
}
@Override
@Range(
from = 0,
to = 4
)
public int getAge() {
return this.get(AGE);
}
@Override
public void setAge(final int age) {
public void setAge(@Range(from = 0, to = 4) final int age) {
this.set(AGE, age);
}
@ -42,6 +48,7 @@ public class CraftPitcherCrop extends CraftBlockData implements PitcherCrop {
@Override
public void setHalf(final org.bukkit.block.data.Bisected.Half half) {
Preconditions.checkArgument(half != null, "half cannot be null!");
this.set(HALF, half);
}
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import net.minecraft.world.level.block.PlayerHeadBlock;
import net.minecraft.world.level.block.state.BlockState;
@ -39,6 +40,8 @@ public class CraftPlayerHead extends CraftBlockData implements Skull {
@Override
public void setRotation(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace != BlockFace.SELF && blockFace.getModY() == 0, "Invalid face, only horizontal face are allowed for this property!");
Vector dir = blockFace.getDirection();
float angle = (float) -Math.toDegrees(Math.atan2(dir.getX(), dir.getZ()));
this.set(ROTATION, RotationSegment.convertToSegment(angle));

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.PlayerWallHeadBlock;
@ -28,6 +29,8 @@ public class CraftPlayerWallHead extends CraftBlockData implements SkullWall {
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!");
this.set(FACING, blockFace);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.PointedDripstoneBlock;
@ -32,6 +33,7 @@ public class CraftPointedDripstone extends CraftBlockData implements PointedDrip
@Override
public void setThickness(final PointedDripstone.Thickness thickness) {
Preconditions.checkArgument(thickness != null, "thickness cannot be null!");
this.set(THICKNESS, thickness);
}
@ -42,6 +44,8 @@ public class CraftPointedDripstone extends CraftBlockData implements PointedDrip
@Override
public void setVerticalDirection(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.getModY() != 0, "Invalid face, only vertical face are allowed for this property!");
this.set(TIP_DIRECTION, blockFace);
}

View File

@ -6,6 +6,7 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import org.bukkit.block.data.Ageable;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.jetbrains.annotations.Range;
@GeneratedFrom("1.20.4")
@SuppressWarnings("unused")
@ -17,12 +18,16 @@ public class CraftPotato extends CraftBlockData implements Ageable {
}
@Override
@Range(
from = 0,
to = 7
)
public int getAge() {
return this.get(AGE);
}
@Override
public void setAge(final int age) {
public void setAge(@Range(from = 0, to = 7) final int age) {
this.set(AGE, age);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.PoweredRailBlock;
@ -40,6 +41,8 @@ public class CraftPoweredRail extends CraftBlockData implements RedstoneRail {
@Override
public void setShape(final org.bukkit.block.data.Rail.Shape shape) {
Preconditions.checkArgument(shape != null, "shape cannot be null!");
Preconditions.checkArgument(shape != org.bukkit.block.data.Rail.Shape.NORTH_EAST && shape != org.bukkit.block.data.Rail.Shape.NORTH_WEST && shape != org.bukkit.block.data.Rail.Shape.SOUTH_EAST && shape != org.bukkit.block.data.Rail.Shape.SOUTH_WEST, "Invalid rail shape, only straight rail are allowed for this property!");
this.set(SHAPE, shape);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.RailBlock;
@ -28,6 +29,7 @@ public class CraftRail extends CraftBlockData implements Rail {
@Override
public void setShape(final Rail.Shape shape) {
Preconditions.checkArgument(shape != null, "shape cannot be null!");
this.set(SHAPE, shape);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Collections;
import java.util.Map;
@ -14,6 +15,7 @@ import org.bukkit.block.BlockFace;
import org.bukkit.block.data.type.RedstoneWire;
import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.jetbrains.annotations.Range;
@GeneratedFrom("1.20.4")
@SuppressWarnings("unused")
@ -28,12 +30,16 @@ public class CraftRedStoneWire extends CraftBlockData implements RedstoneWire {
}
@Override
@Range(
from = 0,
to = 15
)
public int getPower() {
return this.get(POWER);
}
@Override
public void setPower(final int power) {
public void setPower(@Range(from = 0, to = 15) final int power) {
this.set(POWER, power);
}
@ -44,12 +50,19 @@ public class CraftRedStoneWire extends CraftBlockData implements RedstoneWire {
@Override
public RedstoneWire.Connection getFace(final BlockFace blockFace) {
return this.get(PROPERTY_BY_DIRECTION.get(blockFace), RedstoneWire.Connection.class);
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
EnumProperty<RedstoneSide> property = PROPERTY_BY_DIRECTION.get(blockFace);
Preconditions.checkArgument(property != null, "Invalid %s, only %s are allowed!".formatted("blockFace", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))));
return this.get(property, RedstoneWire.Connection.class);
}
@Override
public void setFace(final BlockFace blockFace, final RedstoneWire.Connection connection) {
this.set(PROPERTY_BY_DIRECTION.get(blockFace), connection);
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(connection != null, "connection cannot be null!");
EnumProperty<RedstoneSide> property = PROPERTY_BY_DIRECTION.get(blockFace);
Preconditions.checkArgument(property != null, "Invalid %s, only %s are allowed!".formatted("blockFace", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))));
this.set(property, connection);
}
@Override

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.RedstoneWallTorchBlock;
@ -28,6 +29,8 @@ public class CraftRedstoneWallTorch extends CraftBlockData implements RedstoneWa
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!");
this.set(FACING, blockFace);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.world.level.block.RepeaterBlock;
@ -10,6 +11,7 @@ import net.minecraft.world.level.block.state.properties.IntegerProperty;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.type.Repeater;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.jetbrains.annotations.Range;
@GeneratedFrom("1.20.4")
@SuppressWarnings("unused")
@ -27,12 +29,16 @@ public class CraftRepeater extends CraftBlockData implements Repeater {
}
@Override
@Range(
from = 1,
to = 4
)
public int getDelay() {
return this.get(DELAY);
}
@Override
public void setDelay(final int delay) {
public void setDelay(@Range(from = 1, to = 4) final int delay) {
this.set(DELAY, delay);
}
@ -53,6 +59,8 @@ public class CraftRepeater extends CraftBlockData implements Repeater {
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!");
this.set(FACING, blockFace);
}

View File

@ -6,6 +6,7 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import org.bukkit.block.data.type.RespawnAnchor;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.jetbrains.annotations.Range;
@GeneratedFrom("1.20.4")
@SuppressWarnings("unused")
@ -17,12 +18,16 @@ public class CraftRespawnAnchor extends CraftBlockData implements RespawnAnchor
}
@Override
@Range(
from = 0,
to = 4
)
public int getCharges() {
return this.get(CHARGE);
}
@Override
public void setCharges(final int charges) {
public void setCharges(@Range(from = 0, to = 4) final int charges) {
this.set(CHARGE, charges);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.core.Direction;
@ -26,6 +27,7 @@ public class CraftRotatedPillar extends CraftBlockData implements Orientable {
@Override
public void setAxis(final Axis axis) {
Preconditions.checkArgument(axis != null, "axis cannot be null!");
this.set(AXIS, axis);
}

View File

@ -6,6 +6,7 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import org.bukkit.block.data.type.Sapling;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.jetbrains.annotations.Range;
@GeneratedFrom("1.20.4")
@SuppressWarnings("unused")
@ -17,12 +18,16 @@ public class CraftSapling extends CraftBlockData implements Sapling {
}
@Override
@Range(
from = 0,
to = 1
)
public int getStage() {
return this.get(STAGE);
}
@Override
public void setStage(final int stage) {
public void setStage(@Range(from = 0, to = 1) final int stage) {
this.set(STAGE, stage);
}

View File

@ -7,6 +7,7 @@ import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import org.bukkit.block.data.type.Scaffolding;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.jetbrains.annotations.Range;
@GeneratedFrom("1.20.4")
@SuppressWarnings("unused")
@ -32,12 +33,16 @@ public class CraftScaffolding extends CraftBlockData implements Scaffolding {
}
@Override
@Range(
from = 0,
to = 7
)
public int getDistance() {
return this.get(DISTANCE);
}
@Override
public void setDistance(final int distance) {
public void setDistance(@Range(from = 0, to = 7) final int distance) {
this.set(DISTANCE, distance);
}

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import net.minecraft.world.level.block.SculkSensorBlock;
import net.minecraft.world.level.block.state.BlockState;
@ -9,6 +10,7 @@ import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.world.level.block.state.properties.SculkSensorPhase;
import org.bukkit.block.data.type.SculkSensor;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.jetbrains.annotations.Range;
@GeneratedFrom("1.20.4")
@SuppressWarnings("unused")
@ -24,12 +26,16 @@ public class CraftSculkSensor extends CraftBlockData implements SculkSensor {
}
@Override
@Range(
from = 0,
to = 15
)
public int getPower() {
return this.get(POWER);
}
@Override
public void setPower(final int power) {
public void setPower(@Range(from = 0, to = 15) final int power) {
this.set(POWER, power);
}
@ -45,6 +51,7 @@ public class CraftSculkSensor extends CraftBlockData implements SculkSensor {
@Override
public void setSculkSensorPhase(final SculkSensor.Phase phase) {
Preconditions.checkArgument(phase != null, "phase cannot be null!");
this.set(PHASE, phase);
}

View File

@ -1,10 +1,12 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
@ -42,20 +44,26 @@ public class CraftSculkVein extends CraftBlockData implements SculkVein {
@Override
public boolean hasFace(final BlockFace blockFace) {
return this.get(PROPERTY_BY_DIRECTION.get(blockFace));
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
BooleanProperty property = PROPERTY_BY_DIRECTION.get(blockFace);
Preconditions.checkArgument(property != null, "Invalid %s, only %s are allowed!".formatted("blockFace", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))));
return this.get(property);
}
@Override
public void setFace(final BlockFace blockFace, final boolean face) {
this.set(PROPERTY_BY_DIRECTION.get(blockFace), face);
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
BooleanProperty property = PROPERTY_BY_DIRECTION.get(blockFace);
Preconditions.checkArgument(property != null, "Invalid %s, only %s are allowed!".formatted("blockFace", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))));
this.set(property, face);
}
@Override
public Set<BlockFace> getFaces() {
ImmutableSet.Builder<BlockFace> faces = ImmutableSet.builder();
for (BlockFace blockFace : PROPERTY_BY_DIRECTION.keySet()) {
if (this.get(PROPERTY_BY_DIRECTION.get(blockFace))) {
faces.add(blockFace);
for (Map.Entry<BlockFace, BooleanProperty> entry : PROPERTY_BY_DIRECTION.entrySet()) {
if (this.get(entry.getValue())) {
faces.add(entry.getKey());
}
}
return faces.build();

View File

@ -7,6 +7,7 @@ import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import org.bukkit.block.data.type.SeaPickle;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.jetbrains.annotations.Range;
@GeneratedFrom("1.20.4")
@SuppressWarnings("unused")
@ -20,12 +21,16 @@ public class CraftSeaPickle extends CraftBlockData implements SeaPickle {
}
@Override
@Range(
from = 1,
to = 4
)
public int getPickles() {
return this.get(PICKLES);
}
@Override
public void setPickles(final int pickles) {
public void setPickles(@Range(from = 1, to = 4) final int pickles) {
this.set(PICKLES, pickles);
}

Some files were not shown because too many files have changed in this diff Show More