增加导入导出 增加不开服务端也能获取怪物名字
This commit is contained in:
parent
6c7889169e
commit
8accc6cca2
|
|
@ -1,15 +1,23 @@
|
|||
package gui.tw;
|
||||
|
||||
import cn.hutool.core.io.file.FileReader;
|
||||
import cn.hutool.core.io.file.FileWriter;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import database.DBConPool;
|
||||
import gui.Start;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.MapleItemInformationProvider;
|
||||
import server.life.MapleLifeFactory;
|
||||
import server.life.MapleMonster;
|
||||
import server.life.MapleMonsterInformationProvider;
|
||||
import server.life.MonsterGlobalDropEntry;
|
||||
import tools.FileoutputUtil;
|
||||
import tools.StringUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import java.io.File;
|
||||
import java.sql.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
|
|
@ -105,18 +113,15 @@ public class Drop {
|
|||
b.setItemId(rs.getInt("itemid"));
|
||||
b.setItenName(MapleItemInformationProvider.getInstance().getName(rs.getInt("itemid")));
|
||||
try{
|
||||
MapleMonster dropperid1 = MapleLifeFactory.getMonster(rs.getInt("dropperid"));
|
||||
if (dropperid1 != null) {
|
||||
b.setDropName(dropperid1.getStats().getName());
|
||||
} else {
|
||||
b.setDropName("未查询到怪物");
|
||||
}
|
||||
|
||||
String string = MapleDataTool.getString((rs.getInt("dropperid") + "/name"), MapleLifeFactory.mobStringData, "未知怪物");
|
||||
b.setDropName(string);
|
||||
|
||||
}
|
||||
catch (Exception e){
|
||||
b.setDropName("无名字");
|
||||
};
|
||||
b.setChance(rs.getInt("chance"));
|
||||
b.setChance(rs.getInt("chance"));
|
||||
mobs.add(b);
|
||||
}
|
||||
rs.close();
|
||||
|
|
@ -244,7 +249,6 @@ public class Drop {
|
|||
* @param chance 爆率
|
||||
*/
|
||||
public static void insertGWId(int dropperid, int itemid, int chance) {
|
||||
MapleMonster dropperid1 = MapleLifeFactory.getMonster(itemid);
|
||||
try {
|
||||
final Connection con = (Connection) DBConPool.getInstance().getDataSource().getConnection();
|
||||
PreparedStatement ps = null;
|
||||
|
|
@ -263,13 +267,12 @@ public class Drop {
|
|||
b.setDropperid(dropperid);
|
||||
b.setItemId(itemid);
|
||||
b.setItenName(MapleItemInformationProvider.getInstance().getName(itemid));
|
||||
if (dropperid1 != null) {
|
||||
b.setDropName(dropperid1.getStats().getName());
|
||||
} else {
|
||||
b.setDropName("未查询到怪物");
|
||||
}
|
||||
String string = MapleDataTool.getString((dropperid + "/name"), MapleLifeFactory.mobStringData, "MISSINGNO");
|
||||
|
||||
b.setDropName(string);
|
||||
|
||||
b.setChance(chance);
|
||||
QQS.add(b);
|
||||
mobs.add(b);
|
||||
|
||||
} catch (SQLException ex) {
|
||||
System.err.println("[" + FileoutputUtil.CurrentReadable_Time() + "]刷新出错:" + ex.getMessage());
|
||||
|
|
@ -311,6 +314,30 @@ public class Drop {
|
|||
return QQS;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据序号 删除全局爆率
|
||||
* @param id 序号
|
||||
*/
|
||||
public static void deleteQQId(int id) {
|
||||
try {
|
||||
final Connection con = (Connection) DBConPool.getInstance().getDataSource().getConnection();
|
||||
PreparedStatement ps = null;
|
||||
|
||||
ps = con.prepareStatement("DELETE FROM drop_data_global where id = ?");
|
||||
ps.setInt(1,id);
|
||||
ps.execute();
|
||||
ps.close();
|
||||
con.close();
|
||||
} catch (SQLException ex) {
|
||||
System.err.println("[" + FileoutputUtil.CurrentReadable_Time() + "]删除出错:" + ex.getMessage());
|
||||
}
|
||||
MapleMonsterInformationProvider.getInstance().getGlobalDrop().clear();
|
||||
MapleMonsterInformationProvider.getInstance().retrieveGlobal();
|
||||
|
||||
QQS = QQS.stream().filter(drop -> drop.getId() != id)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改全局爆率
|
||||
* @param itemid 物品id
|
||||
|
|
@ -371,13 +398,41 @@ public class Drop {
|
|||
}
|
||||
MapleMonsterInformationProvider.getInstance().getGlobalDrop().clear();
|
||||
MapleMonsterInformationProvider.getInstance().retrieveGlobal();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量增加全局爆率
|
||||
* @param drops
|
||||
*/
|
||||
public static void insertQQALL(List<Drop> drops) {
|
||||
for (Drop drop : drops) {
|
||||
|
||||
|
||||
try {
|
||||
final Connection con = (Connection) DBConPool.getInstance().getDataSource().getConnection();
|
||||
PreparedStatement ps = null;
|
||||
|
||||
ps = con.prepareStatement("INSERT INTO drop_data_global (continent,droptype,itemid,minimum_quantity,maximum_quantity,chance) VALUES(1,1,?,1,1,?)", Statement.RETURN_GENERATED_KEYS);
|
||||
ps.setInt(1, drop.getItemId());
|
||||
ps.setInt(2, drop.getChance());
|
||||
int id = ps.executeUpdate();
|
||||
ps.close();
|
||||
con.close();
|
||||
|
||||
Drop b = new Drop();
|
||||
b.setId(id);
|
||||
b.setItemId(drop.getItemId());
|
||||
b.setItenName(MapleItemInformationProvider.getInstance().getName(drop.getItemId()));
|
||||
b.setChance(drop.getChance());
|
||||
QQS.add(b);
|
||||
} catch (SQLException ex) {
|
||||
System.err.println("[" + FileoutputUtil.CurrentReadable_Time() + "]刷新出错:" + ex.getMessage());
|
||||
}
|
||||
}
|
||||
MapleMonsterInformationProvider.getInstance().getGlobalDrop().clear();
|
||||
MapleMonsterInformationProvider.getInstance().retrieveGlobal();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除全局爆率集合
|
||||
*/
|
||||
|
|
@ -522,4 +577,55 @@ public class Drop {
|
|||
return drops;
|
||||
}
|
||||
|
||||
/**
|
||||
*导出
|
||||
*/
|
||||
public static void exportData (String file,List<Drop> drops){
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("bl", drops);
|
||||
|
||||
String jsonString1 = jsonObject1.toJSONString();
|
||||
FileWriter fileWriter = new FileWriter(file);
|
||||
fileWriter.write(jsonString1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入全局
|
||||
*/
|
||||
public static void importDataQQ(String file){
|
||||
FileReader fileReader = new FileReader(file);
|
||||
String result3 = fileReader.readString();
|
||||
//转json
|
||||
JSONObject jsonObject1 = JSONObject.parseObject(result3);
|
||||
List<Drop> bl = jsonObject1.getJSONArray("bl").toJavaList(Drop.class);
|
||||
|
||||
getQQS();
|
||||
insertQQALL(bl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入怪物
|
||||
*/
|
||||
public static void importDataMob(String file){
|
||||
FileReader fileReader = new FileReader(file);
|
||||
String result3 = fileReader.readString();
|
||||
//转json
|
||||
JSONObject jsonObject1 = JSONObject.parseObject(result3);
|
||||
List<Drop> bl = jsonObject1.getJSONArray("bl").toJavaList(Drop.class);
|
||||
|
||||
getMobBLs();
|
||||
for (Drop drop : bl) {
|
||||
insertGWId(drop.getDropperid(),drop.getItemId(), drop.getChance());
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
List<Drop> qqs = getMobBLs();
|
||||
exportData("E:\\MXD\\cs.txt", qqs);
|
||||
|
||||
importDataQQ("E:\\MXD\\cs.txt");
|
||||
|
||||
// insertGWId(3037,11,11);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,10 +25,10 @@ import provider.MapleData;
|
|||
import provider.MapleDataProvider;
|
||||
|
||||
public class MapleLifeFactory {
|
||||
private static final MapleDataProvider data = MapleDataProviderFactory.getDataProvider("Mob.wz");
|
||||
public static final MapleDataProvider data = MapleDataProviderFactory.getDataProvider("Mob.wz");
|
||||
private static final MapleDataProvider stringDataWZ = MapleDataProviderFactory.getDataProvider("String.wz");
|
||||
private static final MapleDataProvider etcDataWZ = MapleDataProviderFactory.getDataProvider("Etc.wz");
|
||||
private static final MapleData mobStringData = stringDataWZ.getData("Mob.img");
|
||||
public static final MapleData mobStringData = stringDataWZ.getData("Mob.img");
|
||||
private static final MapleData npcStringData = stringDataWZ.getData("Npc.img");
|
||||
private static final MapleData npclocData = etcDataWZ.getData("NpcLocation.img");
|
||||
private static final Map<Integer, String> npcNames = new HashMap();
|
||||
|
|
|
|||
Loading…
Reference in New Issue