SevenSigns.java 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package com.l2jserver.gameserver;
  16. import java.sql.Connection;
  17. import java.sql.PreparedStatement;
  18. import java.sql.ResultSet;
  19. import java.sql.SQLException;
  20. import java.util.Calendar;
  21. import java.util.Collection;
  22. import java.util.List;
  23. import java.util.Map;
  24. import java.util.logging.Level;
  25. import java.util.logging.Logger;
  26. import javolution.util.FastMap;
  27. import com.l2jserver.Config;
  28. import com.l2jserver.L2DatabaseFactory;
  29. import com.l2jserver.gameserver.datatables.MapRegionTable;
  30. import com.l2jserver.gameserver.datatables.SkillTable;
  31. import com.l2jserver.gameserver.instancemanager.CastleManager;
  32. import com.l2jserver.gameserver.instancemanager.QuestManager;
  33. import com.l2jserver.gameserver.instancemanager.TerritoryWarManager;
  34. import com.l2jserver.gameserver.model.AutoChatHandler;
  35. import com.l2jserver.gameserver.model.AutoSpawnHandler;
  36. import com.l2jserver.gameserver.model.AutoSpawnHandler.AutoSpawnInstance;
  37. import com.l2jserver.gameserver.model.L2World;
  38. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  39. import com.l2jserver.gameserver.model.entity.Castle;
  40. import com.l2jserver.gameserver.model.quest.Quest;
  41. import com.l2jserver.gameserver.network.SystemMessageId;
  42. import com.l2jserver.gameserver.network.serverpackets.SSQInfo;
  43. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  44. import com.l2jserver.gameserver.templates.StatsSet;
  45. import com.l2jserver.gameserver.util.Broadcast;
  46. /**
  47. * Seven Signs Engine
  48. *
  49. *
  50. *
  51. *
  52. * @author Tempy
  53. */
  54. public class SevenSigns
  55. {
  56. protected static final Logger _log = Logger.getLogger(SevenSigns.class.getName());
  57. // Basic Seven Signs Constants \\
  58. public static final String SEVEN_SIGNS_DATA_FILE = "config/signs.properties";
  59. public static final String SEVEN_SIGNS_HTML_PATH = "data/html/seven_signs/";
  60. public static final int CABAL_NULL = 0;
  61. public static final int CABAL_DUSK = 1;
  62. public static final int CABAL_DAWN = 2;
  63. public static final int SEAL_NULL = 0;
  64. public static final int SEAL_AVARICE = 1;
  65. public static final int SEAL_GNOSIS = 2;
  66. public static final int SEAL_STRIFE = 3;
  67. public static final int PERIOD_COMP_RECRUITING = 0;
  68. public static final int PERIOD_COMPETITION = 1;
  69. public static final int PERIOD_COMP_RESULTS = 2;
  70. public static final int PERIOD_SEAL_VALIDATION = 3;
  71. public static final int PERIOD_START_HOUR = 18;
  72. public static final int PERIOD_START_MINS = 00;
  73. public static final int PERIOD_START_DAY = Calendar.MONDAY;
  74. // The quest event and seal validation periods last for approximately one week
  75. // with a 15 minutes "interval" period sandwiched between them.
  76. public static final int PERIOD_MINOR_LENGTH = 900000;
  77. public static final int PERIOD_MAJOR_LENGTH = 604800000 - PERIOD_MINOR_LENGTH;
  78. public static final int ANCIENT_ADENA_ID = 5575;
  79. public static final int RECORD_SEVEN_SIGNS_ID = 5707;
  80. public static final int CERTIFICATE_OF_APPROVAL_ID = 6388;
  81. public static final int RECORD_SEVEN_SIGNS_COST = 500;
  82. public static final int ADENA_JOIN_DAWN_COST = 50000;
  83. // NPC Related Constants \\
  84. public static final int ORATOR_NPC_ID = 31094;
  85. public static final int PREACHER_NPC_ID = 31093;
  86. public static final int MAMMON_MERCHANT_ID = 31113;
  87. public static final int MAMMON_BLACKSMITH_ID = 31126;
  88. public static final int MAMMON_MARKETEER_ID = 31092;
  89. public static final int SPIRIT_IN_ID = 31111;
  90. public static final int SPIRIT_OUT_ID = 31112;
  91. public static final int LILITH_NPC_ID = 25283;
  92. public static final int ANAKIM_NPC_ID = 25286;
  93. public static final int CREST_OF_DAWN_ID = 31170;
  94. public static final int CREST_OF_DUSK_ID = 31171;
  95. // Seal Stone Related Constants \\
  96. public static final int SEAL_STONE_BLUE_ID = 6360;
  97. public static final int SEAL_STONE_GREEN_ID = 6361;
  98. public static final int SEAL_STONE_RED_ID = 6362;
  99. public static final int SEAL_STONE_BLUE_VALUE = 3;
  100. public static final int SEAL_STONE_GREEN_VALUE = 5;
  101. public static final int SEAL_STONE_RED_VALUE = 10;
  102. public static final int BLUE_CONTRIB_POINTS = 3;
  103. public static final int GREEN_CONTRIB_POINTS = 5;
  104. public static final int RED_CONTRIB_POINTS = 10;
  105. private final Calendar _nextPeriodChange = Calendar.getInstance();
  106. protected int _activePeriod;
  107. protected int _currentCycle;
  108. protected double _dawnStoneScore;
  109. protected double _duskStoneScore;
  110. protected int _dawnFestivalScore;
  111. protected int _duskFestivalScore;
  112. protected int _compWinner;
  113. protected int _previousWinner;
  114. protected Calendar _lastSave = Calendar.getInstance();
  115. private Map<Integer, StatsSet> _signsPlayerData;
  116. private Map<Integer, Integer> _signsSealOwners;
  117. private Map<Integer, Integer> _signsDuskSealTotals;
  118. private Map<Integer, Integer> _signsDawnSealTotals;
  119. private static AutoSpawnInstance _merchantSpawn;
  120. private static AutoSpawnInstance _blacksmithSpawn;
  121. private static AutoSpawnInstance _spiritInSpawn;
  122. private static AutoSpawnInstance _spiritOutSpawn;
  123. private static AutoSpawnInstance _lilithSpawn;
  124. private static AutoSpawnInstance _anakimSpawn;
  125. private static Map<Integer, AutoSpawnInstance> _crestofdawnspawns;
  126. private static Map<Integer, AutoSpawnInstance> _crestofduskspawns;
  127. private static Map<Integer, AutoSpawnInstance> _oratorSpawns;
  128. private static Map<Integer, AutoSpawnInstance> _preacherSpawns;
  129. private static Map<Integer, AutoSpawnInstance> _marketeerSpawns;
  130. private static final String LOAD_DATA =
  131. "SELECT charId, cabal, seal, red_stones, green_stones, blue_stones, " +
  132. "ancient_adena_amount, contribution_score FROM seven_signs";
  133. private static final String LOAD_STATUS = "SELECT * FROM seven_signs_status WHERE id=0";
  134. private static final String INSERT_PLAYER =
  135. "INSERT INTO seven_signs (charId, cabal, seal) VALUES (?,?,?)";
  136. private static final String UPDATE_PLAYER =
  137. "UPDATE seven_signs SET cabal=?, seal=?, red_stones=?, green_stones=?, blue_stones=?, " +
  138. "ancient_adena_amount=?, contribution_score=? WHERE charId=?";
  139. private static final String UPDATE_STATUS =
  140. "UPDATE seven_signs_status SET current_cycle=?, active_period=?, previous_winner=?, " +
  141. "dawn_stone_score=?, dawn_festival_score=?, dusk_stone_score=?, dusk_festival_score=?, " +
  142. "avarice_owner=?, gnosis_owner=?, strife_owner=?, avarice_dawn_score=?, gnosis_dawn_score=?, " +
  143. "strife_dawn_score=?, avarice_dusk_score=?, gnosis_dusk_score=?, strife_dusk_score=?, " +
  144. "festival_cycle=?, accumulated_bonus0=?, accumulated_bonus1=?, accumulated_bonus2=?," +
  145. "accumulated_bonus3=?, accumulated_bonus4=?, date=? WHERE id=0";
  146. private SevenSigns()
  147. {
  148. _signsPlayerData = new FastMap<Integer, StatsSet>();
  149. _signsSealOwners = new FastMap<Integer, Integer>();
  150. _signsDuskSealTotals = new FastMap<Integer, Integer>();
  151. _signsDawnSealTotals = new FastMap<Integer, Integer>();
  152. try
  153. {
  154. restoreSevenSignsData();
  155. }
  156. catch (Exception e)
  157. {
  158. _log.log(Level.SEVERE, "SevenSigns: Failed to load configuration: " + e.getMessage(), e);
  159. }
  160. _log.info("SevenSigns: Currently in the " + getCurrentPeriodName() + " period!");
  161. initializeSeals();
  162. if (isSealValidationPeriod())
  163. if (getCabalHighestScore() == CABAL_NULL)
  164. _log.info("SevenSigns: The competition ended with a tie last week.");
  165. else
  166. _log.info("SevenSigns: The " + getCabalName(getCabalHighestScore()) + " were victorious last week.");
  167. else if (getCabalHighestScore() == CABAL_NULL)
  168. _log.info("SevenSigns: The competition, if the current trend continues, will end in a tie this week.");
  169. else
  170. _log.info("SevenSigns: The " + getCabalName(getCabalHighestScore()) + " are in the lead this week.");
  171. long milliToChange = 0;
  172. if (isNextPeriodChangeInPast())
  173. {
  174. _log.info("SevenSigns: Next period change was in the past (server was offline), changing periods now!");
  175. }
  176. else
  177. {
  178. setCalendarForNextPeriodChange();
  179. milliToChange = getMilliToPeriodChange();
  180. }
  181. // Schedule a time for the next period change.
  182. SevenSignsPeriodChange sspc = new SevenSignsPeriodChange();
  183. ThreadPoolManager.getInstance().scheduleGeneral(sspc, milliToChange);
  184. // Thanks to http://rainbow.arch.scriptmania.com/scripts/timezone_countdown.html for help with this.
  185. double numSecs = (milliToChange / 1000) % 60;
  186. double countDown = ((milliToChange / 1000) - numSecs) / 60;
  187. int numMins = (int) Math.floor(countDown % 60);
  188. countDown = (countDown - numMins) / 60;
  189. int numHours = (int) Math.floor(countDown % 24);
  190. int numDays = (int) Math.floor((countDown - numHours) / 24);
  191. _log.info("SevenSigns: Next period begins in " + numDays + " days, " + numHours + " hours and " + numMins + " mins.");
  192. }
  193. private boolean isNextPeriodChangeInPast()
  194. {
  195. Calendar lastPeriodChange = Calendar.getInstance();
  196. switch (getCurrentPeriod())
  197. {
  198. case PERIOD_SEAL_VALIDATION:
  199. case PERIOD_COMPETITION:
  200. lastPeriodChange.set(Calendar.DAY_OF_WEEK, PERIOD_START_DAY);
  201. lastPeriodChange.set(Calendar.HOUR_OF_DAY, PERIOD_START_HOUR);
  202. lastPeriodChange.set(Calendar.MINUTE, PERIOD_START_MINS);
  203. lastPeriodChange.set(Calendar.SECOND, 0);
  204. // if we hit next week, just turn back 1 week
  205. if (Calendar.getInstance().before(lastPeriodChange))
  206. lastPeriodChange.add(Calendar.HOUR, -24*7);
  207. break;
  208. case PERIOD_COMP_RECRUITING:
  209. case PERIOD_COMP_RESULTS:
  210. // because of the short duration of this period, just check it from last save
  211. lastPeriodChange.setTimeInMillis(_lastSave.getTimeInMillis() + PERIOD_MINOR_LENGTH);
  212. break;
  213. }
  214. // because of previous "date" column usage, check only if it already contains usable data for us
  215. if (_lastSave.getTimeInMillis() > 7 && _lastSave.before(lastPeriodChange))
  216. return true;
  217. else
  218. return false;
  219. }
  220. /**
  221. * Registers all random spawns and auto-chats for Seven Signs NPCs,
  222. * along with spawns for the Preachers of Doom and Orators of Revelations
  223. * at the beginning of the Seal Validation period.
  224. *
  225. */
  226. public void spawnSevenSignsNPC()
  227. {
  228. _merchantSpawn = AutoSpawnHandler.getInstance().getAutoSpawnInstance(MAMMON_MERCHANT_ID, false);
  229. _blacksmithSpawn = AutoSpawnHandler.getInstance().getAutoSpawnInstance(MAMMON_BLACKSMITH_ID, false);
  230. _marketeerSpawns = AutoSpawnHandler.getInstance().getAutoSpawnInstances(MAMMON_MARKETEER_ID);
  231. _spiritInSpawn = AutoSpawnHandler.getInstance().getAutoSpawnInstance(SPIRIT_IN_ID, false);
  232. _spiritOutSpawn = AutoSpawnHandler.getInstance().getAutoSpawnInstance(SPIRIT_OUT_ID, false);
  233. _lilithSpawn = AutoSpawnHandler.getInstance().getAutoSpawnInstance(LILITH_NPC_ID, false);
  234. _anakimSpawn = AutoSpawnHandler.getInstance().getAutoSpawnInstance(ANAKIM_NPC_ID, false);
  235. _crestofdawnspawns = AutoSpawnHandler.getInstance().getAutoSpawnInstances(CREST_OF_DAWN_ID);
  236. _crestofduskspawns = AutoSpawnHandler.getInstance().getAutoSpawnInstances(CREST_OF_DUSK_ID);
  237. _oratorSpawns = AutoSpawnHandler.getInstance().getAutoSpawnInstances(ORATOR_NPC_ID);
  238. _preacherSpawns = AutoSpawnHandler.getInstance().getAutoSpawnInstances(PREACHER_NPC_ID);
  239. if (isSealValidationPeriod() || isCompResultsPeriod())
  240. {
  241. for (AutoSpawnInstance spawnInst : _marketeerSpawns.values())
  242. AutoSpawnHandler.getInstance().setSpawnActive(spawnInst, true);
  243. if (getSealOwner(SEAL_GNOSIS) == getCabalHighestScore() && getSealOwner(SEAL_GNOSIS) != CABAL_NULL)
  244. {
  245. if (!Config.ANNOUNCE_MAMMON_SPAWN)
  246. _blacksmithSpawn.setBroadcast(false);
  247. if (!AutoSpawnHandler.getInstance().getAutoSpawnInstance(_blacksmithSpawn.getObjectId(), true).isSpawnActive())
  248. AutoSpawnHandler.getInstance().setSpawnActive(_blacksmithSpawn, true);
  249. for (AutoSpawnInstance spawnInst : _oratorSpawns.values())
  250. if (!AutoSpawnHandler.getInstance().getAutoSpawnInstance(spawnInst.getObjectId(), true).isSpawnActive())
  251. AutoSpawnHandler.getInstance().setSpawnActive(spawnInst, true);
  252. for (AutoSpawnInstance spawnInst : _preacherSpawns.values())
  253. if (!AutoSpawnHandler.getInstance().getAutoSpawnInstance(spawnInst.getObjectId(), true).isSpawnActive())
  254. AutoSpawnHandler.getInstance().setSpawnActive(spawnInst, true);
  255. if (!AutoChatHandler.getInstance().getAutoChatInstance(PREACHER_NPC_ID, false).isActive()
  256. && !AutoChatHandler.getInstance().getAutoChatInstance(ORATOR_NPC_ID, false).isActive())
  257. AutoChatHandler.getInstance().setAutoChatActive(true);
  258. }
  259. else
  260. {
  261. AutoSpawnHandler.getInstance().setSpawnActive(_blacksmithSpawn, false);
  262. for (AutoSpawnInstance spawnInst : _oratorSpawns.values())
  263. AutoSpawnHandler.getInstance().setSpawnActive(spawnInst, false);
  264. for (AutoSpawnInstance spawnInst : _preacherSpawns.values())
  265. AutoSpawnHandler.getInstance().setSpawnActive(spawnInst, false);
  266. AutoChatHandler.getInstance().setAutoChatActive(false);
  267. }
  268. if (getSealOwner(SEAL_AVARICE) == getCabalHighestScore() && getSealOwner(SEAL_AVARICE) != CABAL_NULL)
  269. {
  270. if (!Config.ANNOUNCE_MAMMON_SPAWN)
  271. _merchantSpawn.setBroadcast(false);
  272. if (!AutoSpawnHandler.getInstance().getAutoSpawnInstance(_merchantSpawn.getObjectId(), true).isSpawnActive())
  273. AutoSpawnHandler.getInstance().setSpawnActive(_merchantSpawn, true);
  274. if (!AutoSpawnHandler.getInstance().getAutoSpawnInstance(_spiritInSpawn.getObjectId(), true).isSpawnActive())
  275. AutoSpawnHandler.getInstance().setSpawnActive(_spiritInSpawn, true);
  276. if (!AutoSpawnHandler.getInstance().getAutoSpawnInstance(_spiritOutSpawn.getObjectId(), true).isSpawnActive())
  277. AutoSpawnHandler.getInstance().setSpawnActive(_spiritOutSpawn, true);
  278. switch (getCabalHighestScore())
  279. {
  280. case CABAL_DAWN:
  281. if (!AutoSpawnHandler.getInstance().getAutoSpawnInstance(_lilithSpawn.getObjectId(), true).isSpawnActive())
  282. AutoSpawnHandler.getInstance().setSpawnActive(_lilithSpawn, true);
  283. AutoSpawnHandler.getInstance().setSpawnActive(_anakimSpawn, false);
  284. for (AutoSpawnInstance dawnCrest : _crestofdawnspawns.values())
  285. {
  286. if(!AutoSpawnHandler.getInstance().getAutoSpawnInstance(dawnCrest.getObjectId(), true).isSpawnActive())
  287. {
  288. AutoSpawnHandler.getInstance().setSpawnActive(dawnCrest, true);
  289. }
  290. }
  291. for (AutoSpawnInstance duskCrest : _crestofduskspawns.values())
  292. {
  293. AutoSpawnHandler.getInstance().setSpawnActive(duskCrest, false);
  294. }
  295. break;
  296. case CABAL_DUSK:
  297. if (!AutoSpawnHandler.getInstance().getAutoSpawnInstance(_anakimSpawn.getObjectId(), true).isSpawnActive())
  298. AutoSpawnHandler.getInstance().setSpawnActive(_anakimSpawn, true);
  299. AutoSpawnHandler.getInstance().setSpawnActive(_lilithSpawn, false);
  300. for (AutoSpawnInstance duskCrest : _crestofduskspawns.values())
  301. {
  302. if(!AutoSpawnHandler.getInstance().getAutoSpawnInstance(duskCrest.getObjectId(), true).isSpawnActive())
  303. {
  304. AutoSpawnHandler.getInstance().setSpawnActive(duskCrest, true);
  305. }
  306. }
  307. for (AutoSpawnInstance dawnCrest : _crestofdawnspawns.values())
  308. {
  309. AutoSpawnHandler.getInstance().setSpawnActive(dawnCrest, false);
  310. }
  311. break;
  312. }
  313. }
  314. else
  315. {
  316. AutoSpawnHandler.getInstance().setSpawnActive(_merchantSpawn, false);
  317. AutoSpawnHandler.getInstance().setSpawnActive(_lilithSpawn, false);
  318. AutoSpawnHandler.getInstance().setSpawnActive(_anakimSpawn, false);
  319. for (AutoSpawnInstance dawnCrest : _crestofdawnspawns.values())
  320. {
  321. AutoSpawnHandler.getInstance().setSpawnActive(dawnCrest, false);
  322. }
  323. for (AutoSpawnInstance duskCrest : _crestofduskspawns.values())
  324. {
  325. AutoSpawnHandler.getInstance().setSpawnActive(duskCrest, false);
  326. }
  327. AutoSpawnHandler.getInstance().setSpawnActive(_spiritInSpawn, false);
  328. AutoSpawnHandler.getInstance().setSpawnActive(_spiritOutSpawn, false);
  329. }
  330. }
  331. else
  332. {
  333. AutoSpawnHandler.getInstance().setSpawnActive(_merchantSpawn, false);
  334. AutoSpawnHandler.getInstance().setSpawnActive(_blacksmithSpawn, false);
  335. AutoSpawnHandler.getInstance().setSpawnActive(_lilithSpawn, false);
  336. AutoSpawnHandler.getInstance().setSpawnActive(_anakimSpawn, false);
  337. for (AutoSpawnInstance dawnCrest : _crestofdawnspawns.values())
  338. {
  339. AutoSpawnHandler.getInstance().setSpawnActive(dawnCrest, false);
  340. }
  341. for (AutoSpawnInstance duskCrest : _crestofduskspawns.values())
  342. {
  343. AutoSpawnHandler.getInstance().setSpawnActive(duskCrest, false);
  344. }
  345. AutoSpawnHandler.getInstance().setSpawnActive(_spiritInSpawn, false);
  346. AutoSpawnHandler.getInstance().setSpawnActive(_spiritOutSpawn, false);
  347. for (AutoSpawnInstance spawnInst : _oratorSpawns.values())
  348. AutoSpawnHandler.getInstance().setSpawnActive(spawnInst, false);
  349. for (AutoSpawnInstance spawnInst : _preacherSpawns.values())
  350. AutoSpawnHandler.getInstance().setSpawnActive(spawnInst, false);
  351. for (AutoSpawnInstance spawnInst : _marketeerSpawns.values())
  352. AutoSpawnHandler.getInstance().setSpawnActive(spawnInst, false);
  353. AutoChatHandler.getInstance().setAutoChatActive(false);
  354. }
  355. }
  356. public static SevenSigns getInstance()
  357. {
  358. return SingletonHolder._instance;
  359. }
  360. public static long calcContributionScore(long blueCount, long greenCount, long redCount)
  361. {
  362. long contrib = blueCount * BLUE_CONTRIB_POINTS;
  363. contrib += greenCount * GREEN_CONTRIB_POINTS;
  364. contrib += redCount * RED_CONTRIB_POINTS;
  365. return contrib;
  366. }
  367. public static long calcAncientAdenaReward(long blueCount, long greenCount, long redCount)
  368. {
  369. long reward = blueCount * SEAL_STONE_BLUE_VALUE;
  370. reward += greenCount * SEAL_STONE_GREEN_VALUE;
  371. reward += redCount * SEAL_STONE_RED_VALUE;
  372. return reward;
  373. }
  374. public static final String getCabalShortName(int cabal)
  375. {
  376. switch (cabal)
  377. {
  378. case CABAL_DAWN:
  379. return "dawn";
  380. case CABAL_DUSK:
  381. return "dusk";
  382. }
  383. return "No Cabal";
  384. }
  385. public static final String getCabalName(int cabal)
  386. {
  387. switch (cabal)
  388. {
  389. case CABAL_DAWN:
  390. return "Lords of Dawn";
  391. case CABAL_DUSK:
  392. return "Revolutionaries of Dusk";
  393. }
  394. return "No Cabal";
  395. }
  396. public static final String getSealName(int seal, boolean shortName)
  397. {
  398. String sealName = (!shortName) ? "Seal of " : "";
  399. switch (seal)
  400. {
  401. case SEAL_AVARICE:
  402. sealName += "Avarice";
  403. break;
  404. case SEAL_GNOSIS:
  405. sealName += "Gnosis";
  406. break;
  407. case SEAL_STRIFE:
  408. sealName += "Strife";
  409. break;
  410. }
  411. return sealName;
  412. }
  413. public final int getCurrentCycle()
  414. {
  415. return _currentCycle;
  416. }
  417. public final int getCurrentPeriod()
  418. {
  419. return _activePeriod;
  420. }
  421. private final int getDaysToPeriodChange()
  422. {
  423. int numDays = _nextPeriodChange.get(Calendar.DAY_OF_WEEK) - PERIOD_START_DAY;
  424. if (numDays < 0)
  425. return 0 - numDays;
  426. return 7 - numDays;
  427. }
  428. public final long getMilliToPeriodChange()
  429. {
  430. long currTimeMillis = System.currentTimeMillis();
  431. long changeTimeMillis = _nextPeriodChange.getTimeInMillis();
  432. return (changeTimeMillis - currTimeMillis);
  433. }
  434. protected void setCalendarForNextPeriodChange()
  435. {
  436. // Calculate the number of days until the next period
  437. // A period starts at 18:00 pm (local time), like on official servers.
  438. switch (getCurrentPeriod())
  439. {
  440. case PERIOD_SEAL_VALIDATION:
  441. case PERIOD_COMPETITION:
  442. int daysToChange = getDaysToPeriodChange();
  443. if (daysToChange == 7)
  444. if (_nextPeriodChange.get(Calendar.HOUR_OF_DAY) < PERIOD_START_HOUR)
  445. daysToChange = 0;
  446. else if (_nextPeriodChange.get(Calendar.HOUR_OF_DAY) == PERIOD_START_HOUR && _nextPeriodChange.get(Calendar.MINUTE) < PERIOD_START_MINS)
  447. daysToChange = 0;
  448. // Otherwise...
  449. if (daysToChange > 0)
  450. _nextPeriodChange.add(Calendar.DATE, daysToChange);
  451. _nextPeriodChange.set(Calendar.HOUR_OF_DAY, PERIOD_START_HOUR);
  452. _nextPeriodChange.set(Calendar.MINUTE, PERIOD_START_MINS);
  453. break;
  454. case PERIOD_COMP_RECRUITING:
  455. case PERIOD_COMP_RESULTS:
  456. _nextPeriodChange.add(Calendar.MILLISECOND, PERIOD_MINOR_LENGTH);
  457. break;
  458. }
  459. _log.info("SevenSigns: Next period change set to " + _nextPeriodChange.getTime());
  460. }
  461. public final String getCurrentPeriodName()
  462. {
  463. String periodName = null;
  464. switch (_activePeriod)
  465. {
  466. case PERIOD_COMP_RECRUITING:
  467. periodName = "Quest Event Initialization";
  468. break;
  469. case PERIOD_COMPETITION:
  470. periodName = "Competition (Quest Event)";
  471. break;
  472. case PERIOD_COMP_RESULTS:
  473. periodName = "Quest Event Results";
  474. break;
  475. case PERIOD_SEAL_VALIDATION:
  476. periodName = "Seal Validation";
  477. break;
  478. }
  479. return periodName;
  480. }
  481. public final boolean isSealValidationPeriod()
  482. {
  483. return (_activePeriod == PERIOD_SEAL_VALIDATION);
  484. }
  485. public final boolean isCompResultsPeriod()
  486. {
  487. return (_activePeriod == PERIOD_COMP_RESULTS);
  488. }
  489. /**
  490. * returns true if the given date is in Seal Validation or in Quest Event Results period
  491. * @param date
  492. */
  493. public boolean isDateInSealValidPeriod(Calendar date)
  494. {
  495. long nextPeriodChange = getMilliToPeriodChange();
  496. long nextQuestStart = 0;
  497. long nextValidStart = 0;
  498. long tillDate = date.getTimeInMillis() - Calendar.getInstance().getTimeInMillis();
  499. while ((2 * PERIOD_MAJOR_LENGTH + 2 * PERIOD_MINOR_LENGTH) < tillDate)
  500. tillDate -= (2 * PERIOD_MAJOR_LENGTH + 2 * PERIOD_MINOR_LENGTH);
  501. while (tillDate < 0)
  502. tillDate += (2 * PERIOD_MAJOR_LENGTH + 2 * PERIOD_MINOR_LENGTH);
  503. switch (getCurrentPeriod())
  504. {
  505. case PERIOD_COMP_RECRUITING:
  506. nextValidStart = nextPeriodChange + PERIOD_MAJOR_LENGTH;
  507. nextQuestStart = nextValidStart + PERIOD_MAJOR_LENGTH + PERIOD_MINOR_LENGTH;
  508. break;
  509. case PERIOD_COMPETITION:
  510. nextValidStart = nextPeriodChange;
  511. nextQuestStart = nextPeriodChange + PERIOD_MAJOR_LENGTH + PERIOD_MINOR_LENGTH;
  512. break;
  513. case PERIOD_COMP_RESULTS:
  514. nextQuestStart = nextPeriodChange + PERIOD_MAJOR_LENGTH;
  515. nextValidStart = nextQuestStart + PERIOD_MAJOR_LENGTH + PERIOD_MINOR_LENGTH;
  516. break;
  517. case PERIOD_SEAL_VALIDATION:
  518. nextQuestStart = nextPeriodChange;
  519. nextValidStart = nextPeriodChange + PERIOD_MAJOR_LENGTH + PERIOD_MINOR_LENGTH;
  520. break;
  521. }
  522. if ((nextQuestStart < tillDate && tillDate < nextValidStart)
  523. || (nextValidStart < nextQuestStart && (tillDate < nextValidStart || nextQuestStart < tillDate)))
  524. return false;
  525. return true;
  526. }
  527. public final int getCurrentScore(int cabal)
  528. {
  529. double totalStoneScore = _dawnStoneScore + _duskStoneScore;
  530. switch (cabal)
  531. {
  532. case CABAL_NULL:
  533. return 0;
  534. case CABAL_DAWN:
  535. return Math.round((float) (_dawnStoneScore / ((float) totalStoneScore == 0 ? 1 : totalStoneScore)) * 500)
  536. + _dawnFestivalScore;
  537. case CABAL_DUSK:
  538. return Math.round((float) (_duskStoneScore / ((float) totalStoneScore == 0 ? 1 : totalStoneScore)) * 500)
  539. + _duskFestivalScore;
  540. }
  541. return 0;
  542. }
  543. public final double getCurrentStoneScore(int cabal)
  544. {
  545. switch (cabal)
  546. {
  547. case CABAL_NULL:
  548. return 0;
  549. case CABAL_DAWN:
  550. return _dawnStoneScore;
  551. case CABAL_DUSK:
  552. return _duskStoneScore;
  553. }
  554. return 0;
  555. }
  556. public final int getCurrentFestivalScore(int cabal)
  557. {
  558. switch (cabal)
  559. {
  560. case CABAL_NULL:
  561. return 0;
  562. case CABAL_DAWN:
  563. return _dawnFestivalScore;
  564. case CABAL_DUSK:
  565. return _duskFestivalScore;
  566. }
  567. return 0;
  568. }
  569. public final int getCabalHighestScore()
  570. {
  571. if (getCurrentScore(CABAL_DUSK) == getCurrentScore(CABAL_DAWN))
  572. return CABAL_NULL;
  573. else if (getCurrentScore(CABAL_DUSK) > getCurrentScore(CABAL_DAWN))
  574. return CABAL_DUSK;
  575. else
  576. return CABAL_DAWN;
  577. }
  578. public final int getSealOwner(int seal)
  579. {
  580. return _signsSealOwners.get(seal);
  581. }
  582. public final int getSealProportion(int seal, int cabal)
  583. {
  584. if (cabal == CABAL_NULL)
  585. return 0;
  586. else if (cabal == CABAL_DUSK)
  587. return _signsDuskSealTotals.get(seal);
  588. else
  589. return _signsDawnSealTotals.get(seal);
  590. }
  591. public final int getTotalMembers(int cabal)
  592. {
  593. int cabalMembers = 0;
  594. String cabalName = getCabalShortName(cabal);
  595. for (StatsSet sevenDat : _signsPlayerData.values())
  596. if (sevenDat.getString("cabal").equals(cabalName))
  597. cabalMembers++;
  598. return cabalMembers;
  599. }
  600. public int getPlayerStoneContrib(int objectId)
  601. {
  602. final StatsSet currPlayer = _signsPlayerData.get(objectId);
  603. if (currPlayer == null)
  604. return 0;
  605. int stoneCount = 0;
  606. stoneCount += currPlayer.getInteger("red_stones");
  607. stoneCount += currPlayer.getInteger("green_stones");
  608. stoneCount += currPlayer.getInteger("blue_stones");
  609. return stoneCount;
  610. }
  611. public int getPlayerContribScore(int objectId)
  612. {
  613. final StatsSet currPlayer = _signsPlayerData.get(objectId);
  614. if (currPlayer == null)
  615. return 0;
  616. return currPlayer.getInteger("contribution_score");
  617. }
  618. public int getPlayerAdenaCollect(int objectId)
  619. {
  620. final StatsSet currPlayer = _signsPlayerData.get(objectId);
  621. if (currPlayer == null)
  622. return 0;
  623. return currPlayer.getInteger("ancient_adena_amount");
  624. }
  625. public int getPlayerSeal(int objectId)
  626. {
  627. final StatsSet currPlayer = _signsPlayerData.get(objectId);
  628. if (currPlayer == null)
  629. return SEAL_NULL;
  630. return currPlayer.getInteger("seal");
  631. }
  632. public int getPlayerCabal(int objectId)
  633. {
  634. final StatsSet currPlayer = _signsPlayerData.get(objectId);
  635. if (currPlayer == null)
  636. return CABAL_NULL;
  637. String playerCabal = currPlayer.getString("cabal");
  638. if (playerCabal.equalsIgnoreCase("dawn"))
  639. return CABAL_DAWN;
  640. else if (playerCabal.equalsIgnoreCase("dusk"))
  641. return CABAL_DUSK;
  642. else
  643. return CABAL_NULL;
  644. }
  645. /**
  646. * Restores all Seven Signs data and settings, usually called at server startup.
  647. *
  648. * @throws Exception
  649. */
  650. protected void restoreSevenSignsData()
  651. {
  652. Connection con = null;
  653. PreparedStatement statement = null;
  654. ResultSet rset = null;
  655. try
  656. {
  657. con = L2DatabaseFactory.getInstance().getConnection();
  658. statement = con.prepareStatement(LOAD_DATA);
  659. rset = statement.executeQuery();
  660. StatsSet sevenDat = null;
  661. int charObjId;
  662. while (rset.next())
  663. {
  664. charObjId = rset.getInt("charId");
  665. sevenDat = new StatsSet();
  666. sevenDat.set("charId", charObjId);
  667. sevenDat.set("cabal", rset.getString("cabal"));
  668. sevenDat.set("seal", rset.getInt("seal"));
  669. sevenDat.set("red_stones", rset.getInt("red_stones"));
  670. sevenDat.set("green_stones", rset.getInt("green_stones"));
  671. sevenDat.set("blue_stones", rset.getInt("blue_stones"));
  672. sevenDat.set("ancient_adena_amount", rset.getDouble("ancient_adena_amount"));
  673. sevenDat.set("contribution_score", rset.getDouble("contribution_score"));
  674. if (Config.DEBUG)
  675. _log.info("SevenSigns: Loaded data from DB for char ID " + charObjId + " (" + sevenDat.getString("cabal") + ")");
  676. _signsPlayerData.put(charObjId, sevenDat);
  677. }
  678. rset.close();
  679. statement.close();
  680. statement = con.prepareStatement(LOAD_STATUS);
  681. rset = statement.executeQuery();
  682. while (rset.next())
  683. {
  684. _currentCycle = rset.getInt("current_cycle");
  685. _activePeriod = rset.getInt("active_period");
  686. _previousWinner = rset.getInt("previous_winner");
  687. _dawnStoneScore = rset.getDouble("dawn_stone_score");
  688. _dawnFestivalScore = rset.getInt("dawn_festival_score");
  689. _duskStoneScore = rset.getDouble("dusk_stone_score");
  690. _duskFestivalScore = rset.getInt("dusk_festival_score");
  691. _signsSealOwners.put(SEAL_AVARICE, rset.getInt("avarice_owner"));
  692. _signsSealOwners.put(SEAL_GNOSIS, rset.getInt("gnosis_owner"));
  693. _signsSealOwners.put(SEAL_STRIFE, rset.getInt("strife_owner"));
  694. _signsDawnSealTotals.put(SEAL_AVARICE, rset.getInt("avarice_dawn_score"));
  695. _signsDawnSealTotals.put(SEAL_GNOSIS, rset.getInt("gnosis_dawn_score"));
  696. _signsDawnSealTotals.put(SEAL_STRIFE, rset.getInt("strife_dawn_score"));
  697. _signsDuskSealTotals.put(SEAL_AVARICE, rset.getInt("avarice_dusk_score"));
  698. _signsDuskSealTotals.put(SEAL_GNOSIS, rset.getInt("gnosis_dusk_score"));
  699. _signsDuskSealTotals.put(SEAL_STRIFE, rset.getInt("strife_dusk_score"));
  700. _lastSave.setTimeInMillis(rset.getLong("date"));
  701. }
  702. statement.close();
  703. }
  704. catch (SQLException e)
  705. {
  706. _log.log(Level.SEVERE, "SevenSigns: Unable to load Seven Signs data from database: " + e.getMessage(), e);
  707. }
  708. finally
  709. {
  710. L2DatabaseFactory.close(con);
  711. }
  712. // Festival data is loaded now after the Seven Signs engine data.
  713. }
  714. /**
  715. * Saves all Seven Signs player data.
  716. * Should be called on period change and shutdown only.
  717. * <BR>
  718. *
  719. * @param player
  720. * @param updateSettings
  721. * @throws Exception
  722. */
  723. public void saveSevenSignsData()
  724. {
  725. Connection con = null;
  726. PreparedStatement statement = null;
  727. if (Config.DEBUG)
  728. _log.info("SevenSigns: Saving data to disk.");
  729. try
  730. {
  731. con = L2DatabaseFactory.getInstance().getConnection();
  732. statement = con.prepareStatement(UPDATE_PLAYER);
  733. for (StatsSet sevenDat : _signsPlayerData.values())
  734. {
  735. statement.setString(1, sevenDat.getString("cabal"));
  736. statement.setInt(2, sevenDat.getInteger("seal"));
  737. statement.setInt(3, sevenDat.getInteger("red_stones"));
  738. statement.setInt(4, sevenDat.getInteger("green_stones"));
  739. statement.setInt(5, sevenDat.getInteger("blue_stones"));
  740. statement.setDouble(6, sevenDat.getDouble("ancient_adena_amount"));
  741. statement.setDouble(7, sevenDat.getDouble("contribution_score"));
  742. statement.setInt(8, sevenDat.getInteger("charId"));
  743. statement.execute();
  744. if (Config.DEBUG)
  745. _log.info("SevenSigns: Updated data in database for char ID " + sevenDat.getInteger("charId") + " (" + sevenDat.getString("cabal") + ")");
  746. }
  747. statement.close();
  748. }
  749. catch (SQLException e)
  750. {
  751. _log.log(Level.SEVERE, "SevenSigns: Unable to save data to database: " + e.getMessage(), e);
  752. }
  753. finally
  754. {
  755. L2DatabaseFactory.close(con);
  756. }
  757. }
  758. public final void saveSevenSignsData(int objectId)
  759. {
  760. StatsSet sevenDat = _signsPlayerData.get(objectId);
  761. if (sevenDat == null)
  762. return;
  763. Connection con = null;
  764. PreparedStatement statement = null;
  765. try
  766. {
  767. con = L2DatabaseFactory.getInstance().getConnection();
  768. statement = con.prepareStatement(UPDATE_PLAYER);
  769. statement.setString(1, sevenDat.getString("cabal"));
  770. statement.setInt(2, sevenDat.getInteger("seal"));
  771. statement.setInt(3, sevenDat.getInteger("red_stones"));
  772. statement.setInt(4, sevenDat.getInteger("green_stones"));
  773. statement.setInt(5, sevenDat.getInteger("blue_stones"));
  774. statement.setDouble(6, sevenDat.getDouble("ancient_adena_amount"));
  775. statement.setDouble(7, sevenDat.getDouble("contribution_score"));
  776. statement.setInt(8, sevenDat.getInteger("charId"));
  777. statement.execute();
  778. statement.close();
  779. }
  780. catch (SQLException e)
  781. {
  782. _log.log(Level.SEVERE, "SevenSigns: Unable to save data to database: " + e.getMessage(), e);
  783. }
  784. finally
  785. {
  786. L2DatabaseFactory.close(con);
  787. }
  788. }
  789. public final void saveSevenSignsStatus()
  790. {
  791. Connection con = null;
  792. PreparedStatement statement = null;
  793. try
  794. {
  795. con = L2DatabaseFactory.getInstance().getConnection();
  796. statement = con.prepareStatement(UPDATE_STATUS);
  797. statement.setInt(1, _currentCycle);
  798. statement.setInt(2, _activePeriod);
  799. statement.setInt(3, _previousWinner);
  800. statement.setDouble(4, _dawnStoneScore);
  801. statement.setInt(5, _dawnFestivalScore);
  802. statement.setDouble(6, _duskStoneScore);
  803. statement.setInt(7, _duskFestivalScore);
  804. statement.setInt(8, _signsSealOwners.get(SEAL_AVARICE));
  805. statement.setInt(9, _signsSealOwners.get(SEAL_GNOSIS));
  806. statement.setInt(10, _signsSealOwners.get(SEAL_STRIFE));
  807. statement.setInt(11, _signsDawnSealTotals.get(SEAL_AVARICE));
  808. statement.setInt(12, _signsDawnSealTotals.get(SEAL_GNOSIS));
  809. statement.setInt(13, _signsDawnSealTotals.get(SEAL_STRIFE));
  810. statement.setInt(14, _signsDuskSealTotals.get(SEAL_AVARICE));
  811. statement.setInt(15, _signsDuskSealTotals.get(SEAL_GNOSIS));
  812. statement.setInt(16, _signsDuskSealTotals.get(SEAL_STRIFE));
  813. statement.setInt(17, SevenSignsFestival.getInstance().getCurrentFestivalCycle());
  814. for (int i = 0; i < SevenSignsFestival.FESTIVAL_COUNT; i++)
  815. statement.setInt(18 + i, SevenSignsFestival.getInstance().getAccumulatedBonus(i));
  816. _lastSave = Calendar.getInstance();
  817. statement.setLong(18 + SevenSignsFestival.FESTIVAL_COUNT, _lastSave.getTimeInMillis());
  818. statement.execute();
  819. statement.close();
  820. if (Config.DEBUG)
  821. _log.info("SevenSigns: Updated data in database.");
  822. }
  823. catch (SQLException e)
  824. {
  825. _log.log(Level.SEVERE, "SevenSigns: Unable to save data to database: " + e.getMessage(), e);
  826. }
  827. finally
  828. {
  829. L2DatabaseFactory.close(con);
  830. }
  831. }
  832. /**
  833. * Used to reset the cabal details of all players, and update the database.<BR>
  834. * Primarily used when beginning a new cycle, and should otherwise never be called.
  835. */
  836. protected void resetPlayerData()
  837. {
  838. if (Config.DEBUG)
  839. _log.info("SevenSigns: Resetting player data for new event period.");
  840. int charObjId;
  841. // Reset each player's contribution data as well as seal and cabal.
  842. for (StatsSet sevenDat : _signsPlayerData.values())
  843. {
  844. charObjId = sevenDat.getInteger("charId");
  845. // Reset the player's cabal and seal information
  846. sevenDat.set("cabal", "");
  847. sevenDat.set("seal", SEAL_NULL);
  848. sevenDat.set("contribution_score", 0);
  849. _signsPlayerData.put(charObjId, sevenDat);
  850. }
  851. }
  852. /**
  853. * Used to specify cabal-related details for the specified player. This method
  854. * checks to see if the player has registered before and will update the database
  855. * if necessary.
  856. * <BR>
  857. * Returns the cabal ID the player has joined.
  858. *
  859. * @param player
  860. * @param chosenCabal
  861. * @param chosenSeal
  862. * @return int cabal
  863. */
  864. public int setPlayerInfo(int objectId, int chosenCabal, int chosenSeal)
  865. {
  866. Connection con = null;
  867. PreparedStatement statement = null;
  868. StatsSet currPlayerData = _signsPlayerData.get(objectId);
  869. if (currPlayerData != null)
  870. {
  871. // If the seal validation period has passed,
  872. // cabal information was removed and so "re-register" player
  873. currPlayerData.set("cabal", getCabalShortName(chosenCabal));
  874. currPlayerData.set("seal", chosenSeal);
  875. _signsPlayerData.put(objectId, currPlayerData);
  876. }
  877. else
  878. {
  879. currPlayerData = new StatsSet();
  880. currPlayerData.set("charId", objectId);
  881. currPlayerData.set("cabal", getCabalShortName(chosenCabal));
  882. currPlayerData.set("seal", chosenSeal);
  883. currPlayerData.set("red_stones", 0);
  884. currPlayerData.set("green_stones", 0);
  885. currPlayerData.set("blue_stones", 0);
  886. currPlayerData.set("ancient_adena_amount", 0);
  887. currPlayerData.set("contribution_score", 0);
  888. _signsPlayerData.put(objectId, currPlayerData);
  889. // Update data in database, as we have a new player signing up.
  890. try
  891. {
  892. con = L2DatabaseFactory.getInstance().getConnection();
  893. statement = con.prepareStatement(INSERT_PLAYER);
  894. statement.setInt(1, objectId);
  895. statement.setString(2, getCabalShortName(chosenCabal));
  896. statement.setInt(3, chosenSeal);
  897. statement.execute();
  898. statement.close();
  899. if (Config.DEBUG)
  900. _log.info("SevenSigns: Inserted data in DB for char ID " + currPlayerData.getInteger("charId") + " ("
  901. + currPlayerData.getString("cabal") + ")");
  902. }
  903. catch (SQLException e)
  904. {
  905. _log.log(Level.SEVERE, "SevenSigns: Failed to save data: " + e.getMessage(), e);
  906. }
  907. finally
  908. {
  909. L2DatabaseFactory.close(con);
  910. }
  911. }
  912. // Increasing Seal total score for the player chosen Seal.
  913. if ("dawn".equals(currPlayerData.getString("cabal")))
  914. _signsDawnSealTotals.put(chosenSeal, _signsDawnSealTotals.get(chosenSeal) + 1);
  915. else
  916. _signsDuskSealTotals.put(chosenSeal, _signsDuskSealTotals.get(chosenSeal) + 1);
  917. if (!Config.ALT_SEVENSIGNS_LAZY_UPDATE)
  918. saveSevenSignsStatus();
  919. return chosenCabal;
  920. }
  921. /**
  922. * Returns the amount of ancient adena the specified player can claim, if any.<BR>
  923. * If removeReward = True, all the ancient adena owed to them is removed, then
  924. * DB is updated.
  925. *
  926. * @param player
  927. * @param removeReward
  928. * @return int rewardAmount
  929. */
  930. public int getAncientAdenaReward(int objectId, boolean removeReward)
  931. {
  932. StatsSet currPlayer = _signsPlayerData.get(objectId);
  933. int rewardAmount = currPlayer.getInteger("ancient_adena_amount");
  934. currPlayer.set("red_stones", 0);
  935. currPlayer.set("green_stones", 0);
  936. currPlayer.set("blue_stones", 0);
  937. currPlayer.set("ancient_adena_amount", 0);
  938. if (removeReward)
  939. {
  940. _signsPlayerData.put(objectId, currPlayer);
  941. if (!Config.ALT_SEVENSIGNS_LAZY_UPDATE)
  942. {
  943. saveSevenSignsData(objectId);
  944. saveSevenSignsStatus();
  945. }
  946. }
  947. return rewardAmount;
  948. }
  949. /**
  950. * Used to add the specified player's seal stone contribution points
  951. * to the current total for their cabal. Returns the point score the
  952. * contribution was worth.
  953. *
  954. * Each stone count <B>must be</B> broken down and specified by the stone's color.
  955. *
  956. * @param player
  957. * @param blueCount
  958. * @param greenCount
  959. * @param redCount
  960. * @return int contribScore
  961. */
  962. public long addPlayerStoneContrib(int objectId, long blueCount, long greenCount, long redCount)
  963. {
  964. StatsSet currPlayer = _signsPlayerData.get(objectId);
  965. long contribScore = calcContributionScore(blueCount, greenCount, redCount);
  966. long totalAncientAdena = currPlayer.getLong("ancient_adena_amount") + calcAncientAdenaReward(blueCount, greenCount, redCount);
  967. long totalContribScore = currPlayer.getLong("contribution_score") + contribScore;
  968. if (totalContribScore > Config.ALT_MAXIMUM_PLAYER_CONTRIB)
  969. return -1;
  970. currPlayer.set("red_stones", currPlayer.getInteger("red_stones") + redCount);
  971. currPlayer.set("green_stones", currPlayer.getInteger("green_stones") + greenCount);
  972. currPlayer.set("blue_stones", currPlayer.getInteger("blue_stones") + blueCount);
  973. currPlayer.set("ancient_adena_amount", totalAncientAdena);
  974. currPlayer.set("contribution_score", totalContribScore);
  975. _signsPlayerData.put(objectId, currPlayer);
  976. switch (getPlayerCabal(objectId))
  977. {
  978. case CABAL_DAWN:
  979. _dawnStoneScore += contribScore;
  980. break;
  981. case CABAL_DUSK:
  982. _duskStoneScore += contribScore;
  983. break;
  984. }
  985. if (!Config.ALT_SEVENSIGNS_LAZY_UPDATE)
  986. {
  987. saveSevenSignsData(objectId);
  988. saveSevenSignsStatus();
  989. }
  990. return contribScore;
  991. }
  992. /**
  993. * Adds the specified number of festival points to the specified cabal.
  994. * Remember, the same number of points are <B>deducted from the rival cabal</B>
  995. * to maintain proportionality.
  996. *
  997. * @param cabal
  998. * @param amount
  999. */
  1000. public void addFestivalScore(int cabal, int amount)
  1001. {
  1002. if (cabal == CABAL_DUSK)
  1003. {
  1004. _duskFestivalScore += amount;
  1005. // To prevent negative scores!
  1006. if (_dawnFestivalScore >= amount)
  1007. _dawnFestivalScore -= amount;
  1008. }
  1009. else
  1010. {
  1011. _dawnFestivalScore += amount;
  1012. if (_duskFestivalScore >= amount)
  1013. _duskFestivalScore -= amount;
  1014. }
  1015. }
  1016. /**
  1017. * Send info on the current Seven Signs period to the specified player.
  1018. *
  1019. * @param player
  1020. */
  1021. public void sendCurrentPeriodMsg(L2PcInstance player)
  1022. {
  1023. SystemMessage sm = null;
  1024. switch (getCurrentPeriod())
  1025. {
  1026. case PERIOD_COMP_RECRUITING:
  1027. sm = SystemMessage.getSystemMessage(SystemMessageId.PREPARATIONS_PERIOD_BEGUN);
  1028. break;
  1029. case PERIOD_COMPETITION:
  1030. sm = SystemMessage.getSystemMessage(SystemMessageId.COMPETITION_PERIOD_BEGUN);
  1031. break;
  1032. case PERIOD_COMP_RESULTS:
  1033. sm = SystemMessage.getSystemMessage(SystemMessageId.RESULTS_PERIOD_BEGUN);
  1034. break;
  1035. case PERIOD_SEAL_VALIDATION:
  1036. sm = SystemMessage.getSystemMessage(SystemMessageId.VALIDATION_PERIOD_BEGUN);
  1037. break;
  1038. }
  1039. player.sendPacket(sm);
  1040. }
  1041. /**
  1042. * Sends the built-in system message specified by sysMsgId to all online players.
  1043. *
  1044. * @param sysMsgId
  1045. */
  1046. public void sendMessageToAll(SystemMessageId sysMsgId)
  1047. {
  1048. SystemMessage sm = SystemMessage.getSystemMessage(sysMsgId);
  1049. Broadcast.toAllOnlinePlayers(sm);
  1050. }
  1051. /**
  1052. * Used to initialize the seals for each cabal. (Used at startup or at beginning of a new cycle).
  1053. * This method should be called after <B>resetSeals()</B> and <B>calcNewSealOwners()</B> on a new cycle.
  1054. */
  1055. protected void initializeSeals()
  1056. {
  1057. for (Integer currSeal : _signsSealOwners.keySet())
  1058. {
  1059. int sealOwner = _signsSealOwners.get(currSeal);
  1060. if (sealOwner != CABAL_NULL)
  1061. if (isSealValidationPeriod())
  1062. _log.info("SevenSigns: The " + getCabalName(sealOwner) + " have won the " + getSealName(currSeal, false) + ".");
  1063. else
  1064. _log.info("SevenSigns: The " + getSealName(currSeal, false) + " is currently owned by " + getCabalName(sealOwner) + ".");
  1065. else
  1066. _log.info("SevenSigns: The " + getSealName(currSeal, false) + " remains unclaimed.");
  1067. }
  1068. }
  1069. /**
  1070. * Only really used at the beginning of a new cycle, this method resets all seal-related data.
  1071. */
  1072. protected void resetSeals()
  1073. {
  1074. _signsDawnSealTotals.put(SEAL_AVARICE, 0);
  1075. _signsDawnSealTotals.put(SEAL_GNOSIS, 0);
  1076. _signsDawnSealTotals.put(SEAL_STRIFE, 0);
  1077. _signsDuskSealTotals.put(SEAL_AVARICE, 0);
  1078. _signsDuskSealTotals.put(SEAL_GNOSIS, 0);
  1079. _signsDuskSealTotals.put(SEAL_STRIFE, 0);
  1080. }
  1081. /**
  1082. * Calculates the ownership of the three Seals of the Seven Signs,
  1083. * based on various criterion.
  1084. * <BR><BR>
  1085. * Should only ever called at the beginning of a new cycle.
  1086. */
  1087. protected void calcNewSealOwners()
  1088. {
  1089. if (Config.DEBUG)
  1090. {
  1091. _log.info("SevenSigns: (Avarice) Dawn = " + _signsDawnSealTotals.get(SEAL_AVARICE) + ", Dusk = "
  1092. + _signsDuskSealTotals.get(SEAL_AVARICE));
  1093. _log.info("SevenSigns: (Gnosis) Dawn = " + _signsDawnSealTotals.get(SEAL_GNOSIS) + ", Dusk = "
  1094. + _signsDuskSealTotals.get(SEAL_GNOSIS));
  1095. _log.info("SevenSigns: (Strife) Dawn = " + _signsDawnSealTotals.get(SEAL_STRIFE) + ", Dusk = "
  1096. + _signsDuskSealTotals.get(SEAL_STRIFE));
  1097. }
  1098. for (Integer currSeal : _signsDawnSealTotals.keySet())
  1099. {
  1100. int prevSealOwner = _signsSealOwners.get(currSeal);
  1101. int newSealOwner = CABAL_NULL;
  1102. int dawnProportion = getSealProportion(currSeal, CABAL_DAWN);
  1103. int totalDawnMembers = getTotalMembers(CABAL_DAWN) == 0 ? 1 : getTotalMembers(CABAL_DAWN);
  1104. int dawnPercent = Math.round(((float) dawnProportion / (float) totalDawnMembers) * 100);
  1105. int duskProportion = getSealProportion(currSeal, CABAL_DUSK);
  1106. int totalDuskMembers = getTotalMembers(CABAL_DUSK) == 0 ? 1 : getTotalMembers(CABAL_DUSK);
  1107. int duskPercent = Math.round(((float) duskProportion / (float) totalDuskMembers) * 100);
  1108. /*
  1109. * - If a Seal was already closed or owned by the opponent and the new winner wants
  1110. * to assume ownership of the Seal, 35% or more of the members of the Cabal must
  1111. * have chosen the Seal. If they chose less than 35%, they cannot own the Seal.
  1112. *
  1113. * - If the Seal was owned by the winner in the previous Seven Signs, they can retain
  1114. * that seal if 10% or more members have chosen it. If they want to possess a new Seal,
  1115. * at least 35% of the members of the Cabal must have chosen the new Seal.
  1116. */
  1117. switch (prevSealOwner)
  1118. {
  1119. case CABAL_NULL:
  1120. switch (getCabalHighestScore())
  1121. {
  1122. case CABAL_NULL:
  1123. newSealOwner = CABAL_NULL;
  1124. break;
  1125. case CABAL_DAWN:
  1126. if (dawnPercent >= 35)
  1127. newSealOwner = CABAL_DAWN;
  1128. else
  1129. newSealOwner = CABAL_NULL;
  1130. break;
  1131. case CABAL_DUSK:
  1132. if (duskPercent >= 35)
  1133. newSealOwner = CABAL_DUSK;
  1134. else
  1135. newSealOwner = CABAL_NULL;
  1136. break;
  1137. }
  1138. break;
  1139. case CABAL_DAWN:
  1140. switch (getCabalHighestScore())
  1141. {
  1142. case CABAL_NULL:
  1143. if (dawnPercent >= 10)
  1144. newSealOwner = CABAL_DAWN;
  1145. else
  1146. newSealOwner = CABAL_NULL;
  1147. break;
  1148. case CABAL_DAWN:
  1149. if (dawnPercent >= 10)
  1150. newSealOwner = CABAL_DAWN;
  1151. else
  1152. newSealOwner = CABAL_NULL;
  1153. break;
  1154. case CABAL_DUSK:
  1155. if (duskPercent >= 35)
  1156. newSealOwner = CABAL_DUSK;
  1157. else if (dawnPercent >= 10)
  1158. newSealOwner = CABAL_DAWN;
  1159. else
  1160. newSealOwner = CABAL_NULL;
  1161. break;
  1162. }
  1163. break;
  1164. case CABAL_DUSK:
  1165. switch (getCabalHighestScore())
  1166. {
  1167. case CABAL_NULL:
  1168. if (duskPercent >= 10)
  1169. newSealOwner = CABAL_DUSK;
  1170. else
  1171. newSealOwner = CABAL_NULL;
  1172. break;
  1173. case CABAL_DAWN:
  1174. if (dawnPercent >= 35)
  1175. newSealOwner = CABAL_DAWN;
  1176. else if (duskPercent >= 10)
  1177. newSealOwner = CABAL_DUSK;
  1178. else
  1179. newSealOwner = CABAL_NULL;
  1180. break;
  1181. case CABAL_DUSK:
  1182. if (duskPercent >= 10)
  1183. newSealOwner = CABAL_DUSK;
  1184. else
  1185. newSealOwner = CABAL_NULL;
  1186. break;
  1187. }
  1188. break;
  1189. }
  1190. _signsSealOwners.put(currSeal, newSealOwner);
  1191. // Alert all online players to new seal status.
  1192. switch (currSeal)
  1193. {
  1194. case SEAL_AVARICE:
  1195. if (newSealOwner == CABAL_DAWN)
  1196. sendMessageToAll(SystemMessageId.DAWN_OBTAINED_AVARICE);
  1197. else if (newSealOwner == CABAL_DUSK)
  1198. sendMessageToAll(SystemMessageId.DUSK_OBTAINED_AVARICE);
  1199. break;
  1200. case SEAL_GNOSIS:
  1201. if (newSealOwner == CABAL_DAWN)
  1202. sendMessageToAll(SystemMessageId.DAWN_OBTAINED_GNOSIS);
  1203. else if (newSealOwner == CABAL_DUSK)
  1204. sendMessageToAll(SystemMessageId.DUSK_OBTAINED_GNOSIS);
  1205. break;
  1206. case SEAL_STRIFE:
  1207. if (newSealOwner == CABAL_DAWN)
  1208. sendMessageToAll(SystemMessageId.DAWN_OBTAINED_STRIFE);
  1209. else if (newSealOwner == CABAL_DUSK)
  1210. sendMessageToAll(SystemMessageId.DUSK_OBTAINED_STRIFE);
  1211. CastleManager.getInstance().validateTaxes(newSealOwner);
  1212. break;
  1213. }
  1214. }
  1215. }
  1216. /**
  1217. * This method is called to remove all players from catacombs and
  1218. * necropolises, who belong to the losing cabal.
  1219. * <BR><BR>
  1220. * Should only ever called at the beginning of Seal Validation.
  1221. */
  1222. protected void teleLosingCabalFromDungeons(String compWinner)
  1223. {
  1224. Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers().values();
  1225. //synchronized (L2World.getInstance().getAllPlayers())
  1226. {
  1227. StatsSet currPlayer;
  1228. for (L2PcInstance onlinePlayer : pls)
  1229. {
  1230. if (onlinePlayer == null)
  1231. continue;
  1232. currPlayer = _signsPlayerData.get(onlinePlayer.getObjectId());
  1233. if (isSealValidationPeriod() || isCompResultsPeriod())
  1234. {
  1235. if (!onlinePlayer.isGM() && onlinePlayer.isIn7sDungeon() && (currPlayer == null || !currPlayer.getString("cabal").equals(compWinner)))
  1236. {
  1237. onlinePlayer.teleToLocation(MapRegionTable.TeleportWhereType.Town);
  1238. onlinePlayer.setIsIn7sDungeon(false);
  1239. onlinePlayer.sendMessage("You have been teleported to the nearest town due to the beginning of the Seal Validation period.");
  1240. }
  1241. }
  1242. else
  1243. {
  1244. if (!onlinePlayer.isGM() && onlinePlayer.isIn7sDungeon() && (currPlayer == null || !currPlayer.getString("cabal").isEmpty()))
  1245. {
  1246. onlinePlayer.teleToLocation(MapRegionTable.TeleportWhereType.Town);
  1247. onlinePlayer.setIsIn7sDungeon(false);
  1248. onlinePlayer.sendMessage("You have been teleported to the nearest town because you have not signed for any cabal.");
  1249. }
  1250. }
  1251. }
  1252. }
  1253. }
  1254. /**
  1255. * The primary controller of period change of the Seven Signs system.
  1256. * This runs all related tasks depending on the period that is about to begin.
  1257. *
  1258. * @author Tempy
  1259. */
  1260. protected class SevenSignsPeriodChange implements Runnable
  1261. {
  1262. public void run()
  1263. {
  1264. /*
  1265. * Remember the period check here refers to the period just ENDED!
  1266. */
  1267. final int periodEnded = getCurrentPeriod();
  1268. _activePeriod++;
  1269. switch (periodEnded)
  1270. {
  1271. case PERIOD_COMP_RECRUITING: // Initialization
  1272. // Start the Festival of Darkness cycle.
  1273. SevenSignsFestival.getInstance().startFestivalManager();
  1274. // Send message that Competition has begun.
  1275. sendMessageToAll(SystemMessageId.QUEST_EVENT_PERIOD_BEGUN);
  1276. break;
  1277. case PERIOD_COMPETITION: // Results Calculation
  1278. // Send message that Competition has ended.
  1279. sendMessageToAll(SystemMessageId.QUEST_EVENT_PERIOD_ENDED);
  1280. int compWinner = getCabalHighestScore();
  1281. // Schedule a stop of the festival engine and reward highest ranking members from cycle
  1282. SevenSignsFestival.getInstance().getFestivalManagerSchedule().cancel(false);
  1283. SevenSignsFestival.getInstance().rewardHighestRanked();
  1284. calcNewSealOwners();
  1285. switch (compWinner)
  1286. {
  1287. case CABAL_DAWN:
  1288. sendMessageToAll(SystemMessageId.DAWN_WON);
  1289. break;
  1290. case CABAL_DUSK:
  1291. sendMessageToAll(SystemMessageId.DUSK_WON);
  1292. break;
  1293. }
  1294. _previousWinner = compWinner;
  1295. break;
  1296. case PERIOD_COMP_RESULTS: // Seal Validation
  1297. // Perform initial Seal Validation set up.
  1298. initializeSeals();
  1299. //Buff/Debuff members of the event when Seal of Strife captured.
  1300. giveCPMult(getSealOwner(SEAL_STRIFE));
  1301. // Send message that Seal Validation has begun.
  1302. sendMessageToAll(SystemMessageId.SEAL_VALIDATION_PERIOD_BEGUN);
  1303. // Change next Territory War date
  1304. Quest twQuest = QuestManager.getInstance().getQuest(TerritoryWarManager.qn);
  1305. if (twQuest != null)
  1306. twQuest.startQuestTimer("setNextTWDate", 30000, null, null);
  1307. _log.info("SevenSigns: The " + getCabalName(_previousWinner) + " have won the competition with " + getCurrentScore(_previousWinner) + " points!");
  1308. break;
  1309. case PERIOD_SEAL_VALIDATION: // Reset for New Cycle
  1310. // Ensure a cycle restart when this period ends.
  1311. _activePeriod = PERIOD_COMP_RECRUITING;
  1312. // Send message that Seal Validation has ended.
  1313. sendMessageToAll(SystemMessageId.SEAL_VALIDATION_PERIOD_ENDED);
  1314. //Clear Seal of Strife influence.
  1315. removeCPMult();
  1316. // Reset all data
  1317. resetPlayerData();
  1318. resetSeals();
  1319. _currentCycle++;
  1320. // Reset all Festival-related data and remove any unused blood offerings.
  1321. // NOTE: A full update of Festival data in the database is also performed.
  1322. SevenSignsFestival.getInstance().resetFestivalData(false);
  1323. _dawnStoneScore = 0;
  1324. _duskStoneScore = 0;
  1325. _dawnFestivalScore = 0;
  1326. _duskFestivalScore = 0;
  1327. break;
  1328. }
  1329. // Make sure all Seven Signs data is saved for future use.
  1330. saveSevenSignsData();
  1331. saveSevenSignsStatus();
  1332. teleLosingCabalFromDungeons(getCabalShortName(getCabalHighestScore()));
  1333. SSQInfo ss = new SSQInfo();
  1334. Broadcast.toAllOnlinePlayers(ss);
  1335. spawnSevenSignsNPC();
  1336. _log.info("SevenSigns: The " + getCurrentPeriodName() + " period has begun!");
  1337. setCalendarForNextPeriodChange();
  1338. // make sure that all the scheduled siege dates are in the Seal Validation period
  1339. List<Castle> castles = CastleManager.getInstance().getCastles();
  1340. for (Castle castle : castles)
  1341. {
  1342. castle.getSiege().correctSiegeDateTime();
  1343. }
  1344. SevenSignsPeriodChange sspc = new SevenSignsPeriodChange();
  1345. ThreadPoolManager.getInstance().scheduleGeneral(sspc, getMilliToPeriodChange());
  1346. }
  1347. }
  1348. public boolean checkIsDawnPostingTicket(int itemId)
  1349. {
  1350. //TODO I think it should be some kind of a list in the datapack for compare;
  1351. if (itemId > 6114 && itemId < 6175)
  1352. return true;
  1353. if (itemId > 6801 && itemId < 6812)
  1354. return true;
  1355. if (itemId > 7997 && itemId < 8008)
  1356. return true;
  1357. if (itemId > 7940 && itemId < 7951)
  1358. return true;
  1359. if (itemId > 6294 && itemId < 6307)
  1360. return true;
  1361. if (itemId > 6831 && itemId < 6834)
  1362. return true;
  1363. if (itemId > 8027 && itemId < 8030)
  1364. return true;
  1365. if (itemId > 7970 && itemId < 7973)
  1366. return true;
  1367. return false;
  1368. }
  1369. public boolean checkIsRookiePostingTicket(int itemId)
  1370. {
  1371. //TODO I think it should be some kind of a list in the datapack for compare;
  1372. if (itemId > 6174 && itemId < 6295)
  1373. return true;
  1374. if (itemId > 6811 && itemId < 6832)
  1375. return true;
  1376. if (itemId > 7950 && itemId < 7971)
  1377. return true;
  1378. if (itemId > 8007 && itemId < 8028)
  1379. return true;
  1380. return false;
  1381. }
  1382. public void giveCPMult(int StrifeOwner)
  1383. {
  1384. int cabal;
  1385. //Gives "Victor of War" passive skill to all online characters with Cabal, which controls Seal of Strife
  1386. for (L2PcInstance character : L2World.getInstance().getAllPlayers().values())
  1387. {
  1388. if (character == null)
  1389. continue;
  1390. cabal = getPlayerCabal(character.getObjectId());
  1391. if (cabal != SevenSigns.CABAL_NULL)
  1392. if (cabal == StrifeOwner)
  1393. character.addSkill(SkillTable.FrequentSkill.THE_VICTOR_OF_WAR.getSkill());
  1394. else
  1395. //Gives "The Vanquished of War" passive skill to all online characters with Cabal, which does not control Seal of Strife
  1396. character.addSkill(SkillTable.FrequentSkill.THE_VANQUISHED_OF_WAR.getSkill());
  1397. }
  1398. }
  1399. public void removeCPMult()
  1400. {
  1401. for (L2PcInstance character : L2World.getInstance().getAllPlayers().values())
  1402. {
  1403. if (character == null)
  1404. continue;
  1405. //Remove SevenSigns' buffs/debuffs.
  1406. character.removeSkill(SkillTable.FrequentSkill.THE_VICTOR_OF_WAR.getSkill());
  1407. character.removeSkill(SkillTable.FrequentSkill.THE_VANQUISHED_OF_WAR.getSkill());
  1408. }
  1409. }
  1410. public boolean checkSummonConditions(L2PcInstance activeChar)
  1411. {
  1412. if (activeChar == null)
  1413. return true;
  1414. //Golems cannot be summoned by Dusk when the Seal of Strife is controlled by the Dawn
  1415. if (isSealValidationPeriod())
  1416. if (getSealOwner(SEAL_STRIFE) == CABAL_DAWN)
  1417. if (getPlayerCabal(activeChar.getObjectId()) == CABAL_DUSK)
  1418. {
  1419. activeChar.sendMessage("You cannot summon Siege Golem or Cannon while Seal of Strife posessed by Lords of Dawn.");
  1420. return true;
  1421. }
  1422. return false;
  1423. }
  1424. @SuppressWarnings("synthetic-access")
  1425. private static class SingletonHolder
  1426. {
  1427. protected static final SevenSigns _instance = new SevenSigns();
  1428. }
  1429. }