diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Blink.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Blink.java index 47b177521..1f4add66d 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Blink.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Blink.java @@ -1,6 +1,7 @@ package mineplex.minecraft.game.classcombat.Skill.Assassin; import java.util.HashMap; +import java.util.Map; import org.bukkit.Bukkit; import org.bukkit.Effect; @@ -8,32 +9,35 @@ import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.entity.Player; import org.bukkit.event.block.Action; import org.bukkit.potion.PotionEffectType; import org.bukkit.util.Vector; -import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilWorld; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; import mineplex.minecraft.game.classcombat.Skill.SkillActive; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; import mineplex.minecraft.game.classcombat.Skill.event.SkillTeleportEvent; +import net.minecraft.server.v1_8_R3.AxisAlignedBB; +import net.minecraft.server.v1_8_R3.Entity; public class Blink extends SkillActive { - private HashMap _loc = new HashMap(); - private HashMap _blinkTime = new HashMap(); + private Map _loc = new HashMap<>(); + private Map _blinkTime = new HashMap<>(); + private boolean _allowTrapping = false; public Blink(SkillFactory skills, String name, ClassType classType, SkillType skillType, int cost, int levels, @@ -60,6 +64,7 @@ public class Blink extends SkillActive }); } + @SuppressWarnings("deprecation") @Override public boolean CustomCheck(Player player, int level) { @@ -96,30 +101,37 @@ public class Blink extends SkillActive return true; } - - @Override - public void Skill(Player player, int level) + + public void blinky(Player player) { - //Smoke Trail - Block lastSmoke = player.getLocation().getBlock(); - + Location start = player.getLocation().add(new Vector(0, 0.2, 0)); + Location test = null; + Location end = start.clone(); + Vector dir = player.getLocation().getDirection(); + AxisAlignedBB box = null; + Entity ent = ((CraftEntity)player).getHandle(); double maxRange = getMaxRange(player); - double curRange = 0; - while (curRange <= maxRange) + double range = 0; + + rangeLoop: while (range <= maxRange) { - Location newTarget = player.getLocation().add(new Vector(0,0.2,0)).add(player.getLocation().getDirection().multiply(curRange)); - - if (!UtilBlock.airFoliage(newTarget.getBlock()) || !UtilBlock.airFoliage(newTarget.getBlock().getRelative(BlockFace.UP))) - break; - + test = start.clone().add(dir.clone().multiply(range)); + float halfWidth = ent.width / 2; + float length = ent.length; + box = new AxisAlignedBB(test.getX() - halfWidth, test.getY(), test.getZ() - halfWidth, test.getX() + halfWidth, test.getY() + length, test.getZ() + halfWidth); + //Lock Players - for (Player cur : player.getWorld().getPlayers()) + playerLoop: for (Player cur : player.getWorld().getPlayers()) { - if (cur.equals(player) || cur.getGameMode() == GameMode.SPECTATOR) - continue; + if (cur.equals(player) || cur.getGameMode() == GameMode.SPECTATOR || UtilPlayer.isSpectator(cur)) + { + continue playerLoop; + } - if (UtilMath.offset(newTarget, cur.getLocation()) > 1) - continue; + if (UtilMath.offset(test, cur.getLocation()) > 1) + { + continue playerLoop; + } //Action Location target = cur.getLocation().add(player.getLocation().subtract(cur.getLocation()).toVector().normalize()); @@ -132,35 +144,111 @@ public class Blink extends SkillActive player.getWorld().playEffect(player.getLocation(), Effect.BLAZE_SHOOT, 0); return; } - - //Progress Forwards - curRange += 0.2; - + + for (Block b : UtilBlock.getInBoundingBox(player.getWorld(), box)) + { + if (UtilBlock.airFoliage(b)) + { + if (b.getType() == Material.STRING && _allowTrapping) + { + break rangeLoop; + } + } + else + { + break rangeLoop; + } + } + + range += 0.2; + end = test.clone(); //Smoke Trail - UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, newTarget.clone().add(0, 0.5, 0), 0, 0, 0, 0, 1, + UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, end.clone().add(0, 0.5, 0), 0, 0, 0, 0, 1, ViewDist.LONGER, UtilServer.getPlayers()); - - lastSmoke = newTarget.getBlock(); } - - //Modify Range - curRange -= 0.4; - if (curRange < 0) - { - curRange = 0; - } - - //Destination - Location loc = getDestination(player, curRange); + _loc.put(player, player.getLocation()); - - //Action - if (curRange > 0) + + if (range > 0) { - player.leaveVehicle(); - player.teleport(loc); + player.teleport(end); } + player.setFallDistance(0); + } + @Override + public void Skill(Player player, int level) + { + Location start = player.getLocation().add(new Vector(0, 0.2, 0)); + Location test = null; + Location end = start.clone(); + Vector dir = player.getLocation().getDirection(); + AxisAlignedBB box = null; + Entity ent = ((CraftEntity)player).getHandle(); + double maxRange = getMaxRange(player); + double range = 0; + + rangeLoop: while (range <= maxRange) + { + test = start.clone().add(dir.clone().multiply(range)); + float halfWidth = ent.width / 2; + float length = ent.length; + box = new AxisAlignedBB(test.getX() - halfWidth, test.getY(), test.getZ() - halfWidth, test.getX() + halfWidth, test.getY() + length, test.getZ() + halfWidth); + + //Lock Players + playerLoop: for (Player cur : player.getWorld().getPlayers()) + { + if (cur.equals(player) || cur.getGameMode() == GameMode.SPECTATOR || UtilPlayer.isSpectator(cur)) + { + continue playerLoop; + } + + if (UtilMath.offset(test, cur.getLocation()) > 1) + { + continue playerLoop; + } + + //Action + Location target = cur.getLocation().add(player.getLocation().subtract(cur.getLocation()).toVector().normalize()); + player.teleport(UtilWorld.locMerge(player.getLocation(), target)); + + //Inform + UtilPlayer.message(player, F.main(GetClassType().name(), "You used " + F.skill(GetName()) + ".")); + + //Effect + player.getWorld().playEffect(player.getLocation(), Effect.BLAZE_SHOOT, 0); + return; + } + + for (Block b : UtilBlock.getInBoundingBox(player.getWorld(), box)) + { + if (UtilBlock.airFoliage(b)) + { + if (b.getType() == Material.TRIPWIRE && _allowTrapping) + { + break rangeLoop; + } + } + else + { + break rangeLoop; + } + } + + range += 0.2; + end = test.clone(); + //Smoke Trail + UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, end.clone().add(0, 0.5, 0), 0, 0, 0, 0, 1, + ViewDist.LONGER, UtilServer.getPlayers()); + } + + _loc.put(player, player.getLocation()); + + if (range > 0) + { + player.teleport(end); + } + player.setFallDistance(0); //Inform @@ -242,4 +330,14 @@ public class Blink extends SkillActive { return player.getLocation().add(player.getLocation().getDirection().multiply(range).add(new Vector(0, 0.4, 0))); } + + public boolean isAllowTrapping() + { + return _allowTrapping; + } + + public void setAllowTrapping(boolean allowTrapping) + { + _allowTrapping = allowTrapping; + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Flash.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Flash.java index 41b41c695..6ace97598 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Flash.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Flash.java @@ -1,12 +1,14 @@ package mineplex.minecraft.game.classcombat.Skill.Assassin; import java.util.HashMap; +import java.util.Map; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; -import org.bukkit.block.BlockFace; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.block.Action; @@ -14,22 +16,26 @@ import org.bukkit.potion.PotionEffectType; import org.bukkit.util.Vector; import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.recharge.Recharge; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; import mineplex.minecraft.game.classcombat.Skill.SkillActive; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; import mineplex.minecraft.game.classcombat.Skill.event.SkillTeleportEvent; +import net.minecraft.server.v1_8_R3.AxisAlignedBB; +import net.minecraft.server.v1_8_R3.Entity; public class Flash extends SkillActive { - private HashMap _flash = new HashMap(); + private Map _flash = new HashMap<>(); + private boolean _allowTrapping = false; public Flash(SkillFactory skills, String name, ClassType classType, SkillType skillType, int cost, int levels, @@ -59,6 +65,7 @@ public class Flash extends SkillActive return "Recharge: #8#-1 Seconds per Charge"; } + @SuppressWarnings("deprecation") @Override public boolean CustomCheck(Player player, int level) { @@ -108,99 +115,92 @@ public class Flash extends SkillActive if (charges >= 1 + level) continue; - if (!mineplex.core.recharge.Recharge.Instance.use(cur, "Flash Recharge", 8000 - (1000 * level), false, false)) + if (!Recharge.Instance.use(cur, "Flash Recharge", 8000 - (1000 * level), false, false)) continue; _flash.put(cur, charges + 1); //Inform - UtilPlayer.message(cur, F.main(GetClassType().name(), "Flash Charges: " + F.elem((charges + 1)+""))); + UtilPlayer.message(cur, F.main(GetClassType().name(), "Flash Charges: " + F.elem((charges + 1) + ""))); } } - } + @SuppressWarnings("deprecation") @Override public void Skill(Player player, int level) { //Use Recharge - mineplex.core.recharge.Recharge.Instance.use(player, "Flash Recharge", 8000, false, false); + Recharge.Instance.use(player, "Flash Recharge", 8000, false, false); _flash.put(player, _flash.get(player) - 1); + //Inform + UtilPlayer.message(player, F.main(GetClassType().name(), "Flash Charges: " + F.elem(_flash.get(player) + ""))); + + Location start = player.getLocation().add(new Vector(0, 0.2, 0)); + Location test = null; + Location end = start.clone(); + Vector dir = player.getLocation().getDirection(); + AxisAlignedBB box = null; + Entity ent = ((CraftEntity)player).getHandle(); double maxRange = getMaxRange(player); - double curRange = 0; - while (curRange <= maxRange) + double range = 0; + + rangeLoop: while (range <= maxRange) { - Location newTarget = player.getLocation().add(new Vector(0,0.2,0)).add(player.getLocation().getDirection().multiply(curRange)); - Location aboveTarget = newTarget.getBlock().getRelative(BlockFace.UP).getLocation(); - - // half-slab - boolean newTargetIsSlab = newTarget.getBlock().getType() == Material.STEP || newTarget.getBlock().getType() == Material.WOOD_STEP; - boolean aboveTargetIsSlab = aboveTarget.getBlock().getType() == Material.STEP || aboveTarget.getBlock().getType() == Material.WOOD_STEP; - - boolean newTargetSlabIsBottom = false; - boolean aboveTargetSlabIsBottom = false; - - if (newTargetIsSlab && curRange < 0.5) + test = start.clone().add(dir.clone().multiply(range)); + float halfWidth = ent.width / 2; + float length = ent.length; + box = new AxisAlignedBB(test.getX() - halfWidth, test.getY(), test.getZ() - halfWidth, test.getX() + halfWidth, test.getY() + length, test.getZ() + halfWidth); + for (Block b : UtilBlock.getInBoundingBox(player.getWorld(), box)) { - int newTargetData = (int) newTarget.getBlock().getData(); - - if (newTargetData <= 7) newTargetSlabIsBottom = true; + if (b.getType() == Material.STEP || b.getType() == Material.WOOD_STEP || b.getType() == Material.STONE_SLAB2) + { + boolean bottom = false; + int data = b.getData(); + if (data <= 7) + { + bottom = true; + } + + boolean locIsBottom = (Math.max(test.getY(), b.getY()) - Math.min(test.getY(), b.getY())) < 0.5; + + if (bottom == locIsBottom) + { + break rangeLoop; + } + } + else if (UtilItem.isBoundless(b.getType())) + { + if (b.getType() == Material.TRIPWIRE && _allowTrapping) + { + break rangeLoop; + } + } + else + { + break rangeLoop; + } } - if (aboveTargetIsSlab && curRange < 0.25) - { - int aboveTargetData = (int) aboveTarget.getBlock().getData(); - - if (aboveTargetData <= 7) aboveTargetSlabIsBottom = true; - } - - if ((!newTargetSlabIsBottom && - !UtilItem.isBoundless(aboveTarget.getBlock().getType()) - || (!aboveTargetSlabIsBottom) - && !UtilItem.isBoundless(aboveTarget.getBlock().getType()))) - break; - - if (!UtilItem.isBoundless(newTarget.getBlock().getType()) && UtilItem.isBoundless(aboveTarget.getBlock().getType()) - || !UtilItem.isBoundless(aboveTarget.getBlock().getType()) && !UtilItem.isBoundless(newTarget.getBlock().getType())) - break; - - //Progress Forwards - curRange += 0.1; - + range += 0.1; + end = test.clone(); //Smoke Trail - UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, newTarget.clone().add(0, 0.5, 0), 0, 0, 0, 0, 1, + UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, end.clone().add(0, 0.5, 0), 0, 0, 0, 0, 1, ViewDist.LONGER, UtilServer.getPlayers()); } - - //Modify Range - curRange -= 0.4; - if (curRange < 0) - curRange = 0; - - //Destination - Location loc = getDestination(player, curRange); - if (UtilItem.isBoundless(UtilAlg.moveForward(loc, 0.15d, player.getLocation().getYaw(), false).getBlock().getType())) + if (range > 0) { - loc = UtilAlg.moveForward(loc, 0.25d, player.getLocation().getYaw(), true); + player.teleport(end); } - if (curRange > 0) - { - player.teleport(loc); - } - player.setFallDistance(0); - - //Inform - UtilPlayer.message(player, F.main(GetClassType().name(), "Flash Charges: " + F.elem(_flash.get(player)+""))); - + //Effect player.getWorld().playSound(player.getLocation(), Sound.WITHER_SHOOT, 0.4f, 1.2f); player.getWorld().playSound(player.getLocation(), Sound.SILVERFISH_KILL, 1f, 1.6f); - } @Override @@ -218,4 +218,14 @@ public class Flash extends SkillActive { return player.getLocation().add(player.getLocation().getDirection().multiply(range).add(new Vector(0, 0.4, 0))); } -} + + public boolean isAllowTrapping() + { + return _allowTrapping; + } + + public void setAllowTrapping(boolean allowTrapping) + { + _allowTrapping = allowTrapping; + } +} \ No newline at end of file