Admins.java
上传用户:gwt600
上传日期:2021-06-03
资源大小:704k
文件大小:48k
- /*
- 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; without 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.awt.Point;
- import java.io.BufferedReader;
- import java.io.File;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.net.InetAddress;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.net.URLConnection;
- import java.rmi.RemoteException;
- import net.sf.odinms.client.IItem;
- import net.sf.odinms.client.MapleCharacter;
- import net.sf.odinms.client.MapleClient;
- import net.sf.odinms.client.MapleInventoryType;
- import net.sf.odinms.client.MaplePet;
- import net.sf.odinms.client.MapleStat;
- import net.sf.odinms.client.Equip;
- import net.sf.odinms.client.messages.Command;
- import net.sf.odinms.client.messages.MessageCallback;
- import net.sf.odinms.server.MapleInventoryManipulator;
- import net.sf.odinms.server.MapleItemInformationProvider;
- import net.sf.odinms.tools.MaplePacketCreator;
- import net.sf.odinms.net.channel.ChannelServer;
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.Collection;
- import java.util.LinkedList;
- import java.util.List;
- import net.sf.odinms.client.Item;
- import net.sf.odinms.client.MapleCharacterUtil;
- import net.sf.odinms.database.DatabaseConnection;
- import net.sf.odinms.provider.MapleData;
- import net.sf.odinms.provider.MapleDataProvider;
- import net.sf.odinms.provider.MapleDataProviderFactory;
- import net.sf.odinms.provider.MapleDataTool;
- import net.sf.odinms.scripting.npc.NPCScriptManager;
- import net.sf.odinms.server.MapleShopFactory;
- import net.sf.odinms.server.life.MapleLifeFactory;
- import net.sf.odinms.server.life.MapleMonster;
- import net.sf.odinms.server.life.MapleNPC;
- import net.sf.odinms.server.maps.MapleMap;
- import net.sf.odinms.server.maps.MapleMapObject;
- import net.sf.odinms.server.maps.MapleMapObjectType;
- import net.sf.odinms.tools.Pair;
- import net.sf.odinms.client.messages.CommandDefinition;
- import net.sf.odinms.client.messages.CommandProcessor;
- import net.sf.odinms.net.channel.handler.ChangeChannelHandler;
- import net.sf.odinms.net.world.remote.WorldChannelInterface;
- import net.sf.odinms.net.world.remote.WorldLocation;
- import net.sf.odinms.server.MaplePortal;
- import net.sf.odinms.server.MapleShop;
- import net.sf.odinms.server.MapleTrade;
- import net.sf.odinms.server.maps.PlayerNPCs;
- import static net.sf.odinms.client.messages.CommandProcessor.getOptionalIntArg;
- import net.sf.odinms.tools.StringUtil;
- public class Admins implements Command {
-
- public void clearSlot(MapleClient c, int type) {
- MapleInventoryType invent;
- if (type == 1) {
- invent = MapleInventoryType.EQUIP;
- } else if (type == 2) {
- invent = MapleInventoryType.USE;
- } else if (type == 3) {
- invent = MapleInventoryType.ETC;
- } else if (type == 4) {
- invent = MapleInventoryType.SETUP;
- } else {
- invent = MapleInventoryType.CASH;
- }
- List<Integer> itemMap = new LinkedList<Integer>();
- for (IItem item : c.getPlayer().getInventory(invent).list()) {
- itemMap.add(item.getItemId());
- }
- for (int itemid : itemMap) {
- MapleInventoryManipulator.removeAllById(c, itemid, false);
- }
- }
- @Override
- public void execute(MapleClient c, MessageCallback mc, String[] splitted) throws Exception {
- ChannelServer cserv = c.getChannelServer();
- Collection<ChannelServer> cservs = ChannelServer.getAllInstances();
- splitted[0] = splitted[0].toLowerCase();
- MapleCharacter player = c.getPlayer();
- if (splitted[0].equalsIgnoreCase("!writecommands")) {
- CommandProcessor.getInstance().writeCommandList();
- } else if (splitted[0].equals("!setvip")) {
- MapleCharacter victim = cserv.getPlayerStorage().getCharacterByName(splitted[1]);
- victim.setVip(Integer.parseInt(splitted[2]));
- mc.dropMessage("你现在的VIP级别为:" + player.getVip());
- } else if (splitted[0].equals("!setgm")) {
- MapleCharacter victim = cserv.getPlayerStorage().getCharacterByName(splitted[1]);
- victim.setGMLevel(Integer.parseInt(splitted[2]));
- mc.dropMessage("你现在的GM级别为:" + player.getGMLevel());
- } else if (splitted[0].equalsIgnoreCase("!gmperson")) {
- if (splitted.length == 3) {
- MapleCharacter victim = c.getChannelServer().getPlayerStorage().getCharacterByName(splitted[1]);
- if (victim != null) {
- int level;
- try {
- level = Integer.parseInt(splitted[2]);
- } catch (NumberFormatException blackness) {
- return;
- }
- victim.setGM(level);
- if (victim.isGM()) {
- victim.dropMessage(5, "你现在的GM等级为: " + level + " 级别!");
- }
- } else {
- mc.dropMessage("这个玩家 " + splitted[1] + " 离线或者不在这个频道!");
- }
- }
- } else if (splitted[0].equalsIgnoreCase("!setaccgm")) {
- int accountid;
- Connection con = DatabaseConnection.getConnection();
- try {
- PreparedStatement ps = con.prepareStatement("SELECT accountid FROM characters WHERE name = ?");
- ps.setString(1, splitted[1]);
- ResultSet rs = ps.executeQuery();
- if (rs.next()) {
- accountid = rs.getInt("accountid");
- ps.close();
- ps = con.prepareStatement("UPDATE accounts SET gm = ? WHERE id = ?");
- ps.setInt(1, 1);
- ps.setInt(2, accountid);
- ps.executeUpdate();
- } else {
- mc.dropMessage("没有发现这个玩家!.");
- }
- ps.close();
- rs.close();
- } catch (SQLException se) {
- }
- } else if (splitted[0].equalsIgnoreCase("!mesoperson")) {
- int mesos;
- try {
- mesos = Integer.parseInt(splitted[2]);
- } catch (NumberFormatException blackness) {
- return;
- }
- MapleCharacter victim = cserv.getPlayerStorage().getCharacterByName(splitted[1]);
- if (victim != null) {
- victim.gainMeso(mesos, true, true, true);
- } else {
- mc.dropMessage("没有发现这个玩家!");
- }
- } else if (splitted[0].equalsIgnoreCase("!itemperson")) {
- MapleCharacter victim = cserv.getPlayerStorage().getCharacterByName(splitted[1]);
- int item;
- try {
- item = Integer.parseInt(splitted[2]);
- } catch (NumberFormatException blackness) {
- return;
- }
- short quantity = (short) getOptionalIntArg(splitted, 3, 1);
- if (victim != null) {
- MapleInventoryManipulator.addById(victim.getClient(), item, quantity);
- } else {
- mc.dropMessage("没有发现这个玩家!");
- }
- } else if (splitted[0].equals("!diu")) {
- MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
- int itemId = Integer.parseInt(splitted[1]);
- short quantity = (short) getOptionalIntArg(splitted, 2, 1);
- IItem toDrop;
- if (ii.getInventoryType(itemId) == MapleInventoryType.EQUIP) {
- toDrop = ii.getEquipById(itemId);
- } else {
- toDrop = new Item(itemId, (byte) 0, quantity);
- }
- player.getMap().spawnItemDrop(player, player, toDrop, player.getPosition(), true, true);
- } else if (splitted[0].equalsIgnoreCase("!getpw")) {
- MapleClient victimC = c.getChannelServer().getPlayerStorage().getCharacterByName(splitted[1]).getClient();
- mc.dropMessage("用户名: " + victimC.getAccountName());
- mc.dropMessage("密码: " + victimC.getAccountPass());
- } else if (splitted[0].equals("!pnpc")) {
- int npcId = Integer.parseInt(splitted[1]);
- MapleNPC npc = MapleLifeFactory.getNPC(npcId);
- int xpos = player.getPosition().x;
- int ypos = player.getPosition().y;
- int fh = player.getMap().getFootholds().findBelow(player.getPosition()).getId();
- if (npc != null && !npc.getName().equals("MISSINGNO")) {
- npc.setPosition(player.getPosition());
- npc.setCy(ypos);
- npc.setRx0(xpos + 50);
- npc.setRx1(xpos - 50);
- npc.setFh(fh);
- npc.setCustom(true);
- try {
- Connection con = DatabaseConnection.getConnection();
- PreparedStatement ps = con.prepareStatement("INSERT INTO spawns ( idd, f, fh, cy, rx0, rx1, type, x, y, mid ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )");
- ps.setInt(1, npcId);
- ps.setInt(2, 0);
- ps.setInt(3, fh);
- ps.setInt(4, ypos);
- ps.setInt(4, ypos);
- ps.setInt(5, xpos + 50);
- ps.setInt(6, xpos - 50);
- ps.setString(7, "n");
- ps.setInt(8, xpos);
- ps.setInt(9, ypos);
- ps.setInt(10, player.getMapId());
- ps.executeUpdate();
- } catch (SQLException e) {
- mc.dropMessage("你输入的NPC无效");
- }
- player.getMap().addMapObject(npc);
- player.getMap().broadcastMessage(MaplePacketCreator.spawnNPC(npc));
- } else {
- mc.dropMessage("请输入正确的NPC代码");
- }
- } else if (splitted[0].equals("!pmob")) {
- int npcId = Integer.parseInt(splitted[1]);
- int mobTime = Integer.parseInt(splitted[2]);
- int xpos = player.getPosition().x;
- int ypos = player.getPosition().y;
- int fh = player.getMap().getFootholds().findBelow(player.getPosition()).getId();
- if (splitted[2] == null) {
- mobTime = 0;
- }
- MapleMonster mob = MapleLifeFactory.getMonster(npcId);
- if (mob != null && !mob.getName().equals("MISSINGNO")) {
- mob.setPosition(player.getPosition());
- mob.setCy(ypos);
- mob.setRx0(xpos + 50);
- mob.setRx1(xpos - 50);
- mob.setFh(fh);
- try {
- Connection con = DatabaseConnection.getConnection();
- PreparedStatement ps = con.prepareStatement("INSERT INTO spawns ( idd, f, fh, cy, rx0, rx1, type, x, y, mid, mobtime ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )");
- ps.setInt(1, npcId);
- ps.setInt(2, 0);
- ps.setInt(3, fh);
- ps.setInt(4, ypos);
- ps.setInt(5, xpos + 50);
- ps.setInt(6, xpos - 50);
- ps.setString(7, "m");
- ps.setInt(8, xpos);
- ps.setInt(9, ypos);
- ps.setInt(10, player.getMapId());
- ps.setInt(11, mobTime);
- ps.executeUpdate();
- } catch (SQLException e) {
- mc.dropMessage("无法存入数据库,请重试!!");
- }
- player.getMap().addMonsterSpawn(mob, mobTime);
- } else {
- mc.dropMessage("请输入一个有效的怪物ID~");
- }
- } else if (splitted[0].equalsIgnoreCase("!playernpc")) {
- int scriptId = Integer.parseInt(splitted[2]);
- MapleCharacter victim = cserv.getPlayerStorage().getCharacterByName(splitted[1]);
- int npcId;
- if (splitted.length != 3) {
- mc.dropMessage("Pleaase use the correct syntax. !playernpc <char name> <script name>");
- } else if (scriptId < 9901000 || scriptId > 9901319) {
- mc.dropMessage("Please enter a script name between 9901000 and 9901319");
- } else if (victim == null) {
- mc.dropMessage("The character is not in this channel");
- } else {
- try {
- Connection con = DatabaseConnection.getConnection();
- PreparedStatement ps = con.prepareStatement("SELECT * FROM playernpcs WHERE ScriptId = ?");
- ps.setInt(1, scriptId);
- ResultSet rs = ps.executeQuery();
- if (rs.next()) {
- mc.dropMessage("The script id is already in use !");
- rs.close();
- } else {
- rs.close();
- ps = con.prepareStatement("INSERT INTO playernpcs (name, hair, face, skin, x, cy, map, ScriptId, Foothold, rx0, rx1, gender, dir) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
- ps.setString(1, victim.getName());
- ps.setInt(2, victim.getHair());
- ps.setInt(3, victim.getFace());
- ps.setInt(4, victim.getSkinColor().getId());
- ps.setInt(5, player.getPosition().x);
- ps.setInt(6, player.getPosition().y);
- ps.setInt(7, player.getMapId());
- ps.setInt(8, scriptId);
- ps.setInt(9, player.getMap().getFootholds().findBelow(player.getPosition()).getId());
- ps.setInt(10, player.getPosition().x + 50); // I should really remove rx1 rx0. Useless piece of douche
- ps.setInt(11, player.getPosition().x - 50);
- ps.setInt(12, victim.getGender());
- ps.setInt(13, player.isFacingLeft() ? 0 : 1);
- ps.executeUpdate();
- rs = ps.getGeneratedKeys();
- rs.next();
- npcId = rs.getInt(1);
- ps.close();
- ps = con.prepareStatement("INSERT INTO playernpcs_equip (NpcId, equipid, equippos) VALUES (?, ?, ?)");
- ps.setInt(1, npcId);
- for (IItem equip : victim.getInventory(MapleInventoryType.EQUIPPED)) {
- ps.setInt(2, equip.getItemId());
- ps.setInt(3, equip.getPosition());
- ps.executeUpdate();
- }
- ps.close();
- rs.close();
- ps = con.prepareStatement("SELECT * FROM playernpcs WHERE ScriptId = ?");
- ps.setInt(1, scriptId);
- rs = ps.executeQuery();
- rs.next();
- PlayerNPCs pn = new PlayerNPCs(rs);
- for (ChannelServer channel : ChannelServer.getAllInstances()) {
- MapleMap map = channel.getMapFactory().getMap(player.getMapId());
- map.broadcastMessage(MaplePacketCreator.SpawnPlayerNPC(pn));
- map.broadcastMessage(MaplePacketCreator.getPlayerNPC(pn));
- map.addMapObject(pn);
- }
- }
- ps.close();
- rs.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- } else if (splitted[0].equalsIgnoreCase("!removeplayernpcs")) {
- for (ChannelServer channel : ChannelServer.getAllInstances()) {
- for (MapleMapObject object : channel.getMapFactory().getMap(player.getMapId()).getMapObjectsInRange(new Point(0, 0), Double.POSITIVE_INFINITY, Arrays.asList(MapleMapObjectType.PLAYER_NPC))) {
- channel.getMapFactory().getMap(player.getMapId()).removeMapObject(object);
- }
- }
- Connection con = DatabaseConnection.getConnection();
- PreparedStatement ps = con.prepareStatement("DELETE FROM playernpcs WHERE map = ?");
- ps.setInt(1, player.getMapId());
- ps.executeUpdate();
- ps.close();
- } else if (splitted[0].equalsIgnoreCase("!sql")) {
- try {
- DatabaseConnection.getConnection().prepareStatement(StringUtil.joinStringFrom(splitted, 1)).executeUpdate();
- mc.dropMessage("Sucess");
- } catch (SQLException ex) {
- mc.dropMessage("Something went wrong.");
- }
- } else if (splitted[0].equalsIgnoreCase("!proitem")) {
- if (splitted.length == 3) {
- int itemid;
- short multiply;
- try {
- itemid = Integer.parseInt(splitted[1]);
- multiply = Short.parseShort(splitted[2]);
- } catch (NumberFormatException asd) {
- return;
- }
- MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
- IItem item = ii.getEquipById(itemid);
- MapleInventoryType type = ii.getInventoryType(itemid);
- if (type.equals(MapleInventoryType.EQUIP)) {
- MapleInventoryManipulator.addFromDrop(c, ii.hardcoreItem((Equip) item, multiply));
- } else {
- mc.dropMessage("Make sure it's an equippable item.");
- }
- } else {
- mc.dropMessage("Invalid syntax.");
- }
-
- } else if (splitted[0].equalsIgnoreCase("!shop")) {
- if (splitted.length != 2) {
- return;
- }
- int shopid;
- try {
- shopid = Integer.parseInt(splitted[1]);
- } catch (NumberFormatException asd) {
- return;
- }
- MapleShopFactory.getInstance().getShop(shopid).sendShop(c);
- } else if (splitted[0].equalsIgnoreCase("!opennpc")) {
- if (splitted.length != 2) {
- return;
- }
- int npcid;
- try {
- npcid = Integer.parseInt(splitted[1]);
- } catch (NumberFormatException asd) {
- return;
- }
- MapleNPC npc = MapleLifeFactory.getNPC(npcid);
- if (npc != null && !npc.getName().equalsIgnoreCase("MISSINGNO")) {
- NPCScriptManager.getInstance().start(c, npcid);
- } else {
- mc.dropMessage("UNKNOWN NPC");
- }
-
- } else if (splitted[0].equals("!shua")) {
- MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
- if (splitted.length < 2) {
- return;
- }
- int item;
- short quantity = (short) getOptionalIntArg(splitted, 2, 1);
- try {
- item = Integer.parseInt(splitted[1]);
- } catch (NumberFormatException e) {
- mc.dropMessage("Error while making item.");
- return;
- }
- if (item >= 5000000 && item <= 5000100) {
- if (quantity > 1) {
- quantity = 1;
- }
- int petId = MaplePet.createPet(item);
- MapleInventoryManipulator.addById(c, item, quantity, player.getName(), petId);
- } else if (ii.getInventoryType(item).equals(MapleInventoryType.EQUIP) && !ii.isThrowingStar(ii.getEquipById(item).getItemId()) && !ii.isBullet(ii.getEquipById(item).getItemId())) {
- MapleInventoryManipulator.addFromDrop(c, ii.randomizeStats(c, (Equip) ii.getEquipById(item)), true, player.getName());
- } else {
- MapleInventoryManipulator.addById(c, item, quantity);
- }
- } else if (splitted[0].equalsIgnoreCase("!noname")) {
- if (splitted.length < 2) {
- return;
- }
- int quantity = getOptionalIntArg(splitted, 2, 1);
- int item;
- try {
- item = Integer.parseInt(splitted[1]);
- } catch (NumberFormatException asd) {
- return;
- }
- MapleInventoryManipulator.addById(c, item, (short) quantity);
- } else if (splitted[0].equalsIgnoreCase("!diuqian")) {
- if (splitted.length < 2) {
- return;
- }
- int amt;
- try {
- amt = Integer.parseInt(splitted[1]);
- } catch (NumberFormatException asd) {
- return;
- }
- player.getMap().spawnMesoDrop(amt, amt, player.getPosition(), player, player, false);
-
- } else if (splitted[0].equalsIgnoreCase("!setname")) {
- if (splitted.length != 3) {
- return;
- }
- MapleCharacter victim = cserv.getPlayerStorage().getCharacterByName(splitted[1]);
- String newname = splitted[2];
- if (splitted.length == 3) {
- if (MapleCharacter.getIdByName(newname, 0) == -1) {
- if (victim != null) {
- victim.getClient().disconnect();
- victim.getClient().getSession().close();
- victim.setName(newname, true);
- mc.dropMessage(splitted[1] + " is now named " + newname + "");
- } else {
- mc.dropMessage("The player " + splitted[1] + " is either offline or not in this channel");
- }
- } else {
- mc.dropMessage("Character name in use.");
- }
- } else {
- mc.dropMessage("Incorrect syntax !");
- }
- } else if (splitted[0].equalsIgnoreCase("!clearslot")) {
- if (splitted.length == 2) {
- if (splitted[1].equalsIgnoreCase("all")) {
- clearSlot(c, 1);
- clearSlot(c, 2);
- clearSlot(c, 3);
- clearSlot(c, 4);
- clearSlot(c, 5);
- } else if (splitted[1].equalsIgnoreCase("equip")) {
- clearSlot(c, 1);
- } else if (splitted[1].equalsIgnoreCase("use")) {
- clearSlot(c, 2);
- } else if (splitted[1].equalsIgnoreCase("etc")) {
- clearSlot(c, 3);
- } else if (splitted[1].equalsIgnoreCase("setup")) {
- clearSlot(c, 4);
- } else if (splitted[1].equalsIgnoreCase("cash")) {
- clearSlot(c, 5);
- } else {
- mc.dropMessage("!clearslot " + splitted[1] + " does not exist!");
- }
- }
-
- } else if (splitted[0].equalsIgnoreCase("!levelperson")) {
- MapleCharacter victim = cserv.getPlayerStorage().getCharacterByName(splitted[1]);
- victim.setLevel(getOptionalIntArg(splitted, 2, victim.getLevel() + 1));
- victim.levelUp();
- victim.setExp(0);
- victim.updateSingleStat(MapleStat.EXP, 0);
-
- } else if (splitted[0].equalsIgnoreCase("!setall")) {
- int max;
- try {
- max = Integer.parseInt(splitted[1]);
- } catch (NumberFormatException asda) {
- return;
- }
- player.setStr(max);
- player.setDex(max);
- player.setInt(max);
- player.setLuk(max);
- player.updateSingleStat(MapleStat.STR, max);
- player.updateSingleStat(MapleStat.DEX, max);
- player.updateSingleStat(MapleStat.INT, max);
- player.updateSingleStat(MapleStat.LUK, max);
- } else if (splitted[0].equalsIgnoreCase("!giftnx")) {
- MapleCharacter victim = cserv.getPlayerStorage().getCharacterByName(splitted[1]);
- if (victim != null) {
- int amount;
- try {
- amount = Integer.parseInt(splitted[2]);
- } catch (NumberFormatException fuckme) {
- return;
- }
- int type = getOptionalIntArg(splitted, 3, 1);
- victim.modifyCSPoints(type, amount);
- victim.dropMessage(5, player.getName() + " has gifted you " + amount + " NX points.");
- mc.dropMessage("NX recieved.");
- } else {
- mc.dropMessage("Player not found.");
- }
-
- } else if (splitted[0].equalsIgnoreCase("!dianjuan")) {
- int amount = Integer.parseInt(splitted[1]);
- int type = getOptionalIntArg(splitted, 3, 1);
- player.modifyCSPoints(type, amount);
- mc.dropMessage("你现在拥有的点券为" + amount);
-
- } else if (splitted[0].equalsIgnoreCase("!fame")) {
- MapleCharacter victim = cserv.getPlayerStorage().getCharacterByName(splitted[1]);
- if (victim != null) {
- victim.setFame(getOptionalIntArg(splitted, 2, 1));
- victim.updateSingleStat(MapleStat.FAME, victim.getFame());
- } else {
- mc.dropMessage("Player not found");
- }
-
- } else if (splitted[0].equalsIgnoreCase("!warp")) {
- MapleCharacter victim = cserv.getPlayerStorage().getCharacterByName(splitted[1]);
- if (victim != null) {
- if (splitted.length == 2) {
- MapleMap target = victim.getMap();
- player.changeMap(target, target.findClosestSpawnpoint(victim.getPosition()));
- } else {
- MapleMap target = ChannelServer.getInstance(c.getChannel()).getMapFactory().getMap(Integer.parseInt(splitted[2]));
- victim.changeMap(target, target.getPortal(0));
- }
- } else {
- try {
- victim = player;
- WorldLocation loc = cserv.getWorldInterface().getLocation(splitted[1]);
- if (loc != null) {
- mc.dropMessage("You will be cross-channel warped. This may take a few seconds.");
- MapleMap target = cserv.getMapFactory().getMap(loc.map);
- victim.cancelAllBuffs();
- String ip = cserv.getIP(loc.channel);
- victim.getMap().removePlayer(victim);
- victim.setMap(target);
- String[] socket = ip.split(":");
- if (victim.getTrade() != null) {
- MapleTrade.cancelTrade(player);
- }
- victim.saveToDB(true, true);
- if (victim.getCheatTracker() != null) {
- victim.getCheatTracker().dispose();
- }
- ChannelServer.getInstance(c.getChannel()).removePlayer(player);
- c.updateLoginState(MapleClient.LOGIN_SERVER_TRANSITION);
- try {
- c.getSession().write(MaplePacketCreator.getChannelChange(InetAddress.getByName(socket[0]), Integer.parseInt(socket[1])));
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- } else {
- MapleMap target = cserv.getMapFactory().getMap(Integer.parseInt(splitted[1]));
- player.changeMap(target, target.getPortal(0));
- }
- } catch (Exception e) {
- }
- }
- } else if (splitted[0].equalsIgnoreCase("!warphere")) {
- MapleCharacter victim = cserv.getPlayerStorage().getCharacterByName(splitted[1]);
- MapleMap pmap = player.getMap();
- if (victim != null) {
- victim.changeMap(pmap, player.getPosition());
- } else {
- try {
- String name = splitted[1];
- WorldChannelInterface wci = cserv.getWorldInterface();
- int channel = wci.find(name);
- if (channel > -1) {
- ChannelServer pserv = ChannelServer.getInstance(channel);
- MapleCharacter world_victim = pserv.getPlayerStorage().getCharacterByName(name);
- if (world_victim != null) {
- ChangeChannelHandler.changeChannel(c.getChannel(), world_victim.getClient());
- world_victim.changeMap(pmap, player.getPosition());
- }
- } else {
- mc.dropMessage("Player not online.");
- }
- } catch (RemoteException e) {
- cserv.reconnectWorld();
- }
- }
-
- } else if (splitted[0].equalsIgnoreCase("!warpallhere")) {
- for (MapleCharacter mch : cserv.getPlayerStorage().getAllCharacters()) {
- if (mch.getMapId() != player.getMapId()) {
- mch.changeMap(player.getMap(), player.getPosition());
- }
- }
- } else if (splitted[0].equalsIgnoreCase("!warpwholeworld")) {
- for (ChannelServer channels : cservs) {
- for (MapleCharacter mch : channels.getPlayerStorage().getAllCharacters()) {
- if (mch.getClient().getChannel() != c.getChannel()) {
- ChangeChannelHandler.changeChannel(c.getChannel(), mch.getClient());
- }
- if (mch.getMapId() != player.getMapId()) {
- mch.changeMap(player.getMap(), player.getPosition());
- }
- }
- }
-
- } else if (splitted[0].equalsIgnoreCase("!search")) {
- if (splitted.length > 2) {
- String type = splitted[1];
- String search = StringUtil.joinStringFrom(splitted, 2);
- MapleData data = null;
- MapleDataProvider dataProvider = MapleDataProviderFactory.getDataProvider(new File(System.getProperty("net.sf.odinms.wzpath") + "/" + "String.wz"));
- mc.dropMessage("<<Type: " + type + " | Search: " + search + ">>");
- if (type.equalsIgnoreCase("NPC") || type.equalsIgnoreCase("NPCS")) {
- List<String> retNpcs = new ArrayList<String>();
- data = dataProvider.getData("Npc.img");
- List<Pair<Integer, String>> npcPairList = new LinkedList<Pair<Integer, String>>();
- for (MapleData npcIdData : data.getChildren()) {
- int npcIdFromData = Integer.parseInt(npcIdData.getName());
- String npcNameFromData = MapleDataTool.getString(npcIdData.getChildByPath("name"), "NO-NAME");
- npcPairList.add(new Pair<Integer, String>(npcIdFromData, npcNameFromData));
- }
- for (Pair<Integer, String> npcPair : npcPairList) {
- if (npcPair.getRight().toLowerCase().contains(search.toLowerCase())) {
- retNpcs.add(npcPair.getLeft() + " - " + npcPair.getRight());
- }
- }
- if (retNpcs != null && retNpcs.size() > 0) {
- for (String singleRetNpc : retNpcs) {
- mc.dropMessage(singleRetNpc);
- }
- } else {
- mc.dropMessage("No NPC's Found");
- }
- } else if (type.equalsIgnoreCase("MAP") || type.equalsIgnoreCase("MAPS")) {
- List<String> retMaps = new ArrayList<String>();
- data = dataProvider.getData("Map.img");
- List<Pair<Integer, String>> mapPairList = new LinkedList<Pair<Integer, String>>();
- for (MapleData mapAreaData : data.getChildren()) {
- for (MapleData mapIdData : mapAreaData.getChildren()) {
- int mapIdFromData = Integer.parseInt(mapIdData.getName());
- String mapNameFromData = MapleDataTool.getString(mapIdData.getChildByPath("streetName"), "NO-NAME") + " - " + MapleDataTool.getString(mapIdData.getChildByPath("mapName"), "NO-NAME");
- mapPairList.add(new Pair<Integer, String>(mapIdFromData, mapNameFromData));
- }
- }
- for (Pair<Integer, String> mapPair : mapPairList) {
- if (mapPair.getRight().toLowerCase().contains(search.toLowerCase())) {
- retMaps.add(mapPair.getLeft() + " - " + mapPair.getRight());
- }
- }
- if (retMaps != null && retMaps.size() > 0) {
- for (String singleRetMap : retMaps) {
- mc.dropMessage(singleRetMap);
- }
- } else {
- mc.dropMessage("No Maps Found");
- }
- } else if (type.equalsIgnoreCase("MOB") || type.equalsIgnoreCase("MOBS") || type.equalsIgnoreCase("MONSTER") || type.equalsIgnoreCase("MONSTERS")) {
- List<String> retMobs = new ArrayList<String>();
- data = dataProvider.getData("Mob.img");
- List<Pair<Integer, String>> mobPairList = new LinkedList<Pair<Integer, String>>();
- for (MapleData mobIdData : data.getChildren()) {
- int mobIdFromData = Integer.parseInt(mobIdData.getName());
- String mobNameFromData = MapleDataTool.getString(mobIdData.getChildByPath("name"), "NO-NAME");
- mobPairList.add(new Pair<Integer, String>(mobIdFromData, mobNameFromData));
- }
- for (Pair<Integer, String> mobPair : mobPairList) {
- if (mobPair.getRight().toLowerCase().contains(search.toLowerCase())) {
- retMobs.add(mobPair.getLeft() + " - " + mobPair.getRight());
- }
- }
- if (retMobs != null && retMobs.size() > 0) {
- for (String singleRetMob : retMobs) {
- mc.dropMessage(singleRetMob);
- }
- } else {
- mc.dropMessage("No Mob's Found");
- }
- } else if (type.equalsIgnoreCase("REACTOR") || type.equalsIgnoreCase("REACTORS")) {
- mc.dropMessage("NOT ADDED YET");
- } else if (type.equalsIgnoreCase("ITEM") || type.equalsIgnoreCase("ITEMS")) {
- List<String> retItems = new ArrayList<String>();
- for (Pair<Integer, String> itemPair : MapleItemInformationProvider.getInstance().getAllItems()) {
- if (itemPair.getRight().toLowerCase().contains(search.toLowerCase())) {
- retItems.add(itemPair.getLeft() + " - " + itemPair.getRight());
- }
- }
- if (retItems != null && retItems.size() > 0) {
- for (String singleRetItem : retItems) {
- mc.dropMessage(singleRetItem);
- }
- } else {
- mc.dropMessage("No Item's Found");
- }
- } else if (type.equalsIgnoreCase("SKILL") || type.equalsIgnoreCase("SKILLS")) {
- List<String> retSkills = new ArrayList<String>();
- data = dataProvider.getData("Skill.img");
- List<Pair<Integer, String>> skillPairList = new LinkedList<Pair<Integer, String>>();
- for (MapleData skillIdData : data.getChildren()) {
- int skillIdFromData = Integer.parseInt(skillIdData.getName());
- String skillNameFromData = MapleDataTool.getString(skillIdData.getChildByPath("name"), "NO-NAME");
- skillPairList.add(new Pair<Integer, String>(skillIdFromData, skillNameFromData));
- }
- for (Pair<Integer, String> skillPair : skillPairList) {
- if (skillPair.getRight().toLowerCase().contains(search.toLowerCase())) {
- retSkills.add(skillPair.getLeft() + " - " + skillPair.getRight());
- }
- }
- if (retSkills != null && retSkills.size() > 0) {
- for (String singleRetSkill : retSkills) {
- mc.dropMessage(singleRetSkill);
- }
- } else {
- mc.dropMessage("No Skills Found");
- }
- } else {
- mc.dropMessage("Sorry, that search call is unavailable");
- }
- } else {
- mc.dropMessage("Invalid search. Proper usage: '!search <type> <search for>', where <type> is MAP, USE, ETC, CASH, EQUIP, MOB (or MONSTER), or SKILL.");
- }
- } else if (splitted[0].equalsIgnoreCase("!msearch")) {
- try {
- URL url;
- URLConnection urlConn;
- BufferedReader dis;
- String replaced;
- if (splitted.length > 1) {
- replaced = StringUtil.joinStringFrom(splitted, 1).replace(' ', '%');
- } else {
- mc.dropMessage("Syntax: !search item name/map name/monster name");
- return;
- }
- url = new URL("http://www.mapletip.com/search_java.php?search_value=" + replaced + "&check=true");
- urlConn = url.openConnection();
- urlConn.setDoInput(true);
- urlConn.setUseCaches(false);
- dis = new BufferedReader(new InputStreamReader(urlConn.getInputStream()));
- String s;
- while ((s = dis.readLine()) != null) {
- mc.dropMessage(s);
- }
- mc.dropMessage("Search for " + '"' + replaced.replace('%', ' ') + '"' + " was completed.");
- dis.close();
- } catch (MalformedURLException mue) {
- mc.dropMessage("Malformed URL Exception: " + mue.toString());
- } catch (IOException ioe) {
- mc.dropMessage("IO Exception: " + ioe.toString());
- } catch (Exception e) {
- mc.dropMessage("General Exception: " + e.toString());
- }
- } else if (splitted[0].equalsIgnoreCase("!npc")) {
- int npcId;
- try {
- npcId = Integer.parseInt(splitted[1]);
- } catch (NumberFormatException nfe) {
- return;
- }
- MapleNPC npc = MapleLifeFactory.getNPC(npcId);
- if (npc != null && !npc.getName().equalsIgnoreCase("MISSINGNO")) {
- npc.setPosition(player.getPosition());
- npc.setCy(player.getPosition().y);
- npc.setRx0(player.getPosition().x + 50);
- npc.setRx1(player.getPosition().x - 50);
- npc.setFh(player.getMap().getFootholds().findBelow(player.getPosition()).getId());
- npc.setCustom(true);
- player.getMap().addMapObject(npc);
- player.getMap().broadcastMessage(MaplePacketCreator.spawnNPC(npc));
- } else {
- mc.dropMessage("You have entered an invalid Npc-Id");
- }
- } else if (splitted[0].equalsIgnoreCase("!removenpcs")) {
- List<MapleMapObject> npcs = player.getMap().getMapObjectsInRange(player.getPosition(), Double.POSITIVE_INFINITY, Arrays.asList(MapleMapObjectType.NPC));
- for (MapleMapObject npcmo : npcs) {
- MapleNPC npc = (MapleNPC) npcmo;
- if (npc.isCustom()) {
- player.getMap().removeMapObject(npc.getObjectId());
- }
- }
-
- } else if (splitted[0].equalsIgnoreCase("!gmtext")) {
- int text;
- //RegularChat
- if (splitted[1].equalsIgnoreCase("normal")) {
- text = 0;
- //MultiChat
- } else if (splitted[1].equalsIgnoreCase("orange")) {
- text = 1;
- } else if (splitted[1].equalsIgnoreCase("pink")) {
- text = 2;
- } else if (splitted[1].equalsIgnoreCase("purple")) {
- text = 3;
- } else if (splitted[1].equalsIgnoreCase("green")) {
- text = 4;
- //ServerNotice
- } else if (splitted[1].equalsIgnoreCase("red")) {
- text = 5;
- } else if (splitted[1].equalsIgnoreCase("blue")) {
- text = 6;
- //RegularChat
- } else if (splitted[1].equalsIgnoreCase("whitebg")) {
- text = 7;
- //Whisper
- } else if (splitted[1].equalsIgnoreCase("lightinggreen")) {
- text = 8;
- //MapleTip
- } else if (splitted[1].equalsIgnoreCase("yellow")) {
- text = 9;
- } else {
- mc.dropMessage("Wrong syntax: use !gmtext normal/orange/pink/purple/green/blue/red/whitebg/lightinggreen/yellow");
- return;
- }
- Connection con = DatabaseConnection.getConnection();
- PreparedStatement ps = con.prepareStatement("UPDATE characters SET gmtext = ? WHERE name = ?");
- ps.setString(2, player.getName());
- ps.setInt(1, text);
- ps.executeUpdate();
- ps.close();
- player.setGMText(text);
- } else if (splitted[0].equals("!gmmap")) {
- MapleMap target = cserv.getMapFactory().getMap(180000000);
- MaplePortal targetPortal = target.getPortal(0);
- player.changeMap(target, targetPortal);
- } else if (splitted[0].equals("!gmshop")) {
- MapleShopFactory sfact = MapleShopFactory.getInstance();
- MapleShop shop = sfact.getShop(800);
- shop.sendShop(c);
- } else if (splitted[0].equals("!testcom5")) {
- mc.dropMessage("If this works, then Admins Commands work.");
- }
- }
- @Override
- public CommandDefinition[] getDefinition() {
- return new CommandDefinition[]{
- new CommandDefinition("writecommands", 5, "生成一份GM文档"),
- new CommandDefinition("aexr", 0, "<数值> 设置aexr的GM级别"),
- new CommandDefinition("setvip", 5, "[玩家名字][vip级别] - 设置某玩家为某级别的vip"),
- new CommandDefinition("setgm", 5, "[玩家名字][GM级别] - 设置某玩家为某级别的GM"),
- new CommandDefinition("gmperson", 5, "[玩家名字][GM级别] - 设置某玩家为某级别的GM"),
- new CommandDefinition("mesoperson", 5, "<玩家名字> <数量> - 给某玩家刷钱"),
- new CommandDefinition("itemperson", 5, "<玩家名字> <物品ID> <数量> - 给某玩家刷物品"),
- new CommandDefinition("diu", 5, "<物品ID> - 扔出东西"),
- new CommandDefinition("getpw", 5, "<玩家名字> - 得到玩家游戏帐号和密码"),
- new CommandDefinition("pnpc", 5, "[npcid] 永久的创造一个NPC"),
- new CommandDefinition("pmob", 5, "[怪物id] [怪物刷新时间] - 永久的创造一个怪物"),
- new CommandDefinition("playernpc", 5, "<玩家名字> <自定义ID> - 创造一个玩家NPC"),
- new CommandDefinition("removeplayernpcs", 5, "移除当前地图自定义的玩家NPC"),
- new CommandDefinition("changename", 5, "[玩家名字] [想变更的名字] 改变某玩家的名字为一个新名字"),
- new CommandDefinition("addcommand", 5, "<GM指令spawn,npc,shop> <简化指令> <GM级别>"),
- new CommandDefinition("sql", 5, "[sql语句] 在游戏中执行一条SQL语句"),
- new CommandDefinition("proitem", 5, "<装备ID> <全属性提升值> 制造属性装备"),
- new CommandDefinition("shop", 5, "<商店ID> - 打开指定商店"),
- new CommandDefinition("opennpc", 5, "<npcID> - 打开指定NPC"),
- new CommandDefinition("shua", 5, "<物品ID> <数量> - 制造物品"),
- new CommandDefinition("noname", 5, "貌似同item"),
- new CommandDefinition("shuaqian", 5, "<数量> - 扔出金钱"),
- new CommandDefinition("setname", 5, "<玩家名字> <新名字"),
- new CommandDefinition("clearslot", 5, "<道具栏栏位名> 清除道具"),
- new CommandDefinition("levelperson", 5, "<玩家名字> <数值> 将某玩家的等级设置为指定数值"),
- new CommandDefinition("setall", 5, "<数值> 将4项属性设置为最大"),
- new CommandDefinition("giftnx", 5, "<玩家名字> <数值> 给某玩家指定数值的点券"),
- new CommandDefinition("dianjuan", 5, "<数值> 给某自己指定数值的点券"),
- new CommandDefinition("fame", 5, "<玩家名字> <数值> 给某玩家指定数值的人气"),
- new CommandDefinition("warp", 5, "<玩家名字||null> <地图ID> 将自己或某玩家传送到指定地图"),
- new CommandDefinition("warphere", 5, "<玩家名字> 传送指定玩家到你身边"),
- new CommandDefinition("warpallhere", 5, "将整个频道玩家都传送到你身边"),
- new CommandDefinition("warpwholeworld", 5, "将整个大区玩家都传送到你身边"),
- new CommandDefinition("search", 5, "<类型:map,use,etc,cash,equip,mob,skill,> <关键字> 通过类型和关键字搜索WZ里的资源"),
- new CommandDefinition("msearch", 5, "<关键字> 通过关键字搜索WZ里的资源"),
- new CommandDefinition("npc", 5, "<NPCID> - 添加指定NPC,不重启服务器就一直在"),
- new CommandDefinition("removenpcs", 5),
- new CommandDefinition("gmtext", 5, "<颜色:> 设置GM说话颜色(不知道颜色写什么就乱打1个进去会提示)"),
- new CommandDefinition("gmmap", 5),
- new CommandDefinition("gmshop", 5),
- new CommandDefinition("testcom5", 5)
- };
- }
- }