Deny Piston/Sticky Piston from pushing blocks.

Discussion in 'Spigot Plugin Help' started by Therobodavo, Jun 14, 2015.

  1. Can someone be so kind to help me with something so simple.

    I just want pistons/stickypistons to not be able to push Sponges/Wet Sponges.

    That's all.

    I was told this is super easy and quick to do, so does anyone think they can do this?
     
  2. Can make this for you
     
  3. Sweet
     
  4. Can you code? Because it's only like one Event that you have to cancel
     
  5. Yes I can code lol but I've never really made a plugin other than something where you just type a command in and it says something in chat.
     
  6. So? If someone could just help me do this I could actually create the plugin. As I've said, I've never done something like this that affects a mechanic in the server.
     
  7. Try this:
    Code (Text):

    public class NoPiston extends JavaPlugin implements Listener{
     
        @Override
        public void onEnable() {
         
            Bukkit.getPluginManager().registerEvents(this, this);
         
        }
     
        @EventHandler
        public void onPiston(BlockPistonExtendEvent event){
         
            if(event.getBlock().getType() == Material.SPONGE){
             
                event.setCancelled(true);
             
            }
         
        }
     
       @EventHandler
        public void onPiston(BlockPistonRetractEvent event){
         
            if(event.getBlock().getType() == Material.SPONGE){
             
                event.setCancelled(true);
             
            }
        }

    }
    Not sure if it works for wet sponge, it has a different data value but youll have to try