Fix AntiHack quick-logout NPE

This commit is contained in:
cnr 2017-05-19 14:53:40 -05:00
parent f565b0a9db
commit c60d357cfe
4 changed files with 18 additions and 8 deletions

View File

@ -201,7 +201,7 @@ public class AntiHack extends MiniPlugin
runSync(() -> _banned.remove(uuid));
}
public void doBan(Player player, Class<? extends Check> cause, boolean gep)
public void doBan(Player player, Class<? extends Check> cause, boolean gep, int hoursBanned)
{
runSync(() ->
{
@ -227,7 +227,7 @@ public class AntiHack extends MiniPlugin
new GwenBanNotification(_thisServer, player.getName(), player.getUniqueId().toString(), coreClient.GetRank().name(), CheckManager.getCheckSimpleName(cause), id, gep).publish();
});
_punish.AddPunishment(coreClient.getName(), Category.Hacking, finalMessage, AntiHack.NAME, 3, true, getHoursBanned(player, cause), true, after);
_punish.AddPunishment(coreClient.getName(), Category.Hacking, finalMessage, AntiHack.NAME, 3, true, hoursBanned, true, after);
};
if (coreClient.GetRank().has(Rank.TWITCH))
@ -266,7 +266,7 @@ public class AntiHack extends MiniPlugin
Consumer<Consumer<PunishmentResponse>> doPunish = after ->
{
_punish.AddPunishment(coreClient.getName(), Category.Hacking, info.getMessage(), AntiHack.NAME, 3, true, getHoursBanned(player, CheckManager.getCheckBySimpleName(info.getHackType())), true, after);
_punish.AddPunishment(coreClient.getName(), Category.Hacking, info.getMessage(), AntiHack.NAME, 3, true, getHoursBanned(player), true, after);
};
if (coreClient.GetRank().has(Rank.TWITCH))
@ -346,6 +346,11 @@ public class AntiHack extends MiniPlugin
{
PunishClient punishClient = require(Punish.class).GetClient(player.getName());
if (punishClient == null)
{
return -1;
}
int totalPunishments = 0;
if (punishClient.GetPunishments().containsKey(Category.Hacking))
@ -362,7 +367,7 @@ public class AntiHack extends MiniPlugin
return totalPunishments;
}
public int getHoursBanned(Player player, Class<? extends Check> check)
public int getHoursBanned(Player player)
{
switch (getPunishments(player))
{

View File

@ -12,6 +12,7 @@ import mineplex.core.common.util.UtilServer;
public class BanwaveAction extends AntiHackAction
{
private final AntiHack _antiHack = Managers.require(AntiHack.class);
private static final int BAN_DELAY_MINIMUM_MINUTES = 30;
private static final int BAN_DELAY_MAXIMUM_MINUTES = (int) TimeUnit.MINUTES.convert(2, TimeUnit.HOURS);
@ -25,7 +26,7 @@ public class BanwaveAction extends AntiHackAction
{
if (event.getViolations() >= (Math.floor(getMinVl() * .9)) && event.getPlayer().getMetadata("GWENEXTREMEPREJUDICE").get(0).asBoolean())
{
Managers.get(AntiHack.class).doBan(event.getPlayer(), event.getCheckClass(), true);
_antiHack.doBan(event.getPlayer(), event.getCheckClass(), true, _antiHack.getHoursBanned(event.getPlayer()));
return;
}
if (event.getViolations() >= this.getMinVl())

View File

@ -7,6 +7,8 @@ import mineplex.core.antihack.AntiHack;
public class GEPBanAction extends AntiHackAction
{
private final AntiHack _antiHack = Managers.require(AntiHack.class);
public GEPBanAction(int vl)
{
super(vl);
@ -17,7 +19,7 @@ public class GEPBanAction extends AntiHackAction
{
if (event.getViolations() >= this.getMinVl() && event.getPlayer().getMetadata("GWENEXTREMEPREJUDICE").get(0).asBoolean())
{
Managers.get(AntiHack.class).doBan(event.getPlayer(), event.getCheckClass(), true);
_antiHack.doBan(event.getPlayer(), event.getCheckClass(), true, _antiHack.getHoursBanned(event.getPlayer()));
}
}
}

View File

@ -7,6 +7,8 @@ import mineplex.core.antihack.AntiHack;
public class ImmediateBanAction extends AntiHackAction
{
private final AntiHack _antiHack = Managers.require(AntiHack.class);
public ImmediateBanAction(int vl)
{
super(vl);
@ -17,12 +19,12 @@ public class ImmediateBanAction extends AntiHackAction
{
if (event.getViolations() >= (Math.floor(getMinVl() * .9)) && event.getPlayer().getMetadata("GWENEXTREMEPREJUDICE").get(0).asBoolean())
{
Managers.get(AntiHack.class).doBan(event.getPlayer(), event.getCheckClass(), true);
_antiHack.doBan(event.getPlayer(), event.getCheckClass(), true, _antiHack.getHoursBanned(event.getPlayer()));
return;
}
if (event.getViolations() >= this.getMinVl())
{
Managers.get(AntiHack.class).doBan(event.getPlayer(), event.getCheckClass(), false);
_antiHack.doBan(event.getPlayer(), event.getCheckClass(), false, _antiHack.getHoursBanned(event.getPlayer()));
}
}
}