Sync with L2jServer HighFive Jul 25th 2015.

This commit is contained in:
MobiusDev
2015-07-26 10:59:25 +00:00
parent 83854bc5e5
commit 1fc14085f5
161 changed files with 2288 additions and 2181 deletions

View File

@ -21,6 +21,7 @@ package conquerablehalls.RainbowSpringsChateau;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
@ -31,7 +32,7 @@ import java.util.Map;
import java.util.concurrent.ScheduledFuture;
import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.cache.HtmCache;
import com.l2jserver.gameserver.data.sql.impl.ClanTable;
@ -395,7 +396,7 @@ public final class RainbowSpringsChateau extends ClanHallSiegeEngine
long count = warDecrees.getCount();
_warDecreesCount.put(clan.getId(), count);
player.destroyItem("Rainbow Springs Registration", warDecrees, npc, true);
updateAttacker(clan.getId(), count, false);
addAttacker(clan.getId(), count);
html = "messenger_yetti009.htm";
}
}
@ -415,7 +416,7 @@ public final class RainbowSpringsChateau extends ClanHallSiegeEngine
}
else
{
updateAttacker(clan.getId(), 0, true);
removeAttacker(clan.getId());
html = "messenger_yetti018.htm";
}
break;
@ -830,34 +831,31 @@ public final class RainbowSpringsChateau extends ClanHallSiegeEngine
private static boolean isYetiTarget(int npcId)
{
for (int yeti : YETIS)
{
if (yeti == npcId)
{
return true;
}
}
return false;
return Util.contains(YETIS, npcId);
}
private static void updateAttacker(int clanId, long count, boolean remove)
private static void removeAttacker(int clanId)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM rainbowsprings_attacker_list WHERE clanId = ?"))
{
PreparedStatement statement;
if (remove)
{
statement = con.prepareStatement("DELETE FROM rainbowsprings_attacker_list WHERE clanId = ?");
statement.setInt(1, clanId);
}
else
{
statement = con.prepareStatement("INSERT INTO rainbowsprings_attacker_list VALUES (?,?)");
statement.setInt(1, clanId);
statement.setLong(2, count);
}
statement.execute();
statement.close();
ps.setInt(1, clanId);
ps.execute();
}
catch (Exception e)
{
e.printStackTrace();
}
}
private static void addAttacker(int clanId, long count)
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO rainbowsprings_attacker_list VALUES (?,?)"))
{
ps.setInt(1, clanId);
ps.setLong(2, count);
ps.execute();
}
catch (Exception e)
{
@ -868,18 +866,16 @@ public final class RainbowSpringsChateau extends ClanHallSiegeEngine
@Override
public void loadAttackers()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
try (Connection con = ConnectionFactory.getInstance().getConnection();
Statement s = con.createStatement())
{
PreparedStatement statement = con.prepareStatement("SELECT * FROM rainbowsprings_attacker_list");
ResultSet rset = statement.executeQuery();
while (rset.next())
try (ResultSet rset = s.executeQuery("SELECT * FROM rainbowsprings_attacker_list"))
{
int clanId = rset.getInt("clan_id");
long count = rset.getLong("decrees_count");
_warDecreesCount.put(clanId, count);
while (rset.next())
{
_warDecreesCount.put(rset.getInt("clan_id"), rset.getLong("decrees_count"));
}
}
rset.close();
statement.close();
}
catch (Exception e)
{

View File

@ -27,7 +27,7 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.ai.CtrlIntention;
import com.l2jserver.gameserver.ai.L2SpecialSiegeGuardAI;
@ -764,135 +764,123 @@ public abstract class FlagWar extends ClanHallSiegeEngine
@Override
public final void loadAttackers()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(SQL_LOAD_ATTACKERS))
{
PreparedStatement statement = con.prepareStatement(SQL_LOAD_ATTACKERS);
statement.setInt(1, _hall.getId());
ResultSet rset = statement.executeQuery();
while (rset.next())
ps.setInt(1, _hall.getId());
try (ResultSet rset = ps.executeQuery())
{
final int clanId = rset.getInt("clan_id");
if (ClanTable.getInstance().getClan(clanId) == null)
while (rset.next())
{
_log.warning(getName() + ": Loaded an unexistent clan as attacker! Clan ID: " + clanId);
continue;
final int clanId = rset.getInt("clan_id");
if (ClanTable.getInstance().getClan(clanId) == null)
{
_log.warning(getName() + ": Loaded an unexistent clan as attacker! Clan ID: " + clanId);
continue;
}
ClanData data = new ClanData();
data.flag = rset.getInt("flag");
data.npc = rset.getInt("npc");
_data.put(clanId, data);
loadAttackerMembers(clanId);
}
ClanData data = new ClanData();
data.flag = rset.getInt("flag");
data.npc = rset.getInt("npc");
_data.put(clanId, data);
loadAttackerMembers(clanId);
}
rset.close();
statement.close();
}
catch (Exception e)
{
_log.warning(getName() + ".loadAttackers()->" + e.getMessage());
e.printStackTrace();
}
}
private final void loadAttackerMembers(int clanId)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
final List<Integer> listInstance = _data.get(clanId).players;
if (listInstance == null)
{
ArrayList<Integer> listInstance = _data.get(clanId).players;
if (listInstance == null)
_log.warning(getName() + ": Tried to load unregistered clan with ID " + clanId);
return;
}
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(SQL_LOAD_MEMEBERS))
{
ps.setInt(1, clanId);
try (ResultSet rset = ps.executeQuery())
{
_log.warning(getName() + ": Tried to load unregistered clan with ID " + clanId);
return;
while (rset.next())
{
listInstance.add(rset.getInt("object_id"));
}
}
PreparedStatement statement = con.prepareStatement(SQL_LOAD_MEMEBERS);
statement.setInt(1, clanId);
ResultSet rset = statement.executeQuery();
while (rset.next())
{
listInstance.add(rset.getInt("object_id"));
}
rset.close();
statement.close();
}
catch (Exception e)
{
_log.warning(getName() + ".loadAttackerMembers()->" + e.getMessage());
e.printStackTrace();
}
}
private final void saveClan(int clanId, int flag)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(SQL_SAVE_CLAN))
{
PreparedStatement statement = con.prepareStatement(SQL_SAVE_CLAN);
statement.setInt(1, _hall.getId());
statement.setInt(2, flag);
statement.setInt(3, 0);
statement.setInt(4, clanId);
statement.execute();
statement.close();
ps.setInt(1, _hall.getId());
ps.setInt(2, flag);
ps.setInt(3, 0);
ps.setInt(4, clanId);
ps.execute();
}
catch (Exception e)
{
_log.warning(getName() + ".saveClan()->" + e.getMessage());
e.printStackTrace();
}
}
private final void saveNpc(int npc, int clanId)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(SQL_SAVE_NPC))
{
PreparedStatement statement = con.prepareStatement(SQL_SAVE_NPC);
statement.setInt(1, npc);
statement.setInt(2, clanId);
statement.execute();
statement.close();
ps.setInt(1, npc);
ps.setInt(2, clanId);
ps.execute();
}
catch (Exception e)
{
_log.warning(getName() + ".saveNpc()->" + e.getMessage());
e.printStackTrace();
}
}
private final void saveMember(int clanId, int objectId)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(SQL_SAVE_ATTACKER))
{
PreparedStatement statement = con.prepareStatement(SQL_SAVE_ATTACKER);
statement.setInt(1, _hall.getId());
statement.setInt(2, clanId);
statement.setInt(3, objectId);
statement.execute();
statement.close();
ps.setInt(1, _hall.getId());
ps.setInt(2, clanId);
ps.setInt(3, objectId);
ps.execute();
}
catch (Exception e)
{
_log.warning(getName() + ".saveMember()->" + e.getMessage());
e.printStackTrace();
}
}
private void clearTables()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps1 = con.prepareStatement(SQL_CLEAR_CLAN);
PreparedStatement ps2 = con.prepareStatement(SQL_CLEAR_CLAN_ATTACKERS))
{
PreparedStatement stat1 = con.prepareStatement(SQL_CLEAR_CLAN);
stat1.setInt(1, _hall.getId());
stat1.execute();
stat1.close();
ps1.setInt(1, _hall.getId());
ps1.execute();
PreparedStatement stat2 = con.prepareStatement(SQL_CLEAR_CLAN_ATTACKERS);
stat2.setInt(1, _hall.getId());
stat2.execute();
stat2.close();
ps2.setInt(1, _hall.getId());
ps2.execute();
}
catch (Exception e)
{
@ -904,8 +892,8 @@ public abstract class FlagWar extends ClanHallSiegeEngine
{
int flag = 0;
int npc = 0;
ArrayList<Integer> players = new ArrayList<>(18);
ArrayList<L2PcInstance> playersInstance = new ArrayList<>(18);
List<Integer> players = new ArrayList<>(18);
List<L2PcInstance> playersInstance = new ArrayList<>(18);
L2Spawn warrior = null;
L2Spawn flagInstance = null;
}