From 8accc6cca20fda86413af160fd044dcf202ce098 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=AA=E9=A3=8E?= <1213457484@qq.com> Date: Fri, 14 Mar 2025 16:09:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AF=BC=E5=85=A5=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=20=E5=A2=9E=E5=8A=A0=E4=B8=8D=E5=BC=80=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E7=AB=AF=E4=B9=9F=E8=83=BD=E8=8E=B7=E5=8F=96=E6=80=AA?= =?UTF-8?q?=E7=89=A9=E5=90=8D=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gui/tw/Drop.java | 140 ++++++++++++++++++++++---- src/server/life/MapleLifeFactory.java | 4 +- 2 files changed, 125 insertions(+), 19 deletions(-) diff --git a/src/gui/tw/Drop.java b/src/gui/tw/Drop.java index f49237b..f496697 100644 --- a/src/gui/tw/Drop.java +++ b/src/gui/tw/Drop.java @@ -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 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 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 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 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 qqs = getMobBLs(); + exportData("E:\\MXD\\cs.txt", qqs); + + importDataQQ("E:\\MXD\\cs.txt"); + +// insertGWId(3037,11,11); + } + } diff --git a/src/server/life/MapleLifeFactory.java b/src/server/life/MapleLifeFactory.java index 909c918..dc923b3 100644 --- a/src/server/life/MapleLifeFactory.java +++ b/src/server/life/MapleLifeFactory.java @@ -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 npcNames = new HashMap();