Sync with L2JServer Jan 30th 2015.
This commit is contained in:
@ -59,7 +59,6 @@ import handlers.admincommandhandlers.AdminEvents;
|
||||
import handlers.admincommandhandlers.AdminExpSp;
|
||||
import handlers.admincommandhandlers.AdminFightCalculator;
|
||||
import handlers.admincommandhandlers.AdminFortSiege;
|
||||
import handlers.admincommandhandlers.AdminGamePoints;
|
||||
import handlers.admincommandhandlers.AdminGeodata;
|
||||
import handlers.admincommandhandlers.AdminGm;
|
||||
import handlers.admincommandhandlers.AdminGmChat;
|
||||
@ -87,6 +86,7 @@ import handlers.admincommandhandlers.AdminPetition;
|
||||
import handlers.admincommandhandlers.AdminPledge;
|
||||
import handlers.admincommandhandlers.AdminPolymorph;
|
||||
import handlers.admincommandhandlers.AdminPremium;
|
||||
import handlers.admincommandhandlers.AdminPrimePoints;
|
||||
import handlers.admincommandhandlers.AdminPunishment;
|
||||
import handlers.admincommandhandlers.AdminQuest;
|
||||
import handlers.admincommandhandlers.AdminReload;
|
||||
@ -355,7 +355,6 @@ public class MasterHandler
|
||||
AdminExpSp.class,
|
||||
AdminFightCalculator.class,
|
||||
AdminFortSiege.class,
|
||||
AdminGamePoints.class,
|
||||
AdminGeodata.class,
|
||||
AdminGm.class,
|
||||
AdminGmChat.class,
|
||||
@ -382,6 +381,7 @@ public class MasterHandler
|
||||
AdminPledge.class,
|
||||
AdminPolymorph.class,
|
||||
AdminPremium.class,
|
||||
AdminPrimePoints.class,
|
||||
AdminPunishment.class,
|
||||
AdminQuest.class,
|
||||
AdminReload.class,
|
||||
|
@ -1,238 +0,0 @@
|
||||
/*
|
||||
* 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.NpcHtmlMessage;
|
||||
|
||||
/**
|
||||
* Admin Ncoin commands.
|
||||
* @author Mobius
|
||||
*/
|
||||
public class AdminGamePoints implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_add_game_points",
|
||||
"admin_count_game_points",
|
||||
"admin_gamepoints",
|
||||
"admin_set_game_points",
|
||||
"admin_subtract_game_points"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.startsWith("admin_add_game_points"))
|
||||
{
|
||||
try
|
||||
{
|
||||
if ((activeChar.getTarget() != null) && activeChar.getTarget().isPlayer())
|
||||
{
|
||||
String val = command.substring(22);
|
||||
if (!addGamePoints(activeChar, val))
|
||||
{
|
||||
activeChar.sendMessage("Usage: //add_game_points count");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("You must select a player first.");
|
||||
}
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{ // Case of missing parameter
|
||||
activeChar.sendMessage("Usage: //add_game_points count");
|
||||
}
|
||||
}
|
||||
else if (command.equals("admin_count_game_points"))
|
||||
{
|
||||
if ((activeChar.getTarget() != null) && activeChar.getTarget().isPlayer())
|
||||
{
|
||||
L2PcInstance target = (L2PcInstance) activeChar.getTarget();
|
||||
activeChar.sendMessage(target.getName() + " has a total of " + target.getPrimePoints() + " NCoins.");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("You must select a player first.");
|
||||
}
|
||||
}
|
||||
else if (command.equals("admin_gamepoints"))
|
||||
{
|
||||
openGamePointsMenu(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_set_game_points"))
|
||||
{
|
||||
try
|
||||
{
|
||||
if ((activeChar.getTarget() != null) && activeChar.getTarget().isPlayer())
|
||||
{
|
||||
String val = command.substring(22);
|
||||
if (!setPrimePoints(activeChar, val))
|
||||
{
|
||||
activeChar.sendMessage("Usage: //set_game_points count");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("You must select a player first.");
|
||||
}
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{ // Case of missing parameter
|
||||
activeChar.sendMessage("Usage: //set_game_points count");
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_subtract_game_points"))
|
||||
{
|
||||
try
|
||||
{
|
||||
if ((activeChar.getTarget() != null) && activeChar.getTarget().isPlayer())
|
||||
{
|
||||
String val = command.substring(27);
|
||||
if (!subtractGamePoints(activeChar, val))
|
||||
{
|
||||
activeChar.sendMessage("Usage: //subtract_game_points count");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("You must select a player first.");
|
||||
}
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{ // Case of missing parameter
|
||||
activeChar.sendMessage("Usage: //subtract_game_points count");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void openGamePointsMenu(L2PcInstance activeChar)
|
||||
{
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage();
|
||||
html.setFile(activeChar.getHtmlPrefix(), "data/html/admin/NCoins.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 Ncoin count.");
|
||||
return false;
|
||||
}
|
||||
|
||||
final int currentPoints = player.getPrimePoints();
|
||||
if (currentPoints < 1)
|
||||
{
|
||||
player.setPrimePoints(points);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.setPrimePoints(currentPoints + points);
|
||||
}
|
||||
|
||||
admin.sendMessage("Added " + points + " NCoins to " + player.getName() + ".");
|
||||
admin.sendMessage(player.getName() + " has now a total of " + player.getPrimePoints() + " NCoins.");
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean setPrimePoints(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 Ncoin count.");
|
||||
return false;
|
||||
}
|
||||
|
||||
player.setPrimePoints(points);
|
||||
admin.sendMessage(player.getName() + " has now a total of " + points + " NCoins.");
|
||||
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 Ncoin count.");
|
||||
return false;
|
||||
}
|
||||
|
||||
final int currentPoints = player.getPrimePoints();
|
||||
if (currentPoints <= points)
|
||||
{
|
||||
player.setPrimePoints(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.setPrimePoints(currentPoints - points);
|
||||
}
|
||||
admin.sendMessage(player.getName() + " has now a total of " + player.getPrimePoints() + " NCoins.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
@ -1,14 +1,14 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J Server
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* 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 Server is distributed in the hope that it will be useful,
|
||||
* 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.
|
||||
@ -18,226 +18,192 @@
|
||||
*/
|
||||
package handlers.admincommandhandlers;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.cache.HtmCache;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
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;
|
||||
import com.l2jserver.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* Admin Player Commendation Point commands (PC Cafe/Bang).
|
||||
* @author Mobius
|
||||
* Admin PC Points manage admin commands.
|
||||
*/
|
||||
public class AdminPCBangPoints implements IAdminCommandHandler
|
||||
public final 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"
|
||||
"admin_pcbangpoints",
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.startsWith("admin_add_bang_points"))
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
final String actualCommand = st.nextToken();
|
||||
|
||||
if (actualCommand.equals("admin_pcbangpoints"))
|
||||
{
|
||||
try
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
if ((activeChar.getTarget() != null) && activeChar.getTarget().isPlayer())
|
||||
final String action = st.nextToken();
|
||||
|
||||
final L2PcInstance target = getTarget(activeChar);
|
||||
if ((target == null) || !st.hasMoreTokens())
|
||||
{
|
||||
String val = command.substring(22);
|
||||
if (!addGamePoints(activeChar, val))
|
||||
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":
|
||||
{
|
||||
activeChar.sendMessage("Usage: //add_bang_points count");
|
||||
if (value > Config.PC_BANG_MAX_POINTS)
|
||||
{
|
||||
showMenuHtml(activeChar);
|
||||
activeChar.sendMessage("You cannot set more than " + Config.PC_BANG_MAX_POINTS + " PC points!");
|
||||
return false;
|
||||
}
|
||||
if (value < 0)
|
||||
{
|
||||
value = 0;
|
||||
}
|
||||
|
||||
target.setPcBangPoints(value);
|
||||
target.sendMessage("Admin set your PC point(s) to " + value + "!");
|
||||
activeChar.sendMessage("You set " + value + " PC point(s) to player " + target.getName());
|
||||
target.sendPacket(new ExPCCafePointInfo(value, value, 1));
|
||||
break;
|
||||
}
|
||||
case "increase":
|
||||
{
|
||||
if (target.getPcBangPoints() == Config.PC_BANG_MAX_POINTS)
|
||||
{
|
||||
showMenuHtml(activeChar);
|
||||
activeChar.sendMessage(target.getName() + " already have max count of PC points!");
|
||||
return false;
|
||||
}
|
||||
|
||||
int pcBangCount = Math.min((target.getPcBangPoints() + value), Config.PC_BANG_MAX_POINTS);
|
||||
if (pcBangCount < 0)
|
||||
{
|
||||
pcBangCount = Config.PC_BANG_MAX_POINTS;
|
||||
}
|
||||
target.setPcBangPoints(pcBangCount);
|
||||
target.sendMessage("Admin increased your PC point(s) by " + value + "!");
|
||||
activeChar.sendMessage("You increased PC point(s) of " + target.getName() + " by " + value);
|
||||
target.sendPacket(new ExPCCafePointInfo(pcBangCount, value, 1));
|
||||
break;
|
||||
}
|
||||
case "decrease":
|
||||
{
|
||||
if (target.getPcBangPoints() == 0)
|
||||
{
|
||||
showMenuHtml(activeChar);
|
||||
activeChar.sendMessage(target.getName() + " already have min count of PC points!");
|
||||
return false;
|
||||
}
|
||||
|
||||
final int pcBangCount = Math.max(target.getPcBangPoints() - value, 0);
|
||||
target.setPcBangPoints(pcBangCount);
|
||||
target.sendMessage("Admin decreased your PC point(s) by " + value + "!");
|
||||
activeChar.sendMessage("You decreased PC point(s) of " + target.getName() + " by " + value);
|
||||
target.sendPacket(new ExPCCafePointInfo(pcBangCount, value, 1));
|
||||
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 PC 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 PC point(s) of all players (" + count + ") in range " + range + " by " + value + ".");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
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.");
|
||||
showMenuHtml(activeChar);
|
||||
}
|
||||
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");
|
||||
showMenuHtml(activeChar);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void openGamePointsMenu(L2PcInstance activeChar)
|
||||
private int increaseForAll(Collection<L2PcInstance> playerList, int value)
|
||||
{
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage();
|
||||
html.setFile(activeChar.getHtmlPrefix(), "data/html/admin/pcbang.htm");
|
||||
int counter = 0;
|
||||
for (L2PcInstance temp : playerList)
|
||||
{
|
||||
if ((temp != null) && (temp.isOnlineInt() == 1))
|
||||
{
|
||||
if (temp.getPcBangPoints() == Integer.MAX_VALUE)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int pcBangCount = Math.min((temp.getPcBangPoints() + value), Integer.MAX_VALUE);
|
||||
if (pcBangCount < 0)
|
||||
{
|
||||
pcBangCount = Integer.MAX_VALUE;
|
||||
}
|
||||
temp.setPcBangPoints(pcBangCount);
|
||||
temp.sendMessage("Admin increased your PC point(s) by " + value + "!");
|
||||
temp.sendPacket(new ExPCCafePointInfo(pcBangCount, value, 1));
|
||||
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.getPcBangPoints();
|
||||
html.setHtml(HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/admin/pcbang.htm"));
|
||||
html.replace("%points%", Util.formatAdena(points));
|
||||
html.replace("%targetName%", target.getName());
|
||||
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()
|
||||
{
|
||||
|
@ -20,9 +20,12 @@ package handlers.admincommandhandlers;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.cache.HtmCache;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.instancemanager.PremiumManager;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
@ -55,7 +58,7 @@ public class AdminPremium implements IAdminCommandHandler
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
activeChar.sendMessage("Error.");
|
||||
activeChar.sendMessage("Please enter a valid account name.");
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_premium_add2"))
|
||||
@ -67,7 +70,7 @@ public class AdminPremium implements IAdminCommandHandler
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
activeChar.sendMessage("Error.");
|
||||
activeChar.sendMessage("Please enter a valid account name.");
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_premium_add3"))
|
||||
@ -79,7 +82,7 @@ public class AdminPremium implements IAdminCommandHandler
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
activeChar.sendMessage("Error.");
|
||||
activeChar.sendMessage("Please enter a valid account name.");
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_premium_info"))
|
||||
@ -91,7 +94,7 @@ public class AdminPremium implements IAdminCommandHandler
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
activeChar.sendMessage("Error.");
|
||||
activeChar.sendMessage("Please enter a valid account name.");
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_premium_remove"))
|
||||
@ -103,14 +106,24 @@ public class AdminPremium implements IAdminCommandHandler
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
activeChar.sendMessage("Error.");
|
||||
activeChar.sendMessage("Please enter a valid account name.");
|
||||
}
|
||||
}
|
||||
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, 0);
|
||||
html.setHtml(HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/admin/premium_menu.htm"));
|
||||
activeChar.sendPacket(html);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void addPremiumStatus(L2PcInstance admin, int months, String accountName)
|
||||
{
|
||||
if (!Config.PREMIUM_SYSTEM_ENABLED)
|
||||
{
|
||||
admin.sendMessage("Premium system is disabled.");
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Add check if account exists XD
|
||||
PremiumManager.getInstance().updatePremiumData(months, accountName);
|
||||
final SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy HH:mm");
|
||||
|
196
trunk/dist/game/data/scripts/handlers/admincommandhandlers/AdminPrimePoints.java
vendored
Normal file
196
trunk/dist/game/data/scripts/handlers/admincommandhandlers/AdminPrimePoints.java
vendored
Normal file
@ -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 NCoin(s) to " + value + "!");
|
||||
activeChar.sendMessage("You set " + value + " NCoin(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 NCoins!");
|
||||
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 increased your NCoin(s) by " + value + "!");
|
||||
activeChar.sendMessage("You increased NCoin(s) of " + target.getName() + " by " + value);
|
||||
break;
|
||||
}
|
||||
case "decrease":
|
||||
{
|
||||
if (target.getPrimePoints() == 0)
|
||||
{
|
||||
showMenuHtml(activeChar);
|
||||
activeChar.sendMessage(target.getName() + " already have min count of NCoins!");
|
||||
return false;
|
||||
}
|
||||
|
||||
final int primeCount = Math.max(target.getPrimePoints() - value, 0);
|
||||
target.setPrimePoints(primeCount);
|
||||
target.sendMessage("Admin decreased your NCoin(s) by " + value + "!");
|
||||
activeChar.sendMessage("You decreased NCoin(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 NCoin(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 NCoin(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 increased your NCoin(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;
|
||||
}
|
||||
}
|
@ -259,7 +259,7 @@ public class AdminReload implements IAdminCommandHandler
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded item crystalization data.");
|
||||
break;
|
||||
}
|
||||
case "itemmall":
|
||||
case "primeshop":
|
||||
{
|
||||
PrimeShopData.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded L2 Store data.");
|
||||
|
Reference in New Issue
Block a user