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

游戏

开发平台:

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; withnout 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 net.sf.odinms.client.MapleCharacter;
  21. import net.sf.odinms.client.MapleClient;
  22. import net.sf.odinms.client.MapleStat;
  23. import net.sf.odinms.client.messages.Command;
  24. import net.sf.odinms.client.messages.MessageCallback;
  25. import net.sf.odinms.tools.MaplePacketCreator;
  26. import net.sf.odinms.net.channel.ChannelServer;
  27. import java.util.Collection;
  28. import java.util.List;
  29. import net.sf.odinms.client.MapleCharacterUtil;
  30. import net.sf.odinms.client.SkillFactory;
  31. import net.sf.odinms.net.world.remote.CheaterData;
  32. import net.sf.odinms.server.MaplePortal;
  33. import net.sf.odinms.server.maps.MapleMap;
  34. import net.sf.odinms.client.messages.CommandDefinition;
  35. import net.sf.odinms.client.messages.ServernoticeMapleClientMessageCallback;
  36. import net.sf.odinms.tools.StringUtil;
  37. public class Intern implements Command {
  38.     
  39.     @Override
  40.     public void execute(MapleClient c, MessageCallback mc, String[] splitted) throws Exception {
  41.         ChannelServer cserv = c.getChannelServer();
  42.         Collection<ChannelServer> cservs = ChannelServer.getAllInstances();
  43.         MapleCharacter player = c.getPlayer();
  44.         splitted[0] = splitted[0].toLowerCase();
  45.         if (splitted[0].equals("#hide")) {
  46.             SkillFactory.getSkill(9101004).getEffect(1).applyTo(player);
  47.         } else if (splitted[0].equals("#back2")) {
  48.             MapleMap target = cserv.getMapFactory().getMap(100000000);
  49.             MaplePortal targetPortal = target.getPortal(0);
  50.             player.changeMap(target, targetPortal);
  51.         } else if (splitted[0].equals("#mapvip")) {
  52.             MapleMap target = cserv.getMapFactory().getMap(209000000);
  53.             MaplePortal targetPortal = target.getPortal(0);
  54.             player.changeMap(target, targetPortal);
  55.         } else if (splitted[0].equals("#online")) { // testing
  56.             MessageCallback callback = new ServernoticeMapleClientMessageCallback(c);
  57.             StringBuilder builder = new StringBuilder("在线玩家: ");
  58.             for (MapleCharacter chr : cserv.getPlayerStorage().getAllCharacters()) {
  59.                 if (builder.length() > 150) {
  60.                     builder.setLength(builder.length() - 2);
  61.                     callback.dropMessage(builder.toString());
  62.                     builder = new StringBuilder();
  63.                 }
  64.                 builder.append(MapleCharacterUtil.makeMapleReadable(chr.getName()));
  65.                 builder.append("[");
  66.                 builder.append(MapleCharacterUtil.makeMapleReadable((new StringBuilder()).append(chr.getId()).append("]").toString()));
  67.                 builder.append(", ");
  68.             }
  69.             builder.setLength(builder.length() - 2);
  70.             c.getSession().write(MaplePacketCreator.serverNotice(6, builder.toString()));
  71.         } else if (splitted[0].equals("#whosthere")) {
  72.             MessageCallback callback = new ServernoticeMapleClientMessageCallback(c);
  73.             StringBuilder builder = new StringBuilder("Players on Map: ");
  74.             for (MapleCharacter chr : c.getPlayer().getMap().getCharacters()) {
  75.                 if (builder.length() > 150) { // wild guess :o
  76.                     builder.setLength(builder.length() - 2);
  77.                     callback.dropMessage(builder.toString());
  78.                     builder = new StringBuilder();
  79.                 }
  80.                 builder.append(MapleCharacterUtil.makeMapleReadable(chr.getName()));
  81.                 builder.append(MapleCharacterUtil.makeMapleReadable((new StringBuilder()).append(chr.getId()).append(":").toString()));
  82.                 builder.append(", ");
  83.             }
  84.             builder.setLength(builder.length() - 2);
  85.             c.getSession().write(MaplePacketCreator.serverNotice(6, builder.toString()));
  86.         } else if (splitted[0].equals("#cheaters")) {
  87.             try {
  88.                 List<CheaterData> cheaters = c.getChannelServer().getWorldInterface().getCheaters();
  89.                 for (int x = cheaters.size() - 1; x >= 0; x--) {
  90.                     CheaterData cheater = cheaters.get(x);
  91.                     mc.dropMessage(cheater.getInfo());
  92.                 }
  93.             } catch (RemoteException e) {
  94.                 c.getChannelServer().reconnectWorld();
  95.             }
  96.         } else if (splitted[0].equals("#warp")) {
  97.             if (splitted.length == 2) {
  98.                 try {
  99.                     MapleCharacter victim = cserv.getPlayerStorage().getCharacterById(Integer.parseInt(splitted[1]));
  100.                     if (victim != null) {
  101.                         MapleMap target = victim.getMap();
  102.                         c.getPlayer().changeMap(target, target.findClosestSpawnpoint(victim.getPosition()));
  103.                     } else {
  104.                         mc.dropMessage("找不到该玩家的ID");
  105.                     }
  106.                 } catch (Exception e) {
  107.                     mc.dropMessage("出错了");
  108.                 }
  109.             } else {
  110.                 mc.dropMessage("指令用法:!warp2 玩家ID");
  111.             }
  112.         } else if (splitted[0].equals("#warp2")) {
  113.             if (splitted.length == 2) {
  114.                 try {
  115.                     MapleCharacter victim = cserv.getPlayerStorage().getCharacterByName(splitted[1]);
  116.                     if (victim != null) {
  117.                         MapleMap target = victim.getMap();
  118.                         c.getPlayer().changeMap(target, target.findClosestSpawnpoint(victim.getPosition()));
  119.                     } else {
  120.                         mc.dropMessage("找不到该玩家的名字");
  121.                     }
  122.                 } catch (Exception e) {
  123.                     mc.dropMessage("出错了");
  124.                 }
  125.             } else {
  126.                 mc.dropMessage("指令用法:!warp3 玩家名字");
  127.             }
  128.         } else if (splitted[0].equals("#ban")) {
  129.             String originalReason = StringUtil.joinStringFrom(splitted, 2);
  130.             String reason = player.getName() + " banned " + splitted[1] + ": " + originalReason;
  131.             MapleCharacter target = cserv.getPlayerStorage().getCharacterById(Integer.parseInt(splitted[1]));
  132.             if (target != null) {
  133.                 if (!target.isGM() || player.getGMLevel() > 3) {
  134.                     String readableTargetName = MapleCharacterUtil.makeMapleReadable(target.getName());
  135.                     String ip = target.getClient().getSession().getRemoteAddress().toString().split(":")[0];
  136.                     reason += "  IP: " + ip;
  137.                     target.ban(reason, false);
  138.                     try {
  139.                         cserv.getWorldInterface().broadcastMessage(null, MaplePacketCreator.serverNotice(6, readableTargetName + " has been banned for " + originalReason).getBytes());
  140.                     } catch (RemoteException e) {
  141.                         cserv.reconnectWorld();
  142.                     }
  143.                 } else {
  144.                     mc.dropMessage("Please dont ban " + cserv.getServerName() + " GMs");
  145.                 }
  146.             } else {
  147.                 if (MapleCharacter.ban(splitted[1], reason, false)) {
  148.                     String readableTargetName = MapleCharacterUtil.makeMapleReadable(target.getName());
  149.                     String ip = target.getClient().getSession().getRemoteAddress().toString().split(":")[0];
  150.                     reason += " (IP: " + ip + ")";
  151.                     try {
  152.                         cserv.getWorldInterface().broadcastMessage(null, MaplePacketCreator.serverNotice(6, readableTargetName + " has been banned for " + originalReason).getBytes());
  153.                     } catch (RemoteException e) {
  154.                         cserv.reconnectWorld();
  155.                     }
  156.                 } else {
  157.                     mc.dropMessage("Failed to ban " + splitted[1]);
  158.                 }
  159.             }
  160.         } else if (splitted[0].equals("#ban2")) {
  161.             String originalReason = StringUtil.joinStringFrom(splitted, 2);
  162.             String reason = player.getName() + " banned " + splitted[1] + ": " + originalReason;
  163.             MapleCharacter target = cserv.getPlayerStorage().getCharacterByName(splitted[1]);
  164.             if (target != null) {
  165.                 if (!target.isGM() || player.getGMLevel() > 3) {
  166.                     String readableTargetName = MapleCharacterUtil.makeMapleReadable(target.getName());
  167.                     String ip = target.getClient().getSession().getRemoteAddress().toString().split(":")[0];
  168.                     reason += "  IP: " + ip;
  169.                     target.ban(reason, false);
  170.                     try {
  171.                         cserv.getWorldInterface().broadcastMessage(null, MaplePacketCreator.serverNotice(6, readableTargetName + " has been banned for " + originalReason).getBytes());
  172.                     } catch (RemoteException e) {
  173.                         cserv.reconnectWorld();
  174.                     }
  175.                 } else {
  176.                     mc.dropMessage("Please dont ban " + cserv.getServerName() + " GMs");
  177.                 }
  178.             } else {
  179.                 if (MapleCharacter.ban(splitted[1], reason, false)) {
  180.                     String readableTargetName = MapleCharacterUtil.makeMapleReadable(target.getName());
  181.                     String ip = target.getClient().getSession().getRemoteAddress().toString().split(":")[0];
  182.                     reason += " (IP: " + ip + ")";
  183.                     try {
  184.                         cserv.getWorldInterface().broadcastMessage(null, MaplePacketCreator.serverNotice(6, readableTargetName + " has been banned for " + originalReason).getBytes());
  185.                     } catch (RemoteException e) {
  186.                         cserv.reconnectWorld();
  187.                     }
  188.                 } else {
  189.                     mc.dropMessage("Failed to ban " + splitted[1]);
  190.                 }
  191.             }
  192.         } else if (splitted[0].equals("#heal")) {
  193.             player.setHp(player.getMaxHp());
  194.             player.updateSingleStat(MapleStat.HP, player.getMaxHp());
  195.             player.setMp(player.getMaxMp());
  196.             player.updateSingleStat(MapleStat.MP, player.getMaxMp());
  197.         } else if (splitted[0].equals("!testcom2")) {
  198.             mc.dropMessage("If this works, then Intern Commands work.");
  199.         }
  200.     }
  201.     @Override
  202.     public CommandDefinition[] getDefinition() {
  203.         return new CommandDefinition[]{
  204.                     new CommandDefinition("back2", 2, "传送到射手村."),
  205.                     new CommandDefinition("mapvip", 2, "传送到VIP地图"),
  206.                     new CommandDefinition("heal", 2, "血蓝全满"),
  207.                     new CommandDefinition("hide", 2, "隐身"),
  208.                     new CommandDefinition("online", 2, "查看在线玩家"),
  209.                     new CommandDefinition("whosthere", 2, "查看该地图的玩家"),
  210.                     new CommandDefinition("cheaters", 2, "查看玩家异常数据信息"),
  211.                     new CommandDefinition("warp", 2, "<玩家ID> - 传送到指定玩家身边"),
  212.                     new CommandDefinition("warp2", 2, "<玩家名字> - 传送到指定玩家身边"),
  213.                     new CommandDefinition("ban", 2, "<玩家ID> <封IP理由>"),
  214.                     new CommandDefinition("ban2", 2, "<玩家名字> <封IP理由>"),
  215.                     new CommandDefinition("testcom2", 2)
  216.                 };
  217.     }
  218. }