use of org.bukkit.scheduler.BukkitRunnable in project EliteMobs by MagmaGuy.
the class ZombieNecronomicon method necronomiconVisualEffect.
private void necronomiconVisualEffect(Zombie zombie) {
summoningEffectOn = true;
nameScroller(zombie);
if (!ConfigValues.defaultConfig.getBoolean("Turn on visual effects that indicate an attack is about to happen")) {
return;
}
new BukkitRunnable() {
int counter = 0;
HashMap<Integer, List<Item>> fourTrack = new HashMap();
@Override
public void run() {
if (!zombie.isValid() || zombie.hasAI()) {
for (List<Item> itemList : fourTrack.values()) {
for (Item item : itemList) {
item.removeMetadata(MetadataHandler.MAJOR_VISUAL_EFFECT_MD, plugin);
item.remove();
}
}
if (zombie.isValid()) {
zombie.setCustomName(NameHandler.customAggressiveName(zombie));
}
summoningEffectOn = false;
cancel();
return;
}
if (counter == 0) {
//establish 4tracks
for (int i = 0; i < 8; i++) {
List<Item> itemList = new ArrayList<>();
for (int j = 0; j < 4; j++) {
ItemStack itemStack = new ItemStack(Material.WRITTEN_BOOK, 1);
Item item = zombie.getWorld().dropItem(zombie.getLocation(), itemStack);
item.setGravity(false);
item.setPickupDelay(Integer.MAX_VALUE);
item.setMetadata(MetadataHandler.MAJOR_VISUAL_EFFECT_MD, new FixedMetadataValue(plugin, true));
itemList.add(item);
}
fourTrack.put(i, itemList);
}
} else {
itemMover(fourTrack, zombie, counter);
}
counter++;
}
}.runTaskTimer(plugin, 5, 5);
}
use of org.bukkit.scheduler.BukkitRunnable in project EliteMobs by MagmaGuy.
the class AttackArrow method attackArrow.
@EventHandler
public void attackArrow(EntityTargetEvent event) {
if (event.getEntity().hasMetadata(powerMetadata) && !event.getEntity().hasMetadata(MetadataHandler.SHOOTING_ARROWS)) {
Entity targetter = event.getEntity();
Entity targetted = event.getTarget();
if (targetted instanceof Player) {
targetter.setMetadata(MetadataHandler.SHOOTING_ARROWS, new FixedMetadataValue(plugin, true));
new BukkitRunnable() {
@Override
public void run() {
if (!targetted.isValid() || !targetter.isValid() || targetter.getWorld() != targetted.getWorld() || targetted.getLocation().distance(targetter.getLocation()) > 20) {
targetter.removeMetadata(MetadataHandler.SHOOTING_ARROWS, plugin);
cancel();
return;
}
Entity repeatingArrow = targetter.getWorld().spawnEntity(targetter.getLocation().add(0, 3, 0), EntityType.ARROW);
Vector targetterToTargetted = targetted.getLocation().toVector().subtract(repeatingArrow.getLocation().toVector());
double distanceNerfRepeating = (targetted.getLocation().distance(targetter.getLocation())) / 100;
repeatingArrow.setVelocity(targetterToTargetted.multiply(0.5 - distanceNerfRepeating));
}
}.runTaskTimer(plugin, 0, 100);
}
}
}
use of org.bukkit.scheduler.BukkitRunnable in project Glowstone by GlowstoneMC.
the class BlockDispenser method updatePhysics.
@Override
public void updatePhysics(GlowBlock block) {
GlowBlock up = block.getRelative(BlockFace.UP);
boolean powered = block.isBlockPowered() || block.isBlockIndirectlyPowered() || up.isBlockPowered() || up.isBlockIndirectlyPowered();
GlowBlockState state = block.getState();
MaterialData data = state.getData();
if (!(data instanceof Dispenser)) {
return;
}
boolean isTriggered = (data.getData() >> 3 & 1) != 0;
if (powered && !isTriggered) {
new BukkitRunnable() {
@Override
public void run() {
trigger(block);
}
}.runTaskLater(null, 4);
// TODO replace this with dispenser materialdata class (as soon as it provides access to this property)
data.setData((byte) (data.getData() | 0x8));
state.update();
} else if (!powered && isTriggered) {
data.setData((byte) (data.getData() & ~0x8));
state.update();
}
}
use of org.bukkit.scheduler.BukkitRunnable in project InfernalMobs by NyaaCat.
the class AbilityWebber method setWebWithDecay.
private static void setWebWithDecay(Block b, int seconds, boolean allowInAir) {
if (b == null || b.getType() != Material.AIR)
return;
if (!allowInAir) {
Block below_block = b.getRelative(BlockFace.DOWN);
if (!below_block.getType().isSolid())
return;
}
b.setType(Material.WEB);
(new BukkitRunnable() {
@Override
public void run() {
if (b.getType() == Material.WEB) {
b.setType(Material.AIR);
}
}
}).runTaskLater(InfernalMobs.instance, seconds * 20);
}
use of org.bukkit.scheduler.BukkitRunnable in project MyPet by xXKeyleXx.
the class Sprint method finish.
@Override
public void finish() {
nav.getParameters().removeSpeedModifier("Sprint");
new BukkitRunnable() {
public void run() {
petEntity.setSprinting(false);
}
}.runTaskLater(MyPetApi.getPlugin(), 25L);
}
Aggregations