org.bukkit.entity.Creeper Java Examples
The following examples show how to use
org.bukkit.entity.Creeper.
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: GriefEvents.java From uSkyBlock with GNU General Public License v3.0 | 6 votes |
@EventHandler public void onCreeperExplode(ExplosionPrimeEvent event) { if (!creeperEnabled || !plugin.getWorldManager().isSkyWorld(event.getEntity().getWorld())) { return; } if (event.getEntity() instanceof Creeper && !isValidTarget(((Creeper)event.getEntity()).getTarget())) { event.setCancelled(true); } else if (event.getEntity() instanceof TNTPrimed) { TNTPrimed tntPrimed = (TNTPrimed) event.getEntity(); if (tntPrimed.getSource() instanceof Player && !isValidTarget(tntPrimed.getSource())) { event.setCancelled(true); } } }
Example #2
Source File: EffExplodeCreeper.java From Skript with GNU General Public License v3.0 | 6 votes |
@Override protected void execute(final Event e) { for (final LivingEntity le : entities.getArray(e)) { if (le instanceof Creeper) { if (instant) { ((Creeper) le).explode(); } else if (stop) { ((Creeper) le).setIgnited(false); } else { if (paper) { ((Creeper) le).setIgnited(true); } else { ((Creeper) le).ignite(); } } } } }
Example #3
Source File: Headless.java From ce with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void effect(Event e, ItemStack item, int level) { EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) e; final Player player = (Player) event.getDamager(); final LivingEntity ent = (LivingEntity) event.getEntity(); new BukkitRunnable() { @Override public void run() { if (ent.getHealth() <= 0) { byte type = 3; if (ent instanceof Skeleton) { type = 0; if (((Skeleton) ent).getSkeletonType().equals(SkeletonType.WITHER)) type = 1; } else if (ent instanceof Zombie) type = 2; else if (ent instanceof Creeper) type = 4; ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, type); if (type == 3) { SkullMeta sm = (SkullMeta) skull.getItemMeta(); sm.setOwner(ent.getName()); skull.setItemMeta(sm); } ent.getWorld().dropItem(ent.getLocation(), skull); EffectManager.playSound(player.getLocation(), "BLOCK_ANVIL_LAND", 0.1f, 1.5f); } } }.runTaskLater(getPlugin(), 5l); }
Example #4
Source File: MaterialManager.java From ObsidianDestroyer with GNU General Public License v3.0 | 5 votes |
/** * Returns the amount of damage done to the material by an entity * * @param entity the entity that is involved in damaging * @param material the name of the material to lookup * @param data * @return amount of damage done */ public int getDamageTypeAmount(Entity entity, String material, int data) { material = getMaterialName(material, data); if (durabilityMaterials.containsKey(material)) { EntityType eventTypeRep = entity.getType(); switch (eventTypeRep) { case PRIMED_TNT: return durabilityMaterials.get(material).getTntDamage(); case SNOWBALL: return 0; case CREEPER: Creeper creeper = (Creeper) entity; return creeper.isPowered() ? durabilityMaterials.get(material).getChargedCreeperDamage() : durabilityMaterials.get(material).getCreepersDamage(); case WITHER: case WITHER_SKULL: return durabilityMaterials.get(material).getWithersDamage(); case MINECART_TNT: return durabilityMaterials.get(material).getTntMinecartsDamage(); case FIREBALL: case SMALL_FIREBALL: case GHAST: return durabilityMaterials.get(material).getGhastsDamage(); case BAT: return durabilityMaterials.get(material).getNullDamage(); case ENDER_CRYSTAL: return durabilityMaterials.get(material).getEnderCrystalDamage(); default: break; } } return 1; }
Example #5
Source File: SwordOfBeheading.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
@Override public EntityKillHandler getItemHandler() { return (e, entity, killer, item) -> { Random random = ThreadLocalRandom.current(); if (e.getEntity() instanceof Zombie) { if (random.nextInt(100) < chanceZombie.getValue()) { e.getDrops().add(new ItemStack(Material.ZOMBIE_HEAD)); } } else if (e.getEntity() instanceof WitherSkeleton) { if (random.nextInt(100) < chanceWitherSkeleton.getValue()) { e.getDrops().add(new ItemStack(Material.WITHER_SKELETON_SKULL)); } } else if (e.getEntity() instanceof Skeleton) { if (random.nextInt(100) < chanceSkeleton.getValue()) { e.getDrops().add(new ItemStack(Material.SKELETON_SKULL)); } } else if (e.getEntity() instanceof Creeper) { if (random.nextInt(100) < chanceCreeper.getValue()) { e.getDrops().add(new ItemStack(Material.CREEPER_HEAD)); } } else if (e.getEntity() instanceof Player && random.nextInt(100) < chancePlayer.getValue()) { ItemStack skull = new ItemStack(Material.PLAYER_HEAD); ItemMeta meta = skull.getItemMeta(); ((SkullMeta) meta).setOwningPlayer((Player) e.getEntity()); skull.setItemMeta(meta); e.getDrops().add(skull); } }; }
Example #6
Source File: EffChargeCreeper.java From Skript with GNU General Public License v3.0 | 5 votes |
@Override protected void execute(Event e) { for (LivingEntity le : entities.getArray(e)) { if (le instanceof Creeper) ((Creeper) le).setPowered(charge); } }
Example #7
Source File: ExprCreeperMaxFuseTicks.java From Skript with GNU General Public License v3.0 | 4 votes |
@Override public Number convert(LivingEntity e) { return e instanceof Creeper ? ((Creeper) e).getMaxFuseTicks() : 0; }
Example #8
Source File: IslandGuard.java From askyblock with GNU General Public License v2.0 | 4 votes |
/** * Prevents the breakage of hanging items * * @param e - event */ @EventHandler(priority = EventPriority.LOW) public void onBreakHanging(final HangingBreakByEntityEvent e) { if (DEBUG) { plugin.getLogger().info(e.getEventName()); plugin.getLogger().info(e.getRemover().toString()); } if (inWorld(e.getEntity())) { if ((e.getRemover() instanceof Creeper) && !Settings.allowCreeperDamage) { e.setCancelled(true); return; } // Check if creeper griefing is allowed if ((e.getRemover() instanceof Creeper) && !Settings.allowCreeperGriefing) { // Find out who the creeper was targeting Creeper creeper = (Creeper)e.getRemover(); if (creeper.getTarget() instanceof Player) { Player target = (Player)creeper.getTarget(); // Check if the target is on their own island or not if (!plugin.getGrid().locationIsOnIsland(target, e.getEntity().getLocation())) { // They are a visitor tsk tsk e.setCancelled(true); return; } } // Check if this creeper was lit by a visitor if (litCreeper.contains(creeper.getUniqueId())) { if (DEBUG) { plugin.getLogger().info("DBEUG: preventing creeper from damaging"); } e.setCancelled(true); return; } } if (e.getRemover() instanceof Player) { Player p = (Player) e.getRemover(); // This permission bypasses protection if (p.isOp() || VaultHelper.checkPerm(p, Settings.PERMPREFIX + "mod.bypassprotect")) { return; } if (actionAllowed(p,e.getEntity().getLocation(),SettingsFlag.BREAK_BLOCKS)) { return; } // Not allowed Util.sendMessage(p, ChatColor.RED + plugin.myLocale(p.getUniqueId()).islandProtected); e.setCancelled(true); } } }
Example #9
Source File: CraftEventFactory.java From Thermos with GNU General Public License v3.0 | 4 votes |
public static CreeperPowerEvent callCreeperPowerEvent(net.minecraft.entity.Entity creeper, net.minecraft.entity.Entity lightning, CreeperPowerEvent.PowerCause cause) { CreeperPowerEvent event = new CreeperPowerEvent((Creeper) creeper.getBukkitEntity(), (LightningStrike) lightning.getBukkitEntity(), cause); creeper.getBukkitEntity().getServer().getPluginManager().callEvent(event); return event; }
Example #10
Source File: EntityCreeperPet.java From SonarPet with GNU General Public License v3.0 | 4 votes |
@Override public Creeper getBukkitEntity() { return (Creeper) super.getBukkitEntity(); }
Example #11
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(); }
Example #12
Source File: CondIgnitionProcess.java From Skript with GNU General Public License v3.0 | 4 votes |
@Override public boolean check(LivingEntity e) { return e instanceof Creeper && ((Creeper) e).isIgnited(); }
Example #13
Source File: CondIsCharged.java From Skript with GNU General Public License v3.0 | 4 votes |
@Override public boolean check(final LivingEntity e) { if (e instanceof Creeper) return ((Creeper) e).isPowered(); return false; }
Example #14
Source File: CreeperData.java From Skript with GNU General Public License v3.0 | 4 votes |
@Override public Class<Creeper> getType() { return Creeper.class; }
Example #15
Source File: CreeperData.java From Skript with GNU General Public License v3.0 | 4 votes |
@Override public boolean match(final Creeper entity) { return powered == 0 || entity.isPowered() == (powered == 1); }
Example #16
Source File: CreeperData.java From Skript with GNU General Public License v3.0 | 4 votes |
@Override public void set(final Creeper c) { if (powered != 0) c.setPowered(powered == 1); }
Example #17
Source File: CreeperData.java From Skript with GNU General Public License v3.0 | 4 votes |
@Override protected boolean init(final @Nullable Class<? extends Creeper> c, final @Nullable Creeper e) { powered = e == null ? 0 : e.isPowered() ? 1 : -1; return true; }
Example #18
Source File: CreeperPowerEvent.java From Kettle with GNU General Public License v3.0 | 4 votes |
@Override public Creeper getEntity() { return (Creeper) entity; }
Example #19
Source File: CreeperPowerEvent.java From Kettle with GNU General Public License v3.0 | 4 votes |
public CreeperPowerEvent(final Creeper creeper, final PowerCause cause) { super(creeper); this.cause = cause; }
Example #20
Source File: CreeperPowerEvent.java From Kettle with GNU General Public License v3.0 | 4 votes |
public CreeperPowerEvent(final Creeper creeper, final LightningStrike bolt, final PowerCause cause) { this(creeper, cause); this.bolt = bolt; }