SevenSigns.java 53 KB

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