Button and redstone

Discussion in 'Bukkit Help' started by mocswiatla320, Mar 23, 2020.

Thread Status:
Not open for further replies.
  1. Offline

    mocswiatla320

    Hello, can anyone help me with these buttons :p? The problem is that when you click the plaque the button clicks but does not light the redstone under this block! When redstone is next to it on the same level, everything works and redstone lights up! When I put the button in the game and click it, the redstone under the block lights up! Thank you in advance for any help!


    Code:
    @EventHandler
        public void onClick(PlayerInteractEvent event){
            if (event.getClickedBlock() == null) {
                return;
            }
            if (event.getAction() != Action.RIGHT_CLICK_BLOCK) {
                return;
            }
            if (event.getClickedBlock().getState() instanceof Sign){
                Sign sign = (Sign) event.getClickedBlock().getState();
                event.setCancelled(true);
                new BukkitRunnable(){
                    @Override
                    public void run() {
                        event.getClickedBlock().getLocation().getBlock().setBlockData(Bukkit.getUnsafe().fromLegacy(Material.OAK_BUTTON, (byte) 5), false);
                    }
                }.runTaskLater(Plugin.getPlugin(),1);
                new BukkitRunnable(){
                    @Override
                    public void run() {
                        if (event.getClickedBlock().getBlockData() instanceof Switch) {
                            final Switch button = (Switch) event.getClickedBlock().getBlockData();
                            button.setPowered(true);
                            event.getClickedBlock().setBlockData(button);
                        }
                    }
                }.runTaskLater(Plugin.getPlugin(),20);
                return;
            }
        }
    I'm using the spigot version 1.15.2
     
    Last edited: Mar 24, 2020
  2. Offline

    mocswiatla320

Thread Status:
Not open for further replies.

Share This Page