Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main extends JavaPlugin implements Listener{
- @Override
- public void onEnable() {
- getServer().getPluginManager().registerEvents(this, this);
- }
- @EventHandler
- public void onInteract(PlayerInteractEvent e){
- Player p = e.getPlayer();
- ItemStack ihand = p.getItemInHand();
- Action a = e.getAction();
- byte data = (byte) ihand.getDurability();
- if(a == Action.RIGHT_CLICK_AIR){
- FallingBlock fb = p.getWorld().spawnFallingBlock(p.getLocation().getBlock().getRelative(0,1,0).getLocation(), ihand.getType(), data);
- fb.setDropItem(false);
- fb.setVelocity(p.getLocation().getDirection().multiply(1D));
- ItemStack is = ihand;
- is.setDurability(ihand.getDurability());
- p.getInventory().remove(is);
- p.updateInventory();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment