org.bukkit.Effect Java Examples

The following examples show how to use org.bukkit.Effect. 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: Piercing.java    From ce with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void effect(Event e, ItemStack item, int level) {
    if (e instanceof EntityDamageByEntityEvent) {
        EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) e;
        LivingEntity target = (LivingEntity) event.getEntity();

        int armorCounter = 0;
        for (ItemStack piece : target.getEquipment().getArmorContents())
            if (!piece.getType().equals(Material.AIR))
                armorCounter++;

        if (armorCounter == 0)
            return;
        
        event.setDamage(DamageModifier.ARMOR, 0); //Completely remove effects of Armor
        target.getWorld().playEffect(target.getLocation(), Effect.ZOMBIE_DESTROY_DOOR, 10);
    }
}
 
Example #2
Source File: TableSaw.java    From Slimefun4 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onInteract(Player p, Block b) {
    ItemStack log = p.getInventory().getItemInMainHand();

    Optional<Material> planks = MaterialConverter.getPlanksFromLog(log.getType());

    if (planks.isPresent()) {
        if (p.getGameMode() != GameMode.CREATIVE) {
            ItemUtils.consumeItem(log, true);
        }

        ItemStack output = new ItemStack(planks.get(), 8);
        Inventory outputChest = findOutputChest(b, output);

        if (outputChest != null) {
            outputChest.addItem(output);
        }
        else {
            b.getWorld().dropItemNaturally(b.getLocation(), output);
        }

        b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, log.getType());
    }
}
 
Example #3
Source File: InfernalBonemeal.java    From Slimefun4 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public ItemUseHandler getItemHandler() {
    return e -> {
        Optional<Block> block = e.getClickedBlock();
        e.setUseBlock(Result.DENY);

        if (block.isPresent()) {
            Block b = block.get();

            if (b.getType() == Material.NETHER_WART) {
                Ageable ageable = (Ageable) b.getBlockData();

                if (ageable.getAge() < ageable.getMaximumAge()) {
                    ageable.setAge(ageable.getMaximumAge());
                    b.setBlockData(ageable);
                    b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, Material.REDSTONE_BLOCK);

                    if (e.getPlayer().getGameMode() != GameMode.CREATIVE) {
                        ItemUtils.consumeItem(e.getItem(), false);
                    }
                }
            }
        }
    };
}
 
Example #4
Source File: WindStaff.java    From Slimefun4 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public ItemUseHandler getItemHandler() {
    return e -> {
        Player p = e.getPlayer();

        if (p.getFoodLevel() >= 2) {
            if (p.getInventory().getItemInMainHand().getType() != Material.SHEARS && p.getGameMode() != GameMode.CREATIVE) {
                FoodLevelChangeEvent event = new FoodLevelChangeEvent(p, p.getFoodLevel() - 2);
                Bukkit.getPluginManager().callEvent(event);
                p.setFoodLevel(event.getFoodLevel());
            }

            p.setVelocity(p.getEyeLocation().getDirection().multiply(4));
            p.getWorld().playSound(p.getLocation(), Sound.ENTITY_TNT_PRIMED, 1, 1);
            p.getWorld().playEffect(p.getLocation(), Effect.SMOKE, 1);
            p.setFallDistance(0F);
        }
        else {
            SlimefunPlugin.getLocalization().sendMessage(p, "messages.hungry", true);
        }
    };
}
 
Example #5
Source File: MagicWorkbench.java    From Slimefun4 with GNU General Public License v3.0 6 votes vote down vote up
private void startAnimation(Player p, Block b, Inventory inv, ItemStack output) {
    for (int j = 0; j < 4; j++) {
        int current = j;
        Bukkit.getScheduler().runTaskLater(SlimefunPlugin.instance, () -> {
            p.getWorld().playEffect(b.getLocation(), Effect.MOBSPAWNER_FLAMES, 1);
            p.getWorld().playEffect(b.getLocation(), Effect.ENDER_SIGNAL, 1);

            if (current < 3) {
                p.getWorld().playSound(b.getLocation(), Sound.BLOCK_WOODEN_BUTTON_CLICK_ON, 1F, 1F);
            }
            else {
                p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F);
                inv.addItem(output);
            }
        }, j * 20L);
    }
}
 
