📄 l1itemdrops.java
字号:
/*
* 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.logging.Logger;
import l1j.server.server.model.L1Teleport;
import l1j.server.server.model.L1World;
import l1j.server.server.model.Instance.L1PcInstance;
import l1j.server.server.serverpackets.S_SystemMessage;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import l1j.server.server.utils.SQLUtil;
import l1j.server.server.model.Instance.L1ItemInstance;
import l1j.server.server.datatables.ItemTable;
import l1j.server.server.templates.L1Item;
import l1j.server.L1DatabaseFactory;
public class L1ItemDrops implements L1CommandExecutor {
private static l1j.eric.EricLogger _log = l1j.eric.EricLogger.getLogger2(L1ItemDrops.class.getName());
private L1ItemDrops() {
}
public static L1CommandExecutor getInstance() {
return new L1ItemDrops();
}
@Override
public void execute(L1PcInstance pc, String cmdName, String arg) {
int dropID = 0;
try {
dropID = Integer.parseInt(arg);
} catch(NumberFormatException e) {
}
if (dropID == 40308) {
pc.sendPackets(new S_SystemMessage("金幣(40308) 幾乎都會掉落"));
} else {
Connection con = null;
PreparedStatement pstm = null;
ResultSet rs = null;
int[] mobID;
int[] min;
int[] max;
double[] chance;
String[] name;
try {
L1Item item = ItemTable.getInstance().getTemplate(dropID);
String blessed;
if (item.getBless() == 1) {
blessed = "";
} else if (item.getBless() == 0) {
blessed = "\\fR";
} else {
blessed = "\\fY";
}
con = L1DatabaseFactory.getInstance().getConnection();
pstm = con.prepareStatement("SELECT mobId,min,max,chance FROM droplist WHERE itemId=?");
pstm.setInt(1, dropID);
rs = pstm.executeQuery();
rs.last();
int rows = rs.getRow();
mobID = new int[rows];
min = new int[rows];
max = new int[rows];
chance = new double[rows];
name = new String[rows];
rs.beforeFirst();
int i = 0;
while(rs.next()) {
mobID[i] = rs.getInt("mobId");
min[i] = rs.getInt("min");
max[i] = rs.getInt("max");
chance[i] = rs.getInt("chance") / (double)10000;
i++;
}
rs.close();
pstm.close();
pc.sendPackets(new S_SystemMessage(blessed + item.getName() + "(" + dropID + ") 掉落查詢:"));
for (int j = 0; j < mobID.length; j++) {
pstm = con.prepareStatement("SELECT name FROM npc WHERE npcid=?");
pstm.setInt(1, mobID[j]);
rs = pstm.executeQuery();
while(rs.next()) {
name[j] = rs.getString("name");
}
rs.close();
pstm.close();
pc.sendPackets(new S_SystemMessage("數量: " + min[j] + "~" + max[j] + " 怪物: " + mobID[j] + " " + name[j] + " 機率: " + chance[j] + "%"));
}
} catch(Exception e) {
pc.sendPackets(new S_SystemMessage("請輸入 ." + cmdName + " [物品編號]。"));
} finally {
SQLUtil.close(rs);
SQLUtil.close(pstm);
SQLUtil.close(con);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -