Vinetos

CREER UN PLUGIN BUKKIT #29 - FallingBlocks

Apr 22nd, 2015
411
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. public class Main extends JavaPlugin implements Listener{
  2.  
  3.  
  4. @Override
  5. public void onEnable() {
  6. getServer().getPluginManager().registerEvents(this, this);
  7. }
  8.  
  9. @EventHandler
  10. public void onInteract(PlayerInteractEvent e){
  11. Player p = e.getPlayer();
  12. ItemStack ihand = p.getItemInHand();
  13. Action a = e.getAction();
  14. byte data = (byte) ihand.getDurability();
  15. if(a == Action.RIGHT_CLICK_AIR){
  16. FallingBlock fb = p.getWorld().spawnFallingBlock(p.getLocation().getBlock().getRelative(0,1,0).getLocation(), ihand.getType(), data);
  17. fb.setDropItem(false);
  18. fb.setVelocity(p.getLocation().getDirection().multiply(1D));
  19.  
  20. ItemStack is = ihand;
  21. is.setDurability(ihand.getDurability());
  22. p.getInventory().remove(is);
  23. p.updateInventory();
  24.  
  25. }
  26.  
  27.  
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment