mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2026-01-03 22:26:16 +00:00
泛型
This commit is contained in:
@@ -7,7 +7,6 @@ import net.momirealms.craftengine.bukkit.util.BlockStateUtils;
|
|||||||
import net.momirealms.craftengine.bukkit.util.DirectionUtils;
|
import net.momirealms.craftengine.bukkit.util.DirectionUtils;
|
||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.block.behavior.IsPathFindableBlockBehavior;
|
import net.momirealms.craftengine.core.block.behavior.IsPathFindableBlockBehavior;
|
||||||
import net.momirealms.craftengine.core.block.properties.IntegerProperty;
|
import net.momirealms.craftengine.core.block.properties.IntegerProperty;
|
||||||
@@ -22,7 +21,7 @@ import java.util.Optional;
|
|||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
public class AttachedStemBlockBehavior extends BukkitBlockBehavior implements IsPathFindableBlockBehavior {
|
public class AttachedStemBlockBehavior extends BukkitBlockBehavior implements IsPathFindableBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<AttachedStemBlockBehavior> FACTORY = new Factory();
|
||||||
private final Property<HorizontalDirection> facingProperty;
|
private final Property<HorizontalDirection> facingProperty;
|
||||||
private final Key fruit;
|
private final Key fruit;
|
||||||
private final Key stem;
|
private final Key stem;
|
||||||
@@ -85,10 +84,10 @@ public class AttachedStemBlockBehavior extends BukkitBlockBehavior implements Is
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<AttachedStemBlockBehavior> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public AttachedStemBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Property<HorizontalDirection> facingProperty = (Property<HorizontalDirection>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("facing"), "warning.config.block.behavior.attached_stem.missing_facing");
|
Property<HorizontalDirection> facingProperty = (Property<HorizontalDirection>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("facing"), "warning.config.block.behavior.attached_stem.missing_facing");
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import net.momirealms.craftengine.bukkit.plugin.BukkitCraftEngine;
|
|||||||
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.CoreReflections;
|
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.CoreReflections;
|
||||||
import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.block.behavior.FallOnBlockBehavior;
|
import net.momirealms.craftengine.core.block.behavior.FallOnBlockBehavior;
|
||||||
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||||
@@ -18,7 +17,7 @@ import java.util.Map;
|
|||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
public class BouncingBlockBehavior extends BukkitBlockBehavior implements FallOnBlockBehavior {
|
public class BouncingBlockBehavior extends BukkitBlockBehavior implements FallOnBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<BouncingBlockBehavior> FACTORY = new Factory();
|
||||||
private final double bounceHeight;
|
private final double bounceHeight;
|
||||||
private final boolean syncPlayerPosition;
|
private final boolean syncPlayerPosition;
|
||||||
private final double fallDamageMultiplier;
|
private final double fallDamageMultiplier;
|
||||||
@@ -77,10 +76,10 @@ public class BouncingBlockBehavior extends BukkitBlockBehavior implements FallOn
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<BouncingBlockBehavior> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public BouncingBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
double bounceHeight = ResourceConfigUtils.getAsDouble(arguments.getOrDefault("bounce-height", 0.66), "bounce-height");
|
double bounceHeight = ResourceConfigUtils.getAsDouble(arguments.getOrDefault("bounce-height", 0.66), "bounce-height");
|
||||||
boolean syncPlayerPosition = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("sync-player-position", true), "sync-player-position");
|
boolean syncPlayerPosition = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("sync-player-position", true), "sync-player-position");
|
||||||
double fallDamageMultiplier = ResourceConfigUtils.getAsDouble(arguments.getOrDefault("fall-damage-multiplier", 0.5), "fall-damage-multiplier");
|
double fallDamageMultiplier = ResourceConfigUtils.getAsDouble(arguments.getOrDefault("fall-damage-multiplier", 0.5), "fall-damage-multiplier");
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import net.momirealms.craftengine.bukkit.util.BlockStateUtils;
|
|||||||
import net.momirealms.craftengine.bukkit.util.DirectionUtils;
|
import net.momirealms.craftengine.bukkit.util.DirectionUtils;
|
||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.block.properties.BooleanProperty;
|
import net.momirealms.craftengine.core.block.properties.BooleanProperty;
|
||||||
import net.momirealms.craftengine.core.block.properties.Property;
|
import net.momirealms.craftengine.core.block.properties.Property;
|
||||||
@@ -19,7 +18,7 @@ import java.util.Map;
|
|||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
public class BuddingBlockBehavior extends BukkitBlockBehavior {
|
public class BuddingBlockBehavior extends BukkitBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<BuddingBlockBehavior> FACTORY = new Factory();
|
||||||
private final float growthChance;
|
private final float growthChance;
|
||||||
private final List<Key> blocks;
|
private final List<Key> blocks;
|
||||||
|
|
||||||
@@ -86,10 +85,10 @@ public class BuddingBlockBehavior extends BukkitBlockBehavior {
|
|||||||
&& FastNMS.INSTANCE.field$FluidState$amount(FastNMS.INSTANCE.field$BlockBehaviour$BlockStateBase$fluidState(state)) == 8;
|
&& FastNMS.INSTANCE.field$FluidState$amount(FastNMS.INSTANCE.field$BlockBehaviour$BlockStateBase$fluidState(state)) == 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<BuddingBlockBehavior> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public BuddingBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
float growthChance = ResourceConfigUtils.getAsFloat(arguments.getOrDefault("growth-chance", 0.2), "growth-chance");
|
float growthChance = ResourceConfigUtils.getAsFloat(arguments.getOrDefault("growth-chance", 0.2), "growth-chance");
|
||||||
List<Key> blocks = new ObjectArrayList<>();
|
List<Key> blocks = new ObjectArrayList<>();
|
||||||
MiscUtils.getAsStringList(arguments.get("blocks")).forEach(s -> blocks.add(Key.of(s)));
|
MiscUtils.getAsStringList(arguments.get("blocks")).forEach(s -> blocks.add(Key.of(s)));
|
||||||
|
|||||||
@@ -7,52 +7,52 @@ import net.momirealms.craftengine.core.util.Key;
|
|||||||
public class BukkitBlockBehaviors extends BlockBehaviors {
|
public class BukkitBlockBehaviors extends BlockBehaviors {
|
||||||
private BukkitBlockBehaviors() {}
|
private BukkitBlockBehaviors() {}
|
||||||
|
|
||||||
public static final BlockBehaviorType BUSH_BLOCK = register(Key.ce("bush_block"), BushBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<BushBlockBehavior> BUSH_BLOCK = register(Key.ce("bush_block"), BushBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType HANGING_BLOCK = register(Key.ce("hanging_block"), HangingBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<HangingBlockBehavior> HANGING_BLOCK = register(Key.ce("hanging_block"), HangingBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType FALLING_BLOCK = register(Key.ce("falling_block"), FallingBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<FallingBlockBehavior> FALLING_BLOCK = register(Key.ce("falling_block"), FallingBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType LEAVES_BLOCK = register(Key.ce("leaves_block"), LeavesBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<LeavesBlockBehavior> LEAVES_BLOCK = register(Key.ce("leaves_block"), LeavesBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType STRIPPABLE_BLOCK = register(Key.ce("strippable_block"), StrippableBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<StrippableBlockBehavior> STRIPPABLE_BLOCK = register(Key.ce("strippable_block"), StrippableBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType SAPLING_BLOCK = register(Key.ce("sapling_block"), SaplingBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<SaplingBlockBehavior> SAPLING_BLOCK = register(Key.ce("sapling_block"), SaplingBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType ON_LIQUID_BLOCK = register(Key.ce("on_liquid_block"), OnLiquidBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<OnLiquidBlockBehavior> ON_LIQUID_BLOCK = register(Key.ce("on_liquid_block"), OnLiquidBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType NEAR_LIQUID_BLOCK = register(Key.ce("near_liquid_block"), NearLiquidBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<NearLiquidBlockBehavior> NEAR_LIQUID_BLOCK = register(Key.ce("near_liquid_block"), NearLiquidBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType CONCRETE_POWDER_BLOCK = register(Key.ce("concrete_powder_block"), ConcretePowderBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<ConcretePowderBlockBehavior> CONCRETE_POWDER_BLOCK = register(Key.ce("concrete_powder_block"), ConcretePowderBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType VERTICAL_CROP_BLOCK = register(Key.ce("vertical_crop_block"), VerticalCropBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<VerticalCropBlockBehavior> VERTICAL_CROP_BLOCK = register(Key.ce("vertical_crop_block"), VerticalCropBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType CROP_BLOCK = register(Key.ce("crop_block"), CropBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<CropBlockBehavior> CROP_BLOCK = register(Key.ce("crop_block"), CropBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType GRASS_BLOCK = register(Key.ce("grass_block"), GrassBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<GrassBlockBehavior> GRASS_BLOCK = register(Key.ce("grass_block"), GrassBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType LAMP_BLOCK = register(Key.ce("lamp_block"), LampBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<LampBlockBehavior> LAMP_BLOCK = register(Key.ce("lamp_block"), LampBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType TRAPDOOR_BLOCK = register(Key.ce("trapdoor_block"), TrapDoorBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<TrapDoorBlockBehavior> TRAPDOOR_BLOCK = register(Key.ce("trapdoor_block"), TrapDoorBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType DOOR_BLOCK = register(Key.ce("door_block"), DoorBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<DoorBlockBehavior> DOOR_BLOCK = register(Key.ce("door_block"), DoorBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType STACKABLE_BLOCK = register(Key.ce("stackable_block"), StackableBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<StackableBlockBehavior> STACKABLE_BLOCK = register(Key.ce("stackable_block"), StackableBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType STURDY_BASE_BLOCK = register(Key.ce("sturdy_base_block"), SturdyBaseBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<SturdyBaseBlockBehavior> STURDY_BASE_BLOCK = register(Key.ce("sturdy_base_block"), SturdyBaseBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType FENCE_GATE_BLOCK = register(Key.ce("fence_gate_block"), FenceGateBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<FenceGateBlockBehavior> FENCE_GATE_BLOCK = register(Key.ce("fence_gate_block"), FenceGateBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType SLAB_BLOCK = register(Key.ce("slab_block"), SlabBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<SlabBlockBehavior> SLAB_BLOCK = register(Key.ce("slab_block"), SlabBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType STAIRS_BLOCK = register(Key.ce("stairs_block"), StairsBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<StairsBlockBehavior> STAIRS_BLOCK = register(Key.ce("stairs_block"), StairsBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType PRESSURE_PLATE_BLOCK = register(Key.ce("pressure_plate_block"), PressurePlateBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<PressurePlateBlockBehavior> PRESSURE_PLATE_BLOCK = register(Key.ce("pressure_plate_block"), PressurePlateBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType DOUBLE_HIGH_BLOCK = register(Key.ce("double_high_block"), DoubleHighBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<DoubleHighBlockBehavior> DOUBLE_HIGH_BLOCK = register(Key.ce("double_high_block"), DoubleHighBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType CHANGE_OVER_TIME_BLOCK = register(Key.ce("change_over_time_block"), ChangeOverTimeBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<ChangeOverTimeBlockBehavior> CHANGE_OVER_TIME_BLOCK = register(Key.ce("change_over_time_block"), ChangeOverTimeBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType SIMPLE_STORAGE_BLOCK = register(Key.ce("simple_storage_block"), SimpleStorageBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<SimpleStorageBlockBehavior> SIMPLE_STORAGE_BLOCK = register(Key.ce("simple_storage_block"), SimpleStorageBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType TOGGLEABLE_LAMP_BLOCK = register(Key.ce("toggleable_lamp_block"), ToggleableLampBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<ToggleableLampBlockBehavior> TOGGLEABLE_LAMP_BLOCK = register(Key.ce("toggleable_lamp_block"), ToggleableLampBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType SOFA_BLOCK = register(Key.ce("sofa_block"), SofaBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<SofaBlockBehavior> SOFA_BLOCK = register(Key.ce("sofa_block"), SofaBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType BOUNCING_BLOCK = register(Key.ce("bouncing_block"), BouncingBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<BouncingBlockBehavior> BOUNCING_BLOCK = register(Key.ce("bouncing_block"), BouncingBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType DIRECTIONAL_ATTACHED_BLOCK = register(Key.ce("directional_attached_block"), DirectionalAttachedBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<DirectionalAttachedBlockBehavior> DIRECTIONAL_ATTACHED_BLOCK = register(Key.ce("directional_attached_block"), DirectionalAttachedBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType LIQUID_FLOWABLE_BLOCK = register(Key.ce("liquid_flowable_block"), LiquidFlowableBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<LiquidFlowableBlockBehavior> LIQUID_FLOWABLE_BLOCK = register(Key.ce("liquid_flowable_block"), LiquidFlowableBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType SIMPLE_PARTICLE_BLOCK = register(Key.ce("simple_particle_block"), SimpleParticleBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<SimpleParticleBlockBehavior> SIMPLE_PARTICLE_BLOCK = register(Key.ce("simple_particle_block"), SimpleParticleBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType WALL_TORCH_PARTICLE_BLOCK = register(Key.ce("wall_torch_particle_block"), WallTorchParticleBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<WallTorchParticleBlockBehavior> WALL_TORCH_PARTICLE_BLOCK = register(Key.ce("wall_torch_particle_block"), WallTorchParticleBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType FENCE_BLOCK = register(Key.ce("fence_block"), FenceBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<FenceBlockBehavior> FENCE_BLOCK = register(Key.ce("fence_block"), FenceBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType BUTTON_BLOCK = register(Key.ce("button_block"), ButtonBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<ButtonBlockBehavior> BUTTON_BLOCK = register(Key.ce("button_block"), ButtonBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType FACE_ATTACHED_HORIZONTAL_DIRECTIONAL_BLOCK = register(Key.ce("face_attached_horizontal_directional_block"), FaceAttachedHorizontalDirectionalBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<FaceAttachedHorizontalDirectionalBlockBehavior> FACE_ATTACHED_HORIZONTAL_DIRECTIONAL_BLOCK = register(Key.ce("face_attached_horizontal_directional_block"), FaceAttachedHorizontalDirectionalBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType STEM_BLOCK = register(Key.ce("stem_block"), StemBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<StemBlockBehavior> STEM_BLOCK = register(Key.ce("stem_block"), StemBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType ATTACHED_STEM_BLOCK = register(Key.ce("attached_stem_block"), AttachedStemBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<AttachedStemBlockBehavior> ATTACHED_STEM_BLOCK = register(Key.ce("attached_stem_block"), AttachedStemBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType CHIME_BLOCK = register(Key.ce("chime_block"), ChimeBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<ChimeBlockBehavior> CHIME_BLOCK = register(Key.ce("chime_block"), ChimeBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType BUDDING_BLOCK = register(Key.ce("budding_block"), BuddingBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<BuddingBlockBehavior> BUDDING_BLOCK = register(Key.ce("budding_block"), BuddingBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType SEAT_BLOCK = register(Key.ce("seat_block"), SeatBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<SeatBlockBehavior> SEAT_BLOCK = register(Key.ce("seat_block"), SeatBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType SURFACE_SPREADING_BLOCK = register(Key.ce("surface_spreading_block"), SurfaceSpreadingBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<SurfaceSpreadingBlockBehavior> SURFACE_SPREADING_BLOCK = register(Key.ce("surface_spreading_block"), SurfaceSpreadingBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType SNOWY_BLOCK = register(Key.ce("snowy_block"), SnowyBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<SnowyBlockBehavior> SNOWY_BLOCK = register(Key.ce("snowy_block"), SnowyBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType HANGABLE_BLOCK = register(Key.ce("hangable_block"), HangableBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<HangableBlockBehavior> HANGABLE_BLOCK = register(Key.ce("hangable_block"), HangableBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType DROP_EXPERIENCE_BLOCK = register(Key.ce("drop_experience_block"), DropExperienceBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<DropExperienceBlockBehavior> DROP_EXPERIENCE_BLOCK = register(Key.ce("drop_experience_block"), DropExperienceBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType DROP_EXP_BLOCK = register(Key.ce("drop_exp_block"), DropExperienceBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<DropExperienceBlockBehavior> DROP_EXP_BLOCK = register(Key.ce("drop_exp_block"), DropExperienceBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType MULTI_HIGH_BLOCK = register(Key.ce("multi_high_block"), MultiHighBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<MultiHighBlockBehavior> MULTI_HIGH_BLOCK = register(Key.ce("multi_high_block"), MultiHighBlockBehavior.FACTORY);
|
||||||
public static final BlockBehaviorType SPREADING_BLOCK = register(Key.ce("spreading_block"), SpreadingBlockBehavior.FACTORY);
|
public static final BlockBehaviorType<SpreadingBlockBehavior> SPREADING_BLOCK = register(Key.ce("spreading_block"), SpreadingBlockBehavior.FACTORY);
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import net.momirealms.craftengine.bukkit.util.BlockTags;
|
|||||||
import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.util.Key;
|
import net.momirealms.craftengine.core.util.Key;
|
||||||
import net.momirealms.craftengine.core.util.MiscUtils;
|
import net.momirealms.craftengine.core.util.MiscUtils;
|
||||||
@@ -20,7 +19,7 @@ import org.bukkit.Registry;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class BushBlockBehavior extends AbstractCanSurviveBlockBehavior {
|
public class BushBlockBehavior extends AbstractCanSurviveBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<BushBlockBehavior> FACTORY = new Factory();
|
||||||
protected final List<Object> tagsCanSurviveOn;
|
protected final List<Object> tagsCanSurviveOn;
|
||||||
protected final Set<Object> blockStatesCanSurviveOn;
|
protected final Set<Object> blockStatesCanSurviveOn;
|
||||||
protected final Set<String> customBlocksCansSurviveOn;
|
protected final Set<String> customBlocksCansSurviveOn;
|
||||||
@@ -39,10 +38,10 @@ public class BushBlockBehavior extends AbstractCanSurviveBlockBehavior {
|
|||||||
this.customBlocksCansSurviveOn = customBlocksCansSurviveOn;
|
this.customBlocksCansSurviveOn = customBlocksCansSurviveOn;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<BushBlockBehavior> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public BushBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
Tuple<List<Object>, Set<Object>, Set<String>> tuple = readTagsAndState(arguments, false);
|
Tuple<List<Object>, Set<Object>, Set<String>> tuple = readTagsAndState(arguments, false);
|
||||||
boolean stackable = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("stackable", false), "stackable");
|
boolean stackable = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("stackable", false), "stackable");
|
||||||
int maxHeight = ResourceConfigUtils.getAsInt(arguments.getOrDefault("max-height", 0), "max-height");
|
int maxHeight = ResourceConfigUtils.getAsInt(arguments.getOrDefault("max-height", 0), "max-height");
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
|||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||||
import net.momirealms.craftengine.core.block.UpdateOption;
|
import net.momirealms.craftengine.core.block.UpdateOption;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.block.properties.BooleanProperty;
|
import net.momirealms.craftengine.core.block.properties.BooleanProperty;
|
||||||
import net.momirealms.craftengine.core.block.properties.Property;
|
import net.momirealms.craftengine.core.block.properties.Property;
|
||||||
@@ -29,7 +28,7 @@ import java.util.Optional;
|
|||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
public class ButtonBlockBehavior extends BukkitBlockBehavior {
|
public class ButtonBlockBehavior extends BukkitBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<ButtonBlockBehavior> FACTORY = new Factory();
|
||||||
private final BooleanProperty poweredProperty;
|
private final BooleanProperty poweredProperty;
|
||||||
private final int ticksToStayPressed;
|
private final int ticksToStayPressed;
|
||||||
private final boolean canButtonBeActivatedByArrows;
|
private final boolean canButtonBeActivatedByArrows;
|
||||||
@@ -197,11 +196,11 @@ public class ButtonBlockBehavior extends BukkitBlockBehavior {
|
|||||||
FastNMS.INSTANCE.method$LevelAccessor$gameEvent(level, player, gameEvent, pos);
|
FastNMS.INSTANCE.method$LevelAccessor$gameEvent(level, player, gameEvent, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<ButtonBlockBehavior> {
|
||||||
|
|
||||||
@SuppressWarnings({"unchecked", "DuplicatedCode"})
|
@SuppressWarnings({"unchecked", "DuplicatedCode"})
|
||||||
@Override
|
@Override
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public ButtonBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
BooleanProperty powered = (BooleanProperty) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("powered"), "warning.config.block.behavior.button.missing_powered");
|
BooleanProperty powered = (BooleanProperty) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("powered"), "warning.config.block.behavior.button.missing_powered");
|
||||||
int ticksToStayPressed = ResourceConfigUtils.getAsInt(arguments.getOrDefault("ticks-to-stay-pressed", 30), "ticks-to-stay-pressed");
|
int ticksToStayPressed = ResourceConfigUtils.getAsInt(arguments.getOrDefault("ticks-to-stay-pressed", 30), "ticks-to-stay-pressed");
|
||||||
boolean canButtonBeActivatedByArrows = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("can-be-activated-by-arrows", true), "can-be-activated-by-arrows");
|
boolean canButtonBeActivatedByArrows = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("can-be-activated-by-arrows", true), "can-be-activated-by-arrows");
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import net.momirealms.craftengine.bukkit.util.BlockStateUtils;
|
|||||||
import net.momirealms.craftengine.core.block.BlockStateWrapper;
|
import net.momirealms.craftengine.core.block.BlockStateWrapper;
|
||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.UpdateOption;
|
import net.momirealms.craftengine.core.block.UpdateOption;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||||
import net.momirealms.craftengine.core.util.LazyReference;
|
import net.momirealms.craftengine.core.util.LazyReference;
|
||||||
@@ -19,7 +18,7 @@ import java.util.Map;
|
|||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
public class ChangeOverTimeBlockBehavior extends BukkitBlockBehavior {
|
public class ChangeOverTimeBlockBehavior extends BukkitBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<ChangeOverTimeBlockBehavior> FACTORY = new Factory();
|
||||||
private final float changeSpeed;
|
private final float changeSpeed;
|
||||||
private final String nextBlock;
|
private final String nextBlock;
|
||||||
private final LazyReference<BlockStateWrapper> lazyState;
|
private final LazyReference<BlockStateWrapper> lazyState;
|
||||||
@@ -64,10 +63,10 @@ public class ChangeOverTimeBlockBehavior extends BukkitBlockBehavior {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<ChangeOverTimeBlockBehavior> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public ChangeOverTimeBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
float changeSpeed = ResourceConfigUtils.getAsFloat(arguments.getOrDefault("change-speed", 0.05688889F), "change-speed");
|
float changeSpeed = ResourceConfigUtils.getAsFloat(arguments.getOrDefault("change-speed", 0.05688889F), "change-speed");
|
||||||
String nextBlock = ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.getOrDefault("next-block", "minecraft:air"), "warning.config.block.behavior.change_over_time.missing_next_block");
|
String nextBlock = ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.getOrDefault("next-block", "minecraft:air"), "warning.config.block.behavior.change_over_time.missing_next_block");
|
||||||
List<String> excludedProperties = MiscUtils.getAsStringList(arguments.get("excluded-properties"));
|
List<String> excludedProperties = MiscUtils.getAsStringList(arguments.get("excluded-properties"));
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import net.momirealms.craftengine.bukkit.nms.FastNMS;
|
|||||||
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.CoreReflections;
|
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.CoreReflections;
|
||||||
import net.momirealms.craftengine.bukkit.util.KeyUtils;
|
import net.momirealms.craftengine.bukkit.util.KeyUtils;
|
||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.sound.SoundData;
|
import net.momirealms.craftengine.core.sound.SoundData;
|
||||||
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
||||||
@@ -14,7 +13,7 @@ import java.util.Optional;
|
|||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
public class ChimeBlockBehavior extends BukkitBlockBehavior {
|
public class ChimeBlockBehavior extends BukkitBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<ChimeBlockBehavior> FACTORY = new Factory();
|
||||||
private final SoundData hitSound;
|
private final SoundData hitSound;
|
||||||
|
|
||||||
public ChimeBlockBehavior(CustomBlock customBlock, SoundData hitSound) {
|
public ChimeBlockBehavior(CustomBlock customBlock, SoundData hitSound) {
|
||||||
@@ -29,10 +28,10 @@ public class ChimeBlockBehavior extends BukkitBlockBehavior {
|
|||||||
FastNMS.INSTANCE.method$LevelAccessor$playSound(args[0], null, blockPos, sound, CoreReflections.instance$SoundSource$BLOCKS, hitSound.volume().get(), hitSound.pitch().get());
|
FastNMS.INSTANCE.method$LevelAccessor$playSound(args[0], null, blockPos, sound, CoreReflections.instance$SoundSource$BLOCKS, hitSound.volume().get(), hitSound.pitch().get());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<ChimeBlockBehavior> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public ChimeBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
SoundData hitSound = SoundData.create(ResourceConfigUtils.requireNonNullOrThrow(
|
SoundData hitSound = SoundData.create(ResourceConfigUtils.requireNonNullOrThrow(
|
||||||
Optional.ofNullable(ResourceConfigUtils.getAsMap(arguments.get("sounds"), "sounds"))
|
Optional.ofNullable(ResourceConfigUtils.getAsMap(arguments.get("sounds"), "sounds"))
|
||||||
.map(sounds -> ResourceConfigUtils.get(sounds, "projectile-hit", "chime"))
|
.map(sounds -> ResourceConfigUtils.get(sounds, "projectile-hit", "chime"))
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
|||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||||
import net.momirealms.craftengine.core.block.UpdateOption;
|
import net.momirealms.craftengine.core.block.UpdateOption;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.block.parser.BlockStateParser;
|
import net.momirealms.craftengine.core.block.parser.BlockStateParser;
|
||||||
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||||
@@ -27,7 +26,7 @@ import java.util.Map;
|
|||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
public class ConcretePowderBlockBehavior extends BukkitBlockBehavior {
|
public class ConcretePowderBlockBehavior extends BukkitBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<ConcretePowderBlockBehavior> FACTORY = new Factory();
|
||||||
private final LazyReference<@Nullable ImmutableBlockState> targetBlock;
|
private final LazyReference<@Nullable ImmutableBlockState> targetBlock;
|
||||||
|
|
||||||
public ConcretePowderBlockBehavior(CustomBlock block, String targetBlock) {
|
public ConcretePowderBlockBehavior(CustomBlock block, String targetBlock) {
|
||||||
@@ -125,10 +124,10 @@ public class ConcretePowderBlockBehavior extends BukkitBlockBehavior {
|
|||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<ConcretePowderBlockBehavior> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public ConcretePowderBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
String solidBlock = ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.get("solid-block"), "warning.config.block.behavior.concrete.missing_solid");
|
String solidBlock = ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.get("solid-block"), "warning.config.block.behavior.concrete.missing_solid");
|
||||||
return new ConcretePowderBlockBehavior(block, solidBlock);
|
return new ConcretePowderBlockBehavior(block, solidBlock);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import net.momirealms.craftengine.bukkit.util.ParticleUtils;
|
|||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||||
import net.momirealms.craftengine.core.block.UpdateOption;
|
import net.momirealms.craftengine.core.block.UpdateOption;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.block.properties.IntegerProperty;
|
import net.momirealms.craftengine.core.block.properties.IntegerProperty;
|
||||||
import net.momirealms.craftengine.core.block.properties.Property;
|
import net.momirealms.craftengine.core.block.properties.Property;
|
||||||
@@ -38,7 +37,7 @@ import java.util.concurrent.Callable;
|
|||||||
|
|
||||||
@SuppressWarnings("DuplicatedCode")
|
@SuppressWarnings("DuplicatedCode")
|
||||||
public class CropBlockBehavior extends BukkitBlockBehavior {
|
public class CropBlockBehavior extends BukkitBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<CropBlockBehavior> FACTORY = new Factory();
|
||||||
private final IntegerProperty ageProperty;
|
private final IntegerProperty ageProperty;
|
||||||
private final float growSpeed;
|
private final float growSpeed;
|
||||||
private final int minGrowLight;
|
private final int minGrowLight;
|
||||||
@@ -188,11 +187,11 @@ public class CropBlockBehavior extends BukkitBlockBehavior {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<CropBlockBehavior> {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public CropBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
Property<Integer> ageProperty = (Property<Integer>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("age"), "warning.config.block.behavior.crop.missing_age");
|
Property<Integer> ageProperty = (Property<Integer>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("age"), "warning.config.block.behavior.crop.missing_age");
|
||||||
int minGrowLight = ResourceConfigUtils.getAsInt(arguments.getOrDefault("light-requirement", 9), "light-requirement");
|
int minGrowLight = ResourceConfigUtils.getAsInt(arguments.getOrDefault("light-requirement", 9), "light-requirement");
|
||||||
float growSpeed = ResourceConfigUtils.getAsFloat(arguments.getOrDefault("grow-speed", 0.125f), "grow-speed");
|
float growSpeed = ResourceConfigUtils.getAsFloat(arguments.getOrDefault("grow-speed", 0.125f), "grow-speed");
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import net.momirealms.craftengine.bukkit.util.DirectionUtils;
|
|||||||
import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.block.properties.Property;
|
import net.momirealms.craftengine.core.block.properties.Property;
|
||||||
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
|
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
|
||||||
@@ -26,7 +25,7 @@ import java.util.*;
|
|||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
public class DirectionalAttachedBlockBehavior extends BukkitBlockBehavior {
|
public class DirectionalAttachedBlockBehavior extends BukkitBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<DirectionalAttachedBlockBehavior> FACTORY = new Factory();
|
||||||
private final Property<?> facingProperty;
|
private final Property<?> facingProperty;
|
||||||
private final boolean isSixDirection;
|
private final boolean isSixDirection;
|
||||||
private final List<Object> tagsCanSurviveOn;
|
private final List<Object> tagsCanSurviveOn;
|
||||||
@@ -132,10 +131,10 @@ public class DirectionalAttachedBlockBehavior extends BukkitBlockBehavior {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<DirectionalAttachedBlockBehavior> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public DirectionalAttachedBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
Property<?> facing = ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("facing"), "warning.config.block.behavior.directional_attached.missing_facing");
|
Property<?> facing = ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("facing"), "warning.config.block.behavior.directional_attached.missing_facing");
|
||||||
boolean isHorizontalDirection = facing.valueClass() == HorizontalDirection.class;
|
boolean isHorizontalDirection = facing.valueClass() == HorizontalDirection.class;
|
||||||
boolean isDirection = facing.valueClass() == Direction.class;
|
boolean isDirection = facing.valueClass() == Direction.class;
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
|||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||||
import net.momirealms.craftengine.core.block.UpdateOption;
|
import net.momirealms.craftengine.core.block.UpdateOption;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.block.behavior.IsPathFindableBlockBehavior;
|
import net.momirealms.craftengine.core.block.behavior.IsPathFindableBlockBehavior;
|
||||||
import net.momirealms.craftengine.core.block.properties.Property;
|
import net.momirealms.craftengine.core.block.properties.Property;
|
||||||
@@ -48,7 +47,7 @@ import java.util.concurrent.Callable;
|
|||||||
|
|
||||||
@SuppressWarnings("DuplicatedCode")
|
@SuppressWarnings("DuplicatedCode")
|
||||||
public class DoorBlockBehavior extends AbstractCanSurviveBlockBehavior implements IsPathFindableBlockBehavior {
|
public class DoorBlockBehavior extends AbstractCanSurviveBlockBehavior implements IsPathFindableBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<DoorBlockBehavior> FACTORY = new Factory();
|
||||||
private final Property<DoubleBlockHalf> halfProperty;
|
private final Property<DoubleBlockHalf> halfProperty;
|
||||||
private final Property<HorizontalDirection> facingProperty;
|
private final Property<HorizontalDirection> facingProperty;
|
||||||
private final Property<DoorHinge> hingeProperty;
|
private final Property<DoorHinge> hingeProperty;
|
||||||
@@ -344,9 +343,9 @@ public class DoorBlockBehavior extends AbstractCanSurviveBlockBehavior implement
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<DoorBlockBehavior> {
|
||||||
@Override
|
@Override
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public DoorBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
Property<DoubleBlockHalf> half = (Property<DoubleBlockHalf>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("half"), "warning.config.block.behavior.door.missing_half");
|
Property<DoubleBlockHalf> half = (Property<DoubleBlockHalf>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("half"), "warning.config.block.behavior.door.missing_half");
|
||||||
Property<HorizontalDirection> facing = (Property<HorizontalDirection>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("facing"), "warning.config.block.behavior.door.missing_facing");
|
Property<HorizontalDirection> facing = (Property<HorizontalDirection>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("facing"), "warning.config.block.behavior.door.missing_facing");
|
||||||
Property<DoorHinge> hinge = (Property<DoorHinge>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("hinge"), "warning.config.block.behavior.door.missing_hinge");
|
Property<DoorHinge> hinge = (Property<DoorHinge>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("hinge"), "warning.config.block.behavior.door.missing_hinge");
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
|||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||||
import net.momirealms.craftengine.core.block.UpdateOption;
|
import net.momirealms.craftengine.core.block.UpdateOption;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.block.properties.Property;
|
import net.momirealms.craftengine.core.block.properties.Property;
|
||||||
import net.momirealms.craftengine.core.block.properties.type.DoubleBlockHalf;
|
import net.momirealms.craftengine.core.block.properties.type.DoubleBlockHalf;
|
||||||
@@ -27,7 +26,7 @@ import java.util.Optional;
|
|||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
public class DoubleHighBlockBehavior extends AbstractCanSurviveBlockBehavior {
|
public class DoubleHighBlockBehavior extends AbstractCanSurviveBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<DoubleHighBlockBehavior> FACTORY = new Factory();
|
||||||
private final Property<DoubleBlockHalf> halfProperty;
|
private final Property<DoubleBlockHalf> halfProperty;
|
||||||
|
|
||||||
public DoubleHighBlockBehavior(CustomBlock customBlock, Property<DoubleBlockHalf> halfProperty) {
|
public DoubleHighBlockBehavior(CustomBlock customBlock, Property<DoubleBlockHalf> halfProperty) {
|
||||||
@@ -71,8 +70,13 @@ public class DoubleHighBlockBehavior extends AbstractCanSurviveBlockBehavior {
|
|||||||
Object state = args[2];
|
Object state = args[2];
|
||||||
Object player = args[3];
|
Object player = args[3];
|
||||||
ImmutableBlockState blockState = BlockStateUtils.getOptionalCustomBlockState(state).orElse(null);
|
ImmutableBlockState blockState = BlockStateUtils.getOptionalCustomBlockState(state).orElse(null);
|
||||||
if (blockState == null || blockState.isEmpty()) return superMethod.call();
|
if (blockState == null || blockState.isEmpty()) {
|
||||||
|
return superMethod.call();
|
||||||
|
}
|
||||||
BukkitServerPlayer cePlayer = BukkitAdaptors.adapt(FastNMS.INSTANCE.method$ServerPlayer$getBukkitEntity(player));
|
BukkitServerPlayer cePlayer = BukkitAdaptors.adapt(FastNMS.INSTANCE.method$ServerPlayer$getBukkitEntity(player));
|
||||||
|
if (cePlayer == null) {
|
||||||
|
return superMethod.call();
|
||||||
|
}
|
||||||
Item<ItemStack> item = cePlayer.getItemInHand(InteractionHand.MAIN_HAND);
|
Item<ItemStack> item = cePlayer.getItemInHand(InteractionHand.MAIN_HAND);
|
||||||
if (cePlayer.canInstabuild() || !BlockStateUtils.isCorrectTool(blockState, item)) {
|
if (cePlayer.canInstabuild() || !BlockStateUtils.isCorrectTool(blockState, item)) {
|
||||||
preventDropFromBottomPart(level, pos, blockState, player);
|
preventDropFromBottomPart(level, pos, blockState, player);
|
||||||
@@ -140,10 +144,10 @@ public class DoubleHighBlockBehavior extends AbstractCanSurviveBlockBehavior {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<DoubleHighBlockBehavior> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public DoubleHighBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
Property<DoubleBlockHalf> half = (Property<DoubleBlockHalf>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("half"), "warning.config.block.behavior.double_high.missing_half");
|
Property<DoubleBlockHalf> half = (Property<DoubleBlockHalf>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("half"), "warning.config.block.behavior.double_high.missing_half");
|
||||||
return new DoubleHighBlockBehavior(block, half);
|
return new DoubleHighBlockBehavior(block, half);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import net.momirealms.craftengine.bukkit.world.BukkitWorldManager;
|
|||||||
import net.momirealms.craftengine.core.block.BlockSettings;
|
import net.momirealms.craftengine.core.block.BlockSettings;
|
||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.item.Item;
|
import net.momirealms.craftengine.core.item.Item;
|
||||||
import net.momirealms.craftengine.core.loot.LootContext;
|
import net.momirealms.craftengine.core.loot.LootContext;
|
||||||
@@ -33,7 +32,7 @@ import java.util.concurrent.Callable;
|
|||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
public class DropExperienceBlockBehavior extends BukkitBlockBehavior {
|
public class DropExperienceBlockBehavior extends BukkitBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<DropExperienceBlockBehavior> FACTORY = new Factory();
|
||||||
private final NumberProvider amount;
|
private final NumberProvider amount;
|
||||||
private final Predicate<Context> condition;
|
private final Predicate<Context> condition;
|
||||||
|
|
||||||
@@ -87,10 +86,10 @@ public class DropExperienceBlockBehavior extends BukkitBlockBehavior {
|
|||||||
world.dropExp(dropPos, finalAmount);
|
world.dropExp(dropPos, finalAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<DropExperienceBlockBehavior> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public DropExperienceBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
NumberProvider amount = NumberProviders.fromObject(ResourceConfigUtils.get(arguments, "amount", "count"));
|
NumberProvider amount = NumberProviders.fromObject(ResourceConfigUtils.get(arguments, "amount", "count"));
|
||||||
List<Condition<Context>> conditionList = ResourceConfigUtils.parseConfigAsList(ResourceConfigUtils.get(arguments, "conditions", "condition"), CommonConditions::fromMap);
|
List<Condition<Context>> conditionList = ResourceConfigUtils.parseConfigAsList(ResourceConfigUtils.get(arguments, "conditions", "condition"), CommonConditions::fromMap);
|
||||||
return new DropExperienceBlockBehavior(block, amount, MiscUtils.allOf(conditionList));
|
return new DropExperienceBlockBehavior(block, amount, MiscUtils.allOf(conditionList));
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import net.momirealms.craftengine.bukkit.util.DirectionUtils;
|
|||||||
import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.block.properties.Property;
|
import net.momirealms.craftengine.core.block.properties.Property;
|
||||||
import net.momirealms.craftengine.core.block.properties.type.AnchorType;
|
import net.momirealms.craftengine.core.block.properties.type.AnchorType;
|
||||||
@@ -26,7 +25,7 @@ import java.util.Set;
|
|||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
public class FaceAttachedHorizontalDirectionalBlockBehavior extends BukkitBlockBehavior {
|
public class FaceAttachedHorizontalDirectionalBlockBehavior extends BukkitBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<FaceAttachedHorizontalDirectionalBlockBehavior> FACTORY = new Factory();
|
||||||
private final Property<AnchorType> anchorTypeProperty;
|
private final Property<AnchorType> anchorTypeProperty;
|
||||||
private final Property<HorizontalDirection> facingProperty;
|
private final Property<HorizontalDirection> facingProperty;
|
||||||
private final List<Object> tagsCanSurviveOn;
|
private final List<Object> tagsCanSurviveOn;
|
||||||
@@ -135,11 +134,11 @@ public class FaceAttachedHorizontalDirectionalBlockBehavior extends BukkitBlockB
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<FaceAttachedHorizontalDirectionalBlockBehavior> {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public FaceAttachedHorizontalDirectionalBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
Property<AnchorType> anchorType = (Property<AnchorType>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("face"), "warning.config.block.behavior.face_attached_horizontal_directional.missing_face");
|
Property<AnchorType> anchorType = (Property<AnchorType>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("face"), "warning.config.block.behavior.face_attached_horizontal_directional.missing_face");
|
||||||
Property<HorizontalDirection> facing = (Property<HorizontalDirection>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("facing"), "warning.config.block.behavior.face_attached_horizontal_directional.missing_facing");
|
Property<HorizontalDirection> facing = (Property<HorizontalDirection>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("facing"), "warning.config.block.behavior.face_attached_horizontal_directional.missing_facing");
|
||||||
Tuple<List<Object>, Set<Object>, Set<String>> tuple = DirectionalAttachedBlockBehavior.readTagsAndState(arguments);
|
Tuple<List<Object>, Set<Object>, Set<String>> tuple = DirectionalAttachedBlockBehavior.readTagsAndState(arguments);
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import net.momirealms.craftengine.bukkit.util.BlockStateUtils;
|
|||||||
import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.sound.SoundData;
|
import net.momirealms.craftengine.core.sound.SoundData;
|
||||||
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
||||||
@@ -22,7 +21,7 @@ import java.util.Optional;
|
|||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
public class FallingBlockBehavior extends BukkitBlockBehavior {
|
public class FallingBlockBehavior extends BukkitBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<FallingBlockBehavior> FACTORY = new Factory();
|
||||||
private final float hurtAmount;
|
private final float hurtAmount;
|
||||||
private final int maxHurt;
|
private final int maxHurt;
|
||||||
private final SoundData landSound;
|
private final SoundData landSound;
|
||||||
@@ -112,11 +111,11 @@ public class FallingBlockBehavior extends BukkitBlockBehavior {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<FallingBlockBehavior> {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public FallingBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
float hurtAmount = ResourceConfigUtils.getAsFloat(arguments.getOrDefault("hurt-amount", -1f), "hurt-amount");
|
float hurtAmount = ResourceConfigUtils.getAsFloat(arguments.getOrDefault("hurt-amount", -1f), "hurt-amount");
|
||||||
int hurtMax = ResourceConfigUtils.getAsInt(arguments.getOrDefault("max-hurt", -1), "max-hurt");
|
int hurtMax = ResourceConfigUtils.getAsInt(arguments.getOrDefault("max-hurt", -1), "max-hurt");
|
||||||
Map<String, Object> sounds = (Map<String, Object>) arguments.get("sounds");
|
Map<String, Object> sounds = (Map<String, Object>) arguments.get("sounds");
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import net.momirealms.craftengine.bukkit.util.*;
|
|||||||
import net.momirealms.craftengine.core.block.BlockStateWrapper;
|
import net.momirealms.craftengine.core.block.BlockStateWrapper;
|
||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.block.behavior.IsPathFindableBlockBehavior;
|
import net.momirealms.craftengine.core.block.behavior.IsPathFindableBlockBehavior;
|
||||||
import net.momirealms.craftengine.core.block.properties.BooleanProperty;
|
import net.momirealms.craftengine.core.block.properties.BooleanProperty;
|
||||||
@@ -32,7 +31,7 @@ import java.util.Optional;
|
|||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
public class FenceBlockBehavior extends BukkitBlockBehavior implements IsPathFindableBlockBehavior {
|
public class FenceBlockBehavior extends BukkitBlockBehavior implements IsPathFindableBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<FenceBlockBehavior> FACTORY = new Factory();
|
||||||
private final BooleanProperty northProperty;
|
private final BooleanProperty northProperty;
|
||||||
private final BooleanProperty eastProperty;
|
private final BooleanProperty eastProperty;
|
||||||
private final BooleanProperty southProperty;
|
private final BooleanProperty southProperty;
|
||||||
@@ -137,10 +136,10 @@ public class FenceBlockBehavior extends BukkitBlockBehavior implements IsPathFin
|
|||||||
return superMethod.call();
|
return superMethod.call();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<FenceBlockBehavior> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public FenceBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
BooleanProperty north = (BooleanProperty) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("north"), "warning.config.block.behavior.fence.missing_north");
|
BooleanProperty north = (BooleanProperty) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("north"), "warning.config.block.behavior.fence.missing_north");
|
||||||
BooleanProperty east = (BooleanProperty) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("east"), "warning.config.block.behavior.fence.missing_east");
|
BooleanProperty east = (BooleanProperty) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("east"), "warning.config.block.behavior.fence.missing_east");
|
||||||
BooleanProperty south = (BooleanProperty) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("south"), "warning.config.block.behavior.fence.missing_south");
|
BooleanProperty south = (BooleanProperty) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("south"), "warning.config.block.behavior.fence.missing_south");
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import net.momirealms.craftengine.core.block.BlockStateWrapper;
|
|||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||||
import net.momirealms.craftengine.core.block.UpdateOption;
|
import net.momirealms.craftengine.core.block.UpdateOption;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.block.behavior.IsPathFindableBlockBehavior;
|
import net.momirealms.craftengine.core.block.behavior.IsPathFindableBlockBehavior;
|
||||||
import net.momirealms.craftengine.core.block.properties.Property;
|
import net.momirealms.craftengine.core.block.properties.Property;
|
||||||
@@ -46,7 +45,7 @@ import java.util.concurrent.Callable;
|
|||||||
|
|
||||||
@SuppressWarnings("DuplicatedCode")
|
@SuppressWarnings("DuplicatedCode")
|
||||||
public class FenceGateBlockBehavior extends BukkitBlockBehavior implements IsPathFindableBlockBehavior {
|
public class FenceGateBlockBehavior extends BukkitBlockBehavior implements IsPathFindableBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<FenceGateBlockBehavior> FACTORY = new Factory();
|
||||||
private final Property<HorizontalDirection> facingProperty;
|
private final Property<HorizontalDirection> facingProperty;
|
||||||
private final Property<Boolean> inWallProperty;
|
private final Property<Boolean> inWallProperty;
|
||||||
private final Property<Boolean> openProperty;
|
private final Property<Boolean> openProperty;
|
||||||
@@ -280,11 +279,11 @@ public class FenceGateBlockBehavior extends BukkitBlockBehavior implements IsPat
|
|||||||
return facing != null && facing.axis() == direction.toDirection().clockWise().axis();
|
return facing != null && facing.axis() == direction.toDirection().clockWise().axis();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<FenceGateBlockBehavior> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public FenceGateBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
Property<HorizontalDirection> facing = (Property<HorizontalDirection>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("facing"), "warning.config.block.behavior.fence_gate.missing_facing");
|
Property<HorizontalDirection> facing = (Property<HorizontalDirection>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("facing"), "warning.config.block.behavior.fence_gate.missing_facing");
|
||||||
Property<Boolean> inWall = (Property<Boolean>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("in_wall"), "warning.config.block.behavior.fence_gate.missing_in_wall");
|
Property<Boolean> inWall = (Property<Boolean>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("in_wall"), "warning.config.block.behavior.fence_gate.missing_in_wall");
|
||||||
Property<Boolean> open = (Property<Boolean>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("open"), "warning.config.block.behavior.fence_gate.missing_open");
|
Property<Boolean> open = (Property<Boolean>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("open"), "warning.config.block.behavior.fence_gate.missing_open");
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import net.momirealms.craftengine.bukkit.util.ParticleUtils;
|
|||||||
import net.momirealms.craftengine.bukkit.world.BukkitExistingBlock;
|
import net.momirealms.craftengine.bukkit.world.BukkitExistingBlock;
|
||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.entity.player.InteractionResult;
|
import net.momirealms.craftengine.core.entity.player.InteractionResult;
|
||||||
import net.momirealms.craftengine.core.entity.player.Player;
|
import net.momirealms.craftengine.core.entity.player.Player;
|
||||||
@@ -29,7 +28,7 @@ import java.util.Optional;
|
|||||||
|
|
||||||
@SuppressWarnings("DuplicatedCode")
|
@SuppressWarnings("DuplicatedCode")
|
||||||
public class GrassBlockBehavior extends BukkitBlockBehavior {
|
public class GrassBlockBehavior extends BukkitBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<GrassBlockBehavior> FACTORY = new Factory();
|
||||||
private final Key feature;
|
private final Key feature;
|
||||||
|
|
||||||
public GrassBlockBehavior(CustomBlock block, Key feature) {
|
public GrassBlockBehavior(CustomBlock block, Key feature) {
|
||||||
@@ -155,9 +154,9 @@ public class GrassBlockBehavior extends BukkitBlockBehavior {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<GrassBlockBehavior> {
|
||||||
@Override
|
@Override
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public GrassBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
String feature = ResourceConfigUtils.requireNonEmptyStringOrThrow(ResourceConfigUtils.get(arguments, "feature", "placed-feature"), "warning.config.block.behavior.grass.missing_feature");
|
String feature = ResourceConfigUtils.requireNonEmptyStringOrThrow(ResourceConfigUtils.get(arguments, "feature", "placed-feature"), "warning.config.block.behavior.grass.missing_feature");
|
||||||
return new GrassBlockBehavior(block, Key.of(feature));
|
return new GrassBlockBehavior(block, Key.of(feature));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import net.momirealms.craftengine.bukkit.util.BlockStateUtils;
|
|||||||
import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.block.behavior.IsPathFindableBlockBehavior;
|
import net.momirealms.craftengine.core.block.behavior.IsPathFindableBlockBehavior;
|
||||||
import net.momirealms.craftengine.core.block.properties.BooleanProperty;
|
import net.momirealms.craftengine.core.block.properties.BooleanProperty;
|
||||||
@@ -20,7 +19,7 @@ import java.util.Map;
|
|||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
public class HangableBlockBehavior extends BukkitBlockBehavior implements IsPathFindableBlockBehavior {
|
public class HangableBlockBehavior extends BukkitBlockBehavior implements IsPathFindableBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<HangableBlockBehavior> FACTORY = new Factory();
|
||||||
private final BooleanProperty hangingProperty;
|
private final BooleanProperty hangingProperty;
|
||||||
|
|
||||||
public HangableBlockBehavior(CustomBlock customBlock, BooleanProperty hangingProperty) {
|
public HangableBlockBehavior(CustomBlock customBlock, BooleanProperty hangingProperty) {
|
||||||
@@ -75,10 +74,10 @@ public class HangableBlockBehavior extends BukkitBlockBehavior implements IsPath
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<HangableBlockBehavior> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public HangableBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
BooleanProperty hanging = (BooleanProperty) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("hanging"), "warning.config.block.behavior.hangable.missing_hanging");
|
BooleanProperty hanging = (BooleanProperty) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("hanging"), "warning.config.block.behavior.hangable.missing_hanging");
|
||||||
return new HangableBlockBehavior(block, hanging);
|
return new HangableBlockBehavior(block, hanging);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package net.momirealms.craftengine.bukkit.block.behavior;
|
|||||||
import net.momirealms.craftengine.bukkit.nms.FastNMS;
|
import net.momirealms.craftengine.bukkit.nms.FastNMS;
|
||||||
import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
||||||
import net.momirealms.craftengine.core.util.Tuple;
|
import net.momirealms.craftengine.core.util.Tuple;
|
||||||
@@ -13,7 +12,7 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class HangingBlockBehavior extends BushBlockBehavior {
|
public class HangingBlockBehavior extends BushBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<HangingBlockBehavior> FACTORY = new Factory();
|
||||||
|
|
||||||
public HangingBlockBehavior(CustomBlock block, int delay, boolean blacklist, boolean stackable, List<Object> tagsCanSurviveOn, Set<Object> blocksCansSurviveOn, Set<String> customBlocksCansSurviveOn) {
|
public HangingBlockBehavior(CustomBlock block, int delay, boolean blacklist, boolean stackable, List<Object> tagsCanSurviveOn, Set<Object> blocksCansSurviveOn, Set<String> customBlocksCansSurviveOn) {
|
||||||
super(block, delay, blacklist, stackable, -1, tagsCanSurviveOn, blocksCansSurviveOn, customBlocksCansSurviveOn);
|
super(block, delay, blacklist, stackable, -1, tagsCanSurviveOn, blocksCansSurviveOn, customBlocksCansSurviveOn);
|
||||||
@@ -26,10 +25,10 @@ public class HangingBlockBehavior extends BushBlockBehavior {
|
|||||||
return mayPlaceOn(belowState, world, belowPos);
|
return mayPlaceOn(belowState, world, belowPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<HangingBlockBehavior> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public HangingBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
Tuple<List<Object>, Set<Object>, Set<String>> tuple = readTagsAndState(arguments, true);
|
Tuple<List<Object>, Set<Object>, Set<String>> tuple = readTagsAndState(arguments, true);
|
||||||
boolean stackable = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("stackable", false), "stackable");
|
boolean stackable = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("stackable", false), "stackable");
|
||||||
int delay = ResourceConfigUtils.getAsInt(arguments.getOrDefault("delay", 0), "delay");
|
int delay = ResourceConfigUtils.getAsInt(arguments.getOrDefault("delay", 0), "delay");
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import net.momirealms.craftengine.bukkit.util.BlockStateUtils;
|
|||||||
import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.block.properties.Property;
|
import net.momirealms.craftengine.core.block.properties.Property;
|
||||||
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
||||||
@@ -17,7 +16,7 @@ import java.util.concurrent.Callable;
|
|||||||
|
|
||||||
@SuppressWarnings("DuplicatedCode")
|
@SuppressWarnings("DuplicatedCode")
|
||||||
public class LampBlockBehavior extends BukkitBlockBehavior {
|
public class LampBlockBehavior extends BukkitBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<LampBlockBehavior> FACTORY = new Factory();
|
||||||
private final Property<Boolean> litProperty;
|
private final Property<Boolean> litProperty;
|
||||||
|
|
||||||
public LampBlockBehavior(CustomBlock block, Property<Boolean> litProperty) {
|
public LampBlockBehavior(CustomBlock block, Property<Boolean> litProperty) {
|
||||||
@@ -70,9 +69,9 @@ public class LampBlockBehavior extends BukkitBlockBehavior {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<LampBlockBehavior> {
|
||||||
@Override
|
@Override
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public LampBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
Property<Boolean> lit = (Property<Boolean>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("lit"), "warning.config.block.behavior.lamp.missing_lit");
|
Property<Boolean> lit = (Property<Boolean>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("lit"), "warning.config.block.behavior.lamp.missing_lit");
|
||||||
return new LampBlockBehavior(block, lit);
|
return new LampBlockBehavior(block, lit);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
|||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||||
import net.momirealms.craftengine.core.block.UpdateOption;
|
import net.momirealms.craftengine.core.block.UpdateOption;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.block.properties.Property;
|
import net.momirealms.craftengine.core.block.properties.Property;
|
||||||
import net.momirealms.craftengine.core.util.Direction;
|
import net.momirealms.craftengine.core.util.Direction;
|
||||||
@@ -24,7 +23,7 @@ import java.util.Optional;
|
|||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
public class LeavesBlockBehavior extends BukkitBlockBehavior {
|
public class LeavesBlockBehavior extends BukkitBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<LeavesBlockBehavior> FACTORY = new Factory();
|
||||||
private static final Object LOG_TAG = BlockTags.getOrCreate(Key.of("minecraft", "logs"));
|
private static final Object LOG_TAG = BlockTags.getOrCreate(Key.of("minecraft", "logs"));
|
||||||
private final int maxDistance;
|
private final int maxDistance;
|
||||||
private final Property<Integer> distanceProperty;
|
private final Property<Integer> distanceProperty;
|
||||||
@@ -160,10 +159,10 @@ public class LeavesBlockBehavior extends BukkitBlockBehavior {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<LeavesBlockBehavior> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public LeavesBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
Property<Boolean> persistent = (Property<Boolean>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("persistent"), "warning.config.block.behavior.leaves.missing_persistent");
|
Property<Boolean> persistent = (Property<Boolean>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("persistent"), "warning.config.block.behavior.leaves.missing_persistent");
|
||||||
Property<Integer> distance = (Property<Integer>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("distance"), "warning.config.block.behavior.leaves.missing_distance");
|
Property<Integer> distance = (Property<Integer>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("distance"), "warning.config.block.behavior.leaves.missing_distance");
|
||||||
int actual = distance.possibleValues().getLast();
|
int actual = distance.possibleValues().getLast();
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import net.momirealms.craftengine.bukkit.nms.FastNMS;
|
|||||||
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.MFluids;
|
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.MFluids;
|
||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.UpdateOption;
|
import net.momirealms.craftengine.core.block.UpdateOption;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.block.behavior.PlaceLiquidBlockBehavior;
|
import net.momirealms.craftengine.core.block.behavior.PlaceLiquidBlockBehavior;
|
||||||
import net.momirealms.craftengine.core.world.WorldEvents;
|
import net.momirealms.craftengine.core.world.WorldEvents;
|
||||||
@@ -13,7 +12,7 @@ import java.util.Map;
|
|||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
public class LiquidFlowableBlockBehavior extends BukkitBlockBehavior implements PlaceLiquidBlockBehavior {
|
public class LiquidFlowableBlockBehavior extends BukkitBlockBehavior implements PlaceLiquidBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<LiquidFlowableBlockBehavior> FACTORY = new Factory();
|
||||||
|
|
||||||
public LiquidFlowableBlockBehavior(CustomBlock customBlock) {
|
public LiquidFlowableBlockBehavior(CustomBlock customBlock) {
|
||||||
super(customBlock);
|
super(customBlock);
|
||||||
@@ -40,10 +39,10 @@ public class LiquidFlowableBlockBehavior extends BukkitBlockBehavior implements
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<LiquidFlowableBlockBehavior> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public LiquidFlowableBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
return new LiquidFlowableBlockBehavior(block);
|
return new LiquidFlowableBlockBehavior(block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import net.momirealms.craftengine.bukkit.world.BukkitWorld;
|
|||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||||
import net.momirealms.craftengine.core.block.UpdateOption;
|
import net.momirealms.craftengine.core.block.UpdateOption;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.block.properties.IntegerProperty;
|
import net.momirealms.craftengine.core.block.properties.IntegerProperty;
|
||||||
import net.momirealms.craftengine.core.entity.player.InteractionHand;
|
import net.momirealms.craftengine.core.entity.player.InteractionHand;
|
||||||
@@ -28,7 +27,7 @@ import java.util.Optional;
|
|||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
public class MultiHighBlockBehavior extends BukkitBlockBehavior {
|
public class MultiHighBlockBehavior extends BukkitBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<MultiHighBlockBehavior> FACTORY = new Factory();
|
||||||
public final IntegerProperty highProperty;
|
public final IntegerProperty highProperty;
|
||||||
|
|
||||||
public MultiHighBlockBehavior(CustomBlock customBlock, IntegerProperty highProperty) {
|
public MultiHighBlockBehavior(CustomBlock customBlock, IntegerProperty highProperty) {
|
||||||
@@ -240,10 +239,10 @@ public class MultiHighBlockBehavior extends BukkitBlockBehavior {
|
|||||||
return state.with(property, property.min);
|
return state.with(property, property.min);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<MultiHighBlockBehavior> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public MultiHighBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
IntegerProperty high = (IntegerProperty) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("high"), "warning.config.block.behavior.multi_high.missing_high");
|
IntegerProperty high = (IntegerProperty) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("high"), "warning.config.block.behavior.multi_high.missing_high");
|
||||||
return new MultiHighBlockBehavior(block, high);
|
return new MultiHighBlockBehavior(block, high);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import net.momirealms.craftengine.bukkit.util.BlockStateUtils;
|
|||||||
import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.util.MiscUtils;
|
import net.momirealms.craftengine.core.util.MiscUtils;
|
||||||
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
||||||
@@ -20,7 +19,7 @@ import java.util.Optional;
|
|||||||
public class NearLiquidBlockBehavior extends AbstractCanSurviveBlockBehavior {
|
public class NearLiquidBlockBehavior extends AbstractCanSurviveBlockBehavior {
|
||||||
private static final List<Object> WATER = List.of(MFluids.WATER, MFluids.FLOWING_WATER);
|
private static final List<Object> WATER = List.of(MFluids.WATER, MFluids.FLOWING_WATER);
|
||||||
private static final List<Object> LAVA = List.of(MFluids.LAVA, MFluids.FLOWING_LAVA);
|
private static final List<Object> LAVA = List.of(MFluids.LAVA, MFluids.FLOWING_LAVA);
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<NearLiquidBlockBehavior> FACTORY = new Factory();
|
||||||
private final boolean onWater;
|
private final boolean onWater;
|
||||||
private final boolean onLava;
|
private final boolean onLava;
|
||||||
private final boolean stackable;
|
private final boolean stackable;
|
||||||
@@ -42,10 +41,10 @@ public class NearLiquidBlockBehavior extends AbstractCanSurviveBlockBehavior {
|
|||||||
return this.onLava;
|
return this.onLava;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<NearLiquidBlockBehavior> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public NearLiquidBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
List<String> liquidTypes = MiscUtils.getAsStringList(arguments.getOrDefault("liquid-type", List.of("water")));
|
List<String> liquidTypes = MiscUtils.getAsStringList(arguments.getOrDefault("liquid-type", List.of("water")));
|
||||||
boolean stackable = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("stackable", false), "stackable");
|
boolean stackable = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("stackable", false), "stackable");
|
||||||
int delay = ResourceConfigUtils.getAsInt(arguments.getOrDefault("delay", 0), "delay");
|
int delay = ResourceConfigUtils.getAsInt(arguments.getOrDefault("delay", 0), "delay");
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import net.momirealms.craftengine.bukkit.util.BlockStateUtils;
|
|||||||
import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.util.MiscUtils;
|
import net.momirealms.craftengine.core.util.MiscUtils;
|
||||||
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
||||||
@@ -17,7 +16,7 @@ import java.util.Map;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public class OnLiquidBlockBehavior extends AbstractCanSurviveBlockBehavior {
|
public class OnLiquidBlockBehavior extends AbstractCanSurviveBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<OnLiquidBlockBehavior> FACTORY = new Factory();
|
||||||
private final boolean onWater;
|
private final boolean onWater;
|
||||||
private final boolean onLava;
|
private final boolean onLava;
|
||||||
private final boolean stackable;
|
private final boolean stackable;
|
||||||
@@ -37,9 +36,9 @@ public class OnLiquidBlockBehavior extends AbstractCanSurviveBlockBehavior {
|
|||||||
return this.onLava;
|
return this.onLava;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<OnLiquidBlockBehavior> {
|
||||||
@Override
|
@Override
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public OnLiquidBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
List<String> liquidTypes = MiscUtils.getAsStringList(arguments.getOrDefault("liquid-type", List.of("water")));
|
List<String> liquidTypes = MiscUtils.getAsStringList(arguments.getOrDefault("liquid-type", List.of("water")));
|
||||||
boolean stackable = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("stackable", false), "stackable");
|
boolean stackable = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("stackable", false), "stackable");
|
||||||
int delay = ResourceConfigUtils.getAsInt(arguments.getOrDefault("delay", 0), "delay");
|
int delay = ResourceConfigUtils.getAsInt(arguments.getOrDefault("delay", 0), "delay");
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
|||||||
import net.momirealms.craftengine.bukkit.world.BukkitWorldManager;
|
import net.momirealms.craftengine.bukkit.world.BukkitWorldManager;
|
||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.block.properties.Property;
|
import net.momirealms.craftengine.core.block.properties.Property;
|
||||||
import net.momirealms.craftengine.core.sound.SoundData;
|
import net.momirealms.craftengine.core.sound.SoundData;
|
||||||
@@ -31,7 +30,7 @@ import java.util.Optional;
|
|||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
public class PressurePlateBlockBehavior extends BukkitBlockBehavior {
|
public class PressurePlateBlockBehavior extends BukkitBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<PressurePlateBlockBehavior> FACTORY = new Factory();
|
||||||
private final Property<Boolean> poweredProperty;
|
private final Property<Boolean> poweredProperty;
|
||||||
private final SoundData onSound;
|
private final SoundData onSound;
|
||||||
private final SoundData offSound;
|
private final SoundData offSound;
|
||||||
@@ -220,11 +219,11 @@ public class PressurePlateBlockBehavior extends BukkitBlockBehavior {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<PressurePlateBlockBehavior> {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public PressurePlateBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
Property<Boolean> powered = (Property<Boolean>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("powered"), "warning.config.block.behavior.pressure_plate.missing_powered");
|
Property<Boolean> powered = (Property<Boolean>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("powered"), "warning.config.block.behavior.pressure_plate.missing_powered");
|
||||||
PressurePlateSensitivity pressurePlateSensitivity = PressurePlateSensitivity.byName(arguments.getOrDefault("sensitivity", "everything").toString());
|
PressurePlateSensitivity pressurePlateSensitivity = PressurePlateSensitivity.byName(arguments.getOrDefault("sensitivity", "everything").toString());
|
||||||
int pressedTime = ResourceConfigUtils.getAsInt(arguments.getOrDefault("pressed-time", 20), "pressed-time");
|
int pressedTime = ResourceConfigUtils.getAsInt(arguments.getOrDefault("pressed-time", 20), "pressed-time");
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import net.momirealms.craftengine.bukkit.util.ParticleUtils;
|
|||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||||
import net.momirealms.craftengine.core.block.UpdateOption;
|
import net.momirealms.craftengine.core.block.UpdateOption;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.block.properties.IntegerProperty;
|
import net.momirealms.craftengine.core.block.properties.IntegerProperty;
|
||||||
import net.momirealms.craftengine.core.block.properties.Property;
|
import net.momirealms.craftengine.core.block.properties.Property;
|
||||||
@@ -34,7 +33,7 @@ import java.util.concurrent.Callable;
|
|||||||
|
|
||||||
@SuppressWarnings("DuplicatedCode")
|
@SuppressWarnings("DuplicatedCode")
|
||||||
public class SaplingBlockBehavior extends BukkitBlockBehavior {
|
public class SaplingBlockBehavior extends BukkitBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<SaplingBlockBehavior> FACTORY = new Factory();
|
||||||
private final Key feature;
|
private final Key feature;
|
||||||
private final IntegerProperty stageProperty;
|
private final IntegerProperty stageProperty;
|
||||||
private final double boneMealSuccessChance;
|
private final double boneMealSuccessChance;
|
||||||
@@ -169,11 +168,11 @@ public class SaplingBlockBehavior extends BukkitBlockBehavior {
|
|||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<SaplingBlockBehavior> {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public SaplingBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
String feature = ResourceConfigUtils.requireNonEmptyStringOrThrow(ResourceConfigUtils.get(arguments, "feature", "configured-feature"), "warning.config.block.behavior.sapling.missing_feature");
|
String feature = ResourceConfigUtils.requireNonEmptyStringOrThrow(ResourceConfigUtils.get(arguments, "feature", "configured-feature"), "warning.config.block.behavior.sapling.missing_feature");
|
||||||
Property<Integer> stageProperty = (Property<Integer>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("stage"), "warning.config.block.behavior.sapling.missing_stage");
|
Property<Integer> stageProperty = (Property<Integer>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("stage"), "warning.config.block.behavior.sapling.missing_stage");
|
||||||
double boneMealSuccessChance = ResourceConfigUtils.getAsDouble(arguments.getOrDefault("bone-meal-success-chance", 0.45), "bone-meal-success-chance");
|
double boneMealSuccessChance = ResourceConfigUtils.getAsDouble(arguments.getOrDefault("bone-meal-success-chance", 0.45), "bone-meal-success-chance");
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import net.momirealms.craftengine.bukkit.block.entity.SeatBlockEntity;
|
|||||||
import net.momirealms.craftengine.bukkit.plugin.user.BukkitServerPlayer;
|
import net.momirealms.craftengine.bukkit.plugin.user.BukkitServerPlayer;
|
||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.block.behavior.EntityBlockBehavior;
|
import net.momirealms.craftengine.core.block.behavior.EntityBlockBehavior;
|
||||||
import net.momirealms.craftengine.core.block.entity.BlockEntity;
|
import net.momirealms.craftengine.core.block.entity.BlockEntity;
|
||||||
@@ -21,7 +20,7 @@ import net.momirealms.craftengine.core.world.context.UseOnContext;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class SeatBlockBehavior extends BukkitBlockBehavior implements EntityBlockBehavior {
|
public class SeatBlockBehavior extends BukkitBlockBehavior implements EntityBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<SeatBlockBehavior> FACTORY = new Factory();
|
||||||
private final Property<HorizontalDirection> directionProperty;
|
private final Property<HorizontalDirection> directionProperty;
|
||||||
private final SeatConfig[] seats;
|
private final SeatConfig[] seats;
|
||||||
|
|
||||||
@@ -64,11 +63,11 @@ public class SeatBlockBehavior extends BukkitBlockBehavior implements EntityBloc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<SeatBlockBehavior> {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public SeatBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
Property<HorizontalDirection> directionProperty = null;
|
Property<HorizontalDirection> directionProperty = null;
|
||||||
Property<?> facing = block.getProperty("facing");
|
Property<?> facing = block.getProperty("facing");
|
||||||
if (facing != null && facing.valueClass() == HorizontalDirection.class) {
|
if (facing != null && facing.valueClass() == HorizontalDirection.class) {
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import net.momirealms.craftengine.bukkit.block.entity.BukkitBlockEntityTypes;
|
|||||||
import net.momirealms.craftengine.bukkit.block.entity.SimpleParticleBlockEntity;
|
import net.momirealms.craftengine.bukkit.block.entity.SimpleParticleBlockEntity;
|
||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.block.behavior.EntityBlockBehavior;
|
import net.momirealms.craftengine.core.block.behavior.EntityBlockBehavior;
|
||||||
import net.momirealms.craftengine.core.block.entity.BlockEntity;
|
import net.momirealms.craftengine.core.block.entity.BlockEntity;
|
||||||
@@ -19,7 +18,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class SimpleParticleBlockBehavior extends BukkitBlockBehavior implements EntityBlockBehavior {
|
public class SimpleParticleBlockBehavior extends BukkitBlockBehavior implements EntityBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<SimpleParticleBlockBehavior> FACTORY = new Factory();
|
||||||
public final ParticleConfig[] particles;
|
public final ParticleConfig[] particles;
|
||||||
public final int tickInterval;
|
public final int tickInterval;
|
||||||
|
|
||||||
@@ -53,10 +52,10 @@ public class SimpleParticleBlockBehavior extends BukkitBlockBehavior implements
|
|||||||
return EntityBlockBehavior.createTickerHelper(SimpleParticleBlockEntity::tick);
|
return EntityBlockBehavior.createTickerHelper(SimpleParticleBlockEntity::tick);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<SimpleParticleBlockBehavior> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public SimpleParticleBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
List<ParticleConfig> particles = ResourceConfigUtils.parseConfigAsList(ResourceConfigUtils.get(arguments, "particles", "particle"), ParticleConfig::fromMap$blockEntity);
|
List<ParticleConfig> particles = ResourceConfigUtils.parseConfigAsList(ResourceConfigUtils.get(arguments, "particles", "particle"), ParticleConfig::fromMap$blockEntity);
|
||||||
int tickInterval = ResourceConfigUtils.getAsInt(arguments.getOrDefault("tick-interval", 10), "tick-interval");
|
int tickInterval = ResourceConfigUtils.getAsInt(arguments.getOrDefault("tick-interval", 10), "tick-interval");
|
||||||
return new SimpleParticleBlockBehavior(block, particles.toArray(new ParticleConfig[0]), tickInterval);
|
return new SimpleParticleBlockBehavior(block, particles.toArray(new ParticleConfig[0]), tickInterval);
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
|||||||
import net.momirealms.craftengine.bukkit.world.BukkitWorldManager;
|
import net.momirealms.craftengine.bukkit.world.BukkitWorldManager;
|
||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.block.behavior.EntityBlockBehavior;
|
import net.momirealms.craftengine.core.block.behavior.EntityBlockBehavior;
|
||||||
import net.momirealms.craftengine.core.block.entity.BlockEntity;
|
import net.momirealms.craftengine.core.block.entity.BlockEntity;
|
||||||
@@ -38,7 +37,7 @@ import java.util.Optional;
|
|||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
public class SimpleStorageBlockBehavior extends BukkitBlockBehavior implements EntityBlockBehavior {
|
public class SimpleStorageBlockBehavior extends BukkitBlockBehavior implements EntityBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<SimpleStorageBlockBehavior> FACTORY = new Factory();
|
||||||
private final String containerTitle;
|
private final String containerTitle;
|
||||||
private final int rows;
|
private final int rows;
|
||||||
private final SoundData openSound;
|
private final SoundData openSound;
|
||||||
@@ -198,11 +197,11 @@ public class SimpleStorageBlockBehavior extends BukkitBlockBehavior implements E
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<SimpleStorageBlockBehavior> {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public SimpleStorageBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
String title = arguments.getOrDefault("title", "").toString();
|
String title = arguments.getOrDefault("title", "").toString();
|
||||||
int rows = MiscUtils.clamp(ResourceConfigUtils.getAsInt(arguments.getOrDefault("rows", 1), "rows"), 1, 6);
|
int rows = MiscUtils.clamp(ResourceConfigUtils.getAsInt(arguments.getOrDefault("rows", 1), "rows"), 1, 6);
|
||||||
Map<String, Object> sounds = (Map<String, Object>) arguments.get("sounds");
|
Map<String, Object> sounds = (Map<String, Object>) arguments.get("sounds");
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import java.util.Optional;
|
|||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
public class SlabBlockBehavior extends BukkitBlockBehavior implements IsPathFindableBlockBehavior, CanBeReplacedBlockBehavior {
|
public class SlabBlockBehavior extends BukkitBlockBehavior implements IsPathFindableBlockBehavior, CanBeReplacedBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<SlabBlockBehavior> FACTORY = new Factory();
|
||||||
private final Property<SlabType> typeProperty;
|
private final Property<SlabType> typeProperty;
|
||||||
|
|
||||||
public SlabBlockBehavior(CustomBlock block, Property<SlabType> typeProperty) {
|
public SlabBlockBehavior(CustomBlock block, Property<SlabType> typeProperty) {
|
||||||
@@ -114,11 +114,11 @@ public class SlabBlockBehavior extends BukkitBlockBehavior implements IsPathFind
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<SlabBlockBehavior> {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public SlabBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
Property<SlabType> type = (Property<SlabType>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("type"), "warning.config.block.behavior.slab.missing_type");
|
Property<SlabType> type = (Property<SlabType>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("type"), "warning.config.block.behavior.slab.missing_type");
|
||||||
return new SlabBlockBehavior(block, type);
|
return new SlabBlockBehavior(block, type);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import net.momirealms.craftengine.bukkit.util.BlockStateUtils;
|
|||||||
import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.block.properties.BooleanProperty;
|
import net.momirealms.craftengine.core.block.properties.BooleanProperty;
|
||||||
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
||||||
@@ -17,7 +16,7 @@ import java.util.Map;
|
|||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
public class SnowyBlockBehavior extends BukkitBlockBehavior {
|
public class SnowyBlockBehavior extends BukkitBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<SnowyBlockBehavior> FACTORY = new Factory();
|
||||||
private final BooleanProperty snowyProperty;
|
private final BooleanProperty snowyProperty;
|
||||||
|
|
||||||
public SnowyBlockBehavior(CustomBlock customBlock, BooleanProperty snowyProperty) {
|
public SnowyBlockBehavior(CustomBlock customBlock, BooleanProperty snowyProperty) {
|
||||||
@@ -44,10 +43,10 @@ public class SnowyBlockBehavior extends BukkitBlockBehavior {
|
|||||||
return FastNMS.INSTANCE.method$BlockStateBase$is(state, MTagKeys.Block$SNOW);
|
return FastNMS.INSTANCE.method$BlockStateBase$is(state, MTagKeys.Block$SNOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<SnowyBlockBehavior> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public SnowyBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
BooleanProperty snowyProperty = (BooleanProperty) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("snowy"), "warning.config.block.behavior.snowy.missing_snowy");
|
BooleanProperty snowyProperty = (BooleanProperty) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("snowy"), "warning.config.block.behavior.snowy.missing_snowy");
|
||||||
return new SnowyBlockBehavior(block, snowyProperty);
|
return new SnowyBlockBehavior(block, snowyProperty);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import net.momirealms.craftengine.bukkit.util.DirectionUtils;
|
|||||||
import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.block.properties.Property;
|
import net.momirealms.craftengine.core.block.properties.Property;
|
||||||
import net.momirealms.craftengine.core.block.properties.type.SofaShape;
|
import net.momirealms.craftengine.core.block.properties.type.SofaShape;
|
||||||
@@ -23,7 +22,7 @@ import java.util.Optional;
|
|||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
public class SofaBlockBehavior extends BukkitBlockBehavior {
|
public class SofaBlockBehavior extends BukkitBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<SofaBlockBehavior> FACTORY = new Factory();
|
||||||
private final Property<HorizontalDirection> facingProperty;
|
private final Property<HorizontalDirection> facingProperty;
|
||||||
private final Property<SofaShape> shapeProperty;
|
private final Property<SofaShape> shapeProperty;
|
||||||
|
|
||||||
@@ -99,11 +98,11 @@ public class SofaBlockBehavior extends BukkitBlockBehavior {
|
|||||||
return anotherState.get(anotherBehavior.facingProperty) != state.get(this.facingProperty);
|
return anotherState.get(anotherBehavior.facingProperty) != state.get(this.facingProperty);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<SofaBlockBehavior> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public SofaBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
Property<HorizontalDirection> facing = (Property<HorizontalDirection>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("facing"), "warning.config.block.behavior.sofa.missing_facing");
|
Property<HorizontalDirection> facing = (Property<HorizontalDirection>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("facing"), "warning.config.block.behavior.sofa.missing_facing");
|
||||||
Property<SofaShape> shape = (Property<SofaShape>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("shape"), "warning.config.block.behavior.sofa.missing_shape");
|
Property<SofaShape> shape = (Property<SofaShape>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("shape"), "warning.config.block.behavior.sofa.missing_shape");
|
||||||
return new SofaBlockBehavior(block, facing, shape);
|
return new SofaBlockBehavior(block, facing, shape);
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import net.momirealms.craftengine.bukkit.block.BukkitBlockManager;
|
|||||||
import net.momirealms.craftengine.bukkit.nms.FastNMS;
|
import net.momirealms.craftengine.bukkit.nms.FastNMS;
|
||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.UpdateOption;
|
import net.momirealms.craftengine.core.block.UpdateOption;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.util.LazyReference;
|
import net.momirealms.craftengine.core.util.LazyReference;
|
||||||
import net.momirealms.craftengine.core.util.RandomUtils;
|
import net.momirealms.craftengine.core.util.RandomUtils;
|
||||||
@@ -15,7 +14,7 @@ import java.util.Objects;
|
|||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
public class SpreadingBlockBehavior extends BukkitBlockBehavior {
|
public class SpreadingBlockBehavior extends BukkitBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<SpreadingBlockBehavior> FACTORY = new Factory();
|
||||||
private final LazyReference<Object> targetBlock;
|
private final LazyReference<Object> targetBlock;
|
||||||
|
|
||||||
public SpreadingBlockBehavior(CustomBlock customBlock, String targetBlock) {
|
public SpreadingBlockBehavior(CustomBlock customBlock, String targetBlock) {
|
||||||
@@ -33,10 +32,10 @@ public class SpreadingBlockBehavior extends BukkitBlockBehavior {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<SpreadingBlockBehavior> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public SpreadingBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
String targetBlock = ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.get("target-block"), "warning.config.block.behavior.spreading.missing_target_block");
|
String targetBlock = ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.get("target-block"), "warning.config.block.behavior.spreading.missing_target_block");
|
||||||
return new SpreadingBlockBehavior(block, targetBlock);
|
return new SpreadingBlockBehavior(block, targetBlock);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import net.momirealms.craftengine.bukkit.util.BlockStateUtils;
|
|||||||
import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.block.behavior.CanBeReplacedBlockBehavior;
|
import net.momirealms.craftengine.core.block.behavior.CanBeReplacedBlockBehavior;
|
||||||
import net.momirealms.craftengine.core.block.properties.IntegerProperty;
|
import net.momirealms.craftengine.core.block.properties.IntegerProperty;
|
||||||
@@ -22,7 +21,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class StackableBlockBehavior extends BukkitBlockBehavior implements CanBeReplacedBlockBehavior {
|
public class StackableBlockBehavior extends BukkitBlockBehavior implements CanBeReplacedBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<StackableBlockBehavior> FACTORY = new Factory();
|
||||||
private final IntegerProperty amountProperty;
|
private final IntegerProperty amountProperty;
|
||||||
private final List<Key> items;
|
private final List<Key> items;
|
||||||
private final String propertyName;
|
private final String propertyName;
|
||||||
@@ -71,10 +70,10 @@ public class StackableBlockBehavior extends BukkitBlockBehavior implements CanBe
|
|||||||
return blockState.cycle(property);
|
return blockState.cycle(property);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<StackableBlockBehavior> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public StackableBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
String propertyName = String.valueOf(arguments.getOrDefault("property", "amount"));
|
String propertyName = String.valueOf(arguments.getOrDefault("property", "amount"));
|
||||||
IntegerProperty amount = (IntegerProperty) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty(propertyName), () -> {
|
IntegerProperty amount = (IntegerProperty) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty(propertyName), () -> {
|
||||||
throw new LocalizedResourceConfigException("warning.config.block.behavior.stackable.missing_property", propertyName);
|
throw new LocalizedResourceConfigException("warning.config.block.behavior.stackable.missing_property", propertyName);
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import net.momirealms.craftengine.bukkit.util.DirectionUtils;
|
|||||||
import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.block.properties.Property;
|
import net.momirealms.craftengine.core.block.properties.Property;
|
||||||
import net.momirealms.craftengine.core.block.properties.type.SingleBlockHalf;
|
import net.momirealms.craftengine.core.block.properties.type.SingleBlockHalf;
|
||||||
@@ -25,7 +24,7 @@ import java.util.concurrent.Callable;
|
|||||||
|
|
||||||
@SuppressWarnings("DuplicatedCode")
|
@SuppressWarnings("DuplicatedCode")
|
||||||
public class StairsBlockBehavior extends BukkitBlockBehavior {
|
public class StairsBlockBehavior extends BukkitBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<StairsBlockBehavior> FACTORY = new Factory();
|
||||||
private final Property<HorizontalDirection> facingProperty;
|
private final Property<HorizontalDirection> facingProperty;
|
||||||
private final Property<SingleBlockHalf> halfProperty;
|
private final Property<SingleBlockHalf> halfProperty;
|
||||||
private final Property<StairsShape> shapeProperty;
|
private final Property<StairsShape> shapeProperty;
|
||||||
@@ -125,11 +124,11 @@ public class StairsBlockBehavior extends BukkitBlockBehavior {
|
|||||||
return anotherState.get(anotherBehavior.facingProperty) != state.get(this.facingProperty) || anotherState.get(anotherBehavior.halfProperty) != state.get(this.halfProperty);
|
return anotherState.get(anotherBehavior.facingProperty) != state.get(this.facingProperty) || anotherState.get(anotherBehavior.halfProperty) != state.get(this.halfProperty);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<StairsBlockBehavior> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public StairsBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
Property<HorizontalDirection> facing = (Property<HorizontalDirection>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("facing"), "warning.config.block.behavior.stairs.missing_facing");
|
Property<HorizontalDirection> facing = (Property<HorizontalDirection>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("facing"), "warning.config.block.behavior.stairs.missing_facing");
|
||||||
Property<SingleBlockHalf> half = (Property<SingleBlockHalf>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("half"), "warning.config.block.behavior.stairs.missing_half");
|
Property<SingleBlockHalf> half = (Property<SingleBlockHalf>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("half"), "warning.config.block.behavior.stairs.missing_half");
|
||||||
Property<StairsShape> shape = (Property<StairsShape>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("shape"), "warning.config.block.behavior.stairs.missing_shape");
|
Property<StairsShape> shape = (Property<StairsShape>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("shape"), "warning.config.block.behavior.stairs.missing_shape");
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import net.momirealms.craftengine.bukkit.util.KeyUtils;
|
|||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||||
import net.momirealms.craftengine.core.block.UpdateOption;
|
import net.momirealms.craftengine.core.block.UpdateOption;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.block.behavior.IsPathFindableBlockBehavior;
|
import net.momirealms.craftengine.core.block.behavior.IsPathFindableBlockBehavior;
|
||||||
import net.momirealms.craftengine.core.block.properties.IntegerProperty;
|
import net.momirealms.craftengine.core.block.properties.IntegerProperty;
|
||||||
@@ -23,7 +22,7 @@ import java.util.Optional;
|
|||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
public class StemBlockBehavior extends BukkitBlockBehavior implements IsPathFindableBlockBehavior {
|
public class StemBlockBehavior extends BukkitBlockBehavior implements IsPathFindableBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<StemBlockBehavior> FACTORY = new Factory();
|
||||||
private final IntegerProperty ageProperty;
|
private final IntegerProperty ageProperty;
|
||||||
private final Key fruit;
|
private final Key fruit;
|
||||||
private final Key attachedStem;
|
private final Key attachedStem;
|
||||||
@@ -124,10 +123,10 @@ public class StemBlockBehavior extends BukkitBlockBehavior implements IsPathFind
|
|||||||
return flag1 || flag2;
|
return flag1 || flag2;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<StemBlockBehavior> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public StemBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
IntegerProperty ageProperty = (IntegerProperty) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("age"), "warning.config.block.behavior.stem.missing_age");
|
IntegerProperty ageProperty = (IntegerProperty) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("age"), "warning.config.block.behavior.stem.missing_age");
|
||||||
Key fruit = Key.of(ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.get("fruit"), "warning.config.block.behavior.stem.missing_fruit"));
|
Key fruit = Key.of(ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.get("fruit"), "warning.config.block.behavior.stem.missing_fruit"));
|
||||||
Key attachedStem = Key.of(ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.get("attached-stem"), "warning.config.block.behavior.stem.missing_attached_stem"));
|
Key attachedStem = Key.of(ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.get("attached-stem"), "warning.config.block.behavior.stem.missing_attached_stem"));
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package net.momirealms.craftengine.bukkit.block.behavior;
|
|||||||
|
|
||||||
import net.momirealms.craftengine.core.block.BlockStateWrapper;
|
import net.momirealms.craftengine.core.block.BlockStateWrapper;
|
||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||||
import net.momirealms.craftengine.core.util.LazyReference;
|
import net.momirealms.craftengine.core.util.LazyReference;
|
||||||
@@ -14,7 +13,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class StrippableBlockBehavior extends BukkitBlockBehavior {
|
public class StrippableBlockBehavior extends BukkitBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<StrippableBlockBehavior> FACTORY = new Factory();
|
||||||
private final String stripped;
|
private final String stripped;
|
||||||
private final LazyReference<BlockStateWrapper> lazyState;
|
private final LazyReference<BlockStateWrapper> lazyState;
|
||||||
private final List<String> excludedProperties;
|
private final List<String> excludedProperties;
|
||||||
@@ -41,10 +40,10 @@ public class StrippableBlockBehavior extends BukkitBlockBehavior {
|
|||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<StrippableBlockBehavior> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public StrippableBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
String stripped = ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.get("stripped"), "warning.config.block.behavior.strippable.missing_stripped");
|
String stripped = ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.get("stripped"), "warning.config.block.behavior.strippable.missing_stripped");
|
||||||
List<String> excludedProperties = MiscUtils.getAsStringList(arguments.get("excluded-properties"));
|
List<String> excludedProperties = MiscUtils.getAsStringList(arguments.get("excluded-properties"));
|
||||||
return new StrippableBlockBehavior(block, stripped, excludedProperties);
|
return new StrippableBlockBehavior(block, stripped, excludedProperties);
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import net.momirealms.craftengine.bukkit.util.BlockStateUtils;
|
|||||||
import net.momirealms.craftengine.bukkit.util.DirectionUtils;
|
import net.momirealms.craftengine.bukkit.util.DirectionUtils;
|
||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.util.Direction;
|
import net.momirealms.craftengine.core.util.Direction;
|
||||||
import net.momirealms.craftengine.core.util.MiscUtils;
|
import net.momirealms.craftengine.core.util.MiscUtils;
|
||||||
@@ -18,7 +17,7 @@ import java.util.Map;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public class SturdyBaseBlockBehavior extends AbstractCanSurviveBlockBehavior {
|
public class SturdyBaseBlockBehavior extends AbstractCanSurviveBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<SturdyBaseBlockBehavior> FACTORY = new Factory();
|
||||||
private final Direction direction;
|
private final Direction direction;
|
||||||
private final boolean stackable;
|
private final boolean stackable;
|
||||||
private final boolean checkFull;
|
private final boolean checkFull;
|
||||||
@@ -60,10 +59,10 @@ public class SturdyBaseBlockBehavior extends AbstractCanSurviveBlockBehavior {
|
|||||||
return optionalCustomState.filter(immutableBlockState -> immutableBlockState.owner().value() == super.customBlock).isPresent();
|
return optionalCustomState.filter(immutableBlockState -> immutableBlockState.owner().value() == super.customBlock).isPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<SturdyBaseBlockBehavior> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public SturdyBaseBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
int delay = ResourceConfigUtils.getAsInt(arguments.getOrDefault("delay", 0), "delay");
|
int delay = ResourceConfigUtils.getAsInt(arguments.getOrDefault("delay", 0), "delay");
|
||||||
Direction direction = Direction.valueOf(arguments.getOrDefault("direction", "down").toString().toUpperCase(Locale.ENGLISH));
|
Direction direction = Direction.valueOf(arguments.getOrDefault("direction", "down").toString().toUpperCase(Locale.ENGLISH));
|
||||||
boolean stackable = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("stackable", false), "stackable");
|
boolean stackable = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("stackable", false), "stackable");
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.MTagKeys;
|
|||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||||
import net.momirealms.craftengine.core.block.UpdateOption;
|
import net.momirealms.craftengine.core.block.UpdateOption;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.block.properties.Property;
|
import net.momirealms.craftengine.core.block.properties.Property;
|
||||||
import net.momirealms.craftengine.core.util.LazyReference;
|
import net.momirealms.craftengine.core.util.LazyReference;
|
||||||
@@ -22,7 +21,7 @@ import java.util.Objects;
|
|||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
public class SurfaceSpreadingBlockBehavior extends BukkitBlockBehavior {
|
public class SurfaceSpreadingBlockBehavior extends BukkitBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<SurfaceSpreadingBlockBehavior> FACTORY = new Factory();
|
||||||
private final int requiredLight;
|
private final int requiredLight;
|
||||||
private final LazyReference<Object> baseBlock;
|
private final LazyReference<Object> baseBlock;
|
||||||
private final Property<Boolean> snowyProperty;
|
private final Property<Boolean> snowyProperty;
|
||||||
@@ -101,11 +100,11 @@ public class SurfaceSpreadingBlockBehavior extends BukkitBlockBehavior {
|
|||||||
return canBeGrass(state, level, pos) && !FastNMS.INSTANCE.method$FluidState$is(FastNMS.INSTANCE.method$BlockGetter$getFluidState(level, blockPos), MTagKeys.Fluid$WATER);
|
return canBeGrass(state, level, pos) && !FastNMS.INSTANCE.method$FluidState$is(FastNMS.INSTANCE.method$BlockGetter$getFluidState(level, blockPos), MTagKeys.Fluid$WATER);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<SurfaceSpreadingBlockBehavior> {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public SurfaceSpreadingBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
int requiredLight = ResourceConfigUtils.getAsInt(arguments.getOrDefault("required-light", 9), "required-light");
|
int requiredLight = ResourceConfigUtils.getAsInt(arguments.getOrDefault("required-light", 9), "required-light");
|
||||||
String baseBlock = ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.getOrDefault("base-block", "minecraft:dirt"), "warning.config.block.behavior.surface_spreading.missing_base_block");
|
String baseBlock = ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.getOrDefault("base-block", "minecraft:dirt"), "warning.config.block.behavior.surface_spreading.missing_base_block");
|
||||||
return new SurfaceSpreadingBlockBehavior(block, requiredLight, baseBlock, (Property<Boolean>) block.getProperty("snowy"));
|
return new SurfaceSpreadingBlockBehavior(block, requiredLight, baseBlock, (Property<Boolean>) block.getProperty("snowy"));
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import net.momirealms.craftengine.bukkit.util.BlockStateUtils;
|
|||||||
import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.block.properties.Property;
|
import net.momirealms.craftengine.core.block.properties.Property;
|
||||||
import net.momirealms.craftengine.core.entity.player.InteractionResult;
|
import net.momirealms.craftengine.core.entity.player.InteractionResult;
|
||||||
@@ -18,7 +17,7 @@ import java.util.Optional;
|
|||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
public class ToggleableLampBlockBehavior extends BukkitBlockBehavior {
|
public class ToggleableLampBlockBehavior extends BukkitBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<ToggleableLampBlockBehavior> FACTORY = new Factory();
|
||||||
private final Property<Boolean> litProperty;
|
private final Property<Boolean> litProperty;
|
||||||
private final Property<Boolean> poweredProperty;
|
private final Property<Boolean> poweredProperty;
|
||||||
private final boolean canOpenWithHand;
|
private final boolean canOpenWithHand;
|
||||||
@@ -88,10 +87,10 @@ public class ToggleableLampBlockBehavior extends BukkitBlockBehavior {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<ToggleableLampBlockBehavior> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public ToggleableLampBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
boolean canOpenWithHand = ResourceConfigUtils.getAsBoolean(ResourceConfigUtils.get(arguments, "can-open-with-hand", "can-toggle-with-hand"), "can-toggle-with-hand");
|
boolean canOpenWithHand = ResourceConfigUtils.getAsBoolean(ResourceConfigUtils.get(arguments, "can-open-with-hand", "can-toggle-with-hand"), "can-toggle-with-hand");
|
||||||
Property<Boolean> lit = (Property<Boolean>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("lit"), "warning.config.block.behavior.toggleable_lamp.missing_lit");
|
Property<Boolean> lit = (Property<Boolean>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("lit"), "warning.config.block.behavior.toggleable_lamp.missing_lit");
|
||||||
Property<Boolean> powered = (Property<Boolean>) (canOpenWithHand ? block.getProperty("powered") : ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("powered"), "warning.config.block.behavior.toggleable_lamp.missing_powered"));
|
Property<Boolean> powered = (Property<Boolean>) (canOpenWithHand ? block.getProperty("powered") : ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("powered"), "warning.config.block.behavior.toggleable_lamp.missing_powered"));
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
|||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||||
import net.momirealms.craftengine.core.block.UpdateOption;
|
import net.momirealms.craftengine.core.block.UpdateOption;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.block.behavior.IsPathFindableBlockBehavior;
|
import net.momirealms.craftengine.core.block.behavior.IsPathFindableBlockBehavior;
|
||||||
import net.momirealms.craftengine.core.block.properties.Property;
|
import net.momirealms.craftengine.core.block.properties.Property;
|
||||||
@@ -42,7 +41,7 @@ import java.util.concurrent.Callable;
|
|||||||
|
|
||||||
@SuppressWarnings("DuplicatedCode")
|
@SuppressWarnings("DuplicatedCode")
|
||||||
public class TrapDoorBlockBehavior extends BukkitBlockBehavior implements IsPathFindableBlockBehavior {
|
public class TrapDoorBlockBehavior extends BukkitBlockBehavior implements IsPathFindableBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<TrapDoorBlockBehavior> FACTORY = new Factory();
|
||||||
private final Property<SingleBlockHalf> halfProperty;
|
private final Property<SingleBlockHalf> halfProperty;
|
||||||
private final Property<HorizontalDirection> facingProperty;
|
private final Property<HorizontalDirection> facingProperty;
|
||||||
private final Property<Boolean> poweredProperty;
|
private final Property<Boolean> poweredProperty;
|
||||||
@@ -228,10 +227,10 @@ public class TrapDoorBlockBehavior extends BukkitBlockBehavior implements IsPath
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<TrapDoorBlockBehavior> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public TrapDoorBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
Property<SingleBlockHalf> half = (Property<SingleBlockHalf>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("half"), "warning.config.block.behavior.trapdoor.missing_half");
|
Property<SingleBlockHalf> half = (Property<SingleBlockHalf>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("half"), "warning.config.block.behavior.trapdoor.missing_half");
|
||||||
Property<HorizontalDirection> facing = (Property<HorizontalDirection>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("facing"), "warning.config.block.behavior.trapdoor.missing_facing");
|
Property<HorizontalDirection> facing = (Property<HorizontalDirection>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("facing"), "warning.config.block.behavior.trapdoor.missing_facing");
|
||||||
Property<Boolean> open = (Property<Boolean>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("open"), "warning.config.block.behavior.trapdoor.missing_open");
|
Property<Boolean> open = (Property<Boolean>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("open"), "warning.config.block.behavior.trapdoor.missing_open");
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
|||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||||
import net.momirealms.craftengine.core.block.UpdateOption;
|
import net.momirealms.craftengine.core.block.UpdateOption;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.block.properties.IntegerProperty;
|
import net.momirealms.craftengine.core.block.properties.IntegerProperty;
|
||||||
import net.momirealms.craftengine.core.block.properties.Property;
|
import net.momirealms.craftengine.core.block.properties.Property;
|
||||||
@@ -22,7 +21,7 @@ import java.util.Optional;
|
|||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
public class VerticalCropBlockBehavior extends BukkitBlockBehavior {
|
public class VerticalCropBlockBehavior extends BukkitBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<VerticalCropBlockBehavior> FACTORY = new Factory();
|
||||||
private final int maxHeight;
|
private final int maxHeight;
|
||||||
private final IntegerProperty ageProperty;
|
private final IntegerProperty ageProperty;
|
||||||
private final float growSpeed;
|
private final float growSpeed;
|
||||||
@@ -78,11 +77,11 @@ public class VerticalCropBlockBehavior extends BukkitBlockBehavior {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<VerticalCropBlockBehavior> {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public VerticalCropBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
Property<Integer> ageProperty = (Property<Integer>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("age"), "warning.config.block.behavior.vertical_crop.missing_age");
|
Property<Integer> ageProperty = (Property<Integer>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("age"), "warning.config.block.behavior.vertical_crop.missing_age");
|
||||||
int maxHeight = ResourceConfigUtils.getAsInt(arguments.getOrDefault("max-height", 3), "max-height");
|
int maxHeight = ResourceConfigUtils.getAsInt(arguments.getOrDefault("max-height", 3), "max-height");
|
||||||
boolean direction = arguments.getOrDefault("direction", "up").toString().equalsIgnoreCase("up");
|
boolean direction = arguments.getOrDefault("direction", "up").toString().equalsIgnoreCase("up");
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import net.momirealms.craftengine.bukkit.block.entity.BukkitBlockEntityTypes;
|
|||||||
import net.momirealms.craftengine.bukkit.block.entity.WallTorchParticleBlockEntity;
|
import net.momirealms.craftengine.bukkit.block.entity.WallTorchParticleBlockEntity;
|
||||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehavior;
|
|
||||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.block.behavior.EntityBlockBehavior;
|
import net.momirealms.craftengine.core.block.behavior.EntityBlockBehavior;
|
||||||
import net.momirealms.craftengine.core.block.entity.BlockEntity;
|
import net.momirealms.craftengine.core.block.entity.BlockEntity;
|
||||||
@@ -22,7 +21,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class WallTorchParticleBlockBehavior extends BukkitBlockBehavior implements EntityBlockBehavior {
|
public class WallTorchParticleBlockBehavior extends BukkitBlockBehavior implements EntityBlockBehavior {
|
||||||
public static final BlockBehaviorFactory FACTORY = new Factory();
|
public static final BlockBehaviorFactory<WallTorchParticleBlockBehavior> FACTORY = new Factory();
|
||||||
public final ParticleConfig[] particles;
|
public final ParticleConfig[] particles;
|
||||||
public final int tickInterval;
|
public final int tickInterval;
|
||||||
public final Property<HorizontalDirection> facingProperty;
|
public final Property<HorizontalDirection> facingProperty;
|
||||||
@@ -62,11 +61,11 @@ public class WallTorchParticleBlockBehavior extends BukkitBlockBehavior implemen
|
|||||||
return EntityBlockBehavior.createTickerHelper(WallTorchParticleBlockEntity::tick);
|
return EntityBlockBehavior.createTickerHelper(WallTorchParticleBlockEntity::tick);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements BlockBehaviorFactory {
|
private static class Factory implements BlockBehaviorFactory<WallTorchParticleBlockBehavior> {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
public WallTorchParticleBlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||||
List<ParticleConfig> particles = ResourceConfigUtils.parseConfigAsList(ResourceConfigUtils.get(arguments, "particles", "particle"), ParticleConfig::fromMap$blockEntity);
|
List<ParticleConfig> particles = ResourceConfigUtils.parseConfigAsList(ResourceConfigUtils.get(arguments, "particles", "particle"), ParticleConfig::fromMap$blockEntity);
|
||||||
int tickInterval = ResourceConfigUtils.getAsInt(arguments.getOrDefault("tick-interval", 10), "tick-interval");
|
int tickInterval = ResourceConfigUtils.getAsInt(arguments.getOrDefault("tick-interval", 10), "tick-interval");
|
||||||
Property<HorizontalDirection> directionProperty = (Property<HorizontalDirection>) block.getProperty("facing");
|
Property<HorizontalDirection> directionProperty = (Property<HorizontalDirection>) block.getProperty("facing");
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ import java.util.Map;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public class AxeItemBehavior extends ItemBehavior {
|
public class AxeItemBehavior extends ItemBehavior {
|
||||||
public static final ItemBehaviorFactory FACTORY = new Factory();
|
public static final ItemBehaviorFactory<AxeItemBehavior> FACTORY = new Factory();
|
||||||
public static final AxeItemBehavior INSTANCE = new AxeItemBehavior();
|
public static final AxeItemBehavior INSTANCE = new AxeItemBehavior();
|
||||||
private static final Key AXE_STRIP_SOUND = Key.of("minecraft:item.axe.strip");
|
private static final Key AXE_STRIP_SOUND = Key.of("minecraft:item.axe.strip");
|
||||||
|
|
||||||
@@ -112,9 +112,9 @@ public class AxeItemBehavior extends ItemBehavior {
|
|||||||
return InteractionResult.SUCCESS_AND_CANCEL;
|
return InteractionResult.SUCCESS_AND_CANCEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements ItemBehaviorFactory {
|
private static class Factory implements ItemBehaviorFactory<AxeItemBehavior> {
|
||||||
@Override
|
@Override
|
||||||
public ItemBehavior create(Pack pack, Path path, String node, Key key, Map<String, Object> arguments) {
|
public AxeItemBehavior create(Pack pack, Path path, String node, Key key, Map<String, Object> arguments) {
|
||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import net.momirealms.craftengine.core.entity.player.InteractionResult;
|
|||||||
import net.momirealms.craftengine.core.entity.player.Player;
|
import net.momirealms.craftengine.core.entity.player.Player;
|
||||||
import net.momirealms.craftengine.core.item.Item;
|
import net.momirealms.craftengine.core.item.Item;
|
||||||
import net.momirealms.craftengine.core.item.behavior.BlockBoundItemBehavior;
|
import net.momirealms.craftengine.core.item.behavior.BlockBoundItemBehavior;
|
||||||
import net.momirealms.craftengine.core.item.behavior.ItemBehavior;
|
|
||||||
import net.momirealms.craftengine.core.item.behavior.ItemBehaviorFactory;
|
import net.momirealms.craftengine.core.item.behavior.ItemBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.pack.Pack;
|
import net.momirealms.craftengine.core.pack.Pack;
|
||||||
import net.momirealms.craftengine.core.pack.PendingConfigSection;
|
import net.momirealms.craftengine.core.pack.PendingConfigSection;
|
||||||
@@ -54,7 +53,7 @@ import java.util.Map;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public class BlockItemBehavior extends BlockBoundItemBehavior {
|
public class BlockItemBehavior extends BlockBoundItemBehavior {
|
||||||
public static final ItemBehaviorFactory FACTORY = new Factory();
|
public static final ItemBehaviorFactory<BlockItemBehavior> FACTORY = new Factory();
|
||||||
private final Key blockId;
|
private final Key blockId;
|
||||||
|
|
||||||
public BlockItemBehavior(Key blockId) {
|
public BlockItemBehavior(Key blockId) {
|
||||||
@@ -242,9 +241,9 @@ public class BlockItemBehavior extends BlockBoundItemBehavior {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements ItemBehaviorFactory {
|
private static class Factory implements ItemBehaviorFactory<BlockItemBehavior> {
|
||||||
@Override
|
@Override
|
||||||
public ItemBehavior create(Pack pack, Path path, String node, Key key, Map<String, Object> arguments) {
|
public BlockItemBehavior create(Pack pack, Path path, String node, Key key, Map<String, Object> arguments) {
|
||||||
Object id = arguments.get("block");
|
Object id = arguments.get("block");
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
throw new LocalizedResourceConfigException("warning.config.item.behavior.block.missing_block", new IllegalArgumentException("Missing required parameter 'block' for block_item behavior"));
|
throw new LocalizedResourceConfigException("warning.config.item.behavior.block.missing_block", new IllegalArgumentException("Missing required parameter 'block' for block_item behavior"));
|
||||||
|
|||||||
@@ -7,18 +7,18 @@ import net.momirealms.craftengine.core.util.Key;
|
|||||||
public final class BukkitItemBehaviors extends ItemBehaviors {
|
public final class BukkitItemBehaviors extends ItemBehaviors {
|
||||||
private BukkitItemBehaviors() {}
|
private BukkitItemBehaviors() {}
|
||||||
|
|
||||||
public static final ItemBehaviorType BLOCK_ITEM = register(Key.ce("block_item"), BlockItemBehavior.FACTORY);
|
public static final ItemBehaviorType<BlockItemBehavior> BLOCK_ITEM = register(Key.ce("block_item"), BlockItemBehavior.FACTORY);
|
||||||
public static final ItemBehaviorType ON_LIQUID_BLOCK_ITEM = register(Key.ce("liquid_collision_block_item"), LiquidCollisionBlockItemBehavior.FACTORY);
|
public static final ItemBehaviorType<LiquidCollisionBlockItemBehavior> ON_LIQUID_BLOCK_ITEM = register(Key.ce("liquid_collision_block_item"), LiquidCollisionBlockItemBehavior.FACTORY);
|
||||||
public static final ItemBehaviorType FURNITURE_ITEM = register(Key.ce("furniture_item"), FurnitureItemBehavior.FACTORY);
|
public static final ItemBehaviorType<FurnitureItemBehavior> FURNITURE_ITEM = register(Key.ce("furniture_item"), FurnitureItemBehavior.FACTORY);
|
||||||
public static final ItemBehaviorType ON_LIQUID_FURNITURE_ITEM = register(Key.ce("liquid_collision_furniture_item"), LiquidCollisionFurnitureItemBehavior.FACTORY);
|
public static final ItemBehaviorType<LiquidCollisionFurnitureItemBehavior> ON_LIQUID_FURNITURE_ITEM = register(Key.ce("liquid_collision_furniture_item"), LiquidCollisionFurnitureItemBehavior.FACTORY);
|
||||||
public static final ItemBehaviorType FLINT_AND_STEEL_ITEM = register(Key.ce("flint_and_steel_item"), FlintAndSteelItemBehavior.FACTORY);
|
public static final ItemBehaviorType<FlintAndSteelItemBehavior> FLINT_AND_STEEL_ITEM = register(Key.ce("flint_and_steel_item"), FlintAndSteelItemBehavior.FACTORY);
|
||||||
public static final ItemBehaviorType COMPOSTABLE_ITEM = register(Key.ce("compostable_item"), CompostableItemBehavior.FACTORY);
|
public static final ItemBehaviorType<CompostableItemBehavior> COMPOSTABLE_ITEM = register(Key.ce("compostable_item"), CompostableItemBehavior.FACTORY);
|
||||||
public static final ItemBehaviorType AXE_ITEM = register(Key.ce("axe_item"), AxeItemBehavior.FACTORY);
|
public static final ItemBehaviorType<AxeItemBehavior> AXE_ITEM = register(Key.ce("axe_item"), AxeItemBehavior.FACTORY);
|
||||||
public static final ItemBehaviorType DOUBLE_HIGH_BLOCK_ITEM = register(Key.ce("double_high_block_item"), DoubleHighBlockItemBehavior.FACTORY);
|
public static final ItemBehaviorType<DoubleHighBlockItemBehavior> DOUBLE_HIGH_BLOCK_ITEM = register(Key.ce("double_high_block_item"), DoubleHighBlockItemBehavior.FACTORY);
|
||||||
public static final ItemBehaviorType WALL_BLOCK_ITEM = register(Key.ce("wall_block_item"), WallBlockItemBehavior.FACTORY);
|
public static final ItemBehaviorType<WallBlockItemBehavior> WALL_BLOCK_ITEM = register(Key.ce("wall_block_item"), WallBlockItemBehavior.FACTORY);
|
||||||
public static final ItemBehaviorType CEILING_BLOCK_ITEM = register(Key.ce("ceiling_block_item"), CeilingBlockItemBehavior.FACTORY);
|
public static final ItemBehaviorType<CeilingBlockItemBehavior> CEILING_BLOCK_ITEM = register(Key.ce("ceiling_block_item"), CeilingBlockItemBehavior.FACTORY);
|
||||||
public static final ItemBehaviorType GROUND_BLOCK_ITEM = register(Key.ce("ground_block_item"), GroundBlockItemBehavior.FACTORY);
|
public static final ItemBehaviorType<GroundBlockItemBehavior> GROUND_BLOCK_ITEM = register(Key.ce("ground_block_item"), GroundBlockItemBehavior.FACTORY);
|
||||||
public static final ItemBehaviorType MULTI_HIGH_BLOCK_ITEM = register(Key.ce("multi_high_block_item"), MultiHighBlockItemBehavior.FACTORY);
|
public static final ItemBehaviorType<MultiHighBlockItemBehavior> MULTI_HIGH_BLOCK_ITEM = register(Key.ce("multi_high_block_item"), MultiHighBlockItemBehavior.FACTORY);
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package net.momirealms.craftengine.bukkit.item.behavior;
|
package net.momirealms.craftengine.bukkit.item.behavior;
|
||||||
|
|
||||||
import net.momirealms.craftengine.core.entity.player.InteractionResult;
|
import net.momirealms.craftengine.core.entity.player.InteractionResult;
|
||||||
import net.momirealms.craftengine.core.item.behavior.ItemBehavior;
|
|
||||||
import net.momirealms.craftengine.core.item.behavior.ItemBehaviorFactory;
|
import net.momirealms.craftengine.core.item.behavior.ItemBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.pack.Pack;
|
import net.momirealms.craftengine.core.pack.Pack;
|
||||||
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
|
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
|
||||||
@@ -14,7 +13,7 @@ import java.nio.file.Path;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class CeilingBlockItemBehavior extends BlockItemBehavior {
|
public class CeilingBlockItemBehavior extends BlockItemBehavior {
|
||||||
public static final ItemBehaviorFactory FACTORY = new Factory();
|
public static final ItemBehaviorFactory<CeilingBlockItemBehavior> FACTORY = new Factory();
|
||||||
|
|
||||||
public CeilingBlockItemBehavior(Key ceilingBlockId) {
|
public CeilingBlockItemBehavior(Key ceilingBlockId) {
|
||||||
super(ceilingBlockId);
|
super(ceilingBlockId);
|
||||||
@@ -33,9 +32,9 @@ public class CeilingBlockItemBehavior extends BlockItemBehavior {
|
|||||||
return super.place(context);
|
return super.place(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements ItemBehaviorFactory {
|
private static class Factory implements ItemBehaviorFactory<CeilingBlockItemBehavior> {
|
||||||
@Override
|
@Override
|
||||||
public ItemBehavior create(Pack pack, Path path, String node, Key key, Map<String, Object> arguments) {
|
public CeilingBlockItemBehavior create(Pack pack, Path path, String node, Key key, Map<String, Object> arguments) {
|
||||||
Object id = arguments.get("block");
|
Object id = arguments.get("block");
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
throw new LocalizedResourceConfigException("warning.config.item.behavior.ceiling_block.missing_block", new IllegalArgumentException("Missing required parameter 'block' for ceiling_block_item behavior"));
|
throw new LocalizedResourceConfigException("warning.config.item.behavior.ceiling_block.missing_block", new IllegalArgumentException("Missing required parameter 'block' for ceiling_block_item behavior"));
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import java.nio.file.Path;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class CompostableItemBehavior extends ItemBehavior {
|
public class CompostableItemBehavior extends ItemBehavior {
|
||||||
public static final ItemBehaviorFactory FACTORY = new Factory();
|
public static final ItemBehaviorFactory<CompostableItemBehavior> FACTORY = new Factory();
|
||||||
private final double chance;
|
private final double chance;
|
||||||
|
|
||||||
public CompostableItemBehavior(double chance) {
|
public CompostableItemBehavior(double chance) {
|
||||||
@@ -77,9 +77,9 @@ public class CompostableItemBehavior extends ItemBehavior {
|
|||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements ItemBehaviorFactory {
|
private static class Factory implements ItemBehaviorFactory<CompostableItemBehavior> {
|
||||||
@Override
|
@Override
|
||||||
public ItemBehavior create(Pack pack, Path path, String node, Key key, Map<String, Object> arguments) {
|
public CompostableItemBehavior create(Pack pack, Path path, String node, Key key, Map<String, Object> arguments) {
|
||||||
double chance = ResourceConfigUtils.getAsDouble(arguments.getOrDefault("chance", 0.55), "chance");
|
double chance = ResourceConfigUtils.getAsDouble(arguments.getOrDefault("chance", 0.55), "chance");
|
||||||
return new CompostableItemBehavior(chance);
|
return new CompostableItemBehavior(chance);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.MBlocks;
|
|||||||
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.MFluids;
|
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.MFluids;
|
||||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||||
import net.momirealms.craftengine.core.block.UpdateOption;
|
import net.momirealms.craftengine.core.block.UpdateOption;
|
||||||
import net.momirealms.craftengine.core.item.behavior.ItemBehavior;
|
|
||||||
import net.momirealms.craftengine.core.item.behavior.ItemBehaviorFactory;
|
import net.momirealms.craftengine.core.item.behavior.ItemBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.pack.Pack;
|
import net.momirealms.craftengine.core.pack.Pack;
|
||||||
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
|
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
|
||||||
@@ -18,7 +17,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class DoubleHighBlockItemBehavior extends BlockItemBehavior {
|
public class DoubleHighBlockItemBehavior extends BlockItemBehavior {
|
||||||
public static final ItemBehaviorFactory FACTORY = new Factory();
|
public static final ItemBehaviorFactory<DoubleHighBlockItemBehavior> FACTORY = new Factory();
|
||||||
|
|
||||||
public DoubleHighBlockItemBehavior(Key blockId) {
|
public DoubleHighBlockItemBehavior(Key blockId) {
|
||||||
super(blockId);
|
super(blockId);
|
||||||
@@ -36,9 +35,9 @@ public class DoubleHighBlockItemBehavior extends BlockItemBehavior {
|
|||||||
return super.placeBlock(location, blockState, revertState);
|
return super.placeBlock(location, blockState, revertState);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements ItemBehaviorFactory {
|
private static class Factory implements ItemBehaviorFactory<DoubleHighBlockItemBehavior> {
|
||||||
@Override
|
@Override
|
||||||
public ItemBehavior create(Pack pack, Path path, String node, Key key, Map<String, Object> arguments) {
|
public DoubleHighBlockItemBehavior create(Pack pack, Path path, String node, Key key, Map<String, Object> arguments) {
|
||||||
Object id = arguments.get("block");
|
Object id = arguments.get("block");
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
throw new LocalizedResourceConfigException("warning.config.item.behavior.double_high.missing_block");
|
throw new LocalizedResourceConfigException("warning.config.item.behavior.double_high.missing_block");
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class FlintAndSteelItemBehavior extends ItemBehavior {
|
public class FlintAndSteelItemBehavior extends ItemBehavior {
|
||||||
public static final FlintAndSteelItemBehavior INSTANCE = new FlintAndSteelItemBehavior();
|
public static final FlintAndSteelItemBehavior INSTANCE = new FlintAndSteelItemBehavior();
|
||||||
public static final ItemBehaviorFactory FACTORY = new Factory();
|
public static final ItemBehaviorFactory<FlintAndSteelItemBehavior> FACTORY = new Factory();
|
||||||
private static final Key FLINT_SOUND = Key.of("item.flintandsteel.use");
|
private static final Key FLINT_SOUND = Key.of("item.flintandsteel.use");
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@@ -159,9 +159,9 @@ public class FlintAndSteelItemBehavior extends ItemBehavior {
|
|||||||
return InteractionResult.PASS;
|
return InteractionResult.PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements ItemBehaviorFactory {
|
private static class Factory implements ItemBehaviorFactory<FlintAndSteelItemBehavior> {
|
||||||
@Override
|
@Override
|
||||||
public ItemBehavior create(Pack pack, Path path, String node, Key id, Map<String, Object> arguments) {
|
public FlintAndSteelItemBehavior create(Pack pack, Path path, String node, Key id, Map<String, Object> arguments) {
|
||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ import java.util.*;
|
|||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
public class FurnitureItemBehavior extends ItemBehavior {
|
public class FurnitureItemBehavior extends ItemBehavior {
|
||||||
public static final ItemBehaviorFactory FACTORY = new Factory();
|
public static final ItemBehaviorFactory<FurnitureItemBehavior> FACTORY = new Factory();
|
||||||
protected static final Set<String> ALLOWED_ANCHOR_TYPES = Set.of("wall", "ceiling", "ground");
|
protected static final Set<String> ALLOWED_ANCHOR_TYPES = Set.of("wall", "ceiling", "ground");
|
||||||
private final Key id;
|
private final Key id;
|
||||||
private final Map<AnchorType, Rule> rules;
|
private final Map<AnchorType, Rule> rules;
|
||||||
@@ -210,10 +210,11 @@ public class FurnitureItemBehavior extends ItemBehavior {
|
|||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements ItemBehaviorFactory {
|
private static class Factory implements ItemBehaviorFactory<FurnitureItemBehavior> {
|
||||||
|
|
||||||
|
@SuppressWarnings("DuplicatedCode")
|
||||||
@Override
|
@Override
|
||||||
public ItemBehavior create(Pack pack, Path path, String node, Key key, Map<String, Object> arguments) {
|
public FurnitureItemBehavior create(Pack pack, Path path, String node, Key key, Map<String, Object> arguments) {
|
||||||
Object id = arguments.get("furniture");
|
Object id = arguments.get("furniture");
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
throw new LocalizedResourceConfigException("warning.config.item.behavior.furniture.missing_furniture", new IllegalArgumentException("Missing required parameter 'furniture' for furniture_item behavior"));
|
throw new LocalizedResourceConfigException("warning.config.item.behavior.furniture.missing_furniture", new IllegalArgumentException("Missing required parameter 'furniture' for furniture_item behavior"));
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package net.momirealms.craftengine.bukkit.item.behavior;
|
package net.momirealms.craftengine.bukkit.item.behavior;
|
||||||
|
|
||||||
import net.momirealms.craftengine.core.entity.player.InteractionResult;
|
import net.momirealms.craftengine.core.entity.player.InteractionResult;
|
||||||
import net.momirealms.craftengine.core.item.behavior.ItemBehavior;
|
|
||||||
import net.momirealms.craftengine.core.item.behavior.ItemBehaviorFactory;
|
import net.momirealms.craftengine.core.item.behavior.ItemBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.pack.Pack;
|
import net.momirealms.craftengine.core.pack.Pack;
|
||||||
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
|
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
|
||||||
@@ -14,7 +13,7 @@ import java.nio.file.Path;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class GroundBlockItemBehavior extends BlockItemBehavior {
|
public class GroundBlockItemBehavior extends BlockItemBehavior {
|
||||||
public static final ItemBehaviorFactory FACTORY = new Factory();
|
public static final ItemBehaviorFactory<GroundBlockItemBehavior> FACTORY = new Factory();
|
||||||
|
|
||||||
public GroundBlockItemBehavior(Key ceilingBlockId) {
|
public GroundBlockItemBehavior(Key ceilingBlockId) {
|
||||||
super(ceilingBlockId);
|
super(ceilingBlockId);
|
||||||
@@ -33,9 +32,9 @@ public class GroundBlockItemBehavior extends BlockItemBehavior {
|
|||||||
return super.place(context);
|
return super.place(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements ItemBehaviorFactory {
|
private static class Factory implements ItemBehaviorFactory<GroundBlockItemBehavior> {
|
||||||
@Override
|
@Override
|
||||||
public ItemBehavior create(Pack pack, Path path, String node, Key key, Map<String, Object> arguments) {
|
public GroundBlockItemBehavior create(Pack pack, Path path, String node, Key key, Map<String, Object> arguments) {
|
||||||
Object id = arguments.get("block");
|
Object id = arguments.get("block");
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
throw new LocalizedResourceConfigException("warning.config.item.behavior.ground_block.missing_block", new IllegalArgumentException("Missing required parameter 'block' for ground_block_item behavior"));
|
throw new LocalizedResourceConfigException("warning.config.item.behavior.ground_block.missing_block", new IllegalArgumentException("Missing required parameter 'block' for ground_block_item behavior"));
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
|||||||
import net.momirealms.craftengine.core.entity.player.InteractionHand;
|
import net.momirealms.craftengine.core.entity.player.InteractionHand;
|
||||||
import net.momirealms.craftengine.core.entity.player.InteractionResult;
|
import net.momirealms.craftengine.core.entity.player.InteractionResult;
|
||||||
import net.momirealms.craftengine.core.entity.player.Player;
|
import net.momirealms.craftengine.core.entity.player.Player;
|
||||||
import net.momirealms.craftengine.core.item.behavior.ItemBehavior;
|
|
||||||
import net.momirealms.craftengine.core.item.behavior.ItemBehaviorFactory;
|
import net.momirealms.craftengine.core.item.behavior.ItemBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.pack.Pack;
|
import net.momirealms.craftengine.core.pack.Pack;
|
||||||
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||||
@@ -27,7 +26,7 @@ import java.nio.file.Path;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class LiquidCollisionBlockItemBehavior extends BlockItemBehavior {
|
public class LiquidCollisionBlockItemBehavior extends BlockItemBehavior {
|
||||||
public static final ItemBehaviorFactory FACTORY = new Factory();
|
public static final ItemBehaviorFactory<LiquidCollisionBlockItemBehavior> FACTORY = new Factory();
|
||||||
private final int offsetY;
|
private final int offsetY;
|
||||||
|
|
||||||
public LiquidCollisionBlockItemBehavior(Key blockId, int offsetY) {
|
public LiquidCollisionBlockItemBehavior(Key blockId, int offsetY) {
|
||||||
@@ -66,9 +65,9 @@ public class LiquidCollisionBlockItemBehavior extends BlockItemBehavior {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements ItemBehaviorFactory {
|
private static class Factory implements ItemBehaviorFactory<LiquidCollisionBlockItemBehavior> {
|
||||||
@Override
|
@Override
|
||||||
public ItemBehavior create(Pack pack, Path path, String node, Key key, Map<String, Object> arguments) {
|
public LiquidCollisionBlockItemBehavior create(Pack pack, Path path, String node, Key key, Map<String, Object> arguments) {
|
||||||
Object id = arguments.get("block");
|
Object id = arguments.get("block");
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
throw new LocalizedResourceConfigException("warning.config.item.behavior.liquid_collision.missing_block", new IllegalArgumentException("Missing required parameter 'block' for liquid_collision_block_item behavior"));
|
throw new LocalizedResourceConfigException("warning.config.item.behavior.liquid_collision.missing_block", new IllegalArgumentException("Missing required parameter 'block' for liquid_collision_block_item behavior"));
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import net.momirealms.craftengine.core.entity.furniture.RotationRule;
|
|||||||
import net.momirealms.craftengine.core.entity.player.InteractionHand;
|
import net.momirealms.craftengine.core.entity.player.InteractionHand;
|
||||||
import net.momirealms.craftengine.core.entity.player.InteractionResult;
|
import net.momirealms.craftengine.core.entity.player.InteractionResult;
|
||||||
import net.momirealms.craftengine.core.entity.player.Player;
|
import net.momirealms.craftengine.core.entity.player.Player;
|
||||||
import net.momirealms.craftengine.core.item.behavior.ItemBehavior;
|
|
||||||
import net.momirealms.craftengine.core.item.behavior.ItemBehaviorFactory;
|
import net.momirealms.craftengine.core.item.behavior.ItemBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.pack.Pack;
|
import net.momirealms.craftengine.core.pack.Pack;
|
||||||
import net.momirealms.craftengine.core.pack.PendingConfigSection;
|
import net.momirealms.craftengine.core.pack.PendingConfigSection;
|
||||||
@@ -34,7 +33,7 @@ import java.nio.file.Path;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class LiquidCollisionFurnitureItemBehavior extends FurnitureItemBehavior {
|
public class LiquidCollisionFurnitureItemBehavior extends FurnitureItemBehavior {
|
||||||
public static final ItemBehaviorFactory FACTORY = new Factory();
|
public static final ItemBehaviorFactory<LiquidCollisionFurnitureItemBehavior> FACTORY = new Factory();
|
||||||
private final List<String> liquidTypes;
|
private final List<String> liquidTypes;
|
||||||
private final boolean sourceOnly;
|
private final boolean sourceOnly;
|
||||||
|
|
||||||
@@ -90,10 +89,11 @@ public class LiquidCollisionFurnitureItemBehavior extends FurnitureItemBehavior
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements ItemBehaviorFactory {
|
private static class Factory implements ItemBehaviorFactory<LiquidCollisionFurnitureItemBehavior> {
|
||||||
|
|
||||||
|
@SuppressWarnings("DuplicatedCode")
|
||||||
@Override
|
@Override
|
||||||
public ItemBehavior create(Pack pack, Path path, String node, Key key, Map<String, Object> arguments) {
|
public LiquidCollisionFurnitureItemBehavior create(Pack pack, Path path, String node, Key key, Map<String, Object> arguments) {
|
||||||
Object id = arguments.get("furniture");
|
Object id = arguments.get("furniture");
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
throw new LocalizedResourceConfigException("warning.config.item.behavior.furniture.missing_furniture", new IllegalArgumentException("Missing required parameter 'furniture' for furniture_item behavior"));
|
throw new LocalizedResourceConfigException("warning.config.item.behavior.furniture.missing_furniture", new IllegalArgumentException("Missing required parameter 'furniture' for furniture_item behavior"));
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import net.momirealms.craftengine.core.block.UpdateOption;
|
|||||||
import net.momirealms.craftengine.core.block.properties.IntegerProperty;
|
import net.momirealms.craftengine.core.block.properties.IntegerProperty;
|
||||||
import net.momirealms.craftengine.core.entity.player.InteractionHand;
|
import net.momirealms.craftengine.core.entity.player.InteractionHand;
|
||||||
import net.momirealms.craftengine.core.entity.player.Player;
|
import net.momirealms.craftengine.core.entity.player.Player;
|
||||||
import net.momirealms.craftengine.core.item.behavior.ItemBehavior;
|
|
||||||
import net.momirealms.craftengine.core.item.behavior.ItemBehaviorFactory;
|
import net.momirealms.craftengine.core.item.behavior.ItemBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.pack.Pack;
|
import net.momirealms.craftengine.core.pack.Pack;
|
||||||
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||||
@@ -34,7 +33,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class MultiHighBlockItemBehavior extends BlockItemBehavior {
|
public class MultiHighBlockItemBehavior extends BlockItemBehavior {
|
||||||
public static final ItemBehaviorFactory FACTORY = new Factory();
|
public static final ItemBehaviorFactory<MultiHighBlockItemBehavior> FACTORY = new Factory();
|
||||||
|
|
||||||
public MultiHighBlockItemBehavior(Key blockId) {
|
public MultiHighBlockItemBehavior(Key blockId) {
|
||||||
super(blockId);
|
super(blockId);
|
||||||
@@ -104,9 +103,9 @@ public class MultiHighBlockItemBehavior extends BlockItemBehavior {
|
|||||||
return super.placeBlock(location, blockState, revertState);
|
return super.placeBlock(location, blockState, revertState);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements ItemBehaviorFactory {
|
private static class Factory implements ItemBehaviorFactory<MultiHighBlockItemBehavior> {
|
||||||
@Override
|
@Override
|
||||||
public ItemBehavior create(Pack pack, Path path, String node, Key key, Map<String, Object> arguments) {
|
public MultiHighBlockItemBehavior create(Pack pack, Path path, String node, Key key, Map<String, Object> arguments) {
|
||||||
Object id = arguments.get("block");
|
Object id = arguments.get("block");
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
throw new LocalizedResourceConfigException("warning.config.item.behavior.multi_high.missing_block");
|
throw new LocalizedResourceConfigException("warning.config.item.behavior.multi_high.missing_block");
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package net.momirealms.craftengine.bukkit.item.behavior;
|
package net.momirealms.craftengine.bukkit.item.behavior;
|
||||||
|
|
||||||
import net.momirealms.craftengine.core.entity.player.InteractionResult;
|
import net.momirealms.craftengine.core.entity.player.InteractionResult;
|
||||||
import net.momirealms.craftengine.core.item.behavior.ItemBehavior;
|
|
||||||
import net.momirealms.craftengine.core.item.behavior.ItemBehaviorFactory;
|
import net.momirealms.craftengine.core.item.behavior.ItemBehaviorFactory;
|
||||||
import net.momirealms.craftengine.core.pack.Pack;
|
import net.momirealms.craftengine.core.pack.Pack;
|
||||||
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
|
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
|
||||||
@@ -13,7 +12,7 @@ import java.nio.file.Path;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class WallBlockItemBehavior extends BlockItemBehavior {
|
public class WallBlockItemBehavior extends BlockItemBehavior {
|
||||||
public static final ItemBehaviorFactory FACTORY = new Factory();
|
public static final ItemBehaviorFactory<WallBlockItemBehavior> FACTORY = new Factory();
|
||||||
|
|
||||||
public WallBlockItemBehavior(Key wallBlockId) {
|
public WallBlockItemBehavior(Key wallBlockId) {
|
||||||
super(wallBlockId);
|
super(wallBlockId);
|
||||||
@@ -32,9 +31,9 @@ public class WallBlockItemBehavior extends BlockItemBehavior {
|
|||||||
return super.place(context);
|
return super.place(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements ItemBehaviorFactory {
|
private static class Factory implements ItemBehaviorFactory<WallBlockItemBehavior> {
|
||||||
@Override
|
@Override
|
||||||
public ItemBehavior create(Pack pack, Path path, String node, Key key, Map<String, Object> arguments) {
|
public WallBlockItemBehavior create(Pack pack, Path path, String node, Key key, Map<String, Object> arguments) {
|
||||||
Object id = arguments.get("block");
|
Object id = arguments.get("block");
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
throw new LocalizedResourceConfigException("warning.config.item.behavior.wall_block.missing_block", new IllegalArgumentException("Missing required parameter 'block' for wall_block_item behavior"));
|
throw new LocalizedResourceConfigException("warning.config.item.behavior.wall_block.missing_block", new IllegalArgumentException("Missing required parameter 'block' for wall_block_item behavior"));
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ public class BukkitNetworkManager implements NetworkManager, Listener {
|
|||||||
this.packetIds = VersionHelper.isOrAbove1_20_5() ? new PacketIds1_20_5() : new PacketIds1_20();
|
this.packetIds = VersionHelper.isOrAbove1_20_5() ? new PacketIds1_20_5() : new PacketIds1_20();
|
||||||
// register packet handlers
|
// register packet handlers
|
||||||
this.registerPacketListeners();
|
this.registerPacketListeners();
|
||||||
PayloadHelper.registerDataTypes();
|
PayloadHelper.init();
|
||||||
// set up packet senders
|
// set up packet senders
|
||||||
this.packetConsumer = FastNMS.INSTANCE::method$Connection$send;
|
this.packetConsumer = FastNMS.INSTANCE::method$Connection$send;
|
||||||
this.packetsConsumer = (connection, packets, sendListener) -> {
|
this.packetsConsumer = (connection, packets, sendListener) -> {
|
||||||
@@ -1039,6 +1039,12 @@ public class BukkitNetworkManager implements NetworkManager, Listener {
|
|||||||
int packetID = event.packetID();
|
int packetID = event.packetID();
|
||||||
ByteBufferPacketListenerHolder[] listener = s2cPacketListeners[user.encoderState().ordinal()];
|
ByteBufferPacketListenerHolder[] listener = s2cPacketListeners[user.encoderState().ordinal()];
|
||||||
if (packetID >= listener.length) { // fixme 为什么会这样
|
if (packetID >= listener.length) { // fixme 为什么会这样
|
||||||
|
this.plugin.logger().warn(
|
||||||
|
"Failed to map the Packet ID " + packetID + " to a PacketType constant. " +
|
||||||
|
"Bound: CLIENT, Connection state: " + user.encoderState() + ", " +
|
||||||
|
"Server version: " + VersionHelper.MINECRAFT_VERSION.version(),
|
||||||
|
new Throwable()
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ByteBufferPacketListenerHolder holder = listener[packetID];
|
ByteBufferPacketListenerHolder holder = listener[packetID];
|
||||||
@@ -1055,6 +1061,12 @@ public class BukkitNetworkManager implements NetworkManager, Listener {
|
|||||||
int packetID = event.packetID();
|
int packetID = event.packetID();
|
||||||
ByteBufferPacketListenerHolder[] listener = c2sPacketListeners[user.decoderState().ordinal()];
|
ByteBufferPacketListenerHolder[] listener = c2sPacketListeners[user.decoderState().ordinal()];
|
||||||
if (packetID >= listener.length) { // fixme 为什么会这样
|
if (packetID >= listener.length) { // fixme 为什么会这样
|
||||||
|
this.plugin.logger().warn(
|
||||||
|
"Failed to map the Packet ID " + packetID + " to a PacketType constant. " +
|
||||||
|
"Bound: SERVER, Connection state: " + user.encoderState() + ", " +
|
||||||
|
"Server version: " + VersionHelper.MINECRAFT_VERSION.version(),
|
||||||
|
new Throwable()
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ByteBufferPacketListenerHolder holder = listener[packetID];
|
ByteBufferPacketListenerHolder holder = listener[packetID];
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import net.momirealms.craftengine.bukkit.plugin.network.payload.protocol.VisualB
|
|||||||
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||||
import net.momirealms.craftengine.core.plugin.logger.Debugger;
|
import net.momirealms.craftengine.core.plugin.logger.Debugger;
|
||||||
import net.momirealms.craftengine.core.plugin.network.ModPacket;
|
import net.momirealms.craftengine.core.plugin.network.ModPacket;
|
||||||
|
import net.momirealms.craftengine.core.plugin.network.ModPacketType;
|
||||||
import net.momirealms.craftengine.core.plugin.network.NetWorkUser;
|
import net.momirealms.craftengine.core.plugin.network.NetWorkUser;
|
||||||
import net.momirealms.craftengine.core.plugin.network.PayloadChannelKeys;
|
import net.momirealms.craftengine.core.plugin.network.PayloadChannelKeys;
|
||||||
import net.momirealms.craftengine.core.plugin.network.codec.NetworkCodec;
|
import net.momirealms.craftengine.core.plugin.network.codec.NetworkCodec;
|
||||||
@@ -17,17 +18,21 @@ import net.momirealms.craftengine.core.registry.WritableRegistry;
|
|||||||
import net.momirealms.craftengine.core.util.FriendlyByteBuf;
|
import net.momirealms.craftengine.core.util.FriendlyByteBuf;
|
||||||
import net.momirealms.craftengine.core.util.ResourceKey;
|
import net.momirealms.craftengine.core.util.ResourceKey;
|
||||||
|
|
||||||
public class PayloadHelper {
|
public final class PayloadHelper {
|
||||||
|
public static final ModPacketType<ClientCustomBlockPacket> CLIENT_CUSTOM_BLOCK = register(ClientCustomBlockPacket.TYPE, ClientCustomBlockPacket.CODEC);
|
||||||
|
public static final ModPacketType<CancelBlockUpdatePacket> CANCEL_BLOCK_UPDATE = register(CancelBlockUpdatePacket.TYPE, CancelBlockUpdatePacket.CODEC);
|
||||||
|
public static final ModPacketType<ClientBlockStateSizePacket> CLIENT_BLOCK_STATE_SIZE = register(ClientBlockStateSizePacket.TYPE, ClientBlockStateSizePacket.CODEC);
|
||||||
|
public static final ModPacketType<VisualBlockStatePacket> VISUAL_BLOCK_STATE = register(VisualBlockStatePacket.TYPE, VisualBlockStatePacket.CODEC);
|
||||||
|
|
||||||
public static void registerDataTypes() {
|
private PayloadHelper() {}
|
||||||
registerDataType(ClientCustomBlockPacket.TYPE, ClientCustomBlockPacket.CODEC);
|
|
||||||
registerDataType(CancelBlockUpdatePacket.TYPE, CancelBlockUpdatePacket.CODEC);
|
public static void init() {
|
||||||
registerDataType(ClientBlockStateSizePacket.TYPE, ClientBlockStateSizePacket.CODEC);
|
|
||||||
registerDataType(VisualBlockStatePacket.TYPE, VisualBlockStatePacket.CODEC);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T extends ModPacket> void registerDataType(ResourceKey<NetworkCodec<FriendlyByteBuf, ? extends ModPacket>> key, NetworkCodec<FriendlyByteBuf, T> codec) {
|
public static <T extends ModPacket> ModPacketType<T> register(ResourceKey<NetworkCodec<FriendlyByteBuf, ? extends ModPacket>> key, NetworkCodec<FriendlyByteBuf, T> codec) {
|
||||||
|
ModPacketType<T> type = new ModPacketType<>(key.location(), codec);
|
||||||
((WritableRegistry<NetworkCodec<FriendlyByteBuf, ? extends ModPacket>>) BuiltInRegistries.MOD_PACKET).register(key, codec);
|
((WritableRegistry<NetworkCodec<FriendlyByteBuf, ? extends ModPacket>>) BuiltInRegistries.MOD_PACKET).register(key, codec);
|
||||||
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendData(NetWorkUser user, ModPacket data) {
|
public static void sendData(NetWorkUser user, ModPacket data) {
|
||||||
|
|||||||
@@ -355,6 +355,10 @@ public class BukkitWorldManager implements WorldManager, Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addCraftEngineDecorations(CEWorld ceWorld, Object chunkGenerator, Object worldGenLevel, Object chunkAccess, Object structureManager) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void handleChunkLoad(CEWorld ceWorld, Chunk chunk, boolean isNew) {
|
private void handleChunkLoad(CEWorld ceWorld, Chunk chunk, boolean isNew) {
|
||||||
int chunkX = chunk.getX();
|
int chunkX = chunk.getX();
|
||||||
int chunkZ = chunk.getZ();
|
int chunkZ = chunk.getZ();
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import net.momirealms.craftengine.core.block.CustomBlock;
|
|||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public interface BlockBehaviorFactory {
|
public interface BlockBehaviorFactory<T extends BlockBehavior> {
|
||||||
|
|
||||||
BlockBehavior create(CustomBlock block, Map<String, Object> arguments);
|
T create(CustomBlock block, Map<String, Object> arguments);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,5 +2,5 @@ package net.momirealms.craftengine.core.block.behavior;
|
|||||||
|
|
||||||
import net.momirealms.craftengine.core.util.Key;
|
import net.momirealms.craftengine.core.util.Key;
|
||||||
|
|
||||||
public record BlockBehaviorType(Key id, BlockBehaviorFactory factory) {
|
public record BlockBehaviorType<T extends BlockBehavior>(Key id, BlockBehaviorFactory<T> factory) {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,14 +13,14 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class BlockBehaviors {
|
public class BlockBehaviors {
|
||||||
public static final BlockBehaviorType EMPTY = register(Key.ce("empty"), (block, args) -> EmptyBlockBehavior.INSTANCE);
|
public static final BlockBehaviorType<EmptyBlockBehavior> EMPTY = register(Key.ce("empty"), (block, args) -> EmptyBlockBehavior.INSTANCE);
|
||||||
|
|
||||||
protected BlockBehaviors() {
|
protected BlockBehaviors() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BlockBehaviorType register(Key key, BlockBehaviorFactory factory) {
|
public static <T extends BlockBehavior> BlockBehaviorType<T> register(Key key, BlockBehaviorFactory<T> factory) {
|
||||||
BlockBehaviorType type = new BlockBehaviorType(key, factory);
|
BlockBehaviorType<T> type = new BlockBehaviorType<>(key, factory);
|
||||||
((WritableRegistry<BlockBehaviorType>) BuiltInRegistries.BLOCK_BEHAVIOR_TYPE)
|
((WritableRegistry<BlockBehaviorType<? extends BlockBehavior>>) BuiltInRegistries.BLOCK_BEHAVIOR_TYPE)
|
||||||
.register(ResourceKey.create(Registries.BLOCK_BEHAVIOR_TYPE.location(), key), type);
|
.register(ResourceKey.create(Registries.BLOCK_BEHAVIOR_TYPE.location(), key), type);
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
@@ -29,7 +29,7 @@ public class BlockBehaviors {
|
|||||||
if (map == null || map.isEmpty()) return EmptyBlockBehavior.INSTANCE;
|
if (map == null || map.isEmpty()) return EmptyBlockBehavior.INSTANCE;
|
||||||
String type = ResourceConfigUtils.requireNonEmptyStringOrThrow(map.get("type"), "warning.config.block.behavior.missing_type");
|
String type = ResourceConfigUtils.requireNonEmptyStringOrThrow(map.get("type"), "warning.config.block.behavior.missing_type");
|
||||||
Key key = Key.withDefaultNamespace(type, Key.DEFAULT_NAMESPACE);
|
Key key = Key.withDefaultNamespace(type, Key.DEFAULT_NAMESPACE);
|
||||||
BlockBehaviorType factory = BuiltInRegistries.BLOCK_BEHAVIOR_TYPE.getValue(key);
|
BlockBehaviorType<? extends BlockBehavior> factory = BuiltInRegistries.BLOCK_BEHAVIOR_TYPE.getValue(key);
|
||||||
if (factory == null) {
|
if (factory == null) {
|
||||||
throw new LocalizedResourceConfigException("warning.config.block.behavior.invalid_type", type);
|
throw new LocalizedResourceConfigException("warning.config.block.behavior.invalid_type", type);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,15 +7,15 @@ import java.nio.file.Path;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class EmptyItemBehavior extends ItemBehavior {
|
public class EmptyItemBehavior extends ItemBehavior {
|
||||||
public static final ItemBehaviorFactory FACTORY = new Factory();
|
public static final ItemBehaviorFactory<EmptyItemBehavior> FACTORY = new Factory();
|
||||||
public static final EmptyItemBehavior INSTANCE = new EmptyItemBehavior();
|
public static final EmptyItemBehavior INSTANCE = new EmptyItemBehavior();
|
||||||
|
|
||||||
private EmptyItemBehavior() {}
|
private EmptyItemBehavior() {}
|
||||||
|
|
||||||
private static class Factory implements ItemBehaviorFactory {
|
private static class Factory implements ItemBehaviorFactory<EmptyItemBehavior> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemBehavior create(Pack pack, Path path, String node, Key id, Map<String, Object> arguments) {
|
public EmptyItemBehavior create(Pack pack, Path path, String node, Key id, Map<String, Object> arguments) {
|
||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import net.momirealms.craftengine.core.util.Key;
|
|||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public interface ItemBehaviorFactory {
|
public interface ItemBehaviorFactory<T extends ItemBehavior> {
|
||||||
|
|
||||||
ItemBehavior create(Pack pack, Path path, String node, Key id, Map<String, Object> arguments);
|
T create(Pack pack, Path path, String node, Key id, Map<String, Object> arguments);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,5 +2,5 @@ package net.momirealms.craftengine.core.item.behavior;
|
|||||||
|
|
||||||
import net.momirealms.craftengine.core.util.Key;
|
import net.momirealms.craftengine.core.util.Key;
|
||||||
|
|
||||||
public record ItemBehaviorType(Key id, ItemBehaviorFactory factory) {
|
public record ItemBehaviorType<T extends ItemBehavior>(Key id, ItemBehaviorFactory<T> factory) {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,11 +13,11 @@ import java.nio.file.Path;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class ItemBehaviors {
|
public class ItemBehaviors {
|
||||||
public static final ItemBehaviorType EMPTY = register(Key.withDefaultNamespace("empty", Key.DEFAULT_NAMESPACE), EmptyItemBehavior.FACTORY);
|
public static final ItemBehaviorType<EmptyItemBehavior> EMPTY = register(Key.withDefaultNamespace("empty", Key.DEFAULT_NAMESPACE), EmptyItemBehavior.FACTORY);
|
||||||
|
|
||||||
public static ItemBehaviorType register(Key key, ItemBehaviorFactory factory) {
|
public static <T extends ItemBehavior> ItemBehaviorType<T> register(Key key, ItemBehaviorFactory<T> factory) {
|
||||||
ItemBehaviorType type = new ItemBehaviorType(key, factory);
|
ItemBehaviorType<T> type = new ItemBehaviorType<>(key, factory);
|
||||||
((WritableRegistry<ItemBehaviorType>) BuiltInRegistries.ITEM_BEHAVIOR_TYPE)
|
((WritableRegistry<ItemBehaviorType<? extends ItemBehavior>>) BuiltInRegistries.ITEM_BEHAVIOR_TYPE)
|
||||||
.register(ResourceKey.create(Registries.ITEM_BEHAVIOR_TYPE.location(), key), type);
|
.register(ResourceKey.create(Registries.ITEM_BEHAVIOR_TYPE.location(), key), type);
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
@@ -26,7 +26,7 @@ public class ItemBehaviors {
|
|||||||
if (map == null || map.isEmpty()) return EmptyItemBehavior.INSTANCE;
|
if (map == null || map.isEmpty()) return EmptyItemBehavior.INSTANCE;
|
||||||
String type = ResourceConfigUtils.requireNonEmptyStringOrThrow(map.get("type"), "warning.config.item.behavior.missing_type");
|
String type = ResourceConfigUtils.requireNonEmptyStringOrThrow(map.get("type"), "warning.config.item.behavior.missing_type");
|
||||||
Key key = Key.withDefaultNamespace(type, Key.DEFAULT_NAMESPACE);
|
Key key = Key.withDefaultNamespace(type, Key.DEFAULT_NAMESPACE);
|
||||||
ItemBehaviorType behaviorType = BuiltInRegistries.ITEM_BEHAVIOR_TYPE.getValue(key);
|
ItemBehaviorType<? extends ItemBehavior> behaviorType = BuiltInRegistries.ITEM_BEHAVIOR_TYPE.getValue(key);
|
||||||
if (behaviorType == null) {
|
if (behaviorType == null) {
|
||||||
throw new LocalizedResourceConfigException("warning.config.item.behavior.invalid_type", type);
|
throw new LocalizedResourceConfigException("warning.config.item.behavior.invalid_type", type);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -229,10 +229,10 @@ public class CustomSmithingTransformRecipe<T> extends AbstractedFixedResultRecip
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static final class ItemDataProcessors {
|
public static final class ItemDataProcessors {
|
||||||
public static final ItemDataProcessor.Type KEEP_COMPONENTS = register(Key.ce("keep_components"), KeepComponents.FACTORY);
|
public static final ItemDataProcessor.Type<KeepComponents> KEEP_COMPONENTS = register(Key.ce("keep_components"), KeepComponents.FACTORY);
|
||||||
public static final ItemDataProcessor.Type KEEP_TAGS = register(Key.ce("keep_tags"), KeepTags.FACTORY);
|
public static final ItemDataProcessor.Type<KeepTags> KEEP_TAGS = register(Key.ce("keep_tags"), KeepTags.FACTORY);
|
||||||
public static final ItemDataProcessor.Type KEEP_CUSTOM_DATA = register(Key.ce("keep_custom_data"), KeepCustomData.FACTORY);
|
public static final ItemDataProcessor.Type<KeepCustomData> KEEP_CUSTOM_DATA = register(Key.ce("keep_custom_data"), KeepCustomData.FACTORY);
|
||||||
public static final ItemDataProcessor.Type MERGE_ENCHANTMENTS = register(Key.ce("merge_enchantments"), MergeEnchantments.FACTORY);
|
public static final ItemDataProcessor.Type<MergeEnchantments> MERGE_ENCHANTMENTS = register(Key.ce("merge_enchantments"), MergeEnchantments.FACTORY);
|
||||||
|
|
||||||
private ItemDataProcessors() {}
|
private ItemDataProcessors() {}
|
||||||
|
|
||||||
@@ -251,16 +251,16 @@ public class CustomSmithingTransformRecipe<T> extends AbstractedFixedResultRecip
|
|||||||
throw new LocalizedResourceConfigException("warning.config.recipe.smithing_transform.post_processor.missing_type");
|
throw new LocalizedResourceConfigException("warning.config.recipe.smithing_transform.post_processor.missing_type");
|
||||||
}
|
}
|
||||||
Key key = Key.withDefaultNamespace(type, Key.DEFAULT_NAMESPACE);
|
Key key = Key.withDefaultNamespace(type, Key.DEFAULT_NAMESPACE);
|
||||||
ItemDataProcessor.Type processorType = BuiltInRegistries.SMITHING_RESULT_PROCESSOR_TYPE.getValue(key);
|
ItemDataProcessor.Type<? extends CustomSmithingTransformRecipe.ItemDataProcessor> processorType = BuiltInRegistries.SMITHING_RESULT_PROCESSOR_TYPE.getValue(key);
|
||||||
if (processorType == null) {
|
if (processorType == null) {
|
||||||
throw new LocalizedResourceConfigException("warning.config.recipe.smithing_transform.post_processor.invalid_type", type);
|
throw new LocalizedResourceConfigException("warning.config.recipe.smithing_transform.post_processor.invalid_type", type);
|
||||||
}
|
}
|
||||||
return processorType.factory.create(map);
|
return processorType.factory.create(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemDataProcessor.Type register(Key key, ItemDataProcessor.Factory factory) {
|
public static <T extends ItemDataProcessor> ItemDataProcessor.Type<T> register(Key key, ItemDataProcessor.Factory<T> factory) {
|
||||||
ItemDataProcessor.Type type = new ItemDataProcessor.Type(key, factory);
|
ItemDataProcessor.Type<T> type = new ItemDataProcessor.Type<>(key, factory);
|
||||||
((WritableRegistry<ItemDataProcessor.Type>) BuiltInRegistries.SMITHING_RESULT_PROCESSOR_TYPE)
|
((WritableRegistry<ItemDataProcessor.Type<? extends CustomSmithingTransformRecipe.ItemDataProcessor>>) BuiltInRegistries.SMITHING_RESULT_PROCESSOR_TYPE)
|
||||||
.register(ResourceKey.create(Registries.SMITHING_RESULT_PROCESSOR_TYPE.location(), key), type);
|
.register(ResourceKey.create(Registries.SMITHING_RESULT_PROCESSOR_TYPE.location(), key), type);
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
@@ -268,16 +268,16 @@ public class CustomSmithingTransformRecipe<T> extends AbstractedFixedResultRecip
|
|||||||
|
|
||||||
public interface ItemDataProcessor extends TriConsumer<Item<?>, Item<?>, Item<?>> {
|
public interface ItemDataProcessor extends TriConsumer<Item<?>, Item<?>, Item<?>> {
|
||||||
|
|
||||||
interface Factory {
|
interface Factory<T extends ItemDataProcessor> {
|
||||||
ItemDataProcessor create(Map<String, Object> arguments);
|
T create(Map<String, Object> arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
record Type(Key id, Factory factory) {}
|
record Type<T extends ItemDataProcessor>(Key id, Factory<T> factory) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MergeEnchantments implements ItemDataProcessor {
|
public static class MergeEnchantments implements ItemDataProcessor {
|
||||||
public static final MergeEnchantments INSTANCE = new MergeEnchantments();
|
public static final MergeEnchantments INSTANCE = new MergeEnchantments();
|
||||||
public static final ItemDataProcessor.Factory FACTORY = new Factory();
|
public static final ItemDataProcessor.Factory<MergeEnchantments> FACTORY = new Factory();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void accept(Item<?> item1, Item<?> item2, Item<?> item3) {
|
public void accept(Item<?> item1, Item<?> item2, Item<?> item3) {
|
||||||
@@ -297,17 +297,17 @@ public class CustomSmithingTransformRecipe<T> extends AbstractedFixedResultRecip
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements ItemDataProcessor.Factory {
|
private static class Factory implements ItemDataProcessor.Factory<MergeEnchantments> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemDataProcessor create(Map<String, Object> arguments) {
|
public MergeEnchantments create(Map<String, Object> arguments) {
|
||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class KeepCustomData implements ItemDataProcessor {
|
public static class KeepCustomData implements ItemDataProcessor {
|
||||||
public static final ItemDataProcessor.Factory FACTORY = new Factory();
|
public static final ItemDataProcessor.Factory<KeepCustomData> FACTORY = new Factory();
|
||||||
private final List<String[]> paths;
|
private final List<String[]> paths;
|
||||||
|
|
||||||
public KeepCustomData(List<String[]> data) {
|
public KeepCustomData(List<String[]> data) {
|
||||||
@@ -324,10 +324,10 @@ public class CustomSmithingTransformRecipe<T> extends AbstractedFixedResultRecip
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements ItemDataProcessor.Factory {
|
private static class Factory implements ItemDataProcessor.Factory<KeepCustomData> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemDataProcessor create(Map<String, Object> arguments) {
|
public KeepCustomData create(Map<String, Object> arguments) {
|
||||||
List<String> paths = MiscUtils.getAsStringList(ResourceConfigUtils.requireNonNullOrThrow(
|
List<String> paths = MiscUtils.getAsStringList(ResourceConfigUtils.requireNonNullOrThrow(
|
||||||
arguments.get("paths"),
|
arguments.get("paths"),
|
||||||
"warning.config.recipe.smithing_transform.post_processor.keep_custom_data.missing_paths")
|
"warning.config.recipe.smithing_transform.post_processor.keep_custom_data.missing_paths")
|
||||||
@@ -338,7 +338,7 @@ public class CustomSmithingTransformRecipe<T> extends AbstractedFixedResultRecip
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class KeepComponents implements ItemDataProcessor {
|
public static class KeepComponents implements ItemDataProcessor {
|
||||||
public static final ItemDataProcessor.Factory FACTORY = new Factory();
|
public static final ItemDataProcessor.Factory<KeepComponents> FACTORY = new Factory();
|
||||||
private final List<Key> components;
|
private final List<Key> components;
|
||||||
|
|
||||||
public KeepComponents(List<Key> components) {
|
public KeepComponents(List<Key> components) {
|
||||||
@@ -355,11 +355,11 @@ public class CustomSmithingTransformRecipe<T> extends AbstractedFixedResultRecip
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements ItemDataProcessor.Factory {
|
private static class Factory implements ItemDataProcessor.Factory<KeepComponents> {
|
||||||
private static final Key CUSTOM_DATA = Key.of("minecraft", "custom_data");
|
private static final Key CUSTOM_DATA = Key.of("minecraft", "custom_data");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemDataProcessor create(Map<String, Object> arguments) {
|
public KeepComponents create(Map<String, Object> arguments) {
|
||||||
Object componentsObj = arguments.get("components");
|
Object componentsObj = arguments.get("components");
|
||||||
if (componentsObj == null) {
|
if (componentsObj == null) {
|
||||||
throw new LocalizedResourceConfigException("warning.config.recipe.smithing_transform.post_processor.keep_component.missing_components");
|
throw new LocalizedResourceConfigException("warning.config.recipe.smithing_transform.post_processor.keep_component.missing_components");
|
||||||
@@ -371,7 +371,7 @@ public class CustomSmithingTransformRecipe<T> extends AbstractedFixedResultRecip
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class KeepTags implements ItemDataProcessor {
|
public static class KeepTags implements ItemDataProcessor {
|
||||||
public static final ItemDataProcessor.Factory FACTORY = new Factory();
|
public static final ItemDataProcessor.Factory<KeepTags> FACTORY = new Factory();
|
||||||
private final List<String[]> tags;
|
private final List<String[]> tags;
|
||||||
|
|
||||||
public KeepTags(List<String[]> tags) {
|
public KeepTags(List<String[]> tags) {
|
||||||
@@ -388,10 +388,10 @@ public class CustomSmithingTransformRecipe<T> extends AbstractedFixedResultRecip
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements ItemDataProcessor.Factory {
|
private static class Factory implements ItemDataProcessor.Factory<KeepTags> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemDataProcessor create(Map<String, Object> arguments) {
|
public KeepTags create(Map<String, Object> arguments) {
|
||||||
Object tagsObj = arguments.get("tags");
|
Object tagsObj = arguments.get("tags");
|
||||||
if (tagsObj == null) {
|
if (tagsObj == null) {
|
||||||
throw new LocalizedResourceConfigException("warning.config.recipe.smithing_transform.post_processor.keep_component.missing_tags");
|
throw new LocalizedResourceConfigException("warning.config.recipe.smithing_transform.post_processor.keep_component.missing_tags");
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public final class CropDrops implements Formula {
|
public final class CropDrops implements Formula {
|
||||||
public static final FormulaFactory FACTORY = new Factory();
|
public static final FormulaFactory<CropDrops> FACTORY = new Factory();
|
||||||
private final int extra;
|
private final int extra;
|
||||||
private final float probability;
|
private final float probability;
|
||||||
|
|
||||||
@@ -25,10 +25,10 @@ public final class CropDrops implements Formula {
|
|||||||
return initialCount;
|
return initialCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements FormulaFactory {
|
private static class Factory implements FormulaFactory<CropDrops> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Formula create(Map<String, Object> arguments) {
|
public CropDrops create(Map<String, Object> arguments) {
|
||||||
int extra = ResourceConfigUtils.getAsInt(arguments.getOrDefault("extra", 1), "extra");
|
int extra = ResourceConfigUtils.getAsInt(arguments.getOrDefault("extra", 1), "extra");
|
||||||
float probability = ResourceConfigUtils.getAsFloat(arguments.getOrDefault("probability", 0.5f), "probability");
|
float probability = ResourceConfigUtils.getAsFloat(arguments.getOrDefault("probability", 0.5f), "probability");
|
||||||
return new CropDrops(extra, probability);
|
return new CropDrops(extra, probability);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package net.momirealms.craftengine.core.loot.function.formula;
|
|||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public interface FormulaFactory {
|
public interface FormulaFactory<T extends Formula> {
|
||||||
|
|
||||||
Formula create(Map<String, Object> arguments);
|
T create(Map<String, Object> arguments);
|
||||||
}
|
}
|
||||||
@@ -2,5 +2,5 @@ package net.momirealms.craftengine.core.loot.function.formula;
|
|||||||
|
|
||||||
import net.momirealms.craftengine.core.util.Key;
|
import net.momirealms.craftengine.core.util.Key;
|
||||||
|
|
||||||
public record FormulaType(Key id, FormulaFactory factory) {
|
public record FormulaType<T extends Formula>(Key id, FormulaFactory<T> factory) {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,14 +9,14 @@ import net.momirealms.craftengine.core.util.ResourceKey;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public final class Formulas {
|
public final class Formulas {
|
||||||
public static final FormulaType ORE_DROPS = register(Key.ce("ore_drops"), OreDrops.FACTORY);
|
public static final FormulaType<OreDrops> ORE_DROPS = register(Key.ce("ore_drops"), OreDrops.FACTORY);
|
||||||
public static final FormulaType CROP_DROPS = register(Key.ce("binomial_with_bonus_count"), CropDrops.FACTORY);
|
public static final FormulaType<CropDrops> CROP_DROPS = register(Key.ce("binomial_with_bonus_count"), CropDrops.FACTORY);
|
||||||
|
|
||||||
private Formulas() {}
|
private Formulas() {}
|
||||||
|
|
||||||
public static FormulaType register(Key key, FormulaFactory factory) {
|
public static <T extends Formula> FormulaType<T> register(Key key, FormulaFactory<T> factory) {
|
||||||
FormulaType type = new FormulaType(key, factory);
|
FormulaType<T> type = new FormulaType<>(key, factory);
|
||||||
((WritableRegistry<FormulaType>) BuiltInRegistries.FORMULA_TYPE)
|
((WritableRegistry<FormulaType<? extends Formula>>) BuiltInRegistries.FORMULA_TYPE)
|
||||||
.register(ResourceKey.create(Registries.FORMULA_TYPE.location(), key), type);
|
.register(ResourceKey.create(Registries.FORMULA_TYPE.location(), key), type);
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
@@ -27,7 +27,7 @@ public final class Formulas {
|
|||||||
throw new NullPointerException("number type cannot be null");
|
throw new NullPointerException("number type cannot be null");
|
||||||
}
|
}
|
||||||
Key key = Key.withDefaultNamespace(type, Key.DEFAULT_NAMESPACE);
|
Key key = Key.withDefaultNamespace(type, Key.DEFAULT_NAMESPACE);
|
||||||
FormulaType formulaType = BuiltInRegistries.FORMULA_TYPE.getValue(key);
|
FormulaType<? extends Formula> formulaType = BuiltInRegistries.FORMULA_TYPE.getValue(key);
|
||||||
if (formulaType == null) {
|
if (formulaType == null) {
|
||||||
throw new IllegalArgumentException("Unknown formula type: " + type);
|
throw new IllegalArgumentException("Unknown formula type: " + type);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import net.momirealms.craftengine.core.util.RandomUtils;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public final class OreDrops implements Formula {
|
public final class OreDrops implements Formula {
|
||||||
public static final FormulaFactory FACTORY = new Factory();
|
public static final FormulaFactory<OreDrops> FACTORY = new Factory();
|
||||||
private static final OreDrops INSTANCE = new OreDrops();
|
private static final OreDrops INSTANCE = new OreDrops();
|
||||||
|
|
||||||
private OreDrops() {}
|
private OreDrops() {}
|
||||||
@@ -23,10 +23,10 @@ public final class OreDrops implements Formula {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements FormulaFactory {
|
private static class Factory implements FormulaFactory<OreDrops> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Formula create(Map<String, Object> arguments) {
|
public OreDrops create(Map<String, Object> arguments) {
|
||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import net.momirealms.craftengine.core.util.MiscUtils;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public record ConditionalResolution(Condition<PathContext> matcher, Resolution resolution) implements Resolution {
|
public record ConditionalResolution(Condition<PathContext> matcher, Resolution resolution) implements Resolution {
|
||||||
public static final ResolutionFactory FACTORY = new Factory();
|
public static final ResolutionFactory<ConditionalResolution> FACTORY = new Factory();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(PathContext existing, PathContext conflict) {
|
public void run(PathContext existing, PathContext conflict) {
|
||||||
@@ -17,7 +17,7 @@ public record ConditionalResolution(Condition<PathContext> matcher, Resolution r
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements ResolutionFactory {
|
private static class Factory implements ResolutionFactory<ConditionalResolution> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ConditionalResolution create(Map<String, Object> arguments) {
|
public ConditionalResolution create(Map<String, Object> arguments) {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import java.util.HashSet;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public final class MergeAltasResolution implements Resolution {
|
public final class MergeAltasResolution implements Resolution {
|
||||||
public static final ResolutionFactory FACTORY = new Factory();
|
public static final ResolutionFactory<MergeAltasResolution> FACTORY = new Factory();
|
||||||
public static final MergeAltasResolution INSTANCE = new MergeAltasResolution();
|
public static final MergeAltasResolution INSTANCE = new MergeAltasResolution();
|
||||||
|
|
||||||
private MergeAltasResolution() {}
|
private MergeAltasResolution() {}
|
||||||
@@ -43,10 +43,10 @@ public final class MergeAltasResolution implements Resolution {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements ResolutionFactory {
|
private static class Factory implements ResolutionFactory<MergeAltasResolution> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Resolution create(Map<String, Object> arguments) {
|
public MergeAltasResolution create(Map<String, Object> arguments) {
|
||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import java.util.HashSet;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public final class MergeFontResolution implements Resolution {
|
public final class MergeFontResolution implements Resolution {
|
||||||
public static final ResolutionFactory FACTORY = new Factory();
|
public static final ResolutionFactory<MergeFontResolution> FACTORY = new Factory();
|
||||||
public static final MergeFontResolution INSTANCE = new MergeFontResolution();
|
public static final MergeFontResolution INSTANCE = new MergeFontResolution();
|
||||||
|
|
||||||
private MergeFontResolution() {}
|
private MergeFontResolution() {}
|
||||||
@@ -43,10 +43,10 @@ public final class MergeFontResolution implements Resolution {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements ResolutionFactory {
|
private static class Factory implements ResolutionFactory<MergeFontResolution> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Resolution create(Map<String, Object> arguments) {
|
public MergeFontResolution create(Map<String, Object> arguments) {
|
||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import java.io.IOException;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public record MergeJsonResolution(boolean deeply) implements Resolution {
|
public record MergeJsonResolution(boolean deeply) implements Resolution {
|
||||||
public static final ResolutionFactory FACTORY = new Factory();
|
public static final ResolutionFactory<MergeJsonResolution> FACTORY = new Factory();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(PathContext existing, PathContext conflict) {
|
public void run(PathContext existing, PathContext conflict) {
|
||||||
@@ -29,10 +29,10 @@ public record MergeJsonResolution(boolean deeply) implements Resolution {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements ResolutionFactory {
|
private static class Factory implements ResolutionFactory<MergeJsonResolution> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Resolution create(Map<String, Object> arguments) {
|
public MergeJsonResolution create(Map<String, Object> arguments) {
|
||||||
boolean deeply = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("deeply", false), "deeply");
|
boolean deeply = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("deeply", false), "deeply");
|
||||||
return new MergeJsonResolution(deeply);
|
return new MergeJsonResolution(deeply);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import java.util.Map;
|
|||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
public final class MergeLegacyModelResolution implements Resolution {
|
public final class MergeLegacyModelResolution implements Resolution {
|
||||||
public static final ResolutionFactory FACTORY = new Factory();
|
public static final ResolutionFactory<MergeLegacyModelResolution> FACTORY = new Factory();
|
||||||
public static final MergeLegacyModelResolution INSTANCE = new MergeLegacyModelResolution();
|
public static final MergeLegacyModelResolution INSTANCE = new MergeLegacyModelResolution();
|
||||||
|
|
||||||
private MergeLegacyModelResolution() {}
|
private MergeLegacyModelResolution() {}
|
||||||
@@ -63,10 +63,10 @@ public final class MergeLegacyModelResolution implements Resolution {
|
|||||||
return element != null && element.isJsonArray();
|
return element != null && element.isJsonArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements ResolutionFactory {
|
private static class Factory implements ResolutionFactory<MergeLegacyModelResolution> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Resolution create(Map<String, Object> arguments) {
|
public MergeLegacyModelResolution create(Map<String, Object> arguments) {
|
||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import java.util.*;
|
|||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public final class MergePackMcMetaResolution implements Resolution {
|
public final class MergePackMcMetaResolution implements Resolution {
|
||||||
public static final ResolutionFactory FACTORY = new Factory();
|
public static final ResolutionFactory<MergePackMcMetaResolution> FACTORY = new Factory();
|
||||||
public static final Set<String> STANDARD_PACK_KEYS = ImmutableSet.of("pack", "features", "filter", "overlays", "language");
|
public static final Set<String> STANDARD_PACK_KEYS = ImmutableSet.of("pack", "features", "filter", "overlays", "language");
|
||||||
public static final MergePackMcMetaResolution INSTANCE = new MergePackMcMetaResolution();
|
public static final MergePackMcMetaResolution INSTANCE = new MergePackMcMetaResolution();
|
||||||
|
|
||||||
@@ -257,9 +257,9 @@ public final class MergePackMcMetaResolution implements Resolution {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements ResolutionFactory {
|
private static class Factory implements ResolutionFactory<MergePackMcMetaResolution> {
|
||||||
@Override
|
@Override
|
||||||
public Resolution create(Map<String, Object> arguments) {
|
public MergePackMcMetaResolution create(Map<String, Object> arguments) {
|
||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package net.momirealms.craftengine.core.pack.conflict.resolution;
|
|||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public interface ResolutionFactory {
|
public interface ResolutionFactory<T extends Resolution> {
|
||||||
|
|
||||||
Resolution create(Map<String, Object> arguments);
|
T create(Map<String, Object> arguments);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,5 +2,5 @@ package net.momirealms.craftengine.core.pack.conflict.resolution;
|
|||||||
|
|
||||||
import net.momirealms.craftengine.core.util.Key;
|
import net.momirealms.craftengine.core.util.Key;
|
||||||
|
|
||||||
public record ResolutionType(Key id, ResolutionFactory factory) {
|
public record ResolutionType<T extends Resolution>(Key id, ResolutionFactory<T> factory) {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,19 +11,19 @@ import net.momirealms.craftengine.core.util.ResourceKey;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public final class Resolutions {
|
public final class Resolutions {
|
||||||
public static final ResolutionType RETAIN_MATCHING = register(Key.ce("retain_matching"), RetainMatchingResolution.FACTORY);
|
public static final ResolutionType<RetainMatchingResolution> RETAIN_MATCHING = register(Key.ce("retain_matching"), RetainMatchingResolution.FACTORY);
|
||||||
public static final ResolutionType MERGE_JSON = register(Key.ce("merge_json"), MergeJsonResolution.FACTORY);
|
public static final ResolutionType<MergeJsonResolution> MERGE_JSON = register(Key.ce("merge_json"), MergeJsonResolution.FACTORY);
|
||||||
public static final ResolutionType MERGE_ATLAS = register(Key.ce("merge_atlas"), MergeAltasResolution.FACTORY);
|
public static final ResolutionType<MergeAltasResolution> MERGE_ATLAS = register(Key.ce("merge_atlas"), MergeAltasResolution.FACTORY);
|
||||||
public static final ResolutionType MERGE_FONT = register(Key.ce("merge_font"), MergeFontResolution.FACTORY);
|
public static final ResolutionType<MergeFontResolution> MERGE_FONT = register(Key.ce("merge_font"), MergeFontResolution.FACTORY);
|
||||||
public static final ResolutionType CONDITIONAL = register(Key.ce("conditional"), ConditionalResolution.FACTORY);
|
public static final ResolutionType<ConditionalResolution> CONDITIONAL = register(Key.ce("conditional"), ConditionalResolution.FACTORY);
|
||||||
public static final ResolutionType MERGE_PACK_MCMETA = register(Key.ce("merge_pack_mcmeta"), MergePackMcMetaResolution.FACTORY);
|
public static final ResolutionType<MergePackMcMetaResolution> MERGE_PACK_MCMETA = register(Key.ce("merge_pack_mcmeta"), MergePackMcMetaResolution.FACTORY);
|
||||||
public static final ResolutionType MERGE_LEGACY_MODEL = register(Key.ce("merge_legacy_model"), MergeLegacyModelResolution.FACTORY);
|
public static final ResolutionType<MergeLegacyModelResolution> MERGE_LEGACY_MODEL = register(Key.ce("merge_legacy_model"), MergeLegacyModelResolution.FACTORY);
|
||||||
|
|
||||||
private Resolutions() {}
|
private Resolutions() {}
|
||||||
|
|
||||||
public static ResolutionType register(Key key, ResolutionFactory factory) {
|
public static <T extends Resolution> ResolutionType<T> register(Key key, ResolutionFactory<T> factory) {
|
||||||
ResolutionType type = new ResolutionType(key, factory);
|
ResolutionType<T> type = new ResolutionType<>(key, factory);
|
||||||
((WritableRegistry<ResolutionType>) BuiltInRegistries.RESOLUTION_TYPE)
|
((WritableRegistry<ResolutionType<? extends Resolution>>) BuiltInRegistries.RESOLUTION_TYPE)
|
||||||
.register(ResourceKey.create(Registries.RESOLUTION_TYPE.location(), key), type);
|
.register(ResourceKey.create(Registries.RESOLUTION_TYPE.location(), key), type);
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
@@ -31,7 +31,7 @@ public final class Resolutions {
|
|||||||
public static Resolution fromMap(Map<String, Object> map) {
|
public static Resolution fromMap(Map<String, Object> map) {
|
||||||
String type = ResourceConfigUtils.requireNonEmptyStringOrThrow(map.get("type"), () -> new LocalizedException("warning.config.conflict_resolution.missing_type"));
|
String type = ResourceConfigUtils.requireNonEmptyStringOrThrow(map.get("type"), () -> new LocalizedException("warning.config.conflict_resolution.missing_type"));
|
||||||
Key key = Key.withDefaultNamespace(type, Key.DEFAULT_NAMESPACE);
|
Key key = Key.withDefaultNamespace(type, Key.DEFAULT_NAMESPACE);
|
||||||
ResolutionType resolutionType = BuiltInRegistries.RESOLUTION_TYPE.getValue(key);
|
ResolutionType<? extends Resolution> resolutionType = BuiltInRegistries.RESOLUTION_TYPE.getValue(key);
|
||||||
if (resolutionType == null) {
|
if (resolutionType == null) {
|
||||||
throw new LocalizedException("warning.config.conflict_resolution.invalid_type", type);
|
throw new LocalizedException("warning.config.conflict_resolution.invalid_type", type);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import java.nio.file.StandardCopyOption;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public record RetainMatchingResolution(Condition<PathContext> matcher) implements Resolution {
|
public record RetainMatchingResolution(Condition<PathContext> matcher) implements Resolution {
|
||||||
public static final ResolutionFactory FACTORY = new Factory();
|
public static final ResolutionFactory<RetainMatchingResolution> FACTORY = new Factory();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(PathContext existing, PathContext conflict) {
|
public void run(PathContext existing, PathContext conflict) {
|
||||||
@@ -25,10 +25,10 @@ public record RetainMatchingResolution(Condition<PathContext> matcher) implement
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements ResolutionFactory {
|
private static class Factory implements ResolutionFactory<RetainMatchingResolution> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Resolution create(Map<String, Object> arguments) {
|
public RetainMatchingResolution create(Map<String, Object> arguments) {
|
||||||
Map<String, Object> term = MiscUtils.castToMap(arguments.get("term"), false);
|
Map<String, Object> term = MiscUtils.castToMap(arguments.get("term"), false);
|
||||||
return new RetainMatchingResolution(PathMatchers.fromMap(term));
|
return new RetainMatchingResolution(PathMatchers.fromMap(term));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,5 +13,5 @@ public interface ResourcePackHost {
|
|||||||
|
|
||||||
boolean canUpload();
|
boolean canUpload();
|
||||||
|
|
||||||
ResourcePackHostType type();
|
ResourcePackHostType<? extends ResourcePackHost> type();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ import java.net.InetSocketAddress;
|
|||||||
import java.net.ProxySelector;
|
import java.net.ProxySelector;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public interface ResourcePackHostFactory {
|
public interface ResourcePackHostFactory<T extends ResourcePackHost> {
|
||||||
|
|
||||||
ResourcePackHost create(Map<String, Object> arguments);
|
T create(Map<String, Object> arguments);
|
||||||
|
|
||||||
default ProxySelector getProxySelector(Map<String, Object> proxySetting) {
|
default ProxySelector getProxySelector(Map<String, Object> proxySetting) {
|
||||||
ProxySelector proxy = ProxySelector.getDefault();
|
ProxySelector proxy = ProxySelector.getDefault();
|
||||||
|
|||||||
@@ -2,5 +2,5 @@ package net.momirealms.craftengine.core.pack.host;
|
|||||||
|
|
||||||
import net.momirealms.craftengine.core.util.Key;
|
import net.momirealms.craftengine.core.util.Key;
|
||||||
|
|
||||||
public record ResourcePackHostType(Key id, ResourcePackHostFactory factory) {
|
public record ResourcePackHostType<T extends ResourcePackHost>(Key id, ResourcePackHostFactory<T> factory) {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,21 +11,21 @@ import net.momirealms.craftengine.core.util.ResourceKey;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public final class ResourcePackHosts {
|
public final class ResourcePackHosts {
|
||||||
public static final ResourcePackHostType NONE = register(Key.ce("none"), NoneHost.FACTORY);
|
public static final ResourcePackHostType<NoneHost> NONE = register(Key.ce("none"), NoneHost.FACTORY);
|
||||||
public static final ResourcePackHostType SELF = register(Key.ce("self"), SelfHost.FACTORY);
|
public static final ResourcePackHostType<SelfHost> SELF = register(Key.ce("self"), SelfHost.FACTORY);
|
||||||
public static final ResourcePackHostType EXTERNAL = register(Key.ce("external"), ExternalHost.FACTORY);
|
public static final ResourcePackHostType<ExternalHost> EXTERNAL = register(Key.ce("external"), ExternalHost.FACTORY);
|
||||||
public static final ResourcePackHostType LOBFILE = register(Key.ce("lobfile"), LobFileHost.FACTORY);
|
public static final ResourcePackHostType<LobFileHost> LOBFILE = register(Key.ce("lobfile"), LobFileHost.FACTORY);
|
||||||
public static final ResourcePackHostType S3 = register(Key.ce("s3"), S3HostFactory.INSTANCE);
|
public static final ResourcePackHostType<S3Host> S3 = register(Key.ce("s3"), S3HostFactory.INSTANCE);
|
||||||
public static final ResourcePackHostType ALIST = register(Key.ce("alist"), AlistHost.FACTORY);
|
public static final ResourcePackHostType<AlistHost> ALIST = register(Key.ce("alist"), AlistHost.FACTORY);
|
||||||
public static final ResourcePackHostType DROPBOX = register(Key.ce("dropbox"), DropboxHost.FACTORY);
|
public static final ResourcePackHostType<DropboxHost> DROPBOX = register(Key.ce("dropbox"), DropboxHost.FACTORY);
|
||||||
public static final ResourcePackHostType ONEDRIVE = register(Key.ce("onedrive"), OneDriveHost.FACTORY);
|
public static final ResourcePackHostType<OneDriveHost> ONEDRIVE = register(Key.ce("onedrive"), OneDriveHost.FACTORY);
|
||||||
public static final ResourcePackHostType GITLAB = register(Key.ce("gitlab"), GitLabHost.FACTORY);
|
public static final ResourcePackHostType<GitLabHost> GITLAB = register(Key.ce("gitlab"), GitLabHost.FACTORY);
|
||||||
|
|
||||||
private ResourcePackHosts() {}
|
private ResourcePackHosts() {}
|
||||||
|
|
||||||
public static ResourcePackHostType register(Key key, ResourcePackHostFactory factory) {
|
public static <T extends ResourcePackHost> ResourcePackHostType<T> register(Key key, ResourcePackHostFactory<T> factory) {
|
||||||
ResourcePackHostType type = new ResourcePackHostType(key, factory);
|
ResourcePackHostType<T> type = new ResourcePackHostType<>(key, factory);
|
||||||
((WritableRegistry<ResourcePackHostType>) BuiltInRegistries.RESOURCE_PACK_HOST_TYPE)
|
((WritableRegistry<ResourcePackHostType<? extends ResourcePackHost>>) BuiltInRegistries.RESOURCE_PACK_HOST_TYPE)
|
||||||
.register(ResourceKey.create(Registries.RESOURCE_PACK_HOST_TYPE.location(), key), type);
|
.register(ResourceKey.create(Registries.RESOURCE_PACK_HOST_TYPE.location(), key), type);
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
@@ -36,7 +36,7 @@ public final class ResourcePackHosts {
|
|||||||
throw new LocalizedException("warning.config.host.missing_type");
|
throw new LocalizedException("warning.config.host.missing_type");
|
||||||
}
|
}
|
||||||
Key key = Key.withDefaultNamespace(type, Key.DEFAULT_NAMESPACE);
|
Key key = Key.withDefaultNamespace(type, Key.DEFAULT_NAMESPACE);
|
||||||
ResourcePackHostType hostType = BuiltInRegistries.RESOURCE_PACK_HOST_TYPE.getValue(key);
|
ResourcePackHostType<? extends ResourcePackHost> hostType = BuiltInRegistries.RESOURCE_PACK_HOST_TYPE.getValue(key);
|
||||||
if (hostType == null) {
|
if (hostType == null) {
|
||||||
throw new LocalizedException("warning.config.host.invalid_type", type);
|
throw new LocalizedException("warning.config.host.invalid_type", type);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import java.util.*;
|
|||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public final class AlistHost implements ResourcePackHost {
|
public final class AlistHost implements ResourcePackHost {
|
||||||
public static final ResourcePackHostFactory FACTORY = new Factory();
|
public static final ResourcePackHostFactory<AlistHost> FACTORY = new Factory();
|
||||||
private final String apiUrl;
|
private final String apiUrl;
|
||||||
private final String userName;
|
private final String userName;
|
||||||
private final String password;
|
private final String password;
|
||||||
@@ -70,7 +70,7 @@ public final class AlistHost implements ResourcePackHost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourcePackHostType type() {
|
public ResourcePackHostType<AlistHost> type() {
|
||||||
return ResourcePackHosts.ALIST;
|
return ResourcePackHosts.ALIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -281,10 +281,10 @@ public final class AlistHost implements ResourcePackHost {
|
|||||||
new RuntimeException("Failed to obtain resource pack download URL (HTTP " + response.statusCode() + "): " + response.body()));
|
new RuntimeException("Failed to obtain resource pack download URL (HTTP " + response.statusCode() + "): " + response.body()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements ResourcePackHostFactory {
|
private static class Factory implements ResourcePackHostFactory<AlistHost> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourcePackHost create(Map<String, Object> arguments) {
|
public AlistHost create(Map<String, Object> arguments) {
|
||||||
boolean useEnv = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("use-environment-variables", false), "use-environment-variables");
|
boolean useEnv = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("use-environment-variables", false), "use-environment-variables");
|
||||||
String apiUrl = ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.get("api-url"), () -> new LocalizedException("warning.config.host.alist.missing_api_url"));
|
String apiUrl = ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.get("api-url"), () -> new LocalizedException("warning.config.host.alist.missing_api_url"));
|
||||||
String userName = useEnv ? System.getenv("CE_ALIST_USERNAME") : Optional.ofNullable(arguments.get("username")).map(String::valueOf).orElse(null);
|
String userName = useEnv ? System.getenv("CE_ALIST_USERNAME") : Optional.ofNullable(arguments.get("username")).map(String::valueOf).orElse(null);
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
public final class DropboxHost implements ResourcePackHost {
|
public final class DropboxHost implements ResourcePackHost {
|
||||||
public static final ResourcePackHostFactory FACTORY = new Factory();
|
public static final ResourcePackHostFactory<DropboxHost> FACTORY = new Factory();
|
||||||
private final String appKey;
|
private final String appKey;
|
||||||
private final String appSecret;
|
private final String appSecret;
|
||||||
private final String uploadPath;
|
private final String uploadPath;
|
||||||
@@ -92,7 +92,7 @@ public final class DropboxHost implements ResourcePackHost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourcePackHostType type() {
|
public ResourcePackHostType<DropboxHost> type() {
|
||||||
return ResourcePackHosts.DROPBOX;
|
return ResourcePackHosts.DROPBOX;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -257,10 +257,10 @@ public final class DropboxHost implements ResourcePackHost {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements ResourcePackHostFactory {
|
private static class Factory implements ResourcePackHostFactory<DropboxHost> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourcePackHost create(Map<String, Object> arguments) {
|
public DropboxHost create(Map<String, Object> arguments) {
|
||||||
boolean useEnv = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("use-environment-variables", false), "use-environment-variables");
|
boolean useEnv = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("use-environment-variables", false), "use-environment-variables");
|
||||||
String appKey = useEnv ? System.getenv("CE_DROPBOX_APP_KEY") : Optional.ofNullable(arguments.get("app-key")).map(String::valueOf).orElse(null);
|
String appKey = useEnv ? System.getenv("CE_DROPBOX_APP_KEY") : Optional.ofNullable(arguments.get("app-key")).map(String::valueOf).orElse(null);
|
||||||
if (appKey == null || appKey.isEmpty()) {
|
if (appKey == null || appKey.isEmpty()) {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import java.util.UUID;
|
|||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public final class ExternalHost implements ResourcePackHost {
|
public final class ExternalHost implements ResourcePackHost {
|
||||||
public static final ResourcePackHostFactory FACTORY = new Factory();
|
public static final ResourcePackHostFactory<ExternalHost> FACTORY = new Factory();
|
||||||
private final ResourcePackDownloadData downloadData;
|
private final ResourcePackDownloadData downloadData;
|
||||||
|
|
||||||
public ExternalHost(ResourcePackDownloadData downloadData) {
|
public ExternalHost(ResourcePackDownloadData downloadData) {
|
||||||
@@ -35,14 +35,14 @@ public final class ExternalHost implements ResourcePackHost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourcePackHostType type() {
|
public ResourcePackHostType<ExternalHost> type() {
|
||||||
return ResourcePackHosts.EXTERNAL;
|
return ResourcePackHosts.EXTERNAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements ResourcePackHostFactory {
|
private static class Factory implements ResourcePackHostFactory<ExternalHost> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourcePackHost create(Map<String, Object> arguments) {
|
public ExternalHost create(Map<String, Object> arguments) {
|
||||||
String url = Optional.ofNullable(arguments.get("url")).map(String::valueOf).orElse(null);
|
String url = Optional.ofNullable(arguments.get("url")).map(String::valueOf).orElse(null);
|
||||||
if (url == null || url.isEmpty()) {
|
if (url == null || url.isEmpty()) {
|
||||||
throw new LocalizedException("warning.config.host.external.missing_url");
|
throw new LocalizedException("warning.config.host.external.missing_url");
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import java.util.*;
|
|||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public final class GitLabHost implements ResourcePackHost {
|
public final class GitLabHost implements ResourcePackHost {
|
||||||
public static final ResourcePackHostFactory FACTORY = new Factory();
|
public static final ResourcePackHostFactory<GitLabHost> FACTORY = new Factory();
|
||||||
private final String gitlabUrl;
|
private final String gitlabUrl;
|
||||||
private final String accessToken;
|
private final String accessToken;
|
||||||
private final String projectId;
|
private final String projectId;
|
||||||
@@ -162,14 +162,14 @@ public final class GitLabHost implements ResourcePackHost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourcePackHostType type() {
|
public ResourcePackHostType<GitLabHost> type() {
|
||||||
return ResourcePackHosts.GITLAB;
|
return ResourcePackHosts.GITLAB;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements ResourcePackHostFactory {
|
private static class Factory implements ResourcePackHostFactory<GitLabHost> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourcePackHost create(Map<String, Object> arguments) {
|
public GitLabHost create(Map<String, Object> arguments) {
|
||||||
boolean useEnv = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("use-environment-variables", false), "use-environment-variables");
|
boolean useEnv = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("use-environment-variables", false), "use-environment-variables");
|
||||||
String gitlabUrl = Optional.ofNullable(arguments.get("gitlab-url")).map(String::valueOf).orElse(null);
|
String gitlabUrl = Optional.ofNullable(arguments.get("gitlab-url")).map(String::valueOf).orElse(null);
|
||||||
if (gitlabUrl == null || gitlabUrl.isEmpty()) {
|
if (gitlabUrl == null || gitlabUrl.isEmpty()) {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import java.util.*;
|
|||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public final class LobFileHost implements ResourcePackHost {
|
public final class LobFileHost implements ResourcePackHost {
|
||||||
public static final ResourcePackHostFactory FACTORY = new Factory();
|
public static final ResourcePackHostFactory<LobFileHost> FACTORY = new Factory();
|
||||||
private final String apiKey;
|
private final String apiKey;
|
||||||
private final ProxySelector proxy;
|
private final ProxySelector proxy;
|
||||||
private AccountInfo accountInfo;
|
private AccountInfo accountInfo;
|
||||||
@@ -50,7 +50,7 @@ public final class LobFileHost implements ResourcePackHost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourcePackHostType type() {
|
public ResourcePackHostType<LobFileHost> type() {
|
||||||
return ResourcePackHosts.LOBFILE;
|
return ResourcePackHosts.LOBFILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -263,10 +263,10 @@ public final class LobFileHost implements ResourcePackHost {
|
|||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements ResourcePackHostFactory {
|
private static class Factory implements ResourcePackHostFactory<LobFileHost> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourcePackHost create(Map<String, Object> arguments) {
|
public LobFileHost create(Map<String, Object> arguments) {
|
||||||
boolean useEnv = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("use-environment-variables", false), "use-environment-variables");
|
boolean useEnv = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("use-environment-variables", false), "use-environment-variables");
|
||||||
String apiKey = useEnv ? System.getenv("CE_LOBFILE_API_KEY") : Optional.ofNullable(arguments.get("api-key")).map(String::valueOf).orElse(null);
|
String apiKey = useEnv ? System.getenv("CE_LOBFILE_API_KEY") : Optional.ofNullable(arguments.get("api-key")).map(String::valueOf).orElse(null);
|
||||||
if (apiKey == null || apiKey.isEmpty()) {
|
if (apiKey == null || apiKey.isEmpty()) {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import java.util.UUID;
|
|||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public final class NoneHost implements ResourcePackHost {
|
public final class NoneHost implements ResourcePackHost {
|
||||||
public static final ResourcePackHostFactory FACTORY = new Factory();
|
public static final ResourcePackHostFactory<NoneHost> FACTORY = new Factory();
|
||||||
public static final NoneHost INSTANCE = new NoneHost();
|
public static final NoneHost INSTANCE = new NoneHost();
|
||||||
|
|
||||||
private NoneHost() {}
|
private NoneHost() {}
|
||||||
@@ -25,7 +25,7 @@ public final class NoneHost implements ResourcePackHost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourcePackHostType type() {
|
public ResourcePackHostType<NoneHost> type() {
|
||||||
return ResourcePackHosts.NONE;
|
return ResourcePackHosts.NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,10 +34,10 @@ public final class NoneHost implements ResourcePackHost {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements ResourcePackHostFactory {
|
private static class Factory implements ResourcePackHostFactory<NoneHost> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourcePackHost create(Map<String, Object> arguments) {
|
public NoneHost create(Map<String, Object> arguments) {
|
||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import java.util.*;
|
|||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public final class OneDriveHost implements ResourcePackHost {
|
public final class OneDriveHost implements ResourcePackHost {
|
||||||
public static final ResourcePackHostFactory FACTORY = new Factory();
|
public static final ResourcePackHostFactory<OneDriveHost> FACTORY = new Factory();
|
||||||
private final String clientId;
|
private final String clientId;
|
||||||
private final String clientSecret;
|
private final String clientSecret;
|
||||||
private final ProxySelector proxy;
|
private final ProxySelector proxy;
|
||||||
@@ -55,7 +55,7 @@ public final class OneDriveHost implements ResourcePackHost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourcePackHostType type() {
|
public ResourcePackHostType<OneDriveHost> type() {
|
||||||
return ResourcePackHosts.ONEDRIVE;
|
return ResourcePackHosts.ONEDRIVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,10 +224,10 @@ public final class OneDriveHost implements ResourcePackHost {
|
|||||||
return this.refreshToken.mid();
|
return this.refreshToken.mid();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements ResourcePackHostFactory {
|
private static class Factory implements ResourcePackHostFactory<OneDriveHost> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourcePackHost create(Map<String, Object> arguments) {
|
public OneDriveHost create(Map<String, Object> arguments) {
|
||||||
boolean useEnv = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("use-environment-variables", false), "use-environment-variables");
|
boolean useEnv = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("use-environment-variables", false), "use-environment-variables");
|
||||||
String clientId = useEnv ? System.getenv("CE_ONEDRIVE_CLIENT_ID") : Optional.ofNullable(arguments.get("client-id")).map(String::valueOf).orElse(null);
|
String clientId = useEnv ? System.getenv("CE_ONEDRIVE_CLIENT_ID") : Optional.ofNullable(arguments.get("client-id")).map(String::valueOf).orElse(null);
|
||||||
if (clientId == null || clientId.isEmpty()) {
|
if (clientId == null || clientId.isEmpty()) {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package net.momirealms.craftengine.core.pack.host.impl;
|
package net.momirealms.craftengine.core.pack.host.impl;
|
||||||
|
|
||||||
import net.momirealms.craftengine.core.pack.host.ResourcePackHost;
|
|
||||||
import net.momirealms.craftengine.core.pack.host.ResourcePackHostFactory;
|
import net.momirealms.craftengine.core.pack.host.ResourcePackHostFactory;
|
||||||
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||||
import net.momirealms.craftengine.core.plugin.dependency.Dependencies;
|
import net.momirealms.craftengine.core.plugin.dependency.Dependencies;
|
||||||
@@ -8,11 +7,11 @@ import net.momirealms.craftengine.core.plugin.dependency.Dependencies;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public final class S3HostFactory implements ResourcePackHostFactory {
|
public final class S3HostFactory implements ResourcePackHostFactory<S3Host> {
|
||||||
public static final ResourcePackHostFactory INSTANCE = new S3HostFactory();
|
public static final ResourcePackHostFactory<S3Host> INSTANCE = new S3HostFactory();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourcePackHost create(Map<String, Object> arguments) {
|
public S3Host create(Map<String, Object> arguments) {
|
||||||
CraftEngine.instance().dependencyManager().loadDependencies(
|
CraftEngine.instance().dependencyManager().loadDependencies(
|
||||||
List.of(
|
List.of(
|
||||||
Dependencies.NETTY_HTTP2,
|
Dependencies.NETTY_HTTP2,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import java.util.UUID;
|
|||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public final class SelfHost implements ResourcePackHost {
|
public final class SelfHost implements ResourcePackHost {
|
||||||
public static final ResourcePackHostFactory FACTORY = new Factory();
|
public static final ResourcePackHostFactory<SelfHost> FACTORY = new Factory();
|
||||||
private static final SelfHost INSTANCE = new SelfHost();
|
private static final SelfHost INSTANCE = new SelfHost();
|
||||||
|
|
||||||
public SelfHost() {
|
public SelfHost() {
|
||||||
@@ -49,14 +49,14 @@ public final class SelfHost implements ResourcePackHost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourcePackHostType type() {
|
public ResourcePackHostType<SelfHost> type() {
|
||||||
return ResourcePackHosts.SELF;
|
return ResourcePackHosts.SELF;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements ResourcePackHostFactory {
|
private static class Factory implements ResourcePackHostFactory<SelfHost> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourcePackHost create(Map<String, Object> arguments) {
|
public SelfHost create(Map<String, Object> arguments) {
|
||||||
SelfHostHttpServer selfHostHttpServer = SelfHostHttpServer.instance();
|
SelfHostHttpServer selfHostHttpServer = SelfHostHttpServer.instance();
|
||||||
String ip = ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.get("ip"), () -> new LocalizedException("warning.config.host.self.missing_ip"));
|
String ip = ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.get("ip"), () -> new LocalizedException("warning.config.host.self.missing_ip"));
|
||||||
int port = ResourceConfigUtils.getAsInt(arguments.getOrDefault("port", 8163), "port");
|
int port = ResourceConfigUtils.getAsInt(arguments.getOrDefault("port", 8163), "port");
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public final class BaseItemModel implements ItemModel {
|
public final class BaseItemModel implements ItemModel {
|
||||||
public static final ItemModelFactory FACTORY = new Factory();
|
public static final ItemModelFactory<BaseItemModel> FACTORY = new Factory();
|
||||||
public static final ItemModelReader READER = new Reader();
|
public static final ItemModelReader<BaseItemModel> READER = new Reader();
|
||||||
private final String path;
|
private final String path;
|
||||||
private final List<Tint> tints;
|
private final List<Tint> tints;
|
||||||
private final ModelGeneration modelGeneration;
|
private final ModelGeneration modelGeneration;
|
||||||
@@ -78,11 +78,11 @@ public final class BaseItemModel implements ItemModel {
|
|||||||
return List.of();
|
return List.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements ItemModelFactory {
|
private static class Factory implements ItemModelFactory<BaseItemModel> {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public ItemModel create(Map<String, Object> arguments) {
|
public BaseItemModel create(Map<String, Object> arguments) {
|
||||||
String modelPath = ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.get("path"), "warning.config.item.model.base.missing_path");
|
String modelPath = ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.get("path"), "warning.config.item.model.base.missing_path");
|
||||||
if (!ResourceLocation.isValid(modelPath)) {
|
if (!ResourceLocation.isValid(modelPath)) {
|
||||||
throw new LocalizedResourceConfigException("warning.config.item.model.base.invalid_path", modelPath);
|
throw new LocalizedResourceConfigException("warning.config.item.model.base.invalid_path", modelPath);
|
||||||
@@ -105,10 +105,10 @@ public final class BaseItemModel implements ItemModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Reader implements ItemModelReader {
|
private static class Reader implements ItemModelReader<BaseItemModel> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemModel read(JsonObject json) {
|
public BaseItemModel read(JsonObject json) {
|
||||||
String model = json.get("model").getAsString();
|
String model = json.get("model").getAsString();
|
||||||
if (json.has("tints")) {
|
if (json.has("tints")) {
|
||||||
JsonArray array = json.getAsJsonArray("tints");
|
JsonArray array = json.getAsJsonArray("tints");
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ import java.util.Map;
|
|||||||
|
|
||||||
public final class BundleSelectedItemModel implements ItemModel {
|
public final class BundleSelectedItemModel implements ItemModel {
|
||||||
public static final BundleSelectedItemModel INSTANCE = new BundleSelectedItemModel();
|
public static final BundleSelectedItemModel INSTANCE = new BundleSelectedItemModel();
|
||||||
public static final ItemModelFactory FACTORY = new Factory();
|
public static final ItemModelFactory<BundleSelectedItemModel> FACTORY = new Factory();
|
||||||
public static final ItemModelReader READER = new Reader();
|
public static final ItemModelReader<BundleSelectedItemModel> READER = new Reader();
|
||||||
|
|
||||||
private BundleSelectedItemModel() {}
|
private BundleSelectedItemModel() {}
|
||||||
|
|
||||||
@@ -32,16 +32,16 @@ public final class BundleSelectedItemModel implements ItemModel {
|
|||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Factory implements ItemModelFactory {
|
private static class Factory implements ItemModelFactory<BundleSelectedItemModel> {
|
||||||
@Override
|
@Override
|
||||||
public ItemModel create(Map<String, Object> arguments) {
|
public BundleSelectedItemModel create(Map<String, Object> arguments) {
|
||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Reader implements ItemModelReader {
|
private static class Reader implements ItemModelReader<BundleSelectedItemModel> {
|
||||||
@Override
|
@Override
|
||||||
public ItemModel read(JsonObject json) {
|
public BundleSelectedItemModel read(JsonObject json) {
|
||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user