Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.chickenstyle.dragon;
- import java.util.Arrays;
- import org.bukkit.ChatColor;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.configuration.file.FileConfiguration;
- import org.bukkit.entity.EnderDragon;
- import org.bukkit.entity.LivingEntity;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.block.Action;
- import org.bukkit.event.player.PlayerInteractEvent;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.inventory.meta.ItemMeta;
- public class DragonsListener implements Listener {
- @SuppressWarnings("deprecation")
- @EventHandler
- public void Interact(PlayerInteractEvent e) {
- FileConfiguration config = Main.config.getConfig();
- Player player = e.getPlayer();
- Location loc = e.getClickedBlock().getLocation();
- String Worldname = config.getString("Word");
- if (e.getAction() == Action.RIGHT_CLICK_BLOCK || e.getAction() == Action.LEFT_CLICK_BLOCK) {
- player.sendMessage(Worldname);
- if (player.getLocation().getWorld().getName().equals(config.getString("end_world_name"))) {
- if (e.getClickedBlock().getType() == Material.DIAMOND_BLOCK) {
- //Summon Item
- ItemStack star = new ItemStack(Material.NETHER_STAR);
- ItemMeta meta = star.getItemMeta();
- meta.setDisplayName(ChatColor.GOLD + "Dragon's Summoning Crystal");
- meta.setLore(Arrays.asList(ChatColor.WHITE + "Click with this on",ChatColor.WHITE + "dragon's egg and",ChatColor.WHITE + "dragon will spawn!"));
- star.setItemMeta(meta);
- if (player.getItemInHand() == star) {
- e.setCancelled(true);
- loc.getWorld().strikeLightning(loc);
- loc.getWorld().strikeLightning(loc);
- loc.getBlock().setType(null);
- EnderDragon dragon = loc.getWorld().spawn(loc.add(0, 30, 0), EnderDragon.class);
- ((LivingEntity) dragon).setAI(true);
- dragon.setMaxHealth(config.getInt("dragon_health"));
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement