Advertisement
Guest User

Untitled

a guest
Jan 5th, 2014
387
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Main extends JavaPlugin{
  2.  
  3. public final static HashMap<Entity, EntityData> shotprojectiledata = new HashMap<Entity, EntityData>();
  4.  
  5. public class EntityData {
  6. private Location firedfrom;
  7. private Integer range;
  8. private Double damage;
  9. public EntityData(Location loc, Integer range, Double damage) {
  10. this.firedfrom = loc;
  11. this.range = range;
  12. this.damage = damage;
  13. }
  14. public Location getFiredFrom() {
  15. return firedfrom;
  16. }
  17. public Integer getRange() {
  18. return range;
  19. }
  20. public Double getDamage() {
  21. return damage;
  22. }
  23. }
  24. public void onEnable() {
  25. getLogger().info("wow much enable :^]");
  26. }
  27.  
  28. public void onDisable() {
  29. getLogger().info("wow many disable doge sad :c");
  30. }
  31.  
  32.  
  33. @EventHandler
  34. public void onHit(EntityDamageByEntityEvent event) {
  35. if (event.getDamager() instanceof Snowball) {
  36. if (shotprojectiledata.containsKey(event.getDamager())) {
  37. EntityData eventdata = shotprojectiledata.get(event.getDamager());
  38. if (event.getEntity().getLocation().distance(eventdata.getFiredFrom())<=eventdata.getRange()) {
  39. event.setDamage(eventdata.getDamage());
  40. shotprojectiledata.remove(event.getDamager());
  41. }
  42. }
  43. }
  44. }
  45. @EventHandler
  46. public void eva (PlayerInteractEvent e) {
  47. /*
  48. I would recommend putting stuff in here to check if the are right clicking air, holding a certain item, or whatever you want.
  49. */
  50. Location location = player.getEyeLocation();
  51. BlockIterator blocksToAdd = new BlockIterator(location, 0D, 15);
  52. Location blockToAdd;
  53. while(blocksToAdd.hasNext()) {
  54. if (blockToAdd.getBlock().getType() != Material.AIR ||!shotprojectiledata.containsKey(projectile)) {
  55. break;
  56. }
  57. blockToAdd = blocksToAdd.next().getLocation();
  58. player.getWorld().playEffect(blockToAdd, Effect.STEP_SOUND, Material.FIRE);
  59. }
  60. Snowball projectile = player.launchProjectile(Snowball.class);
  61. EntityData data = new EntityData(projectile.getLocation(), 15, 5D);
  62. shotprojectiledata.put(projectile, data);
  63. for (Player p : Bukkit.getOnlinePlayers()) {
  64. ((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityDestroy(((CraftSnowball) projectile).getHandle().getId()));
  65. }
  66. }
Advertisement
RAW Paste Data Copied
Advertisement