package net.glowstone.block.blocktype;

import net.glowstone.block.GlowBlock;
import net.glowstone.block.GlowBlockState;
import net.glowstone.block.entity.BlockEntity;
import net.glowstone.block.entity.SignEntity;
import net.glowstone.chunk.GlowChunk;
import net.glowstone.entity.GlowPlayer;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.Sign;
import org.bukkit.util.Vector;

public class BlockSign extends BlockType {

    public BlockSign() {
        setDrops(new ItemStack(Material.SIGN));
    }

    @Override
    public BlockEntity createBlockEntity(GlowChunk chunk, int cx, int cy, int cz) {
        return new SignEntity(chunk.getBlock(cx, cy, cz));
    }

    @Override
    public void placeBlock(GlowPlayer player, GlowBlockState state, BlockFace face, ItemStack holding, Vector clickedLoc) {
        state.setType(getMaterial());
        if (!(state.getData() instanceof Sign)) {
            warnMaterialData(Sign.class, state.getData());
            return;
        }
        Sign sign = (Sign) state.getData();
        sign.setFacingDirection(sign.isWallSign() ? face : player.getFacing().getOppositeFace());
    }

    @Override
    public void afterPlace(GlowPlayer player, GlowBlock block, ItemStack holding, GlowBlockState oldState) {
        player.openSignEditor(block.getLocation());
    }
}

@@ -1196,32 +1196,849 @@
 Face());%0A    %7D%0A%0A
+    @Override%0A    public void onNearBlockChanged(GlowBlock block, BlockFace face, GlowBlock changedBlock, Material oldType, byte oldData, Material newType, byte newData) %7B%0A        super.onNearBlockChanged(block, face, changedBlock, oldType, oldData, newType, newData);%0A        GlowBlockState state = block.getState();%0A        if (!(state.getData() instanceof Sign)) %7B%0A            warnMaterialData(Sign.class, state.getData());%0A            return;%0A        %7D%0A        Sign sign = (Sign) state.getData();%0A        if (!newType.isSolid() && block.getRelative(sign.getAttachedFace()).equals(changedBlock)) %7B%0A            destroy(block);%0A        %7D%0A    %7D%0A%0A    private void destroy(GlowBlock me) %7B%0A        me.setType(Material.AIR);%0A        me.getWorld().dropItemNaturally(me.getLocation(), new ItemStack(Material.SIGN));%0A    %7D%0A%0A
     @Override%0A  

Break sign when attached block is broken (partial #370)