Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Eclipse Workspace Patch 1.0
- #P aCis_datapack
- Index: data/html/godmanagement/intro.htm
- ===================================================================
- --- data/html/godmanagement/intro.htm (revision 0)
- +++ data/html/godmanagement/intro.htm (revision 0)
- @@ -0,0 +1,37 @@
- +<html>
- +
- +<head>
- +<title>God Manager</title>
- +</head>
- +
- +<body>
- +
- +
- +<center>
- +<br>
- +<img src="l2ui.SquareWhite" width=275 height=3><br>
- + Server's God at the moment: <font color="99ffcc">%godname%</font><br>
- +Next period remaining time: <font color="LEVEL">%remain%</font>
- + <img src="l2ui.SquareWhite" width=275 height=3>
- +<br><br>
- + Hello <font color="LEVEL"> %charname% </font>, I am God Manager Npc<br>
- + Choose any function you want:
- + <br>
- + <br>
- + <button value="Vote player" action="bypass -h npc_%objectId%_voteForGod" width=75 height=21 back="L2UI_ch3.Btn1_normalOn" fore="L2UI_ch3.Btn1_normal">
- + <br><img src="l2ui.SquareWhite" width=275 height=1><br>
- + <img src="l2ui.SquareWhite" width=275 height=1><br>
- + <br><button value="Ranking" action="bypass -h npc_%objectId%_showGodRanking" width=75 height=21 back="L2UI_ch3.Btn1_normalOn" fore="L2UI_ch3.Btn1_normal">
- + <br>
- + <img src="l2ui.SquareWhite" width=275 height=1><br>
- + <img src="l2ui.SquareWhite" width=275 height=1><br>
- +<br>
- + <button value="My Votes" action="bypass -h npc_%objectId%_showPersonalGodVotes" width=75 height=21 back="L2UI_ch3.Btn1_normalOn" fore="L2UI_ch3.Btn1_normal">
- +
- +</center>
- +
- +
- +
- +</body>
- +
- +</html>
- \ No newline at end of file
- Index: sql/characters.sql
- ===================================================================
- --- sql/characters.sql (revision 1)
- +++ sql/characters.sql (working copy)
- @@ -54,6 +54,9 @@
- `clan_join_expiry_time` BIGINT UNSIGNED NOT NULL DEFAULT 0,
- `clan_create_expiry_time` BIGINT UNSIGNED NOT NULL DEFAULT 0,
- `death_penalty_level` SMALLINT UNSIGNED NOT NULL DEFAULT 0,
- + `godvotes` SMALLINT UNSIGNED DEFAULT NULL,
- + `godvoted` TINYINT UNSIGNED NOT NULL DEFAULT 0,
- + `god` TINYINT UNSIGNED NOT NULL DEFAULT 0,
- PRIMARY KEY (obj_Id),
- KEY `clanid` (`clanid`)
- );
- \ No newline at end of file
- Index: data/html/godmanagement/vote.htm
- ===================================================================
- --- data/html/godmanagement/vote.htm (revision 0)
- +++ data/html/godmanagement/vote.htm (revision 0)
- @@ -0,0 +1,38 @@
- +<html>
- +
- +<head>
- +<title>God Manager</title>
- +</head>
- +
- +<body>
- +
- +
- +<center>
- +
- + <br>
- + <br>
- + <br>
- + <br>
- + <br>
- +<img src="l2ui.SquareWhite" width=275 height=1><br>
- +
- + Put below player's name you want to vote
- +<img src="l2ui.SquareWhite" width=275 height=1><br>
- +<br>
- +<edit var="chaname" width=100>
- +<br>
- +<button value="Confirm" action="bypass -h npc_%objectId%_voteplayer $chaname" width=75 height=21 back="L2UI_ch3.Btn1_normalOn" fore="L2UI_ch3.Btn1_normal">
- +<br><br><br>
- +
- + <font color="fc1818">Warning:<br>
- +
- + You can vote one time every period so vote carefully!
- +
- +</font>
- +
- +
- +
- +</center>
- +</body>
- +
- +</html>
- \ No newline at end of file
- Index: data/html/godmanagement/personal.htm
- ===================================================================
- --- data/html/godmanagement/personal.htm (revision 0)
- +++ data/html/godmanagement/personal.htm (revision 0)
- @@ -0,0 +1,33 @@
- +<html>
- +
- +<head>
- +<title>God Manager</title>
- +</head>
- +
- +<body>
- +
- +
- +<center>
- +
- + <br>
- + <br>
- + <br>
- + <br>
- +
- +<img src="l2ui.SquareWhite" width=275 height=1><br>
- +<img src="l2ui.SquareWhite" width=275 height=1><br>
- +
- + You have collected <font color="LEVEL"> %votes% </font> votes.
- +<img src="l2ui.SquareWhite" width=275 height=1><br>
- +<img src="l2ui.SquareWhite" width=275 height=1><br>
- +
- +<br><br><br>
- +
- + <font color="f100cc">Have fun</font>
- +
- +</center>
- +
- +
- +</body>
- +
- +</html>
- \ No newline at end of file
- Index: data/xml/admin_commands_rights.xml
- ===================================================================
- --- data/xml/admin_commands_rights.xml (revision 1)
- +++ data/xml/admin_commands_rights.xml (working copy)
- @@ -14,7 +14,7 @@
- <aCar name="admin_tradeoff" accessLevel="1" />
- <aCar name="admin_reload" accessLevel="1" />
- <aCar name="admin_script_load" accessLevel="1" />
- -
- + <aCar name="admin_end_god" accessLevel="1" />
- <!-- ANNOUNCEMENTS -->
- <aCar name="admin_list_announcements" accessLevel="1" />
- <aCar name="admin_reload_announcements" accessLevel="1" />
- Index: tools/database_installer.bat
- ===================================================================
- --- tools/database_installer.bat (revision 1)
- +++ tools/database_installer.bat (working copy)
- @@ -99,6 +99,7 @@
- %mysqlPath% -h %gshost% -u %gsuser% --password=%gspass% -D %gsdb% < ../sql/olympiad_fights.sql
- %mysqlPath% -h %gshost% -u %gsuser% --password=%gspass% -D %gsdb% < ../sql/olympiad_nobles_eom.sql
- %mysqlPath% -h %gshost% -u %gsuser% --password=%gspass% -D %gsdb% < ../sql/olympiad_nobles.sql
- +%mysqlPath% -h %gshost% -u %gsuser% --password=%gspass% -D %gsdb% < ../sql/god_ips.sql
- %mysqlPath% -h %gshost% -u %gsuser% --password=%gspass% -D %gsdb% < ../sql/pets.sql
- %mysqlPath% -h %gshost% -u %gsuser% --password=%gspass% -D %gsdb% < ../sql/posts.sql
- %mysqlPath% -h %gshost% -u %gsuser% --password=%gspass% -D %gsdb% < ../sql/server_variables.sql
- Index: data/xml/npcs/npcs.xml
- ===================================================================
- --- data/xml/npcs/npcs.xml (revision 1)
- +++ data/xml/npcs/npcs.xml (working copy)
- @@ -300199,4 +300199,40 @@
- <skill id="4416" level="16"/>
- </skills>
- </npc>
- + <npc id="10" idTemplate="31618" name="God Manager" title="[giolioy coding]">
- + <set name="level" val="70"/>
- + <set name="radius" val="8"/>
- + <set name="height" val="23"/>
- + <set name="rHand" val="316"/>
- + <set name="lHand" val="0"/>
- + <set name="type" val="L2GodManager"/>
- + <set name="exp" val="0"/>
- + <set name="sp" val="0"/>
- + <set name="hp" val="2444.46819"/>
- + <set name="mp" val="1345.8"/>
- + <set name="hpRegen" val="7.5"/>
- + <set name="mpRegen" val="2.7"/>
- + <set name="pAtk" val="688.86373"/>
- + <set name="pDef" val="295.91597"/>
- + <set name="mAtk" val="470.40463"/>
- + <set name="mDef" val="216.53847"/>
- + <set name="crit" val="4"/>
- + <set name="atkSpd" val="253"/>
- + <set name="str" val="40"/>
- + <set name="int" val="21"/>
- + <set name="dex" val="30"/>
- + <set name="wit" val="20"/>
- + <set name="con" val="43"/>
- + <set name="men" val="20"/>
- + <set name="corpseTime" val="7"/>
- + <set name="walkSpd" val="50"/>
- + <set name="runSpd" val="120"/>
- + <set name="dropHerbGroup" val="0"/>
- + <set name="attackRange" val="40"/>
- + <ai type="default" ssCount="0" ssRate="0" spsCount="0" spsRate="0" aggro="0" canMove="true" seedable="false"/>
- + <skills>
- + <skill id="4045" level="1"/>
- + <skill id="4416" level="16"/>
- + </skills>
- + </npc>
- </list>
- Index: sql/god_ips.sql
- ===================================================================
- --- sql/god_ips.sql (revision 0)
- +++ sql/god_ips.sql (revision 0)
- @@ -0,0 +1,4 @@
- +CREATE TABLE IF NOT EXISTS god_ips (
- + `ip` VARCHAR(40) NOT NULL DEFAULT '',
- + PRIMARY KEY (ip)
- +);
- \ No newline at end of file
- ### Eclipse Workspace Patch 1.0
- #P aCis_gameserver
- Index: java/net/sf/l2j/gameserver/model/actor/instance/L2GodManagerInstance.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/actor/instance/L2GodManagerInstance.java (revision 0)
- +++ java/net/sf/l2j/gameserver/model/actor/instance/L2GodManagerInstance.java (revision 0)
- @@ -0,0 +1,105 @@
- +/*
- + * This program is free software: you can redistribute it and/or modify it under
- + * the terms of the GNU General Public License as published by the Free Software
- + * Foundation, either version 3 of the License, or (at your option) any later
- + * version.
- + *
- + * This program is distributed in the hope that it will be useful, but WITHOUT
- + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- + * details.
- + *
- + * You should have received a copy of the GNU General Public License along with
- + * this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +package net.sf.l2j.gameserver.model.actor.instance;
- +
- +import java.util.StringTokenizer;
- +
- +import net.sf.l2j.gameserver.model.GodSystem;
- +import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
- +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
- +import net.sf.l2j.gameserver.templates.chars.L2NpcTemplate;
- +
- +/**
- + * @author gio.lioy
- + *
- + */
- +public class L2GodManagerInstance extends L2NpcInstance
- +{
- + public L2GodManagerInstance(int objectId, L2NpcTemplate template)
- + {
- + super(objectId, template);
- + }
- +
- +
- + @Override
- + public void showChatWindow(L2PcInstance player)
- + {
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- +
- + String filename = "data/html/godmanagement/intro.htm";
- +
- + // Send a Server->Client NpcHtmlMessage containing the text of the L2Npc to the L2PcInstance
- + NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
- + html.setFile(filename);
- + html.replace("%charname%",player.getName());
- + html.replace("%godname%", GodSystem.returnGodName());
- + html.replace("%remain%",GodSystem.returnRemainingTime());
- + html.replace("%objectId%", String.valueOf(getObjectId()));
- + player.sendPacket(html);
- + }
- +
- + @Override
- + public void onBypassFeedback(L2PcInstance player, String command)
- + {
- + if(command.startsWith("voteForGod"))
- + {
- + String filename = "data/html/godmanagement/vote.htm";
- + NpcHtmlMessage html = new NpcHtmlMessage(0);
- + html.setFile(filename);
- + html.replace("%objectId%", String.valueOf(getObjectId()));
- + player.sendPacket(html);
- + }
- + else if(command.startsWith("showGodRanking"))
- + {
- + GodSystem.showGodRanking(player);
- + }
- + else if(command.startsWith("showPersonalGodVotes"))
- + {
- + GodSystem.showPersonalGodVotes(player);
- + }
- + else if(command.startsWith("voteplayer"))
- + {
- +
- + if(player.isGodVoted())
- + {
- + player.sendMessage("You have already voted , we are sorry!");
- + return;
- + }
- +
- + String charName = null;
- +
- + try
- + {
- + StringTokenizer stringTokenizer = new StringTokenizer(command);
- + stringTokenizer.nextToken();
- + charName = stringTokenizer.nextToken();
- + }
- + catch(Exception e)
- + {
- + return;
- + }
- +
- + if(charName == null)
- + {
- + player.sendMessage("Wrong name");
- + return;
- + }
- +
- + GodSystem.vote(player, charName);
- + }
- + }
- +
- +
- +}
- Index: java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminGod.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminGod.java (revision 0)
- +++ java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminGod.java (revision 0)
- @@ -0,0 +1,51 @@
- +/*
- + * This program is free software: you can redistribute it and/or modify it under
- + * the terms of the GNU General Public License as published by the Free Software
- + * Foundation, either version 3 of the License, or (at your option) any later
- + * version.
- + *
- + * This program is distributed in the hope that it will be useful, but WITHOUT
- + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- + * details.
- + *
- + * You should have received a copy of the GNU General Public License along with
- + * this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +package net.sf.l2j.gameserver.handler.admincommandhandlers;
- +
- +import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
- +import net.sf.l2j.gameserver.model.GodSystem;
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +import net.sf.l2j.gameserver.util.Broadcast;
- +
- +/**
- + * @author gio.lioy
- + *
- + */
- +public class AdminGod implements IAdminCommandHandler
- +{
- + private static final String[] ADMIN_COMMANDS =
- + {
- + "admin_end_god"
- + };
- +
- + @Override
- + public boolean useAdminCommand(String command, L2PcInstance activeChar)
- + {
- + if(command.equals("admin_end_god"))
- + {
- + Broadcast.announceToOnlinePlayers("Admin "+activeChar.getName()+" ended God Period!");
- + GodSystem.deleteAndUpdate();
- + }
- +
- + return true;
- + }
- +
- + @Override
- + public String[] getAdminCommandList()
- + {
- + return ADMIN_COMMANDS;
- + }
- +
- +}
- Index: java/net/sf/l2j/gameserver/GameServer.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/GameServer.java (revision 1)
- +++ java/net/sf/l2j/gameserver/GameServer.java (working copy)
- @@ -85,6 +85,7 @@
- import net.sf.l2j.gameserver.instancemanager.SiegeManager;
- import net.sf.l2j.gameserver.instancemanager.ZoneManager;
- import net.sf.l2j.gameserver.model.AutoSpawnHandler;
- +import net.sf.l2j.gameserver.model.GodSystem;
- import net.sf.l2j.gameserver.model.L2Manor;
- import net.sf.l2j.gameserver.model.L2Multisell;
- import net.sf.l2j.gameserver.model.L2World;
- @@ -243,6 +244,7 @@
- Util.printSection("Quests & Scripts");
- QuestManager.getInstance();
- BoatManager.getInstance();
- + GodSystem.getInstance();
- if (!Config.ALT_DEV_NO_SCRIPTS)
- {
- Index: java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java (revision 1)
- +++ java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java (working copy)
- @@ -39,6 +39,7 @@
- import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminGeodata;
- import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminGm;
- import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminGmChat;
- +import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminGod;
- import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminHeal;
- import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminHelpPage;
- import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminInvul;
- @@ -92,6 +93,7 @@
- registerAdminCommandHandler(new AdminCreateItem());
- registerAdminCommandHandler(new AdminCursedWeapons());
- registerAdminCommandHandler(new AdminDelete());
- + registerAdminCommandHandler(new AdminGod());
- registerAdminCommandHandler(new AdminDoorControl());
- registerAdminCommandHandler(new AdminEditChar());
- registerAdminCommandHandler(new AdminEditNpc());
- Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (revision 1)
- +++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (working copy)
- @@ -260,9 +260,9 @@
- private static final String DELETE_SKILL_SAVE = "DELETE FROM character_skills_save WHERE char_obj_id=? AND class_index=?";
- // Character SQL String Definitions:
- - 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 (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
- - 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=?";
- - 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=?";
- + 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 (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
- + 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=?";
- + 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=?";
- // Character Subclass SQL String Definitions:
- 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";
- @@ -282,6 +282,8 @@
- private static final String UPDATE_NOBLESS = "UPDATE characters SET nobless=? WHERE obj_Id=?";
- +
- +
- public static final int REQUEST_TIMEOUT = 15;
- public static final int STORE_PRIVATE_NONE = 0;
- public static final int STORE_PRIVATE_SELL = 1;
- @@ -393,6 +395,10 @@
- private byte _siegeState = 0;
- private int _curWeightPenalty = 0;
- + private int _godvotes;
- + private boolean _godvoted;
- + private boolean _god;
- +
- private int _lastCompassZone; // the last compass zone update send to the client
- private boolean _isInWater;
- @@ -1902,6 +1908,74 @@
- sendPacket(new ExStorageMaxCount(this));
- }
- + public void votePlayer(L2PcInstance target)
- + {
- + target.setGodVotes(target.getGodVotes() + 1);
- + setGodVoted(true);
- + }
- +
- + /**
- + * @return votes for god status of the L2PcInstance
- + */
- +
- + public int getGodVotes()
- + {
- + return _godvotes;
- + }
- +
- + /**
- + * @param votes of the L2PcInstance for god status
- + */
- + public void setGodVotes(int votes)
- + {
- + _godvotes = votes;
- +
- + try (Connection con = L2DatabaseFactory.getInstance().getConnection())
- + {
- + PreparedStatement statement = con.prepareStatement("UPDATE characters SET godvotes=? WHERE obj_Id=?");
- + statement.setInt(1, _godvotes);
- + statement.setInt(2, getObjectId());
- + statement.executeUpdate();
- + statement.close();
- + }
- + catch (Exception e)
- + {
- + _log.log(Level.WARNING, "Could not update " + getName() + " god votes " + e.getMessage(), e);
- + }
- + }
- +
- + /**
- + * @return if player has already voted
- + */
- + public boolean isGodVoted()
- + {
- + return _godvoted;
- + }
- +
- + /**
- + * @param voted value of L2PcInstance if he voted or no
- + */
- + public void setGodVoted(boolean voted)
- + {
- + _godvoted = voted;
- + }
- +
- + /**
- + * @return if L2PcInstance is God
- + */
- + public boolean isGod()
- + {
- + return _god;
- + }
- +
- + /**
- + * @param god set L2PcInstance god status
- + */
- + public void setGod(boolean god)
- + {
- + _god = god;
- + }
- +
- /**
- * @return PvP Kills of the L2PcInstance (number of player killed during a PvP).
- */
- @@ -5523,6 +5597,9 @@
- statement.setInt(32, isNoble() ? 1 : 0);
- statement.setLong(33, 0);
- statement.setLong(34, System.currentTimeMillis());
- + statement.setLong(35, getGodVotes());
- + statement.setInt(36, isGodVoted() ? 1 : 0);
- + statement.setInt(37, isGod() ? 1 : 0);
- statement.executeUpdate();
- statement.close();
- }
- @@ -5670,6 +5747,9 @@
- player.setDeathPenaltyBuffLevel(rset.getInt("death_penalty_level"));
- + player.setGodVotes(rset.getInt("godvotes"));
- + player.setGodVoted(rset.getInt("godvoted") == 1);
- + player.setGod(rset.getInt("god") == 1);
- // Set the x,y,z position of the L2PcInstance and make it invisible
- player.setXYZInvisible(rset.getInt("x"), rset.getInt("y"), rset.getInt("z"));
- @@ -6017,7 +6097,11 @@
- statement.setLong(47, getClanCreateExpiryTime());
- statement.setString(48, getName());
- statement.setLong(49, getDeathPenaltyBuffLevel());
- - statement.setInt(50, getObjectId());
- + statement.setInt(50, getGodVotes());
- + statement.setInt(51, isGodVoted() ? 1 : 0);
- + statement.setInt(52, isGod() ? 1 : 0);
- + statement.setInt(53, getObjectId());
- +
- statement.execute();
- statement.close();
- Index: java/net/sf/l2j/gameserver/model/GodSystem.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/GodSystem.java (revision 0)
- +++ java/net/sf/l2j/gameserver/model/GodSystem.java (revision 0)
- @@ -0,0 +1,396 @@
- +/*
- + * This program is free software: you can redistribute it and/or modify it under
- + * the terms of the GNU General Public License as published by the Free Software
- + * Foundation, either version 3 of the License, or (at your option) any later
- + * version.
- + *
- + * This program is distributed in the hope that it will be useful, but WITHOUT
- + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- + * details.
- + *
- + * You should have received a copy of the GNU General Public License along with
- + * this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +package net.sf.l2j.gameserver.model;
- +
- +import java.util.concurrent.CopyOnWriteArrayList;
- +import java.util.concurrent.TimeUnit;
- +import java.util.logging.Logger;
- +import java.sql.Connection;
- +import java.sql.PreparedStatement;
- +import java.sql.ResultSet;
- +import java.util.Calendar;
- +import java.util.LinkedHashMap;
- +import java.util.List;
- +import java.util.Map;
- +
- +import net.sf.l2j.L2DatabaseFactory;
- +import net.sf.l2j.gameserver.ThreadPoolManager;
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +import net.sf.l2j.gameserver.network.clientpackets.Say2;
- +import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
- +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
- +import net.sf.l2j.gameserver.util.Broadcast;
- +
- +/**
- + * @author gio.lioy
- + *
- + */
- +public class GodSystem
- +{
- +
- + private static final Map<String,Integer> godMap = new LinkedHashMap<>();
- + private static final List<String> ips = new CopyOnWriteArrayList<>();
- + private static final Logger _log = Logger.getLogger(GodSystem.class.getName());
- + private static int started = 0;
- + private static String GOD_NAME;
- +
- + public static String returnRemainingTime()
- + {
- + long millis =getTimeForNewStart();
- +
- + String hms = String.format("%02d:%02d:%02d", TimeUnit.MILLISECONDS.toHours(millis),
- + TimeUnit.MILLISECONDS.toMinutes(millis) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(millis)),
- + TimeUnit.MILLISECONDS.toSeconds(millis) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis)));
- +
- + return hms;
- + }
- +
- + public static String returnGodName()
- + {
- + return GOD_NAME;
- + }
- +
- + public static void deleteAndUpdate()
- + {
- +
- +
- + try(Connection con = L2DatabaseFactory.getInstance().getConnection())
- + {
- + PreparedStatement st = con.prepareStatement("SELECT obj_Id,godvotes FROM characters WHERE godvotes>0 ORDER BY godvotes DESC LIMIT 1");
- + ResultSet rset = st.executeQuery();
- +
- + //store the new GOD infos
- + int objectId = 0;
- + int godVotes = 0;
- +
- + while(rset.next())
- + {
- + objectId = rset.getInt("obj_Id");
- + godVotes = rset.getInt("godvotes");
- + }
- +
- + Broadcast.announceToOnlinePlayers("God System initialized! New period started!");
- +
- +
- + started = 0;
- + GOD_NAME = "None";
- +
- + if(objectId == 0)
- + {
- + Broadcast.announceToOnlinePlayers("New GOD wasn't found, GOD remains the same player");
- + return;
- + }
- +
- + //delete old
- + cleanGodSystem();
- +
- +
- + //release new
- +
- +
- + L2PcInstance player = L2World.getInstance().getPlayer(objectId);
- + if(player != null)
- + {
- + player.setGod(true);
- + player.sendPacket(new CreatureSay(0,Say2.SHOUT,"God Manager","You are the new God! Congratulations!!!"));
- + Broadcast.announceToOnlinePlayers("New God of server is "+player.getName()+" with "+godVotes+" votes!");
- +
- + ips.clear();
- + }
- + else
- + {
- + st = con.prepareStatement("UPDATE characters SET god=1 WHERE obj_Id=?");
- + st.setInt(1, objectId);
- + st.executeUpdate();
- +
- + st = con.prepareStatement("SELECT char_name FROM characters WHERE god=1");
- + rset = st.executeQuery();
- +
- + String name = "";
- + while(rset.next())
- + name = rset.getString("char_name");
- +
- + Broadcast.announceToOnlinePlayers("New God of server is "+name+" with "+godVotes+" votes!");
- +
- + st = con.prepareStatement("DELETE FROM god_ips");
- + st.executeUpdate();
- +
- + st.close();
- +
- +
- + }
- +
- +
- +
- +
- + }
- + catch(Exception e)
- + {
- + _log.warning("Problem to delete/update new God: "+e.getMessage());
- + }
- + }
- +
- + protected static long getTimeForNewStart()
- + {
- + Calendar cal = Calendar.getInstance();
- + cal.set(Calendar.DAY_OF_WEEK,Calendar.SUNDAY);
- + cal.add(Calendar.WEEK_OF_MONTH, 1);
- + cal.set(Calendar.HOUR,00);
- + cal.set(Calendar.MINUTE,0);
- + cal.set(Calendar.SECOND,1);
- +
- + long time = ( (cal.getTimeInMillis() -System.currentTimeMillis()));
- +
- +
- + return time;
- + }
- +
- + protected static void cleanGodSystem()
- + {
- + for(L2PcInstance player : L2World.getInstance().getAllPlayers().values())
- + if(player != null)
- + {
- + player.setGodVotes(0);
- + player.setGod(false);
- + player.setGodVoted(false);
- + }
- +
- + try(Connection con = L2DatabaseFactory.getInstance().getConnection())
- + {
- + PreparedStatement st = con.prepareStatement("UPDATE characters SET godvotes=0,godvoted=0,god=0");
- + st.executeUpdate();
- + st.close();
- + }
- + catch(Exception e)
- + {
- + _log.warning("Error ar clean gold System "+e.getMessage());
- + }
- + }
- +
- + public static void vote(L2PcInstance player, String playerToVote)
- + {
- + L2PcInstance playerVote = L2World.getInstance().getPlayer(playerToVote);
- +
- + if(player.getName().equals(playerToVote))
- + {
- + player.sendMessage("You cannot vote yourself, we are sorry!");
- + return;
- + }
- + if(ips.contains(player.getClient().getConnection().getInetAddress().getHostAddress()))
- + {
- + player.sendMessage("You have already voted from this IP , we are sorry!");
- + return;
- + }
- + boolean voted = false;
- + if(playerVote != null)
- + {
- + player.votePlayer(playerVote);
- + playerVote.sendMessage("You received one vote for God Player, congratulations!");
- + player.sendPacket(new CreatureSay(0,Say2.SHOUT,"God Manager","You voted successfully for "+playerToVote+", thank you!"));
- + voted = true;
- + }
- + else
- + {
- + try(Connection con = L2DatabaseFactory.getInstance().getConnection())
- + {
- + PreparedStatement st = con.prepareStatement("SELECT count(*) FROM characters WHERE UPPER(char_name)=UPPER(?)");
- + st.setString(1, playerToVote);
- + ResultSet rset = st.executeQuery();
- +
- + int count = 0 ;
- +
- + while(rset.next())
- + count = rset.getInt(1);
- +
- + if(count == 0)
- + {
- + player.sendMessage("Incorrect name , we are sorry!");
- + return;
- + }
- +
- + st = con.prepareStatement("UPDATE characters SET godvotes=godvotes+1 WHERE char_name=?");
- + st.setString(1, playerToVote);
- + st.executeUpdate();
- +
- + player.setGodVoted(true);
- + player.sendPacket(new CreatureSay(0,Say2.SHOUT,"God Manager","You voted successfully for "+playerToVote+", thank you!"));
- + voted = true;
- + rset.close();
- + st.close();
- +
- + }
- + catch(Exception e)
- + {
- + _log.warning("Failed to vote : "+e.getMessage());
- + }
- + }
- +
- + if(voted)
- + {
- + String ip = player.getClient().getConnection().getInetAddress().getHostAddress();
- +
- + try(Connection con = L2DatabaseFactory.getInstance().getConnection())
- + {
- + PreparedStatement st = con.prepareStatement("INSERT INTO god_ips VALUES (?)");
- + st.setString(1, ip);
- + st.executeUpdate();
- + st.close();
- + }
- + catch(Exception e)
- + {
- + _log.warning(e.getMessage());
- + }
- + }
- +
- + }
- +
- + public static void showPersonalGodVotes(L2PcInstance player)
- + {
- + String filename = "data/html/godmanagement/personal.htm";
- + NpcHtmlMessage html = new NpcHtmlMessage(0);
- + html.setFile(filename);
- + html.replace("%votes%", String.valueOf(player.getGodVotes()));
- + player.sendPacket(html);
- + }
- +
- + public static void showGodRanking(L2PcInstance player)
- + {
- + StringBuilder sb = new StringBuilder("<html><head>");
- + sb.append("<title>God Manager</title></head>");
- + sb.append("<body><center>");
- + sb.append("<br><br>");
- + sb.append("<table width=210 border=1");
- + int counter = 1;
- +
- + sb.append("<tr>");
- +
- + sb.append("<td><font color=\"LEVEL\">Rank</font></td>");
- + sb.append("<td><font color=\"LEVEL\">Name</font></td>");
- + sb.append("<td><font color=\"LEVEL\">Votes</font></td>");
- +
- + sb.append("</tr>");
- + for(String charname : godMap.keySet())
- + {
- + sb.append("<tr>");
- +
- + sb.append("<td>"+counter+"</td>");
- + sb.append("<td>"+charname+"</td>");
- + sb.append("<td>"+godMap.get(charname)+"</td>");
- +
- + sb.append("</tr>");
- +
- + counter++;
- + }
- +
- + sb.append("</table>");
- + sb.append("</center></body></html>");
- +
- + NpcHtmlMessage nhm = new NpcHtmlMessage(0);
- + nhm.setHtml(sb.toString());
- + player.sendPacket(nhm);
- + }
- +
- + protected GodSystem()
- + {
- + ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new Runnable()
- + {
- + @Override
- + public void run()
- + {
- + init();
- + }
- +
- + }, 0, 30000);
- +
- + ThreadPoolManager.getInstance().scheduleGeneral(new NewStart(), getTimeForNewStart());
- +
- + }
- +
- + protected class NewStart implements Runnable
- + {
- +
- + @Override
- + public void run()
- + {
- +
- + deleteAndUpdate();
- + ThreadPoolManager.getInstance().scheduleGeneral(new NewStart(), getTimeForNewStart());
- +
- + }
- +
- + }
- +
- + protected void init()
- + {
- + godMap.clear();
- +
- +
- + try(Connection con = L2DatabaseFactory.getInstance().getConnection())
- + {
- + PreparedStatement st = con.prepareStatement("SELECT godvotes,char_name FROM characters WHERE godvotes>0 ORDER BY godvotes desc");
- + ResultSet rset = st.executeQuery();
- +
- + while(rset.next())
- + {
- + int votes = rset.getInt("godvotes");
- + String name = rset.getString("char_name");
- +
- + godMap.put(name,votes);
- + }
- +
- + if(started == 0)
- + {
- + st = con.prepareStatement("SELECT char_name FROM characters WHERE god=1");
- + rset = st.executeQuery();
- +
- + String godName = "";
- +
- + while(rset.next())
- + godName = rset.getString("char_name");
- +
- + if(godName == "")
- + GOD_NAME = "None";
- + else
- + GOD_NAME = godName;
- +
- + started++;
- + }
- +
- + st = con.prepareStatement("SELECT ip FROM god_ips");
- + rset = st.executeQuery();
- +
- + while(rset.next())
- + ips.add(rset.getString("ip"));
- +
- + rset.close();
- + st.close();
- +
- + }
- + catch(Exception e)
- + {
- + _log.warning("Error at storing God Map : \n"+e.getMessage());
- + }
- + }
- +
- + public static GodSystem getInstance()
- + {
- + return SingletonHolder._instance;
- + }
- +
- + protected static class SingletonHolder
- + {
- + protected final static GodSystem _instance = new GodSystem();
- + }
- +}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement