Fixed hero issues and minor code cleanup.
This commit is contained in:
parent
9e4cef720e
commit
bc72e5021d
@ -71,15 +71,12 @@ public class Hero
|
||||
private static final String INSERT_HERO = "INSERT INTO heroes (charId, class_id, count, played, claimed) VALUES (?,?,?,?,?)";
|
||||
private static final String UPDATE_HERO = "UPDATE heroes SET count = ?, played = ?, claimed = ? WHERE charId = ?";
|
||||
private static final String GET_CLAN_ALLY = "SELECT characters.clanid AS clanid, coalesce(clan_data.ally_Id, 0) AS allyId FROM characters LEFT JOIN clan_data ON clan_data.clan_id = characters.clanid WHERE characters.charId = ?";
|
||||
// delete hero items
|
||||
private static final String DELETE_ITEMS = "DELETE FROM items WHERE item_id IN (30392, 30393, 30394, 30395, 30396, 30397, 30398, 30399, 30400, 30401, 30402, 30403, 30404, 30405, 30372, 30373, 6842, 6611, 6612, 6613, 6614, 6615, 6616, 6617, 6618, 6619, 6620, 6621, 9388, 9389, 9390) AND owner_id NOT IN (SELECT charId FROM characters WHERE accesslevel > 0)";
|
||||
|
||||
private static final Map<Integer, StatSet> HEROES = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, StatSet> COMPLETE_HEROS = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Map<Integer, StatSet> HERO_COUNTS = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, List<StatSet>> HERO_FIGHTS = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Map<Integer, List<StatSet>> HERO_DIARY = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, String> HERO_MESSAGE = new ConcurrentHashMap<>();
|
||||
|
||||
@ -128,7 +125,6 @@ public class Hero
|
||||
loadFights(charId);
|
||||
loadDiary(charId);
|
||||
loadMessage(charId);
|
||||
|
||||
processHeros(ps, charId, hero);
|
||||
HEROES.put(charId, hero);
|
||||
}
|
||||
@ -281,7 +277,7 @@ public class Hero
|
||||
data.set(Calendar.MILLISECOND, 0);
|
||||
|
||||
final long from = data.getTimeInMillis();
|
||||
int numberoffights = 0;
|
||||
int numberOfFights = 0;
|
||||
int victories = 0;
|
||||
int losses = 0;
|
||||
int draws = 0;
|
||||
@ -340,10 +336,8 @@ public class Hero
|
||||
fight.set("result", "<font color=\"ffff00\">draw</font>");
|
||||
draws++;
|
||||
}
|
||||
|
||||
fights.add(fight);
|
||||
|
||||
numberoffights++;
|
||||
numberOfFights++;
|
||||
}
|
||||
}
|
||||
else if (charId == charTwoId)
|
||||
@ -374,10 +368,8 @@ public class Hero
|
||||
fight.set("result", "<font color=\"ffff00\">draw</font>");
|
||||
draws++;
|
||||
}
|
||||
|
||||
fights.add(fight);
|
||||
|
||||
numberoffights++;
|
||||
numberOfFights++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -389,7 +381,7 @@ public class Hero
|
||||
HERO_COUNTS.put(charId, heroCountData);
|
||||
HERO_FIGHTS.put(charId, fights);
|
||||
|
||||
LOGGER.info("Hero System: Loaded " + numberoffights + " fights for Hero: " + CharNameTable.getInstance().getNameById(charId));
|
||||
LOGGER.info("Hero System: Loaded " + numberOfFights + " fights for Hero: " + CharNameTable.getInstance().getNameById(charId));
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
@ -631,12 +623,10 @@ public class Hero
|
||||
{
|
||||
player.sendInventoryUpdate(iu);
|
||||
}
|
||||
|
||||
player.broadcastUserInfo();
|
||||
}
|
||||
|
||||
deleteItemsInDb();
|
||||
|
||||
HEROES.clear();
|
||||
|
||||
if (newHeroes.isEmpty())
|
||||
@ -696,9 +686,9 @@ public class Hero
|
||||
{
|
||||
insert.setInt(1, heroId);
|
||||
insert.setInt(2, hero.getInt(Olympiad.CLASS_ID));
|
||||
insert.setInt(3, hero.getInt(COUNT));
|
||||
insert.setInt(4, hero.getInt(PLAYED));
|
||||
insert.setString(5, String.valueOf(hero.getBoolean(CLAIMED)));
|
||||
insert.setInt(3, hero.getInt(COUNT, 0));
|
||||
insert.setInt(4, hero.getInt(PLAYED, 0));
|
||||
insert.setString(5, String.valueOf(hero.getBoolean(CLAIMED, false)));
|
||||
insert.execute();
|
||||
insert.close();
|
||||
}
|
||||
@ -726,7 +716,6 @@ public class Hero
|
||||
allyCrest = ClanTable.getInstance().getClan(clanId).getAllyCrestId();
|
||||
}
|
||||
}
|
||||
|
||||
hero.set(CLAN_CREST, clanCrest);
|
||||
hero.set(CLAN_NAME, clanName);
|
||||
hero.set(ALLY_CREST, allyCrest);
|
||||
@ -734,17 +723,17 @@ public class Hero
|
||||
}
|
||||
}
|
||||
}
|
||||
HEROES.put(heroId, hero);
|
||||
|
||||
HEROES.put(heroId, hero);
|
||||
COMPLETE_HEROS.put(heroId, hero);
|
||||
}
|
||||
else
|
||||
{
|
||||
try (PreparedStatement statement = con.prepareStatement(UPDATE_HERO))
|
||||
{
|
||||
statement.setInt(1, hero.getInt(COUNT));
|
||||
statement.setInt(2, hero.getInt(PLAYED));
|
||||
statement.setString(3, String.valueOf(hero.getBoolean(CLAIMED)));
|
||||
statement.setInt(1, hero.getInt(COUNT, 0));
|
||||
statement.setInt(2, hero.getInt(PLAYED, 0));
|
||||
statement.setString(3, String.valueOf(hero.getBoolean(CLAIMED, false)));
|
||||
statement.setInt(4, heroId);
|
||||
statement.execute();
|
||||
}
|
||||
@ -773,11 +762,13 @@ public class Hero
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare new data
|
||||
final StatSet diaryEntry = new StatSet();
|
||||
final String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
|
||||
diaryEntry.set("date", date);
|
||||
diaryEntry.set("action", template.getName() + " was defeated");
|
||||
|
||||
// Add to old list
|
||||
list.add(diaryEntry);
|
||||
}
|
||||
@ -792,11 +783,13 @@ public class Hero
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare new data
|
||||
final StatSet diaryEntry = new StatSet();
|
||||
final String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
|
||||
diaryEntry.set("date", date);
|
||||
diaryEntry.set("action", castle.getName() + " Castle was successfuly taken");
|
||||
|
||||
// Add to old list
|
||||
list.add(diaryEntry);
|
||||
}
|
||||
@ -871,10 +864,7 @@ public class Hero
|
||||
*/
|
||||
public void shutdown()
|
||||
{
|
||||
for (int charId : HERO_MESSAGE.keySet())
|
||||
{
|
||||
saveHeroMessage(charId);
|
||||
}
|
||||
HERO_MESSAGE.keySet().forEach(this::saveHeroMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -926,11 +916,13 @@ public class Hero
|
||||
player.broadcastPacket(new SocialAction(player.getObjectId(), 20016)); // Hero Animation
|
||||
player.sendPacket(new UserInfo(player));
|
||||
player.broadcastUserInfo();
|
||||
|
||||
// Set Gained hero and reload data
|
||||
setHeroGained(player.getObjectId());
|
||||
loadFights(player.getObjectId());
|
||||
loadDiary(player.getObjectId());
|
||||
HERO_MESSAGE.put(player.getObjectId(), "");
|
||||
|
||||
EventDispatcher.getInstance().notifyEvent(new OnPlayerTakeHero(player));
|
||||
updateHeroes(false);
|
||||
}
|
||||
|
@ -71,15 +71,12 @@ public class Hero
|
||||
private static final String INSERT_HERO = "INSERT INTO heroes (charId, class_id, count, played, claimed) VALUES (?,?,?,?,?)";
|
||||
private static final String UPDATE_HERO = "UPDATE heroes SET count = ?, played = ?, claimed = ? WHERE charId = ?";
|
||||
private static final String GET_CLAN_ALLY = "SELECT characters.clanid AS clanid, coalesce(clan_data.ally_Id, 0) AS allyId FROM characters LEFT JOIN clan_data ON clan_data.clan_id = characters.clanid WHERE characters.charId = ?";
|
||||
// delete hero items
|
||||
private static final String DELETE_ITEMS = "DELETE FROM items WHERE item_id IN (30392, 30393, 30394, 30395, 30396, 30397, 30398, 30399, 30400, 30401, 30402, 30403, 30404, 30405, 30372, 30373, 6842, 6611, 6612, 6613, 6614, 6615, 6616, 6617, 6618, 6619, 6620, 6621, 9388, 9389, 9390) AND owner_id NOT IN (SELECT charId FROM characters WHERE accesslevel > 0)";
|
||||
|
||||
private static final Map<Integer, StatSet> HEROES = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, StatSet> COMPLETE_HEROS = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Map<Integer, StatSet> HERO_COUNTS = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, List<StatSet>> HERO_FIGHTS = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Map<Integer, List<StatSet>> HERO_DIARY = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, String> HERO_MESSAGE = new ConcurrentHashMap<>();
|
||||
|
||||
@ -128,7 +125,6 @@ public class Hero
|
||||
loadFights(charId);
|
||||
loadDiary(charId);
|
||||
loadMessage(charId);
|
||||
|
||||
processHeros(ps, charId, hero);
|
||||
HEROES.put(charId, hero);
|
||||
}
|
||||
@ -281,7 +277,7 @@ public class Hero
|
||||
data.set(Calendar.MILLISECOND, 0);
|
||||
|
||||
final long from = data.getTimeInMillis();
|
||||
int numberoffights = 0;
|
||||
int numberOfFights = 0;
|
||||
int victories = 0;
|
||||
int losses = 0;
|
||||
int draws = 0;
|
||||
@ -340,10 +336,8 @@ public class Hero
|
||||
fight.set("result", "<font color=\"ffff00\">draw</font>");
|
||||
draws++;
|
||||
}
|
||||
|
||||
fights.add(fight);
|
||||
|
||||
numberoffights++;
|
||||
numberOfFights++;
|
||||
}
|
||||
}
|
||||
else if (charId == charTwoId)
|
||||
@ -374,10 +368,8 @@ public class Hero
|
||||
fight.set("result", "<font color=\"ffff00\">draw</font>");
|
||||
draws++;
|
||||
}
|
||||
|
||||
fights.add(fight);
|
||||
|
||||
numberoffights++;
|
||||
numberOfFights++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -389,7 +381,7 @@ public class Hero
|
||||
HERO_COUNTS.put(charId, heroCountData);
|
||||
HERO_FIGHTS.put(charId, fights);
|
||||
|
||||
LOGGER.info("Hero System: Loaded " + numberoffights + " fights for Hero: " + CharNameTable.getInstance().getNameById(charId));
|
||||
LOGGER.info("Hero System: Loaded " + numberOfFights + " fights for Hero: " + CharNameTable.getInstance().getNameById(charId));
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
@ -631,12 +623,10 @@ public class Hero
|
||||
{
|
||||
player.sendInventoryUpdate(iu);
|
||||
}
|
||||
|
||||
player.broadcastUserInfo();
|
||||
}
|
||||
|
||||
deleteItemsInDb();
|
||||
|
||||
HEROES.clear();
|
||||
|
||||
if (newHeroes.isEmpty())
|
||||
@ -696,9 +686,9 @@ public class Hero
|
||||
{
|
||||
insert.setInt(1, heroId);
|
||||
insert.setInt(2, hero.getInt(Olympiad.CLASS_ID));
|
||||
insert.setInt(3, hero.getInt(COUNT));
|
||||
insert.setInt(4, hero.getInt(PLAYED));
|
||||
insert.setString(5, String.valueOf(hero.getBoolean(CLAIMED)));
|
||||
insert.setInt(3, hero.getInt(COUNT, 0));
|
||||
insert.setInt(4, hero.getInt(PLAYED, 0));
|
||||
insert.setString(5, String.valueOf(hero.getBoolean(CLAIMED, false)));
|
||||
insert.execute();
|
||||
insert.close();
|
||||
}
|
||||
@ -726,7 +716,6 @@ public class Hero
|
||||
allyCrest = ClanTable.getInstance().getClan(clanId).getAllyCrestId();
|
||||
}
|
||||
}
|
||||
|
||||
hero.set(CLAN_CREST, clanCrest);
|
||||
hero.set(CLAN_NAME, clanName);
|
||||
hero.set(ALLY_CREST, allyCrest);
|
||||
@ -734,17 +723,17 @@ public class Hero
|
||||
}
|
||||
}
|
||||
}
|
||||
HEROES.put(heroId, hero);
|
||||
|
||||
HEROES.put(heroId, hero);
|
||||
COMPLETE_HEROS.put(heroId, hero);
|
||||
}
|
||||
else
|
||||
{
|
||||
try (PreparedStatement statement = con.prepareStatement(UPDATE_HERO))
|
||||
{
|
||||
statement.setInt(1, hero.getInt(COUNT));
|
||||
statement.setInt(2, hero.getInt(PLAYED));
|
||||
statement.setString(3, String.valueOf(hero.getBoolean(CLAIMED)));
|
||||
statement.setInt(1, hero.getInt(COUNT, 0));
|
||||
statement.setInt(2, hero.getInt(PLAYED, 0));
|
||||
statement.setString(3, String.valueOf(hero.getBoolean(CLAIMED, false)));
|
||||
statement.setInt(4, heroId);
|
||||
statement.execute();
|
||||
}
|
||||
@ -773,11 +762,13 @@ public class Hero
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare new data
|
||||
final StatSet diaryEntry = new StatSet();
|
||||
final String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
|
||||
diaryEntry.set("date", date);
|
||||
diaryEntry.set("action", template.getName() + " was defeated");
|
||||
|
||||
// Add to old list
|
||||
list.add(diaryEntry);
|
||||
}
|
||||
@ -792,11 +783,13 @@ public class Hero
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare new data
|
||||
final StatSet diaryEntry = new StatSet();
|
||||
final String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
|
||||
diaryEntry.set("date", date);
|
||||
diaryEntry.set("action", castle.getName() + " Castle was successfuly taken");
|
||||
|
||||
// Add to old list
|
||||
list.add(diaryEntry);
|
||||
}
|
||||
@ -871,10 +864,7 @@ public class Hero
|
||||
*/
|
||||
public void shutdown()
|
||||
{
|
||||
for (int charId : HERO_MESSAGE.keySet())
|
||||
{
|
||||
saveHeroMessage(charId);
|
||||
}
|
||||
HERO_MESSAGE.keySet().forEach(this::saveHeroMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -926,11 +916,13 @@ public class Hero
|
||||
player.broadcastPacket(new SocialAction(player.getObjectId(), 20016)); // Hero Animation
|
||||
player.sendPacket(new UserInfo(player));
|
||||
player.broadcastUserInfo();
|
||||
|
||||
// Set Gained hero and reload data
|
||||
setHeroGained(player.getObjectId());
|
||||
loadFights(player.getObjectId());
|
||||
loadDiary(player.getObjectId());
|
||||
HERO_MESSAGE.put(player.getObjectId(), "");
|
||||
|
||||
EventDispatcher.getInstance().notifyEvent(new OnPlayerTakeHero(player));
|
||||
updateHeroes(false);
|
||||
}
|
||||
|
@ -71,15 +71,12 @@ public class Hero
|
||||
private static final String INSERT_HERO = "INSERT INTO heroes (charId, class_id, count, played, claimed) VALUES (?,?,?,?,?)";
|
||||
private static final String UPDATE_HERO = "UPDATE heroes SET count = ?, played = ?, claimed = ? WHERE charId = ?";
|
||||
private static final String GET_CLAN_ALLY = "SELECT characters.clanid AS clanid, coalesce(clan_data.ally_Id, 0) AS allyId FROM characters LEFT JOIN clan_data ON clan_data.clan_id = characters.clanid WHERE characters.charId = ?";
|
||||
// delete hero items
|
||||
private static final String DELETE_ITEMS = "DELETE FROM items WHERE item_id IN (30392, 30393, 30394, 30395, 30396, 30397, 30398, 30399, 30400, 30401, 30402, 30403, 30404, 30405, 30372, 30373, 6842, 6611, 6612, 6613, 6614, 6615, 6616, 6617, 6618, 6619, 6620, 6621, 9388, 9389, 9390) AND owner_id NOT IN (SELECT charId FROM characters WHERE accesslevel > 0)";
|
||||
|
||||
private static final Map<Integer, StatSet> HEROES = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, StatSet> COMPLETE_HEROS = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Map<Integer, StatSet> HERO_COUNTS = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, List<StatSet>> HERO_FIGHTS = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Map<Integer, List<StatSet>> HERO_DIARY = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, String> HERO_MESSAGE = new ConcurrentHashMap<>();
|
||||
|
||||
@ -128,7 +125,6 @@ public class Hero
|
||||
loadFights(charId);
|
||||
loadDiary(charId);
|
||||
loadMessage(charId);
|
||||
|
||||
processHeros(ps, charId, hero);
|
||||
HEROES.put(charId, hero);
|
||||
}
|
||||
@ -281,7 +277,7 @@ public class Hero
|
||||
data.set(Calendar.MILLISECOND, 0);
|
||||
|
||||
final long from = data.getTimeInMillis();
|
||||
int numberoffights = 0;
|
||||
int numberOfFights = 0;
|
||||
int victories = 0;
|
||||
int losses = 0;
|
||||
int draws = 0;
|
||||
@ -340,10 +336,8 @@ public class Hero
|
||||
fight.set("result", "<font color=\"ffff00\">draw</font>");
|
||||
draws++;
|
||||
}
|
||||
|
||||
fights.add(fight);
|
||||
|
||||
numberoffights++;
|
||||
numberOfFights++;
|
||||
}
|
||||
}
|
||||
else if (charId == charTwoId)
|
||||
@ -374,10 +368,8 @@ public class Hero
|
||||
fight.set("result", "<font color=\"ffff00\">draw</font>");
|
||||
draws++;
|
||||
}
|
||||
|
||||
fights.add(fight);
|
||||
|
||||
numberoffights++;
|
||||
numberOfFights++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -389,7 +381,7 @@ public class Hero
|
||||
HERO_COUNTS.put(charId, heroCountData);
|
||||
HERO_FIGHTS.put(charId, fights);
|
||||
|
||||
LOGGER.info("Hero System: Loaded " + numberoffights + " fights for Hero: " + CharNameTable.getInstance().getNameById(charId));
|
||||
LOGGER.info("Hero System: Loaded " + numberOfFights + " fights for Hero: " + CharNameTable.getInstance().getNameById(charId));
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
@ -631,12 +623,10 @@ public class Hero
|
||||
{
|
||||
player.sendInventoryUpdate(iu);
|
||||
}
|
||||
|
||||
player.broadcastUserInfo();
|
||||
}
|
||||
|
||||
deleteItemsInDb();
|
||||
|
||||
HEROES.clear();
|
||||
|
||||
if (newHeroes.isEmpty())
|
||||
@ -696,9 +686,9 @@ public class Hero
|
||||
{
|
||||
insert.setInt(1, heroId);
|
||||
insert.setInt(2, hero.getInt(Olympiad.CLASS_ID));
|
||||
insert.setInt(3, hero.getInt(COUNT));
|
||||
insert.setInt(4, hero.getInt(PLAYED));
|
||||
insert.setString(5, String.valueOf(hero.getBoolean(CLAIMED)));
|
||||
insert.setInt(3, hero.getInt(COUNT, 0));
|
||||
insert.setInt(4, hero.getInt(PLAYED, 0));
|
||||
insert.setString(5, String.valueOf(hero.getBoolean(CLAIMED, false)));
|
||||
insert.execute();
|
||||
insert.close();
|
||||
}
|
||||
@ -726,7 +716,6 @@ public class Hero
|
||||
allyCrest = ClanTable.getInstance().getClan(clanId).getAllyCrestId();
|
||||
}
|
||||
}
|
||||
|
||||
hero.set(CLAN_CREST, clanCrest);
|
||||
hero.set(CLAN_NAME, clanName);
|
||||
hero.set(ALLY_CREST, allyCrest);
|
||||
@ -734,17 +723,17 @@ public class Hero
|
||||
}
|
||||
}
|
||||
}
|
||||
HEROES.put(heroId, hero);
|
||||
|
||||
HEROES.put(heroId, hero);
|
||||
COMPLETE_HEROS.put(heroId, hero);
|
||||
}
|
||||
else
|
||||
{
|
||||
try (PreparedStatement statement = con.prepareStatement(UPDATE_HERO))
|
||||
{
|
||||
statement.setInt(1, hero.getInt(COUNT));
|
||||
statement.setInt(2, hero.getInt(PLAYED));
|
||||
statement.setString(3, String.valueOf(hero.getBoolean(CLAIMED)));
|
||||
statement.setInt(1, hero.getInt(COUNT, 0));
|
||||
statement.setInt(2, hero.getInt(PLAYED, 0));
|
||||
statement.setString(3, String.valueOf(hero.getBoolean(CLAIMED, false)));
|
||||
statement.setInt(4, heroId);
|
||||
statement.execute();
|
||||
}
|
||||
@ -773,11 +762,13 @@ public class Hero
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare new data
|
||||
final StatSet diaryEntry = new StatSet();
|
||||
final String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
|
||||
diaryEntry.set("date", date);
|
||||
diaryEntry.set("action", template.getName() + " was defeated");
|
||||
|
||||
// Add to old list
|
||||
list.add(diaryEntry);
|
||||
}
|
||||
@ -792,11 +783,13 @@ public class Hero
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare new data
|
||||
final StatSet diaryEntry = new StatSet();
|
||||
final String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
|
||||
diaryEntry.set("date", date);
|
||||
diaryEntry.set("action", castle.getName() + " Castle was successfuly taken");
|
||||
|
||||
// Add to old list
|
||||
list.add(diaryEntry);
|
||||
}
|
||||
@ -871,10 +864,7 @@ public class Hero
|
||||
*/
|
||||
public void shutdown()
|
||||
{
|
||||
for (int charId : HERO_MESSAGE.keySet())
|
||||
{
|
||||
saveHeroMessage(charId);
|
||||
}
|
||||
HERO_MESSAGE.keySet().forEach(this::saveHeroMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -926,11 +916,13 @@ public class Hero
|
||||
player.broadcastPacket(new SocialAction(player.getObjectId(), 20016)); // Hero Animation
|
||||
player.sendPacket(new UserInfo(player));
|
||||
player.broadcastUserInfo();
|
||||
|
||||
// Set Gained hero and reload data
|
||||
setHeroGained(player.getObjectId());
|
||||
loadFights(player.getObjectId());
|
||||
loadDiary(player.getObjectId());
|
||||
HERO_MESSAGE.put(player.getObjectId(), "");
|
||||
|
||||
EventDispatcher.getInstance().notifyEvent(new OnPlayerTakeHero(player));
|
||||
updateHeroes(false);
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ public class OlyManager extends AbstractNpcAI implements IBypassHandler
|
||||
htmltext = getHtm(player, "OlyManager-joinMatchClass.html");
|
||||
break;
|
||||
}
|
||||
default:// Rest is only 1v1 non-class matches
|
||||
default: // Rest is only 1v1 non-class matches
|
||||
{
|
||||
htmltext = getHtm(player, "OlyManager-joinMatch.html");
|
||||
break;
|
||||
|
@ -71,15 +71,12 @@ public class Hero
|
||||
private static final String INSERT_HERO = "INSERT INTO heroes (charId, class_id, count, played, claimed) VALUES (?,?,?,?,?)";
|
||||
private static final String UPDATE_HERO = "UPDATE heroes SET count = ?, played = ?, claimed = ? WHERE charId = ?";
|
||||
private static final String GET_CLAN_ALLY = "SELECT characters.clanid AS clanid, coalesce(clan_data.ally_Id, 0) AS allyId FROM characters LEFT JOIN clan_data ON clan_data.clan_id = characters.clanid WHERE characters.charId = ?";
|
||||
// delete hero items
|
||||
private static final String DELETE_ITEMS = "DELETE FROM items WHERE item_id IN (30392, 30393, 30394, 30395, 30396, 30397, 30398, 30399, 30400, 30401, 30402, 30403, 30404, 30405, 30372, 30373, 6842, 6611, 6612, 6613, 6614, 6615, 6616, 6617, 6618, 6619, 6620, 6621, 9388, 9389, 9390) AND owner_id NOT IN (SELECT charId FROM characters WHERE accesslevel > 0)";
|
||||
|
||||
private static final Map<Integer, StatSet> HEROES = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, StatSet> COMPLETE_HEROS = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Map<Integer, StatSet> HERO_COUNTS = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, List<StatSet>> HERO_FIGHTS = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Map<Integer, List<StatSet>> HERO_DIARY = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, String> HERO_MESSAGE = new ConcurrentHashMap<>();
|
||||
|
||||
@ -128,7 +125,6 @@ public class Hero
|
||||
loadFights(charId);
|
||||
loadDiary(charId);
|
||||
loadMessage(charId);
|
||||
|
||||
processHeros(ps, charId, hero);
|
||||
HEROES.put(charId, hero);
|
||||
}
|
||||
@ -281,7 +277,7 @@ public class Hero
|
||||
data.set(Calendar.MILLISECOND, 0);
|
||||
|
||||
final long from = data.getTimeInMillis();
|
||||
int numberoffights = 0;
|
||||
int numberOfFights = 0;
|
||||
int victories = 0;
|
||||
int losses = 0;
|
||||
int draws = 0;
|
||||
@ -340,10 +336,8 @@ public class Hero
|
||||
fight.set("result", "<font color=\"ffff00\">draw</font>");
|
||||
draws++;
|
||||
}
|
||||
|
||||
fights.add(fight);
|
||||
|
||||
numberoffights++;
|
||||
numberOfFights++;
|
||||
}
|
||||
}
|
||||
else if (charId == charTwoId)
|
||||
@ -374,10 +368,8 @@ public class Hero
|
||||
fight.set("result", "<font color=\"ffff00\">draw</font>");
|
||||
draws++;
|
||||
}
|
||||
|
||||
fights.add(fight);
|
||||
|
||||
numberoffights++;
|
||||
numberOfFights++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -389,7 +381,7 @@ public class Hero
|
||||
HERO_COUNTS.put(charId, heroCountData);
|
||||
HERO_FIGHTS.put(charId, fights);
|
||||
|
||||
LOGGER.info("Hero System: Loaded " + numberoffights + " fights for Hero: " + CharNameTable.getInstance().getNameById(charId));
|
||||
LOGGER.info("Hero System: Loaded " + numberOfFights + " fights for Hero: " + CharNameTable.getInstance().getNameById(charId));
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
@ -631,12 +623,10 @@ public class Hero
|
||||
{
|
||||
player.sendInventoryUpdate(iu);
|
||||
}
|
||||
|
||||
player.broadcastUserInfo();
|
||||
}
|
||||
|
||||
deleteItemsInDb();
|
||||
|
||||
HEROES.clear();
|
||||
|
||||
if (newHeroes.isEmpty())
|
||||
@ -696,9 +686,9 @@ public class Hero
|
||||
{
|
||||
insert.setInt(1, heroId);
|
||||
insert.setInt(2, hero.getInt(Olympiad.CLASS_ID));
|
||||
insert.setInt(3, hero.getInt(COUNT));
|
||||
insert.setInt(4, hero.getInt(PLAYED));
|
||||
insert.setString(5, String.valueOf(hero.getBoolean(CLAIMED)));
|
||||
insert.setInt(3, hero.getInt(COUNT, 0));
|
||||
insert.setInt(4, hero.getInt(PLAYED, 0));
|
||||
insert.setString(5, String.valueOf(hero.getBoolean(CLAIMED, false)));
|
||||
insert.execute();
|
||||
insert.close();
|
||||
}
|
||||
@ -726,7 +716,6 @@ public class Hero
|
||||
allyCrest = ClanTable.getInstance().getClan(clanId).getAllyCrestId();
|
||||
}
|
||||
}
|
||||
|
||||
hero.set(CLAN_CREST, clanCrest);
|
||||
hero.set(CLAN_NAME, clanName);
|
||||
hero.set(ALLY_CREST, allyCrest);
|
||||
@ -734,17 +723,17 @@ public class Hero
|
||||
}
|
||||
}
|
||||
}
|
||||
HEROES.put(heroId, hero);
|
||||
|
||||
HEROES.put(heroId, hero);
|
||||
COMPLETE_HEROS.put(heroId, hero);
|
||||
}
|
||||
else
|
||||
{
|
||||
try (PreparedStatement statement = con.prepareStatement(UPDATE_HERO))
|
||||
{
|
||||
statement.setInt(1, hero.getInt(COUNT));
|
||||
statement.setInt(2, hero.getInt(PLAYED));
|
||||
statement.setString(3, String.valueOf(hero.getBoolean(CLAIMED)));
|
||||
statement.setInt(1, hero.getInt(COUNT, 0));
|
||||
statement.setInt(2, hero.getInt(PLAYED, 0));
|
||||
statement.setString(3, String.valueOf(hero.getBoolean(CLAIMED, false)));
|
||||
statement.setInt(4, heroId);
|
||||
statement.execute();
|
||||
}
|
||||
@ -773,11 +762,13 @@ public class Hero
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare new data
|
||||
final StatSet diaryEntry = new StatSet();
|
||||
final String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
|
||||
diaryEntry.set("date", date);
|
||||
diaryEntry.set("action", template.getName() + " was defeated");
|
||||
|
||||
// Add to old list
|
||||
list.add(diaryEntry);
|
||||
}
|
||||
@ -792,11 +783,13 @@ public class Hero
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare new data
|
||||
final StatSet diaryEntry = new StatSet();
|
||||
final String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
|
||||
diaryEntry.set("date", date);
|
||||
diaryEntry.set("action", castle.getName() + " Castle was successfuly taken");
|
||||
|
||||
// Add to old list
|
||||
list.add(diaryEntry);
|
||||
}
|
||||
@ -871,10 +864,7 @@ public class Hero
|
||||
*/
|
||||
public void shutdown()
|
||||
{
|
||||
for (int charId : HERO_MESSAGE.keySet())
|
||||
{
|
||||
saveHeroMessage(charId);
|
||||
}
|
||||
HERO_MESSAGE.keySet().forEach(this::saveHeroMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -926,11 +916,13 @@ public class Hero
|
||||
player.broadcastPacket(new SocialAction(player.getObjectId(), 20016)); // Hero Animation
|
||||
player.sendPacket(new UserInfo(player));
|
||||
player.broadcastUserInfo();
|
||||
|
||||
// Set Gained hero and reload data
|
||||
setHeroGained(player.getObjectId());
|
||||
loadFights(player.getObjectId());
|
||||
loadDiary(player.getObjectId());
|
||||
HERO_MESSAGE.put(player.getObjectId(), "");
|
||||
|
||||
EventDispatcher.getInstance().notifyEvent(new OnPlayerTakeHero(player));
|
||||
updateHeroes(false);
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ public class OlyManager extends AbstractNpcAI implements IBypassHandler
|
||||
htmltext = getHtm(player, "OlyManager-joinMatchClass.html");
|
||||
break;
|
||||
}
|
||||
default:// Rest is only 1v1 non-class matches
|
||||
default: // Rest is only 1v1 non-class matches
|
||||
{
|
||||
htmltext = getHtm(player, "OlyManager-joinMatch.html");
|
||||
break;
|
||||
|
@ -71,15 +71,12 @@ public class Hero
|
||||
private static final String INSERT_HERO = "INSERT INTO heroes (charId, class_id, count, played, claimed) VALUES (?,?,?,?,?)";
|
||||
private static final String UPDATE_HERO = "UPDATE heroes SET count = ?, played = ?, claimed = ? WHERE charId = ?";
|
||||
private static final String GET_CLAN_ALLY = "SELECT characters.clanid AS clanid, coalesce(clan_data.ally_Id, 0) AS allyId FROM characters LEFT JOIN clan_data ON clan_data.clan_id = characters.clanid WHERE characters.charId = ?";
|
||||
// delete hero items
|
||||
private static final String DELETE_ITEMS = "DELETE FROM items WHERE item_id IN (30392, 30393, 30394, 30395, 30396, 30397, 30398, 30399, 30400, 30401, 30402, 30403, 30404, 30405, 30372, 30373, 6842, 6611, 6612, 6613, 6614, 6615, 6616, 6617, 6618, 6619, 6620, 6621, 9388, 9389, 9390) AND owner_id NOT IN (SELECT charId FROM characters WHERE accesslevel > 0)";
|
||||
|
||||
private static final Map<Integer, StatSet> HEROES = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, StatSet> COMPLETE_HEROS = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Map<Integer, StatSet> HERO_COUNTS = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, List<StatSet>> HERO_FIGHTS = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Map<Integer, List<StatSet>> HERO_DIARY = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, String> HERO_MESSAGE = new ConcurrentHashMap<>();
|
||||
|
||||
@ -128,7 +125,6 @@ public class Hero
|
||||
loadFights(charId);
|
||||
loadDiary(charId);
|
||||
loadMessage(charId);
|
||||
|
||||
processHeros(ps, charId, hero);
|
||||
HEROES.put(charId, hero);
|
||||
}
|
||||
@ -281,7 +277,7 @@ public class Hero
|
||||
data.set(Calendar.MILLISECOND, 0);
|
||||
|
||||
final long from = data.getTimeInMillis();
|
||||
int numberoffights = 0;
|
||||
int numberOfFights = 0;
|
||||
int victories = 0;
|
||||
int losses = 0;
|
||||
int draws = 0;
|
||||
@ -340,10 +336,8 @@ public class Hero
|
||||
fight.set("result", "<font color=\"ffff00\">draw</font>");
|
||||
draws++;
|
||||
}
|
||||
|
||||
fights.add(fight);
|
||||
|
||||
numberoffights++;
|
||||
numberOfFights++;
|
||||
}
|
||||
}
|
||||
else if (charId == charTwoId)
|
||||
@ -374,10 +368,8 @@ public class Hero
|
||||
fight.set("result", "<font color=\"ffff00\">draw</font>");
|
||||
draws++;
|
||||
}
|
||||
|
||||
fights.add(fight);
|
||||
|
||||
numberoffights++;
|
||||
numberOfFights++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -389,7 +381,7 @@ public class Hero
|
||||
HERO_COUNTS.put(charId, heroCountData);
|
||||
HERO_FIGHTS.put(charId, fights);
|
||||
|
||||
LOGGER.info("Hero System: Loaded " + numberoffights + " fights for Hero: " + CharNameTable.getInstance().getNameById(charId));
|
||||
LOGGER.info("Hero System: Loaded " + numberOfFights + " fights for Hero: " + CharNameTable.getInstance().getNameById(charId));
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
@ -631,12 +623,10 @@ public class Hero
|
||||
{
|
||||
player.sendInventoryUpdate(iu);
|
||||
}
|
||||
|
||||
player.broadcastUserInfo();
|
||||
}
|
||||
|
||||
deleteItemsInDb();
|
||||
|
||||
HEROES.clear();
|
||||
|
||||
if (newHeroes.isEmpty())
|
||||
@ -696,9 +686,9 @@ public class Hero
|
||||
{
|
||||
insert.setInt(1, heroId);
|
||||
insert.setInt(2, hero.getInt(Olympiad.CLASS_ID));
|
||||
insert.setInt(3, hero.getInt(COUNT));
|
||||
insert.setInt(4, hero.getInt(PLAYED));
|
||||
insert.setString(5, String.valueOf(hero.getBoolean(CLAIMED)));
|
||||
insert.setInt(3, hero.getInt(COUNT, 0));
|
||||
insert.setInt(4, hero.getInt(PLAYED, 0));
|
||||
insert.setString(5, String.valueOf(hero.getBoolean(CLAIMED, false)));
|
||||
insert.execute();
|
||||
insert.close();
|
||||
}
|
||||
@ -726,7 +716,6 @@ public class Hero
|
||||
allyCrest = ClanTable.getInstance().getClan(clanId).getAllyCrestId();
|
||||
}
|
||||
}
|
||||
|
||||
hero.set(CLAN_CREST, clanCrest);
|
||||
hero.set(CLAN_NAME, clanName);
|
||||
hero.set(ALLY_CREST, allyCrest);
|
||||
@ -734,17 +723,17 @@ public class Hero
|
||||
}
|
||||
}
|
||||
}
|
||||
HEROES.put(heroId, hero);
|
||||
|
||||
HEROES.put(heroId, hero);
|
||||
COMPLETE_HEROS.put(heroId, hero);
|
||||
}
|
||||
else
|
||||
{
|
||||
try (PreparedStatement statement = con.prepareStatement(UPDATE_HERO))
|
||||
{
|
||||
statement.setInt(1, hero.getInt(COUNT));
|
||||
statement.setInt(2, hero.getInt(PLAYED));
|
||||
statement.setString(3, String.valueOf(hero.getBoolean(CLAIMED)));
|
||||
statement.setInt(1, hero.getInt(COUNT, 0));
|
||||
statement.setInt(2, hero.getInt(PLAYED, 0));
|
||||
statement.setString(3, String.valueOf(hero.getBoolean(CLAIMED, false)));
|
||||
statement.setInt(4, heroId);
|
||||
statement.execute();
|
||||
}
|
||||
@ -773,11 +762,13 @@ public class Hero
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare new data
|
||||
final StatSet diaryEntry = new StatSet();
|
||||
final String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
|
||||
diaryEntry.set("date", date);
|
||||
diaryEntry.set("action", template.getName() + " was defeated");
|
||||
|
||||
// Add to old list
|
||||
list.add(diaryEntry);
|
||||
}
|
||||
@ -792,11 +783,13 @@ public class Hero
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare new data
|
||||
final StatSet diaryEntry = new StatSet();
|
||||
final String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
|
||||
diaryEntry.set("date", date);
|
||||
diaryEntry.set("action", castle.getName() + " Castle was successfuly taken");
|
||||
|
||||
// Add to old list
|
||||
list.add(diaryEntry);
|
||||
}
|
||||
@ -871,10 +864,7 @@ public class Hero
|
||||
*/
|
||||
public void shutdown()
|
||||
{
|
||||
for (int charId : HERO_MESSAGE.keySet())
|
||||
{
|
||||
saveHeroMessage(charId);
|
||||
}
|
||||
HERO_MESSAGE.keySet().forEach(this::saveHeroMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -926,11 +916,13 @@ public class Hero
|
||||
player.broadcastPacket(new SocialAction(player.getObjectId(), 20016)); // Hero Animation
|
||||
player.sendPacket(new UserInfo(player));
|
||||
player.broadcastUserInfo();
|
||||
|
||||
// Set Gained hero and reload data
|
||||
setHeroGained(player.getObjectId());
|
||||
loadFights(player.getObjectId());
|
||||
loadDiary(player.getObjectId());
|
||||
HERO_MESSAGE.put(player.getObjectId(), "");
|
||||
|
||||
EventDispatcher.getInstance().notifyEvent(new OnPlayerTakeHero(player));
|
||||
updateHeroes(false);
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ public class OlyManager extends AbstractNpcAI implements IBypassHandler
|
||||
htmltext = getHtm(player, "OlyManager-joinMatchClass.html");
|
||||
break;
|
||||
}
|
||||
default:// Rest is only 1v1 non-class matches
|
||||
default: // Rest is only 1v1 non-class matches
|
||||
{
|
||||
htmltext = getHtm(player, "OlyManager-joinMatch.html");
|
||||
break;
|
||||
|
@ -71,15 +71,12 @@ public class Hero
|
||||
private static final String INSERT_HERO = "INSERT INTO heroes (charId, class_id, count, played, claimed) VALUES (?,?,?,?,?)";
|
||||
private static final String UPDATE_HERO = "UPDATE heroes SET count = ?, played = ?, claimed = ? WHERE charId = ?";
|
||||
private static final String GET_CLAN_ALLY = "SELECT characters.clanid AS clanid, coalesce(clan_data.ally_Id, 0) AS allyId FROM characters LEFT JOIN clan_data ON clan_data.clan_id = characters.clanid WHERE characters.charId = ?";
|
||||
// delete hero items
|
||||
private static final String DELETE_ITEMS = "DELETE FROM items WHERE item_id IN (30392, 30393, 30394, 30395, 30396, 30397, 30398, 30399, 30400, 30401, 30402, 30403, 30404, 30405, 30372, 30373, 6842, 6611, 6612, 6613, 6614, 6615, 6616, 6617, 6618, 6619, 6620, 6621, 9388, 9389, 9390) AND owner_id NOT IN (SELECT charId FROM characters WHERE accesslevel > 0)";
|
||||
|
||||
private static final Map<Integer, StatSet> HEROES = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, StatSet> COMPLETE_HEROS = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Map<Integer, StatSet> HERO_COUNTS = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, List<StatSet>> HERO_FIGHTS = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Map<Integer, List<StatSet>> HERO_DIARY = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, String> HERO_MESSAGE = new ConcurrentHashMap<>();
|
||||
|
||||
@ -128,7 +125,6 @@ public class Hero
|
||||
loadFights(charId);
|
||||
loadDiary(charId);
|
||||
loadMessage(charId);
|
||||
|
||||
processHeros(ps, charId, hero);
|
||||
HEROES.put(charId, hero);
|
||||
}
|
||||
@ -281,7 +277,7 @@ public class Hero
|
||||
data.set(Calendar.MILLISECOND, 0);
|
||||
|
||||
final long from = data.getTimeInMillis();
|
||||
int numberoffights = 0;
|
||||
int numberOfFights = 0;
|
||||
int victories = 0;
|
||||
int losses = 0;
|
||||
int draws = 0;
|
||||
@ -340,10 +336,8 @@ public class Hero
|
||||
fight.set("result", "<font color=\"ffff00\">draw</font>");
|
||||
draws++;
|
||||
}
|
||||
|
||||
fights.add(fight);
|
||||
|
||||
numberoffights++;
|
||||
numberOfFights++;
|
||||
}
|
||||
}
|
||||
else if (charId == charTwoId)
|
||||
@ -374,10 +368,8 @@ public class Hero
|
||||
fight.set("result", "<font color=\"ffff00\">draw</font>");
|
||||
draws++;
|
||||
}
|
||||
|
||||
fights.add(fight);
|
||||
|
||||
numberoffights++;
|
||||
numberOfFights++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -389,7 +381,7 @@ public class Hero
|
||||
HERO_COUNTS.put(charId, heroCountData);
|
||||
HERO_FIGHTS.put(charId, fights);
|
||||
|
||||
LOGGER.info("Hero System: Loaded " + numberoffights + " fights for Hero: " + CharNameTable.getInstance().getNameById(charId));
|
||||
LOGGER.info("Hero System: Loaded " + numberOfFights + " fights for Hero: " + CharNameTable.getInstance().getNameById(charId));
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
@ -631,12 +623,10 @@ public class Hero
|
||||
{
|
||||
player.sendInventoryUpdate(iu);
|
||||
}
|
||||
|
||||
player.broadcastUserInfo();
|
||||
}
|
||||
|
||||
deleteItemsInDb();
|
||||
|
||||
HEROES.clear();
|
||||
|
||||
if (newHeroes.isEmpty())
|
||||
@ -696,9 +686,9 @@ public class Hero
|
||||
{
|
||||
insert.setInt(1, heroId);
|
||||
insert.setInt(2, hero.getInt(Olympiad.CLASS_ID));
|
||||
insert.setInt(3, hero.getInt(COUNT));
|
||||
insert.setInt(4, hero.getInt(PLAYED));
|
||||
insert.setString(5, String.valueOf(hero.getBoolean(CLAIMED)));
|
||||
insert.setInt(3, hero.getInt(COUNT, 0));
|
||||
insert.setInt(4, hero.getInt(PLAYED, 0));
|
||||
insert.setString(5, String.valueOf(hero.getBoolean(CLAIMED, false)));
|
||||
insert.execute();
|
||||
insert.close();
|
||||
}
|
||||
@ -726,7 +716,6 @@ public class Hero
|
||||
allyCrest = ClanTable.getInstance().getClan(clanId).getAllyCrestId();
|
||||
}
|
||||
}
|
||||
|
||||
hero.set(CLAN_CREST, clanCrest);
|
||||
hero.set(CLAN_NAME, clanName);
|
||||
hero.set(ALLY_CREST, allyCrest);
|
||||
@ -734,17 +723,17 @@ public class Hero
|
||||
}
|
||||
}
|
||||
}
|
||||
HEROES.put(heroId, hero);
|
||||
|
||||
HEROES.put(heroId, hero);
|
||||
COMPLETE_HEROS.put(heroId, hero);
|
||||
}
|
||||
else
|
||||
{
|
||||
try (PreparedStatement statement = con.prepareStatement(UPDATE_HERO))
|
||||
{
|
||||
statement.setInt(1, hero.getInt(COUNT));
|
||||
statement.setInt(2, hero.getInt(PLAYED));
|
||||
statement.setString(3, String.valueOf(hero.getBoolean(CLAIMED)));
|
||||
statement.setInt(1, hero.getInt(COUNT, 0));
|
||||
statement.setInt(2, hero.getInt(PLAYED, 0));
|
||||
statement.setString(3, String.valueOf(hero.getBoolean(CLAIMED, false)));
|
||||
statement.setInt(4, heroId);
|
||||
statement.execute();
|
||||
}
|
||||
@ -773,11 +762,13 @@ public class Hero
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare new data
|
||||
final StatSet diaryEntry = new StatSet();
|
||||
final String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
|
||||
diaryEntry.set("date", date);
|
||||
diaryEntry.set("action", template.getName() + " was defeated");
|
||||
|
||||
// Add to old list
|
||||
list.add(diaryEntry);
|
||||
}
|
||||
@ -792,11 +783,13 @@ public class Hero
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare new data
|
||||
final StatSet diaryEntry = new StatSet();
|
||||
final String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
|
||||
diaryEntry.set("date", date);
|
||||
diaryEntry.set("action", castle.getName() + " Castle was successfuly taken");
|
||||
|
||||
// Add to old list
|
||||
list.add(diaryEntry);
|
||||
}
|
||||
@ -871,10 +864,7 @@ public class Hero
|
||||
*/
|
||||
public void shutdown()
|
||||
{
|
||||
for (int charId : HERO_MESSAGE.keySet())
|
||||
{
|
||||
saveHeroMessage(charId);
|
||||
}
|
||||
HERO_MESSAGE.keySet().forEach(this::saveHeroMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -926,11 +916,13 @@ public class Hero
|
||||
player.broadcastPacket(new SocialAction(player.getObjectId(), 20016)); // Hero Animation
|
||||
player.sendPacket(new UserInfo(player));
|
||||
player.broadcastUserInfo();
|
||||
|
||||
// Set Gained hero and reload data
|
||||
setHeroGained(player.getObjectId());
|
||||
loadFights(player.getObjectId());
|
||||
loadDiary(player.getObjectId());
|
||||
HERO_MESSAGE.put(player.getObjectId(), "");
|
||||
|
||||
EventDispatcher.getInstance().notifyEvent(new OnPlayerTakeHero(player));
|
||||
updateHeroes(false);
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ public class OlyManager extends AbstractNpcAI implements IBypassHandler
|
||||
htmltext = getHtm(player, "OlyManager-joinMatchClass.html");
|
||||
break;
|
||||
}
|
||||
default:// Rest is only 1v1 non-class matches
|
||||
default: // Rest is only 1v1 non-class matches
|
||||
{
|
||||
htmltext = getHtm(player, "OlyManager-joinMatch.html");
|
||||
break;
|
||||
|
@ -71,15 +71,12 @@ public class Hero
|
||||
private static final String INSERT_HERO = "INSERT INTO heroes (charId, class_id, count, played, claimed) VALUES (?,?,?,?,?)";
|
||||
private static final String UPDATE_HERO = "UPDATE heroes SET count = ?, played = ?, claimed = ? WHERE charId = ?";
|
||||
private static final String GET_CLAN_ALLY = "SELECT characters.clanid AS clanid, coalesce(clan_data.ally_Id, 0) AS allyId FROM characters LEFT JOIN clan_data ON clan_data.clan_id = characters.clanid WHERE characters.charId = ?";
|
||||
// delete hero items
|
||||
private static final String DELETE_ITEMS = "DELETE FROM items WHERE item_id IN (30392, 30393, 30394, 30395, 30396, 30397, 30398, 30399, 30400, 30401, 30402, 30403, 30404, 30405, 30372, 30373, 6842, 6611, 6612, 6613, 6614, 6615, 6616, 6617, 6618, 6619, 6620, 6621, 9388, 9389, 9390) AND owner_id NOT IN (SELECT charId FROM characters WHERE accesslevel > 0)";
|
||||
|
||||
private static final Map<Integer, StatSet> HEROES = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, StatSet> COMPLETE_HEROS = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Map<Integer, StatSet> HERO_COUNTS = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, List<StatSet>> HERO_FIGHTS = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Map<Integer, List<StatSet>> HERO_DIARY = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, String> HERO_MESSAGE = new ConcurrentHashMap<>();
|
||||
|
||||
@ -128,7 +125,6 @@ public class Hero
|
||||
loadFights(charId);
|
||||
loadDiary(charId);
|
||||
loadMessage(charId);
|
||||
|
||||
processHeros(ps, charId, hero);
|
||||
HEROES.put(charId, hero);
|
||||
}
|
||||
@ -281,7 +277,7 @@ public class Hero
|
||||
data.set(Calendar.MILLISECOND, 0);
|
||||
|
||||
final long from = data.getTimeInMillis();
|
||||
int numberoffights = 0;
|
||||
int numberOfFights = 0;
|
||||
int victories = 0;
|
||||
int losses = 0;
|
||||
int draws = 0;
|
||||
@ -340,10 +336,8 @@ public class Hero
|
||||
fight.set("result", "<font color=\"ffff00\">draw</font>");
|
||||
draws++;
|
||||
}
|
||||
|
||||
fights.add(fight);
|
||||
|
||||
numberoffights++;
|
||||
numberOfFights++;
|
||||
}
|
||||
}
|
||||
else if (charId == charTwoId)
|
||||
@ -374,10 +368,8 @@ public class Hero
|
||||
fight.set("result", "<font color=\"ffff00\">draw</font>");
|
||||
draws++;
|
||||
}
|
||||
|
||||
fights.add(fight);
|
||||
|
||||
numberoffights++;
|
||||
numberOfFights++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -389,7 +381,7 @@ public class Hero
|
||||
HERO_COUNTS.put(charId, heroCountData);
|
||||
HERO_FIGHTS.put(charId, fights);
|
||||
|
||||
LOGGER.info("Hero System: Loaded " + numberoffights + " fights for Hero: " + CharNameTable.getInstance().getNameById(charId));
|
||||
LOGGER.info("Hero System: Loaded " + numberOfFights + " fights for Hero: " + CharNameTable.getInstance().getNameById(charId));
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
@ -631,12 +623,10 @@ public class Hero
|
||||
{
|
||||
player.sendInventoryUpdate(iu);
|
||||
}
|
||||
|
||||
player.broadcastUserInfo();
|
||||
}
|
||||
|
||||
deleteItemsInDb();
|
||||
|
||||
HEROES.clear();
|
||||
|
||||
if (newHeroes.isEmpty())
|
||||
@ -696,9 +686,9 @@ public class Hero
|
||||
{
|
||||
insert.setInt(1, heroId);
|
||||
insert.setInt(2, hero.getInt(Olympiad.CLASS_ID));
|
||||
insert.setInt(3, hero.getInt(COUNT));
|
||||
insert.setInt(4, hero.getInt(PLAYED));
|
||||
insert.setString(5, String.valueOf(hero.getBoolean(CLAIMED)));
|
||||
insert.setInt(3, hero.getInt(COUNT, 0));
|
||||
insert.setInt(4, hero.getInt(PLAYED, 0));
|
||||
insert.setString(5, String.valueOf(hero.getBoolean(CLAIMED, false)));
|
||||
insert.execute();
|
||||
insert.close();
|
||||
}
|
||||
@ -726,7 +716,6 @@ public class Hero
|
||||
allyCrest = ClanTable.getInstance().getClan(clanId).getAllyCrestId();
|
||||
}
|
||||
}
|
||||
|
||||
hero.set(CLAN_CREST, clanCrest);
|
||||
hero.set(CLAN_NAME, clanName);
|
||||
hero.set(ALLY_CREST, allyCrest);
|
||||
@ -734,17 +723,17 @@ public class Hero
|
||||
}
|
||||
}
|
||||
}
|
||||
HEROES.put(heroId, hero);
|
||||
|
||||
HEROES.put(heroId, hero);
|
||||
COMPLETE_HEROS.put(heroId, hero);
|
||||
}
|
||||
else
|
||||
{
|
||||
try (PreparedStatement statement = con.prepareStatement(UPDATE_HERO))
|
||||
{
|
||||
statement.setInt(1, hero.getInt(COUNT));
|
||||
statement.setInt(2, hero.getInt(PLAYED));
|
||||
statement.setString(3, String.valueOf(hero.getBoolean(CLAIMED)));
|
||||
statement.setInt(1, hero.getInt(COUNT, 0));
|
||||
statement.setInt(2, hero.getInt(PLAYED, 0));
|
||||
statement.setString(3, String.valueOf(hero.getBoolean(CLAIMED, false)));
|
||||
statement.setInt(4, heroId);
|
||||
statement.execute();
|
||||
}
|
||||
@ -773,11 +762,13 @@ public class Hero
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare new data
|
||||
final StatSet diaryEntry = new StatSet();
|
||||
final String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
|
||||
diaryEntry.set("date", date);
|
||||
diaryEntry.set("action", template.getName() + " was defeated");
|
||||
|
||||
// Add to old list
|
||||
list.add(diaryEntry);
|
||||
}
|
||||
@ -792,11 +783,13 @@ public class Hero
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare new data
|
||||
final StatSet diaryEntry = new StatSet();
|
||||
final String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
|
||||
diaryEntry.set("date", date);
|
||||
diaryEntry.set("action", castle.getName() + " Castle was successfuly taken");
|
||||
|
||||
// Add to old list
|
||||
list.add(diaryEntry);
|
||||
}
|
||||
@ -871,10 +864,7 @@ public class Hero
|
||||
*/
|
||||
public void shutdown()
|
||||
{
|
||||
for (int charId : HERO_MESSAGE.keySet())
|
||||
{
|
||||
saveHeroMessage(charId);
|
||||
}
|
||||
HERO_MESSAGE.keySet().forEach(this::saveHeroMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -926,11 +916,13 @@ public class Hero
|
||||
player.broadcastPacket(new SocialAction(player.getObjectId(), 20016)); // Hero Animation
|
||||
player.sendPacket(new UserInfo(player));
|
||||
player.broadcastUserInfo();
|
||||
|
||||
// Set Gained hero and reload data
|
||||
setHeroGained(player.getObjectId());
|
||||
loadFights(player.getObjectId());
|
||||
loadDiary(player.getObjectId());
|
||||
HERO_MESSAGE.put(player.getObjectId(), "");
|
||||
|
||||
EventDispatcher.getInstance().notifyEvent(new OnPlayerTakeHero(player));
|
||||
updateHeroes(false);
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ public class OlyManager extends AbstractNpcAI implements IBypassHandler
|
||||
htmltext = getHtm(player, "OlyManager-joinMatchClass.html");
|
||||
break;
|
||||
}
|
||||
default:// Rest is only 1v1 non-class matches
|
||||
default: // Rest is only 1v1 non-class matches
|
||||
{
|
||||
htmltext = getHtm(player, "OlyManager-joinMatch.html");
|
||||
break;
|
||||
|
@ -71,15 +71,12 @@ public class Hero
|
||||
private static final String INSERT_HERO = "INSERT INTO heroes (charId, class_id, count, legend_count, played, claimed) VALUES (?,?,?,?,?,?)";
|
||||
private static final String UPDATE_HERO = "UPDATE heroes SET count = ?, legend_count = ?, played = ?, claimed = ? WHERE charId = ?";
|
||||
private static final String GET_CLAN_ALLY = "SELECT characters.clanid AS clanid, coalesce(clan_data.ally_Id, 0) AS allyId FROM characters LEFT JOIN clan_data ON clan_data.clan_id = characters.clanid WHERE characters.charId = ?";
|
||||
// delete hero items
|
||||
private static final String DELETE_ITEMS = "DELETE FROM items WHERE item_id IN (30392, 30393, 30394, 30395, 30396, 30397, 30398, 30399, 30400, 30401, 30402, 30403, 30404, 30405, 30372, 30373, 6842, 6611, 6612, 6613, 6614, 6615, 6616, 6617, 6618, 6619, 6620, 6621, 9388, 9389, 9390) AND owner_id NOT IN (SELECT charId FROM characters WHERE accesslevel > 0)";
|
||||
|
||||
private static final Map<Integer, StatSet> HEROES = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, StatSet> COMPLETE_HEROS = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Map<Integer, StatSet> HERO_COUNTS = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, List<StatSet>> HERO_FIGHTS = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Map<Integer, List<StatSet>> HERO_DIARY = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, String> HERO_MESSAGE = new ConcurrentHashMap<>();
|
||||
|
||||
@ -130,7 +127,6 @@ public class Hero
|
||||
loadFights(charId);
|
||||
loadDiary(charId);
|
||||
loadMessage(charId);
|
||||
|
||||
processHeros(ps, charId, hero);
|
||||
HEROES.put(charId, hero);
|
||||
}
|
||||
@ -284,7 +280,7 @@ public class Hero
|
||||
data.set(Calendar.MILLISECOND, 0);
|
||||
|
||||
final long from = data.getTimeInMillis();
|
||||
int numberoffights = 0;
|
||||
int numberOfFights = 0;
|
||||
int victories = 0;
|
||||
int losses = 0;
|
||||
int draws = 0;
|
||||
@ -343,10 +339,8 @@ public class Hero
|
||||
fight.set("result", "<font color=\"ffff00\">draw</font>");
|
||||
draws++;
|
||||
}
|
||||
|
||||
fights.add(fight);
|
||||
|
||||
numberoffights++;
|
||||
numberOfFights++;
|
||||
}
|
||||
}
|
||||
else if (charId == charTwoId)
|
||||
@ -377,10 +371,8 @@ public class Hero
|
||||
fight.set("result", "<font color=\"ffff00\">draw</font>");
|
||||
draws++;
|
||||
}
|
||||
|
||||
fights.add(fight);
|
||||
|
||||
numberoffights++;
|
||||
numberOfFights++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -392,7 +384,7 @@ public class Hero
|
||||
HERO_COUNTS.put(charId, heroCountData);
|
||||
HERO_FIGHTS.put(charId, fights);
|
||||
|
||||
LOGGER.info("Hero System: Loaded " + numberoffights + " fights for Hero: " + CharNameTable.getInstance().getNameById(charId));
|
||||
LOGGER.info("Hero System: Loaded " + numberOfFights + " fights for Hero: " + CharNameTable.getInstance().getNameById(charId));
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
@ -639,12 +631,10 @@ public class Hero
|
||||
{
|
||||
player.sendInventoryUpdate(iu);
|
||||
}
|
||||
|
||||
player.broadcastUserInfo();
|
||||
}
|
||||
|
||||
deleteItemsInDb();
|
||||
|
||||
HEROES.clear();
|
||||
|
||||
if (newHeroes.isEmpty())
|
||||
@ -719,10 +709,10 @@ public class Hero
|
||||
{
|
||||
insert.setInt(1, heroId);
|
||||
insert.setInt(2, hero.getInt(Olympiad.CLASS_ID));
|
||||
insert.setInt(3, hero.getInt(COUNT));
|
||||
insert.setInt(4, hero.getInt(LEGEND_COUNT));
|
||||
insert.setInt(5, hero.getInt(PLAYED));
|
||||
insert.setString(6, String.valueOf(hero.getBoolean(CLAIMED)));
|
||||
insert.setInt(3, hero.getInt(COUNT, 0));
|
||||
insert.setInt(4, hero.getInt(LEGEND_COUNT, 0));
|
||||
insert.setInt(5, hero.getInt(PLAYED, 0));
|
||||
insert.setString(6, String.valueOf(hero.getBoolean(CLAIMED, false)));
|
||||
insert.execute();
|
||||
insert.close();
|
||||
}
|
||||
@ -750,7 +740,6 @@ public class Hero
|
||||
allyCrest = ClanTable.getInstance().getClan(clanId).getAllyCrestId();
|
||||
}
|
||||
}
|
||||
|
||||
hero.set(CLAN_CREST, clanCrest);
|
||||
hero.set(CLAN_NAME, clanName);
|
||||
hero.set(ALLY_CREST, allyCrest);
|
||||
@ -758,19 +747,19 @@ public class Hero
|
||||
}
|
||||
}
|
||||
}
|
||||
HEROES.put(heroId, hero);
|
||||
|
||||
HEROES.put(heroId, hero);
|
||||
COMPLETE_HEROS.put(heroId, hero);
|
||||
}
|
||||
else
|
||||
{
|
||||
try (PreparedStatement statement = con.prepareStatement(UPDATE_HERO))
|
||||
{
|
||||
statement.setInt(1, hero.getInt(COUNT));
|
||||
statement.setInt(2, hero.getInt(LEGEND_COUNT));
|
||||
statement.setInt(2, hero.getInt(PLAYED));
|
||||
statement.setString(3, String.valueOf(hero.getBoolean(CLAIMED)));
|
||||
statement.setInt(4, heroId);
|
||||
statement.setInt(1, hero.getInt(COUNT, 0));
|
||||
statement.setInt(2, hero.getInt(LEGEND_COUNT, 0));
|
||||
statement.setInt(3, hero.getInt(PLAYED, 0));
|
||||
statement.setString(4, String.valueOf(hero.getBoolean(CLAIMED, false)));
|
||||
statement.setInt(5, heroId);
|
||||
statement.execute();
|
||||
}
|
||||
}
|
||||
@ -798,11 +787,13 @@ public class Hero
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare new data
|
||||
final StatSet diaryEntry = new StatSet();
|
||||
final String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
|
||||
diaryEntry.set("date", date);
|
||||
diaryEntry.set("action", template.getName() + " was defeated");
|
||||
|
||||
// Add to old list
|
||||
list.add(diaryEntry);
|
||||
}
|
||||
@ -817,11 +808,13 @@ public class Hero
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare new data
|
||||
final StatSet diaryEntry = new StatSet();
|
||||
final String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
|
||||
diaryEntry.set("date", date);
|
||||
diaryEntry.set("action", castle.getName() + " Castle was successfuly taken");
|
||||
|
||||
// Add to old list
|
||||
list.add(diaryEntry);
|
||||
}
|
||||
@ -896,10 +889,7 @@ public class Hero
|
||||
*/
|
||||
public void shutdown()
|
||||
{
|
||||
for (int charId : HERO_MESSAGE.keySet())
|
||||
{
|
||||
saveHeroMessage(charId);
|
||||
}
|
||||
HERO_MESSAGE.keySet().forEach(this::saveHeroMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -951,11 +941,13 @@ public class Hero
|
||||
player.broadcastPacket(new SocialAction(player.getObjectId(), 20016)); // Hero Animation
|
||||
player.sendPacket(new UserInfo(player));
|
||||
player.broadcastUserInfo();
|
||||
|
||||
// Set Gained hero and reload data
|
||||
setHeroGained(player.getObjectId());
|
||||
loadFights(player.getObjectId());
|
||||
loadDiary(player.getObjectId());
|
||||
HERO_MESSAGE.put(player.getObjectId(), "");
|
||||
|
||||
EventDispatcher.getInstance().notifyEvent(new OnPlayerTakeHero(player));
|
||||
updateHeroes(false);
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
@ -57,9 +58,9 @@ public class Hero
|
||||
private static final String GET_CLAN_ALLY = "SELECT characters.clanid AS clanid, coalesce(clan_data.ally_Id, 0) AS allyId FROM characters LEFT JOIN clan_data ON clan_data.clan_id = characters.clanid WHERE characters.obj_Id = ?";
|
||||
private static final String GET_CLAN_NAME = "SELECT clan_name FROM clan_data WHERE clan_id = (SELECT clanid FROM characters WHERE char_name = ?)";
|
||||
private static final String DELETE_ITEMS = "DELETE FROM items WHERE item_id IN (6842, 6611, 6612, 6613, 6614, 6615, 6616, 6617, 6618, 6619, 6620, 6621) AND owner_id NOT IN (SELECT obj_id FROM characters WHERE accesslevel > 0)";
|
||||
private static final List<Integer> _heroItems = Arrays.asList(6842, 6611, 6612, 6613, 6614, 6615, 6616, 6617, 6618, 6619, 6620, 6621);
|
||||
private static Map<Integer, StatSet> _heroes;
|
||||
private static Map<Integer, StatSet> _completeHeroes;
|
||||
private static final List<Integer> HERO_ITEMS = Arrays.asList(6842, 6611, 6612, 6613, 6614, 6615, 6616, 6617, 6618, 6619, 6620, 6621);
|
||||
private static final Map<Integer, StatSet> HEROES = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, StatSet> COMPLETE_HEROES = new ConcurrentHashMap<>();
|
||||
|
||||
public static final String COUNT = "count";
|
||||
public static final String PLAYED = "played";
|
||||
@ -75,8 +76,6 @@ public class Hero
|
||||
|
||||
private void init()
|
||||
{
|
||||
_heroes = new HashMap<>();
|
||||
_completeHeroes = new HashMap<>();
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
PreparedStatement statement = null;
|
||||
@ -121,7 +120,7 @@ public class Hero
|
||||
}
|
||||
rset2.close();
|
||||
statement2.close();
|
||||
_heroes.put(charId, hero);
|
||||
HEROES.put(charId, hero);
|
||||
}
|
||||
rset.close();
|
||||
statement.close();
|
||||
@ -172,15 +171,15 @@ public class Hero
|
||||
}
|
||||
rset2.close();
|
||||
statement2.close();
|
||||
_completeHeroes.put(charId, hero);
|
||||
COMPLETE_HEROES.put(charId, hero);
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
LOGGER.warning("Hero System: Couldnt load Heroes");
|
||||
}
|
||||
LOGGER.info("Hero System: Loaded " + _heroes.size() + " Heroes.");
|
||||
LOGGER.info("Hero System: Loaded " + _completeHeroes.size() + " all time Heroes.");
|
||||
LOGGER.info("Hero System: Loaded " + HEROES.size() + " Heroes.");
|
||||
LOGGER.info("Hero System: Loaded " + COMPLETE_HEROES.size() + " all time Heroes.");
|
||||
}
|
||||
|
||||
public void putHero(PlayerInstance player, boolean isComplete)
|
||||
@ -192,10 +191,10 @@ public class Hero
|
||||
newHero.set(Olympiad.CLASS_ID, player.getClassId().getId());
|
||||
newHero.set(COUNT, 1);
|
||||
newHero.set(PLAYED, 1);
|
||||
_heroes.put(player.getObjectId(), newHero);
|
||||
HEROES.put(player.getObjectId(), newHero);
|
||||
if (isComplete)
|
||||
{
|
||||
_completeHeroes.put(player.getObjectId(), newHero);
|
||||
COMPLETE_HEROES.put(player.getObjectId(), newHero);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
@ -206,19 +205,19 @@ public class Hero
|
||||
public void deleteHero(PlayerInstance player, boolean isComplete)
|
||||
{
|
||||
final int objId = player.getObjectId();
|
||||
if (_heroes.containsKey(objId))
|
||||
if (HEROES.containsKey(objId))
|
||||
{
|
||||
_heroes.remove(objId);
|
||||
HEROES.remove(objId);
|
||||
}
|
||||
if (isComplete && _completeHeroes.containsKey(objId))
|
||||
if (isComplete && COMPLETE_HEROES.containsKey(objId))
|
||||
{
|
||||
_completeHeroes.remove(objId);
|
||||
COMPLETE_HEROES.remove(objId);
|
||||
}
|
||||
}
|
||||
|
||||
public Map<Integer, StatSet> getHeroes()
|
||||
{
|
||||
return _heroes;
|
||||
return HEROES;
|
||||
}
|
||||
|
||||
public synchronized void computeNewHeroes(List<StatSet> newHeroes)
|
||||
@ -226,9 +225,9 @@ public class Hero
|
||||
updateHeroes(true);
|
||||
ItemInstance[] items;
|
||||
InventoryUpdate iu;
|
||||
if (_heroes.size() != 0)
|
||||
if (HEROES.size() != 0)
|
||||
{
|
||||
for (StatSet hero : _heroes.values())
|
||||
for (StatSet hero : HEROES.values())
|
||||
{
|
||||
final String name = hero.getString(Olympiad.CHAR_NAME);
|
||||
final PlayerInstance player = World.getInstance().getPlayer(name);
|
||||
@ -280,7 +279,7 @@ public class Hero
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!_heroItems.contains(item.getItemId()))
|
||||
if (!HERO_ITEMS.contains(item.getItemId()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -297,18 +296,20 @@ public class Hero
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (newHeroes.isEmpty())
|
||||
{
|
||||
_heroes.clear();
|
||||
HEROES.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
final Map<Integer, StatSet> heroes = new HashMap<>();
|
||||
for (StatSet hero : newHeroes)
|
||||
{
|
||||
final int charId = hero.getInt(Olympiad.CHAR_ID);
|
||||
if ((_completeHeroes != null) && _completeHeroes.containsKey(charId))
|
||||
if ((COMPLETE_HEROES != null) && COMPLETE_HEROES.containsKey(charId))
|
||||
{
|
||||
final StatSet oldHero = _completeHeroes.get(charId);
|
||||
final StatSet oldHero = COMPLETE_HEROES.get(charId);
|
||||
final int count = oldHero.getInt(COUNT);
|
||||
oldHero.set(COUNT, count + 1);
|
||||
oldHero.set(PLAYED, 1);
|
||||
@ -325,11 +326,11 @@ public class Hero
|
||||
}
|
||||
}
|
||||
deleteItemsInDb();
|
||||
_heroes.clear();
|
||||
_heroes.putAll(heroes);
|
||||
HEROES.clear();
|
||||
HEROES.putAll(heroes);
|
||||
heroes.clear();
|
||||
updateHeroes(false);
|
||||
for (StatSet hero : _heroes.values())
|
||||
for (StatSet hero : HEROES.values())
|
||||
{
|
||||
final String name = hero.getString(Olympiad.CHAR_NAME);
|
||||
final PlayerInstance player = World.getInstance().getPlayer(name);
|
||||
@ -401,19 +402,20 @@ public class Hero
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Entry<Integer, StatSet> entry : _heroes.entrySet())
|
||||
for (Entry<Integer, StatSet> entry : HEROES.entrySet())
|
||||
{
|
||||
final Integer heroId = entry.getKey();
|
||||
final StatSet hero = entry.getValue();
|
||||
if ((_completeHeroes == null) || !_completeHeroes.containsKey(heroId))
|
||||
if ((COMPLETE_HEROES == null) || !COMPLETE_HEROES.containsKey(heroId))
|
||||
{
|
||||
statement = con.prepareStatement(INSERT_HERO);
|
||||
statement.setInt(1, heroId);
|
||||
statement.setString(2, hero.getString(Olympiad.CHAR_NAME));
|
||||
statement.setInt(3, hero.getInt(Olympiad.CLASS_ID));
|
||||
statement.setInt(4, hero.getInt(COUNT));
|
||||
statement.setInt(5, hero.getInt(PLAYED));
|
||||
statement.setInt(4, hero.getInt(COUNT, 0));
|
||||
statement.setInt(5, hero.getInt(PLAYED, 0));
|
||||
statement.execute();
|
||||
|
||||
statement2 = con.prepareStatement(GET_CLAN_ALLY);
|
||||
statement2.setInt(1, heroId);
|
||||
rset2 = statement2.executeQuery();
|
||||
@ -442,15 +444,15 @@ public class Hero
|
||||
}
|
||||
rset2.close();
|
||||
statement2.close();
|
||||
// _heroes.remove(heroId);
|
||||
_heroes.put(heroId, hero);
|
||||
_completeHeroes.put(heroId, hero);
|
||||
|
||||
HEROES.put(heroId, hero);
|
||||
COMPLETE_HEROES.put(heroId, hero);
|
||||
}
|
||||
else
|
||||
{
|
||||
statement = con.prepareStatement(UPDATE_HERO);
|
||||
statement.setInt(1, hero.getInt(COUNT));
|
||||
statement.setInt(2, hero.getInt(PLAYED));
|
||||
statement.setInt(1, hero.getInt(COUNT, 0));
|
||||
statement.setInt(2, hero.getInt(PLAYED, 0));
|
||||
statement.setInt(3, heroId);
|
||||
statement.execute();
|
||||
}
|
||||
@ -466,7 +468,7 @@ public class Hero
|
||||
|
||||
public List<Integer> getHeroItems()
|
||||
{
|
||||
return _heroItems;
|
||||
return HERO_ITEMS;
|
||||
}
|
||||
|
||||
private void deleteItemsInDb()
|
||||
|
@ -70,15 +70,12 @@ public class Hero
|
||||
private static final String INSERT_HERO = "INSERT INTO heroes (charId, class_id, count, played, claimed) VALUES (?,?,?,?,?)";
|
||||
private static final String UPDATE_HERO = "UPDATE heroes SET count = ?, played = ?, claimed = ? WHERE charId = ?";
|
||||
private static final String GET_CLAN_ALLY = "SELECT characters.clanid AS clanid, coalesce(clan_data.ally_Id, 0) AS allyId FROM characters LEFT JOIN clan_data ON clan_data.clan_id = characters.clanid WHERE characters.charId = ?";
|
||||
// delete hero items
|
||||
private static final String DELETE_ITEMS = "DELETE FROM items WHERE item_id IN (6842, 6611, 6612, 6613, 6614, 6615, 6616, 6617, 6618, 6619, 6620, 6621, 9388, 9389, 9390) AND owner_id NOT IN (SELECT charId FROM characters WHERE accesslevel > 0)";
|
||||
|
||||
private static final Map<Integer, StatSet> HEROES = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, StatSet> COMPLETE_HEROS = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Map<Integer, StatSet> HERO_COUNTS = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, List<StatSet>> HERO_FIGHTS = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Map<Integer, List<StatSet>> HERO_DIARY = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, String> HERO_MESSAGE = new ConcurrentHashMap<>();
|
||||
|
||||
@ -127,7 +124,6 @@ public class Hero
|
||||
loadFights(charId);
|
||||
loadDiary(charId);
|
||||
loadMessage(charId);
|
||||
|
||||
processHeros(ps, charId, hero);
|
||||
HEROES.put(charId, hero);
|
||||
}
|
||||
@ -339,9 +335,7 @@ public class Hero
|
||||
fight.set("result", "<font color=\"ffff00\">draw</font>");
|
||||
draws++;
|
||||
}
|
||||
|
||||
fights.add(fight);
|
||||
|
||||
numberOfFights++;
|
||||
}
|
||||
}
|
||||
@ -373,9 +367,7 @@ public class Hero
|
||||
fight.set("result", "<font color=\"ffff00\">draw</font>");
|
||||
draws++;
|
||||
}
|
||||
|
||||
fights.add(fight);
|
||||
|
||||
numberOfFights++;
|
||||
}
|
||||
}
|
||||
@ -630,12 +622,10 @@ public class Hero
|
||||
{
|
||||
player.sendPacket(iu);
|
||||
}
|
||||
|
||||
player.broadcastUserInfo();
|
||||
}
|
||||
|
||||
deleteItemsInDb();
|
||||
|
||||
HEROES.clear();
|
||||
|
||||
if (newHeroes.isEmpty())
|
||||
@ -695,9 +685,9 @@ public class Hero
|
||||
{
|
||||
insert.setInt(1, heroId);
|
||||
insert.setInt(2, hero.getInt(Olympiad.CLASS_ID));
|
||||
insert.setInt(3, hero.getInt(COUNT));
|
||||
insert.setInt(4, hero.getInt(PLAYED));
|
||||
insert.setString(5, String.valueOf(hero.getBoolean(CLAIMED)));
|
||||
insert.setInt(3, hero.getInt(COUNT, 0));
|
||||
insert.setInt(4, hero.getInt(PLAYED, 0));
|
||||
insert.setString(5, String.valueOf(hero.getBoolean(CLAIMED, false)));
|
||||
insert.execute();
|
||||
insert.close();
|
||||
}
|
||||
@ -725,7 +715,6 @@ public class Hero
|
||||
allyCrest = ClanTable.getInstance().getClan(clanId).getAllyCrestId();
|
||||
}
|
||||
}
|
||||
|
||||
hero.set(CLAN_CREST, clanCrest);
|
||||
hero.set(CLAN_NAME, clanName);
|
||||
hero.set(ALLY_CREST, allyCrest);
|
||||
@ -733,17 +722,17 @@ public class Hero
|
||||
}
|
||||
}
|
||||
}
|
||||
HEROES.put(heroId, hero);
|
||||
|
||||
HEROES.put(heroId, hero);
|
||||
COMPLETE_HEROS.put(heroId, hero);
|
||||
}
|
||||
else
|
||||
{
|
||||
try (PreparedStatement statement = con.prepareStatement(UPDATE_HERO))
|
||||
{
|
||||
statement.setInt(1, hero.getInt(COUNT));
|
||||
statement.setInt(2, hero.getInt(PLAYED));
|
||||
statement.setString(3, String.valueOf(hero.getBoolean(CLAIMED)));
|
||||
statement.setInt(1, hero.getInt(COUNT, 0));
|
||||
statement.setInt(2, hero.getInt(PLAYED, 0));
|
||||
statement.setString(3, String.valueOf(hero.getBoolean(CLAIMED, false)));
|
||||
statement.setInt(4, heroId);
|
||||
statement.execute();
|
||||
}
|
||||
@ -772,11 +761,13 @@ public class Hero
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare new data
|
||||
final StatSet diaryEntry = new StatSet();
|
||||
final String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
|
||||
diaryEntry.set("date", date);
|
||||
diaryEntry.set("action", template.getName() + " was defeated");
|
||||
|
||||
// Add to old list
|
||||
list.add(diaryEntry);
|
||||
}
|
||||
@ -791,11 +782,13 @@ public class Hero
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare new data
|
||||
final StatSet diaryEntry = new StatSet();
|
||||
final String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
|
||||
diaryEntry.set("date", date);
|
||||
diaryEntry.set("action", castle.getName() + " Castle was successfuly taken");
|
||||
|
||||
// Add to old list
|
||||
list.add(diaryEntry);
|
||||
}
|
||||
@ -923,6 +916,7 @@ public class Hero
|
||||
player.sendPacket(new UserInfo(player));
|
||||
player.sendPacket(new ExBrExtraUserInfo(player));
|
||||
player.broadcastUserInfo();
|
||||
|
||||
// Set Gained hero and reload data
|
||||
setHeroGained(player.getObjectId());
|
||||
loadFights(player.getObjectId());
|
||||
|
@ -70,15 +70,12 @@ public class Hero
|
||||
private static final String INSERT_HERO = "INSERT INTO heroes (charId, class_id, count, played, claimed) VALUES (?,?,?,?,?)";
|
||||
private static final String UPDATE_HERO = "UPDATE heroes SET count = ?, played = ?, claimed = ? WHERE charId = ?";
|
||||
private static final String GET_CLAN_ALLY = "SELECT characters.clanid AS clanid, coalesce(clan_data.ally_Id, 0) AS allyId FROM characters LEFT JOIN clan_data ON clan_data.clan_id = characters.clanid WHERE characters.charId = ?";
|
||||
// delete hero items
|
||||
private static final String DELETE_ITEMS = "DELETE FROM items WHERE item_id IN (6842, 6611, 6612, 6613, 6614, 6615, 6616, 6617, 6618, 6619, 6620, 6621, 9388, 9389, 9390) AND owner_id NOT IN (SELECT charId FROM characters WHERE accesslevel > 0)";
|
||||
|
||||
private static final Map<Integer, StatSet> HEROES = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, StatSet> COMPLETE_HEROS = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Map<Integer, StatSet> HERO_COUNTS = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, List<StatSet>> HERO_FIGHTS = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Map<Integer, List<StatSet>> HERO_DIARY = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, String> HERO_MESSAGE = new ConcurrentHashMap<>();
|
||||
|
||||
@ -127,7 +124,6 @@ public class Hero
|
||||
loadFights(charId);
|
||||
loadDiary(charId);
|
||||
loadMessage(charId);
|
||||
|
||||
processHeros(ps, charId, hero);
|
||||
HEROES.put(charId, hero);
|
||||
}
|
||||
@ -339,9 +335,7 @@ public class Hero
|
||||
fight.set("result", "<font color=\"ffff00\">draw</font>");
|
||||
draws++;
|
||||
}
|
||||
|
||||
fights.add(fight);
|
||||
|
||||
numberOfFights++;
|
||||
}
|
||||
}
|
||||
@ -373,9 +367,7 @@ public class Hero
|
||||
fight.set("result", "<font color=\"ffff00\">draw</font>");
|
||||
draws++;
|
||||
}
|
||||
|
||||
fights.add(fight);
|
||||
|
||||
numberOfFights++;
|
||||
}
|
||||
}
|
||||
@ -630,12 +622,10 @@ public class Hero
|
||||
{
|
||||
player.sendPacket(iu);
|
||||
}
|
||||
|
||||
player.broadcastUserInfo();
|
||||
}
|
||||
|
||||
deleteItemsInDb();
|
||||
|
||||
HEROES.clear();
|
||||
|
||||
if (newHeroes.isEmpty())
|
||||
@ -695,9 +685,9 @@ public class Hero
|
||||
{
|
||||
insert.setInt(1, heroId);
|
||||
insert.setInt(2, hero.getInt(Olympiad.CLASS_ID));
|
||||
insert.setInt(3, hero.getInt(COUNT));
|
||||
insert.setInt(4, hero.getInt(PLAYED));
|
||||
insert.setString(5, String.valueOf(hero.getBoolean(CLAIMED)));
|
||||
insert.setInt(3, hero.getInt(COUNT, 0));
|
||||
insert.setInt(4, hero.getInt(PLAYED, 0));
|
||||
insert.setString(5, String.valueOf(hero.getBoolean(CLAIMED, false)));
|
||||
insert.execute();
|
||||
insert.close();
|
||||
}
|
||||
@ -725,7 +715,6 @@ public class Hero
|
||||
allyCrest = ClanTable.getInstance().getClan(clanId).getAllyCrestId();
|
||||
}
|
||||
}
|
||||
|
||||
hero.set(CLAN_CREST, clanCrest);
|
||||
hero.set(CLAN_NAME, clanName);
|
||||
hero.set(ALLY_CREST, allyCrest);
|
||||
@ -733,17 +722,17 @@ public class Hero
|
||||
}
|
||||
}
|
||||
}
|
||||
HEROES.put(heroId, hero);
|
||||
|
||||
HEROES.put(heroId, hero);
|
||||
COMPLETE_HEROS.put(heroId, hero);
|
||||
}
|
||||
else
|
||||
{
|
||||
try (PreparedStatement statement = con.prepareStatement(UPDATE_HERO))
|
||||
{
|
||||
statement.setInt(1, hero.getInt(COUNT));
|
||||
statement.setInt(2, hero.getInt(PLAYED));
|
||||
statement.setString(3, String.valueOf(hero.getBoolean(CLAIMED)));
|
||||
statement.setInt(1, hero.getInt(COUNT, 0));
|
||||
statement.setInt(2, hero.getInt(PLAYED, 0));
|
||||
statement.setString(3, String.valueOf(hero.getBoolean(CLAIMED, false)));
|
||||
statement.setInt(4, heroId);
|
||||
statement.execute();
|
||||
}
|
||||
@ -772,11 +761,13 @@ public class Hero
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare new data
|
||||
final StatSet diaryEntry = new StatSet();
|
||||
final String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
|
||||
diaryEntry.set("date", date);
|
||||
diaryEntry.set("action", template.getName() + " was defeated");
|
||||
|
||||
// Add to old list
|
||||
list.add(diaryEntry);
|
||||
}
|
||||
@ -791,11 +782,13 @@ public class Hero
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare new data
|
||||
final StatSet diaryEntry = new StatSet();
|
||||
final String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
|
||||
diaryEntry.set("date", date);
|
||||
diaryEntry.set("action", castle.getName() + " Castle was successfuly taken");
|
||||
|
||||
// Add to old list
|
||||
list.add(diaryEntry);
|
||||
}
|
||||
@ -923,6 +916,7 @@ public class Hero
|
||||
player.sendPacket(new UserInfo(player));
|
||||
player.sendPacket(new ExBrExtraUserInfo(player));
|
||||
player.broadcastUserInfo();
|
||||
|
||||
// Set Gained hero and reload data
|
||||
setHeroGained(player.getObjectId());
|
||||
loadFights(player.getObjectId());
|
||||
|
@ -71,15 +71,12 @@ public class Hero
|
||||
private static final String INSERT_HERO = "INSERT INTO heroes (charId, class_id, count, played, claimed) VALUES (?,?,?,?,?)";
|
||||
private static final String UPDATE_HERO = "UPDATE heroes SET count = ?, played = ?, claimed = ? WHERE charId = ?";
|
||||
private static final String GET_CLAN_ALLY = "SELECT characters.clanid AS clanid, coalesce(clan_data.ally_Id, 0) AS allyId FROM characters LEFT JOIN clan_data ON clan_data.clan_id = characters.clanid WHERE characters.charId = ?";
|
||||
// delete hero items
|
||||
private static final String DELETE_ITEMS = "DELETE FROM items WHERE item_id IN (30392, 30393, 30394, 30395, 30396, 30397, 30398, 30399, 30400, 30401, 30402, 30403, 30404, 30405, 30372, 30373, 6842, 6611, 6612, 6613, 6614, 6615, 6616, 6617, 6618, 6619, 6620, 6621, 9388, 9389, 9390) AND owner_id NOT IN (SELECT charId FROM characters WHERE accesslevel > 0)";
|
||||
|
||||
private static final Map<Integer, StatSet> HEROES = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, StatSet> COMPLETE_HEROS = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Map<Integer, StatSet> HERO_COUNTS = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, List<StatSet>> HERO_FIGHTS = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Map<Integer, List<StatSet>> HERO_DIARY = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, String> HERO_MESSAGE = new ConcurrentHashMap<>();
|
||||
|
||||
@ -128,7 +125,6 @@ public class Hero
|
||||
loadFights(charId);
|
||||
loadDiary(charId);
|
||||
loadMessage(charId);
|
||||
|
||||
processHeros(ps, charId, hero);
|
||||
HEROES.put(charId, hero);
|
||||
}
|
||||
@ -281,7 +277,7 @@ public class Hero
|
||||
data.set(Calendar.MILLISECOND, 0);
|
||||
|
||||
final long from = data.getTimeInMillis();
|
||||
int numberoffights = 0;
|
||||
int numberOfFights = 0;
|
||||
int victories = 0;
|
||||
int losses = 0;
|
||||
int draws = 0;
|
||||
@ -340,10 +336,8 @@ public class Hero
|
||||
fight.set("result", "<font color=\"ffff00\">draw</font>");
|
||||
draws++;
|
||||
}
|
||||
|
||||
fights.add(fight);
|
||||
|
||||
numberoffights++;
|
||||
numberOfFights++;
|
||||
}
|
||||
}
|
||||
else if (charId == charTwoId)
|
||||
@ -374,10 +368,8 @@ public class Hero
|
||||
fight.set("result", "<font color=\"ffff00\">draw</font>");
|
||||
draws++;
|
||||
}
|
||||
|
||||
fights.add(fight);
|
||||
|
||||
numberoffights++;
|
||||
numberOfFights++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -389,7 +381,7 @@ public class Hero
|
||||
HERO_COUNTS.put(charId, heroCountData);
|
||||
HERO_FIGHTS.put(charId, fights);
|
||||
|
||||
LOGGER.info("Hero System: Loaded " + numberoffights + " fights for Hero: " + CharNameTable.getInstance().getNameById(charId));
|
||||
LOGGER.info("Hero System: Loaded " + numberOfFights + " fights for Hero: " + CharNameTable.getInstance().getNameById(charId));
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
@ -631,12 +623,10 @@ public class Hero
|
||||
{
|
||||
player.sendInventoryUpdate(iu);
|
||||
}
|
||||
|
||||
player.broadcastUserInfo();
|
||||
}
|
||||
|
||||
deleteItemsInDb();
|
||||
|
||||
HEROES.clear();
|
||||
|
||||
if (newHeroes.isEmpty())
|
||||
@ -696,9 +686,9 @@ public class Hero
|
||||
{
|
||||
insert.setInt(1, heroId);
|
||||
insert.setInt(2, hero.getInt(Olympiad.CLASS_ID));
|
||||
insert.setInt(3, hero.getInt(COUNT));
|
||||
insert.setInt(4, hero.getInt(PLAYED));
|
||||
insert.setString(5, String.valueOf(hero.getBoolean(CLAIMED)));
|
||||
insert.setInt(3, hero.getInt(COUNT, 0));
|
||||
insert.setInt(4, hero.getInt(PLAYED, 0));
|
||||
insert.setString(5, String.valueOf(hero.getBoolean(CLAIMED, false)));
|
||||
insert.execute();
|
||||
insert.close();
|
||||
}
|
||||
@ -726,7 +716,6 @@ public class Hero
|
||||
allyCrest = ClanTable.getInstance().getClan(clanId).getAllyCrestId();
|
||||
}
|
||||
}
|
||||
|
||||
hero.set(CLAN_CREST, clanCrest);
|
||||
hero.set(CLAN_NAME, clanName);
|
||||
hero.set(ALLY_CREST, allyCrest);
|
||||
@ -734,17 +723,17 @@ public class Hero
|
||||
}
|
||||
}
|
||||
}
|
||||
HEROES.put(heroId, hero);
|
||||
|
||||
HEROES.put(heroId, hero);
|
||||
COMPLETE_HEROS.put(heroId, hero);
|
||||
}
|
||||
else
|
||||
{
|
||||
try (PreparedStatement statement = con.prepareStatement(UPDATE_HERO))
|
||||
{
|
||||
statement.setInt(1, hero.getInt(COUNT));
|
||||
statement.setInt(2, hero.getInt(PLAYED));
|
||||
statement.setString(3, String.valueOf(hero.getBoolean(CLAIMED)));
|
||||
statement.setInt(1, hero.getInt(COUNT, 0));
|
||||
statement.setInt(2, hero.getInt(PLAYED, 0));
|
||||
statement.setString(3, String.valueOf(hero.getBoolean(CLAIMED, false)));
|
||||
statement.setInt(4, heroId);
|
||||
statement.execute();
|
||||
}
|
||||
@ -773,11 +762,13 @@ public class Hero
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare new data
|
||||
final StatSet diaryEntry = new StatSet();
|
||||
final String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
|
||||
diaryEntry.set("date", date);
|
||||
diaryEntry.set("action", template.getName() + " was defeated");
|
||||
|
||||
// Add to old list
|
||||
list.add(diaryEntry);
|
||||
}
|
||||
@ -792,11 +783,13 @@ public class Hero
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare new data
|
||||
final StatSet diaryEntry = new StatSet();
|
||||
final String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
|
||||
diaryEntry.set("date", date);
|
||||
diaryEntry.set("action", castle.getName() + " Castle was successfuly taken");
|
||||
|
||||
// Add to old list
|
||||
list.add(diaryEntry);
|
||||
}
|
||||
@ -871,10 +864,7 @@ public class Hero
|
||||
*/
|
||||
public void shutdown()
|
||||
{
|
||||
for (int charId : HERO_MESSAGE.keySet())
|
||||
{
|
||||
saveHeroMessage(charId);
|
||||
}
|
||||
HERO_MESSAGE.keySet().forEach(this::saveHeroMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -926,11 +916,13 @@ public class Hero
|
||||
player.broadcastPacket(new SocialAction(player.getObjectId(), 20016)); // Hero Animation
|
||||
player.sendPacket(new UserInfo(player));
|
||||
player.broadcastUserInfo();
|
||||
|
||||
// Set Gained hero and reload data
|
||||
setHeroGained(player.getObjectId());
|
||||
loadFights(player.getObjectId());
|
||||
loadDiary(player.getObjectId());
|
||||
HERO_MESSAGE.put(player.getObjectId(), "");
|
||||
|
||||
EventDispatcher.getInstance().notifyEvent(new OnPlayerTakeHero(player));
|
||||
updateHeroes(false);
|
||||
}
|
||||
|
@ -71,15 +71,12 @@ public class Hero
|
||||
private static final String INSERT_HERO = "INSERT INTO heroes (charId, class_id, count, played, claimed) VALUES (?,?,?,?,?)";
|
||||
private static final String UPDATE_HERO = "UPDATE heroes SET count = ?, played = ?, claimed = ? WHERE charId = ?";
|
||||
private static final String GET_CLAN_ALLY = "SELECT characters.clanid AS clanid, coalesce(clan_data.ally_Id, 0) AS allyId FROM characters LEFT JOIN clan_data ON clan_data.clan_id = characters.clanid WHERE characters.charId = ?";
|
||||
// delete hero items
|
||||
private static final String DELETE_ITEMS = "DELETE FROM items WHERE item_id IN (30392, 30393, 30394, 30395, 30396, 30397, 30398, 30399, 30400, 30401, 30402, 30403, 30404, 30405, 30372, 30373, 6842, 6611, 6612, 6613, 6614, 6615, 6616, 6617, 6618, 6619, 6620, 6621, 9388, 9389, 9390) AND owner_id NOT IN (SELECT charId FROM characters WHERE accesslevel > 0)";
|
||||
|
||||
private static final Map<Integer, StatSet> HEROES = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, StatSet> COMPLETE_HEROS = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Map<Integer, StatSet> HERO_COUNTS = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, List<StatSet>> HERO_FIGHTS = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Map<Integer, List<StatSet>> HERO_DIARY = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, String> HERO_MESSAGE = new ConcurrentHashMap<>();
|
||||
|
||||
@ -128,7 +125,6 @@ public class Hero
|
||||
loadFights(charId);
|
||||
loadDiary(charId);
|
||||
loadMessage(charId);
|
||||
|
||||
processHeros(ps, charId, hero);
|
||||
HEROES.put(charId, hero);
|
||||
}
|
||||
@ -281,7 +277,7 @@ public class Hero
|
||||
data.set(Calendar.MILLISECOND, 0);
|
||||
|
||||
final long from = data.getTimeInMillis();
|
||||
int numberoffights = 0;
|
||||
int numberOfFights = 0;
|
||||
int victories = 0;
|
||||
int losses = 0;
|
||||
int draws = 0;
|
||||
@ -340,10 +336,8 @@ public class Hero
|
||||
fight.set("result", "<font color=\"ffff00\">draw</font>");
|
||||
draws++;
|
||||
}
|
||||
|
||||
fights.add(fight);
|
||||
|
||||
numberoffights++;
|
||||
numberOfFights++;
|
||||
}
|
||||
}
|
||||
else if (charId == charTwoId)
|
||||
@ -374,10 +368,8 @@ public class Hero
|
||||
fight.set("result", "<font color=\"ffff00\">draw</font>");
|
||||
draws++;
|
||||
}
|
||||
|
||||
fights.add(fight);
|
||||
|
||||
numberoffights++;
|
||||
numberOfFights++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -389,7 +381,7 @@ public class Hero
|
||||
HERO_COUNTS.put(charId, heroCountData);
|
||||
HERO_FIGHTS.put(charId, fights);
|
||||
|
||||
LOGGER.info("Hero System: Loaded " + numberoffights + " fights for Hero: " + CharNameTable.getInstance().getNameById(charId));
|
||||
LOGGER.info("Hero System: Loaded " + numberOfFights + " fights for Hero: " + CharNameTable.getInstance().getNameById(charId));
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
@ -631,12 +623,10 @@ public class Hero
|
||||
{
|
||||
player.sendInventoryUpdate(iu);
|
||||
}
|
||||
|
||||
player.broadcastUserInfo();
|
||||
}
|
||||
|
||||
deleteItemsInDb();
|
||||
|
||||
HEROES.clear();
|
||||
|
||||
if (newHeroes.isEmpty())
|
||||
@ -696,9 +686,9 @@ public class Hero
|
||||
{
|
||||
insert.setInt(1, heroId);
|
||||
insert.setInt(2, hero.getInt(Olympiad.CLASS_ID));
|
||||
insert.setInt(3, hero.getInt(COUNT));
|
||||
insert.setInt(4, hero.getInt(PLAYED));
|
||||
insert.setString(5, String.valueOf(hero.getBoolean(CLAIMED)));
|
||||
insert.setInt(3, hero.getInt(COUNT, 0));
|
||||
insert.setInt(4, hero.getInt(PLAYED, 0));
|
||||
insert.setString(5, String.valueOf(hero.getBoolean(CLAIMED, false)));
|
||||
insert.execute();
|
||||
insert.close();
|
||||
}
|
||||
@ -726,7 +716,6 @@ public class Hero
|
||||
allyCrest = ClanTable.getInstance().getClan(clanId).getAllyCrestId();
|
||||
}
|
||||
}
|
||||
|
||||
hero.set(CLAN_CREST, clanCrest);
|
||||
hero.set(CLAN_NAME, clanName);
|
||||
hero.set(ALLY_CREST, allyCrest);
|
||||
@ -734,17 +723,17 @@ public class Hero
|
||||
}
|
||||
}
|
||||
}
|
||||
HEROES.put(heroId, hero);
|
||||
|
||||
HEROES.put(heroId, hero);
|
||||
COMPLETE_HEROS.put(heroId, hero);
|
||||
}
|
||||
else
|
||||
{
|
||||
try (PreparedStatement statement = con.prepareStatement(UPDATE_HERO))
|
||||
{
|
||||
statement.setInt(1, hero.getInt(COUNT));
|
||||
statement.setInt(2, hero.getInt(PLAYED));
|
||||
statement.setString(3, String.valueOf(hero.getBoolean(CLAIMED)));
|
||||
statement.setInt(1, hero.getInt(COUNT, 0));
|
||||
statement.setInt(2, hero.getInt(PLAYED, 0));
|
||||
statement.setString(3, String.valueOf(hero.getBoolean(CLAIMED, false)));
|
||||
statement.setInt(4, heroId);
|
||||
statement.execute();
|
||||
}
|
||||
@ -773,11 +762,13 @@ public class Hero
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare new data
|
||||
final StatSet diaryEntry = new StatSet();
|
||||
final String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
|
||||
diaryEntry.set("date", date);
|
||||
diaryEntry.set("action", template.getName() + " was defeated");
|
||||
|
||||
// Add to old list
|
||||
list.add(diaryEntry);
|
||||
}
|
||||
@ -792,11 +783,13 @@ public class Hero
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare new data
|
||||
final StatSet diaryEntry = new StatSet();
|
||||
final String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
|
||||
diaryEntry.set("date", date);
|
||||
diaryEntry.set("action", castle.getName() + " Castle was successfuly taken");
|
||||
|
||||
// Add to old list
|
||||
list.add(diaryEntry);
|
||||
}
|
||||
@ -871,10 +864,7 @@ public class Hero
|
||||
*/
|
||||
public void shutdown()
|
||||
{
|
||||
for (int charId : HERO_MESSAGE.keySet())
|
||||
{
|
||||
saveHeroMessage(charId);
|
||||
}
|
||||
HERO_MESSAGE.keySet().forEach(this::saveHeroMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -926,11 +916,13 @@ public class Hero
|
||||
player.broadcastPacket(new SocialAction(player.getObjectId(), 20016)); // Hero Animation
|
||||
player.sendPacket(new UserInfo(player));
|
||||
player.broadcastUserInfo();
|
||||
|
||||
// Set Gained hero and reload data
|
||||
setHeroGained(player.getObjectId());
|
||||
loadFights(player.getObjectId());
|
||||
loadDiary(player.getObjectId());
|
||||
HERO_MESSAGE.put(player.getObjectId(), "");
|
||||
|
||||
EventDispatcher.getInstance().notifyEvent(new OnPlayerTakeHero(player));
|
||||
updateHeroes(false);
|
||||
}
|
||||
|
@ -71,15 +71,12 @@ public class Hero
|
||||
private static final String INSERT_HERO = "INSERT INTO heroes (charId, class_id, count, played, claimed) VALUES (?,?,?,?,?)";
|
||||
private static final String UPDATE_HERO = "UPDATE heroes SET count = ?, played = ?, claimed = ? WHERE charId = ?";
|
||||
private static final String GET_CLAN_ALLY = "SELECT characters.clanid AS clanid, coalesce(clan_data.ally_Id, 0) AS allyId FROM characters LEFT JOIN clan_data ON clan_data.clan_id = characters.clanid WHERE characters.charId = ?";
|
||||
// delete hero items
|
||||
private static final String DELETE_ITEMS = "DELETE FROM items WHERE item_id IN (30392, 30393, 30394, 30395, 30396, 30397, 30398, 30399, 30400, 30401, 30402, 30403, 30404, 30405, 30372, 30373, 6842, 6611, 6612, 6613, 6614, 6615, 6616, 6617, 6618, 6619, 6620, 6621, 9388, 9389, 9390) AND owner_id NOT IN (SELECT charId FROM characters WHERE accesslevel > 0)";
|
||||
|
||||
private static final Map<Integer, StatSet> HEROES = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, StatSet> COMPLETE_HEROS = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Map<Integer, StatSet> HERO_COUNTS = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, List<StatSet>> HERO_FIGHTS = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Map<Integer, List<StatSet>> HERO_DIARY = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, String> HERO_MESSAGE = new ConcurrentHashMap<>();
|
||||
|
||||
@ -128,7 +125,6 @@ public class Hero
|
||||
loadFights(charId);
|
||||
loadDiary(charId);
|
||||
loadMessage(charId);
|
||||
|
||||
processHeros(ps, charId, hero);
|
||||
HEROES.put(charId, hero);
|
||||
}
|
||||
@ -281,7 +277,7 @@ public class Hero
|
||||
data.set(Calendar.MILLISECOND, 0);
|
||||
|
||||
final long from = data.getTimeInMillis();
|
||||
int numberoffights = 0;
|
||||
int numberOfFights = 0;
|
||||
int victories = 0;
|
||||
int losses = 0;
|
||||
int draws = 0;
|
||||
@ -340,10 +336,8 @@ public class Hero
|
||||
fight.set("result", "<font color=\"ffff00\">draw</font>");
|
||||
draws++;
|
||||
}
|
||||
|
||||
fights.add(fight);
|
||||
|
||||
numberoffights++;
|
||||
numberOfFights++;
|
||||
}
|
||||
}
|
||||
else if (charId == charTwoId)
|
||||
@ -374,10 +368,8 @@ public class Hero
|
||||
fight.set("result", "<font color=\"ffff00\">draw</font>");
|
||||
draws++;
|
||||
}
|
||||
|
||||
fights.add(fight);
|
||||
|
||||
numberoffights++;
|
||||
numberOfFights++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -389,7 +381,7 @@ public class Hero
|
||||
HERO_COUNTS.put(charId, heroCountData);
|
||||
HERO_FIGHTS.put(charId, fights);
|
||||
|
||||
LOGGER.info("Hero System: Loaded " + numberoffights + " fights for Hero: " + CharNameTable.getInstance().getNameById(charId));
|
||||
LOGGER.info("Hero System: Loaded " + numberOfFights + " fights for Hero: " + CharNameTable.getInstance().getNameById(charId));
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
@ -631,12 +623,10 @@ public class Hero
|
||||
{
|
||||
player.sendInventoryUpdate(iu);
|
||||
}
|
||||
|
||||
player.broadcastUserInfo();
|
||||
}
|
||||
|
||||
deleteItemsInDb();
|
||||
|
||||
HEROES.clear();
|
||||
|
||||
if (newHeroes.isEmpty())
|
||||
@ -696,9 +686,9 @@ public class Hero
|
||||
{
|
||||
insert.setInt(1, heroId);
|
||||
insert.setInt(2, hero.getInt(Olympiad.CLASS_ID));
|
||||
insert.setInt(3, hero.getInt(COUNT));
|
||||
insert.setInt(4, hero.getInt(PLAYED));
|
||||
insert.setString(5, String.valueOf(hero.getBoolean(CLAIMED)));
|
||||
insert.setInt(3, hero.getInt(COUNT, 0));
|
||||
insert.setInt(4, hero.getInt(PLAYED, 0));
|
||||
insert.setString(5, String.valueOf(hero.getBoolean(CLAIMED, false)));
|
||||
insert.execute();
|
||||
insert.close();
|
||||
}
|
||||
@ -726,7 +716,6 @@ public class Hero
|
||||
allyCrest = ClanTable.getInstance().getClan(clanId).getAllyCrestId();
|
||||
}
|
||||
}
|
||||
|
||||
hero.set(CLAN_CREST, clanCrest);
|
||||
hero.set(CLAN_NAME, clanName);
|
||||
hero.set(ALLY_CREST, allyCrest);
|
||||
@ -734,17 +723,17 @@ public class Hero
|
||||
}
|
||||
}
|
||||
}
|
||||
HEROES.put(heroId, hero);
|
||||
|
||||
HEROES.put(heroId, hero);
|
||||
COMPLETE_HEROS.put(heroId, hero);
|
||||
}
|
||||
else
|
||||
{
|
||||
try (PreparedStatement statement = con.prepareStatement(UPDATE_HERO))
|
||||
{
|
||||
statement.setInt(1, hero.getInt(COUNT));
|
||||
statement.setInt(2, hero.getInt(PLAYED));
|
||||
statement.setString(3, String.valueOf(hero.getBoolean(CLAIMED)));
|
||||
statement.setInt(1, hero.getInt(COUNT, 0));
|
||||
statement.setInt(2, hero.getInt(PLAYED, 0));
|
||||
statement.setString(3, String.valueOf(hero.getBoolean(CLAIMED, false)));
|
||||
statement.setInt(4, heroId);
|
||||
statement.execute();
|
||||
}
|
||||
@ -773,11 +762,13 @@ public class Hero
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare new data
|
||||
final StatSet diaryEntry = new StatSet();
|
||||
final String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
|
||||
diaryEntry.set("date", date);
|
||||
diaryEntry.set("action", template.getName() + " was defeated");
|
||||
|
||||
// Add to old list
|
||||
list.add(diaryEntry);
|
||||
}
|
||||
@ -792,11 +783,13 @@ public class Hero
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare new data
|
||||
final StatSet diaryEntry = new StatSet();
|
||||
final String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
|
||||
diaryEntry.set("date", date);
|
||||
diaryEntry.set("action", castle.getName() + " Castle was successfuly taken");
|
||||
|
||||
// Add to old list
|
||||
list.add(diaryEntry);
|
||||
}
|
||||
@ -871,10 +864,7 @@ public class Hero
|
||||
*/
|
||||
public void shutdown()
|
||||
{
|
||||
for (int charId : HERO_MESSAGE.keySet())
|
||||
{
|
||||
saveHeroMessage(charId);
|
||||
}
|
||||
HERO_MESSAGE.keySet().forEach(this::saveHeroMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -926,11 +916,13 @@ public class Hero
|
||||
player.broadcastPacket(new SocialAction(player.getObjectId(), 20016)); // Hero Animation
|
||||
player.sendPacket(new UserInfo(player));
|
||||
player.broadcastUserInfo();
|
||||
|
||||
// Set Gained hero and reload data
|
||||
setHeroGained(player.getObjectId());
|
||||
loadFights(player.getObjectId());
|
||||
loadDiary(player.getObjectId());
|
||||
HERO_MESSAGE.put(player.getObjectId(), "");
|
||||
|
||||
EventDispatcher.getInstance().notifyEvent(new OnPlayerTakeHero(player));
|
||||
updateHeroes(false);
|
||||
}
|
||||
|
@ -71,15 +71,12 @@ public class Hero
|
||||
private static final String INSERT_HERO = "INSERT INTO heroes (charId, class_id, count, played, claimed) VALUES (?,?,?,?,?)";
|
||||
private static final String UPDATE_HERO = "UPDATE heroes SET count = ?, played = ?, claimed = ? WHERE charId = ?";
|
||||
private static final String GET_CLAN_ALLY = "SELECT characters.clanid AS clanid, coalesce(clan_data.ally_Id, 0) AS allyId FROM characters LEFT JOIN clan_data ON clan_data.clan_id = characters.clanid WHERE characters.charId = ?";
|
||||
// delete hero items
|
||||
private static final String DELETE_ITEMS = "DELETE FROM items WHERE item_id IN (30392, 30393, 30394, 30395, 30396, 30397, 30398, 30399, 30400, 30401, 30402, 30403, 30404, 30405, 30372, 30373, 6842, 6611, 6612, 6613, 6614, 6615, 6616, 6617, 6618, 6619, 6620, 6621, 9388, 9389, 9390) AND owner_id NOT IN (SELECT charId FROM characters WHERE accesslevel > 0)";
|
||||
|
||||
private static final Map<Integer, StatSet> HEROES = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, StatSet> COMPLETE_HEROS = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Map<Integer, StatSet> HERO_COUNTS = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, List<StatSet>> HERO_FIGHTS = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Map<Integer, List<StatSet>> HERO_DIARY = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, String> HERO_MESSAGE = new ConcurrentHashMap<>();
|
||||
|
||||
@ -128,7 +125,6 @@ public class Hero
|
||||
loadFights(charId);
|
||||
loadDiary(charId);
|
||||
loadMessage(charId);
|
||||
|
||||
processHeros(ps, charId, hero);
|
||||
HEROES.put(charId, hero);
|
||||
}
|
||||
@ -281,7 +277,7 @@ public class Hero
|
||||
data.set(Calendar.MILLISECOND, 0);
|
||||
|
||||
final long from = data.getTimeInMillis();
|
||||
int numberoffights = 0;
|
||||
int numberOfFights = 0;
|
||||
int victories = 0;
|
||||
int losses = 0;
|
||||
int draws = 0;
|
||||
@ -340,10 +336,8 @@ public class Hero
|
||||
fight.set("result", "<font color=\"ffff00\">draw</font>");
|
||||
draws++;
|
||||
}
|
||||
|
||||
fights.add(fight);
|
||||
|
||||
numberoffights++;
|
||||
numberOfFights++;
|
||||
}
|
||||
}
|
||||
else if (charId == charTwoId)
|
||||
@ -374,10 +368,8 @@ public class Hero
|
||||
fight.set("result", "<font color=\"ffff00\">draw</font>");
|
||||
draws++;
|
||||
}
|
||||
|
||||
fights.add(fight);
|
||||
|
||||
numberoffights++;
|
||||
numberOfFights++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -389,7 +381,7 @@ public class Hero
|
||||
HERO_COUNTS.put(charId, heroCountData);
|
||||
HERO_FIGHTS.put(charId, fights);
|
||||
|
||||
LOGGER.info("Hero System: Loaded " + numberoffights + " fights for Hero: " + CharNameTable.getInstance().getNameById(charId));
|
||||
LOGGER.info("Hero System: Loaded " + numberOfFights + " fights for Hero: " + CharNameTable.getInstance().getNameById(charId));
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
@ -631,12 +623,10 @@ public class Hero
|
||||
{
|
||||
player.sendInventoryUpdate(iu);
|
||||
}
|
||||
|
||||
player.broadcastUserInfo();
|
||||
}
|
||||
|
||||
deleteItemsInDb();
|
||||
|
||||
HEROES.clear();
|
||||
|
||||
if (newHeroes.isEmpty())
|
||||
@ -696,9 +686,9 @@ public class Hero
|
||||
{
|
||||
insert.setInt(1, heroId);
|
||||
insert.setInt(2, hero.getInt(Olympiad.CLASS_ID));
|
||||
insert.setInt(3, hero.getInt(COUNT));
|
||||
insert.setInt(4, hero.getInt(PLAYED));
|
||||
insert.setString(5, String.valueOf(hero.getBoolean(CLAIMED)));
|
||||
insert.setInt(3, hero.getInt(COUNT, 0));
|
||||
insert.setInt(4, hero.getInt(PLAYED, 0));
|
||||
insert.setString(5, String.valueOf(hero.getBoolean(CLAIMED, false)));
|
||||
insert.execute();
|
||||
insert.close();
|
||||
}
|
||||
@ -726,7 +716,6 @@ public class Hero
|
||||
allyCrest = ClanTable.getInstance().getClan(clanId).getAllyCrestId();
|
||||
}
|
||||
}
|
||||
|
||||
hero.set(CLAN_CREST, clanCrest);
|
||||
hero.set(CLAN_NAME, clanName);
|
||||
hero.set(ALLY_CREST, allyCrest);
|
||||
@ -734,17 +723,17 @@ public class Hero
|
||||
}
|
||||
}
|
||||
}
|
||||
HEROES.put(heroId, hero);
|
||||
|
||||
HEROES.put(heroId, hero);
|
||||
COMPLETE_HEROS.put(heroId, hero);
|
||||
}
|
||||
else
|
||||
{
|
||||
try (PreparedStatement statement = con.prepareStatement(UPDATE_HERO))
|
||||
{
|
||||
statement.setInt(1, hero.getInt(COUNT));
|
||||
statement.setInt(2, hero.getInt(PLAYED));
|
||||
statement.setString(3, String.valueOf(hero.getBoolean(CLAIMED)));
|
||||
statement.setInt(1, hero.getInt(COUNT, 0));
|
||||
statement.setInt(2, hero.getInt(PLAYED, 0));
|
||||
statement.setString(3, String.valueOf(hero.getBoolean(CLAIMED, false)));
|
||||
statement.setInt(4, heroId);
|
||||
statement.execute();
|
||||
}
|
||||
@ -773,11 +762,13 @@ public class Hero
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare new data
|
||||
final StatSet diaryEntry = new StatSet();
|
||||
final String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
|
||||
diaryEntry.set("date", date);
|
||||
diaryEntry.set("action", template.getName() + " was defeated");
|
||||
|
||||
// Add to old list
|
||||
list.add(diaryEntry);
|
||||
}
|
||||
@ -792,11 +783,13 @@ public class Hero
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare new data
|
||||
final StatSet diaryEntry = new StatSet();
|
||||
final String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
|
||||
diaryEntry.set("date", date);
|
||||
diaryEntry.set("action", castle.getName() + " Castle was successfuly taken");
|
||||
|
||||
// Add to old list
|
||||
list.add(diaryEntry);
|
||||
}
|
||||
@ -871,10 +864,7 @@ public class Hero
|
||||
*/
|
||||
public void shutdown()
|
||||
{
|
||||
for (int charId : HERO_MESSAGE.keySet())
|
||||
{
|
||||
saveHeroMessage(charId);
|
||||
}
|
||||
HERO_MESSAGE.keySet().forEach(this::saveHeroMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -926,11 +916,13 @@ public class Hero
|
||||
player.broadcastPacket(new SocialAction(player.getObjectId(), 20016)); // Hero Animation
|
||||
player.sendPacket(new UserInfo(player));
|
||||
player.broadcastUserInfo();
|
||||
|
||||
// Set Gained hero and reload data
|
||||
setHeroGained(player.getObjectId());
|
||||
loadFights(player.getObjectId());
|
||||
loadDiary(player.getObjectId());
|
||||
HERO_MESSAGE.put(player.getObjectId(), "");
|
||||
|
||||
EventDispatcher.getInstance().notifyEvent(new OnPlayerTakeHero(player));
|
||||
updateHeroes(false);
|
||||
}
|
||||
|
@ -71,15 +71,12 @@ public class Hero
|
||||
private static final String INSERT_HERO = "INSERT INTO heroes (charId, class_id, count, played, claimed) VALUES (?,?,?,?,?)";
|
||||
private static final String UPDATE_HERO = "UPDATE heroes SET count = ?, played = ?, claimed = ? WHERE charId = ?";
|
||||
private static final String GET_CLAN_ALLY = "SELECT characters.clanid AS clanid, coalesce(clan_data.ally_Id, 0) AS allyId FROM characters LEFT JOIN clan_data ON clan_data.clan_id = characters.clanid WHERE characters.charId = ?";
|
||||
// delete hero items
|
||||
private static final String DELETE_ITEMS = "DELETE FROM items WHERE item_id IN (30392, 30393, 30394, 30395, 30396, 30397, 30398, 30399, 30400, 30401, 30402, 30403, 30404, 30405, 30372, 30373, 6842, 6611, 6612, 6613, 6614, 6615, 6616, 6617, 6618, 6619, 6620, 6621, 9388, 9389, 9390) AND owner_id NOT IN (SELECT charId FROM characters WHERE accesslevel > 0)";
|
||||
|
||||
private static final Map<Integer, StatSet> HEROES = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, StatSet> COMPLETE_HEROS = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Map<Integer, StatSet> HERO_COUNTS = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, List<StatSet>> HERO_FIGHTS = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Map<Integer, List<StatSet>> HERO_DIARY = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, String> HERO_MESSAGE = new ConcurrentHashMap<>();
|
||||
|
||||
@ -128,7 +125,6 @@ public class Hero
|
||||
loadFights(charId);
|
||||
loadDiary(charId);
|
||||
loadMessage(charId);
|
||||
|
||||
processHeros(ps, charId, hero);
|
||||
HEROES.put(charId, hero);
|
||||
}
|
||||
@ -281,7 +277,7 @@ public class Hero
|
||||
data.set(Calendar.MILLISECOND, 0);
|
||||
|
||||
final long from = data.getTimeInMillis();
|
||||
int numberoffights = 0;
|
||||
int numberOfFights = 0;
|
||||
int victories = 0;
|
||||
int losses = 0;
|
||||
int draws = 0;
|
||||
@ -340,10 +336,8 @@ public class Hero
|
||||
fight.set("result", "<font color=\"ffff00\">draw</font>");
|
||||
draws++;
|
||||
}
|
||||
|
||||
fights.add(fight);
|
||||
|
||||
numberoffights++;
|
||||
numberOfFights++;
|
||||
}
|
||||
}
|
||||
else if (charId == charTwoId)
|
||||
@ -374,10 +368,8 @@ public class Hero
|
||||
fight.set("result", "<font color=\"ffff00\">draw</font>");
|
||||
draws++;
|
||||
}
|
||||
|
||||
fights.add(fight);
|
||||
|
||||
numberoffights++;
|
||||
numberOfFights++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -389,7 +381,7 @@ public class Hero
|
||||
HERO_COUNTS.put(charId, heroCountData);
|
||||
HERO_FIGHTS.put(charId, fights);
|
||||
|
||||
LOGGER.info("Hero System: Loaded " + numberoffights + " fights for Hero: " + CharNameTable.getInstance().getNameById(charId));
|
||||
LOGGER.info("Hero System: Loaded " + numberOfFights + " fights for Hero: " + CharNameTable.getInstance().getNameById(charId));
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
@ -631,12 +623,10 @@ public class Hero
|
||||
{
|
||||
player.sendInventoryUpdate(iu);
|
||||
}
|
||||
|
||||
player.broadcastUserInfo();
|
||||
}
|
||||
|
||||
deleteItemsInDb();
|
||||
|
||||
HEROES.clear();
|
||||
|
||||
if (newHeroes.isEmpty())
|
||||
@ -696,9 +686,9 @@ public class Hero
|
||||
{
|
||||
insert.setInt(1, heroId);
|
||||
insert.setInt(2, hero.getInt(Olympiad.CLASS_ID));
|
||||
insert.setInt(3, hero.getInt(COUNT));
|
||||
insert.setInt(4, hero.getInt(PLAYED));
|
||||
insert.setString(5, String.valueOf(hero.getBoolean(CLAIMED)));
|
||||
insert.setInt(3, hero.getInt(COUNT, 0));
|
||||
insert.setInt(4, hero.getInt(PLAYED, 0));
|
||||
insert.setString(5, String.valueOf(hero.getBoolean(CLAIMED, false)));
|
||||
insert.execute();
|
||||
insert.close();
|
||||
}
|
||||
@ -726,7 +716,6 @@ public class Hero
|
||||
allyCrest = ClanTable.getInstance().getClan(clanId).getAllyCrestId();
|
||||
}
|
||||
}
|
||||
|
||||
hero.set(CLAN_CREST, clanCrest);
|
||||
hero.set(CLAN_NAME, clanName);
|
||||
hero.set(ALLY_CREST, allyCrest);
|
||||
@ -734,17 +723,17 @@ public class Hero
|
||||
}
|
||||
}
|
||||
}
|
||||
HEROES.put(heroId, hero);
|
||||
|
||||
HEROES.put(heroId, hero);
|
||||
COMPLETE_HEROS.put(heroId, hero);
|
||||
}
|
||||
else
|
||||
{
|
||||
try (PreparedStatement statement = con.prepareStatement(UPDATE_HERO))
|
||||
{
|
||||
statement.setInt(1, hero.getInt(COUNT));
|
||||
statement.setInt(2, hero.getInt(PLAYED));
|
||||
statement.setString(3, String.valueOf(hero.getBoolean(CLAIMED)));
|
||||
statement.setInt(1, hero.getInt(COUNT, 0));
|
||||
statement.setInt(2, hero.getInt(PLAYED, 0));
|
||||
statement.setString(3, String.valueOf(hero.getBoolean(CLAIMED, false)));
|
||||
statement.setInt(4, heroId);
|
||||
statement.execute();
|
||||
}
|
||||
@ -773,11 +762,13 @@ public class Hero
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare new data
|
||||
final StatSet diaryEntry = new StatSet();
|
||||
final String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
|
||||
diaryEntry.set("date", date);
|
||||
diaryEntry.set("action", template.getName() + " was defeated");
|
||||
|
||||
// Add to old list
|
||||
list.add(diaryEntry);
|
||||
}
|
||||
@ -792,11 +783,13 @@ public class Hero
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare new data
|
||||
final StatSet diaryEntry = new StatSet();
|
||||
final String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
|
||||
diaryEntry.set("date", date);
|
||||
diaryEntry.set("action", castle.getName() + " Castle was successfuly taken");
|
||||
|
||||
// Add to old list
|
||||
list.add(diaryEntry);
|
||||
}
|
||||
@ -871,10 +864,7 @@ public class Hero
|
||||
*/
|
||||
public void shutdown()
|
||||
{
|
||||
for (int charId : HERO_MESSAGE.keySet())
|
||||
{
|
||||
saveHeroMessage(charId);
|
||||
}
|
||||
HERO_MESSAGE.keySet().forEach(this::saveHeroMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -926,11 +916,13 @@ public class Hero
|
||||
player.broadcastPacket(new SocialAction(player.getObjectId(), 20016)); // Hero Animation
|
||||
player.sendPacket(new UserInfo(player));
|
||||
player.broadcastUserInfo();
|
||||
|
||||
// Set Gained hero and reload data
|
||||
setHeroGained(player.getObjectId());
|
||||
loadFights(player.getObjectId());
|
||||
loadDiary(player.getObjectId());
|
||||
HERO_MESSAGE.put(player.getObjectId(), "");
|
||||
|
||||
EventDispatcher.getInstance().notifyEvent(new OnPlayerTakeHero(player));
|
||||
updateHeroes(false);
|
||||
}
|
||||
|
@ -71,15 +71,12 @@ public class Hero
|
||||
private static final String INSERT_HERO = "INSERT INTO heroes (charId, class_id, count, legend_count, played, claimed) VALUES (?,?,?,?,?,?)";
|
||||
private static final String UPDATE_HERO = "UPDATE heroes SET count = ?, legend_count = ?, played = ?, claimed = ? WHERE charId = ?";
|
||||
private static final String GET_CLAN_ALLY = "SELECT characters.clanid AS clanid, coalesce(clan_data.ally_Id, 0) AS allyId FROM characters LEFT JOIN clan_data ON clan_data.clan_id = characters.clanid WHERE characters.charId = ?";
|
||||
// delete hero items
|
||||
private static final String DELETE_ITEMS = "DELETE FROM items WHERE item_id IN (30392, 30393, 30394, 30395, 30396, 30397, 30398, 30399, 30400, 30401, 30402, 30403, 30404, 30405, 30372, 30373, 6842, 6611, 6612, 6613, 6614, 6615, 6616, 6617, 6618, 6619, 6620, 6621, 9388, 9389, 9390) AND owner_id NOT IN (SELECT charId FROM characters WHERE accesslevel > 0)";
|
||||
|
||||
private static final Map<Integer, StatSet> HEROES = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, StatSet> COMPLETE_HEROS = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Map<Integer, StatSet> HERO_COUNTS = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, List<StatSet>> HERO_FIGHTS = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Map<Integer, List<StatSet>> HERO_DIARY = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, String> HERO_MESSAGE = new ConcurrentHashMap<>();
|
||||
|
||||
@ -130,7 +127,6 @@ public class Hero
|
||||
loadFights(charId);
|
||||
loadDiary(charId);
|
||||
loadMessage(charId);
|
||||
|
||||
processHeros(ps, charId, hero);
|
||||
HEROES.put(charId, hero);
|
||||
}
|
||||
@ -284,7 +280,7 @@ public class Hero
|
||||
data.set(Calendar.MILLISECOND, 0);
|
||||
|
||||
final long from = data.getTimeInMillis();
|
||||
int numberoffights = 0;
|
||||
int numberOfFights = 0;
|
||||
int victories = 0;
|
||||
int losses = 0;
|
||||
int draws = 0;
|
||||
@ -343,10 +339,8 @@ public class Hero
|
||||
fight.set("result", "<font color=\"ffff00\">draw</font>");
|
||||
draws++;
|
||||
}
|
||||
|
||||
fights.add(fight);
|
||||
|
||||
numberoffights++;
|
||||
numberOfFights++;
|
||||
}
|
||||
}
|
||||
else if (charId == charTwoId)
|
||||
@ -377,10 +371,8 @@ public class Hero
|
||||
fight.set("result", "<font color=\"ffff00\">draw</font>");
|
||||
draws++;
|
||||
}
|
||||
|
||||
fights.add(fight);
|
||||
|
||||
numberoffights++;
|
||||
numberOfFights++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -392,7 +384,7 @@ public class Hero
|
||||
HERO_COUNTS.put(charId, heroCountData);
|
||||
HERO_FIGHTS.put(charId, fights);
|
||||
|
||||
LOGGER.info("Hero System: Loaded " + numberoffights + " fights for Hero: " + CharNameTable.getInstance().getNameById(charId));
|
||||
LOGGER.info("Hero System: Loaded " + numberOfFights + " fights for Hero: " + CharNameTable.getInstance().getNameById(charId));
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
@ -639,12 +631,10 @@ public class Hero
|
||||
{
|
||||
player.sendInventoryUpdate(iu);
|
||||
}
|
||||
|
||||
player.broadcastUserInfo();
|
||||
}
|
||||
|
||||
deleteItemsInDb();
|
||||
|
||||
HEROES.clear();
|
||||
|
||||
if (newHeroes.isEmpty())
|
||||
@ -719,10 +709,10 @@ public class Hero
|
||||
{
|
||||
insert.setInt(1, heroId);
|
||||
insert.setInt(2, hero.getInt(Olympiad.CLASS_ID));
|
||||
insert.setInt(3, hero.getInt(COUNT));
|
||||
insert.setInt(4, hero.getInt(LEGEND_COUNT));
|
||||
insert.setInt(5, hero.getInt(PLAYED));
|
||||
insert.setString(6, String.valueOf(hero.getBoolean(CLAIMED)));
|
||||
insert.setInt(3, hero.getInt(COUNT, 0));
|
||||
insert.setInt(4, hero.getInt(LEGEND_COUNT, 0));
|
||||
insert.setInt(5, hero.getInt(PLAYED, 0));
|
||||
insert.setString(6, String.valueOf(hero.getBoolean(CLAIMED, false)));
|
||||
insert.execute();
|
||||
insert.close();
|
||||
}
|
||||
@ -750,7 +740,6 @@ public class Hero
|
||||
allyCrest = ClanTable.getInstance().getClan(clanId).getAllyCrestId();
|
||||
}
|
||||
}
|
||||
|
||||
hero.set(CLAN_CREST, clanCrest);
|
||||
hero.set(CLAN_NAME, clanName);
|
||||
hero.set(ALLY_CREST, allyCrest);
|
||||
@ -758,19 +747,19 @@ public class Hero
|
||||
}
|
||||
}
|
||||
}
|
||||
HEROES.put(heroId, hero);
|
||||
|
||||
HEROES.put(heroId, hero);
|
||||
COMPLETE_HEROS.put(heroId, hero);
|
||||
}
|
||||
else
|
||||
{
|
||||
try (PreparedStatement statement = con.prepareStatement(UPDATE_HERO))
|
||||
{
|
||||
statement.setInt(1, hero.getInt(COUNT));
|
||||
statement.setInt(2, hero.getInt(LEGEND_COUNT));
|
||||
statement.setInt(2, hero.getInt(PLAYED));
|
||||
statement.setString(3, String.valueOf(hero.getBoolean(CLAIMED)));
|
||||
statement.setInt(4, heroId);
|
||||
statement.setInt(1, hero.getInt(COUNT, 0));
|
||||
statement.setInt(2, hero.getInt(LEGEND_COUNT, 0));
|
||||
statement.setInt(3, hero.getInt(PLAYED, 0));
|
||||
statement.setString(4, String.valueOf(hero.getBoolean(CLAIMED, false)));
|
||||
statement.setInt(5, heroId);
|
||||
statement.execute();
|
||||
}
|
||||
}
|
||||
@ -798,11 +787,13 @@ public class Hero
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare new data
|
||||
final StatSet diaryEntry = new StatSet();
|
||||
final String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
|
||||
diaryEntry.set("date", date);
|
||||
diaryEntry.set("action", template.getName() + " was defeated");
|
||||
|
||||
// Add to old list
|
||||
list.add(diaryEntry);
|
||||
}
|
||||
@ -817,11 +808,13 @@ public class Hero
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare new data
|
||||
final StatSet diaryEntry = new StatSet();
|
||||
final String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
|
||||
diaryEntry.set("date", date);
|
||||
diaryEntry.set("action", castle.getName() + " Castle was successfuly taken");
|
||||
|
||||
// Add to old list
|
||||
list.add(diaryEntry);
|
||||
}
|
||||
@ -896,10 +889,7 @@ public class Hero
|
||||
*/
|
||||
public void shutdown()
|
||||
{
|
||||
for (int charId : HERO_MESSAGE.keySet())
|
||||
{
|
||||
saveHeroMessage(charId);
|
||||
}
|
||||
HERO_MESSAGE.keySet().forEach(this::saveHeroMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -951,11 +941,13 @@ public class Hero
|
||||
player.broadcastPacket(new SocialAction(player.getObjectId(), 20016)); // Hero Animation
|
||||
player.sendPacket(new UserInfo(player));
|
||||
player.broadcastUserInfo();
|
||||
|
||||
// Set Gained hero and reload data
|
||||
setHeroGained(player.getObjectId());
|
||||
loadFights(player.getObjectId());
|
||||
loadDiary(player.getObjectId());
|
||||
HERO_MESSAGE.put(player.getObjectId(), "");
|
||||
|
||||
EventDispatcher.getInstance().notifyEvent(new OnPlayerTakeHero(player));
|
||||
updateHeroes(false);
|
||||
}
|
||||
|
@ -71,15 +71,12 @@ public class Hero
|
||||
private static final String INSERT_HERO = "INSERT INTO heroes (charId, class_id, count, played, claimed) VALUES (?,?,?,?,?)";
|
||||
private static final String UPDATE_HERO = "UPDATE heroes SET count = ?, played = ?, claimed = ? WHERE charId = ?";
|
||||
private static final String GET_CLAN_ALLY = "SELECT characters.clanid AS clanid, coalesce(clan_data.ally_Id, 0) AS allyId FROM characters LEFT JOIN clan_data ON clan_data.clan_id = characters.clanid WHERE characters.charId = ?";
|
||||
// delete hero items
|
||||
private static final String DELETE_ITEMS = "DELETE FROM items WHERE item_id IN (30392, 30393, 30394, 30395, 30396, 30397, 30398, 30399, 30400, 30401, 30402, 30403, 30404, 30405, 30372, 30373, 6842, 6611, 6612, 6613, 6614, 6615, 6616, 6617, 6618, 6619, 6620, 6621, 9388, 9389, 9390) AND owner_id NOT IN (SELECT charId FROM characters WHERE accesslevel > 0)";
|
||||
|
||||
private static final Map<Integer, StatSet> HEROES = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, StatSet> COMPLETE_HEROS = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Map<Integer, StatSet> HERO_COUNTS = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, List<StatSet>> HERO_FIGHTS = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Map<Integer, List<StatSet>> HERO_DIARY = new ConcurrentHashMap<>();
|
||||
private static final Map<Integer, String> HERO_MESSAGE = new ConcurrentHashMap<>();
|
||||
|
||||
@ -128,7 +125,6 @@ public class Hero
|
||||
loadFights(charId);
|
||||
loadDiary(charId);
|
||||
loadMessage(charId);
|
||||
|
||||
processHeros(ps, charId, hero);
|
||||
HEROES.put(charId, hero);
|
||||
}
|
||||
@ -281,7 +277,7 @@ public class Hero
|
||||
data.set(Calendar.MILLISECOND, 0);
|
||||
|
||||
final long from = data.getTimeInMillis();
|
||||
int numberoffights = 0;
|
||||
int numberOfFights = 0;
|
||||
int victories = 0;
|
||||
int losses = 0;
|
||||
int draws = 0;
|
||||
@ -340,10 +336,8 @@ public class Hero
|
||||
fight.set("result", "<font color=\"ffff00\">draw</font>");
|
||||
draws++;
|
||||
}
|
||||
|
||||
fights.add(fight);
|
||||
|
||||
numberoffights++;
|
||||
numberOfFights++;
|
||||
}
|
||||
}
|
||||
else if (charId == charTwoId)
|
||||
@ -374,10 +368,8 @@ public class Hero
|
||||
fight.set("result", "<font color=\"ffff00\">draw</font>");
|
||||
draws++;
|
||||
}
|
||||
|
||||
fights.add(fight);
|
||||
|
||||
numberoffights++;
|
||||
numberOfFights++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -389,7 +381,7 @@ public class Hero
|
||||
HERO_COUNTS.put(charId, heroCountData);
|
||||
HERO_FIGHTS.put(charId, fights);
|
||||
|
||||
LOGGER.info("Hero System: Loaded " + numberoffights + " fights for Hero: " + CharNameTable.getInstance().getNameById(charId));
|
||||
LOGGER.info("Hero System: Loaded " + numberOfFights + " fights for Hero: " + CharNameTable.getInstance().getNameById(charId));
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
@ -631,12 +623,10 @@ public class Hero
|
||||
{
|
||||
player.sendInventoryUpdate(iu);
|
||||
}
|
||||
|
||||
player.broadcastUserInfo();
|
||||
}
|
||||
|
||||
deleteItemsInDb();
|
||||
|
||||
HEROES.clear();
|
||||
|
||||
if (newHeroes.isEmpty())
|
||||
@ -696,9 +686,9 @@ public class Hero
|
||||
{
|
||||
insert.setInt(1, heroId);
|
||||
insert.setInt(2, hero.getInt(Olympiad.CLASS_ID));
|
||||
insert.setInt(3, hero.getInt(COUNT));
|
||||
insert.setInt(4, hero.getInt(PLAYED));
|
||||
insert.setString(5, String.valueOf(hero.getBoolean(CLAIMED)));
|
||||
insert.setInt(3, hero.getInt(COUNT, 0));
|
||||
insert.setInt(4, hero.getInt(PLAYED, 0));
|
||||
insert.setString(5, String.valueOf(hero.getBoolean(CLAIMED, false)));
|
||||
insert.execute();
|
||||
insert.close();
|
||||
}
|
||||
@ -726,7 +716,6 @@ public class Hero
|
||||
allyCrest = ClanTable.getInstance().getClan(clanId).getAllyCrestId();
|
||||
}
|
||||
}
|
||||
|
||||
hero.set(CLAN_CREST, clanCrest);
|
||||
hero.set(CLAN_NAME, clanName);
|
||||
hero.set(ALLY_CREST, allyCrest);
|
||||
@ -734,17 +723,17 @@ public class Hero
|
||||
}
|
||||
}
|
||||
}
|
||||
HEROES.put(heroId, hero);
|
||||
|
||||
HEROES.put(heroId, hero);
|
||||
COMPLETE_HEROS.put(heroId, hero);
|
||||
}
|
||||
else
|
||||
{
|
||||
try (PreparedStatement statement = con.prepareStatement(UPDATE_HERO))
|
||||
{
|
||||
statement.setInt(1, hero.getInt(COUNT));
|
||||
statement.setInt(2, hero.getInt(PLAYED));
|
||||
statement.setString(3, String.valueOf(hero.getBoolean(CLAIMED)));
|
||||
statement.setInt(1, hero.getInt(COUNT, 0));
|
||||
statement.setInt(2, hero.getInt(PLAYED, 0));
|
||||
statement.setString(3, String.valueOf(hero.getBoolean(CLAIMED, false)));
|
||||
statement.setInt(4, heroId);
|
||||
statement.execute();
|
||||
}
|
||||
@ -773,11 +762,13 @@ public class Hero
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare new data
|
||||
final StatSet diaryEntry = new StatSet();
|
||||
final String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
|
||||
diaryEntry.set("date", date);
|
||||
diaryEntry.set("action", template.getName() + " was defeated");
|
||||
|
||||
// Add to old list
|
||||
list.add(diaryEntry);
|
||||
}
|
||||
@ -792,11 +783,13 @@ public class Hero
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare new data
|
||||
final StatSet diaryEntry = new StatSet();
|
||||
final String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
|
||||
diaryEntry.set("date", date);
|
||||
diaryEntry.set("action", castle.getName() + " Castle was successfuly taken");
|
||||
|
||||
// Add to old list
|
||||
list.add(diaryEntry);
|
||||
}
|
||||
@ -871,10 +864,7 @@ public class Hero
|
||||
*/
|
||||
public void shutdown()
|
||||
{
|
||||
for (int charId : HERO_MESSAGE.keySet())
|
||||
{
|
||||
saveHeroMessage(charId);
|
||||
}
|
||||
HERO_MESSAGE.keySet().forEach(this::saveHeroMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -926,11 +916,13 @@ public class Hero
|
||||
player.broadcastPacket(new SocialAction(player.getObjectId(), 20016)); // Hero Animation
|
||||
player.sendPacket(new UserInfo(player));
|
||||
player.broadcastUserInfo();
|
||||
|
||||
// Set Gained hero and reload data
|
||||
setHeroGained(player.getObjectId());
|
||||
loadFights(player.getObjectId());
|
||||
loadDiary(player.getObjectId());
|
||||
HERO_MESSAGE.put(player.getObjectId(), "");
|
||||
|
||||
EventDispatcher.getInstance().notifyEvent(new OnPlayerTakeHero(player));
|
||||
updateHeroes(false);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user