Initialize clans after connection is closed.

This commit is contained in:
MobiusDev
2018-09-11 01:38:53 +00:00
parent 222b1d1136
commit a0f11c4826
8 changed files with 128 additions and 96 deletions

View File

@@ -76,30 +76,34 @@ public class ClanTable
ForumsBBSManager.getInstance().initRoot(); ForumsBBSManager.getInstance().initRoot();
} }
L2Clan clan; // Get all clan ids.
// Count the clans final List<Integer> cids = new ArrayList<>();
int clanCount = 0;
try (Connection con = DatabaseFactory.getConnection(); try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement(); Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT clan_id FROM clan_data")) ResultSet rs = s.executeQuery("SELECT clan_id FROM clan_data"))
{ {
while (rs.next()) while (rs.next())
{ {
final int clanId = rs.getInt("clan_id"); cids.add(rs.getInt("clan_id"));
_clans.put(clanId, new L2Clan(clanId));
clan = getClan(clanId);
if (clan.getDissolvingExpiryTime() != 0)
{
scheduleRemoveClan(clan.getId());
}
clanCount++;
} }
} }
catch (Exception e) catch (Exception e)
{ {
LOGGER.log(Level.SEVERE, "Error restoring ClanTable.", e); LOGGER.log(Level.SEVERE, "Error restoring ClanTable.", e);
} }
LOGGER.info(getClass().getSimpleName() + ": Restored " + clanCount + " clans from the database.");
// Create clans.
for (int cid : cids)
{
final L2Clan clan = new L2Clan(cid);
_clans.put(cid, clan);
if (clan.getDissolvingExpiryTime() != 0)
{
scheduleRemoveClan(clan.getId());
}
}
LOGGER.info(getClass().getSimpleName() + ": Restored " + cids.size() + " clans from the database.");
allianceCheck(); allianceCheck();
restorewars(); restorewars();
} }

View File

@@ -76,30 +76,34 @@ public class ClanTable
ForumsBBSManager.getInstance().initRoot(); ForumsBBSManager.getInstance().initRoot();
} }
L2Clan clan; // Get all clan ids.
// Count the clans final List<Integer> cids = new ArrayList<>();
int clanCount = 0;
try (Connection con = DatabaseFactory.getConnection(); try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement(); Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT clan_id FROM clan_data")) ResultSet rs = s.executeQuery("SELECT clan_id FROM clan_data"))
{ {
while (rs.next()) while (rs.next())
{ {
final int clanId = rs.getInt("clan_id"); cids.add(rs.getInt("clan_id"));
_clans.put(clanId, new L2Clan(clanId));
clan = getClan(clanId);
if (clan.getDissolvingExpiryTime() != 0)
{
scheduleRemoveClan(clan.getId());
}
clanCount++;
} }
} }
catch (Exception e) catch (Exception e)
{ {
LOGGER.log(Level.SEVERE, "Error restoring ClanTable.", e); LOGGER.log(Level.SEVERE, "Error restoring ClanTable.", e);
} }
LOGGER.info(getClass().getSimpleName() + ": Restored " + clanCount + " clans from the database.");
// Create clans.
for (int cid : cids)
{
final L2Clan clan = new L2Clan(cid);
_clans.put(cid, clan);
if (clan.getDissolvingExpiryTime() != 0)
{
scheduleRemoveClan(clan.getId());
}
}
LOGGER.info(getClass().getSimpleName() + ": Restored " + cids.size() + " clans from the database.");
allianceCheck(); allianceCheck();
restorewars(); restorewars();
} }

View File

@@ -77,30 +77,34 @@ public class ClanTable
ForumsBBSManager.getInstance().initRoot(); ForumsBBSManager.getInstance().initRoot();
} }
L2Clan clan; // Get all clan ids.
// Count the clans final List<Integer> cids = new ArrayList<>();
int clanCount = 0;
try (Connection con = DatabaseFactory.getConnection(); try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement(); Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT clan_id FROM clan_data")) ResultSet rs = s.executeQuery("SELECT clan_id FROM clan_data"))
{ {
while (rs.next()) while (rs.next())
{ {
final int clanId = rs.getInt("clan_id"); cids.add(rs.getInt("clan_id"));
_clans.put(clanId, new L2Clan(clanId));
clan = getClan(clanId);
if (clan.getDissolvingExpiryTime() != 0)
{
scheduleRemoveClan(clan.getId());
}
clanCount++;
} }
} }
catch (Exception e) catch (Exception e)
{ {
LOGGER.log(Level.SEVERE, "Error restoring ClanTable.", e); LOGGER.log(Level.SEVERE, "Error restoring ClanTable.", e);
} }
LOGGER.info(getClass().getSimpleName() + ": Restored " + clanCount + " clans from the database.");
// Create clans.
for (int cid : cids)
{
final L2Clan clan = new L2Clan(cid);
_clans.put(cid, clan);
if (clan.getDissolvingExpiryTime() != 0)
{
scheduleRemoveClan(clan.getId());
}
}
LOGGER.info(getClass().getSimpleName() + ": Restored " + cids.size() + " clans from the database.");
allianceCheck(); allianceCheck();
restorewars(); restorewars();
} }

