org.bukkit.entity.EnderDragon Java Examples

The following examples show how to use org.bukkit.entity.EnderDragon. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EnderDragonEvent.java    From SkyWarsReloaded with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void endEvent(boolean force) {
	if (fired) {
		if (force && length != -1) {
			br.cancel();
		}
		World world = gMap.getCurrentWorld();
		for (Entity ent: world.getEntities()) {
			if (ent instanceof EnderDragon) {
				ent.remove();
				break;
			}
		}
		if (gMap.getMatchState() == MatchState.PLAYING) {
			MatchManager.get().message(gMap, ChatColor.translateAlternateColorCodes('&', endMessage));
		}
		if (repeatable || force) {
			setStartTime();
			this.startTime = this.startTime + gMap.getTimer();
			this.fired = false;
		}
	}
}
 
Example #2
Source File: ControllableEnderDragonBase.java    From EntityAPI with GNU Lesser General Public License v3.0 6 votes vote down vote up
public ControllableEnderDragonBase(int id, EntityManager manager) {
    super(id, ControllableEntityType.ENDERDRAGON, manager);
    Bukkit.getPluginManager().registerEvents(new Listener() {

        @EventHandler
        public void onEntityExplode(EntityExplodeEvent event) {
            if (!shouldDestroyBlocks()) {
                Entity entity = event.getEntity();
                if (entity instanceof EnderDragon && entity.equals(getBukkitEntity())) {
                    event.setCancelled(true);
                } else if (entity instanceof ComplexEntityPart && ((ComplexEntityPart) entity).getParent().equals(getBukkitEntity())) {
                    event.setCancelled(true);
                }
            }
        }

    }, EntityAPI.getCore());
}
 
Example #3
Source File: EvtDamage.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("null")
@Override
public boolean check(final Event evt) {
	final EntityDamageEvent e = (EntityDamageEvent) evt;
	if (!checkType(e.getEntity()))
		return false;
	if (e instanceof EntityDamageByEntityEvent && ((EntityDamageByEntityEvent) e).getDamager() instanceof EnderDragon && ((EntityDamageByEntityEvent) e).getEntity() instanceof EnderDragon)
		return false;
	return checkDamage(e);
}
 
Example #4
Source File: BeastmastersBow.java    From ce with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
	public boolean effect(Event event, Player player) {
//		  List<String> lore = e.getBow().getItemMeta().getLore();
//		  if(!lore.contains(placeHolder)) {
//			  for(int i = descriptionSize; i != 0; i--)
//				  lore.remove(i);
//			  e.getProjectile().setMetadata("ce." + this.getOriginalName(), new FixedMetadataValue(main, writeType(lore)));
//			  player.setMetadata("ce.CanUnleashBeasts", null);
//		  } else
//			  e.getProjectile().setMetadata("ce." + this.getOriginalName(), null);
		  if(event instanceof EntityDamageByEntityEvent) {
		  EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event;
		  if(e.getDamager() != player)
			  return false;
		  Entity ent = e.getEntity();
		  Location loc = ent.getLocation();
		  World w = ent.getWorld();
			if(ent instanceof Silverfish || ent instanceof EnderDragon || ent instanceof Spider || ent instanceof Slime || ent instanceof Ghast || ent instanceof MagmaCube || ent instanceof CaveSpider || (ent instanceof Wolf && ((Wolf) ent).isAngry()) || ent instanceof PigZombie) {
					e.setDamage(e.getDamage()*DamageMultiplication);
					w.playEffect(loc, Effect.SMOKE, 50);
					w.playEffect(loc, Effect.MOBSPAWNER_FLAMES, 50);
					EffectManager.playSound(loc, "BLOCK_PISTON_RETRACT", 1.3f, 3f);
				return true;
			} else if (ent instanceof Player) {
				for(int i = 0; i < MaximumMobs; i++) {
					if(rand.nextInt(100) < MobAppearanceChance) {
						w.spawnEntity(loc, rand.nextInt(2) == 1 ? EntityType.SPIDER : EntityType.SLIME);
						w.playEffect(loc, Effect.MOBSPAWNER_FLAMES, 30);
						w.playEffect(loc, Effect.SMOKE, 30);
						EffectManager.playSound(loc, "BLOCK_ANVIL_BREAK", 0.3f, 0.1f);
					}
				}
			}
		}
		  return false;
	}
 
Example #5
Source File: EnderDragonChangePhaseEvent.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public EnderDragonChangePhaseEvent(EnderDragon enderDragon, EnderDragon.Phase currentPhase, EnderDragon.Phase newPhase) {
    super(enderDragon);
    this.currentPhase = currentPhase;
    this.setNewPhase(newPhase);
}
 
Example #6
Source File: EnderDragonChangePhaseEvent.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@Override
public EnderDragon getEntity() {
    return (EnderDragon) entity;
}
 
Example #7
Source File: CraftEnderDragonPart.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@Override
public EnderDragon getParent() {
    return (EnderDragon) super.getParent();
}
 
Example #8
Source File: CraftEnderDragonPart.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
@Override
public EnderDragon getParent() {
    return (EnderDragon) super.getParent();
}
 
Example #9
Source File: EnderDragonChangePhaseEvent.java    From Kettle with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Gets the current phase that the dragon is in. This method will return null
 * when a dragon is first spawned and hasn't yet been assigned a phase.
 *
 * @return the current dragon phase
 */
public EnderDragon.Phase getCurrentPhase() {
    return currentPhase;
}
 
Example #10
Source File: EnderDragonChangePhaseEvent.java    From Kettle with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Gets the new phase that the dragon will switch to.
 *
 * @return the new dragon phase
 */
public EnderDragon.Phase getNewPhase() {
    return newPhase;
}
 
Example #11
Source File: EnderDragonChangePhaseEvent.java    From Kettle with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Sets the new phase for the ender dragon.
 *
 * @param newPhase the new dragon phase
 */
public void setNewPhase(EnderDragon.Phase newPhase) {
    Validate.notNull(newPhase, "New dragon phase cannot be null");
    this.newPhase = newPhase;
}