org.bukkit.entity.Slime Java Examples
The following examples show how to use
org.bukkit.entity.Slime.
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: LimitLogic.java From uSkyBlock with GNU General Public License v3.0 | 6 votes |
public CreatureType getCreatureType(EntityType entityType) { if (Monster.class.isAssignableFrom(entityType.getEntityClass()) || WaterMob.class.isAssignableFrom(entityType.getEntityClass()) || Slime.class.isAssignableFrom(entityType.getEntityClass()) || Ghast.class.isAssignableFrom(entityType.getEntityClass()) ) { return CreatureType.MONSTER; } else if (Animals.class.isAssignableFrom(entityType.getEntityClass())) { return CreatureType.ANIMAL; } else if (Villager.class.isAssignableFrom(entityType.getEntityClass())) { return CreatureType.VILLAGER; } else if (Golem.class.isAssignableFrom(entityType.getEntityClass())) { return CreatureType.GOLEM; } return CreatureType.UNKNOWN; }
Example #2
Source File: OwnedMobTracker.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onSlimeSplit(CreatureSpawnEvent event) { switch (event.getSpawnReason()) { case SLIME_SPLIT: Slime parent = splitter.get(); if (parent != null) { MobInfo info = resolveEntity(parent); if (info != null) { entities().trackEntity(event.getEntity(), info); } } break; } }
Example #3
Source File: OwnedMobTracker.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onSlimeSplit(CreatureSpawnEvent event) { switch(event.getSpawnReason()) { case SLIME_SPLIT: Slime parent = splitter.get(); if(parent != null) { MobInfo info = resolveEntity(parent); if(info != null) { entities().trackEntity(event.getEntity(), info); } } break; } }
Example #4
Source File: SlimeTrait.java From StackMob-3 with GNU General Public License v3.0 | 5 votes |
@Override public boolean checkTrait(Entity original, Entity nearby) { if(original instanceof Slime){ return (((Slime) original).getSize() != ((Slime) nearby).getSize()); } return false; }
Example #5
Source File: LimitLogic.java From uSkyBlock with GNU General Public License v3.0 | 5 votes |
public CreatureType getCreatureType(LivingEntity creature) { if (creature instanceof Monster || creature instanceof WaterMob || creature instanceof Slime || creature instanceof Ghast) { return CreatureType.MONSTER; } else if (creature instanceof Animals) { return CreatureType.ANIMAL; } else if (creature instanceof Villager) { return CreatureType.VILLAGER; } else if (creature instanceof Golem) { return CreatureType.GOLEM; } return CreatureType.UNKNOWN; }
Example #6
Source File: BeastmastersBow.java From ce with GNU Lesser General Public License v3.0 | 5 votes |
@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 #7
Source File: SlimeSplitEvent.java From Kettle with GNU General Public License v3.0 | 4 votes |
public SlimeSplitEvent(final Slime slime, final int count) { super(slime); this.count = count; }
Example #8
Source File: SlimeSplitEvent.java From Kettle with GNU General Public License v3.0 | 4 votes |
@Override public Slime getEntity() { return (Slime) entity; }
Example #9
Source File: SlimeTrait.java From StackMob-3 with GNU General Public License v3.0 | 4 votes |
@Override public void applyTrait(Entity original, Entity spawned) { if(original instanceof Slime){ ((Slime) spawned).setSize(((Slime) original).getSize()); } }
Example #10
Source File: AbstractEntitySlimePet.java From SonarPet with GNU General Public License v3.0 | 4 votes |
@Override public Slime getBukkitEntity() { return (Slime) super.getBukkitEntity(); }
Example #11
Source File: IslandGuard1_9.java From askyblock with GNU General Public License v2.0 | 4 votes |
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true) public void onLingeringPotionDamage(final EntityDamageByEntityEvent e) { if (!IslandGuard.inWorld(e.getEntity().getLocation())) { return; } if (e.getEntity() == null || e.getEntity().getUniqueId() == null) { return; } if (e.getCause().equals(DamageCause.ENTITY_ATTACK) && thrownPotions.containsKey(e.getDamager().getEntityId())) { UUID attacker = thrownPotions.get(e.getDamager().getEntityId()); // Self damage if (attacker.equals(e.getEntity().getUniqueId())) { return; } Island island = plugin.getGrid().getIslandAt(e.getEntity().getLocation()); boolean inNether = false; if (e.getEntity().getWorld().equals(ASkyBlock.getNetherWorld())) { inNether = true; } // Monsters being hurt if (e.getEntity() instanceof Monster || e.getEntity() instanceof Slime || e.getEntity() instanceof Squid) { // Normal island check if (island != null && island.getMembers().contains(attacker)) { // Members always allowed return; } if (actionAllowed(attacker, e.getEntity().getLocation(), SettingsFlag.HURT_MONSTERS)) { return; } // Not allowed e.setCancelled(true); return; } // Mobs being hurt if (e.getEntity() instanceof Animals || e.getEntity() instanceof IronGolem || e.getEntity() instanceof Snowman || e.getEntity() instanceof Villager) { if (island != null && (island.getIgsFlag(SettingsFlag.HURT_MOBS) || island.getMembers().contains(attacker))) { return; } e.setCancelled(true); return; } // Establish whether PVP is allowed or not. boolean pvp = false; if ((inNether && island != null && island.getIgsFlag(SettingsFlag.NETHER_PVP) || (!inNether && island != null && island.getIgsFlag(SettingsFlag.PVP)))) { pvp = true; } // Players being hurt PvP if (e.getEntity() instanceof Player) { if (pvp) { } else { e.setCancelled(true); } } } }
Example #12
Source File: IslandGuard.java From askyblock with GNU General Public License v2.0 | 4 votes |
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onFishing(final PlayerFishEvent e) { if (DEBUG) { plugin.getLogger().info("Player fish event " + e.getEventName()); plugin.getLogger().info("Player fish event " + e.getCaught()); } if (e.getCaught() == null) return; Player p = e.getPlayer(); if (!inWorld(p)) { return; } if (p.isOp() || VaultHelper.checkPerm(p, Settings.PERMPREFIX + "mod.bypassprotect")) { // You can do anything if you are Op of have the bypass return; } // Handle rods Island island = plugin.getGrid().getProtectedIslandAt(e.getCaught().getLocation()); // PVP check if (e.getCaught() instanceof Player) { // Check if this is the player who is holding the rod if (e.getCaught().equals(e.getPlayer())) { if (DEBUG) plugin.getLogger().info("DEBUG: player cught themselves!"); return; } if (island == null && (e.getCaught().getWorld().getEnvironment().equals(Environment.NORMAL) && !Settings.defaultWorldSettings.get(SettingsFlag.PVP)) || ((e.getCaught().getWorld().getEnvironment().equals(Environment.NETHER) && !Settings.defaultWorldSettings.get(SettingsFlag.NETHER_PVP)))) { Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).targetInNoPVPArea); e.setCancelled(true); e.getHook().remove(); return; } if (island != null && ((e.getCaught().getWorld().getEnvironment().equals(Environment.NORMAL) && !island.getIgsFlag(SettingsFlag.PVP)) || (e.getCaught().getWorld().getEnvironment().equals(Environment.NETHER) && !island.getIgsFlag(SettingsFlag.NETHER_PVP)))) { Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).targetInNoPVPArea); e.setCancelled(true); e.getHook().remove(); return; } } if (!plugin.getGrid().playerIsOnIsland(e.getPlayer())) { if (e.getCaught() instanceof Animals) { if (island == null && !Settings.defaultWorldSettings.get(SettingsFlag.HURT_MOBS)) { Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).islandProtected); e.setCancelled(true); e.getHook().remove(); return; } if (island != null) { if ((!island.getIgsFlag(SettingsFlag.HURT_MOBS) && !island.getMembers().contains(p.getUniqueId()))) { Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).islandProtected); e.setCancelled(true); e.getHook().remove(); return; } } } // Monster protection if (e.getCaught() instanceof Monster || e.getCaught() instanceof Squid || e.getCaught() instanceof Slime) { if (island == null && !Settings.defaultWorldSettings.get(SettingsFlag.HURT_MONSTERS)) { Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).islandProtected); e.setCancelled(true); e.getHook().remove(); return; } if (island != null) { if ((!island.getIgsFlag(SettingsFlag.HURT_MONSTERS) && !island.getMembers().contains(p.getUniqueId()))) { Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).islandProtected); e.setCancelled(true); e.getHook().remove(); } } } } }
Example #13
Source File: IslandGuard.java From askyblock with GNU General Public License v2.0 | 4 votes |
/** * Checks for splash damage. If there is any to any affected entity and it's not allowed, it won't work on any of them. * @param e - event */ @EventHandler(priority = EventPriority.LOW, ignoreCancelled=true) public void onSplashPotionSplash(final PotionSplashEvent e) { if (DEBUG) { plugin.getLogger().info(e.getEventName()); plugin.getLogger().info("splash entity = " + e.getEntity()); plugin.getLogger().info("splash entity type = " + e.getEntityType()); plugin.getLogger().info("splash affected entities = " + e.getAffectedEntities()); //plugin.getLogger().info("splash hit entity = " + e.getHitEntity()); } if (!IslandGuard.inWorld(e.getEntity().getLocation())) { return; } // Try to get the shooter Projectile projectile = e.getEntity(); if (DEBUG) plugin.getLogger().info("splash shooter = " + projectile.getShooter()); if (projectile.getShooter() != null && projectile.getShooter() instanceof Player) { Player attacker = (Player)projectile.getShooter(); // Run through all the affected entities for (LivingEntity entity: e.getAffectedEntities()) { if (DEBUG) plugin.getLogger().info("DEBUG: affected splash entity = " + entity); // Self damage if (attacker.equals(entity)) { if (DEBUG) plugin.getLogger().info("DEBUG: Self damage from splash potion!"); continue; } Island island = plugin.getGrid().getIslandAt(entity.getLocation()); boolean inNether = false; if (entity.getWorld().equals(ASkyBlock.getNetherWorld())) { inNether = true; } // Monsters being hurt if (entity instanceof Monster || entity instanceof Slime || entity instanceof Squid) { // Normal island check if (island != null && island.getMembers().contains(attacker.getUniqueId())) { // Members always allowed continue; } if (actionAllowed(attacker, entity.getLocation(), SettingsFlag.HURT_MONSTERS)) { continue; } // Not allowed Util.sendMessage(attacker, ChatColor.RED + plugin.myLocale(attacker.getUniqueId()).islandProtected); e.setCancelled(true); return; } // Mobs being hurt if (entity instanceof Animals || entity instanceof IronGolem || entity instanceof Snowman || entity instanceof Villager) { if (island != null && (island.getIgsFlag(SettingsFlag.HURT_MOBS) || island.getMembers().contains(attacker.getUniqueId()))) { continue; } if (DEBUG) plugin.getLogger().info("DEBUG: Mobs not allowed to be hurt. Blocking"); Util.sendMessage(attacker, ChatColor.RED + plugin.myLocale(attacker.getUniqueId()).islandProtected); e.setCancelled(true); return; } // Establish whether PVP is allowed or not. boolean pvp = false; if ((inNether && island != null && island.getIgsFlag(SettingsFlag.NETHER_PVP) || (!inNether && island != null && island.getIgsFlag(SettingsFlag.PVP)))) { if (DEBUG) plugin.getLogger().info("DEBUG: PVP allowed"); pvp = true; } // Players being hurt PvP if (entity instanceof Player) { if (pvp) { if (DEBUG) plugin.getLogger().info("DEBUG: PVP allowed"); } else { if (DEBUG) plugin.getLogger().info("DEBUG: PVP not allowed"); Util.sendMessage(attacker, ChatColor.RED + plugin.myLocale(attacker.getUniqueId()).targetInNoPVPArea); e.setCancelled(true); return; } } } } }
Example #14
Source File: EntityLimits.java From askyblock with GNU General Public License v2.0 | 4 votes |
/** * Prevents mobs spawning naturally at spawn or in an island * * @param e - event */ @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onNaturalMobSpawn(final CreatureSpawnEvent e) { // if grid is not loaded yet, return. if (plugin.getGrid() == null) { return; } // If not in the right world, return if (!IslandGuard.inWorld(e.getEntity())) { return; } // Deal with natural spawning if (e.getSpawnReason().equals(SpawnReason.NATURAL) || e.getSpawnReason().equals(SpawnReason.CHUNK_GEN) || e.getSpawnReason().equals(SpawnReason.DEFAULT) || e.getSpawnReason().equals(SpawnReason.MOUNT) || e.getSpawnReason().equals(SpawnReason.JOCKEY) || e.getSpawnReason().equals(SpawnReason.NETHER_PORTAL)) { if (e.getEntity() instanceof Monster || e.getEntity() instanceof Slime) { if (!actionAllowed(e.getLocation(), SettingsFlag.MONSTER_SPAWN)) { if (DEBUG3) plugin.getLogger().info("Natural monster spawn cancelled."); // Mobs not allowed to spawn e.setCancelled(true); return; } } else if (e.getEntity() instanceof Animals) { if (!actionAllowed(e.getLocation(), SettingsFlag.MOB_SPAWN)) { // Animals are not allowed to spawn if (DEBUG2) plugin.getLogger().info("Natural animal spawn cancelled."); e.setCancelled(true); return; } } } if (DEBUG2) { plugin.getLogger().info("Mob spawn allowed " + e.getEventName()); plugin.getLogger().info(e.getSpawnReason().toString()); plugin.getLogger().info(e.getEntityType().toString()); } }