org.bukkit.entity.Sheep Java Examples
The following examples show how to use
org.bukkit.entity.Sheep.
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: ShearObjective.java From BetonQuest with GNU General Public License v3.0 | 7 votes |
@EventHandler(ignoreCancelled = true) public void onShear(PlayerShearEntityEvent event) { if (event.getEntity().getType() != EntityType.SHEEP) return; String playerID = PlayerConverter.getID(event.getPlayer()); if (!containsPlayer(playerID)) return; if (name != null && (event.getEntity().getCustomName() == null || !event.getEntity().getCustomName().equals(name))) return; if (color != null && !((Sheep) event.getEntity()).getColor().toString().equalsIgnoreCase(color)) return; SheepData data = (SheepData) dataMap.get(playerID); if (checkConditions(playerID)) { data.shearSheep(); // complete quest or notify if (data.getAmount() <= 0) completeObjective(playerID); else if (notify && data.getAmount() % notifyInterval == 0) Config.sendNotify(playerID, "sheep_to_shear", new String[]{String.valueOf(data.getAmount())}, "sheep_to_shear,info"); } }
Example #2
Source File: DyeEvent.java From StackMob-3 with GNU General Public License v3.0 | 6 votes |
@EventHandler public void onSheepDye(SheepDyeWoolEvent event) { if(!(StackTools.hasSizeMoreThanOne(event.getEntity()))) { return; } if(event.isCancelled()){ return; } int stackSize = StackTools.getSize(event.getEntity()); Sheep oldEntity = event.getEntity(); if (sm.getCustomConfig().getBoolean("divide-on.sheep-dye")) { Sheep newEntity = (Sheep) sm.getTools().duplicate(oldEntity); newEntity.setColor(event.getEntity().getColor()); oldEntity.setColor(event.getColor()); StackTools.setSize(newEntity,stackSize - 1); StackTools.makeSingle(oldEntity); } }
Example #3
Source File: DispenserShear.java From StackMob-3 with GNU General Public License v3.0 | 6 votes |
@EventHandler public void onDispenserShear(BlockShearEntityEvent event) { if(!StackTools.hasSizeMoreThanOne(event.getEntity())) { return; } if(event.getEntity() instanceof Sheep) { Sheep sheep = (Sheep) event.getEntity(); if(sm.getLogic().doSheepShearAll(sheep, event.getTool())){ ItemStack is = ItemTools.damageItem(event.getTool(), StackTools.getSize(event.getEntity())); sm.getServer().getScheduler().runTask(sm, () -> { Container dispenser = (Container) event.getBlock().getState(); int itemId = dispenser.getInventory().first(event.getTool()); dispenser.getInventory().setItem(itemId, is); }); return; } sm.getLogic().doSheepShearSingle(sheep); } else { throw new UnsupportedOperationException("This is not implemented!"); } }
Example #4
Source File: StackLogic.java From StackMob-3 with GNU General Public License v3.0 | 5 votes |
@Override public boolean doSheepShearAll(Sheep sheared, ItemStack tool) { int stackSize = StackTools.getSize(sheared); if(sm.getCustomConfig().getBoolean("multiply.sheep-wool") && ItemTools.hasEnoughDurability(tool, stackSize)){ LootContext lootContext = new LootContext.Builder(sheared.getLocation()).lootedEntity(sheared).build(); Collection<ItemStack> loot = sheared.getLootTable().populateLoot(ThreadLocalRandom.current(), lootContext); for(ItemStack itemStack : loot){ if(itemStack.getData() instanceof Wool) { sm.getDropTools().dropDrops(itemStack, sm.getDropTools().calculateAmount(stackSize), sheared.getLocation()); } } return true; } return false; }
Example #5
Source File: SheepData.java From Skript with GNU General Public License v3.0 | 5 votes |
@Override public void set(final Sheep entity) { if (colors != null) { final Color c = CollectionUtils.getRandom(colors); assert c != null; entity.setColor(c.asDyeColor()); } }
Example #6
Source File: SheepData.java From Skript with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("null") @Override protected boolean init(@Nullable Class<? extends Sheep> c, @Nullable Sheep e) { if (e != null) { sheared = e.isSheared() ? 1 : -1; colors = CollectionUtils.array(SkriptColor.fromDyeColor(e.getColor())); } return true; }
Example #7
Source File: SheepShearedTrait.java From StackMob-3 with GNU General Public License v3.0 | 5 votes |
@Override public boolean checkTrait(Entity original, Entity nearby) { if(original instanceof Sheep){ return (((Sheep) original).isSheared() != ((Sheep) nearby).isSheared()); } return false; }
Example #8
Source File: EffShear.java From Skript with GNU General Public License v3.0 | 5 votes |
@Override protected void execute(final Event e) { for (final LivingEntity en : sheep.getArray(e)) { if (en instanceof Sheep) { ((Sheep) en).setSheared(shear); } } }
Example #9
Source File: SheepColorTrait.java From StackMob-3 with GNU General Public License v3.0 | 5 votes |
@Override public boolean checkTrait(Entity original, Entity nearby) { if(original instanceof Sheep){ return (((Sheep) original).getColor() != ((Sheep) nearby).getColor()); } return false; }
Example #10
Source File: StackLogic.java From StackMob-3 with GNU General Public License v3.0 | 5 votes |
@Override public void doSheepShearSingle(Sheep sheared) { int stackSize = StackTools.getSize(sheared); if(sm.getCustomConfig().getBoolean("divide-on.sheep-shear")){ Sheep newEntity = (Sheep) sm.getTools().duplicate(sheared); newEntity.setSheared(false); StackTools.setSize(newEntity,stackSize - 1); StackTools.makeSingle(sheared); } }
Example #11
Source File: ShearingTaskType.java From Quests with MIT License | 5 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onShear(PlayerShearEntityEvent event) { if (!(event.getEntity() instanceof Sheep)) { return; } Player player = event.getPlayer(); QPlayer qPlayer = QuestsAPI.getPlayerManager().getPlayer(player.getUniqueId(), true); QuestProgressFile questProgressFile = qPlayer.getQuestProgressFile(); for (Quest quest : super.getRegisteredQuests()) { if (questProgressFile.hasStartedQuest(quest)) { QuestProgress questProgress = questProgressFile.getQuestProgress(quest); for (Task task : quest.getTasksOfType(super.getType())) { TaskProgress taskProgress = questProgress.getTaskProgress(task.getId()); if (taskProgress.isCompleted()) { continue; } int sheepNeeded = (int) task.getConfigValue("amount"); int progressSheared; if (taskProgress.getProgress() == null) { progressSheared = 0; } else { progressSheared = (int) taskProgress.getProgress(); } taskProgress.setProgress(progressSheared + 1); if (((int) taskProgress.getProgress()) >= sheepNeeded) { taskProgress.setCompleted(true); } } } } }
Example #12
Source File: ControllableWolfBase.java From EntityAPI with GNU Lesser General Public License v3.0 | 5 votes |
@Override public BehaviourItem[] getDefaultTargetingBehaviours() { return new BehaviourItem[]{ new BehaviourItem(1, new BehaviourHelpTamerTarget(this)), new BehaviourItem(2, new BehaviourDefendTamer(this)), new BehaviourItem(3, new BehaviourHurtByTarget(this, true)), new BehaviourItem(4, new BehaviourRandomTargetNonTamed(this, Sheep.class, 200, false)) }; }
Example #13
Source File: SheepShearedTrait.java From StackMob-3 with GNU General Public License v3.0 | 4 votes |
@Override public void applyTrait(Entity original, Entity spawned) { if(original instanceof Sheep){ ((Sheep) spawned).setSheared(((Sheep) original).isSheared()); } }
Example #14
Source File: SheepHandler.java From EliteMobs with GNU General Public License v3.0 | 4 votes |
@EventHandler public void onShear(PlayerShearEntityEvent event) { if (event.getEntity() instanceof Sheep && EntityTracker.isSuperMob(event.getEntity())) { Sheep sheep = (Sheep) event.getEntity(); for (int i = 0; i < 50; i++) { sheep.getWorld().dropItem(sheep.getLocation(), woolStackRandomizer(sheep)).setVelocity(ItemDropVelocity.ItemDropVelocity()); } } }
Example #15
Source File: EntitySheepPet.java From SonarPet with GNU General Public License v3.0 | 4 votes |
@Override public Sheep getBukkitEntity() { return (Sheep) super.getBukkitEntity(); }
Example #16
Source File: SheepData.java From Skript with GNU General Public License v3.0 | 4 votes |
@Override public Class<Sheep> getType() { return Sheep.class; }
Example #17
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 #18
Source File: SheepData.java From Skript with GNU General Public License v3.0 | 4 votes |
@Override public boolean match(final Sheep entity) { return (sheared == 0 || entity.isSheared() == (sheared == 1)) && (colors == null || SimpleExpression.check(colors, c -> c != null && entity.getColor() == c.asDyeColor(), false, false)); }
Example #19
Source File: SheepDyeWoolEvent.java From Kettle with GNU General Public License v3.0 | 4 votes |
public SheepDyeWoolEvent(final Sheep sheep, final DyeColor color) { super(sheep); this.cancel = false; this.color = color; }
Example #20
Source File: SheepColorTrait.java From StackMob-3 with GNU General Public License v3.0 | 4 votes |
@Override public void applyTrait(Entity original, Entity spawned) { if(original instanceof Sheep){ ((Sheep) spawned).setColor(((Sheep) original).getColor()); } }
Example #21
Source File: SheepRegrowWoolEvent.java From Kettle with GNU General Public License v3.0 | 4 votes |
@Override public Sheep getEntity() { return (Sheep) entity; }
Example #22
Source File: SheepRegrowWoolEvent.java From Kettle with GNU General Public License v3.0 | 4 votes |
public SheepRegrowWoolEvent(final Sheep sheep) { super(sheep); this.cancel = false; }
Example #23
Source File: SheepDyeWoolEvent.java From Kettle with GNU General Public License v3.0 | 4 votes |
@Override public Sheep getEntity() { return (Sheep) entity; }
Example #24
Source File: SheepHandler.java From EliteMobs with GNU General Public License v3.0 | 3 votes |
@EventHandler public void onDeath(EntityDeathEvent event) { if (event.getEntity() instanceof Sheep && EntityTracker.isSuperMob(event.getEntity())) { Sheep sheep = (Sheep) event.getEntity(); ItemStack sheepMonsterEgg = new ItemStack(MONSTER_EGG, 2, (short) 91); sheep.getWorld().dropItem(sheep.getLocation(), sheepMonsterEgg); } }
Example #25
Source File: IStackLogic.java From StackMob-3 with GNU General Public License v3.0 | votes |
void doSheepShearSingle(Sheep sheared);
Example #26
Source File: IStackLogic.java From StackMob-3 with GNU General Public License v3.0 | votes |
boolean doSheepShearAll(Sheep sheared, ItemStack tool);