Advertisement
Guest User

Untitled

a guest
Jun 1st, 2014
784
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 33.01 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P aCis_datapack
  3. Index: data/html/godmanagement/intro.htm
  4. ===================================================================
  5. --- data/html/godmanagement/intro.htm   (revision 0)
  6. +++ data/html/godmanagement/intro.htm   (revision 0)
  7. @@ -0,0 +1,37 @@
  8. +<html>
  9. +
  10. +<head>
  11. +<title>God Manager</title>
  12. +</head>
  13. +
  14. +<body>
  15. +
  16. +
  17. +<center>
  18. +<br>
  19. +<img src="l2ui.SquareWhite" width=275 height=3><br>
  20. +   Server's God at the moment: <font color="99ffcc">%godname%</font><br>
  21. +Next period remaining time: <font color="LEVEL">%remain%</font>   
  22. +   <img src="l2ui.SquareWhite" width=275 height=3>
  23. +<br><br>
  24. +   Hello <font color="LEVEL"> %charname% </font>, I am God Manager Npc<br>
  25. +   Choose any function you want:
  26. +   <br>
  27. +   <br>
  28. +   <button value="Vote player" action="bypass -h npc_%objectId%_voteForGod" width=75 height=21 back="L2UI_ch3.Btn1_normalOn" fore="L2UI_ch3.Btn1_normal">
  29. +   <br><img src="l2ui.SquareWhite" width=275 height=1><br>
  30. +   <img src="l2ui.SquareWhite" width=275 height=1><br>
  31. +   <br><button value="Ranking" action="bypass -h npc_%objectId%_showGodRanking" width=75 height=21 back="L2UI_ch3.Btn1_normalOn" fore="L2UI_ch3.Btn1_normal">
  32. +   <br>
  33. +   <img src="l2ui.SquareWhite" width=275 height=1><br>
  34. +   <img src="l2ui.SquareWhite" width=275 height=1><br>
  35. +<br>
  36. +   <button value="My Votes" action="bypass -h npc_%objectId%_showPersonalGodVotes" width=75 height=21 back="L2UI_ch3.Btn1_normalOn" fore="L2UI_ch3.Btn1_normal">
  37. +
  38. +</center>
  39. +
  40. +
  41. +
  42. +</body>
  43. +
  44. +</html>
  45. \ No newline at end of file
  46. Index: sql/characters.sql
  47. ===================================================================
  48. --- sql/characters.sql  (revision 1)
  49. +++ sql/characters.sql  (working copy)
  50. @@ -54,6 +54,9 @@
  51.   `clan_join_expiry_time` BIGINT UNSIGNED NOT NULL DEFAULT 0,
  52.   `clan_create_expiry_time` BIGINT UNSIGNED NOT NULL DEFAULT 0,
  53.   `death_penalty_level` SMALLINT UNSIGNED NOT NULL DEFAULT 0,
  54. +  `godvotes` SMALLINT UNSIGNED DEFAULT NULL,
  55. +  `godvoted` TINYINT UNSIGNED NOT NULL DEFAULT 0,
  56. +  `god` TINYINT UNSIGNED NOT NULL DEFAULT 0,
  57.   PRIMARY KEY (obj_Id),
  58.   KEY `clanid` (`clanid`)
  59. );
  60. \ No newline at end of file
  61. Index: data/html/godmanagement/vote.htm
  62. ===================================================================
  63. --- data/html/godmanagement/vote.htm    (revision 0)
  64. +++ data/html/godmanagement/vote.htm    (revision 0)
  65. @@ -0,0 +1,38 @@
  66. +<html>
  67. +
  68. +<head>
  69. +<title>God Manager</title>
  70. +</head>
  71. +
  72. +<body>
  73. +
  74. +
  75. +<center>
  76. +
  77. +   <br>
  78. +   <br>
  79. +   <br>
  80. +   <br>
  81. +   <br>
  82. +<img src="l2ui.SquareWhite" width=275 height=1><br>   
  83. +
  84. +   Put below player's name you want to vote
  85. +<img src="l2ui.SquareWhite" width=275 height=1><br>
  86. +<br>
  87. +<edit var="chaname" width=100>
  88. +<br>
  89. +<button value="Confirm" action="bypass -h npc_%objectId%_voteplayer $chaname" width=75 height=21 back="L2UI_ch3.Btn1_normalOn" fore="L2UI_ch3.Btn1_normal">
  90. +<br><br><br>
  91. +
  92. +   <font color="fc1818">Warning:<br>
  93. +
  94. + You can vote one time every period so vote carefully!
  95. +
  96. +</font>
  97. +  
  98. +
  99. +
  100. +</center>
  101. +</body>
  102. +
  103. +</html>
  104. \ No newline at end of file
  105. Index: data/html/godmanagement/personal.htm
  106. ===================================================================
  107. --- data/html/godmanagement/personal.htm    (revision 0)
  108. +++ data/html/godmanagement/personal.htm    (revision 0)
  109. @@ -0,0 +1,33 @@
  110. +<html>
  111. +
  112. +<head>
  113. +<title>God Manager</title>
  114. +</head>
  115. +
  116. +<body>
  117. +
  118. +
  119. +<center>
  120. +
  121. +   <br>
  122. +   <br>
  123. +   <br>
  124. +   <br>
  125. +  
  126. +<img src="l2ui.SquareWhite" width=275 height=1><br>
  127. +<img src="l2ui.SquareWhite" width=275 height=1><br>   
  128. +
  129. +   You have collected <font color="LEVEL"> %votes% </font>  votes.
  130. +<img src="l2ui.SquareWhite" width=275 height=1><br>
  131. +<img src="l2ui.SquareWhite" width=275 height=1><br>
  132. +
  133. +<br><br><br>
  134. +
  135. +           <font color="f100cc">Have fun</font>
  136. +  
  137. +</center>
  138. +
  139. +
  140. +</body>
  141. +
  142. +</html>
  143. \ No newline at end of file
  144. Index: data/xml/admin_commands_rights.xml
  145. ===================================================================
  146. --- data/xml/admin_commands_rights.xml  (revision 1)
  147. +++ data/xml/admin_commands_rights.xml  (working copy)
  148. @@ -14,7 +14,7 @@
  149.     <aCar name="admin_tradeoff" accessLevel="1" />
  150.     <aCar name="admin_reload" accessLevel="1" />
  151.     <aCar name="admin_script_load" accessLevel="1" />
  152. -
  153. +   <aCar name="admin_end_god" accessLevel="1" />
  154.     <!-- ANNOUNCEMENTS -->
  155.     <aCar name="admin_list_announcements" accessLevel="1" />
  156.     <aCar name="admin_reload_announcements" accessLevel="1" />
  157. Index: tools/database_installer.bat
  158. ===================================================================
  159. --- tools/database_installer.bat    (revision 1)
  160. +++ tools/database_installer.bat    (working copy)
  161. @@ -99,6 +99,7 @@
  162.  %mysqlPath% -h %gshost% -u %gsuser% --password=%gspass% -D %gsdb% < ../sql/olympiad_fights.sql
  163.  %mysqlPath% -h %gshost% -u %gsuser% --password=%gspass% -D %gsdb% < ../sql/olympiad_nobles_eom.sql
  164.  %mysqlPath% -h %gshost% -u %gsuser% --password=%gspass% -D %gsdb% < ../sql/olympiad_nobles.sql
  165. +%mysqlPath% -h %gshost% -u %gsuser% --password=%gspass% -D %gsdb% < ../sql/god_ips.sql
  166.  %mysqlPath% -h %gshost% -u %gsuser% --password=%gspass% -D %gsdb% < ../sql/pets.sql
  167.  %mysqlPath% -h %gshost% -u %gsuser% --password=%gspass% -D %gsdb% < ../sql/posts.sql
  168.  %mysqlPath% -h %gshost% -u %gsuser% --password=%gspass% -D %gsdb% < ../sql/server_variables.sql
  169. Index: data/xml/npcs/npcs.xml
  170. ===================================================================
  171. --- data/xml/npcs/npcs.xml  (revision 1)
  172. +++ data/xml/npcs/npcs.xml  (working copy)
  173. @@ -300199,4 +300199,40 @@
  174.             <skill id="4416" level="16"/>
  175.         </skills>
  176.     </npc>
  177. +    <npc id="10" idTemplate="31618" name="God Manager" title="[giolioy coding]">
  178. +       <set name="level" val="70"/>
  179. +       <set name="radius" val="8"/>
  180. +       <set name="height" val="23"/>
  181. +       <set name="rHand" val="316"/>
  182. +       <set name="lHand" val="0"/>
  183. +       <set name="type" val="L2GodManager"/>
  184. +       <set name="exp" val="0"/>
  185. +       <set name="sp" val="0"/>
  186. +       <set name="hp" val="2444.46819"/>
  187. +       <set name="mp" val="1345.8"/>
  188. +       <set name="hpRegen" val="7.5"/>
  189. +       <set name="mpRegen" val="2.7"/>
  190. +       <set name="pAtk" val="688.86373"/>
  191. +       <set name="pDef" val="295.91597"/>
  192. +       <set name="mAtk" val="470.40463"/>
  193. +       <set name="mDef" val="216.53847"/>
  194. +       <set name="crit" val="4"/>
  195. +       <set name="atkSpd" val="253"/>
  196. +       <set name="str" val="40"/>
  197. +       <set name="int" val="21"/>
  198. +       <set name="dex" val="30"/>
  199. +       <set name="wit" val="20"/>
  200. +       <set name="con" val="43"/>
  201. +       <set name="men" val="20"/>
  202. +       <set name="corpseTime" val="7"/>
  203. +       <set name="walkSpd" val="50"/>
  204. +       <set name="runSpd" val="120"/>
  205. +       <set name="dropHerbGroup" val="0"/>
  206. +       <set name="attackRange" val="40"/>
  207. +       <ai type="default" ssCount="0" ssRate="0" spsCount="0" spsRate="0" aggro="0" canMove="true" seedable="false"/>
  208. +       <skills>
  209. +           <skill id="4045" level="1"/>
  210. +           <skill id="4416" level="16"/>
  211. +       </skills>
  212. +   </npc>
  213.  </list>
  214. Index: sql/god_ips.sql
  215. ===================================================================
  216. --- sql/god_ips.sql (revision 0)
  217. +++ sql/god_ips.sql (revision 0)
  218. @@ -0,0 +1,4 @@
  219. +CREATE TABLE IF NOT EXISTS god_ips (
  220. +  `ip` VARCHAR(40) NOT NULL DEFAULT '',
  221. +  PRIMARY KEY  (ip)
  222. +);
  223. \ No newline at end of file
  224.  
  225. ### Eclipse Workspace Patch 1.0
  226. #P aCis_gameserver
  227. Index: java/net/sf/l2j/gameserver/model/actor/instance/L2GodManagerInstance.java
  228. ===================================================================
  229. --- java/net/sf/l2j/gameserver/model/actor/instance/L2GodManagerInstance.java   (revision 0)
  230. +++ java/net/sf/l2j/gameserver/model/actor/instance/L2GodManagerInstance.java   (revision 0)
  231. @@ -0,0 +1,105 @@
  232. +/*
  233. + * This program is free software: you can redistribute it and/or modify it under
  234. + * the terms of the GNU General Public License as published by the Free Software
  235. + * Foundation, either version 3 of the License, or (at your option) any later
  236. + * version.
  237. + *
  238. + * This program is distributed in the hope that it will be useful, but WITHOUT
  239. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  240. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  241. + * details.
  242. + *
  243. + * You should have received a copy of the GNU General Public License along with
  244. + * this program. If not, see <http://www.gnu.org/licenses/>.
  245. + */
  246. +package net.sf.l2j.gameserver.model.actor.instance;
  247. +
  248. +import java.util.StringTokenizer;
  249. +
  250. +import net.sf.l2j.gameserver.model.GodSystem;
  251. +import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
  252. +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  253. +import net.sf.l2j.gameserver.templates.chars.L2NpcTemplate;
  254. +
  255. +/**
  256. + * @author gio.lioy
  257. + *
  258. + */
  259. +public class L2GodManagerInstance extends L2NpcInstance
  260. +{
  261. +   public L2GodManagerInstance(int objectId, L2NpcTemplate template)
  262. +   {
  263. +       super(objectId, template);
  264. +   }
  265. +
  266. +
  267. +   @Override
  268. +   public void showChatWindow(L2PcInstance player)
  269. +   {
  270. +       player.sendPacket(ActionFailed.STATIC_PACKET);
  271. +  
  272. +       String filename = "data/html/godmanagement/intro.htm";
  273. +      
  274. +       // Send a Server->Client NpcHtmlMessage containing the text of the L2Npc to the L2PcInstance
  275. +       NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
  276. +       html.setFile(filename);
  277. +       html.replace("%charname%",player.getName());
  278. +       html.replace("%godname%", GodSystem.returnGodName());
  279. +       html.replace("%remain%",GodSystem.returnRemainingTime());
  280. +       html.replace("%objectId%", String.valueOf(getObjectId()));
  281. +       player.sendPacket(html);
  282. +   }
  283. +  
  284. +   @Override
  285. +   public void onBypassFeedback(L2PcInstance player, String command)
  286. +   {
  287. +       if(command.startsWith("voteForGod"))
  288. +       {
  289. +           String filename = "data/html/godmanagement/vote.htm";
  290. +           NpcHtmlMessage html = new NpcHtmlMessage(0);
  291. +           html.setFile(filename);
  292. +           html.replace("%objectId%", String.valueOf(getObjectId()));
  293. +           player.sendPacket(html);
  294. +       }
  295. +       else if(command.startsWith("showGodRanking"))
  296. +       {
  297. +           GodSystem.showGodRanking(player);
  298. +       }
  299. +       else if(command.startsWith("showPersonalGodVotes"))
  300. +       {
  301. +           GodSystem.showPersonalGodVotes(player);
  302. +       }
  303. +       else if(command.startsWith("voteplayer"))
  304. +       {
  305. +          
  306. +           if(player.isGodVoted())
  307. +           {
  308. +               player.sendMessage("You have already voted , we are sorry!");
  309. +               return;
  310. +           }
  311. +          
  312. +           String charName = null;
  313. +          
  314. +           try
  315. +           {
  316. +             StringTokenizer stringTokenizer = new StringTokenizer(command);
  317. +              stringTokenizer.nextToken();
  318. +              charName = stringTokenizer.nextToken();
  319. +           }
  320. +           catch(Exception e)
  321. +           {
  322. +               return;
  323. +           }
  324. +            
  325. +              if(charName == null)
  326. +              {
  327. +                 player.sendMessage("Wrong name");
  328. +                 return;
  329. +              }
  330. +              
  331. +              GodSystem.vote(player, charName);
  332. +       }
  333. +   }
  334. +  
  335. +  
  336. +}
  337. Index: java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminGod.java
  338. ===================================================================
  339. --- java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminGod.java   (revision 0)
  340. +++ java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminGod.java   (revision 0)
  341. @@ -0,0 +1,51 @@
  342. +/*
  343. + * This program is free software: you can redistribute it and/or modify it under
  344. + * the terms of the GNU General Public License as published by the Free Software
  345. + * Foundation, either version 3 of the License, or (at your option) any later
  346. + * version.
  347. + *
  348. + * This program is distributed in the hope that it will be useful, but WITHOUT
  349. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  350. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  351. + * details.
  352. + *
  353. + * You should have received a copy of the GNU General Public License along with
  354. + * this program. If not, see <http://www.gnu.org/licenses/>.
  355. + */
  356. +package net.sf.l2j.gameserver.handler.admincommandhandlers;
  357. +
  358. +import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
  359. +import net.sf.l2j.gameserver.model.GodSystem;
  360. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  361. +import net.sf.l2j.gameserver.util.Broadcast;
  362. +
  363. +/**
  364. + * @author gio.lioy
  365. + *
  366. + */
  367. +public class AdminGod implements IAdminCommandHandler
  368. +{
  369. +   private static final String[] ADMIN_COMMANDS =
  370. +   {
  371. +       "admin_end_god"
  372. +   };
  373. +  
  374. +   @Override
  375. +   public boolean useAdminCommand(String command, L2PcInstance activeChar)
  376. +   {
  377. +       if(command.equals("admin_end_god"))
  378. +       {
  379. +           Broadcast.announceToOnlinePlayers("Admin "+activeChar.getName()+" ended God Period!");
  380. +           GodSystem.deleteAndUpdate();
  381. +       }
  382. +      
  383. +       return true;
  384. +   }
  385. +
  386. +   @Override
  387. +   public String[] getAdminCommandList()
  388. +   {
  389. +       return ADMIN_COMMANDS;
  390. +   }
  391. +  
  392. +}
  393. Index: java/net/sf/l2j/gameserver/GameServer.java
  394. ===================================================================
  395. --- java/net/sf/l2j/gameserver/GameServer.java  (revision 1)
  396. +++ java/net/sf/l2j/gameserver/GameServer.java  (working copy)
  397. @@ -85,6 +85,7 @@
  398.  import net.sf.l2j.gameserver.instancemanager.SiegeManager;
  399.  import net.sf.l2j.gameserver.instancemanager.ZoneManager;
  400.  import net.sf.l2j.gameserver.model.AutoSpawnHandler;
  401. +import net.sf.l2j.gameserver.model.GodSystem;
  402.  import net.sf.l2j.gameserver.model.L2Manor;
  403.  import net.sf.l2j.gameserver.model.L2Multisell;
  404.  import net.sf.l2j.gameserver.model.L2World;
  405. @@ -243,6 +244,7 @@
  406.         Util.printSection("Quests & Scripts");
  407.         QuestManager.getInstance();
  408.         BoatManager.getInstance();
  409. +       GodSystem.getInstance();
  410.        
  411.         if (!Config.ALT_DEV_NO_SCRIPTS)
  412.         {
  413. Index: java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java
  414. ===================================================================
  415. --- java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java (revision 1)
  416. +++ java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java (working copy)
  417. @@ -39,6 +39,7 @@
  418.  import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminGeodata;
  419.  import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminGm;
  420.  import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminGmChat;
  421. +import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminGod;
  422.  import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminHeal;
  423.  import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminHelpPage;
  424.  import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminInvul;
  425. @@ -92,6 +93,7 @@
  426.         registerAdminCommandHandler(new AdminCreateItem());
  427.         registerAdminCommandHandler(new AdminCursedWeapons());
  428.         registerAdminCommandHandler(new AdminDelete());
  429. +       registerAdminCommandHandler(new AdminGod());
  430.         registerAdminCommandHandler(new AdminDoorControl());
  431.         registerAdminCommandHandler(new AdminEditChar());
  432.         registerAdminCommandHandler(new AdminEditNpc());
  433. Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
  434. ===================================================================
  435. --- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java   (revision 1)
  436. +++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java   (working copy)
  437. @@ -260,9 +260,9 @@
  438.     private static final String DELETE_SKILL_SAVE = "DELETE FROM character_skills_save WHERE char_obj_id=? AND class_index=?";
  439.    
  440.     // Character SQL String Definitions:
  441. -   private static final String INSERT_CHARACTER = "INSERT INTO characters (account_name,obj_Id,char_name,level,maxHp,curHp,maxCp,curCp,maxMp,curMp,face,hairStyle,hairColor,sex,exp,sp,karma,pvpkills,pkkills,clanid,race,classid,deletetime,cancraft,title,accesslevel,online,isin7sdungeon,clan_privs,wantspeace,base_class,nobless,power_grade,last_recom_date) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
  442. -   private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,face=?,hairStyle=?,hairColor=?,sex=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,pvpkills=?,pkkills=?,rec_have=?,rec_left=?,clanid=?,race=?,classid=?,deletetime=?,title=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,punish_level=?,punish_timer=?,nobless=?,power_grade=?,subpledge=?,last_recom_date=?,lvl_joined_academy=?,apprentice=?,sponsor=?,varka_ketra_ally=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=? WHERE obj_id=?";
  443. -   private static final String RESTORE_CHARACTER = "SELECT account_name, obj_Id, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, face, hairStyle, hairColor, sex, heading, x, y, z, exp, expBeforeDeath, sp, karma, pvpkills, pkkills, clanid, race, classid, deletetime, cancraft, title, rec_have, rec_left, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon, punish_level, punish_timer, nobless, power_grade, subpledge, last_recom_date, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally,clan_join_expiry_time,clan_create_expiry_time,death_penalty_level FROM characters WHERE obj_id=?";
  444. +   private static final String INSERT_CHARACTER = "INSERT INTO characters (account_name,obj_Id,char_name,level,maxHp,curHp,maxCp,curCp,maxMp,curMp,face,hairStyle,hairColor,sex,exp,sp,karma,pvpkills,pkkills,clanid,race,classid,deletetime,cancraft,title,accesslevel,online,isin7sdungeon,clan_privs,wantspeace,base_class,nobless,power_grade,last_recom_date,godvotes,godvoted,god) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
  445. +   private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,face=?,hairStyle=?,hairColor=?,sex=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,pvpkills=?,pkkills=?,rec_have=?,rec_left=?,clanid=?,race=?,classid=?,deletetime=?,title=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,punish_level=?,punish_timer=?,nobless=?,power_grade=?,subpledge=?,last_recom_date=?,lvl_joined_academy=?,apprentice=?,sponsor=?,varka_ketra_ally=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=?,godvotes=?,godvoted=?,god=? WHERE obj_id=?";
  446. +   private static final String RESTORE_CHARACTER = "SELECT account_name, obj_Id, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, face, hairStyle, hairColor, sex, heading, x, y, z, exp, expBeforeDeath, sp, karma, pvpkills, pkkills, clanid, race, classid, deletetime, cancraft, title, rec_have, rec_left, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon, punish_level, punish_timer, nobless, power_grade, subpledge, last_recom_date, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally,clan_join_expiry_time,clan_create_expiry_time,death_penalty_level,godvotes,godvoted,god FROM characters WHERE obj_id=?";
  447.    
  448.     // Character Subclass SQL String Definitions:
  449.     private static final String RESTORE_CHAR_SUBCLASSES = "SELECT class_id,exp,sp,level,class_index FROM character_subclasses WHERE char_obj_id=? ORDER BY class_index ASC";
  450. @@ -282,6 +282,8 @@
  451.    
  452.     private static final String UPDATE_NOBLESS = "UPDATE characters SET nobless=? WHERE obj_Id=?";
  453.    
  454. +  
  455. +  
  456.     public static final int REQUEST_TIMEOUT = 15;
  457.     public static final int STORE_PRIVATE_NONE = 0;
  458.     public static final int STORE_PRIVATE_SELL = 1;
  459. @@ -393,6 +395,10 @@
  460.     private byte _siegeState = 0;
  461.     private int _curWeightPenalty = 0;
  462.    
  463. +   private int _godvotes;
  464. +   private boolean _godvoted;
  465. +   private boolean _god;
  466. +  
  467.     private int _lastCompassZone; // the last compass zone update send to the client
  468.    
  469.     private boolean _isInWater;
  470. @@ -1902,6 +1908,74 @@
  471.             sendPacket(new ExStorageMaxCount(this));
  472.     }
  473.    
  474. +   public void votePlayer(L2PcInstance target)
  475. +   {
  476. +       target.setGodVotes(target.getGodVotes() + 1);
  477. +       setGodVoted(true);
  478. +   }
  479. +  
  480. +   /**
  481. +    * @return votes for god status of the L2PcInstance
  482. +    */
  483. +  
  484. +   public int getGodVotes()
  485. +   {
  486. +       return _godvotes;
  487. +   }
  488. +  
  489. +   /**
  490. +    * @param votes of the L2PcInstance for god status
  491. +    */
  492. +   public void setGodVotes(int votes)
  493. +   {
  494. +       _godvotes = votes;
  495. +      
  496. +       try (Connection con = L2DatabaseFactory.getInstance().getConnection())
  497. +       {
  498. +           PreparedStatement statement = con.prepareStatement("UPDATE characters SET godvotes=? WHERE obj_Id=?");
  499. +           statement.setInt(1, _godvotes);
  500. +           statement.setInt(2, getObjectId());
  501. +           statement.executeUpdate();
  502. +           statement.close();
  503. +       }
  504. +       catch (Exception e)
  505. +       {
  506. +           _log.log(Level.WARNING, "Could not update " + getName() + " god votes " + e.getMessage(), e);
  507. +       }
  508. +   }
  509. +  
  510. +   /**
  511. +    * @return if player has already voted
  512. +    */
  513. +   public boolean isGodVoted()
  514. +   {
  515. +       return _godvoted;
  516. +   }
  517. +  
  518. +   /**
  519. +    * @param voted value of L2PcInstance if he voted or no
  520. +    */
  521. +   public void setGodVoted(boolean voted)
  522. +   {
  523. +       _godvoted = voted;
  524. +   }
  525. +  
  526. +   /**
  527. +    * @return if L2PcInstance is  God
  528. +    */
  529. +   public boolean isGod()
  530. +   {
  531. +       return _god;
  532. +   }
  533. +  
  534. +   /**
  535. +    * @param god set L2PcInstance god status
  536. +    */
  537. +   public void setGod(boolean god)
  538. +   {
  539. +       _god = god;
  540. +   }
  541. +  
  542.     /**
  543.      * @return PvP Kills of the L2PcInstance (number of player killed during a PvP).
  544.      */
  545. @@ -5523,6 +5597,9 @@
  546.             statement.setInt(32, isNoble() ? 1 : 0);
  547.             statement.setLong(33, 0);
  548.             statement.setLong(34, System.currentTimeMillis());
  549. +           statement.setLong(35, getGodVotes());
  550. +           statement.setInt(36, isGodVoted() ? 1 : 0);
  551. +           statement.setInt(37, isGod() ? 1 : 0);
  552.             statement.executeUpdate();
  553.             statement.close();
  554.         }
  555. @@ -5670,6 +5747,9 @@
  556.                
  557.                 player.setDeathPenaltyBuffLevel(rset.getInt("death_penalty_level"));
  558.                
  559. +               player.setGodVotes(rset.getInt("godvotes"));
  560. +               player.setGodVoted(rset.getInt("godvoted") == 1);
  561. +               player.setGod(rset.getInt("god") == 1);
  562.                 // Set the x,y,z position of the L2PcInstance and make it invisible
  563.                 player.setXYZInvisible(rset.getInt("x"), rset.getInt("y"), rset.getInt("z"));
  564.                
  565. @@ -6017,7 +6097,11 @@
  566.             statement.setLong(47, getClanCreateExpiryTime());
  567.             statement.setString(48, getName());
  568.             statement.setLong(49, getDeathPenaltyBuffLevel());
  569. -           statement.setInt(50, getObjectId());
  570. +           statement.setInt(50, getGodVotes());
  571. +           statement.setInt(51, isGodVoted() ? 1 : 0);
  572. +           statement.setInt(52, isGod() ? 1 : 0);
  573. +           statement.setInt(53, getObjectId());
  574. +          
  575.            
  576.             statement.execute();
  577.             statement.close();
  578. Index: java/net/sf/l2j/gameserver/model/GodSystem.java
  579. ===================================================================
  580. --- java/net/sf/l2j/gameserver/model/GodSystem.java (revision 0)
  581. +++ java/net/sf/l2j/gameserver/model/GodSystem.java (revision 0)
  582. @@ -0,0 +1,396 @@
  583. +/*
  584. + * This program is free software: you can redistribute it and/or modify it under
  585. + * the terms of the GNU General Public License as published by the Free Software
  586. + * Foundation, either version 3 of the License, or (at your option) any later
  587. + * version.
  588. + *
  589. + * This program is distributed in the hope that it will be useful, but WITHOUT
  590. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  591. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  592. + * details.
  593. + *
  594. + * You should have received a copy of the GNU General Public License along with
  595. + * this program. If not, see <http://www.gnu.org/licenses/>.
  596. + */
  597. +package net.sf.l2j.gameserver.model;
  598. +
  599. +import java.util.concurrent.CopyOnWriteArrayList;
  600. +import java.util.concurrent.TimeUnit;
  601. +import java.util.logging.Logger;
  602. +import java.sql.Connection;
  603. +import java.sql.PreparedStatement;
  604. +import java.sql.ResultSet;
  605. +import java.util.Calendar;
  606. +import java.util.LinkedHashMap;
  607. +import java.util.List;
  608. +import java.util.Map;
  609. +
  610. +import net.sf.l2j.L2DatabaseFactory;
  611. +import net.sf.l2j.gameserver.ThreadPoolManager;
  612. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  613. +import net.sf.l2j.gameserver.network.clientpackets.Say2;
  614. +import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
  615. +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  616. +import net.sf.l2j.gameserver.util.Broadcast;
  617. +
  618. +/**
  619. + * @author gio.lioy
  620. + *
  621. + */
  622. +public class GodSystem
  623. +{
  624. +  
  625. +   private static final  Map<String,Integer> godMap = new LinkedHashMap<>();
  626. +   private static final List<String> ips = new CopyOnWriteArrayList<>();
  627. +   private static final Logger _log = Logger.getLogger(GodSystem.class.getName());
  628. +   private static int started = 0;
  629. +   private static String GOD_NAME;
  630. +  
  631. +   public static String returnRemainingTime()
  632. +   {
  633. +           long millis =getTimeForNewStart();
  634. +          
  635. +           String hms = String.format("%02d:%02d:%02d", TimeUnit.MILLISECONDS.toHours(millis),
  636. +           TimeUnit.MILLISECONDS.toMinutes(millis) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(millis)),
  637. +           TimeUnit.MILLISECONDS.toSeconds(millis) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis)));
  638. +          
  639. +           return hms;
  640. +   }
  641. +  
  642. +   public static String returnGodName()
  643. +   {
  644. +       return GOD_NAME;
  645. +   }
  646. +  
  647. +   public static void deleteAndUpdate()
  648. +   {
  649. +      
  650. +      
  651. +       try(Connection con = L2DatabaseFactory.getInstance().getConnection())
  652. +       {
  653. +           PreparedStatement st = con.prepareStatement("SELECT obj_Id,godvotes FROM characters WHERE godvotes>0 ORDER BY godvotes DESC LIMIT 1");
  654. +           ResultSet rset = st.executeQuery();
  655. +          
  656. +           //store the new GOD infos
  657. +           int objectId = 0;
  658. +           int godVotes = 0;
  659. +          
  660. +           while(rset.next())
  661. +           {
  662. +               objectId = rset.getInt("obj_Id");
  663. +               godVotes = rset.getInt("godvotes");
  664. +           }
  665. +          
  666. +           Broadcast.announceToOnlinePlayers("God System initialized! New period started!");
  667. +          
  668. +          
  669. +           started = 0;
  670. +           GOD_NAME = "None";
  671. +          
  672. +           if(objectId == 0)
  673. +           {
  674. +               Broadcast.announceToOnlinePlayers("New GOD wasn't found, GOD remains the same player");
  675. +               return;
  676. +           }
  677. +          
  678. +           //delete old
  679. +           cleanGodSystem();
  680. +          
  681. +          
  682. +           //release new
  683. +          
  684. +
  685. +           L2PcInstance player = L2World.getInstance().getPlayer(objectId);
  686. +           if(player != null)
  687. +           {
  688. +               player.setGod(true);
  689. +               player.sendPacket(new CreatureSay(0,Say2.SHOUT,"God Manager","You are the new God! Congratulations!!!"));
  690. +               Broadcast.announceToOnlinePlayers("New God of server is "+player.getName()+" with "+godVotes+" votes!");
  691. +  
  692. +               ips.clear();
  693. +           }
  694. +           else
  695. +           {
  696. +               st = con.prepareStatement("UPDATE characters SET god=1 WHERE obj_Id=?");
  697. +               st.setInt(1, objectId);
  698. +               st.executeUpdate();
  699. +              
  700. +               st = con.prepareStatement("SELECT char_name FROM characters WHERE god=1");
  701. +               rset = st.executeQuery();
  702. +              
  703. +               String name = "";
  704. +               while(rset.next())
  705. +                   name = rset.getString("char_name");
  706. +              
  707. +               Broadcast.announceToOnlinePlayers("New God of server is "+name+" with "+godVotes+" votes!");
  708. +              
  709. +               st = con.prepareStatement("DELETE FROM god_ips");
  710. +               st.executeUpdate();
  711. +              
  712. +               st.close();
  713. +              
  714. +              
  715. +           }
  716. +          
  717. +          
  718. +              
  719. +          
  720. +       }
  721. +       catch(Exception e)
  722. +       {
  723. +           _log.warning("Problem to delete/update new God: "+e.getMessage());
  724. +       }
  725. +   }
  726. +  
  727. +   protected static long getTimeForNewStart()
  728. +   {
  729. +       Calendar cal = Calendar.getInstance();
  730. +       cal.set(Calendar.DAY_OF_WEEK,Calendar.SUNDAY);
  731. +       cal.add(Calendar.WEEK_OF_MONTH, 1);
  732. +       cal.set(Calendar.HOUR,00);
  733. +       cal.set(Calendar.MINUTE,0);
  734. +       cal.set(Calendar.SECOND,1);
  735. +      
  736. +       long time = ( (cal.getTimeInMillis() -System.currentTimeMillis()));
  737. +      
  738. +      
  739. +       return time;
  740. +   }
  741. +  
  742. +   protected static void cleanGodSystem()
  743. +   {
  744. +       for(L2PcInstance player : L2World.getInstance().getAllPlayers().values())
  745. +           if(player != null)
  746. +           {
  747. +               player.setGodVotes(0);
  748. +               player.setGod(false);
  749. +               player.setGodVoted(false);
  750. +           }
  751. +      
  752. +       try(Connection con = L2DatabaseFactory.getInstance().getConnection())
  753. +       {
  754. +           PreparedStatement st = con.prepareStatement("UPDATE characters SET godvotes=0,godvoted=0,god=0");
  755. +           st.executeUpdate();
  756. +           st.close();
  757. +       }
  758. +       catch(Exception e)
  759. +       {
  760. +           _log.warning("Error ar clean gold System "+e.getMessage());
  761. +       }
  762. +   }
  763. +  
  764. +   public static void vote(L2PcInstance player, String playerToVote)
  765. +   {
  766. +       L2PcInstance playerVote = L2World.getInstance().getPlayer(playerToVote);
  767. +      
  768. +       if(player.getName().equals(playerToVote))
  769. +       {
  770. +           player.sendMessage("You cannot vote yourself, we are sorry!");
  771. +           return;
  772. +       }
  773. +       if(ips.contains(player.getClient().getConnection().getInetAddress().getHostAddress()))
  774. +       {
  775. +           player.sendMessage("You have already voted from this IP , we are sorry!");
  776. +           return;
  777. +       }
  778. +       boolean voted = false;
  779. +       if(playerVote != null)
  780. +       {
  781. +           player.votePlayer(playerVote);
  782. +           playerVote.sendMessage("You received one vote for God Player, congratulations!");
  783. +           player.sendPacket(new CreatureSay(0,Say2.SHOUT,"God Manager","You voted successfully for "+playerToVote+", thank you!"));
  784. +           voted = true;
  785. +       }
  786. +       else
  787. +       {
  788. +           try(Connection con = L2DatabaseFactory.getInstance().getConnection())
  789. +           {
  790. +               PreparedStatement st = con.prepareStatement("SELECT count(*) FROM characters WHERE UPPER(char_name)=UPPER(?)");
  791. +               st.setString(1, playerToVote);
  792. +               ResultSet rset = st.executeQuery();
  793. +              
  794. +               int count = 0 ;
  795. +              
  796. +               while(rset.next())
  797. +                   count = rset.getInt(1);
  798. +              
  799. +               if(count == 0)
  800. +               {
  801. +                   player.sendMessage("Incorrect name , we are sorry!");
  802. +                   return;
  803. +               }
  804. +              
  805. +               st = con.prepareStatement("UPDATE characters SET godvotes=godvotes+1 WHERE char_name=?");
  806. +               st.setString(1, playerToVote);
  807. +               st.executeUpdate();
  808. +              
  809. +               player.setGodVoted(true);
  810. +               player.sendPacket(new CreatureSay(0,Say2.SHOUT,"God Manager","You voted successfully for "+playerToVote+", thank you!"));
  811. +               voted = true;
  812. +               rset.close();
  813. +               st.close();
  814. +              
  815. +           }
  816. +           catch(Exception e)
  817. +           {
  818. +               _log.warning("Failed to vote : "+e.getMessage());
  819. +           }
  820. +       }
  821. +      
  822. +       if(voted)
  823. +       {
  824. +           String ip =  player.getClient().getConnection().getInetAddress().getHostAddress();
  825. +          
  826. +           try(Connection con = L2DatabaseFactory.getInstance().getConnection())
  827. +           {
  828. +               PreparedStatement st = con.prepareStatement("INSERT INTO god_ips VALUES (?)");
  829. +               st.setString(1, ip);
  830. +               st.executeUpdate();
  831. +               st.close();
  832. +           }
  833. +           catch(Exception e)
  834. +           {
  835. +               _log.warning(e.getMessage());
  836. +           }
  837. +       }
  838. +      
  839. +   }
  840. +  
  841. +   public static void showPersonalGodVotes(L2PcInstance player)
  842. +   {
  843. +       String filename = "data/html/godmanagement/personal.htm";
  844. +       NpcHtmlMessage html = new NpcHtmlMessage(0);
  845. +       html.setFile(filename);
  846. +       html.replace("%votes%", String.valueOf(player.getGodVotes()));
  847. +       player.sendPacket(html);
  848. +   }
  849. +  
  850. +   public static void showGodRanking(L2PcInstance player)
  851. +   {
  852. +       StringBuilder sb = new StringBuilder("<html><head>");
  853. +       sb.append("<title>God Manager</title></head>");
  854. +       sb.append("<body><center>");
  855. +       sb.append("<br><br>");
  856. +       sb.append("<table width=210 border=1");
  857. +       int counter = 1;
  858. +      
  859. +       sb.append("<tr>");
  860. +      
  861. +       sb.append("<td><font color=\"LEVEL\">Rank</font></td>");
  862. +       sb.append("<td><font color=\"LEVEL\">Name</font></td>");
  863. +       sb.append("<td><font color=\"LEVEL\">Votes</font></td>");
  864. +      
  865. +       sb.append("</tr>");
  866. +       for(String charname : godMap.keySet())
  867. +       {
  868. +           sb.append("<tr>");
  869. +          
  870. +           sb.append("<td>"+counter+"</td>");
  871. +           sb.append("<td>"+charname+"</td>");
  872. +           sb.append("<td>"+godMap.get(charname)+"</td>");
  873. +          
  874. +           sb.append("</tr>");
  875. +          
  876. +           counter++;
  877. +       }
  878. +      
  879. +       sb.append("</table>");
  880. +       sb.append("</center></body></html>");
  881. +      
  882. +       NpcHtmlMessage nhm = new NpcHtmlMessage(0);
  883. +       nhm.setHtml(sb.toString());
  884. +       player.sendPacket(nhm);
  885. +   }
  886. +  
  887. +   protected GodSystem()
  888. +   {
  889. +       ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new Runnable()
  890. +       {
  891. +           @Override
  892. +           public void run()
  893. +           {
  894. +               init();
  895. +           }
  896. +          
  897. +       }, 0, 30000);
  898. +      
  899. +       ThreadPoolManager.getInstance().scheduleGeneral(new NewStart(), getTimeForNewStart());
  900. +          
  901. +   }
  902. +  
  903. +   protected class NewStart implements Runnable
  904. +   {
  905. +      
  906. +       @Override
  907. +       public void run()
  908. +       {
  909. +          
  910. +           deleteAndUpdate();
  911. +           ThreadPoolManager.getInstance().scheduleGeneral(new NewStart(), getTimeForNewStart());
  912. +          
  913. +       }
  914. +      
  915. +   }
  916. +  
  917. +   protected void init()
  918. +   {
  919. +       godMap.clear();
  920. +      
  921. +      
  922. +       try(Connection con = L2DatabaseFactory.getInstance().getConnection())
  923. +       {
  924. +           PreparedStatement st = con.prepareStatement("SELECT godvotes,char_name FROM characters WHERE godvotes>0 ORDER BY godvotes desc");
  925. +           ResultSet rset = st.executeQuery();
  926. +          
  927. +           while(rset.next())
  928. +           {
  929. +               int votes = rset.getInt("godvotes");
  930. +               String name = rset.getString("char_name");
  931. +              
  932. +               godMap.put(name,votes);
  933. +           }
  934. +          
  935. +           if(started == 0)
  936. +           {
  937. +               st = con.prepareStatement("SELECT char_name FROM characters WHERE god=1");
  938. +               rset = st.executeQuery();
  939. +              
  940. +               String godName = "";
  941. +              
  942. +               while(rset.next())
  943. +                   godName = rset.getString("char_name");
  944. +              
  945. +               if(godName == "")
  946. +                   GOD_NAME = "None";
  947. +               else
  948. +                   GOD_NAME = godName;
  949. +              
  950. +               started++;
  951. +           }
  952. +          
  953. +           st = con.prepareStatement("SELECT ip FROM god_ips");
  954. +           rset = st.executeQuery();
  955. +          
  956. +           while(rset.next())
  957. +               ips.add(rset.getString("ip"));
  958. +          
  959. +           rset.close();
  960. +           st.close();
  961. +          
  962. +       }
  963. +       catch(Exception e)
  964. +       {
  965. +           _log.warning("Error at storing God Map : \n"+e.getMessage());
  966. +       }
  967. +   }
  968. +  
  969. +   public static GodSystem getInstance()
  970. +   {
  971. +       return SingletonHolder._instance;
  972. +   }
  973. +  
  974. +   protected static class SingletonHolder
  975. +   {
  976. +       protected final static GodSystem _instance = new GodSystem();
  977. +   }
  978. +}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement