Instantly share code, notes, and snippets.
Last active
August 29, 2015 14:14
-
Star
(0)
0
You must be signed in to star a gist -
Fork
(0)
0
You must be signed in to fork a gist
-
Save St3eT/0dcf0557a9032161b725 to your computer and use it in GitHub Desktop.
Prime Points menu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/L2J_DataPack/dist/game/config/adminCommands.xml b/L2J_DataPack/dist/game/config/adminCommands.xml | |
index 32b7cdf..3084b2e 100644 | |
--- a/L2J_DataPack/dist/game/config/adminCommands.xml | |
+++ b/L2J_DataPack/dist/game/config/adminCommands.xml | |
@@ -418,6 +418,9 @@ | |
<admin command="admin_transform" accessLevel="7" /> | |
<admin command="admin_untransform" accessLevel="7" /> | |
<admin command="admin_transform_menu" accessLevel="7" /> | |
+ | |
+ <!-- ADMIN PRIME POINTS --> | |
+ <admin command="admin_primepoints" accessLevel="7" /> | |
<!-- ADMIN QUEST --> | |
<admin command="admin_quest_reload" accessLevel="7" /> | |
diff --git a/L2J_DataPack/dist/game/data/html/admin/char_menu.htm b/L2J_DataPack/dist/game/data/html/admin/char_menu.htm | |
index 3c1ab62..3419004 100644 | |
--- a/L2J_DataPack/dist/game/data/html/admin/char_menu.htm | |
+++ b/L2J_DataPack/dist/game/data/html/admin/char_menu.htm | |
@@ -36,6 +36,7 @@ | |
<tr> | |
<td><button value="Vit Set" action="bypass -h admin_set_vitality $qbox" width=82 height=20 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td> | |
<td><button value="Vit Max" action="bypass -h admin_full_vitality" width=82 height=20 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td> | |
+<td><button value="Prime Points" action="bypass -h admin_primepoints" width=82 height=20 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td> | |
</tr> | |
<tr> | |
<td><button value="Get Buffs" action="bypass -h admin_getbuffs $qbox" width=82 height=20 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td> | |
diff --git a/L2J_DataPack/dist/game/data/html/admin/primepoints.htm b/L2J_DataPack/dist/game/data/html/admin/primepoints.htm | |
new file mode 100644 | |
index 0000000..ddff480 | |
--- /dev/null | |
+++ b/L2J_DataPack/dist/game/data/html/admin/primepoints.htm | |
@@ -0,0 +1,59 @@ | |
+<html><title>Admin Prime Points Manage</title><body> | |
+<center> | |
+<table width=270> | |
+<tr> | |
+<td width=45><button value="Main" action="bypass admin_admin" width=45 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td> | |
+<td width=180><center>Admin Prime Points Manage</center></td> | |
+<td width=45><button value="Back" action="bypass -h admin_admin6" width=45 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td> | |
+</tr> | |
+</table> | |
+<font color=""><button action="" value="Target info:" width=270 height=21 back="L2UI_CT1.OlympiadWnd_DF_Watch_Down" fore="L2UI_CT1.OlympiadWnd_DF_Watch"></font> | |
+ <table width="270" border="0" bgcolor="444444"> | |
+ <tr> | |
+ <td>Player Name:</td> | |
+ <td><font color="LEVEL">%targetName%<font></td> | |
+ </tr> | |
+ <tr> | |
+ <td>Player Points:</td> | |
+ <td><font color="LEVEL">%points%<font></td> | |
+ </tr> | |
+ </table> | |
+ <br> | |
+ <button action="" value="Target Operations" width=270 height=21 back="L2UI_CT1.OlympiadWnd_DF_Watch_Down" fore="L2UI_CT1.OlympiadWnd_DF_Watch"> | |
+ <table width=256 border=0 bgcolor="444444"> | |
+ <tr> | |
+ <td align=center><button value="Operation: " action="" width=130 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td> | |
+ <td align=center><combobox width=120 height=17 var=ebox list=increase;decrease;set></td> | |
+ </tr> | |
+ <tr> | |
+ <td align=center><button value="Value: " action="" width=130 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td> | |
+ <td align=center><edit var="val" width=120 type="number"></td> | |
+ </tr> | |
+ </table> | |
+ <table width="267" border="0" bgcolor="444444"> | |
+ <tr> | |
+ <td><center><button value="Confirm" action="bypass -h admin_primepoints $ebox $val" width=125 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></center></td> | |
+ </tr> | |
+ </table> | |
+ <br> | |
+ <button action="" value="Reward More players" width=270 height=21 back="L2UI_CT1.OlympiadWnd_DF_Watch_Down" fore="L2UI_CT1.OlympiadWnd_DF_Watch"> | |
+ <table width=256 border=0 bgcolor="444444"> | |
+ <tr> | |
+ <td align=center><button value="Range: " action="" width=130 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td> | |
+ <td align=center><edit var="range" width=120 type="number"></td> | |
+ </tr> | |
+ <tr> | |
+ <td align=center><button value="Value: " action="" width=130 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td> | |
+ <td align=center><edit var="val2" width=120 type="number"></td> | |
+ </tr> | |
+ </table> | |
+ <table width="259" border="0" bgcolor="444444"> | |
+ <tr> | |
+ <td><center><button value="Confirm" action="bypass -h admin_primepoints rewardOnline $val2 $range" width=125 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></center></td> | |
+ </tr> | |
+ <tr> | |
+ <td><center>Note: If you leave 'Range' empty or set 0, it will reward all online players.</center></td> | |
+ </tr> | |
+ </table> | |
+</center> | |
+</body></html> | |
\ No newline at end of file | |
diff --git a/L2J_DataPack/dist/game/data/scripts/handlers/MasterHandler.java b/L2J_DataPack/dist/game/data/scripts/handlers/MasterHandler.java | |
index 0bf2ce0..3af68c8 100644 | |
--- a/L2J_DataPack/dist/game/data/scripts/handlers/MasterHandler.java | |
+++ b/L2J_DataPack/dist/game/data/scripts/handlers/MasterHandler.java | |
@@ -84,6 +84,7 @@ | |
import handlers.admincommandhandlers.AdminPetition; | |
import handlers.admincommandhandlers.AdminPledge; | |
import handlers.admincommandhandlers.AdminPolymorph; | |
+import handlers.admincommandhandlers.AdminPrimePoints; | |
import handlers.admincommandhandlers.AdminPunishment; | |
import handlers.admincommandhandlers.AdminQuest; | |
import handlers.admincommandhandlers.AdminReload; | |
@@ -372,6 +373,7 @@ | |
AdminPForge.class, | |
AdminPledge.class, | |
AdminPolymorph.class, | |
+ AdminPrimePoints.class, | |
AdminPunishment.class, | |
AdminQuest.class, | |
AdminReload.class, | |
diff --git a/L2J_DataPack/dist/game/data/scripts/handlers/admincommandhandlers/AdminPrimePoints.java b/L2J_DataPack/dist/game/data/scripts/handlers/admincommandhandlers/AdminPrimePoints.java | |
new file mode 100644 | |
index 0000000..be2c8d8 | |
--- /dev/null | |
+++ b/L2J_DataPack/dist/game/data/scripts/handlers/admincommandhandlers/AdminPrimePoints.java | |
@@ -0,0 +1,196 @@ | |
+/* | |
+ * Copyright (C) 2004-2015 L2J DataPack | |
+ * | |
+ * This file is part of L2J DataPack. | |
+ * | |
+ * L2J DataPack 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. | |
+ * | |
+ * L2J DataPack 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 handlers.admincommandhandlers; | |
+ | |
+import java.util.Collection; | |
+import java.util.StringTokenizer; | |
+ | |
+import com.l2jserver.gameserver.cache.HtmCache; | |
+import com.l2jserver.gameserver.handler.IAdminCommandHandler; | |
+import com.l2jserver.gameserver.model.L2World; | |
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; | |
+import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage; | |
+import com.l2jserver.gameserver.util.Util; | |
+ | |
+/** | |
+ * Admin Prime Points manage admin commands. | |
+ * @author St3eT | |
+ */ | |
+public final class AdminPrimePoints implements IAdminCommandHandler | |
+{ | |
+ private static final String[] ADMIN_COMMANDS = | |
+ { | |
+ "admin_primepoints", | |
+ }; | |
+ | |
+ @Override | |
+ public boolean useAdminCommand(String command, L2PcInstance activeChar) | |
+ { | |
+ final StringTokenizer st = new StringTokenizer(command, " "); | |
+ final String actualCommand = st.nextToken(); | |
+ | |
+ if (actualCommand.equals("admin_primepoints")) | |
+ { | |
+ if (st.hasMoreTokens()) | |
+ { | |
+ final String action = st.nextToken(); | |
+ | |
+ final L2PcInstance target = getTarget(activeChar); | |
+ if ((target == null) || !st.hasMoreTokens()) | |
+ { | |
+ return false; | |
+ } | |
+ | |
+ int value = 0; | |
+ try | |
+ { | |
+ value = Integer.parseInt(st.nextToken()); | |
+ } | |
+ catch (Exception e) | |
+ { | |
+ showMenuHtml(activeChar); | |
+ activeChar.sendMessage("Invalid Value!"); | |
+ return false; | |
+ } | |
+ | |
+ switch (action) | |
+ { | |
+ case "set": | |
+ { | |
+ target.setPrimePoints(value); | |
+ target.sendMessage("Admin set your Prime Point(s) to " + value + "!"); | |
+ activeChar.sendMessage("You set " + value + " Prime Point(s) to player " + target.getName()); | |
+ break; | |
+ } | |
+ case "increase": | |
+ { | |
+ if (target.getPrimePoints() == Integer.MAX_VALUE) | |
+ { | |
+ showMenuHtml(activeChar); | |
+ activeChar.sendMessage(target.getName() + " already have max count of Prime Points!"); | |
+ return false; | |
+ } | |
+ | |
+ int primeCount = Math.min((target.getPrimePoints() + value), Integer.MAX_VALUE); | |
+ if (primeCount < 0) | |
+ { | |
+ primeCount = Integer.MAX_VALUE; | |
+ } | |
+ target.setPrimePoints(primeCount); | |
+ target.sendMessage("Admin increase your Prime Point(s) by " + value + "!"); | |
+ activeChar.sendMessage("You increased Prime Point(s) of " + target.getName() + " by " + value); | |
+ break; | |
+ } | |
+ case "decrease": | |
+ { | |
+ if (target.getPrimePoints() == 0) | |
+ { | |
+ showMenuHtml(activeChar); | |
+ activeChar.sendMessage(target.getName() + " already have min count of Prime Points!"); | |
+ return false; | |
+ } | |
+ | |
+ final int primeCount = Math.max(target.getPrimePoints() - value, 0); | |
+ target.setPrimePoints(primeCount); | |
+ target.sendMessage("Admin decreased your Prime Point(s) by " + value + "!"); | |
+ activeChar.sendMessage("You decreased Prime Point(s) of " + target.getName() + " by " + value); | |
+ break; | |
+ } | |
+ case "rewardOnline": | |
+ { | |
+ int range = 0; | |
+ try | |
+ { | |
+ range = Integer.parseInt(st.nextToken()); | |
+ } | |
+ catch (Exception e) | |
+ { | |
+ | |
+ } | |
+ | |
+ if (range <= 0) | |
+ { | |
+ final int count = increaseForAll(L2World.getInstance().getPlayers(), value); | |
+ activeChar.sendMessage("You increased Prime Point(s) of all online players (" + count + ") by " + value + "."); | |
+ } | |
+ else if (range > 0) | |
+ { | |
+ final int count = increaseForAll(activeChar.getKnownList().getKnownPlayers().values(), value); | |
+ activeChar.sendMessage("You increased Prime Point(s) of all players (" + count + ") in range " + range + " by " + value + "."); | |
+ } | |
+ break; | |
+ } | |
+ } | |
+ showMenuHtml(activeChar); | |
+ } | |
+ else | |
+ { | |
+ showMenuHtml(activeChar); | |
+ } | |
+ } | |
+ return true; | |
+ } | |
+ | |
+ private int increaseForAll(Collection<L2PcInstance> playerList, int value) | |
+ { | |
+ int counter = 0; | |
+ for (L2PcInstance temp : playerList) | |
+ { | |
+ if ((temp != null) && (temp.isOnlineInt() == 1)) | |
+ { | |
+ if (temp.getPrimePoints() == Integer.MAX_VALUE) | |
+ { | |
+ continue; | |
+ } | |
+ | |
+ int primeCount = Math.min((temp.getPrimePoints() + value), Integer.MAX_VALUE); | |
+ if (primeCount < 0) | |
+ { | |
+ primeCount = Integer.MAX_VALUE; | |
+ } | |
+ temp.setPrimePoints(primeCount); | |
+ temp.sendMessage("Admin increase your Prime Point(s) by " + value + "!"); | |
+ counter++; | |
+ } | |
+ } | |
+ return counter; | |
+ } | |
+ | |
+ private L2PcInstance getTarget(L2PcInstance activeChar) | |
+ { | |
+ return ((activeChar.getTarget() != null) && (activeChar.getTarget().getActingPlayer() != null)) ? activeChar.getTarget().getActingPlayer() : activeChar; | |
+ } | |
+ | |
+ private void showMenuHtml(L2PcInstance activeChar) | |
+ { | |
+ final NpcHtmlMessage html = new NpcHtmlMessage(0, 0); | |
+ final L2PcInstance target = getTarget(activeChar); | |
+ final int points = target.getPrimePoints(); | |
+ html.setHtml(HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/admin/primepoints.htm")); | |
+ html.replace("%points%", Util.formatAdena(points)); | |
+ html.replace("%targetName%", target.getName()); | |
+ activeChar.sendPacket(html); | |
+ } | |
+ | |
+ @Override | |
+ public String[] getAdminCommandList() | |
+ { | |
+ return ADMIN_COMMANDS; | |
+ } | |
+} | |
\ No newline at end of file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment