Intern.java
上传用户:gwt600
上传日期:2021-06-03
资源大小:704k
文件大小:12k
- /*
- This file is part of the OdinMS Maple Story Server
- Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
- Matthias Butz <matze@odinms.de>
- Jan Christian Meyer <vimes@odinms.de>
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License version 3
- as published by the Free Software Foundation. You may not use, modify
- or distribute this program under any other version of the
- GNU Affero General Public License.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; withnout even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- package net.sf.odinms.client.messages.commands;
- import java.rmi.RemoteException;
- import net.sf.odinms.client.MapleCharacter;
- import net.sf.odinms.client.MapleClient;
- import net.sf.odinms.client.MapleStat;
- import net.sf.odinms.client.messages.Command;
- import net.sf.odinms.client.messages.MessageCallback;
- import net.sf.odinms.tools.MaplePacketCreator;
- import net.sf.odinms.net.channel.ChannelServer;
- import java.util.Collection;
- import java.util.List;
- import net.sf.odinms.client.MapleCharacterUtil;
- import net.sf.odinms.client.SkillFactory;
- import net.sf.odinms.net.world.remote.CheaterData;
- import net.sf.odinms.server.MaplePortal;
- import net.sf.odinms.server.maps.MapleMap;
- import net.sf.odinms.client.messages.CommandDefinition;
- import net.sf.odinms.client.messages.ServernoticeMapleClientMessageCallback;
- import net.sf.odinms.tools.StringUtil;
- public class Intern implements Command {
-
- @Override
- public void execute(MapleClient c, MessageCallback mc, String[] splitted) throws Exception {
- ChannelServer cserv = c.getChannelServer();
- Collection<ChannelServer> cservs = ChannelServer.getAllInstances();
- MapleCharacter player = c.getPlayer();
- splitted[0] = splitted[0].toLowerCase();
- if (splitted[0].equals("#hide")) {
- SkillFactory.getSkill(9101004).getEffect(1).applyTo(player);
- } else if (splitted[0].equals("#back2")) {
- MapleMap target = cserv.getMapFactory().getMap(100000000);
- MaplePortal targetPortal = target.getPortal(0);
- player.changeMap(target, targetPortal);
- } else if (splitted[0].equals("#mapvip")) {
- MapleMap target = cserv.getMapFactory().getMap(209000000);
- MaplePortal targetPortal = target.getPortal(0);
- player.changeMap(target, targetPortal);
- } else if (splitted[0].equals("#online")) { // testing
- MessageCallback callback = new ServernoticeMapleClientMessageCallback(c);
- StringBuilder builder = new StringBuilder("在线玩家: ");
- for (MapleCharacter chr : cserv.getPlayerStorage().getAllCharacters()) {
- if (builder.length() > 150) {
- builder.setLength(builder.length() - 2);
- callback.dropMessage(builder.toString());
- builder = new StringBuilder();
- }
- builder.append(MapleCharacterUtil.makeMapleReadable(chr.getName()));
- builder.append("[");
- builder.append(MapleCharacterUtil.makeMapleReadable((new StringBuilder()).append(chr.getId()).append("]").toString()));
- builder.append(", ");
- }
- builder.setLength(builder.length() - 2);
- c.getSession().write(MaplePacketCreator.serverNotice(6, builder.toString()));
- } else if (splitted[0].equals("#whosthere")) {
- MessageCallback callback = new ServernoticeMapleClientMessageCallback(c);
- StringBuilder builder = new StringBuilder("Players on Map: ");
- for (MapleCharacter chr : c.getPlayer().getMap().getCharacters()) {
- if (builder.length() > 150) { // wild guess :o
- builder.setLength(builder.length() - 2);
- callback.dropMessage(builder.toString());
- builder = new StringBuilder();
- }
- builder.append(MapleCharacterUtil.makeMapleReadable(chr.getName()));
- builder.append(MapleCharacterUtil.makeMapleReadable((new StringBuilder()).append(chr.getId()).append(":").toString()));
- builder.append(", ");
- }
- builder.setLength(builder.length() - 2);
- c.getSession().write(MaplePacketCreator.serverNotice(6, builder.toString()));
- } else if (splitted[0].equals("#cheaters")) {
- try {
- List<CheaterData> cheaters = c.getChannelServer().getWorldInterface().getCheaters();
- for (int x = cheaters.size() - 1; x >= 0; x--) {
- CheaterData cheater = cheaters.get(x);
- mc.dropMessage(cheater.getInfo());
- }
- } catch (RemoteException e) {
- c.getChannelServer().reconnectWorld();
- }
- } else if (splitted[0].equals("#warp")) {
- if (splitted.length == 2) {
- try {
- MapleCharacter victim = cserv.getPlayerStorage().getCharacterById(Integer.parseInt(splitted[1]));
- if (victim != null) {
- MapleMap target = victim.getMap();
- c.getPlayer().changeMap(target, target.findClosestSpawnpoint(victim.getPosition()));
- } else {
- mc.dropMessage("找不到该玩家的ID");
- }
- } catch (Exception e) {
- mc.dropMessage("出错了");
- }
- } else {
- mc.dropMessage("指令用法:!warp2 玩家ID");
- }
- } else if (splitted[0].equals("#warp2")) {
- if (splitted.length == 2) {
- try {
- MapleCharacter victim = cserv.getPlayerStorage().getCharacterByName(splitted[1]);
- if (victim != null) {
- MapleMap target = victim.getMap();
- c.getPlayer().changeMap(target, target.findClosestSpawnpoint(victim.getPosition()));
- } else {
- mc.dropMessage("找不到该玩家的名字");
- }
- } catch (Exception e) {
- mc.dropMessage("出错了");
- }
- } else {
- mc.dropMessage("指令用法:!warp3 玩家名字");
- }
- } else if (splitted[0].equals("#ban")) {
- String originalReason = StringUtil.joinStringFrom(splitted, 2);
- String reason = player.getName() + " banned " + splitted[1] + ": " + originalReason;
- MapleCharacter target = cserv.getPlayerStorage().getCharacterById(Integer.parseInt(splitted[1]));
- if (target != null) {
- if (!target.isGM() || player.getGMLevel() > 3) {
- String readableTargetName = MapleCharacterUtil.makeMapleReadable(target.getName());
- String ip = target.getClient().getSession().getRemoteAddress().toString().split(":")[0];
- reason += " IP: " + ip;
- target.ban(reason, false);
- try {
- cserv.getWorldInterface().broadcastMessage(null, MaplePacketCreator.serverNotice(6, readableTargetName + " has been banned for " + originalReason).getBytes());
- } catch (RemoteException e) {
- cserv.reconnectWorld();
- }
- } else {
- mc.dropMessage("Please dont ban " + cserv.getServerName() + " GMs");
- }
- } else {
- if (MapleCharacter.ban(splitted[1], reason, false)) {
- String readableTargetName = MapleCharacterUtil.makeMapleReadable(target.getName());
- String ip = target.getClient().getSession().getRemoteAddress().toString().split(":")[0];
- reason += " (IP: " + ip + ")";
- try {
- cserv.getWorldInterface().broadcastMessage(null, MaplePacketCreator.serverNotice(6, readableTargetName + " has been banned for " + originalReason).getBytes());
- } catch (RemoteException e) {
- cserv.reconnectWorld();
- }
- } else {
- mc.dropMessage("Failed to ban " + splitted[1]);
- }
- }
- } else if (splitted[0].equals("#ban2")) {
- String originalReason = StringUtil.joinStringFrom(splitted, 2);
- String reason = player.getName() + " banned " + splitted[1] + ": " + originalReason;
- MapleCharacter target = cserv.getPlayerStorage().getCharacterByName(splitted[1]);
- if (target != null) {
- if (!target.isGM() || player.getGMLevel() > 3) {
- String readableTargetName = MapleCharacterUtil.makeMapleReadable(target.getName());
- String ip = target.getClient().getSession().getRemoteAddress().toString().split(":")[0];
- reason += " IP: " + ip;
- target.ban(reason, false);
- try {
- cserv.getWorldInterface().broadcastMessage(null, MaplePacketCreator.serverNotice(6, readableTargetName + " has been banned for " + originalReason).getBytes());
- } catch (RemoteException e) {
- cserv.reconnectWorld();
- }
- } else {
- mc.dropMessage("Please dont ban " + cserv.getServerName() + " GMs");
- }
- } else {
- if (MapleCharacter.ban(splitted[1], reason, false)) {
- String readableTargetName = MapleCharacterUtil.makeMapleReadable(target.getName());
- String ip = target.getClient().getSession().getRemoteAddress().toString().split(":")[0];
- reason += " (IP: " + ip + ")";
- try {
- cserv.getWorldInterface().broadcastMessage(null, MaplePacketCreator.serverNotice(6, readableTargetName + " has been banned for " + originalReason).getBytes());
- } catch (RemoteException e) {
- cserv.reconnectWorld();
- }
- } else {
- mc.dropMessage("Failed to ban " + splitted[1]);
- }
- }
- } else if (splitted[0].equals("#heal")) {
- player.setHp(player.getMaxHp());
- player.updateSingleStat(MapleStat.HP, player.getMaxHp());
- player.setMp(player.getMaxMp());
- player.updateSingleStat(MapleStat.MP, player.getMaxMp());
- } else if (splitted[0].equals("!testcom2")) {
- mc.dropMessage("If this works, then Intern Commands work.");
- }
- }
- @Override
- public CommandDefinition[] getDefinition() {
- return new CommandDefinition[]{
- new CommandDefinition("back2", 2, "传送到射手村."),
- new CommandDefinition("mapvip", 2, "传送到VIP地图"),
- new CommandDefinition("heal", 2, "血蓝全满"),
- new CommandDefinition("hide", 2, "隐身"),
- new CommandDefinition("online", 2, "查看在线玩家"),
- new CommandDefinition("whosthere", 2, "查看该地图的玩家"),
- new CommandDefinition("cheaters", 2, "查看玩家异常数据信息"),
- new CommandDefinition("warp", 2, "<玩家ID> - 传送到指定玩家身边"),
- new CommandDefinition("warp2", 2, "<玩家名字> - 传送到指定玩家身边"),
- new CommandDefinition("ban", 2, "<玩家ID> <封IP理由>"),
- new CommandDefinition("ban2", 2, "<玩家名字> <封IP理由>"),
- new CommandDefinition("testcom2", 2)
- };
- }
- }