Log out everyone on startup
This commit is contained in:
@@ -61,6 +61,17 @@ public class AccountRepository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setAllLoginState(LoginState loginState) {
|
||||||
|
String sql = """
|
||||||
|
UPDATE account
|
||||||
|
SET login_state = :loginState""";
|
||||||
|
try (Handle handle = connection.getHandle()) {
|
||||||
|
handle.createUpdate(sql)
|
||||||
|
.bind("loginState", loginState.getValue())
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Integer insert(Account account) {
|
public Integer insert(Account account) {
|
||||||
String sql = """
|
String sql = """
|
||||||
INSERT INTO account (name, password, birthdate, chr_slots, login_state)
|
INSERT INTO account (name, password, birthdate, chr_slots, login_state)
|
||||||
|
|||||||
@@ -731,7 +731,7 @@ public class Server {
|
|||||||
|
|
||||||
final int worldCount = Math.min(GameConstants.WORLD_NAMES.length, YamlConfig.config.server.WORLDS);
|
final int worldCount = Math.min(GameConstants.WORLD_NAMES.length, YamlConfig.config.server.WORLDS);
|
||||||
try (Connection con = DatabaseConnection.getConnection()) {
|
try (Connection con = DatabaseConnection.getConnection()) {
|
||||||
setAllLoggedOut(con);
|
channelDependencies.accountService().setAllLoggedOut();
|
||||||
setAllMerchantsInactive(con);
|
setAllMerchantsInactive(con);
|
||||||
cleanNxcodeCoupons(con);
|
cleanNxcodeCoupons(con);
|
||||||
loadCouponRates(con);
|
loadCouponRates(con);
|
||||||
@@ -873,12 +873,6 @@ public class Server {
|
|||||||
return loginServer;
|
return loginServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setAllLoggedOut(Connection con) throws SQLException {
|
|
||||||
try (PreparedStatement ps = con.prepareStatement("UPDATE accounts SET loggedin = 0")) {
|
|
||||||
ps.executeUpdate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void setAllMerchantsInactive(Connection con) throws SQLException {
|
private static void setAllMerchantsInactive(Connection con) throws SQLException {
|
||||||
try (PreparedStatement ps = con.prepareStatement("UPDATE characters SET HasMerchant = 0")) {
|
try (PreparedStatement ps = con.prepareStatement("UPDATE characters SET HasMerchant = 0")) {
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
|
|||||||
@@ -95,6 +95,10 @@ public class AccountService {
|
|||||||
return accountRepository.findByChrNameIgnoreCase(chrName);
|
return accountRepository.findByChrNameIgnoreCase(chrName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setAllLoggedOut() {
|
||||||
|
accountRepository.setAllLoginState(LoginState.LOGGED_OUT);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean acceptTos(int accountId) {
|
public boolean acceptTos(int accountId) {
|
||||||
acceptTosMysql(accountId);
|
acceptTosMysql(accountId);
|
||||||
acceptTosPostgres(accountId);
|
acceptTosPostgres(accountId);
|
||||||
|
|||||||
Reference in New Issue
Block a user