danik159

Untitled

Sep 29th, 2019
180
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.chickenstyle.dragon;
  2.  
  3. import java.util.Arrays;
  4.  
  5. import org.bukkit.ChatColor;
  6. import org.bukkit.Location;
  7. import org.bukkit.Material;
  8. import org.bukkit.configuration.file.FileConfiguration;
  9. import org.bukkit.entity.EnderDragon;
  10. import org.bukkit.entity.LivingEntity;
  11. import org.bukkit.entity.Player;
  12. import org.bukkit.event.EventHandler;
  13. import org.bukkit.event.Listener;
  14. import org.bukkit.event.block.Action;
  15. import org.bukkit.event.player.PlayerInteractEvent;
  16. import org.bukkit.inventory.ItemStack;
  17. import org.bukkit.inventory.meta.ItemMeta;
  18.  
  19.  
  20. public class DragonsListener implements Listener {
  21. @SuppressWarnings("deprecation")
  22. @EventHandler
  23. public void Interact(PlayerInteractEvent e) {
  24. FileConfiguration config = Main.config.getConfig();
  25. Player player = e.getPlayer();
  26. Location loc = e.getClickedBlock().getLocation();
  27.  
  28. //Summon Item
  29. ItemStack star = new ItemStack(Material.NETHER_STAR);
  30. ItemMeta meta = star.getItemMeta();
  31. meta.setDisplayName(ChatColor.GOLD + "Dragon's Summoning Crystal");
  32. meta.setLore(Arrays.asList(ChatColor.WHITE + "Click with this on",ChatColor.WHITE + "dragon's egg and",ChatColor.WHITE + "dragon will spawn!"));
  33. star.setItemMeta(meta);
  34.  
  35. if (e.getAction() == Action.RIGHT_CLICK_BLOCK || e.getAction() == Action.LEFT_CLICK_BLOCK) {
  36. if (e.getClickedBlock().getType() == Material.DIAMOND_BLOCK) {
  37. if (player.getLocation().getWorld().getName().equals(config.getString("end_world_name"))) {
  38. if (player.getItemInHand().getType() == Material.NETHER_STAR) {
  39. if (player.getItemInHand().getItemMeta().getDisplayName().equals(ChatColor.GOLD + "Dragon's Summoning Crystal")) {
  40. player.sendMessage("1");
  41. e.setCancelled(true);
  42. loc.getWorld().strikeLightning(loc);
  43. loc.getWorld().strikeLightning(loc);
  44. loc.getBlock().setType(Material.AIR);
  45. EnderDragon dragon = loc.getWorld().spawn(loc.add(0, 30, 0), EnderDragon.class);
  46. ((LivingEntity) dragon).setAI(true);
  47. dragon.setMaxHealth(config.getInt("dragon_health"));
  48. }
  49. }
  50. }
  51. }
  52. }
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment