Onenrico

Jicko

Dec 29th, 2017
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. package com.gmail.JyckoSianjaya;
  2.  
  3. import org.bukkit.Sound;
  4. import org.bukkit.entity.Entity;
  5. import org.bukkit.entity.Giant;
  6. import org.bukkit.entity.Player;
  7. import org.bukkit.event.EventHandler;
  8. import org.bukkit.event.Listener;
  9. import org.bukkit.event.entity.EntityDamageByEntityEvent;
  10. import org.bukkit.plugin.java.JavaPlugin;
  11.  
  12. import net.md_5.bungee.api.ChatColor;
  13.  
  14. public class Domin extends JavaPlugin implements Listener {
  15. public void onEnable() {
  16. getLogger().info(ChatColor.translateAlternateColorCodes('&', "&e&lEnabled the Plugin!"));
  17. getServer().getPluginManager().registerEvents(this, this);
  18. }
  19. public void onDisable() {
  20. getLogger().info(ChatColor.translateAlternateColorCodes('&', "Succesfully disabled the plugin"));
  21. }
  22.  
  23. public void sendMsg(Player player, String msg){
  24. player.sendMessage(ChatColor.translateAlternateColorCodes('&', msg));
  25. }
  26. public void play(Player player, Sound sound){
  27. player.playSound(player.getLocation(), sound, 2F, 1F);
  28. }
  29. @EventHandler
  30. public void GiantDmg(EntityDamageByEntityEvent event) {
  31. Entity victim = event.getEntity();
  32. Entity damager = event.getDamager();
  33. if (victim instanceof Giant) {
  34. Giant giant = (Giant) victim;
  35. Player player = null;
  36. if (damager instanceof Player) {
  37. player = (Player) damager;
  38. }
  39. else if(damager instanceof Arrow){
  40. Arrow arrow = (Arrow) damager;
  41. if(arrow.getShooter() instanceof Player){
  42. player = (Player) arrow.getShooter()
  43. }
  44. }
  45. if(player != null){
  46. event.setCancelled(true);
  47. int xp = player.getLevel() + 1;
  48. player.setLevel(xp);
  49. Double health = giant.getHealth() - 0.5;
  50. giant.setHealth(health);
  51. sendMsg(player, "&aYou took &f1 &alevel from the Giant!");
  52. play(player, Sound.ENTITY_CHICKEN_HURT);
  53. play(player, Sound.ENTITY_EXPERIENCE_ORB_PICKUP);
  54. }
  55.  
  56. }
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment