Fixed GranBossManager stopping when boss NPC template not found.

This commit is contained in:
MobiusDev 2017-09-10 13:00:26 +00:00
parent 1ff538f3ce
commit ecee43306c
4 changed files with 88 additions and 64 deletions

View File

@ -66,26 +66,32 @@ public final class GrandBossManager implements IStorable
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT * from grandboss_data ORDER BY boss_id"))
{
// Read all info from DB, and store it for AI to read and decide what to do faster than accessing DB in real time
while (rs.next())
{
// Read all info from DB, and store it for AI to read and decide what to do
// faster than accessing DB in real time
final StatsSet info = new StatsSet();
final int bossId = rs.getInt("boss_id");
info.set("loc_x", rs.getInt("loc_x"));
info.set("loc_y", rs.getInt("loc_y"));
info.set("loc_z", rs.getInt("loc_z"));
info.set("heading", rs.getInt("heading"));
info.set("respawn_time", rs.getLong("respawn_time"));
info.set("currentHP", rs.getDouble("currentHP"));
info.set("currentMP", rs.getDouble("currentMP"));
final int status = rs.getInt("status");
_bossStatus.put(bossId, status);
_storedInfo.put(bossId, info);
_log.info(getClass().getSimpleName() + ": " + NpcData.getInstance().getTemplate(bossId).getName() + "(" + bossId + ") status is " + status);
if (status > 0)
if (NpcData.getInstance().getTemplate(bossId) != null)
{
_log.info(getClass().getSimpleName() + ": Next spawn date of " + NpcData.getInstance().getTemplate(bossId).getName() + " is " + new Date(info.getLong("respawn_time")));
final StatsSet info = new StatsSet();
info.set("loc_x", rs.getInt("loc_x"));
info.set("loc_y", rs.getInt("loc_y"));
info.set("loc_z", rs.getInt("loc_z"));
info.set("heading", rs.getInt("heading"));
info.set("respawn_time", rs.getLong("respawn_time"));
info.set("currentHP", rs.getDouble("currentHP"));
info.set("currentMP", rs.getDouble("currentMP"));
final int status = rs.getInt("status");
_bossStatus.put(bossId, status);
_storedInfo.put(bossId, info);
_log.info(getClass().getSimpleName() + ": " + NpcData.getInstance().getTemplate(bossId).getName() + "(" + bossId + ") status is " + status);
if (status > 0)
{
_log.info(getClass().getSimpleName() + ": Next spawn date of " + NpcData.getInstance().getTemplate(bossId).getName() + " is " + new Date(info.getLong("respawn_time")));
}
}
else
{
_log.warning(getClass().getSimpleName() + ": Could not find GrandBoss NPC template for " + bossId);
}
}
_log.info(getClass().getSimpleName() + ": Loaded " + _storedInfo.size() + " Instances.");

View File

@ -66,26 +66,32 @@ public final class GrandBossManager implements IStorable
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT * from grandboss_data ORDER BY boss_id"))
{
// Read all info from DB, and store it for AI to read and decide what to do faster than accessing DB in real time
while (rs.next())
{
// Read all info from DB, and store it for AI to read and decide what to do
// faster than accessing DB in real time
final StatsSet info = new StatsSet();
final int bossId = rs.getInt("boss_id");
info.set("loc_x", rs.getInt("loc_x"));
info.set("loc_y", rs.getInt("loc_y"));
info.set("loc_z", rs.getInt("loc_z"));
info.set("heading", rs.getInt("heading"));
info.set("respawn_time", rs.getLong("respawn_time"));
info.set("currentHP", rs.getDouble("currentHP"));
info.set("currentMP", rs.getDouble("currentMP"));
final int status = rs.getInt("status");
_bossStatus.put(bossId, status);
_storedInfo.put(bossId, info);
_log.info(getClass().getSimpleName() + ": " + NpcData.getInstance().getTemplate(bossId).getName() + "(" + bossId + ") status is " + status);
if (status > 0)
if (NpcData.getInstance().getTemplate(bossId) != null)
{
_log.info(getClass().getSimpleName() + ": Next spawn date of " + NpcData.getInstance().getTemplate(bossId).getName() + " is " + new Date(info.getLong("respawn_time")));
final StatsSet info = new StatsSet();
info.set("loc_x", rs.getInt("loc_x"));
info.set("loc_y", rs.getInt("loc_y"));
info.set("loc_z", rs.getInt("loc_z"));
info.set("heading", rs.getInt("heading"));
info.set("respawn_time", rs.getLong("respawn_time"));
info.set("currentHP", rs.getDouble("currentHP"));
info.set("currentMP", rs.getDouble("currentMP"));
final int status = rs.getInt("status");
_bossStatus.put(bossId, status);
_storedInfo.put(bossId, info);
_log.info(getClass().getSimpleName() + ": " + NpcData.getInstance().getTemplate(bossId).getName() + "(" + bossId + ") status is " + status);
if (status > 0)
{
_log.info(getClass().getSimpleName() + ": Next spawn date of " + NpcData.getInstance().getTemplate(bossId).getName() + " is " + new Date(info.getLong("respawn_time")));
}
}
else
{
_log.warning(getClass().getSimpleName() + ": Could not find GrandBoss NPC template for " + bossId);
}
}
_log.info(getClass().getSimpleName() + ": Loaded " + _storedInfo.size() + " Instances.");

View File

@ -66,26 +66,32 @@ public final class GrandBossManager implements IStorable
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT * from grandboss_data ORDER BY boss_id"))
{
// Read all info from DB, and store it for AI to read and decide what to do faster than accessing DB in real time
while (rs.next())
{
// Read all info from DB, and store it for AI to read and decide what to do
// faster than accessing DB in real time
final StatsSet info = new StatsSet();
final int bossId = rs.getInt("boss_id");
info.set("loc_x", rs.getInt("loc_x"));
info.set("loc_y", rs.getInt("loc_y"));
info.set("loc_z", rs.getInt("loc_z"));
info.set("heading", rs.getInt("heading"));
info.set("respawn_time", rs.getLong("respawn_time"));
info.set("currentHP", rs.getDouble("currentHP"));
info.set("currentMP", rs.getDouble("currentMP"));
final int status = rs.getInt("status");
_bossStatus.put(bossId, status);
_storedInfo.put(bossId, info);
_log.info(getClass().getSimpleName() + ": " + NpcData.getInstance().getTemplate(bossId).getName() + "(" + bossId + ") status is " + status);
if (status > 0)
if (NpcData.getInstance().getTemplate(bossId) != null)
{
_log.info(getClass().getSimpleName() + ": Next spawn date of " + NpcData.getInstance().getTemplate(bossId).getName() + " is " + new Date(info.getLong("respawn_time")));
final StatsSet info = new StatsSet();
info.set("loc_x", rs.getInt("loc_x"));
info.set("loc_y", rs.getInt("loc_y"));
info.set("loc_z", rs.getInt("loc_z"));
info.set("heading", rs.getInt("heading"));
info.set("respawn_time", rs.getLong("respawn_time"));
info.set("currentHP", rs.getDouble("currentHP"));
info.set("currentMP", rs.getDouble("currentMP"));
final int status = rs.getInt("status");
_bossStatus.put(bossId, status);
_storedInfo.put(bossId, info);
_log.info(getClass().getSimpleName() + ": " + NpcData.getInstance().getTemplate(bossId).getName() + "(" + bossId + ") status is " + status);
if (status > 0)
{
_log.info(getClass().getSimpleName() + ": Next spawn date of " + NpcData.getInstance().getTemplate(bossId).getName() + " is " + new Date(info.getLong("respawn_time")));
}
}
else
{
_log.warning(getClass().getSimpleName() + ": Could not find GrandBoss NPC template for " + bossId);
}
}
_log.info(getClass().getSimpleName() + ": Loaded " + _storedInfo.size() + " Instances.");

View File

@ -66,26 +66,32 @@ public final class GrandBossManager implements IStorable
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT * from grandboss_data ORDER BY boss_id"))
{
// Read all info from DB, and store it for AI to read and decide what to do faster than accessing DB in real time
while (rs.next())
{
// Read all info from DB, and store it for AI to read and decide what to do
// faster than accessing DB in real time
final StatsSet info = new StatsSet();
final int bossId = rs.getInt("boss_id");
info.set("loc_x", rs.getInt("loc_x"));
info.set("loc_y", rs.getInt("loc_y"));
info.set("loc_z", rs.getInt("loc_z"));
info.set("heading", rs.getInt("heading"));
info.set("respawn_time", rs.getLong("respawn_time"));
info.set("currentHP", rs.getDouble("currentHP"));
info.set("currentMP", rs.getDouble("currentMP"));
final int status = rs.getInt("status");
_bossStatus.put(bossId, status);
_storedInfo.put(bossId, info);
_log.info(getClass().getSimpleName() + ": " + NpcData.getInstance().getTemplate(bossId).getName() + "(" + bossId + ") status is " + status);
if (status > 0)
if (NpcData.getInstance().getTemplate(bossId) != null)
{
_log.info(getClass().getSimpleName() + ": Next spawn date of " + NpcData.getInstance().getTemplate(bossId).getName() + " is " + new Date(info.getLong("respawn_time")));
final StatsSet info = new StatsSet();
info.set("loc_x", rs.getInt("loc_x"));
info.set("loc_y", rs.getInt("loc_y"));
info.set("loc_z", rs.getInt("loc_z"));
info.set("heading", rs.getInt("heading"));
info.set("respawn_time", rs.getLong("respawn_time"));
info.set("currentHP", rs.getDouble("currentHP"));
info.set("currentMP", rs.getDouble("currentMP"));
final int status = rs.getInt("status");
_bossStatus.put(bossId, status);
_storedInfo.put(bossId, info);
_log.info(getClass().getSimpleName() + ": " + NpcData.getInstance().getTemplate(bossId).getName() + "(" + bossId + ") status is " + status);
if (status > 0)
{
_log.info(getClass().getSimpleName() + ": Next spawn date of " + NpcData.getInstance().getTemplate(bossId).getName() + " is " + new Date(info.getLong("respawn_time")));
}
}
else
{
_log.warning(getClass().getSimpleName() + ": Could not find GrandBoss NPC template for " + bossId);
}
}
_log.info(getClass().getSimpleName() + ": Loaded " + _storedInfo.size() + " Instances.");