View File

@@ -77,30 +77,34 @@ public class ClanTable
ForumsBBSManager.getInstance().initRoot(); ForumsBBSManager.getInstance().initRoot();
} }
L2Clan clan; // Get all clan ids.
// Count the clans final List<Integer> cids = new ArrayList<>();
int clanCount = 0;
try (Connection con = DatabaseFactory.getConnection(); try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement(); Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT clan_id FROM clan_data")) ResultSet rs = s.executeQuery("SELECT clan_id FROM clan_data"))
{ {
while (rs.next()) while (rs.next())
{ {
final int clanId = rs.getInt("clan_id"); cids.add(rs.getInt("clan_id"));
_clans.put(clanId, new L2Clan(clanId));
clan = getClan(clanId);
if (clan.getDissolvingExpiryTime() != 0)
{
scheduleRemoveClan(clan.getId());
}
clanCount++;
} }
} }
catch (Exception e) catch (Exception e)
{ {
LOGGER.log(Level.SEVERE, "Error restoring ClanTable.", e); LOGGER.log(Level.SEVERE, "Error restoring ClanTable.", e);
} }
LOGGER.info(getClass().getSimpleName() + ": Restored " + clanCount + " clans from the database.");
// Initialize clans.
for (int cid : cids)
{
final L2Clan clan = new L2Clan(cid);
_clans.put(cid, clan);
if (clan.getDissolvingExpiryTime() != 0)
{
scheduleRemoveClan(clan.getId());
}
}
LOGGER.info(getClass().getSimpleName() + ": Restored " + cids.size() + " clans from the database.");
allianceCheck(); allianceCheck();
restorewars(); restorewars();
} }

View File

@@ -78,30 +78,34 @@ public class ClanTable
ForumsBBSManager.getInstance().initRoot(); ForumsBBSManager.getInstance().initRoot();
} }
L2Clan clan; // Get all clan ids.
// Count the clans final List<Integer> cids = new ArrayList<>();
int clanCount = 0;
try (Connection con = DatabaseFactory.getConnection(); try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement(); Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT clan_id FROM clan_data")) ResultSet rs = s.executeQuery("SELECT clan_id FROM clan_data"))
{ {
while (rs.next()) while (rs.next())
{ {
final int clanId = rs.getInt("clan_id"); cids.add(rs.getInt("clan_id"));
_clans.put(clanId, new L2Clan(clanId));
clan = getClan(clanId);
if (clan.getDissolvingExpiryTime() != 0)
{
scheduleRemoveClan(clan.getId());
}
clanCount++;
} }
} }
catch (Exception e) catch (Exception e)
{ {
LOGGER.log(Level.SEVERE, "Error restoring ClanTable.", e); LOGGER.log(Level.SEVERE, "Error restoring ClanTable.", e);
} }
LOGGER.info(getClass().getSimpleName() + ": Restored " + clanCount + " clans from the database.");
// Create clans.
for (int cid : cids)
{
final L2Clan clan = new L2Clan(cid);
_clans.put(cid, clan);
if (clan.getDissolvingExpiryTime() != 0)
{
scheduleRemoveClan(clan.getId());
}
}
LOGGER.info(getClass().getSimpleName() + ": Restored " + cids.size() + " clans from the database.");
allianceCheck(); allianceCheck();
restorewars(); restorewars();
} }

View File

