SuperGM.java
上传用户:gwt600
上传日期:2021-06-03
资源大小:704k
文件大小:18k
- /*
- 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 net.sf.odinms.client.MapleCharacter;
- import net.sf.odinms.client.MapleClient;
- 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.HashMap;
- import java.util.Map;
- import net.sf.odinms.client.MapleRing;
- import net.sf.odinms.server.life.MapleLifeFactory;
- import net.sf.odinms.server.life.MapleMonster;
- import net.sf.odinms.server.life.MapleMonsterStats;
- import net.sf.odinms.client.messages.CommandDefinition;
- import static net.sf.odinms.client.messages.CommandProcessor.getNamedDoubleArg;
- import static net.sf.odinms.client.messages.CommandProcessor.getNamedIntArg;
- import static net.sf.odinms.client.messages.CommandProcessor.getOptionalIntArg;
- public class SuperGM 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();
- String themapname = player.getMap().getMapName();
- if (splitted[0].equalsIgnoreCase("!zhakun")) {
- for (int m = 8800003; m <= 8800010; m++) {
- player.getMap().spawnMonsterOnGroudBelow(MapleLifeFactory.getMonster(m), player.getPosition());
- }
- player.getMap().spawnMonsterOnGroudBelow(MapleLifeFactory.getMonster(8800000), player.getPosition());
- player.getMap().broadcastMessage(MaplePacketCreator.serverNotice(0, "请注意: 扎昆已经召唤,请大家速度到<" + themapname + ">集合."));
- } else if (splitted[0].equalsIgnoreCase("!heilong")) {
- MapleMonster ht = MapleLifeFactory.getMonster(8810026);
- player.getMap().spawnMonsterOnGroudBelow(ht, player.getPosition());
- player.getMap().killMonster(ht, player, false);
- player.getMap().broadcastMessage(MaplePacketCreator.serverNotice(0, "请注意: 黑龙已经召唤,请大家速度到<" + themapname + ">集合."));
- } else if (splitted[0].equals("!baoxiang")) {//爆炸箱子
- player.getMap().spawnMonsterOnGroudBelow(MapleLifeFactory.getMonster(9400566), player.getPosition());
- player.getMap().broadcastMessage(MaplePacketCreator.serverNotice(0, "请注意,GM刷邪恶箱子爆现金道具的活动已经开始了,请大家速度到[" + themapname + "]集合,找到地图里的邪恶箱子,并打开它,你就能得到现金道具。还等什么呢,赶快去找吧。"));
- } else if (splitted[0].equals("!jinshuiling")) {//金水灵
- for (int amnt = getOptionalIntArg(splitted, 1, 1); amnt > 0; amnt--) {
- player.getMap().spawnMonsterOnGroudBelow(MapleLifeFactory.getMonster(9400202), player.getPosition());
- }
- player.getMap().broadcastMessage(MaplePacketCreator.serverNotice(0, "请注意,GM刷金水灵爆现金道具的活动已经开始了,请大家速度到[" + themapname + "]集合,找到地图里的金水灵并杀死它,大量现金道具就是你的了!!!."));
- } else if (splitted[0].equalsIgnoreCase("!zhaohuan")) {
- int mid;
- int num = getOptionalIntArg(splitted, 2, 1);
- try {
- mid = Integer.parseInt(splitted[1]);
- } catch (NumberFormatException asd) {
- return;
- }
- if (num > 20) {
- mc.dropMessage("Remember that we know what you're doing ;] please dont over summon");
- }
- Integer hp = getNamedIntArg(splitted, 1, "hp");
- Integer exp = getNamedIntArg(splitted, 1, "exp");
- Double php = getNamedDoubleArg(splitted, 1, "php");
- Double pexp = getNamedDoubleArg(splitted, 1, "pexp");
- MapleMonster onemob = MapleLifeFactory.getMonster(mid);
- int newhp = 0;
- int newexp = 0;
- if (hp != null) {
- newhp = hp.intValue();
- } else if (php != null) {
- newhp = (int) (onemob.getMaxHp() * (php.doubleValue() / 100));
- } else {
- newhp = onemob.getMaxHp();
- }
- if (exp != null) {
- newexp = exp.intValue();
- } else if (pexp != null) {
- newexp = (int) (onemob.getExp() * (pexp.doubleValue() / 100));
- } else {
- newexp = onemob.getExp();
- }
- if (newhp < 1) {
- newhp = 1;
- }
- MapleMonsterStats overrideStats = new MapleMonsterStats();
- overrideStats.setHp(newhp);
- overrideStats.setExp(newexp);
- overrideStats.setMp(onemob.getMaxMp());
- if (num > 20) {
- num = 20;
- }
- for (int i = 0; i < num; i++) {
- MapleMonster mob = MapleLifeFactory.getMonster(mid);
- mob.setHp(newhp);
- mob.setOverrideStats(overrideStats);
- player.getMap().spawnMonsterOnGroudBelow(mob, player.getPosition());
- }
-
-
- } else if (splitted[0].equalsIgnoreCase("!mesosrate")) { // All these could be so much shorter but cbf.
- int set;
- try {
- set = Integer.parseInt(splitted[1]);
- } catch (NumberFormatException asd) {
- return;
- }
- if (splitted.length > 2) {
- for (ChannelServer channel : cservs) {
- channel.setMesoRate(set);
- channel.broadcastPacket(MaplePacketCreator.serverNotice(0, "Meso Rate has been changed to " + set + "x"));
- }
- } else if (splitted.length == 2) {
- cserv.setMesoRate(set);
- cserv.broadcastPacket(MaplePacketCreator.serverNotice(0, "Meso Rate has been changed to " + set + "x"));
- } else {
- mc.dropMessage("Syntax: !mesorate <number>");
- }
- } else if (splitted[0].equalsIgnoreCase("!droprate")) {
- int set;
- try {
- set = Integer.parseInt(splitted[1]);
- } catch (NumberFormatException asd) {
- return;
- }
- if (splitted.length > 2) {
- for (ChannelServer channel : cservs) {
- channel.setDropRate(set);
- channel.broadcastPacket(MaplePacketCreator.serverNotice(0, "Drop Rate has been changed to " + set + "x"));
- }
- } else if (splitted.length == 2) {
- cserv.setDropRate(set);
- cserv.broadcastPacket(MaplePacketCreator.serverNotice(0, "Drop Rate has been changed to " + set + "x"));
- } else {
- mc.dropMessage("Syntax: !droprate <number>");
- }
- } else if (splitted[0].equalsIgnoreCase("!bossdroprate")) {
- int set;
- try {
- set = Integer.parseInt(splitted[1]);
- } catch (NumberFormatException asd) {
- return;
- }
- if (splitted.length > 2) {
- for (ChannelServer channel : cservs) {
- channel.setBossDropRate(set);
- channel.broadcastPacket(MaplePacketCreator.serverNotice(0, "Boss Drop Rate has been changed to " + set + "x"));
- }
- } else if (splitted.length == 2) {
- cserv.setBossDropRate(set);
- cserv.broadcastPacket(MaplePacketCreator.serverNotice(0, "Boss Drop Rate has been changed to " + set + "x"));
- } else {
- mc.dropMessage("Syntax: !bossdroprate <number>");
- }
- } else if (splitted[0].equalsIgnoreCase("!exprate")) {
- int set;
- try {
- set = Integer.parseInt(splitted[1]);
- } catch (NumberFormatException asd) {
- return;
- }
- if (splitted.length > 2) {
- for (ChannelServer channel : cservs) {
- channel.setExpRate(set);
- channel.broadcastPacket(MaplePacketCreator.serverNotice(0, "Exp Rate has been changed to " + set + "x"));
- }
- } else if (splitted.length == 2) {
- cserv.setExpRate(set);
- cserv.broadcastPacket(MaplePacketCreator.serverNotice(0, "Exp Rate has been changed to " + set + "x"));
- } else {
- mc.dropMessage("Syntax: !exprate <number>");
- }
- } else if (splitted[0].equalsIgnoreCase("!godlyitemrate")) {
- int set;
- try {
- set = Integer.parseInt(splitted[1]);
- } catch (NumberFormatException asd) {
- return;
- }
- if (splitted.length > 2) {
- for (ChannelServer channel : cservs) {
- channel.setGodlyItemRate((short) set);
- channel.broadcastPacket(MaplePacketCreator.serverNotice(0, "Godly items will now drop at a " + set + "% rate."));
- }
- } else if (splitted.length == 2) {
- cserv.setGodlyItemRate((short) set);
- cserv.broadcastPacket(MaplePacketCreator.serverNotice(0, "Godly items will now drop at a " + set + "% rate."));
- } else {
- mc.dropMessage("Syntax: !godlyitemrate <number>");
- }
- } else if (splitted[0].equalsIgnoreCase("!itemstat")) {
- int set;
- try {
- set = Integer.parseInt(splitted[1]);
- } catch (NumberFormatException asd) {
- return;
- }
- if (splitted.length > 2) {
- for (ChannelServer channel : cservs) {
- channel.setItemMultiplier((short) set);
- channel.broadcastPacket(MaplePacketCreator.serverNotice(0, "Item stat multiplier has been changed to " + set + "x"));
- }
- } else if (splitted.length == 2) {
- cserv.setItemMultiplier((short) set);
- cserv.broadcastPacket(MaplePacketCreator.serverNotice(0, "Item stat multiplier has been changed to " + set + "x"));
- } else {
- mc.dropMessage("Syntax: !setItemMultiplier <number>");
- }
- } else if (splitted[0].equalsIgnoreCase("!togglegodlyitems")) {
- if (splitted.length > 1) {
- for (ChannelServer channel : cservs) {
- channel.setGodlyItems(!cserv.isGodlyItems());
- if (channel.isGodlyItems()) {
- channel.broadcastPacket(MaplePacketCreator.serverNotice(0, "Godly items will now drop at a " + channel.getGodlyItemRate() + "% rate. Items like these will be multiplied by " + channel.getItemMultiplier() + "x each rate."));
- } else {
- channel.broadcastPacket(MaplePacketCreator.serverNotice(0, "Godly item drops have been turned off."));
- }
- }
- } else {
- cserv.setGodlyItems(!cserv.isGodlyItems());
- if (cserv.isGodlyItems()) {
- cserv.broadcastPacket(MaplePacketCreator.serverNotice(0, "Godly items will now drop at a " + cserv.getGodlyItemRate() + "% rate. Items like these will be multiplied by " + cserv.getItemMultiplier() + "x each rate."));
- } else {
- cserv.broadcastPacket(MaplePacketCreator.serverNotice(0, "Godly item drops have been turned off."));
- }
- }
-
- } else if (splitted[0].equalsIgnoreCase("!getrings")) {
- mc.dropMessage("1112800 - clover");
- mc.dropMessage("1112001 - crush");
- mc.dropMessage("1112801 - flower");
- mc.dropMessage("1112802 - Star");
- mc.dropMessage("1112803 - moonstone");
- mc.dropMessage("1112806 - Stargem");
- mc.dropMessage("1112807 - golden");
- mc.dropMessage("1112809 - silverswan");
- } else if (splitted[0].equalsIgnoreCase("!ringall")) {
- Map<String, Integer> rings = new HashMap<String, Integer>();
- rings.put("a", 1112800);//clover 四叶挚友戒指 - 任何人
- rings.put("b", 1112801);//flower 雏菊挚友戒指 - 任何人
- rings.put("c", 1112802);//star 闪星挚友戒指 - 任何人
- rings.put("d", 1112806);//stargem 头上两把剑 - 第三人看到
- rings.put("e", 1112809);//silverswan
- rings.put("f", 1112807);//golden
- rings.put("g", 1112001);//crush 恋人戒指 - 第三人看到
- rings.put("h", 1112002);//纯爱恋人戒指 - 第三人看到
- rings.put("i", 1112003);//丘比特戒指 - 第三人看到
- rings.put("j", 1112005);//多个大红心围绕 - 第三人看到
- if (rings.containsKey(splitted[3])) {
- MapleCharacter partner1 = cserv.getPlayerStorage().getCharacterByName(splitted[1]);
- MapleCharacter partner2 = cserv.getPlayerStorage().getCharacterByName(splitted[2]);
- int ret = MapleRing.createRing(rings.get(splitted[3]), partner1, partner2);
- switch (ret) {
- case -2:
- mc.dropMessage("Partner number 1 was not found.");
- break;
- case -1:
- mc.dropMessage("Partner number 2 was not found.");
- break;
- case 0:
- //mc.dropMessage("Error. One of the players already posesses a ring");
- mc.dropMessage("Error. 其中某人已经拥有过戒指");
- break;
- default:
- mc.dropMessage("Sucess !");
- }
- } else {
- //mc.dropMessage("Ring name was not found.");
- //mc.dropMessage("Ring name : clover,crush,flower,star,stargem,silverswan,golden");
- mc.dropMessage("找不到戒指编号. 指令用法!ringall <玩家1> <玩家2> <戒指编号a~j>");
- }
- rings.clear();
- } else if (splitted[0].equals("!removering")) {
- MapleCharacter victim = player;
- if (splitted.length == 2) {
- victim = cserv.getPlayerStorage().getCharacterByName(splitted[1]);
- }
- if (victim != null) {
- if (MapleRing.checkRingDB(victim)) {
- MapleRing.removeRingFromDb(victim);
- } else {
- victim.dropMessage("You have no ring..");
- }
- }
- } else if (splitted[0].equalsIgnoreCase("!map")) {
- int mapid;
- try {
- mapid = Integer.parseInt(splitted[1]);
- } catch (NumberFormatException mwa) {
- return;
- }
- player.changeMap(mapid, getOptionalIntArg(splitted, 2, 0));
- } else if (splitted[0].equals("!testcom4")) {
- mc.dropMessage("If this works, then SuperGM Commands work.");
- }
- }
- @Override
- public CommandDefinition[] getDefinition() {
- return new CommandDefinition[]{
- new CommandDefinition("zhakun", 4, "召唤扎昆"),
- new CommandDefinition("heilong", 4, "召唤黑龙"),
- new CommandDefinition("baoxiang", 4, "召唤邪恶的宝箱"),
- new CommandDefinition("jinshuiling", 4, "召唤金水灵,爆现金道具的"),
- new CommandDefinition("zhaohuan", 4, "<怪物ID> <数量> - 刷出指定怪物"),
- new CommandDefinition("map", 3, "<地图ID> - 传送到指定地图"),
- new CommandDefinition("mesosrate", 4, "<数值> 设置金钱掉落的数值倍率"),
- new CommandDefinition("droprate", 4, "<数值> 设置物品掉落倍率"),
- new CommandDefinition("bossdroprate", 4, "<数值> 设置BOSS的掉宝几率"),
- new CommandDefinition("exprate", 4, "<数值> 设置经念倍率"),
- new CommandDefinition("godlyitemrate", 4, "<数值> 设置Godly物品的倍率"),
- new CommandDefinition("itemstat", 4, "<数值> 设置ItemMultiplier的倍率"),
- new CommandDefinition("togglegodlyitems", 4, "<数值> 设置Godly物品的掉落几率"),
- new CommandDefinition("getrings", 4, "查看戒指代码和预设名称"),
- new CommandDefinition("ringall", 4, "<玩家1名字> <玩家2名字> <戒指预设名称> 送戒指"),
- new CommandDefinition("removering", 4),
- new CommandDefinition("testcom4", 4)
- };
- }
- }