Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. package me.kbz.runes;
  2.  
  3. import java.util.Random;
  4.  
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.ChatColor;
  7. import org.bukkit.Material;
  8. import org.bukkit.entity.Player;
  9. import org.bukkit.event.EventHandler;
  10. import org.bukkit.event.Listener;
  11. import org.bukkit.event.entity.EntityDamageByEntityEvent;
  12. import org.bukkit.plugin.java.JavaPlugin;
  13. import org.bukkit.potion.PotionEffect;
  14. import org.bukkit.potion.PotionEffectType;
  15.  
  16. public class Runes extends JavaPlugin implements Listener {
  17.  
  18. public void onEnable() {
  19. Bukkit.getPluginManager().registerEvents(this, this);
  20. }
  21.  
  22. @SuppressWarnings("deprecation")
  23. @EventHandler
  24. public void onEntityHitSlow(EntityDamageByEntityEvent event) {
  25. Random random = new Random();
  26. int Chance = random.nextInt(100);
  27. if (event.getDamager() instanceof Player && event.getEntity() instanceof Player && Chance <= 12) {
  28. Player attacker = (Player) event.getDamager();
  29. Player damaged = (Player) event.getEntity();
  30. if (attacker.getItemInHand().getTypeId() == Material.DIAMOND_SWORD.getId()) {
  31. PotionEffect potioneffect = new PotionEffect(PotionEffectType.SLOW, 75, 3);
  32. damaged.removePotionEffect(PotionEffectType.SPEED); //pizza added this
  33. potioneffect.apply(damaged);
  34. attacker.sendMessage(ChatColor.GRAY + "[" + ChatColor.RED + "Arena" + ChatColor.GRAY + "]"
  35. + ChatColor.YELLOW + " Your Rune of " + ChatColor.LIGHT_PURPLE + "Slowing" + ChatColor.YELLOW
  36. + " was activated! ");
  37. }
  38. }
  39. }
  40.  
  41. @SuppressWarnings("deprecation")
  42. @EventHandler
  43. public void onEntityHitSpeed(EntityDamageByEntityEvent event) {
  44. Random random = new Random();
  45. int Chance = random.nextInt(100);
  46. if (event.getDamager() instanceof Player && event.getEntity() instanceof Player && Chance <= 12) {
  47. Player attacker = (Player) event.getDamager();
  48. if (attacker.getItemInHand().getTypeId() == Material.DIAMOND_SWORD.getId()) {
  49. PotionEffect potioneffect = new PotionEffect(PotionEffectType.SPEED, 75, 2);
  50. attacker.removePotionEffect(PotionEffectType.SPEED);//pizza added this
  51. potioneffect.apply(attacker);
  52. attacker.sendMessage(
  53. ChatColor.GRAY + "[" + ChatColor.RED + "Arena" + ChatColor.GRAY + "]" + ChatColor.YELLOW
  54. + " Your Rune of " + ChatColor.WHITE + "Speed" + ChatColor.YELLOW + " was activated! ");
  55. }
  56. }
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement