在0.2里增加GM命令方法(2) { StringTokenizer st = new StringTokenizer(text); st.nextToken();// skip command String x1 = st.nextToken(); int x = Integer.parseInt(x1); String y1 = st.nextToken(); int y = Integer.parseInt(y1); String z1 = st.nextToken(); int z = Integer.parseInt(z1);
CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), "teleporting to "+ x + " " + y + " "+z); con.sendPacket(cs);
TeleportToLocation tele = new TeleportToLocation(activeChar, x,y,z); con.sendPacket(tele); activeChar.setX(x); activeChar.setY(y); activeChar.setZ(z); } else if (text.startsWith(".buy")) { int listId = 0; listId = Integer.parseInt(text.substring(4));
L2BuyList list = TradeController.getInstance().getBuyList(listId);
if (list != null) { BuyList bl = new BuyList(list, activeChar.getAdena()); con.sendPacket(bl); } else { System.out.println("no buylist with id:" +listId); } } else if (text.equals(".money")) { activeChar.addAdena(100000); ItemList il = new ItemList(activeChar, true); con.sendPacket(il); } else if (text.equals(".mob")) { L2Npc goblin = NpcTable.getInstance().getTemplate(3); L2NpcInstance mob = new L2NpcInstance(goblin); mob.setObjectId(IdFactory.getInstance().getNextId()); mob.setX(activeChar.getX()); mob.setY(activeChar.getY()); mob.setZ(activeChar.getZ()); mob.setCurrentHp(80); mob.setMaxHp(198); mob.setHeading(activeChar.getHeading()); mob.setUnknown1(1.08); mob.setUnknown2(0.9983664); NpcInfo ni = new NpcInfo(mob); con.sendPacket(ni);
L2World.getInstance().storeObject(mob); // this is just a hack to make the id globally known } else if (text.startsWith(".movehere")) { L2Object target1 = activeChar.getTarget(); if (target1 instanceof L2NpcInstance) { L2NpcInstance temp = (L2NpcInstance) target1; temp.moveTo(activeChar.getX(), activeChar.getY(), activeChar.getZ(),0); } } else if (text.startsWith(".sethere")) { L2Object target1 = activeChar.getTarget(); if (target1 instanceof L2NpcInstance) { L2NpcInstance temp = (L2NpcInstance) target1; temp.setTo(activeChar.getX(), activeChar.getY(), activeChar.getZ(), activeChar.getHeading()); } } else if (text.startsWith(".stopmove")) { L2Object target1 = activeChar.getTarget(); if (target1 instanceof L2NpcInstance) { L2NpcInstance temp = (L2NpcInstance) target1; temp.stopMove(); } } else if (text.startsWith(".stat")) { int val = Integer.parseInt(text.substring(5)); System.out.println("changing stat: "+val); StatusUpdate su = new StatusUpdate(activeChar.getObjectId()); su.addAttribute(val, 234); con.sendPacket(su); } else if (text.startsWith(".exp")) { int val = Integer.parseInt(text.substring(5)); System.out.println("setting exp t "+val); activeChar.setExp(val); UserInfo ui = new UserInfo(activeChar); con.sendPacket(ui); } else if (text.startsWith(".level")) { int val = Integer.parseInt(text.substring(7)); System.out.println("setting level t "+val); activeChar.setLevel(val); UserInfo ui = new UserInfo(activeChar); con.sendPacket(ui); } else if (text.startsWith(".doorinfo")) { System.out.println("creating door "); L2DoorInstance door = new L2DoorInstance(); door.setObjectId(0x48302222); door.setX(activeChar.getX()); door.setY(activeChar.getY()); door.setZ(activeChar.getZ());
DoorInfo di = new DoorInfo(door); con.sendPacket(di);
DoorStatusUpdate ds = new DoorStatusUpdate(door); con.sendPacket(ds); } else { talk(activeChar, type, text,target); } } catch(Exception e)//if command is input error format , the client will not be crash { talk(activeChar, type, text,target); } }