· 9 years ago · Dec 08, 2016, 09:02 AM
1diff --git a/dist/game/data/scripts/handlers/MasterHandler.java b/dist/game/data/scripts/handlers/MasterHandler.java
2index a2b2de3..ebd8760 100644
3--- a/dist/game/data/scripts/handlers/MasterHandler.java
4+++ b/dist/game/data/scripts/handlers/MasterHandler.java
5@@ -280,6 +280,7 @@ import handlers.voicedcommandhandlers.StatsVCmd;
6 import handlers.voicedcommandhandlers.Wedding;
7 import handlers.voicedcommandhandlers.VoiceExperience;
8 import handlers.voicedcommandhandlers.OnlineStatus;
9+import handlers.voicedcommandhandlers.VoteCommand;
10
11
12 /**
13@@ -538,6 +539,7 @@ public class MasterHandler
14 (Config.L2JMOD_DEBUG_VOICE_COMMAND ? Debug.class : null),
15 (Config.L2JMOD_ALLOW_CHANGE_PASSWORD ? ChangePassword.class : null),
16 (Config.L2JMOD_ENABLE_ONLINE_STATUS ? OnlineStatus.class : null),
17+ (Config.L2JMOD_ENABLE_VOTE_COMMAND ? VoteCommand.class : null),
18 },
19 {
20 // Target Handlers
21diff --git a/dist/game/data/scripts/handlers/voicedcommandhandlers/VoteCommand.java b/dist/game/data/scripts/handlers/voicedcommandhandlers/VoteCommand.java
22new file mode 100644
23index 0000000..140970b
24--- /dev/null
25+++ b/dist/game/data/scripts/handlers/voicedcommandhandlers/VoteCommand.java
26@@ -0,0 +1,75 @@
27+/*
28+ * Copyright (C) 2004-2013 L2J DataPack
29+ *
30+ * This file is part of L2J DataPack.
31+ *
32+ * L2J DataPack is free software: you can redistribute it and/or modify
33+ * it under the terms of the GNU General Public License as published by
34+ * the Free Software Foundation, either version 3 of the License, or
35+ * (at your option) any later version.
36+ *
37+ * L2J DataPack is distributed in the hope that it will be useful,
38+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
39+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
40+ * General Public License for more details.
41+ *
42+ * You should have received a copy of the GNU General Public License
43+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
44+ */
45+package handlers.voicedcommandhandlers;
46+
47+import com.l2jserver.Config;
48+import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
49+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
50+import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
51+import java.util.logging.Logger;
52+
53+public class VoteCommand implements IVoicedCommandHandler
54+{
55+ static final Logger _log = Logger.getLogger(VoteCommand.class.getName());
56+ private static final String[] VOICED_COMMANDS = {"vote"};
57+
58+ @Override
59+ public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
60+ {
61+ if (!Config.L2JMOD_ENABLE_VOTE_COMMAND || activeChar == null)
62+ {
63+ activeChar.sendMessage("Command Disabled");
64+ return false;
65+ }
66+
67+ final NpcHtmlMessage html = new NpcHtmlMessage(0);
68+ html.setHtml(getVoteHtml(activeChar));
69+ activeChar.sendPacket(html);
70+ return true;
71+ }
72+
73+ private static String getVoteHtml(L2PcInstance activeChar)
74+ {
75+ StringBuilder sb = new StringBuilder();
76+ sb.append("<html><body><center><br>");
77+ if(activeChar.eligibleToVoteHop()) {
78+ sb.append("<a action=\"bypass -h vote hopzone\">I have voted on hopzone</a><br1>");
79+ } else {
80+ sb.append(String.format("You can vote again in: %s <br1>",activeChar.getVoteCountdownHop()));
81+ }
82+ if(activeChar.eligibleToVoteTop()) {
83+ sb.append("<a action=\"bypass -h vote topzone\">I have voted on topzone</a><br1>");
84+ } else {
85+ sb.append(String.format("You can vote again in: %s <br1>",activeChar.getVoteCountdownTop()));
86+ }
87+ if(activeChar.eligibleToVoteNet()) {
88+ sb.append("<a action=\"bypass -h vote network\">I have voted on network</a><br1>");
89+ } else {
90+ sb.append(String.format("You can vote again in: %s <br1>",activeChar.getVoteCountdownNet()));
91+ }
92+
93+ sb.append("</body></html>");
94+ return sb.toString();
95+ }
96+ @Override
97+ public String[] getVoicedCommandList()
98+ {
99+ return VOICED_COMMANDS;
100+ }
101+}
102\ No newline at end of file
103diff --git a/dist/game/data/stats/npcs/custom/custom.xml b/dist/game/data/stats/npcs/custom/custom.xml
104index 18f8f27..81fa19b 100644
105--- a/dist/game/data/stats/npcs/custom/custom.xml
106+++ b/dist/game/data/stats/npcs/custom/custom.xml
107@@ -58,4 +58,10 @@
108 <height normal="22.25" />
109 </collision>
110 </npc>
111+ <npc id="50004" displayId="35187" level="80" name="Vote Manager" usingServerSideName="true" title="L2J Server" usingServerSideTitle="true" type="L2VoteNpc">
112+ <collision>
113+ <radius normal="10.0" />
114+ <height normal="24.0" />
115+ </collision>
116+ </npc>
117 </list>
118\ No newline at end of file
119diff --git a/dist/sql/game/characters.sql b/dist/sql/game/characters.sql
120index f84c9c6..b9aa84c 100644
121--- a/dist/sql/game/characters.sql
122+++ b/dist/sql/game/characters.sql
123@@ -54,6 +54,9 @@ CREATE TABLE IF NOT EXISTS `characters` (
124 `bookmarkslot` SMALLINT UNSIGNED NOT NULL DEFAULT 0,
125 `vitality_points` SMALLINT UNSIGNED NOT NULL DEFAULT 0,
126 `createDate` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
127+ `last_hop_vote` BIGINT UNSIGNED NOT NULL DEFAULT 0,
128+ `last_top_vote` BIGINT UNSIGNED NOT NULL DEFAULT 0,
129+ `last_net_vote` BIGINT UNSIGNED NOT NULL DEFAULT 0,
130 `language` VARCHAR(2) DEFAULT NULL,
131 PRIMARY KEY (`charId`),
132 KEY `account_name` (`account_name`),