Disable the trampoline within 20 blocks from spawn in game lobbies
This commit is contained in:
parent
9ac2d3452a
commit
6180e049e0
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue