2013年6月8日 星期六

【Java教學】【★★★★★】GM指令調整玩家等級

新增一組程式碼檔案

新增l1j\server\server\command\executor\L1Levelid.java
新增以下程式碼



QUOTE:
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* http://www.gnu.org/copyleft/gpl.html
*/
package l1j.server.server.command.executor;

import java.util.StringTokenizer;
import java.util.logging.Logger;

import l1j.server.server.datatables.ExpTable;
import l1j.server.server.model.L1World;
import l1j.server.server.model.Instance.L1PcInstance;
import l1j.server.server.serverpackets.S_ServerMessage;
import l1j.server.server.serverpackets.S_SystemMessage;
import l1j.server.server.utils.IntRange;

public class L1Levelid implements L1CommandExecutor {
private static Logger _log = Logger.getLogger(L1Levelid.class.getName());

private L1Levelid() {
}

public static L1CommandExecutor getInstance() {
return new L1Levelid();
}

public void execute(L1PcInstance pc, String cmdName, String arg) {
try {
StringTokenizer tok = new StringTokenizer(arg);
String char_name = tok.nextToken();
int level = Integer.parseInt(tok.nextToken());

L1PcInstance target = L1World.getInstance().getPlayer(char_name);
if (target == null) {
pc.sendPackets(new S_ServerMessage(73, char_name));
}
else {
if (level == target.getLevel()) {
return;
}
if (!IntRange.includes(level, 1, 99)) {
pc.sendPackets(new S_SystemMessage("請在1-99範圍內指定"));
return;
}
target.setExp(ExpTable.getExpByLevel(level));
}
}
catch (Exception e) {
pc.sendPackets(new S_SystemMessage(cmdName + " 玩家名稱 請輸入。"));
}
}
}



更動commands資料庫
新增以下指令


QUOTE:

玩家等級100L1Levelid

沒有留言:

張貼留言