org.bukkit.entity.Skeleton Java Examples
The following examples show how to use
org.bukkit.entity.Skeleton.
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: IslandGuard.java From askyblock with GNU General Public License v2.0 | 7 votes |
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onItemFrameDamage(final EntityDamageByEntityEvent e) { // Check world if (!inWorld(e.getEntity()) || !(e.getEntity() instanceof ItemFrame)) { return; } if (e.getDamager() instanceof Projectile) { if (DEBUG) plugin.getLogger().info("DEBUG: Projectile damage to itemframe"); // Find out who fired the arrow Projectile p = (Projectile) e.getDamager(); if (DEBUG) plugin.getLogger().info("DEBUG: Shooter is " + p.getShooter().toString()); if (p.getShooter() instanceof Skeleton || p.getShooter() instanceof Golem) { if (DEBUG) plugin.getLogger().info("DEBUG: Shooter is mob"); if (!Settings.allowMobDamageToItemFrames) { if (DEBUG) plugin.getLogger().info("DEBUG: Damage not allowed, cancelling"); e.setCancelled(true); } } } }
Example #2
Source File: ListenerCommand.java From TabooLib with MIT License | 6 votes |
@Override public void run(Player player, String[] args) { player.sendMessage("§8[§fTabooLib§8] §7SimpleAI."); Skeleton skeleton = player.getWorld().spawn(player.getLocation(), Skeleton.class, c -> { c.setCustomName("Fearless Skeleton"); c.setCustomNameVisible(true); }); TabooLib.getPlugin().runTask(() -> { SimpleAiSelector.getExecutor().getGoalAi(skeleton).forEach(ai -> { player.sendMessage("§8[§fTabooLib§8] §7AI (Origin): §8" + SimpleReflection.getFieldValueChecked(ai.getClass(), ai, "a", true)); }); SimpleAiSelector.getExecutor().removeGoalAi(skeleton, 3); SimpleAiSelector.getExecutor().getGoalAi(skeleton).forEach(ai -> { player.sendMessage("§8[§fTabooLib§8] §7AI (After): §8" + SimpleReflection.getFieldValueChecked(ai.getClass(), ai, "a", true)); }); }, 20); }
Example #3
Source File: IslandGuard.java From askyblock with GNU General Public License v2.0 | 6 votes |
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onItemFrameDamage(final HangingBreakByEntityEvent e) { if (DEBUG) { plugin.getLogger().info("DEBUG: Hanging break by entity event"); plugin.getLogger().info("DEBUG: cause = " + e.getCause()); plugin.getLogger().info("DEBUG: entity = " + e.getEntity()); plugin.getLogger().info("DEBUG: remover = " + e.getRemover()); } // Check world if (!inWorld(e.getEntity()) || !(e.getEntity() instanceof ItemFrame)) { return; } if (e.getRemover() instanceof Skeleton || e.getRemover() instanceof Golem) { if (DEBUG) plugin.getLogger().info("DEBUG: Remover is mob"); if (!Settings.allowMobDamageToItemFrames) { if (DEBUG) plugin.getLogger().info("DEBUG: Damage not allowed, cancelling"); e.setCancelled(true); } } }
Example #4
Source File: SkeletonData.java From Skript with GNU General Public License v3.0 | 5 votes |
@Override protected boolean init(final @Nullable Class<? extends Skeleton> c, final @Nullable Skeleton e) { if (e == null) return true; if (hasWither && e.getSkeletonType() == SkeletonType.WITHER) type = WITHER; if (hasStray && e.getSkeletonType() == SkeletonType.STRAY) type = STRAY; return true; }
Example #5
Source File: SkeletonData.java From Skript with GNU General Public License v3.0 | 5 votes |
@Override public void set(final Skeleton e) { switch (type) { case WITHER: e.setSkeletonType(SkeletonType.WITHER); break; case STRAY: e.setSkeletonType(SkeletonType.STRAY); break; default: e.setSkeletonType(SkeletonType.NORMAL); } }
Example #6
Source File: SkeletonData.java From Skript with GNU General Public License v3.0 | 5 votes |
@Override protected boolean match(final Skeleton e) { switch (type) { case WITHER: return e.getSkeletonType() == SkeletonType.WITHER; case STRAY: return e.getSkeletonType() == SkeletonType.STRAY; default: return e.getSkeletonType() == SkeletonType.NORMAL; } }
Example #7
Source File: MobSpawnEvent.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
@Override public void doEvent() { if (gMap.getMatchState() == MatchState.PLAYING) { this.fired = true; sendTitle(); World world = gMap.getCurrentWorld(); for (int i = 0; i < gMap.getAlivePlayers().size(); i++) { Player player = gMap.getAlivePlayers().get(i); br1 = new BukkitRunnable() { @Override public void run() { if (player != null) { List<Block> blocks = getSpawnableBlocks(player.getLocation()); Collections.shuffle(blocks); for (int i = 0; i < Util.get().getRandomNum(minMobsPerPlayer, maxMobsPerPlayer); i++) { Location spawn = blocks.get(i).getLocation().clone().add(0, 1, 0); LivingEntity ent = (LivingEntity) world.spawnEntity(spawn, EntityType.valueOf(mobs.get(ThreadLocalRandom.current().nextInt(0, mobs.size())).toUpperCase())); if (ent instanceof Zombie || ent instanceof Skeleton) { ent.getEquipment().setHelmet(new ItemStack(Material.CHAINMAIL_HELMET, 1)); } SkyWarsReloaded.getNMS().setEntityTarget(ent, player); mobsSpawned.add(ent); } } } }.runTaskLater(SkyWarsReloaded.get(), i * 3L); } if (length != -1) { br2 = new BukkitRunnable() { @Override public void run() { endEvent(false); } }.runTaskLater(SkyWarsReloaded.get(), length * 20L); } } }
Example #8
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 #9
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 #10
Source File: SkeletonData.java From Skript with GNU General Public License v3.0 | 4 votes |
@Override public Class<? extends Skeleton> getType() { return Skeleton.class; }
Example #11
Source File: EntitySkeletonPet.java From SonarPet with GNU General Public License v3.0 | 4 votes |
@Override public Skeleton getBukkitEntity() { return (Skeleton) super.getBukkitEntity(); }
Example #12
Source File: DMobType.java From DungeonsXL with GNU General Public License v3.0 | 4 votes |
@Override public Entity toEntity(Location loc) { World world = loc.getWorld(); GameWorld gameWorld = plugin.getGameWorld(world); if (gameWorld == null) { return null; } LivingEntity entity = (LivingEntity) world.spawnEntity(loc, type); /* Set the Items */ entity.getEquipment().setItemInHand(itemHand); entity.getEquipment().setHelmet(itemHelmet); entity.getEquipment().setChestplate(itemChestplate); entity.getEquipment().setLeggings(itemLeggings); entity.getEquipment().setBoots(itemBoots); /* Check mob specified stuff */ if (type == EntityType.SKELETON) { if (witherSkeleton) { ((Skeleton) entity).setSkeletonType(SkeletonType.WITHER); } else { ((Skeleton) entity).setSkeletonType(SkeletonType.NORMAL); } } if (type == EntityType.OCELOT) { Ocelot ocelot = (Ocelot) entity; if (EnumUtil.isValidEnum(Ocelot.Type.class, ocelotType.toUpperCase())) { ocelot.setCatType(Ocelot.Type.valueOf(ocelotType.toUpperCase())); } } /* Set Health */ if (maxHealth > 0) { entity.setMaxHealth(maxHealth); entity.setHealth(maxHealth); } /* Disable Despawning */ entity.setRemoveWhenFarAway(false); /* Spawn Mob */ new DMob(entity, gameWorld, this); return entity; }
Example #13
Source File: EntityUtilTest.java From uSkyBlock with GNU General Public License v3.0 | 4 votes |
@Test public void testGetEntity() { List<Entity> testList = new ArrayList<>(); ArmorStand fakeArmorStand = mock(ArmorStand.class); Cow fakeCow = mock(Cow.class); Evoker fakeEvoker = mock(Evoker.class); Guardian fakeGuardian = mock(Guardian.class); Pig fakePig = mock(Pig.class); PigZombie fakePigZombie = mock(PigZombie.class); Pillager fakePillager = mock(Pillager.class); Sheep fakeSheep = mock(Sheep.class); Skeleton fakeSkeleton = mock(Skeleton.class); Turtle fakeTurtle = mock(Turtle.class); Villager fakeVillager = mock(Villager.class); WanderingTrader fakeWanderingTrader = mock(WanderingTrader.class); testList.add(fakeArmorStand); testList.add(fakeCow); testList.add(fakeEvoker); testList.add(fakeGuardian); testList.add(fakePig); testList.add(fakePigZombie); testList.add(fakePillager); testList.add(fakeSheep); testList.add(fakeSkeleton); testList.add(fakeTurtle); testList.add(fakeVillager); testList.add(fakeWanderingTrader); List<Sheep> sheepList = EntityUtil.getEntity(testList, Sheep.class); assertEquals(1, sheepList.size()); assertEquals(fakeSheep, sheepList.get(0)); List<Animals> animalsList = EntityUtil.getAnimals(testList); assertEquals(4, animalsList.size()); assertTrue(animalsList.contains(fakeCow)); assertTrue(animalsList.contains(fakePig)); assertTrue(animalsList.contains(fakeSheep)); assertTrue(animalsList.contains(fakeTurtle)); List<Monster> monsterList = EntityUtil.getMonsters(testList); assertEquals(5, monsterList.size()); assertTrue(monsterList.contains(fakeEvoker)); assertTrue(monsterList.contains(fakeGuardian)); assertTrue(monsterList.contains(fakePigZombie)); assertTrue(monsterList.contains(fakePillager)); assertTrue(monsterList.contains(fakeSkeleton)); List<NPC> npcList = EntityUtil.getNPCs(testList); assertEquals(2, npcList.size()); assertTrue(npcList.contains(fakeVillager)); assertTrue(npcList.contains(fakeWanderingTrader)); }