Disable the trampoline within 20 blocks from spawn in game lobbies

This commit is contained in:
Spencer 2018-05-10 15:50:10 -04:00 committed by Alexander Meech
parent 9ac2d3452a
commit 6180e049e0
1 changed files with 23 additions and 0 deletions

View File

@ -36,9 +36,12 @@ import mineplex.core.common.util.UtilBlockText;
import mineplex.core.common.util.UtilBlockText.TextAlign;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilLambda;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.gadget.event.GadgetSelectLocationEvent;
import mineplex.core.gadget.gadgets.item.ItemTrampoline;
import mineplex.core.game.kit.GameKit;
import mineplex.core.game.kit.event.KitNPCInteractEvent;
import mineplex.core.game.kit.event.KitSelectEvent;
@ -811,4 +814,24 @@ public abstract class LobbyManager implements Listener
{
_missions = loc;
}
public boolean isNearSpawn(Location location, int distance)
{
// offsetSquared should be compared to squared distance, obviously...
return UtilMath.offsetSquared(_spawn.clone(), location) < distance*distance;
}
public boolean isNearSpawn(Location location)
{
// Default to a 10 block radius
return isNearSpawn(location, 10);
}
@EventHandler
public void blockTrampolineNearSpawn(GadgetSelectLocationEvent event)
{
if (event.getGadget() instanceof ItemTrampoline && isNearSpawn(event.getLocation(), 20)) {
event.setCancelled(true);
}
}
}