Example #6
Source File: CraftJukebox.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean update(boolean force, boolean applyPhysics) {
    boolean result = super.update(force, applyPhysics);

    if (result && this.isPlaced() && this.getType() == Material.JUKEBOX) {
        CraftWorld world = (CraftWorld) this.getWorld();
        Material record = this.getPlaying();
        if (record == Material.AIR) {
            world.getHandle().setBlockState(new BlockPos(this.getX(), this.getY(), this.getZ()),
                    Blocks.JUKEBOX.getDefaultState()
                            .withProperty(BlockJukebox.HAS_RECORD, false), 3);
        } else {
            world.getHandle().setBlockState(new BlockPos(this.getX(), this.getY(), this.getZ()),
                    Blocks.JUKEBOX.getDefaultState()
                            .withProperty(BlockJukebox.HAS_RECORD, true), 3);
        }
        world.playEffect(this.getLocation(), Effect.RECORD_PLAY, record.getId());
    }

    return result;
}
 
Example #7
Source File: BlitzMatchModule.java    From PGM with GNU Affero General Public License v3.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR)
public void onBlitzPlayerEliminated(final BlitzPlayerEliminatedEvent event) {
  this.eliminatedPlayers.add(event.getPlayer().getBukkit().getUniqueId());

  World world = event.getMatch().getWorld();
  Location death = event.getDeathLocation();

  double radius = 0.1;
  int n = 8;
  for (int i = 0; i < 6; i++) {
    double angle = 2 * Math.PI * i / n;
    Location base =
        death.clone().add(new Vector(radius * Math.cos(angle), 0, radius * Math.sin(angle)));
    for (int j = 0; j <= 8; j++) {
      world.playEffect(base, Effect.SMOKE, j);
    }
  }
}
 
Example #8
Source File: BlitzMatchModule.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
private void handleElimination(final MatchPlayer player) {
    if (!eliminatedPlayers.add(player.getBukkit().getUniqueId())) return;

    World world = player.getMatch().getWorld();
    Location death = player.getBukkit().getLocation();

    double radius = 0.1;
    int n = 8;
    for(int i = 0; i < 6; i++) {
        double angle = 2 * Math.PI * i / n;
        Location base = death.clone().add(new Vector(radius * Math.cos(angle), 0, radius * Math.sin(angle)));
        for(int j = 0; j <= 8; j++) {
            world.playEffect(base, Effect.SMOKE, j);
        }
    }
    checkEnd();
}
 
Example #9
Source File: PressureChamber.java    From Slimefun4 with GNU General Public License v3.0 6 votes vote down vote up
private void craft(Player p, Block b, ItemStack output, Inventory outputInv) {
    for (int i = 0; i < 4; i++) {
        int j = i;

        Bukkit.getScheduler().runTaskLater(SlimefunPlugin.instance, () -> {
            p.getWorld().playSound(b.getLocation(), Sound.ENTITY_TNT_PRIMED, 1, 1);
            p.getWorld().playEffect(b.getRelative(BlockFace.UP).getLocation(), Effect.SMOKE, 4);
            p.getWorld().playEffect(b.getRelative(BlockFace.UP).getLocation(), Effect.SMOKE, 4);
            p.getWorld().playEffect(b.getRelative(BlockFace.UP).getLocation(), Effect.SMOKE, 4);

            if (j < 3) {
                p.getWorld().playSound(b.getLocation(), Sound.ENTITY_TNT_PRIMED, 1F, 1F);
            }
            else {
                p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F);
                outputInv.addItem(output);
            }
        }, i * 20L);
    }
}
 
Example #10
Source File: GoldPan.java    From Slimefun4 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public ItemUseHandler getItemHandler() {
    return e -> {
        Optional<Block> block = e.getClickedBlock();

        if (block.isPresent()) {
            Block b = block.get();

            if (b.getType() == getInput() && SlimefunPlugin.getProtectionManager().hasPermission(e.getPlayer(), b.getLocation(), ProtectableAction.BREAK_BLOCK)) {
                ItemStack output = getRandomOutput();

                b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType());
                b.setType(Material.AIR);

                if (output.getType() != Material.AIR) {
                    b.getWorld().dropItemNaturally(b.getLocation(), output.clone());
                }
            }
        }

        e.cancel();
    };
}
 
