Advertisement
danik159

Untitled

Sep 22nd, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 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. String Worldname = config.getString("Word");
  28. if (e.getAction() == Action.RIGHT_CLICK_BLOCK || e.getAction() == Action.LEFT_CLICK_BLOCK) {
  29. player.sendMessage(Worldname);
  30. if (player.getLocation().getWorld().getName().equals(config.getString("end_world_name"))) {
  31. if (e.getClickedBlock().getType() == Material.DIAMOND_BLOCK) {
  32. //Summon Item
  33. ItemStack star = new ItemStack(Material.NETHER_STAR);
  34. ItemMeta meta = star.getItemMeta();
  35. meta.setDisplayName(ChatColor.GOLD + "Dragon's Summoning Crystal");
  36. meta.setLore(Arrays.asList(ChatColor.WHITE + "Click with this on",ChatColor.WHITE + "dragon's egg and",ChatColor.WHITE + "dragon will spawn!"));
  37. star.setItemMeta(meta);
  38. if (player.getItemInHand() == star) {
  39. e.setCancelled(true);
  40. loc.getWorld().strikeLightning(loc);
  41. loc.getWorld().strikeLightning(loc);
  42. loc.getBlock().setType(null);
  43. EnderDragon dragon = loc.getWorld().spawn(loc.add(0, 30, 0), EnderDragon.class);
  44. ((LivingEntity) dragon).setAI(true);
  45. dragon.setMaxHealth(config.getInt("dragon_health"));
  46. }
  47. }
  48. }
  49. }
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement