Advertisement
Guest User

Untitled

a guest
Feb 25th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. package com.cwok.main;
  2.  
  3. import java.util.Random;
  4.  
  5. import org.bukkit.Effect;
  6. import org.bukkit.Location;
  7. import org.bukkit.entity.Entity;
  8. import org.bukkit.entity.Player;
  9. import org.bukkit.event.EventHandler;
  10. import org.bukkit.event.Listener;
  11. import org.bukkit.event.entity.EntityDamageEvent;
  12. import org.bukkit.plugin.java.JavaPlugin;
  13.  
  14. public class Main extends JavaPlugin implements Listener{
  15.  
  16. public static void main(String[] args) {
  17. // TODO Auto-generated method stub
  18. }
  19.  
  20. public void onEnable() {
  21. getServer().getPluginManager().registerEvents(this, this);
  22. }
  23.  
  24. @EventHandler
  25. public void onPlayerDamageEvent(EntityDamageEvent event) {
  26. Entity attacked = event.getEntity();
  27. Entity attacker = event.getEntity();
  28. int n = 0;
  29. Random rand = new Random();
  30. for(n=0; n<4; n++) {
  31. if ((attacked instanceof Player)&&(attacker instanceof Player)) {
  32. Location location = attacked.getLocation();
  33.  
  34. double xadd = (rand.nextDouble()-0.5);
  35. double yadd = (rand.nextDouble()+1);
  36. double zadd = (rand.nextDouble()-0.5);
  37.  
  38. location.add(xadd, yadd, zadd);
  39. (attacked.getWorld()).playEffect(location, Effect.COLOURED_DUST, Integer.MAX_VALUE);
  40. }
  41. }
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement