org.bukkit.entity.Villager Java Examples
The following examples show how to use
org.bukkit.entity.Villager.
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: MultiTradeMatchModule.java From PGM with GNU Affero General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onInteract(PlayerInteractEntityEvent event) { if (event.getRightClicked() instanceof Villager) { // Fallback to once-at-a-time trading if multi trade does not work if (ok) { event.setCancelled(true); } else { return; } try { InventoryUtils.openVillager((Villager) event.getRightClicked(), event.getPlayer()); } catch (NoSuchMethodError e) { logger.log(Level.WARNING, "<multitrade/> is not compatible with your server version"); ok = false; } catch (Throwable t) { logger.log( Level.WARNING, String.format( "Villager at (%s) has invalid NBT data", event.getRightClicked().getLocation().toVector()), t); ok = false; } } }
Example #2
Source File: FindSuperMobs.java From EliteMobs with GNU General Public License v3.0 | 6 votes |
@EventHandler public void findSuperMob(ChunkLoadEvent event) { for (Entity entity : event.getChunk().getEntities()) { if (SuperMobProperties.isValidSuperMobType(entity)) if (((LivingEntity) entity).getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue() == SuperMobProperties.getDataInstance(entity).getSuperMobMaxHealth()) if (!EntityTracker.isSuperMob(entity)) EntityTracker.registerSuperMob((LivingEntity) entity); else if (entity instanceof Villager) { } } }
Example #3
Source File: ControllableVillagerBase.java From EntityAPI with GNU Lesser General Public License v3.0 | 6 votes |
@Override public BehaviourItem[] getDefaultMovementBehaviours() { return new BehaviourItem[]{ new BehaviourItem(0, new BehaviourFloat(this)), new BehaviourItem(1, new BehaviourAvoidEntity(this, Zombie.class, 8.0F, 0.6D, 0.6D)), new BehaviourItem(1, new BehaviourTradeWithPlayer(this)), new BehaviourItem(1, new BehaviourLookAtTradingPlayer(this)), new BehaviourItem(2, new BehaviourMoveIndoors(this)), new BehaviourItem(3, new BehaviourRestrictOpenDoor(this)), new BehaviourItem(4, new BehaviourOpenDoor(this, true)), new BehaviourItem(5, new BehaviourMoveTowardsRestriction(this, 0.6D)), new BehaviourItem(6, new BehaviourMakeLove(this)), new BehaviourItem(7, new BehaviourTakeFlower(this)), new BehaviourItem(8, new BehaviourVillagerPlay(this, 0.32D)), new BehaviourItem(9, new BehaviourInteract(this, HumanEntity.class, 3.0F, 1.0F)), new BehaviourItem(9, new BehaviourInteract(this, Villager.class, 3.0F, 1.0F)), new BehaviourItem(9, new BehaviourRandomStroll(this, 0.6D)), new BehaviourItem(10, new BehaviourLookAtNearestEntity(this, InsentientEntity.class, 8.0F)) }; }
Example #4
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 #5
Source File: RegionEffectTests.java From Civs with GNU General Public License v3.0 | 6 votes |
@Test @Ignore // TODO fix this public void villagerShouldNotSpawnIfAtMaxVillagers() { RegionsTests.loadRegionTypeCobble(); Region region = RegionsTests.createNewRegion("cobble"); HashMap<String, String> effectMap = new HashMap<>(); effectMap.put("villager",""); region.setEffects(effectMap); VillagerEffect villagerEffect = new VillagerEffect(); // Block block = TestUtil.createBlock(Material.CHEST, townLocation); // doReturn(TestUtil.createBlock(Material.AIR, townLocation.add(0, 1,0))).when(block).getRelative(any(), anyInt()); // when(block.getWorld()).thenReturn(mock(World.class)); CommonScheduler.getLastTown().put(TestUtil.player.getUniqueId(), this.town); villagerEffect.regionCreatedHandler(region); Villager villager = VillagerEffect.spawnVillager(region); assertNotNull(villager); VillagerEffect.townCooldowns.clear(); villager = VillagerEffect.spawnVillager(region); assertNull(villager); }
Example #6
Source File: ControllablePigZombieBase.java From EntityAPI with GNU Lesser General Public License v3.0 | 5 votes |
@Override public BehaviourItem[] getDefaultTargetingBehaviours() { return new BehaviourItem[]{ new BehaviourItem(1, new BehaviourHurtByTarget(this, true)), new BehaviourItem(2, new BehaviourMoveTowardsNearestAttackableTarget(this, HumanEntity.class, 0, true)), new BehaviourItem(2, new BehaviourMoveTowardsNearestAttackableTarget(this, Villager.class, 0, false)) }; }
Example #7
Source File: NPCEntity.java From EliteMobs with GNU General Public License v3.0 | 5 votes |
/** * Spawns NPC based off of the values in the NPCConfig config file. Runs at startup and on reload. * * @param key Name of the config key for this NPC */ public NPCEntity(String key) { this.key = key; key += "."; Configuration configuration = ConfigValues.npcConfig; if (!setSpawnLocation(configuration.getString(key + NPCConfig.LOCATION))) return; if (!configuration.getBoolean(key + NPCConfig.ENABLED)) return; this.villager = (Villager) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.VILLAGER); this.villager.setRemoveWhenFarAway(true); setName(configuration.getString(key + NPCConfig.NAME)); initializeRole(configuration.getString(key + NPCConfig.ROLE)); setProfession(configuration.getString(key + NPCConfig.TYPE)); setGreetings(configuration.getStringList(key + NPCConfig.GREETINGS)); setDialog(configuration.getStringList(key + NPCConfig.DIALOG)); setFarewell(configuration.getStringList(key + NPCConfig.FAREWELL)); setCanMove(configuration.getBoolean(key + NPCConfig.CAN_MOVE)); setCanTalk(configuration.getBoolean(key + NPCConfig.CAN_TALK)); setActivationRadius(configuration.getDouble(key + NPCConfig.ACTIVATION_RADIUS)); setDisappearsAtNight(configuration.getBoolean(key + NPCConfig.DISAPPEARS_AT_NIGHT)); setNpcInteractionType(configuration.getString(key + NPCConfig.INTERACTION_TYPE)); EntityTracker.registerNPCEntity(this); addNPCEntity(this); }
Example #8
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 #9
Source File: VillagerData.java From Skript with GNU General Public License v3.0 | 5 votes |
@Override public void set(final Villager entity) { Profession prof = profession == null ? CollectionUtils.getRandom(professions) : profession; assert prof != null; entity.setProfession(prof); if (HAS_NITWIT && profession == Profession.NITWIT) entity.setRecipes(Collections.emptyList()); }
Example #10
Source File: RegionEffectTests.java From Civs with GNU General Public License v3.0 | 5 votes |
@Test public void villagerShouldNotSpawnIfOnCooldown() { RegionsTests.loadRegionTypeCobble(); Region region = RegionsTests.createNewRegion("cobble"); VillagerEffect.spawnVillager(region); Villager villager = VillagerEffect.spawnVillager(region); assertNull(villager); }
Example #11
Source File: RegionEffectTests.java From Civs with GNU General Public License v3.0 | 5 votes |
@Test @Ignore // TODO fix this public void villagerShouldSpawnNewVillager() { CommonScheduler.getLastTown().put(TestUtil.player.getUniqueId(), this.town); RegionsTests.loadRegionTypeCobble(); Region region = RegionsTests.createNewRegion("cobble"); HashMap<String, String> effectMap = new HashMap<>(); effectMap.put("villager",""); region.setEffects(effectMap); VillagerEffect villagerEffect = new VillagerEffect(); villagerEffect.regionCreatedHandler(region); Villager villager = VillagerEffect.spawnVillager(region); assertNotNull(villager); }
Example #12
Source File: RegionEffectTests.java From Civs with GNU General Public License v3.0 | 5 votes |
@Test public void villagerEffectShouldDecrementPower() { VillagerEffect villagerEffect = new VillagerEffect(); Villager villager = mock(Villager.class); when(villager.getLocation()).thenReturn(this.townLocation); EntityDeathEvent entityDeathEvent = mock(EntityDeathEvent.class); when(entityDeathEvent.getEntity()).thenReturn(villager); villagerEffect.onVillagerDeath(entityDeathEvent); assertEquals(296, this.town.getPower()); }
Example #13
Source File: VillagerEffect.java From Civs with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onVillagerDeath(EntityDeathEvent event) { if (!(event.getEntity() instanceof Villager)) { return; } Location location = event.getEntity().getLocation(); Town town = TownManager.getInstance().getTownAt(location); if (town == null) { return; } TownManager.getInstance().setTownPower(town, town.getPower() - ConfigManager.getInstance().getPowerPerNPCKill()); }
Example #14
Source File: Island.java From askyblock with GNU General Public License v2.0 | 5 votes |
/** * @return Provides count of villagers within the protected island boundaries */ public int getPopulation() { int result = 0; for (int x = getMinProtectedX() /16; x <= (getMinProtectedX() + getProtectionSize() - 1)/16; x++) { for (int z = getMinProtectedZ() /16; z <= (getMinProtectedZ() + getProtectionSize() - 1)/16; z++) { for (Entity entity : world.getChunkAt(x, z).getEntities()) { if (entity instanceof Villager && onIsland(entity.getLocation())) { result++; } } } } return result; }
Example #15
Source File: VillagerTrait.java From StackMob-3 with GNU General Public License v3.0 | 5 votes |
@Override public boolean checkTrait(Entity original, Entity nearby) { if(original instanceof Villager){ return ((Villager) original).getProfession() != ((Villager) nearby).getProfession(); } return false; }
Example #16
Source File: VillagerTrait.java From StackMob-3 with GNU General Public License v3.0 | 5 votes |
@Override public void applyTrait(Entity original, Entity spawned) { if(original instanceof Villager){ ((Villager) original).setProfession(((Villager) original).getProfession()); ((Villager) original).setCareer(((Villager) original).getCareer()); } }
Example #17
Source File: VillagerTrait.java From StackMob-3 with GNU General Public License v3.0 | 5 votes |
@Override public boolean checkTrait(Entity original, Entity nearby) { if(original instanceof Villager){ if (((Villager) original).getProfession() != ((Villager) nearby).getProfession()) { return true; } return (((Villager) original).getCareer() != ((Villager) nearby).getCareer()); } return false; }
Example #18
Source File: MultiTradeMatchModule.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@ListenerScope(MatchScope.LOADED) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void processItemRemoval(PlayerInteractEntityEvent event) { if(event.getRightClicked() instanceof Villager) { event.setCancelled(true); event.getPlayer().openMerchantCopy((Villager) event.getRightClicked()); } }
Example #19
Source File: Multitrade.java From CardinalPGM with MIT License | 5 votes |
@EventHandler public void handleRightClick(PlayerInteractEntityEvent event) { if ((event.getRightClicked() instanceof Villager)) { event.setCancelled(true); event.getPlayer().openMerchantCopy((Villager)event.getRightClicked()); } }
Example #20
Source File: VillagerInteractionListener.java From Shopkeepers with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) void onEntityInteract(PlayerInteractEntityEvent event) { if (!(event.getRightClicked() instanceof Villager)) return; Villager villager = (Villager) event.getRightClicked(); if (plugin.isShopkeeper(villager)) return; // shopkeeper interaction is handled elsewhere Log.debug("Interaction with Non-shopkeeper villager .."); if (villager.hasMetadata("NPC")) { // ignore any interaction with citizens2 NPCs Log.debug(" ignoring (probably citizens2) NPC"); return; } if (Settings.disableOtherVillagers) { // don't allow trading with other villagers event.setCancelled(true); Log.debug(" trade prevented"); } // only trigger hiring for main-hand events: if (!NMSManager.getProvider().isMainHandInteraction(event)) return; if (Settings.hireOtherVillagers) { Player player = event.getPlayer(); // allow hiring of other villagers Log.debug(" possible hire .."); if (this.handleHireOtherVillager(player, villager)) { // hiring was successful -> prevent normal trading Log.debug(" ..success (normal trading prevented)"); event.setCancelled(true); } else { // hiring was not successful -> no preventing of normal villager trading Log.debug(" ..failed"); } } }
Example #21
Source File: ControllableZombieBase.java From EntityAPI with GNU Lesser General Public License v3.0 | 5 votes |
@Override public BehaviourItem[] getDefaultMovementBehaviours() { return new BehaviourItem[]{ new BehaviourItem(0, new BehaviourFloat(this)), new BehaviourItem(1, new BehaviourBreakDoor(this, false)), new BehaviourItem(2, new BehaviourMeleeAttack(this, HumanEntity.class, false, 1.0D)), new BehaviourItem(4, new BehaviourMeleeAttack(this, Villager.class, true, 1.0D)), new BehaviourItem(5, new BehaviourMoveTowardsRestriction(this, 1.0D)), new BehaviourItem(6, new BehaviourMoveThroughVillage(this, false, 1.0D)), new BehaviourItem(7, new BehaviourRandomStroll(this, 1.0D)), new BehaviourItem(8, new BehaviourLookAtNearestEntity(this, HumanEntity.class, 8.0F)), new BehaviourItem(8, new BehaviourLookAtRandom(this)) }; }
Example #22
Source File: ControllableZombieBase.java From EntityAPI with GNU Lesser General Public License v3.0 | 5 votes |
@Override public BehaviourItem[] getDefaultTargetingBehaviours() { return new BehaviourItem[]{ new BehaviourItem(1, new BehaviourHurtByTarget(this, true)), new BehaviourItem(2, new BehaviourMoveTowardsNearestAttackableTarget(this, HumanEntity.class, 0, true)), new BehaviourItem(2, new BehaviourMoveTowardsNearestAttackableTarget(this, Villager.class, 0, false)) }; }
Example #23
Source File: ControllablePigZombieBase.java From EntityAPI with GNU Lesser General Public License v3.0 | 5 votes |
@Override public BehaviourItem[] getDefaultMovementBehaviours() { return new BehaviourItem[]{ new BehaviourItem(0, new BehaviourFloat(this)), new BehaviourItem(2, new BehaviourMeleeAttack(this, HumanEntity.class, false, 1.0D)), new BehaviourItem(4, new BehaviourMeleeAttack(this, Villager.class, true, 1.0D)), new BehaviourItem(5, new BehaviourMoveTowardsRestriction(this, 1.0D)), new BehaviourItem(6, new BehaviourMoveThroughVillage(this, false, 1.0D)), new BehaviourItem(7, new BehaviourRandomStroll(this, 1.0D)), new BehaviourItem(8, new BehaviourLookAtNearestEntity(this, HumanEntity.class, 8.0F)), new BehaviourItem(8, new BehaviourLookAtRandom(this)) }; }
Example #24
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 #25
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 #26
Source File: EntityLimits.java From askyblock with GNU General Public License v2.0 | 4 votes |
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onVillagerSpawn(final CreatureSpawnEvent e) { // If not an villager if (!(e.getEntity() instanceof Villager)) { return; } if (DEBUG3) { plugin.getLogger().info("Villager spawn event! " + e.getEventName()); plugin.getLogger().info("Reason:" + e.getSpawnReason().toString()); plugin.getLogger().info("Entity:" + e.getEntityType().toString()); } // Only cover overworld if (!e.getEntity().getWorld().equals(ASkyBlock.getIslandWorld())) { return; } // If there's no limit - leave it if (Settings.villagerLimit <= 0) { return; } // We only care about villagers breeding, being cured or coming from a spawn egg, etc. if (e.getSpawnReason() != SpawnReason.SPAWNER && e.getSpawnReason() != SpawnReason.BREEDING && e.getSpawnReason() != SpawnReason.DISPENSE_EGG && e.getSpawnReason() != SpawnReason.SPAWNER_EGG && e.getSpawnReason() != SpawnReason.CURED) { return; } Island island = plugin.getGrid().getProtectedIslandAt(e.getLocation()); if (island == null || island.getOwner() == null || island.isSpawn()) { // No island, no limit return; } int limit = Settings.villagerLimit * Math.max(1,plugin.getPlayers().getMembers(island.getOwner()).size()); //plugin.getLogger().info("DEBUG: villager limit = " + limit); //long time = System.nanoTime(); int pop = island.getPopulation(); //plugin.getLogger().info("DEBUG: time = " + ((System.nanoTime() - time)*0.000000001)); if (pop >= limit) { plugin.getLogger().warning( "Island at " + island.getCenter().getBlockX() + "," + island.getCenter().getBlockZ() + " hit the island villager limit of " + limit); //plugin.getLogger().info("Stopped villager spawning on island " + island.getCenter()); // Get all players in the area List<Entity> players = e.getEntity().getNearbyEntities(10,10,10); for (Entity player: players) { if (player instanceof Player) { Player p = (Player) player; Util.sendMessage(p, ChatColor.RED + plugin.myLocale(island.getOwner()).villagerLimitError.replace("[number]", String.valueOf(limit))); } } plugin.getMessages().tellTeam(island.getOwner(), ChatColor.RED + plugin.myLocale(island.getOwner()).villagerLimitError.replace("[number]", String.valueOf(limit))); if (e.getSpawnReason().equals(SpawnReason.CURED)) { // Easter Egg. Or should I say Easter Apple? ItemStack goldenApple = new ItemStack(Material.GOLDEN_APPLE); // Nerfed //goldenApple.setDurability((short)1); e.getLocation().getWorld().dropItemNaturally(e.getLocation(), goldenApple); } e.setCancelled(true); } }
Example #27
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)); }
Example #28
Source File: InventoryUtils.java From PGM with GNU Affero General Public License v3.0 | 4 votes |
public static void openVillager(Villager villager, Player viewer) throws Throwable { // An exception can be thrown if the Villager's NBT is invalid // or if the server does not support for this patch. // TODO: Newer versions of Bukkit can use HumanEntity#openMerchant(Merchant, boolean) viewer.openMerchantCopy(villager); }
Example #29
Source File: EntityVillagerPet.java From SonarPet with GNU General Public License v3.0 | 4 votes |
@Override public void setProfession(Villager.Profession profession) { ((Villager) getBukkitEntity()).setProfession(profession); }
Example #30
Source File: CraftZombie.java From Kettle with GNU General Public License v3.0 | 4 votes |
@Override public Villager.Profession getVillagerProfession() { return null; }