Prevent users with PvP Timers from participating in the Capture Point event

This commit is contained in:
AlexTheCoder 2018-01-28 01:56:51 -05:00 committed by Alexander Meech
parent 90a72d6129
commit 46016b2aee

View File

@ -11,6 +11,7 @@ import org.bukkit.entity.Player;
import mineplex.core.common.Pair;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTextTop;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTime.TimeUnit;
@ -50,6 +51,20 @@ public class CapturePointEvent extends WorldEvent
double maxY = getCenterLocation().getBlockY() + 4;
_boundary = new PointBoundary(minX, maxX, minZ, maxZ, minY, maxY);
}
private boolean isEligible(Player player)
{
if (ClansManager.getInstance().hasTimer(player))
{
if (Recharge.Instance.use(player, "PvP Timer Inform NoCapturePoint", 5000, false, false))
{
UtilPlayer.message(player, F.main(getName(), "You cannot participate in the Capture Point whilst protected from PvP. Run " + F.elem("/pvp") + " to enable PvP!"));
}
return false;
}
return true;
}
@Override
protected void customTick()
@ -60,7 +75,10 @@ public class CapturePointEvent extends WorldEvent
}
if (_capturing == null)
{
Optional<? extends Player> opt = Bukkit.getOnlinePlayers().stream().filter(_boundary::isInBoundary).findAny();
Optional<? extends Player> opt = Bukkit.getOnlinePlayers().stream()
.filter(_boundary::isInBoundary)
.filter(this::isEligible)
.findAny();
if (opt.isPresent())
{
_capturing = opt.get();