org.bukkit.entity.EnderCrystal Java Examples
The following examples show how to use
org.bukkit.entity.EnderCrystal.
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: Pickup.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
public void spawn() { Location location = data.region().getRandom(match.getRandom()).toLocation(world); effects(Sound.BLOCK_NOTE_BASEDRUM, Particle.CLOUD); Entity entity = world.spawn(location, (Class) data.appearance().getEntityClass()); entity.setKnockbackReduction(1); data.name().ifPresent(name -> { entity.setCustomName(ChatColor.translateAlternateColorCodes('`', name)); entity.setCustomNameVisible(true); }); switch(data.appearance()) { // TODO: Support more appearances later case ENDER_CRYSTAL: ifInstance(entity, EnderCrystal.class, crystal -> crystal.setShowingBottom(false)); break; case PRIMED_TNT: ifInstance(entity, TNTPrimed.class, tnt -> tnt.setFuseTicks(Integer.MAX_VALUE)); break; } this.entity = Optional.of(entity); spawnAt = Optional.empty(); }
Example #2
Source File: EntityEventHandler.java From GriefDefender with MIT License | 4 votes |
@EventHandler(priority = EventPriority.LOWEST) public void onExplosionPrimeEvent(ExplosionPrimeEvent event) { final World world = event.getEntity().getLocation().getWorld(); final Entity source = event.getEntity(); if (!GDFlags.EXPLOSION_BLOCK && !GDFlags.EXPLOSION_ENTITY) { return; } if (!GriefDefenderPlugin.getInstance().claimsEnabledForWorld(world.getUID())) { return; } if (source instanceof Creeper || source instanceof EnderCrystal) { return; } GDCauseStackManager.getInstance().pushCause(source); GDTimings.ENTITY_EXPLOSION_PRE_EVENT.startTiming(); final GDEntity gdEntity = EntityTracker.getCachedEntity(source.getEntityId()); GDPermissionUser user = null; if (gdEntity != null) { user = PermissionHolderCache.getInstance().getOrCreateUser(gdEntity.getOwnerUUID()); } final Location location = event.getEntity().getLocation(); final GDClaim radiusClaim = NMSUtil.getInstance().createClaimFromCenter(location, event.getRadius()); final GDClaimManager claimManager = GriefDefenderPlugin.getInstance().dataStore.getClaimWorldManager(location.getWorld().getUID()); final Set<Claim> surroundingClaims = claimManager.findOverlappingClaims(radiusClaim); if (surroundingClaims.size() == 0) { GDTimings.ENTITY_EXPLOSION_PRE_EVENT.stopTiming(); return; } for (Claim claim : surroundingClaims) { // Use any location for permission check final Vector3i pos = claim.getLesserBoundaryCorner(); Location targetLocation = new Location(location.getWorld(), pos.getX(), pos.getY(), pos.getZ()); Tristate blockResult = GDPermissionManager.getInstance().getFinalPermission(event, location, claim, Flags.EXPLOSION_BLOCK, source, targetLocation, user, true); if (blockResult == Tristate.FALSE) { // Check explosion entity if (GDPermissionManager.getInstance().getFinalPermission(event, location, claim, Flags.EXPLOSION_ENTITY, source, targetLocation, user, true) == Tristate.FALSE) { event.setCancelled(true); break; } } } GDTimings.ENTITY_EXPLOSION_PRE_EVENT.stopTiming(); }