Example #11
Source File: JetBootsTask.java    From Slimefun4 with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void executeTask() {
    if (p.getInventory().getBoots() == null || p.getInventory().getBoots().getType() == Material.AIR) {
        return;
    }

    double accuracy = DoubleHandler.fixDouble(boots.getSpeed() - 0.7);

    if (boots.removeItemCharge(p.getInventory().getBoots(), COST)) {
        p.getWorld().playSound(p.getLocation(), Sound.ENTITY_TNT_PRIMED, (float) 0.25, 1);
        p.getWorld().playEffect(p.getLocation(), Effect.SMOKE, 1, 1);
        p.setFallDistance(0F);
        double gravity = 0.04;
        double offset = ThreadLocalRandom.current().nextBoolean() ? accuracy : -accuracy;
        Vector vector = new Vector(p.getEyeLocation().getDirection().getX() * boots.getSpeed() + offset, gravity, p.getEyeLocation().getDirection().getZ() * boots.getSpeed() - offset);

        p.setVelocity(vector);
    }
    else {
        Bukkit.getScheduler().cancelTask(id);
    }
}
 
Example #12
Source File: JetpackTask.java    From Slimefun4 with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void executeTask() {
    if (p.getInventory().getChestplate() == null || p.getInventory().getChestplate().getType() == Material.AIR) {
        return;
    }

    if (jetpack.removeItemCharge(p.getInventory().getChestplate(), COST)) {
        p.getWorld().playSound(p.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, (float) 0.25, 1);
        p.getWorld().playEffect(p.getLocation(), Effect.SMOKE, 1, 1);
        p.setFallDistance(0F);
        Vector vector = new Vector(0, 1, 0);
        vector.multiply(jetpack.getThrust());
        vector.add(p.getEyeLocation().getDirection().multiply(0.2F));

        p.setVelocity(vector);
    }
    else {
        Bukkit.getScheduler().cancelTask(id);
    }
}
 
Example #13
Source File: BlockPlacer.java    From Slimefun4 with GNU General Public License v3.0 6 votes vote down vote up
private void placeSlimefunBlock(SlimefunItem sfItem, ItemStack item, Block block, Dispenser dispenser) {
    block.setType(item.getType());
    BlockStorage.store(block, sfItem.getID());
    block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, item.getType());

    if (item.getType() == Material.SPAWNER && sfItem instanceof RepairedSpawner) {
        Optional<EntityType> entity = ((RepairedSpawner) sfItem).getEntityType(item);

        if (entity.isPresent()) {
            CreatureSpawner spawner = (CreatureSpawner) block.getState();
            spawner.setSpawnedType(entity.get());
            spawner.update(true, false);
        }
    }

    if (dispenser.getInventory().containsAtLeast(item, 2)) {
        dispenser.getInventory().removeItem(new CustomItem(item, 1));
    }
    else {
        Slimefun.runSync(() -> dispenser.getInventory().removeItem(item), 2L);
    }
}
 
Example #14
Source File: SlimefunBootsListener.java    From Slimefun4 with GNU General Public License v3.0 6 votes vote down vote up
private void stomp(EntityDamageEvent e) {
    Player p = (Player) e.getEntity();
    p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ZOMBIE_BREAK_WOODEN_DOOR, 1F, 2F);
    p.setVelocity(new Vector(0.0, 0.7, 0.0));

    for (Entity n : p.getNearbyEntities(4, 4, 4)) {
        if (n instanceof LivingEntity && !n.getUniqueId().equals(p.getUniqueId())) {
            Vector velocity = n.getLocation().toVector().subtract(p.getLocation().toVector()).normalize().multiply(1.4);
            n.setVelocity(velocity);

            if (!(n instanceof Player) || (p.getWorld().getPVP() && SlimefunPlugin.getProtectionManager().hasPermission(p, n.getLocation(), ProtectableAction.PVP))) {
                EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(p, n, DamageCause.ENTITY_ATTACK, e.getDamage() / 2);
                Bukkit.getPluginManager().callEvent(event);
                if (!event.isCancelled()) ((LivingEntity) n).damage(e.getDamage() / 2);
            }
        }
    }

    for (BlockFace face : BlockFace.values()) {
        Block b = p.getLocation().getBlock().getRelative(BlockFace.DOWN).getRelative(face);
        p.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType());
    }
}
 
