Solved "Benches" not functioning correctly

Discussion in 'Plugin Help/Development/Requests' started by BizarrePlatinum, Apr 7, 2015.

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

    BizarrePlatinum

    Code:
    @EventHandler
        public void onSit(PlayerInteractEvent e) {
            Player p = e.getPlayer();
            Block b = e.getClickedBlock();
         
            if(!p.hasMetadata("sitting")) {
                p.setMetadata("sitting", new FixedMetadataValue(this, false));
            }
    
            if(!p.getMetadata("sitting").get(0).asBoolean() == true) {
                if(b != null) {
                    if(b.getType().equals(Material.ACACIA_STAIRS) || b.getType().equals(Material.BIRCH_WOOD_STAIRS) || b.getType().equals(Material.DARK_OAK_STAIRS) || b.getType().equals(Material.JUNGLE_WOOD_STAIRS) || b.getType().equals(Material.WOOD_STAIRS)) {
                        Entity a = Bukkit.getServer().getWorld("world").spawnEntity(b.getLocation(), EntityType.ARROW);
                        a.setPassenger(p);
                        p.setMetadata("sitting", new FixedMetadataValue(this, true));
                        p.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 100000, 0));
                    }
                }
            }
        }
     
        @EventHandler
        public void onMove(PlayerMoveEvent e) {
            Player p = e.getPlayer();
         
           
    if(!p.hasMetadata("sitting")) {
                p.setMetadata("sitting", new FixedMetadataValue(this, false));
            }
    
            if(p.getMetadata("sitting").get(0).asBoolean() == true) {
                p.getVehicle().eject();
                p.setMetadata("sitting", new FixedMetadataValue(this, false));
                p.removePotionEffect(PotionEffectType.INVISIBILITY);
            }
        }
    
    I am attempting to spawn an arrow in the block, should it be one of those stairs, then set the passenger of that arrow to the player. Then, if they attempt to move, they should be ejected. However, they are not functioning right, both giving errors. Could someone shed some light on what I am doing wrong here?

    EDIT -- nvm, I forgot to add the world (I'm dumb) .
     
    Last edited: Apr 7, 2015
Thread Status:
Not open for further replies.

Share This Page