Untitled
unknown
java
2 months ago
2.5 kB
5
Indexable
@SuppressWarnings("OptionalUsedAsFieldOrParameterType") private void setBombVelocity(Player player, WrapperEntity bombEntity, Location location, Vector direction, Bomb bomb, Optional<Hologram> hologram) { Vector initialVelocity = direction.multiply(bomb.getVelocity()).multiply(bomb.getVelocityMultiplier()).setY(bomb.getYMultiplier()); new BukkitRunnable() { private final Vector velocity = initialVelocity; final AtomicInteger ticksLived = new AtomicInteger(0); @Override public void run() { if (bomb.isParticlesEnabled()) { ParticleManager.sendParticlePacket( player, location, bomb.getTrailParticle(), bomb.getTrailOffset(), bomb.getTrailSpeed(), bomb.getTrailAmount(), false); } hologram.ifPresent(h -> h.teleport(location.clone().add(0, bomb.getHologramYOffset(), 0))); hologram.ifPresent(h -> { for (int i = 0; i < bomb.getHologramText().size(); i++) { String updatedLine = bomb.getHologramText().get(i); if (updatedLine.contains("%time%")) { String parsedTime = MessageParser.getTimeRemaining(ticksLived.get(), bomb.getMaxTicks()); updatedLine = updatedLine.replace("%time%", parsedTime); h.updateLine(i, new OptimalTextLine((OptimalHologram) h, Color.hex(updatedLine))); } } }); location.add(velocity.getX(), velocity.getY(), velocity.getZ()); bombEntity.teleport(SpigotConversionUtil.fromBukkitLocation(location)); velocity.setY(velocity.getY() + bomb.getGravity()); if (location.getBlock().isSolid() || ticksLived.getAndIncrement() > bomb.getMaxTicks()) { hologram.ifPresent(Hologram::delete); bombEntity.remove(); cancel(); BombHandler.handleBomb(player, bomb, LocationUtils.getPlayersWithinRadiusSync(location, bomb.getViewDistance()), location); } } }.runTaskTimerAsynchronously(PhantomBombs.getInstance(), 0L, 1L); }
Editor is loading...
Leave a Comment