Example #15
Source File: PlantsListener.java    From ExoticGarden with GNU General Public License v3.0 6 votes vote down vote up
private void dropFruitFromTree(Block block) {
    for (int x = -1; x < 2; x++) {
        for (int y = -1; y < 2; y++) {
            for (int z = -1; z < 2; z++) {
                // inspect a cube at the reference
                Block fruit = block.getRelative(x, y, z);
                if (fruit.isEmpty()) continue;

                Location loc = fruit.getLocation();
                SlimefunItem check = BlockStorage.check(loc);
                if (check == null) continue;

                for (Tree tree : ExoticGarden.getTrees()) {
                    if (check.getID().equalsIgnoreCase(tree.getFruitID())) {
                        BlockStorage.clearBlockInfo(loc);
                        ItemStack fruits = check.getItem();
                        fruit.getWorld().playEffect(loc, Effect.STEP_SOUND, Material.OAK_LEAVES);
                        fruit.getWorld().dropItemNaturally(loc, fruits);
                        fruit.setType(Material.AIR);
                        break;
                    }
                }
            }
        }
    }
}
 
Example #16
Source File: GrassSeeds.java    From ExoticGarden with GNU General Public License v3.0 6 votes vote down vote up
@Override
public ItemUseHandler getItemHandler() {
	return e -> {
		if (e.getClickedBlock().isPresent()) {
			Block b = e.getClickedBlock().get();
			
			if (b.getType() == Material.DIRT) {
				if (e.getPlayer().getGameMode() != GameMode.CREATIVE) {
					ItemUtils.consumeItem(e.getItem(), false);
				}
				
				b.setType(Material.GRASS_BLOCK);
				
				if (b.getRelative(BlockFace.UP).getType() == Material.AIR) {
					b.getRelative(BlockFace.UP).setType(Material.GRASS);
				}
				
				b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, Material.GRASS);
			}
		}
	};
}
 
Example #17
Source File: BountyHunter.java    From ce with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void effect(Event e, ItemStack item, final int level) {
	if(e instanceof EntityDamageByEntityEvent) {
	EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) e;
	Entity target = event.getEntity();
	
	if(!(target instanceof Player))
		return;
	
	Player p = (Player) ((Projectile) event.getDamager()).getShooter();
	
	Material bountyDrop = getBounty();
	
	for(int i = 10; i>0; i--) {
		p.getWorld().playEffect(p.getLocation(), Effect.COLOURED_DUST, 10);
		p.getWorld().playEffect(target.getLocation(), Effect.COLOURED_DUST, 10);
	}
	
	p.getInventory().addItem(new ItemStack(bountyDrop, Tools.random.nextInt(MaximumBounty+level)+1));
	p.sendMessage(ChatColor.GOLD + "You have collected a bounty on " + target.getName() + "!");
	this.generateCooldown(p, Cooldown);
	
	}
}
 
Example #18
Source File: CheckConfig.java    From WildernessTp with MIT License 6 votes vote down vote up
public boolean checkParticle(){
    if(wild.getConfig().getBoolean("DoParticle")) {
        try {
            String[] tmp = Bukkit.getVersion().split("MC: ");
            String version = tmp[tmp.length - 1].substring(0, 3);
            if (version.equals("1.9") || version.equals("1.1"))
                Particle.valueOf(wild.getConfig().getString("Particle").toUpperCase());
            else
                Effect.valueOf(wild.getConfig().getString("Particle").toUpperCase());
        } catch (IllegalArgumentException e) {
            return false;
        }
    }else
        return true;
    return true;
}
 
