Clean up tempBanCalendar
This commit is contained in:
@@ -167,7 +167,6 @@ import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
@@ -191,7 +190,6 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.DAYS;
|
||||
import static java.util.concurrent.TimeUnit.MINUTES;
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
|
||||
@@ -10685,7 +10683,7 @@ public class Character extends AbstractCharacterObject {
|
||||
public int checkWorldTransferEligibility() {
|
||||
if (getLevel() < 20) {
|
||||
return 2;
|
||||
} else if (getClient().getTempBanCalendar() != null && getClient().getTempBanCalendar().getTimeInMillis() + (int) DAYS.toMillis(30) < Calendar.getInstance().getTimeInMillis()) {
|
||||
} else if (client.wasRecentlyBanned()) {
|
||||
return 3;
|
||||
} else if (isMarried()) {
|
||||
return 4;
|
||||
|
||||
@@ -61,6 +61,8 @@ import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
@@ -118,7 +120,6 @@ public class Client extends ChannelInboundHandlerAdapter {
|
||||
private final Lock lock = new ReentrantLock(true);
|
||||
private final Lock announcerLock = new ReentrantLock(true);
|
||||
// thanks Masterrulax & try2hack for pointing out a bottleneck issue with shared locks, shavit for noticing an opportunity for improvement
|
||||
private Calendar tempBanCalendar;
|
||||
private long lastNpcClick;
|
||||
private long lastPacket = System.currentTimeMillis();
|
||||
|
||||
@@ -500,8 +501,9 @@ public class Client extends ChannelInboundHandlerAdapter {
|
||||
return ++failedLoginAttempts < MAX_FAILED_LOGIN_ATTEMPTS;
|
||||
}
|
||||
|
||||
public Calendar getTempBanCalendar() {
|
||||
return tempBanCalendar;
|
||||
public boolean wasRecentlyBanned() {
|
||||
Instant recentThreshold = Instant.now().minus(Duration.ofDays(30));
|
||||
return account != null && account.bannedUntil() != null && account.bannedUntil().isAfter(recentThreshold);
|
||||
}
|
||||
|
||||
public void updateHwid(Hwid hwid) {
|
||||
|
||||
@@ -51,8 +51,6 @@ import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.DAYS;
|
||||
|
||||
public final class CashOperationHandler extends AbstractPacketHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(CashOperationHandler.class);
|
||||
|
||||
@@ -419,7 +417,7 @@ public final class CashOperationHandler extends AbstractPacketHandler {
|
||||
c.sendPacket(PacketCreator.showCashShopMessage((byte) 0));
|
||||
c.enableCSActions();
|
||||
return;
|
||||
} else if (c.getTempBanCalendar() != null && (c.getTempBanCalendar().getTimeInMillis() + DAYS.toMillis(30)) > Calendar.getInstance().getTimeInMillis()) {
|
||||
} else if (c.wasRecentlyBanned()) {
|
||||
c.sendPacket(PacketCreator.showCashShopMessage((byte) 0));
|
||||
c.enableCSActions();
|
||||
return;
|
||||
|
||||
@@ -33,9 +33,6 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Calendar;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.DAYS;
|
||||
|
||||
/**
|
||||
* @author Ronan
|
||||
@@ -60,7 +57,7 @@ public final class TransferNameHandler extends AbstractPacketHandler {
|
||||
if (chr.getLevel() < 10) {
|
||||
c.sendPacket(PacketCreator.sendNameTransferRules(4));
|
||||
return;
|
||||
} else if (c.getTempBanCalendar() != null && c.getTempBanCalendar().getTimeInMillis() + DAYS.toMillis(30) < Calendar.getInstance().getTimeInMillis()) {
|
||||
} else if (c.wasRecentlyBanned()) {
|
||||
c.sendPacket(PacketCreator.sendNameTransferRules(2));
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user