reuse latestSession to cut down on db requests

This commit is contained in:
Gjum
2021-10-26 16:44:05 +02:00
parent 3ec18a783e
commit f79fa3c5b8

View File

@@ -369,19 +369,20 @@ public class BanStickEventHandler implements Listener {
// Then do VPN checks
if (enableProxyBans || enableProxyKicks) {
// Inject IP Hub handler.
BanStick.getPlugin().getIPHubHandler().offer(bsPlayer.getLatestSession().getIP());
final BSSession latestSession = bsPlayer.getLatestSession();
BanStick.getPlugin().getIPHubHandler().offer(latestSession.getIP());
try {
if (bsPlayer.getProxyPardonTime() == null) {
if (bsPlayer.getLatestSession().getIP() == null) {
if (latestSession.getIP() == null) {
BanStick.getPlugin().warning("Weird failure, no ip for {0}", bsPlayer);
return;
}
if (bsPlayer.getLatestSession().getIP().getIPAddress() == null) {
if (latestSession.getIP().getIPAddress() == null) {
BanStick.getPlugin().warning("Weird failure, no ip address for {0}", bsPlayer);
return;
}
List<BSIPData> proxyChecks = BSIPData.allByIP(bsPlayer.getLatestSession().getIP());
List<BSIPData> proxyChecks = BSIPData.allByIP(latestSession.getIP());
if (proxyChecks != null) {
for (BSIPData proxyCheck : proxyChecks) {
// check if entire provider is banned