Example #19
Source File: WoodcutterAndroid.java    From Slimefun4 with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected boolean chopTree(Block b, BlockMenu menu, BlockFace face) {
    if (MaterialCollections.getAllLogs().contains(b.getRelative(face).getType())) {
        List<Block> list = Vein.find(b.getRelative(face), 180, block -> MaterialCollections.getAllLogs().contains(block.getType()));

        if (!list.isEmpty()) {
            Block log = list.get(list.size() - 1);
            log.getWorld().playEffect(log.getLocation(), Effect.STEP_SOUND, log.getType());

            if (SlimefunPlugin.getProtectionManager().hasPermission(Bukkit.getOfflinePlayer(UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner"))), log.getLocation(), ProtectableAction.BREAK_BLOCK)) {
                breakLog(log, b, menu, face);
            }

            return false;
        }
    }

    return true;
}
 
Example #20
Source File: LivefireBoots.java    From ce with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean effect(Event event, final Player player) {
	  final PlayerMoveEvent e = (PlayerMoveEvent) event;
	  final Block b = e.getTo().getBlock();
	  		  
	  if(!Tools.checkWorldGuard(e.getTo(), player, "PVP", false))
		  return false;
	  
	  if(b.getType().equals(Material.AIR)) {
		b.setType(Material.FIRE);
		new BukkitRunnable() {
			@Override
			public void run() {
				if(b.getType().equals(Material.FIRE)) {
					player.getWorld().playEffect(e.getTo(), Effect.EXTINGUISH, 60);
					b.setType(Material.AIR);
				}
			}
		}.runTaskLater(main, FlameDuration);
	
	}
	return true;
}
 
Example #21
Source File: MinerAndroid.java    From Slimefun4 with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void dig(Block b, BlockMenu menu, Block block) {
    Collection<ItemStack> drops = block.getDrops(effectivePickaxe);

    if (!MaterialCollections.getAllUnbreakableBlocks().contains(block.getType()) && !drops.isEmpty() && SlimefunPlugin.getProtectionManager().hasPermission(Bukkit.getOfflinePlayer(UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner"))), block.getLocation(), ProtectableAction.BREAK_BLOCK)) {

        AndroidMineEvent event = new AndroidMineEvent(block, new AndroidInstance(this, b));
        Bukkit.getPluginManager().callEvent(event);

        if (event.isCancelled()) {
            return;
        }

        // We only want to break non-Slimefun blocks
        String blockId = BlockStorage.checkID(block);
        if (blockId == null) {
            for (ItemStack drop : drops) {
                if (menu.fits(drop, getOutputSlots())) {
                    menu.pushItem(drop, getOutputSlots());
                    block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType());
                    block.setType(Material.AIR);
                }
            }
        }
    }
}
 
Example #22
Source File: ExplosiveShovel.java    From Slimefun4 with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void breakBlock(Player p, ItemStack item, Block b, int fortune, List<ItemStack> drops) {
    if (MaterialTools.getBreakableByShovel().contains(b.getType()) && SlimefunPlugin.getProtectionManager().hasPermission(p, b.getLocation(), ProtectableAction.BREAK_BLOCK)) {
        SlimefunPlugin.getProtectionManager().logAction(p, b, ProtectableAction.BREAK_BLOCK);

        b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType());

        for (ItemStack drop : b.getDrops(getItem())) {
            if (drop != null) {
                b.getWorld().dropItemNaturally(b.getLocation(), drop);
            }
        }

        b.setType(Material.AIR);
        damageItem(p, item);
    }
}
 
Example #23
Source File: CraftWorld.java    From Thermos with GNU General Public License v3.0 6 votes vote down vote up
public <T> void playEffect(Location loc, Effect effect, T data, int radius) {
    if (data != null) {
        Validate.isTrue(data.getClass().equals(effect.getData()), "Wrong kind of data for this effect!");
    } else {
        Validate.isTrue(effect.getData() == null, "Wrong kind of data for this effect!");
    }

    if (data != null && data.getClass().equals( org.bukkit.material.MaterialData.class )) {
        org.bukkit.material.MaterialData materialData = (org.bukkit.material.MaterialData) data;
        Validate.isTrue( materialData.getItemType().isBlock(), "Material must be block" );
        spigot().playEffect( loc, effect, materialData.getItemType().getId(), materialData.getData(), 0, 0, 0, 1, 1, radius );
    } else {
        int dataValue = data == null ? 0 : CraftEffect.getDataValue( effect, data );
        playEffect( loc, effect, dataValue, radius );
    }
}
 
Example #24
Source File: Camp.java    From civcraft with GNU General Public License v2.0 5 votes vote down vote up
public void onControlBlockHit(ControlPoint cp, World world, Player player) {
	world.playSound(cp.getCoord().getLocation(), Sound.ANVIL_USE, 0.2f, 1);
	world.playEffect(cp.getCoord().getLocation(), Effect.MOBSPAWNER_FLAMES, 0);
	
	CivMessage.send(player, CivColor.LightGray+"Damaged Control Block ("+cp.getHitpoints()+" / "+cp.getMaxHitpoints()+")");
	CivMessage.sendCamp(this, CivColor.Yellow+"One of our camp's Control Points is under attack!");
}
 
Example #25
Source File: DebugCommand.java    From civcraft with GNU General Public License v2.0 5 votes vote down vote up
public void flashedges_cmd() throws CivException {
	Town town = getNamedTown(1);
	
	for (TownChunk chunk : town.savedEdgeBlocks) {
		for (int x = 0; x < 16; x++) {
			for (int z = 0; z < 16; z++) {
				Block b = Bukkit.getWorld("world").getHighestBlockAt(((chunk.getChunkCoord().getX()+x<<4)+x), 
						((chunk.getChunkCoord().getZ()<<4)+z));
				Bukkit.getWorld("world").playEffect(b.getLocation(), Effect.MOBSPAWNER_FLAMES, 1);
			}
		}
	}
	CivMessage.sendSuccess(sender, "flashed");
}
 
Example #26
Source File: DebugFarmCommand.java    From civcraft with GNU General Public License v2.0 5 votes vote down vote up
public void cropcache_cmd() throws CivException {
	Player player = getPlayer();
	
	ChunkCoord coord = new ChunkCoord(player.getLocation());
	FarmChunk fc = CivGlobal.getFarmChunk(coord);
	if (fc == null) {
		throw new CivException("This is not a farm.");
	}
	
	for (BlockCoord bcoord : fc.cropLocationCache) {
		bcoord.getBlock().getWorld().playEffect(bcoord.getLocation(), Effect.MOBSPAWNER_FLAMES, 1);
	}
	CivMessage.sendSuccess(player, "Flashed cached crops.");
}
 
Example #27
Source File: LumberAxe.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
private void breakLog(Block b) {
    b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType());

    for (ItemStack drop : b.getDrops(getItem())) {
        b.getWorld().dropItemNaturally(b.getLocation(), drop);
    }

    b.setType(Material.AIR);
}
 
Example #28
Source File: DebugFarmCommand.java    From civcraft with GNU General Public License v2.0 5 votes vote down vote up
public void showgrowth_cmd() throws CivException {
	Player player = getPlayer();

	ChunkCoord coord = new ChunkCoord(player.getLocation());
	FarmChunk fc = CivGlobal.getFarmChunk(coord);
	if (fc == null) {
		throw new CivException("This is not a farm.");
	}
	
	for(BlockCoord bcoord : fc.getLastGrownCrops()) {
		bcoord.getBlock().getWorld().playEffect(bcoord.getLocation(), Effect.MOBSPAWNER_FLAMES, 1);
	}
	
	CivMessage.sendSuccess(player, "Flashed last grown crops");
}
 
Example #29
Source File: Road.java    From civcraft with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onDamage(int amount, World world, Player player, BlockCoord coord, BuildableDamageBlock hit) {
	boolean wasTenPercent = false;
	
	if(hit.getOwner().isDestroyed()) {
		CivMessage.sendError(player, hit.getOwner().getDisplayName()+" is already destroyed.");
		return;
	}
	
	if (!hit.getOwner().isComplete() && !(hit.getOwner() instanceof Wonder)) {
		CivMessage.sendError(player, hit.getOwner().getDisplayName()+" is still being built, cannot be destroyed.");
		return;		
	}
	
	if ((hit.getOwner().getDamagePercentage() % 10) == 0) {
		wasTenPercent = true;
	}
		
	this.damage(amount);
	
	world.playSound(hit.getCoord().getLocation(), Sound.ANVIL_USE, 0.2f, 1);
	world.playEffect(hit.getCoord().getLocation(), Effect.MOBSPAWNER_FLAMES, 0);
	
	if ((hit.getOwner().getDamagePercentage() % 10) == 0 && !wasTenPercent) {
		onDamageNotification(player, hit);
	}
}
 
Example #30
Source File: Spawned.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void tickLoaded() {
  super.tickLoaded();

  this.particleClock++;

  if (this.flag.getDefinition().showBeam()) {
    for (MatchPlayer player : flag.getMatch().getPlayers()) {
      if (this.canSeeParticles(player.getBukkit())) {
        player
            .getBukkit()
            .spigot()
            .playEffect(
                this.getLocation().clone().add(0, 56, 0),
                Effect.TILE_DUST,
                Material.WOOL.getId(),
                flag.getDyeColor().getWoolData(),
                0.15f, // radius on each axis of the particle ball
                24f,
                0.15f,
                0f, // initial horizontal velocity
                40, // number of particles
                200); // radius in blocks to show particles
      }
    }
  }
}