Lexepi

Untitled

Nov 5th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. package SheepWars;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.Material;
  5. import org.bukkit.entity.Player;
  6. import org.bukkit.entity.Sheep;
  7. import org.bukkit.event.EventHandler;
  8. import org.bukkit.event.Listener;
  9. import org.bukkit.event.block.Action;
  10. import org.bukkit.event.player.PlayerInteractEvent;
  11. import org.bukkit.plugin.java.JavaPlugin;
  12.  
  13.  
  14.  
  15. public class SheepWars extends JavaPlugin implements Listener{
  16.  
  17.  
  18. public void onEnable(){
  19. Bukkit.getPluginManager().registerEvents(this, this);
  20.  
  21. }
  22.  
  23.  
  24. @EventHandler
  25. public void onPlayerInteract(PlayerInteractEvent e){
  26. Player p = e.getPlayer();
  27.  
  28. if(e.getItem().getType() == Material.WOOL){
  29.  
  30. if(p.getItemInHand().getItemMeta().getDisplayName().equalsIgnoreCase("Mouton d'Abordage")){
  31.  
  32. if(e.getAction() == Action.RIGHT_CLICK_AIR){
  33.  
  34. p.getLocation().getDirection();
  35. Sheep sheep = (Sheep) p.getWorld().spawn(p.getLocation(), Sheep.class);
  36. sheep.setVelocity(p.getLocation().getDirection().normalize().multiply(6D));
  37. sheep.setPassenger(p);
  38.  
  39.  
  40.  
  41. }else if(e.getAction() == Action.RIGHT_CLICK_BLOCK){
  42.  
  43. e.setCancelled(true);
  44. p.getLocation().getDirection();
  45. Sheep sheep = (Sheep) p.getWorld().spawn(p.getLocation(), Sheep.class);
  46. sheep.setVelocity(p.getLocation().getDirection().normalize().multiply(6D));
  47. sheep.setPassenger(p);
  48. }
  49. }else{
  50. return;
  51. }
  52. }
  53. }
  54.  
  55. }
Advertisement
Add Comment
Please, Sign In to add comment