diff --git a/changelog.md b/changelog.md index 7c2c886..b164870 100644 --- a/changelog.md +++ b/changelog.md @@ -15,6 +15,7 @@ These changes will (most likely) be included in the next version. - Arena signs now support dynamic list entry variables for 4 different player lists. As an example, `` results in the name of a player in the lobby who hasn't readied up yet. This is useful for visualizing who is holding up the lobby. Check the wiki for details. - Elytra are now supported chest pieces in class chests. - Boss names now support color codes. +- The Root Target ability now uses potion effects (slowness, slow falling, and negative jump boost) instead of repeated teleports. This should make for a smoother root experience. - Config-files with missing `pet-items` nodes no longer errors. A missing `pet-items` node in `global-settings` is treated as empty, i.e. no pet items will be registered. ## [0.104.2] - 2020-01-03 diff --git a/src/main/java/com/garbagemule/MobArena/waves/ability/core/RootTarget.java b/src/main/java/com/garbagemule/MobArena/waves/ability/core/RootTarget.java index acc582f..989cd61 100644 --- a/src/main/java/com/garbagemule/MobArena/waves/ability/core/RootTarget.java +++ b/src/main/java/com/garbagemule/MobArena/waves/ability/core/RootTarget.java @@ -1,16 +1,14 @@ package com.garbagemule.MobArena.waves.ability.core; import com.garbagemule.MobArena.framework.Arena; -import com.garbagemule.MobArena.region.ArenaRegion; import com.garbagemule.MobArena.waves.MABoss; import com.garbagemule.MobArena.waves.ability.Ability; import com.garbagemule.MobArena.waves.ability.AbilityInfo; import com.garbagemule.MobArena.waves.ability.AbilityUtils; -import org.bukkit.Location; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; /** * DISCLAIMER: The Ability source code is provided as-is, and the creator(s) of @@ -36,16 +34,14 @@ import org.bukkit.entity.Player; public class RootTarget implements Ability { /** - * How many times the player will be warped back to his original position. - * Must be greater than 0. + * How long the the potions last (in ticks). */ - private static final int ITERATIONS = 30; + private static final int DURATION = 30; /** - * How many server ticks between each iteration of - * Must be greater than 0. + * The amplifier for the potions. */ - private static final int TICKS = 1; + private static final int AMPLIFIER = 100; @Override public void execute(Arena arena, MABoss boss) { @@ -54,49 +50,8 @@ public class RootTarget implements Ability return; Player player = (Player) target; - ArenaRegion region = arena.getRegion(); - - Block block = player.getLocation().getBlock(); - Block solid = findSolidBlockBelow(region, block); - - Location location = player.getLocation(); - location.setY(solid.getLocation().getY() + 1); - - rootTarget(arena, player, location, ITERATIONS); - } - - private Block findSolidBlockBelow(ArenaRegion region, Block block) { - Block below = block.getRelative(BlockFace.DOWN); - - // If the block below is not in the region, return the block itself - if (!region.contains(below.getLocation())) { - return block; - } - - // If the block below is solid, return it - if (below.getType().isSolid()) { - return below; - } - - // Otherwise, recurse downwards - return findSolidBlockBelow(region, below); - } - - private void rootTarget(final Arena arena, final Player p, final Location loc, final int counter) { - // If the counter is 0, we're done. - if (counter <= 0) { - return; - } - - arena.scheduleTask(new Runnable() { - public void run() { - if (!arena.isRunning() || !arena.inArena(p)) { - return; - } - - p.teleport(loc); - rootTarget(arena, p, loc, counter - 1); - } - }, TICKS); + player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, DURATION, AMPLIFIER)); + player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, DURATION, AMPLIFIER)); + player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, DURATION, -AMPLIFIER)); } }