- Spawn protection

This commit is contained in:
AlexTheCoder 2016-02-17 22:04:20 -05:00
parent 4158c12227
commit fe849576f7

View File

@ -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<Location> redSpawns = WorldData.SpawnLocs.get("Red");
List<Location> 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())