PlayerCommands.java
上传用户:gwt600
上传日期:2021-06-03
资源大小:704k
文件大小:45k
源码类别:

游戏

开发平台:

Java

  1. /*
  2. This file is part of the OdinMS Maple Story Server
  3. Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
  4. Matthias Butz <matze@odinms.de>
  5. Jan Christian Meyer <vimes@odinms.de>
  6. This program is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU Affero General Public License version 3
  8. as published by the Free Software Foundation. You may not use, modify
  9. or distribute this program under any other version of the
  10. GNU Affero General Public License.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU Affero General Public License for more details.
  15. You should have received a copy of the GNU Affero General Public License
  16. along with this program.  If not, see <http://www.gnu.org/licenses/>.
  17.  */
  18. package net.sf.odinms.client.messages.commands;
  19. import java.rmi.RemoteException;
  20. import java.sql.Connection;
  21. import java.sql.PreparedStatement;
  22. import java.util.Collection;
  23. import java.sql.ResultSet;
  24. import java.sql.SQLException;
  25. import java.util.Arrays;
  26. import java.util.HashMap;
  27. import java.util.List;
  28. import java.util.Map;
  29. import net.sf.odinms.client.ExpTable;
  30. import net.sf.odinms.server.maps.MapleMapObjectType;
  31. import net.sf.odinms.client.MapleCharacter;
  32. import net.sf.odinms.client.SkillFactory;
  33. import net.sf.odinms.client.MapleClient;
  34. import net.sf.odinms.tools.Pair;
  35. import net.sf.odinms.client.MapleJob;
  36. import net.sf.odinms.client.MapleRing;
  37. import net.sf.odinms.server.maps.MapleMapObject;
  38. import net.sf.odinms.net.world.remote.WorldChannelInterface;
  39. import java.util.ArrayList;
  40. import net.sf.odinms.client.MapleStat;
  41. import net.sf.odinms.client.messages.Command;
  42. import net.sf.odinms.client.messages.CommandDefinition;
  43. import net.sf.odinms.client.messages.MessageCallback;
  44. import net.sf.odinms.client.messages.ServernoticeMapleClientMessageCallback;
  45. import net.sf.odinms.net.channel.ChannelServer;
  46. import net.sf.odinms.database.DatabaseConnection;
  47. import net.sf.odinms.scripting.npc.NPCScriptManager;
  48. import net.sf.odinms.server.MapleInventoryManipulator;
  49. import net.sf.odinms.server.MaplePortal;
  50. import net.sf.odinms.server.maps.MapleMap;
  51. import net.sf.odinms.server.maps.SavedLocationType;
  52. import net.sf.odinms.tools.MaplePacketCreator;
  53. import net.sf.odinms.tools.StringUtil;
  54. public class PlayerCommands implements Command {
  55.     private int vip;
  56.     public void addAP(MapleClient c, int stat, int amount, String line) {
  57.         MapleCharacter player = c.getPlayer();
  58.                 String[] splitted = line.split(" ");
  59.         ChannelServer cserv = c.getChannelServer();
  60.         int vip = c.getPlayer().getVip();
  61.         switch (stat) {
  62.             case 1: // STR
  63.                 player.setStr(player.getStr() + amount);
  64.                 player.updateSingleStat(MapleStat.STR, player.getStr());
  65.                 break;
  66.             case 2: // DEX
  67.                 player.setDex(player.getDex() + amount);
  68.                 player.updateSingleStat(MapleStat.DEX, player.getDex());
  69.                 break;
  70.             case 3: // INT
  71.                 player.setInt(player.getInt() + amount);
  72.                 player.updateSingleStat(MapleStat.INT, player.getInt());
  73.                 break;
  74.             case 4: // LUK
  75.                 player.setLuk(player.getLuk() + amount);
  76.                 player.updateSingleStat(MapleStat.LUK, player.getLuk());
  77.                 break;
  78.             case 5: // HP
  79.                 player.setMaxHp(amount);
  80.                 player.updateSingleStat(MapleStat.MAXHP, player.getMaxHp());
  81.                 break;
  82.             case 6: // MP
  83.                 player.setMaxMp(amount);
  84.                 player.updateSingleStat(MapleStat.MAXMP, player.getMaxMp());
  85.                 break;
  86.         }
  87.         if (!player.isGM()) {
  88.             player.setRemainingAp(player.getRemainingAp() - amount);
  89.         }
  90.         player.updateSingleStat(MapleStat.AVAILABLEAP, player.getRemainingAp());
  91.     }
  92.     private ResultSet ranking(boolean gm) {
  93.         try {
  94.             Connection con = DatabaseConnection.getConnection();
  95.             PreparedStatement ps;
  96.             if (!gm) {
  97.                 ps = con.prepareStatement("SELECT reborns, level, name, job FROM characters WHERE gm < 3 ORDER BY reborns desc LIMIT 10");
  98.             } else {
  99.                 ps = con.prepareStatement("SELECT name, gm FROM characters WHERE gm >= 3");
  100.             }
  101.             return ps.executeQuery();
  102.         } catch (SQLException ex) {
  103.             return null;
  104.         }
  105.     }
  106.     @Override
  107.     public void execute(MapleClient c, MessageCallback mc, String[] splitted) throws Exception {
  108.         splitted[0] = splitted[0].toLowerCase();
  109.         MapleCharacter player = c.getPlayer();
  110.         ChannelServer cserv = c.getChannelServer();
  111.         if (player.getMapId() != 980000404) {
  112.             /* if (splitted[0].equals("@str") || splitted[0].equals("@dex") || splitted[0].equals("@int") || splitted[0].equals("@luk") || splitted[0].equals("@hp") || splitted[0].equals("@mp")) {
  113.             if (splitted.length != 2) {
  114.             return;
  115.             }
  116.             int x, max = 30000;
  117.             try {
  118.             x = Integer.parseInt(splitted[1]);
  119.             } catch (NumberFormatException asd) {
  120.             return;
  121.             }
  122.             if (x > 0 && x <= player.getRemainingAp() && x < Short.MAX_VALUE) {
  123.             if (splitted[0].equals("@str") && x + player.getStr() < max) {
  124.             addAP(c, 1, x);
  125.             } else if (splitted[0].equals("@dex") && x + player.getDex() < max) {
  126.             addAP(c, 2, x);
  127.             } else if (splitted[0].equals("@int") && x + player.getInt() < max) {
  128.             addAP(c, 3, x);
  129.             } else if (splitted[0].equals("@luk") && x + player.getLuk() < max) {
  130.             addAP(c, 4, x);
  131.             } else if (splitted[0].equals("@hp") && x + player.getMaxHp() < max) {
  132.             addAP(c, 5, x);
  133.             } else if (splitted[0].equals("@mp") && x + player.getMaxMp() < max) {
  134.             addAP(c, 6, x);
  135.             } else {
  136.             mc.dropMessage("Make sure the stat you are trying to raise will not be over 30000.");
  137.             }
  138.             } else {
  139.             mc.dropMessage("Please make sure your AP is valid.");
  140.             }
  141.             } else */
  142.             if (splitted[0].equalsIgnoreCase("@jiancha")) {
  143.                 mc.dropMessage("你的状态:");
  144.                 mc.dropMessage("力量: " + player.getStr());
  145.                 mc.dropMessage("敏捷: " + player.getDex());
  146.                 mc.dropMessage("智力: " + player.getInt());
  147.                 mc.dropMessage("运气: " + player.getLuk());
  148.                 mc.dropMessage("可用的能力点数: " + player.getRemainingAp());
  149.                 mc.dropMessage("转生次数: " + player.getReborns());
  150.             } else if (splitted[0].equalsIgnoreCase("@help")) {
  151.                 mc.dropMessage("============================================================");
  152.                 mc.dropMessage("        " + c.getChannelServer().getServerName() + " 命令");
  153.                 mc.dropMessage("============================================================");
  154.                 mc.dropMessage("@ll/@mj/@zl/@yq <你所要加的点数> ~ 快速加能力值哦.");
  155.                 mc.dropMessage("@save 存档.");
  156.                 mc.dropMessage("@zaixian 使用1金币来查看全服在线情况.");
  157.                 mc.dropMessage("@shangdian 在线超级商店.");
  158.                 mc.dropMessage("@sethp 设置自动吃药,比如:@sethp 50,即使低于50自动吃药.");
  159.                 mc.dropMessage("@setmp 设置自动吃药,比如:@setmp 50,即使低于50自动吃药.");
  160.                 mc.dropMessage("@mapid 查看你所在的地图坐标.");
  161.                 mc.dropMessage("@aphuanyuan 属性点还原.");
  162.                 //mc.dropMessage("@zhuanshen 转生.");
  163.                 mc.dropMessage("@wz 查看你在本地图的坐标.");
  164.                 mc.dropMessage("@qingchu 清楚地图上的垃圾.");
  165.                 mc.dropMessage("@zidong VIP自动捡钱.");
  166.                 mc.dropMessage("@ring 察看戒指编号.");
  167.                 mc.dropMessage("@sring 送戒指,比如:@sring aini a.");
  168.                 mc.dropMessage("@fuzhu 给自己添加辅助技能.");
  169.                 mc.dropMessage("@heal 信春哥满血满蓝原地复活.");
  170.                 mc.dropMessage("@rank ~ 排行榜.");
  171.                 mc.dropMessage("@jiasi 修复假死.");
  172.                 mc.dropMessage("@exp 修复经验值");
  173.                 mc.dropMessage("@gm <你想对GM说的话> ~ 私密GM ?");
  174.                 mc.dropMessage("@jiancha ~ 检查自己的状态");
  175.             /*    } else if (splitted[0].equalsIgnoreCase("@buynx")) {
  176.             if (splitted.length != 2) {
  177.             mc.dropMessage("Syntax: @buynx <number>");
  178.             return;
  179.             }
  180.             int nxamount;
  181.             try {
  182.             nxamount = Integer.parseInt(splitted[1]);
  183.             } catch (NumberFormatException asd) {
  184.             return;
  185.             }
  186.             int cost = nxamount * 5000;
  187.             if (nxamount > 0 && nxamount < 420000) {
  188.             if (player.getMeso() >= cost) {
  189.             player.gainMeso(-cost, true, true, true);
  190.             player.modifyCSPoints(1, nxamount);
  191.             mc.dropMessage("You spent " + cost + " mesos. You have gained " + nxamount + " nx.");
  192.             } else {
  193.             mc.dropMessage("Not enough mesos. Go get some money you poor hobo. 1 NX is 5000 mesos.");
  194.             }
  195.             } else {
  196.             mc.dropMessage("I cant let you do this, why would you want to do that.");
  197.             }*/
  198.             } else if (splitted[0].equalsIgnoreCase("@save")) {
  199.                 if (!player.getCheatTracker().Spam(900000, 0)) { // 15 minutes
  200.                     player.saveToDB(true, false);
  201.                     mc.dropMessage("保存成功.");
  202.                 } else {
  203.                     mc.dropMessage("距离上次保存没到15分钟,无法保存.");
  204.                 }
  205.                                     } else if (splitted[0].equals("@mapid")) {
  206.             mc.dropMessage("你在地图 " + player.getMap().getId());
  207.                } else if (splitted[0].equals("@heal")) {
  208.                   if (c.getPlayer().getMeso() < 1000000000) {
  209.                        mc.dropMessage("{ 玩家指令 } 你没有10E游戏币来复活!");
  210.                     } else {
  211.              c.getPlayer().gainMeso(-1000000000, true);
  212.             player.setHp(player.getMaxHp());
  213.             player.updateSingleStat(MapleStat.HP, player.getMaxHp());
  214.             player.setMp(player.getMaxMp());
  215.             player.updateSingleStat(MapleStat.MP, player.getMaxMp());
  216.                     }
  217.             } else if (splitted[0].equalsIgnoreCase("@exp")) {
  218.                 player.setExp(0);
  219.                 player.updateSingleStat(MapleStat.EXP, player.getExp());
  220.             } else if (splitted[0].equalsIgnoreCase("@fei")) {
  221.                 HashMap<String, Integer> maps = new HashMap<String, Integer>();
  222.                 maps.put("ziyou", 910000000);
  223.                 maps.put("henesys", 100000000);
  224.                 maps.put("ellinia", 101000000);
  225.                 maps.put("perion", 102000000);
  226.                 maps.put("kerning", 103000000);
  227.                 maps.put("lith", 104000000);
  228.                 maps.put("sleepywood", 105040300);
  229.                 maps.put("florina", 110000000);
  230.                 maps.put("orbis", 200000000);
  231.                 maps.put("happy", 209000000);
  232.                 maps.put("elnath", 211000000);
  233.                 maps.put("ludi", 220000000);
  234.                 maps.put("aqua", 230000000);
  235.                 maps.put("leafre", 240000000);
  236.                 maps.put("mulung", 250000000);
  237.                 maps.put("herb", 251000000);
  238.                 maps.put("omega", 221000000);
  239.                 maps.put("korean", 222000000);
  240.                 maps.put("nlc", 600000000);
  241.                 maps.put("excavation", 990000000);
  242.                 maps.put("mushmom", 100000005);
  243.                 maps.put("griffey", 240020101);
  244.                 maps.put("manon", 240020401);
  245.                 maps.put("horseman", 682000001);
  246.                 maps.put("balrog", 105090900);
  247.                 maps.put("showa", 801000000);
  248.                 maps.put("guild", 200000301);
  249.                 maps.put("shrine", 800000000);
  250.                 maps.put("skelegon", 104040001);
  251.                 maps.put("mall", 910000022);
  252.                 if (splitted.length != 2) {
  253.                     StringBuilder builder = new StringBuilder("用法: @fei <地图名字>");
  254.                     int i = 0;
  255.                     for (String mapss : maps.keySet()) {
  256.                         if (1 % 10 == 0) {// 10 maps per line
  257.                             mc.dropMessage(builder.toString());
  258.                         } else {
  259.                             builder.append(mapss + ", ");
  260.                         }
  261.                     }
  262.                     mc.dropMessage(builder.toString());
  263.                 } else if (maps.containsKey(splitted[1])) {
  264.                     int map = maps.get(splitted[1]);
  265.                     if (map == 910000000) {
  266.                         player.saveLocation(SavedLocationType.FREE_MARKET);
  267.                     }
  268.                     player.changeMap(map);
  269.                     mc.dropMessage("Please feel free to suggest any more locations");
  270.                 } else {
  271.                     mc.dropMessage("我没有找到可用的地图!");
  272.                 }
  273.                 maps.clear();
  274.             } else if (splitted[0].equalsIgnoreCase("@gm")) {
  275.                 if (splitted.length < 2) {
  276.                     return;
  277.                 }
  278.                 if (!player.getCheatTracker().Spam(300000, 1)) { // 5 minutes.
  279.                     try {
  280.                         c.getChannelServer().getWorldInterface().broadcastGMMessage(null, MaplePacketCreator.serverNotice(6, "频道: " + c.getChannel() + "  " + player.getName() + ": " + StringUtil.joinStringFrom(splitted, 1)).getBytes());
  281.                     } catch (RemoteException ex) {
  282.                         c.getChannelServer().reconnectWorld();
  283.                     }
  284.                 } else {
  285.                     player.dropMessage(1, "Please don't flood GMs with your messages");
  286.                 }
  287.                 } else if (splitted[0].equalsIgnoreCase("@qingchu")||splitted[0].equalsIgnoreCase("@laji")) {
  288.             MapleMap map = player.getMap();
  289.             double range = Double.POSITIVE_INFINITY;
  290.             java.util.List<MapleMapObject> items = map.getMapObjectsInRange(player.getPosition(), range, Arrays.asList(MapleMapObjectType.ITEM));
  291.             for (MapleMapObject itemmo : items) {
  292.                 map.removeMapObject(itemmo);
  293.                 map.broadcastMessage(MaplePacketCreator.removeItemFromMap(itemmo.getObjectId(), 0, player.getId()));
  294.             }
  295.             mc.dropMessage("你清楚了地上 " + items.size() + " 个物品、、");
  296.                      } else if (splitted[0].equals("@vipmap2")) {
  297.             MapleMap target = cserv.getMapFactory().getMap(922020300);
  298.             MaplePortal targetPortal = target.getPortal(0);
  299.             player.changeMap(target, targetPortal);
  300.         } else if (splitted[0].equals("@vipmap3")) {
  301.             MapleMap target = cserv.getMapFactory().getMap(801040101);
  302.             MaplePortal targetPortal = target.getPortal(0);
  303.             player.changeMap(target, targetPortal);
  304.             } else if (splitted[0].equalsIgnoreCase("@togglesmega")) {
  305.                 if (player.getMeso() >= 10000000) {
  306.                     player.setSmegaEnabled(!player.getSmegaEnabled());
  307.                     String text = (!player.getSmegaEnabled() ? "I blinded you with enchanted dog shit :) ! Now you may not see Avatar smega's" : "You magically grew ears that can see smegas T___T oh god that line is lame.");
  308.                     mc.dropMessage(text);
  309.                     player.gainMeso(-10000000, true);
  310.                 } else {
  311.                     mc.dropMessage("Wheres the mesos you idiot ! I want 10,000,000 meso");
  312.                 }
  313.             } else if (splitted[0].equals("@jieka")) {
  314.                 try {
  315.                     String name = splitted[1];
  316.                     Connection dcon = (Connection) DatabaseConnection.getConnection();
  317.                     PreparedStatement ps = (PreparedStatement) dcon.prepareStatement("UPDATE accounts SET loggedin = 0 WHERE name = ?");
  318.                     ps.setString(1, name);
  319.                     if (ps.executeUpdate() > 0) {
  320.                         mc.dropMessage("卡号自救提示:" + name + "这个游戏帐号已经解卡成功!!");
  321.                     } else {
  322.                         mc.dropMessage("输入错误,指令用法:@jieka 游戏帐号");
  323.                     }
  324.                     ps.close();
  325.                 } catch (SQLException ex) {
  326.                 }
  327.             } else if (splitted[0].equalsIgnoreCase("@jiasi")) {
  328.                 NPCScriptManager.getInstance().dispose(c);
  329.                 mc.dropMessage("已经解除假死了,试试看吧.");
  330.             } else if (splitted[0].equalsIgnoreCase("@rank")) {
  331.                 ResultSet rs = ranking(false);
  332.                 mc.dropMessage("前10名的玩家数据为: ");
  333.                 int i = 1;
  334.                 while (rs.next()) {
  335.                     String job;
  336.                     if (rs.getInt("job") >= 400 && rs.getInt("job") <= 422) {
  337.                         job = "侠客职业";
  338.                     } else if (rs.getInt("job") >= 300 && rs.getInt("job") <= 322) {
  339.                         job = "弓箭职业";
  340.                     } else if (rs.getInt("job") >= 200 && rs.getInt("job") <= 232) {
  341.                         job = "法师职业";
  342.                     } else if (rs.getInt("job") >= 100 && rs.getInt("job") <= 132) {
  343.                         job = "勇士职业";
  344.                     } else if (rs.getInt("job") >= 500 && rs.getInt("job") <= 532) {
  345.                         job = "海盗职业";
  346.                     } else {
  347.                         job = "新手";
  348.                     }
  349.                     mc.dropMessage(i + ". " + rs.getString("name") + "  ||  职业: " + job + "  ||  转生次数: " + rs.getInt("reborns") + "  ||  等级: " + rs.getInt("level"));
  350.                     i++;
  351.                 }
  352.                             } else if (splitted[0].equalsIgnoreCase("@sring")) {
  353.                 Map<String, Integer> rings = new HashMap<String, Integer>();
  354.                 rings.put("a", 1112800);//clover 四叶挚友戒指 - 任何人
  355.             rings.put("b", 1112801);//flower 雏菊挚友戒指 - 任何人
  356.             rings.put("c", 1112802);//star   闪星挚友戒指 - 任何人
  357.             rings.put("d", 1112806);//stargem 头上两把剑 - 第三人看到
  358.             rings.put("e", 1112809);//silverswan
  359.             rings.put("f", 1112807);//golden
  360.             rings.put("g", 1112001);//crush 恋人戒指 - 第三人看到
  361.             rings.put("h", 1112002);//纯爱恋人戒指 - 第三人看到
  362.             rings.put("i", 1112003);//丘比特戒指 - 第三人看到
  363.             rings.put("j", 1112005);//多个大红心围绕 - 第三人看到
  364.                 if (rings.containsKey(splitted[2])) {
  365.                     MapleCharacter partner1 = cserv.getPlayerStorage().getCharacterByName(player.getName());
  366.                     MapleCharacter partner2 = cserv.getPlayerStorage().getCharacterByName(splitted[1]);
  367.                     int ret = MapleRing.createRing(rings.get(splitted[2]), partner1, partner2);
  368.                     switch (ret) {
  369.                         case -1:
  370.                             mc.dropMessage("找不到伙伴");
  371.                             break;
  372.                         case 0:
  373.                             mc.dropMessage("错误. 你或伙伴已经拥有过戒指");
  374.                             break;
  375.                         default:
  376.                             mc.dropMessage("Sucess!");
  377.                     }
  378.                 } else {
  379.                     mc.dropMessage("找不到戒指编号. 指令用法@sring <对方名> <戒指编号a~j>");
  380.                 }
  381.                 rings.clear();
  382.             } else if (splitted[0].equalsIgnoreCase("@servergms")) {
  383.                 ResultSet rs = ranking(true);
  384.                 String gmType;
  385.                 while (rs.next()) {
  386.                     int gmLevl = rs.getInt("gm");
  387.                     if (gmLevl == 3) {
  388.                         gmType = "GM Helper.";
  389.                     } else if (gmLevl >= 4) {
  390.                         gmType = "Monster GM :D.";
  391.                     } else {
  392.                         gmType = "Error";
  393.                     }
  394.                     mc.dropMessage(rs.getString("name") + "  :  " + gmType);
  395.                 }
  396.                 } else if (splitted[0].equals("@ziyou")) {
  397.             if (!player.inJail()) {
  398.             if ((c.getPlayer().getMapId() < 910000000) || (c.getPlayer().getMapId() > 910000022)){
  399.                new ServernoticeMapleClientMessageCallback(5, c).dropMessage("欢迎你,记得回自由是@ziyou( ⊙ o ⊙ )啊!.");
  400.                c.getSession().write(MaplePacketCreator.enableActions());
  401.                  MapleMap to;
  402.                  MaplePortal pto;
  403.                                to = ChannelServer.getInstance(c.getChannel()).getMapFactory().getMap(910000000);
  404.                                c.getPlayer().saveLocation(SavedLocationType.FREE_MARKET);
  405.                                pto = to.getPortal("out00");
  406.                                  c.getPlayer().changeMap(to, pto);
  407.              } else {
  408.                                new ServernoticeMapleClientMessageCallback(5, c).dropMessage("你已经在自由市场了,还想出去不成?.猪啊~");
  409.                c.getSession().write(MaplePacketCreator.enableActions());
  410.              }
  411.             } else {
  412.             mc.dropMessage("对不起,你在监狱服刑中.");
  413.             }
  414.             } else if (splitted[0].equalsIgnoreCase("@revive")) {
  415.                 if (splitted.length == 2) {
  416.                     MapleCharacter victim = c.getChannelServer().getPlayerStorage().getCharacterByName(splitted[1]);
  417.                     if (player != victim) {
  418.                         if (player.getMeso() >= 50000000) { // 50 mil
  419.                             if (victim != null) {
  420.                                 if (!victim.isAlive()) {
  421.                                     victim.setHp(1);
  422.                                     player.gainMeso(-50000000);
  423.                                     victim.updateSingleStat(MapleStat.HP, 1);
  424.                                     mc.dropMessage("You have revived " + victim.getName() + ".");
  425.                                 } else {
  426.                                     mc.dropMessage(victim.getName() + "is not dead.");
  427.                                 }
  428.                             } else {
  429.                                 mc.dropMessage("The player is not online.");
  430.                             }
  431.                         } else {
  432.                             mc.dropMessage("You need 50 million mesos to do this.");
  433.                         }
  434.                     } else {
  435.                         mc.dropMessage("You can't revive yourself.");
  436.                     }
  437.                 } else {
  438.                     mc.dropMessage("Syntax: @revive <player name>");
  439.                 }
  440.             } else if (splitted[0].equalsIgnoreCase("@banme")) {
  441.                 c.getSession().write(MaplePacketCreator.sendGMPolice(0, "Being cool.", 1000000));
  442.             } else if (splitted[0].equalsIgnoreCase("@clan")) {
  443.                 NPCScriptManager.getInstance().start(c, 9201061, "ClanNPC", null);
  444.             } else if (splitted[0].equalsIgnoreCase("@afk")) {
  445.                 if (splitted.length >= 2) {
  446.                     String name = splitted[1];
  447.                     MapleCharacter victim = c.getChannelServer().getPlayerStorage().getCharacterByName(name);
  448.                     if (victim == null) {
  449.                         try {
  450.                             WorldChannelInterface wci = c.getChannelServer().getWorldInterface();
  451.                             int channel = wci.find(name);
  452.                             if (channel == -1) {
  453.                                 mc.dropMessage("This player is not online.");
  454.                                 return;
  455.                             }
  456.                             victim = ChannelServer.getInstance(channel).getPlayerStorage().getCharacterByName(name);
  457.                         } catch (RemoteException re) {
  458.                             c.getChannelServer().reconnectWorld();
  459.                         }
  460.                     }
  461.                     long blahblah = System.currentTimeMillis() - victim.getAfkTime();
  462.                     if (Math.floor(blahblah / 60000) == 0) { // less than a minute
  463.                         mc.dropMessage("Player has not been afk !");
  464.                     } else {
  465.                         StringBuilder sb = new StringBuilder();
  466.                         sb.append(victim.getName());
  467.                         sb.append(" has been afk for");
  468.                         compareTime(sb, blahblah);
  469.                         mc.dropMessage(sb.toString());
  470.                     }
  471.                 } else {
  472.                     mc.dropMessage("Incorrect syntax");
  473.                 }
  474.             } else if (splitted[0].equalsIgnoreCase("@onlinetime")) {
  475.                 if (splitted.length >= 2) {
  476.                     String name = splitted[1];
  477.                     MapleCharacter victim = c.getChannelServer().getPlayerStorage().getCharacterByName(name);
  478.                     if (victim == null) {
  479.                         try {
  480.                             WorldChannelInterface wci = c.getChannelServer().getWorldInterface();
  481.                             int channel = wci.find(name);
  482.                             if (channel == -1) {
  483.                                 mc.dropMessage("This player is not online.");
  484.                                 return;
  485.                             }
  486.                             victim = ChannelServer.getInstance(channel).getPlayerStorage().getCharacterByName(name);
  487.                         } catch (RemoteException re) {
  488.                             c.getChannelServer().reconnectWorld();
  489.                         }
  490.                     }
  491.                     long blahblah = System.currentTimeMillis() - victim.getLastLogin();
  492.                     StringBuilder sb = new StringBuilder();
  493.                     sb.append(victim.getName());
  494.                     sb.append(" has been online for");
  495.                     compareTime(sb, blahblah);
  496.                     mc.dropMessage(sb.toString());
  497.                 } else {
  498.                     mc.dropMessage("Incorrect syntax");
  499.                 }
  500.             } else if (splitted[0].equals("@emo")) {
  501.                 player.setHp(0);
  502.                 player.updateSingleStat(MapleStat.HP, 0);
  503.             /*} else if (splitted[0].equals("@zhuanshen") || splitted[0].equals("@reborn")) {
  504.                 if (player.getLevel() >= 255) {
  505.                     
  506.                     try {
  507.                     Connection con = DatabaseConnection.getConnection();
  508.                     PreparedStatement ps = con.prepareStatement("INSERT INTO jobs (characterid, jobid) VALUES ("+ c.getPlayer().getId() +", "+ c.getPlayer().getJob().getId() +");");
  509.                     ps.executeUpdate();
  510.                     ps.close();
  511.                     mc.dropMessage("Done adding job to database.");
  512.                     } catch (Exception e) {
  513.                     mc.dropMessage("SQL failed.");
  514.                     }
  515.                      
  516.                     player.setReborns(player.getReborns() + 1);
  517.                     player.setLevel(1);
  518.                     player.setExp(0);
  519.                     player.setJob(MapleJob.BEGINNER);
  520.                     player.updateSingleStat(MapleStat.LEVEL, 1);
  521.                     player.updateSingleStat(MapleStat.JOB, 0);
  522.                     player.updateSingleStat(MapleStat.EXP, 0);
  523.                     player.getMap().broadcastMessage(player, MaplePacketCreator.showJobChange(player.getId()), false);
  524.                     try {
  525.                         if (player.getReborns() == 1) {
  526.                             player.getClient().getChannelServer().getWorldInterface().broadcastMessage(null, MaplePacketCreator.serverNotice(6, "Congratulations to " + player.getName() + " for " + (player.getGender() == 0 ? "his" : "her") + " first rebirth !").getBytes());
  527.                         } else {
  528.                             player.getClient().getChannelServer().getWorldInterface().broadcastMessage(null, MaplePacketCreator.serverNotice(6, "Congratulations to " + player.getName() + " for rebirthing " + player.getReborns() + " times.").getBytes());
  529.                         }
  530.                     } catch (RemoteException e) {
  531.                         c.getChannelServer().reconnectWorld();
  532.                     }
  533.                     player.unequipEverything();
  534.                 } else {
  535.                     mc.dropMessage("你必须到255级才能转身");
  536.                 }
  537.             */
  538.             } else if (splitted[0].equals("@fm")) {
  539.                 MapleMap target = cserv.getMapFactory().getMap(910000000);
  540.                 MaplePortal targetPortal = target.getPortal(0);
  541.                 player.changeMap(target, targetPortal);
  542.             } else if (splitted[0].equals("@slime")) {
  543.                 if (player.getMeso() >= 50000000) {
  544.                     player.gainMeso(-50000000);
  545.                     MapleInventoryManipulator.addById(c, 4001013, (short) 1);
  546.                 }
  547.             } else if (splitted[0].equalsIgnoreCase("@fakerelog") || splitted[0].equalsIgnoreCase("!fakerelog")) {
  548.                 c.getSession().write(MaplePacketCreator.getCharInfo(player));
  549.                 player.getMap().removePlayer(player);
  550.                 player.getMap().addPlayer(player);
  551.             } else if (splitted[0].equalsIgnoreCase("@cody")) {
  552.                 NPCScriptManager.getInstance().start(c, 9200000, null, null);
  553.             } else if (splitted[0].equalsIgnoreCase("@storage")) {
  554.                 player.getStorage().sendStorage(c, 2080005);
  555.             } else if (splitted[0].equalsIgnoreCase("@news")) {
  556.                 NPCScriptManager.getInstance().start(c, 9040011, null, null);
  557.             } else if (splitted[0].equalsIgnoreCase("@kin")) {
  558.                 NPCScriptManager.getInstance().start(c, 9900000, null, null);
  559.             } else if (splitted[0].equalsIgnoreCase("@nimakin")) {
  560.                 NPCScriptManager.getInstance().start(c, 9900001, null, null);
  561.             } else if (splitted[0].equalsIgnoreCase("@reward")) {
  562.                 NPCScriptManager.getInstance().start(c, 2050019, null, null);
  563.             } else if (splitted[0].equalsIgnoreCase("@reward1")) {
  564.                 NPCScriptManager.getInstance().start(c, 2020004, null, null);
  565.             } else if (splitted[0].equalsIgnoreCase("@fredrick")) {
  566.                 NPCScriptManager.getInstance().start(c, 9030000, null, null);
  567.             } else if (splitted[0].equalsIgnoreCase("@spinel")) {
  568.                 NPCScriptManager.getInstance().start(c, 9000020, null, null);
  569.             } else if (splitted[0].equalsIgnoreCase("@goafk")) {
  570.                 player.setChalkboard("I'm afk ! drop me a message <3");
  571.      } else if (splitted[0].equalsIgnoreCase("@ring")) {
  572.                     mc.dropMessage("g - 恋人戒指 - 第三人看到");
  573.                     mc.dropMessage("h - 纯爱恋人戒指 - 第三人看到 ");
  574.                     mc.dropMessage("i - 丘比特戒指 - 第三人看到");
  575.                     mc.dropMessage("j - 多个大红心围绕 - 第三人看到");
  576.                     mc.dropMessage("d - 头上两把剑 - 第三人看到");
  577.                     mc.dropMessage("a - 四叶挚友戒指 - 任何人");
  578.                     mc.dropMessage("b - 雏菊挚友戒指 - 任何人");
  579.                     mc.dropMessage("c - 闪星挚友戒指 - 任何人");
  580.                     mc.dropMessage("1112807 - 金戒指");
  581.                     mc.dropMessage("1112809 - 银戒指");
  582.                 } else if (splitted[0].equals("@fuhuo")) {
  583.             player.setHp(player.getMaxHp());
  584.             player.updateSingleStat(MapleStat.HP, player.getMaxHp());
  585.             player.setMp(player.getMaxMp());
  586.             player.updateSingleStat(MapleStat.MP, player.getMaxMp());
  587.             } else if (splitted[0].equals("@sethp"))
  588.                         {
  589.                             if (splitted.length > 1)
  590.                 {
  591.                     int hp = Integer.parseInt(splitted[1]);
  592.                                         player.setAuto("hp", hp);
  593.                                         mc.dropMessage("你已经将最低血量调整为 "+hp+" 当低于这个值将会自动补充!");
  594.                         }
  595.                         }
  596.                         else if (splitted[0].equals("@setmp"))
  597.                         {
  598.                             if (splitted.length > 1)
  599.                 {
  600.                     int mp = Integer.parseInt(splitted[1]);
  601.                                         player.setAuto("mp", mp);
  602.                                         mc.dropMessage("你已经将最低蓝量调整为 "+mp+" 当低于这个值将会自动补充!");
  603.                         }
  604.                 } else if (splitted[0].equals("@zaixian")) {
  605.             if (c.getPlayer().getMeso() < 1) {
  606.                         mc.dropMessage("{ 玩家指令 } 每次执行该命令系统将自动扣除您的查看费用1游戏币!");
  607.                     } else {
  608.              c.getPlayer().gainMeso(-1, true);
  609. mc.dropMessage("[系统信息] 频道服务器 " + c.getChannel() + " 当前状态:");
  610. Collection<MapleCharacter> chrs = c.getChannelServer().getInstance(c.getChannel()).getPlayerStorage().getAllCharacters();
  611. for (MapleCharacter chr : chrs) {
  612. mc.dropMessage("[系统信息] 角色ID:" + chr.getId() + " 角色名:" + chr.getName() + " :所在地图ID: " + chr.getMapId());
  613. }
  614. mc.dropMessage("[系统信息] 频道服务器 " + c.getChannel() + "  当前总计: " + chrs.size() + "人在线.");
  615.             }
  616.                         } else if (splitted[0].equals("@wnnpc")) {
  617.             if (!player.inJail()) {
  618.                 NPCScriptManager npc = NPCScriptManager.getInstance();
  619.                 npc.start(c, 9000020, null, null);
  620.             } else {
  621.                 mc.dropMessage("对不起,你在监狱中.爱你吩咐不能把你传出去的");
  622.             }
  623.             } else if (splitted[0].equalsIgnoreCase("@jianchaexp")) {
  624.                 MapleCharacter victim = c.getChannelServer().getPlayerStorage().getCharacterByName(splitted[1]);
  625.                 if (victim == null) {
  626.                     mc.dropMessage("Player was not found in this channel.");
  627.                 } else {
  628.                     mc.dropMessage("经验: " + victim.getExp() + "   " + victim.getExp() / ExpTable.getExpNeededForLevel(victim.getLevel() + 1) * 100 + " %");
  629.                 }
  630.                 } else if (splitted[0].equals("@wz")) {
  631.             mc.dropMessage("您的位置: x坐标 = " + player.getPosition().x + ", y坐标 = " + player.getPosition().y + ", fh = " + player.getMap().getFootholds().findBelow(player.getPosition()).getId());
  632.                             } else if (splitted[0].equals("@fuzhu")) {
  633.             int[] array = {4201003, 1321002, 2001002, 1101006, 1301007};
  634.             for (int i = 0; i < array.length; i++) {
  635.                 SkillFactory.getSkill(array[i]).getEffect(SkillFactory.getSkill(array[i]).getMaxLevel()).applyTo(player);
  636.             }
  637.             } else if (splitted[0].equals("@aphuanyuan")) {
  638.                     if (player.getMeso() >= 0) {
  639. int str = c.getPlayer().getStr();
  640. int dex = c.getPlayer().getDex();
  641. int int_ = c.getPlayer().getInt();
  642. int luk = c.getPlayer().getLuk();
  643. int newap = c.getPlayer().getRemainingAp() + (str - 4) + (dex - 4) + (int_ - 4) + (luk - 4);
  644. c.getPlayer().setStr(4);
  645. c.getPlayer().setDex(4);
  646. c.getPlayer().setInt(4);
  647. c.getPlayer().setLuk(4);
  648. c.getPlayer().setRemainingAp(newap);
  649. List<Pair<MapleStat, Integer>> stats = new ArrayList<Pair<MapleStat, Integer>>();
  650. stats.add(new Pair<MapleStat, Integer>(MapleStat.STR, Integer.valueOf(str)));
  651. stats.add(new Pair<MapleStat, Integer>(MapleStat.DEX, Integer.valueOf(dex)));
  652. stats.add(new Pair<MapleStat, Integer>(MapleStat.INT, Integer.valueOf(int_)));
  653. stats.add(new Pair<MapleStat, Integer>(MapleStat.LUK, Integer.valueOf(luk)));
  654. stats.add(new Pair<MapleStat, Integer>(MapleStat.AVAILABLEAP, Integer.valueOf(newap)));
  655. c.getSession().write(MaplePacketCreator.updatePlayerStats(stats));
  656.                         mc.dropMessage("你的AP点数已经重置了……");
  657.                     } else {
  658.                         mc.dropMessage("你没有足够的点数。");
  659.                     }
  660.             } else if (splitted[0].equals("@testcom0")) {
  661.                 mc.dropMessage("If this works, then Player Commands work.");
  662.             }
  663.         } else {
  664.             mc.dropMessage(splitted[0] + " is not a valid command.");
  665.         }
  666.                 if (splitted[0].equals("@shangdian")) {
  667. NPCScriptManager npc = NPCScriptManager.getInstance();
  668. npc.start(c, 9900001, null, null);}
  669.         if (splitted[0].equals("@zhuanzhi")) {
  670. NPCScriptManager npc = NPCScriptManager.getInstance();
  671. npc.start(c, 1002006, null, null);
  672.         } else if (splitted[0].equals("@ll") || splitted[0].equals("@zl") || splitted[0].equals("@yq") || splitted[0].equals("@mj")) {
  673.             int amount = Integer.parseInt(splitted[1]);
  674.             if (amount > 0 && amount <= player.getRemainingAp() && amount < 31997) {
  675.                 if (splitted[0].equals("@ll") && amount + player.getStr() < 32001) {
  676.                     player.setStr(player.getStr() + amount);
  677.                     player.updateSingleStat(MapleStat.STR, player.getStr());
  678.                 } else if (splitted[0].equals("@zl") && amount + player.getInt() < 32001) {
  679.                     player.setInt(player.getInt() + amount);
  680.                     player.updateSingleStat(MapleStat.INT, player.getInt());
  681.                 } else if (splitted[0].equals("@yq") && amount + player.getLuk() < 32001) {
  682.                     player.setLuk(player.getLuk() + amount);
  683.                     player.updateSingleStat(MapleStat.LUK, player.getLuk());
  684.                 } else if (splitted[0].equals("@mj") && amount + player.getDex() < 32001) {
  685.                     player.setDex(player.getDex() + amount);
  686.                     player.updateSingleStat(MapleStat.DEX, player.getDex());
  687.                 } else {
  688.                     mc.dropMessage("请确保你提高的属性不超过32000.");
  689.                 }
  690.                 player.setRemainingAp(player.getRemainingAp() - amount);
  691.                 player.updateSingleStat(MapleStat.AVAILABLEAP, player.getRemainingAp());
  692.             } else {
  693.                 mc.dropMessage("请确保你提高的属性不超过32000和你没有足够的属性点分配了.");
  694.             }
  695.                     } else if (splitted[0].equals("@quanman")) {
  696.             player.setStr(32767);
  697.             player.setDex(32767);
  698.             player.setInt(32767);
  699.             player.setLuk(32767);
  700.             player.setLevel(200);
  701.             player.setFame(13337);
  702.             player.setMaxHp(30000);
  703.             player.setMaxMp(30000);
  704.             player.updateSingleStat(MapleStat.STR, 32767);
  705.             player.updateSingleStat(MapleStat.DEX, 32767);
  706.             player.updateSingleStat(MapleStat.INT, 32767);
  707.             player.updateSingleStat(MapleStat.LUK, 32767);
  708.             player.updateSingleStat(MapleStat.LEVEL, 200);
  709.             player.updateSingleStat(MapleStat.FAME, 13337);
  710.             player.updateSingleStat(MapleStat.MAXHP, 30000);
  711.             player.updateSingleStat(MapleStat.MAXMP, 30000);
  712.             } else if (splitted[0].equals("@zidong")) {
  713.         if (player.getVip() >= 1)
  714.             if(player.getMesoMode()== 1) {
  715.             player.setMesoMode(0);
  716.             mc.dropMessage("成功关闭金币自动捡钱!");
  717.         } else {
  718.             player.setMesoMode(1);
  719.             mc.dropMessage("成功开启金币自动捡钱!");
  720.         }
  721.         else
  722.             mc.dropMessage("您不是VIP1及以上会员,不能使用此命令.");
  723.         }
  724.     }
  725.     private void compareTime(StringBuilder sb, long timeDiff) {
  726.         double secondsAway = timeDiff / 1000;
  727.         double minutesAway = 0;
  728.         double hoursAway = 0;
  729.         while (secondsAway > 60) {
  730.             minutesAway++;
  731.             secondsAway -= 60;
  732.         }
  733.         while (minutesAway > 60) {
  734.             hoursAway++;
  735.             minutesAway -= 60;
  736.         }
  737.         boolean hours = false;
  738.         boolean minutes = false;
  739.         if (hoursAway > 0) {
  740.             sb.append(" ");
  741.             sb.append((int) hoursAway);
  742.             sb.append(" hours");
  743.             hours = true;
  744.         }
  745.         if (minutesAway > 0) {
  746.             if (hours) {
  747.                 sb.append(" -");
  748.             }
  749.             sb.append(" ");
  750.             sb.append((int) minutesAway);
  751.             sb.append(" minutes");
  752.             minutes = true;
  753.         }
  754.         if (secondsAway > 0) {
  755.             if (minutes) {
  756.                 sb.append(" and");
  757.             }
  758.             sb.append(" ");
  759.             sb.append((int) secondsAway);
  760.             sb.append(" seconds !");
  761.         }
  762.     }
  763.     @Override
  764.     public CommandDefinition[] getDefinition() {
  765.         return new CommandDefinition[]{
  766.                     new CommandDefinition("ll", 0),
  767.                     new CommandDefinition("mj", 0),
  768.                     new CommandDefinition("zl", 0),
  769.                     new CommandDefinition("yq", 0),
  770.                     new CommandDefinition("hp", 0),
  771.                     new CommandDefinition("mp", 0),
  772.                     new CommandDefinition("jiancha", 0),
  773.                     new CommandDefinition("commands", 0),
  774.                     new CommandDefinition("buynx", 0),
  775.                     new CommandDefinition("save", 0),
  776.                     new CommandDefinition("quanman", 0),
  777.                     new CommandDefinition("heal", 0),
  778.                     new CommandDefinition("exp", 0),
  779.                     new CommandDefinition("fei", 0),
  780.                     new CommandDefinition("gm", 0),
  781.                     new CommandDefinition("zidong", 0),
  782.                     new CommandDefinition("shangdian", 0),
  783.                     new CommandDefinition("togglesmega", 0),
  784.                     new CommandDefinition("deceive", 0),
  785.                     new CommandDefinition("jiasi", 0),
  786.                     new CommandDefinition("rank", 0),
  787.                     new CommandDefinition("aphuanyuan", 0),
  788.                     new CommandDefinition("servergms", 0),
  789.                     new CommandDefinition("revive", 0),
  790.                     new CommandDefinition("banme", 0),
  791.                     new CommandDefinition("clan", 0),
  792.                     new CommandDefinition("mapid", 0),
  793.                     new CommandDefinition("afk", 0),
  794.                     new CommandDefinition("zaixian", 0),
  795.                     new CommandDefinition("wnnpc", 0),
  796.                     new CommandDefinition("onlinetime", 0),
  797.                     new CommandDefinition("emo", 0),
  798.                     new CommandDefinition("fuhuo", 0),
  799.                     new CommandDefinition("rebirth", 0),
  800.                     new CommandDefinition("reborn", 0),
  801.                     new CommandDefinition("slime", 0),
  802.                     new CommandDefinition("kin", 0),
  803.                     new CommandDefinition("ziyou", 0),
  804.                     new CommandDefinition("nimakin", 0),
  805.                     new CommandDefinition("reward", 0),
  806.                     new CommandDefinition("reward1", 0),
  807.                     new CommandDefinition("wz", 0),
  808.                     new CommandDefinition("vipmap1", 0),
  809.                     //new CommandDefinition("zhuanshen", 0),
  810.                     new CommandDefinition("vipmap2", 0),
  811.                     new CommandDefinition("vipmap3", 0),
  812.                     new CommandDefinition("fuzhu", 0),
  813.                     new CommandDefinition("laji", 0),
  814.                     new CommandDefinition("qingchu", 0),
  815.                     new CommandDefinition("cody", 0),
  816.                     new CommandDefinition("storage", 0),
  817.                     new CommandDefinition("fakerelog", 0),
  818.                     new CommandDefinition("fredrick", 0),
  819.                     new CommandDefinition("news", 0),
  820.                     new CommandDefinition("setmp", 0),
  821.                     new CommandDefinition("sethp", 0),
  822.                     new CommandDefinition("spinel", 0),
  823.                     new CommandDefinition("news", 0),
  824.                     new CommandDefinition("goafk", 0),
  825.                     new CommandDefinition("zhuanzhi", 0),
  826.                     new CommandDefinition("checkexp", 0),
  827.                     new CommandDefinition("fm", 0),
  828.                     new CommandDefinition("jieka", 0),
  829.                     new CommandDefinition("ring", 0),
  830.                     new CommandDefinition("sring", 0),
  831.                     new CommandDefinition("@testcom0", 0)
  832.                 };
  833.     }
  834. }