From fe849576f7d5bbcd511af205f92ef6539b77b405 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Wed, 17 Feb 2016 22:04:20 -0500 Subject: [PATCH] - Spawn protection --- .../minecraftleague/MinecraftLeague.java | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java index c3fde5c52..a25098ff2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java @@ -8,9 +8,11 @@ import java.util.concurrent.ConcurrentHashMap; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; @@ -54,6 +56,7 @@ import org.bukkit.entity.CreatureType; import org.bukkit.entity.Enderman; import org.bukkit.entity.EntityType; import org.bukkit.entity.ItemFrame; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; import org.bukkit.event.EventHandler; @@ -616,6 +619,62 @@ public class MinecraftLeague extends TeamGame } } + if (event.getType() == UpdateType.FASTER) + { + List redSpawns = WorldData.SpawnLocs.get("Red"); + List blueSpawns = WorldData.SpawnLocs.get("Blue"); + + for (Location rL : redSpawns) + { + for (LivingEntity near : UtilEnt.getInRadius(rL, 5).keySet()) + { + if (!(near instanceof Player)) + continue; + Player player = (Player)near; + if (GetTeam(player).GetColor() == ChatColor.RED) + continue; + + Vector vec = UtilAlg.getTrajectory(rL, player.getLocation()); + + Location tpLoc = rL.add(vec.clone().multiply(8)); + tpLoc.setDirection(player.getLocation().getDirection()); + + //First tp out this combats hacked clients with anti-KB + player.teleport(tpLoc); + + //Then apply velocity as normal + UtilAction.velocity(player, vec, 1.8, false, 0, 0.4, vec.length(), false); + + player.playSound(player.getEyeLocation(), Sound.NOTE_PLING, 10F, 0.5F); + } + } + + for (Location bL : blueSpawns) + { + for (LivingEntity near : UtilEnt.getInRadius(bL, 5).keySet()) + { + if (!(near instanceof Player)) + continue; + Player player = (Player)near; + if (GetTeam(player).GetColor() == ChatColor.AQUA) + continue; + + Vector vec = UtilAlg.getTrajectory(bL, player.getLocation()); + + Location tpLoc = bL.add(vec.clone().multiply(8)); + tpLoc.setDirection(player.getLocation().getDirection()); + + //First tp out this combats hacked clients with anti-KB + player.teleport(tpLoc); + + //Then apply velocity as normal + UtilAction.velocity(player, vec, 1.8, false, 0, 0.4, vec.length(), false); + + player.playSound(player.getEyeLocation(), Sound.NOTE_PLING, 10F, 0.5F); + } + } + } + if (event.getType() == UpdateType.FASTEST) { for (TeamCrystal crystal : _crystals.values())