@@ -77,30 +77,34 @@ public class ClanTable
ForumsBBSManager.getInstance().initRoot(); ForumsBBSManager.getInstance().initRoot();
} }
L2Clan clan; // Get all clan ids.
// Count the clans final List<Integer> cids = new ArrayList<>();
int clanCount = 0;
try (Connection con = DatabaseFactory.getConnection(); try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement(); Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT clan_id FROM clan_data")) ResultSet rs = s.executeQuery("SELECT clan_id FROM clan_data"))
{ {
while (rs.next()) while (rs.next())
{ {
final int clanId = rs.getInt("clan_id"); cids.add(rs.getInt("clan_id"));
_clans.put(clanId, new L2Clan(clanId));
clan = getClan(clanId);
if (clan.getDissolvingExpiryTime() != 0)
{
scheduleRemoveClan(clan.getId());
}
clanCount++;
} }
} }
catch (Exception e) catch (Exception e)
{ {
LOGGER.log(Level.SEVERE, "Error restoring ClanTable.", e); LOGGER.log(Level.SEVERE, "Error restoring ClanTable.", e);
} }
LOGGER.info(getClass().getSimpleName() + ": Restored " + clanCount + " clans from the database.");
// Create clans.
for (int cid : cids)
{
final L2Clan clan = new L2Clan(cid);
_clans.put(cid, clan);
if (clan.getDissolvingExpiryTime() != 0)
{
scheduleRemoveClan(clan.getId());
}
}
LOGGER.info(getClass().getSimpleName() + ": Restored " + cids.size() + " clans from the database.");
allianceCheck(); allianceCheck();
restorewars(); restorewars();
} }

View File

@@ -77,30 +77,34 @@ public class ClanTable
ForumsBBSManager.getInstance().initRoot(); ForumsBBSManager.getInstance().initRoot();
} }
L2Clan clan; // Get all clan ids.
// Count the clans final List<Integer> cids = new ArrayList<>();
int clanCount = 0;
try (Connection con = DatabaseFactory.getConnection(); try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement(); Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT clan_id FROM clan_data")) ResultSet rs = s.executeQuery("SELECT clan_id FROM clan_data"))
{ {
while (rs.next()) while (rs.next())
{ {
final int clanId = rs.getInt("clan_id"); cids.add(rs.getInt("clan_id"));
_clans.put(clanId, new L2Clan(clanId));
clan = getClan(clanId);
if (clan.getDissolvingExpiryTime() != 0)
{
scheduleRemoveClan(clan.getId());
}
clanCount++;
} }
} }
catch (Exception e) catch (Exception e)
{ {
LOGGER.log(Level.SEVERE, "Error restoring ClanTable.", e); LOGGER.log(Level.SEVERE, "Error restoring ClanTable.", e);
} }
LOGGER.info(getClass().getSimpleName() + ": Restored " + clanCount + " clans from the database.");
// Create clans.
for (int cid : cids)
{
final L2Clan clan = new L2Clan(cid);
_clans.put(cid, clan);
if (clan.getDissolvingExpiryTime() != 0)
{
scheduleRemoveClan(clan.getId());
}
}
LOGGER.info(getClass().getSimpleName() + ": Restored " + cids.size() + " clans from the database.");
allianceCheck(); allianceCheck();
restorewars(); restorewars();
} }

View File

@@ -77,30 +77,34 @@ public class ClanTable
ForumsBBSManager.getInstance().initRoot(); ForumsBBSManager.getInstance().initRoot();
} }
L2Clan clan; // Get all clan ids.
// Count the clans final List<Integer> cids = new ArrayList<>();
int clanCount = 0;
try (Connection con = DatabaseFactory.getConnection(); try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement(); Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT clan_id FROM clan_data")) ResultSet rs = s.executeQuery("SELECT clan_id FROM clan_data"))
{ {
while (rs.next()) while (rs.next())
{ {
final int clanId = rs.getInt("clan_id"); cids.add(rs.getInt("clan_id"));
_clans.put(clanId, new L2Clan(clanId));
clan = getClan(clanId);
if (clan.getDissolvingExpiryTime() != 0)
{
scheduleRemoveClan(clan.getId());
}
clanCount++;
} }
} }
catch (Exception e) catch (Exception e)
{ {
LOGGER.log(Level.SEVERE, "Error restoring ClanTable.", e); LOGGER.log(Level.SEVERE, "Error restoring ClanTable.", e);
} }
LOGGER.info(getClass().getSimpleName() + ": Restored " + clanCount + " clans from the database.");
// Create clans.
for (int cid : cids)
{
final L2Clan clan = new L2Clan(cid);
_clans.put(cid, clan);
if (clan.getDissolvingExpiryTime() != 0)
{
scheduleRemoveClan(clan.getId());
}
}
LOGGER.info(getClass().getSimpleName() + ": Restored " + cids.size() + " clans from the database.");
allianceCheck(); allianceCheck();
restorewars(); restorewars();
} }