try
{
con = DatabaseFactory.getInstance().getConnection();
statement = con.createStatement();
int order = 0;
SqlBatch b = new SqlBatch("INSERT IGNORE INTO `character_effects_save` (`object_id`,`skill_id`,`skill_level`,`effect_count`,`effect_cur_time`,`duration`,`order`,`id`) VALUES");
StringBuilder sb;
for (Effect effect : effects)
{
if ((effect != null) && effect.isInUse() && !effect.getSkill().isToggle() && (effect.getEffectType() != EffectType.HealOverTime) && (effect.getEffectType() != EffectType.CombatPointHealOverTime) && (effect.getEffectType() != EffectType.Mentoring))
{
if (effect.isSaveable())
{
sb = new StringBuilder("(");
sb.append(objectId).append(',');
sb.append(effect.getSkill().getId()).append(',');
sb.append(effect.getSkill().getLevel()).append(',');
sb.append(effect.getCount()).append(',');
sb.append(effect.getTime()).append(',');
sb.append(effect.getPeriod()).append(',');
sb.append(order).append(',');
sb.append(id).append(')');
b.write(sb.toString());
}
while (((effect = effect.getNext()) != null) && effect.isSaveable())
{
sb = new StringBuilder("(");
sb.append(objectId).append(',');
sb.append(effect.getSkill().getId()).append(',');
sb.append(effect.getSkill().getLevel()).append(',');
sb.append(effect.getCount()).append(',');
sb.append(effect.getTime()).append(',');
sb.append(effect.getPeriod()).append(',');
sb.append(order).append(',');
sb.append(id).append(')');
b.write(sb.toString());
}
order++;
}
}
if (!b.isEmpty())
{
statement.executeUpdate(b.close());
}
}
catch (final Exception e)
{
_log.error("Could not store active effects data!", e);