Addition of PC points admin commands.

This commit is contained in:
mobius 2015-01-29 20:50:25 +00:00
parent 02b43ae09e
commit f9acd64eb8
8 changed files with 302 additions and 11 deletions

View File

@ -273,6 +273,13 @@
<admin command="admin_subtract_game_points" accessLevel="100" />
<admin command="admin_reload_itemmall" accessLevel="100" />
<!-- ADMIN PCBANG -->
<admin command="admin_add_bang_points" accessLevel="100" />
<admin command="admin_count_bang_points" accessLevel="100" />
<admin command="admin_bangpoints" accessLevel="100" />
<admin command="admin_set_bang_points" accessLevel="100" />
<admin command="admin_subtract_bang_points" accessLevel="100" />
<!-- ADMIN GEODATA -->
<admin command="admin_geo_pos" accessLevel="100" />
<admin command="admin_geo_spawn_pos" accessLevel="100" />

View File

@ -28,6 +28,7 @@
<td><button value="goSpawn" action="bypass -h admin_list_spawns $qbox 1" width=65 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
</tr><tr>
<td><button value="Scan" action="bypass -h admin_scan $qbox" width=65 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="PC Cafe" action="bypass -h admin_bangpoints" width=65 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="NCoin" action="bypass -h admin_gamepoints" width=65 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="Premium" action="bypass -h admin_premium_menu" width=65 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
</tr>

View File

@ -15,7 +15,7 @@
<br><br>
<font color="LEVEL">NCoins is a type of currency used by L2Store.</font>
<br><br>
<font color="FF0000">(You must have targeted the player that you are interested in modifing/count his NCoins.)</font>
<font color="FF0000">(You must have targeted the player that you are interested in modifying/count his NCoins.)</font>
</center>
<table width=270>
<tr>

View File

@ -0,0 +1,38 @@
<html><title>PC Cafe Points</title>
<body>
<table width=270>
<tr>
<td width=45><button value="Main" action="bypass -h admin_admin" width=45 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td width=180>
<center>Player Commendation Points</center>
</td>
<td width=45>
<center><button value="Back" action="bypass -h admin_admin6" width=45 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></center>
</td>
</tr>
</table>
<center>
<br><br>
<font color="LEVEL">PC points is a type of currency gained by killing monsters.</font>
<br><br>
<font color="FF0000">(You must have targeted the player that you are interested in modifying/count his PC points.)</font>
</center>
<table width=270>
<tr>
<td width=70 align=right><font color="LEVEL">Value:</font></td>
<td>
<edit var="qbox" width=120 height=15>
</td>
</tr>
</table>
<br>
<table width=270>
<tr>
<td><button value="Add" action="bypass -h admin_add_bang_points $qbox" width=65 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="Subtract" action="bypass -h admin_subtract_bang_points $qbox" width=65 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="Set" action="bypass -h admin_set_bang_points $qbox" width=65 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="Count" action="bypass -h admin_count_bang_points" width=65 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
</tr>
</table>
</center>
</body></html>

View File

@ -79,6 +79,7 @@ import handlers.admincommandhandlers.AdminMenu;
import handlers.admincommandhandlers.AdminMessages;
import handlers.admincommandhandlers.AdminMobGroup;
import handlers.admincommandhandlers.AdminMonsterRace;
import handlers.admincommandhandlers.AdminPCBangPoints;
import handlers.admincommandhandlers.AdminPForge;
import handlers.admincommandhandlers.AdminPathNode;
import handlers.admincommandhandlers.AdminPcCondOverride;
@ -375,6 +376,7 @@ public class MasterHandler
AdminMobGroup.class,
AdminMonsterRace.class,
AdminPathNode.class,
AdminPCBangPoints.class,
AdminPetition.class,
AdminPForge.class,
AdminPledge.class,

View File

@ -0,0 +1,246 @@
/*
* Copyright (C) 2004-2015 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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 Server 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 com.l2jserver.gameserver.handler.IAdminCommandHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ExPCCafePointInfo;
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
/**
* Admin Player Commendation Point commands (PC Cafe/Bang).
* @author Mobius
*/
public class AdminPCBangPoints implements IAdminCommandHandler
{
private static final String[] ADMIN_COMMANDS =
{
"admin_add_bang_points",
"admin_count_bang_points",
"admin_bangpoints",
"admin_set_bang_points",
"admin_subtract_bang_points"
};
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (command.startsWith("admin_add_bang_points"))
{
try
{
if ((activeChar.getTarget() != null) && activeChar.getTarget().isPlayer())
{
String val = command.substring(22);
if (!addGamePoints(activeChar, val))
{
activeChar.sendMessage("Usage: //add_bang_points count");
}
}
else
{
activeChar.sendMessage("You must select a player first.");
}
}
catch (StringIndexOutOfBoundsException e)
{
// Case of missing parameter
activeChar.sendMessage("Usage: //add_bang_points count");
}
}
else if (command.equals("admin_count_bang_points"))
{
if ((activeChar.getTarget() != null) && activeChar.getTarget().isPlayer())
{
L2PcInstance target = (L2PcInstance) activeChar.getTarget();
activeChar.sendMessage(target.getName() + " has a total of " + target.getPcBangPoints() + " PC points.");
}
else
{
activeChar.sendMessage("You must select a player first.");
}
}
else if (command.equals("admin_bangpoints"))
{
openGamePointsMenu(activeChar);
}
else if (command.startsWith("admin_set_bang_points"))
{
try
{
if ((activeChar.getTarget() != null) && activeChar.getTarget().isPlayer())
{
String val = command.substring(22);
if (!setPcBangPoints(activeChar, val))
{
activeChar.sendMessage("Usage: //set_bang_points count");
}
}
else
{
activeChar.sendMessage("You must select a player first.");
}
}
catch (StringIndexOutOfBoundsException e)
{
// Case of missing parameter
activeChar.sendMessage("Usage: //set_bang_points count");
}
}
else if (command.startsWith("admin_subtract_bang_points"))
{
try
{
if ((activeChar.getTarget() != null) && activeChar.getTarget().isPlayer())
{
String val = command.substring(27);
if (!subtractGamePoints(activeChar, val))
{
activeChar.sendMessage("Usage: //subtract_bang_points count");
}
}
else
{
activeChar.sendMessage("You must select a player first.");
}
}
catch (StringIndexOutOfBoundsException e)
{
// Case of missing parameter
activeChar.sendMessage("Usage: //subtract_bang_points count");
}
}
return true;
}
private void openGamePointsMenu(L2PcInstance activeChar)
{
final NpcHtmlMessage html = new NpcHtmlMessage();
html.setFile(activeChar.getHtmlPrefix(), "data/html/admin/pcbang.htm");
activeChar.sendPacket(html);
}
private boolean addGamePoints(L2PcInstance admin, String val)
{
L2Object target = admin.getTarget();
L2PcInstance player = null;
if (target.isPlayer())
{
player = (L2PcInstance) target;
}
else
{
admin.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
return false;
}
final int points = Integer.valueOf(val);
if (points < 1)
{
admin.sendMessage("Invalid points count.");
return false;
}
final int currentPoints = player.getPcBangPoints();
if (currentPoints < 1)
{
player.setPcBangPoints(points);
}
else
{
player.setPcBangPoints(currentPoints + points);
}
player.sendPacket(new ExPCCafePointInfo(player.getPcBangPoints(), points, 1));
admin.sendMessage("Added " + points + " PC points to " + player.getName() + ".");
admin.sendMessage(player.getName() + " has now a total of " + player.getPcBangPoints() + " PC points.");
return true;
}
private boolean setPcBangPoints(L2PcInstance admin, String val)
{
L2Object target = admin.getTarget();
L2PcInstance player = null;
if (target.isPlayer())
{
player = (L2PcInstance) target;
}
else
{
admin.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
return false;
}
final int points = Integer.valueOf(val);
if (points < 0)
{
admin.sendMessage("Invalid points count.");
return false;
}
player.setPcBangPoints(points);
player.sendPacket(new ExPCCafePointInfo(player.getPcBangPoints(), points, 1));
admin.sendMessage(player.getName() + " has now a total of " + points + " PC points.");
return true;
}
private boolean subtractGamePoints(L2PcInstance admin, String val)
{
L2Object target = admin.getTarget();
L2PcInstance player = null;
if (target.isPlayer())
{
player = (L2PcInstance) target;
}
else
{
admin.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
return false;
}
final int points = Integer.valueOf(val);
if (points < 1)
{
admin.sendMessage("Invalid points count.");
return false;
}
final int currentPoints = player.getPcBangPoints();
if (currentPoints <= points)
{
player.setPcBangPoints(0);
player.sendPacket(new ExPCCafePointInfo(player.getPcBangPoints(), 0, 1));
}
else
{
player.setPcBangPoints(currentPoints - points);
player.sendPacket(new ExPCCafePointInfo(player.getPcBangPoints(), currentPoints - points, 1));
}
admin.sendMessage(player.getName() + " has now a total of " + player.getPcBangPoints() + " PC points.");
return true;
}
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
}

View File

@ -30,6 +30,10 @@ public class PcCafePointsManager
{
private static PcCafePointsManager _instance;
public PcCafePointsManager()
{
}
public static PcCafePointsManager getInstance()
{
if (_instance == null)
@ -39,10 +43,6 @@ public class PcCafePointsManager
return _instance;
}
public PcCafePointsManager()
{
}
public void givePcCafePoint(final L2PcInstance player, final long givedexp)
{
if (!Config.PC_BANG_ENABLED)
@ -74,8 +74,6 @@ public class PcCafePointsManager
_points = Rnd.get(_points / 2, _points);
}
@SuppressWarnings("unused")
boolean doublepoint = false;
SystemMessage sm = null;
if (_points > 0)
{
@ -83,7 +81,6 @@ public class PcCafePointsManager
{
_points *= 2;
sm = SystemMessage.getSystemMessage(SystemMessageId.DOUBLE_POINTS_YOU_EARNED_S1_PC_POINT_S);
doublepoint = true;
}
else
{

View File

@ -14173,11 +14173,11 @@ public final class L2PcInstance extends L2Playable
}
public void setPcBangPoints(final int i)
public void setPcBangPoints(final int count)
{
if (i < 200000)
if (count < 200000)
{
_pcBangPoints = i;
_pcBangPoints = count;
}
else
{