Merge branch 'master' of http://192.168.200.25:3000/Lenheart/MXD-Server
# Conflicts: # src/gui/tw/Drop.java
This commit is contained in:
commit
bd92c59240
|
|
@ -1,15 +1,23 @@
|
||||||
package gui.tw;
|
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 database.DBConPool;
|
||||||
|
import gui.Start;
|
||||||
|
import provider.MapleData;
|
||||||
|
import provider.MapleDataTool;
|
||||||
import server.MapleItemInformationProvider;
|
import server.MapleItemInformationProvider;
|
||||||
import server.life.MapleLifeFactory;
|
import server.life.MapleLifeFactory;
|
||||||
import server.life.MapleMonster;
|
import server.life.MapleMonster;
|
||||||
import server.life.MapleMonsterInformationProvider;
|
import server.life.MapleMonsterInformationProvider;
|
||||||
import server.life.MonsterGlobalDropEntry;
|
import server.life.MonsterGlobalDropEntry;
|
||||||
import tools.FileoutputUtil;
|
import tools.FileoutputUtil;
|
||||||
|
import tools.StringUtil;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.table.DefaultTableModel;
|
import javax.swing.table.DefaultTableModel;
|
||||||
|
import java.io.File;
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
@ -105,18 +113,15 @@ public class Drop {
|
||||||
b.setItemId(rs.getInt("itemid"));
|
b.setItemId(rs.getInt("itemid"));
|
||||||
b.setItenName(MapleItemInformationProvider.getInstance().getName(rs.getInt("itemid")));
|
b.setItenName(MapleItemInformationProvider.getInstance().getName(rs.getInt("itemid")));
|
||||||
try{
|
try{
|
||||||
MapleMonster dropperid1 = MapleLifeFactory.getMonster(rs.getInt("dropperid"));
|
|
||||||
if (dropperid1 != null) {
|
String string = MapleDataTool.getString((rs.getInt("dropperid") + "/name"), MapleLifeFactory.mobStringData, "未知怪物");
|
||||||
b.setDropName(dropperid1.getStats().getName());
|
b.setDropName(string);
|
||||||
} else {
|
|
||||||
b.setDropName("未查询到怪物");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception e){
|
catch (Exception e){
|
||||||
b.setDropName("无名字");
|
b.setDropName("无名字");
|
||||||
};
|
};
|
||||||
b.setChance(rs.getInt("chance"));
|
b.setChance(rs.getInt("chance"));
|
||||||
b.setChance(rs.getInt("chance"));
|
|
||||||
mobs.add(b);
|
mobs.add(b);
|
||||||
}
|
}
|
||||||
rs.close();
|
rs.close();
|
||||||
|
|
@ -244,7 +249,6 @@ public class Drop {
|
||||||
* @param chance 爆率
|
* @param chance 爆率
|
||||||
*/
|
*/
|
||||||
public static void insertGWId(int dropperid, int itemid, int chance) {
|
public static void insertGWId(int dropperid, int itemid, int chance) {
|
||||||
MapleMonster dropperid1 = MapleLifeFactory.getMonster(dropperid);
|
|
||||||
try {
|
try {
|
||||||
final Connection con = (Connection) DBConPool.getInstance().getDataSource().getConnection();
|
final Connection con = (Connection) DBConPool.getInstance().getDataSource().getConnection();
|
||||||
PreparedStatement ps = null;
|
PreparedStatement ps = null;
|
||||||
|
|
@ -263,13 +267,12 @@ public class Drop {
|
||||||
b.setDropperid(dropperid);
|
b.setDropperid(dropperid);
|
||||||
b.setItemId(itemid);
|
b.setItemId(itemid);
|
||||||
b.setItenName(MapleItemInformationProvider.getInstance().getName(itemid));
|
b.setItenName(MapleItemInformationProvider.getInstance().getName(itemid));
|
||||||
if (dropperid1 != null) {
|
String string = MapleDataTool.getString((dropperid + "/name"), MapleLifeFactory.mobStringData, "MISSINGNO");
|
||||||
b.setDropName(dropperid1.getStats().getName());
|
|
||||||
} else {
|
b.setDropName(string);
|
||||||
b.setDropName("未查询到怪物");
|
|
||||||
}
|
|
||||||
b.setChance(chance);
|
b.setChance(chance);
|
||||||
QQS.add(b);
|
mobs.add(b);
|
||||||
|
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
System.err.println("[" + FileoutputUtil.CurrentReadable_Time() + "]刷新出错:" + ex.getMessage());
|
System.err.println("[" + FileoutputUtil.CurrentReadable_Time() + "]刷新出错:" + ex.getMessage());
|
||||||
|
|
@ -311,6 +314,30 @@ public class Drop {
|
||||||
return QQS;
|
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
|
* @param itemid 物品id
|
||||||
|
|
@ -371,13 +398,41 @@ public class Drop {
|
||||||
}
|
}
|
||||||
MapleMonsterInformationProvider.getInstance().getGlobalDrop().clear();
|
MapleMonsterInformationProvider.getInstance().getGlobalDrop().clear();
|
||||||
MapleMonsterInformationProvider.getInstance().retrieveGlobal();
|
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;
|
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;
|
import provider.MapleDataProvider;
|
||||||
|
|
||||||
public class MapleLifeFactory {
|
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 stringDataWZ = MapleDataProviderFactory.getDataProvider("String.wz");
|
||||||
private static final MapleDataProvider etcDataWZ = MapleDataProviderFactory.getDataProvider("Etc.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 npcStringData = stringDataWZ.getData("Npc.img");
|
||||||
private static final MapleData npclocData = etcDataWZ.getData("NpcLocation.img");
|
private static final MapleData npclocData = etcDataWZ.getData("NpcLocation.img");
|
||||||
private static final Map<Integer, String> npcNames = new HashMap();
|
private static final Map<Integer, String> npcNames = new HashMap();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue