org.bukkit.entity.Guardian Java Examples

The following examples show how to use org.bukkit.entity.Guardian. 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: GuardianData.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings({"null", "deprecation"})
@Override
protected boolean init(Class<? extends Guardian> c, Guardian e) {
	if(e != null)
		isElder = e.isElder();
	return true;
}
 
Example #2
Source File: GuardianData.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public void set(Guardian entity) {
	if(isElder)
		entity.setElder(true);
	
}
 
Example #3
Source File: AcidTask.java    From askyblock with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Runs repeating tasks to deliver acid damage to mobs, etc.
 * @param plugin - ASkyBlock plugin object - ASkyBlock plugin
 */
public AcidTask(final ASkyBlock plugin) {
    this.plugin = plugin;
    // Initialize water item list
    itemsInWater = new HashSet<>();
    // This part will kill monsters if they fall into the water
    // because it
    // is acid
    if (Settings.mobAcidDamage > 0D || Settings.animalAcidDamage > 0D) {
        plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, () -> {
            List<Entity> entList = ASkyBlock.getIslandWorld().getEntities();
            for (Entity current : entList) {
                if (plugin.isOnePointEight() && current instanceof Guardian) {
                    // Guardians are immune to acid too
                    continue;
                }
                if ((current instanceof Monster) && Settings.mobAcidDamage > 0D) {
                    if ((current.getLocation().getBlock().getType() == Material.WATER)
                            || (current.getLocation().getBlock().getType() == Material.STATIONARY_WATER)) {
                        ((Monster) current).damage(Settings.mobAcidDamage);
                    }
                } else if ((current instanceof Animals) && Settings.animalAcidDamage > 0D) {
                    if ((current.getLocation().getBlock().getType() == Material.WATER)
                            || (current.getLocation().getBlock().getType() == Material.STATIONARY_WATER)) {
                        if (!current.getType().equals(EntityType.CHICKEN) || Settings.damageChickens) {
                            ((Animals) current).damage(Settings.animalAcidDamage);
                        }
                    }
                }
            }
        }, 0L, 20L);
    }
    runAcidItemRemovalTask();
}
 
Example #4
Source File: GuardianData.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
protected boolean match(Guardian entity) {
	return entity.isElder() == isElder;
}
 
Example #5
Source File: GuardianData.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Class<? extends Guardian> getType() {
	return Guardian.class;
}
 
Example #6
Source File: IEntityGuardianPet.java    From SonarPet with GNU General Public License v3.0 4 votes vote down vote up
@Override
Guardian getBukkitEntity();
 
Example #7
Source File: EntityUtilTest.java    From uSkyBlock with GNU General Public License v3.0 4 votes vote down vote up
@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));
}