修复bug
This commit is contained in:
		
							
								
								
									
										5
									
								
								.idea/compiler.xml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										5
									
								
								.idea/compiler.xml
									
									
									
										generated
									
									
									
								
							| @@ -11,4 +11,9 @@ | |||||||
|       </profile> |       </profile> | ||||||
|     </annotationProcessing> |     </annotationProcessing> | ||||||
|   </component> |   </component> | ||||||
|  |   <component name="JavacSettings"> | ||||||
|  |     <option name="ADDITIONAL_OPTIONS_OVERRIDE"> | ||||||
|  |       <module name="SrDisassemble" options="-extdirs lib" /> | ||||||
|  |     </option> | ||||||
|  |   </component> | ||||||
| </project> | </project> | ||||||
							
								
								
									
										10
									
								
								.idea/libraries/lib__6_.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								.idea/libraries/lib__6_.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | |||||||
|  | <component name="libraryTable"> | ||||||
|  |   <library name="lib (6)"> | ||||||
|  |     <CLASSES> | ||||||
|  |       <root url="file://$PROJECT_DIR$/lib" /> | ||||||
|  |     </CLASSES> | ||||||
|  |     <JAVADOC /> | ||||||
|  |     <SOURCES /> | ||||||
|  |     <jarDirectory url="file://$PROJECT_DIR$/lib" recursive="false" /> | ||||||
|  |   </library> | ||||||
|  | </component> | ||||||
							
								
								
									
										10
									
								
								.idea/libraries/lib__7_.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								.idea/libraries/lib__7_.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | |||||||
|  | <component name="libraryTable"> | ||||||
|  |   <library name="lib (7)"> | ||||||
|  |     <CLASSES> | ||||||
|  |       <root url="file://$PROJECT_DIR$/lib" /> | ||||||
|  |     </CLASSES> | ||||||
|  |     <JAVADOC /> | ||||||
|  |     <SOURCES /> | ||||||
|  |     <jarDirectory url="file://$PROJECT_DIR$/lib" recursive="false" /> | ||||||
|  |   </library> | ||||||
|  | </component> | ||||||
| @@ -21,6 +21,17 @@ | |||||||
|           <target>${java.version}</target> |           <target>${java.version}</target> | ||||||
|         </configuration> |         </configuration> | ||||||
|       </plugin> |       </plugin> | ||||||
|  |       <plugin> | ||||||
|  |         <artifactId>maven-compiler-plugin</artifactId> | ||||||
|  |         <configuration> | ||||||
|  |           <source>1.8</source> | ||||||
|  |           <target>1.8</target> | ||||||
|  |           <encoding>UTF-8</encoding> | ||||||
|  |           <compilerArguments> | ||||||
|  |             <extdirs>lib</extdirs> | ||||||
|  |           </compilerArguments> | ||||||
|  |         </configuration> | ||||||
|  |       </plugin> | ||||||
|       <plugin> |       <plugin> | ||||||
|         <artifactId>maven-shade-plugin</artifactId> |         <artifactId>maven-shade-plugin</artifactId> | ||||||
|         <version>3.2.4</version> |         <version>3.2.4</version> | ||||||
|   | |||||||
							
								
								
									
										17
									
								
								pom.xml
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								pom.xml
									
									
									
									
									
								
							| @@ -27,6 +27,18 @@ | |||||||
|           <target>${java.version}</target> |           <target>${java.version}</target> | ||||||
|         </configuration> |         </configuration> | ||||||
|       </plugin> |       </plugin> | ||||||
|  |         <plugin> | ||||||
|  |             <artifactId>maven-compiler-plugin</artifactId> | ||||||
|  |             <configuration> | ||||||
|  |                 <source>1.8</source> | ||||||
|  |                 <target>1.8</target> | ||||||
|  |                 <encoding>UTF-8</encoding> | ||||||
|  |                 <compilerArguments> | ||||||
|  |                     <extdirs>lib</extdirs><!--指定外部lib--> | ||||||
|  |                 </compilerArguments> | ||||||
|  |             </configuration> | ||||||
|  |         </plugin> | ||||||
|  |  | ||||||
|       <plugin> |       <plugin> | ||||||
|         <groupId>org.apache.maven.plugins</groupId> |         <groupId>org.apache.maven.plugins</groupId> | ||||||
|         <artifactId>maven-shade-plugin</artifactId> |         <artifactId>maven-shade-plugin</artifactId> | ||||||
| @@ -78,11 +90,6 @@ | |||||||
|           <artifactId>mysql-connector-java</artifactId> |           <artifactId>mysql-connector-java</artifactId> | ||||||
|           <version>8.0.28</version> |           <version>8.0.28</version> | ||||||
|       </dependency> |       </dependency> | ||||||
|       <dependency> |  | ||||||
|           <groupId>org.mybatis</groupId> |  | ||||||
|           <artifactId>mybatis</artifactId> |  | ||||||
|           <version>3.5.7</version> |  | ||||||
|       </dependency> |  | ||||||
|       <dependency> |       <dependency> | ||||||
|           <groupId>junit</groupId> |           <groupId>junit</groupId> | ||||||
|           <artifactId>junit</artifactId> |           <artifactId>junit</artifactId> | ||||||
|   | |||||||
| @@ -2,15 +2,16 @@ package com.yuyu.srdisassemble; | |||||||
|  |  | ||||||
| import com.sakurarealm.sritem.bukkit.command.CommandBase; | import com.sakurarealm.sritem.bukkit.command.CommandBase; | ||||||
| import com.yuyu.srdisassemble.command.DisCommand; | import com.yuyu.srdisassemble.command.DisCommand; | ||||||
| import com.yuyu.srdisassemble.command.MeltCommand; |  | ||||||
| import com.yuyu.srdisassemble.command.RepairCommand; |  | ||||||
| import com.yuyu.srdisassemble.config.ConfigManager; | import com.yuyu.srdisassemble.config.ConfigManager; | ||||||
| import com.yuyu.srdisassemble.data.JdbcSqlClass; | import com.yuyu.srdisassemble.data.JdbcSqlClass; | ||||||
| import com.yuyu.srdisassemble.disassemeble.TemporarilyBox; | import com.yuyu.srdisassemble.disassemeble.TemporarilyBox; | ||||||
| import lombok.Getter; | import lombok.Getter; | ||||||
|  | import org.bukkit.Bukkit; | ||||||
| import org.bukkit.ChatColor; | import org.bukkit.ChatColor; | ||||||
| import org.bukkit.plugin.java.JavaPlugin; | import org.bukkit.plugin.java.JavaPlugin; | ||||||
|  |  | ||||||
|  | import java.util.logging.Level; | ||||||
|  |  | ||||||
| public final class SrDisassemble extends JavaPlugin { | public final class SrDisassemble extends JavaPlugin { | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -30,6 +31,7 @@ public final class SrDisassemble extends JavaPlugin { | |||||||
|         commandBase.registerSubCommand("open",new DisCommand()); |         commandBase.registerSubCommand("open",new DisCommand()); | ||||||
|         commandBase.registerSubCommand("reload",new DisCommand()); |         commandBase.registerSubCommand("reload",new DisCommand()); | ||||||
|  |  | ||||||
|  |         Bukkit.getServer().getPluginManager().registerEvents(new TemporarilyBox(),this); | ||||||
|  |  | ||||||
|         //读取暂存箱 |         //读取暂存箱 | ||||||
|         JdbcSqlClass.createPauseBoxTable(); |         JdbcSqlClass.createPauseBoxTable(); | ||||||
| @@ -37,11 +39,12 @@ public final class SrDisassemble extends JavaPlugin { | |||||||
|         TemporarilyBox.getPauseBoxData(); |         TemporarilyBox.getPauseBoxData(); | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void onDisable() { |     public void onDisable() { | ||||||
|         JdbcSqlClass.clearPauseBoxTable(); |         JdbcSqlClass.clearPauseBoxTable("TemporarilyBox-disassemble"); | ||||||
|         // Plugin shutdown logic |         // Plugin shutdown logic | ||||||
|         TemporarilyBox.savePauseBoxData(); |         TemporarilyBox.savePauseBoxData(); | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -1,10 +1,8 @@ | |||||||
| package com.yuyu.srdisassemble.command; | package com.yuyu.srdisassemble.command; | ||||||
|  |  | ||||||
| import com.germ.germplugin.api.dynamic.gui.GermGuiScreen; |  | ||||||
| import com.sakurarealm.sritem.bukkit.command.SubCommand; | import com.sakurarealm.sritem.bukkit.command.SubCommand; | ||||||
| import com.yuyu.srdisassemble.SrDisassemble; | import com.yuyu.srdisassemble.SrDisassemble; | ||||||
| import com.yuyu.srdisassemble.disassemeble.DisassembleManager; | import com.yuyu.srdisassemble.disassemeble.DisassembleManager; | ||||||
| import com.yuyu.srdisassemble.disassemeble.SassembleGuiService; |  | ||||||
| import com.yuyu.srdisassemble.disassemeble.TemporarilyBox; | import com.yuyu.srdisassemble.disassemeble.TemporarilyBox; | ||||||
| import org.bukkit.Bukkit; | import org.bukkit.Bukkit; | ||||||
| import org.bukkit.ChatColor; | import org.bukkit.ChatColor; | ||||||
| @@ -27,6 +25,11 @@ public class DisCommand implements SubCommand { | |||||||
|                 //重载文件 |                 //重载文件 | ||||||
|                 SrDisassemble.getConfigManager().reload(); |                 SrDisassemble.getConfigManager().reload(); | ||||||
|                 return; |                 return; | ||||||
|  |             } else if (strings[0].equalsIgnoreCase("clear")) { | ||||||
|  |                 commandSender.sendMessage(ChatColor.GREEN+"分解gui缓存清空"); | ||||||
|  |                 TemporarilyBox.temporarilyBoxHashMap.clear(); | ||||||
|  |                 TemporarilyBox.getPauseBoxData(); | ||||||
|  |                 return; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -43,7 +46,7 @@ public class DisCommand implements SubCommand { | |||||||
|         } |         } | ||||||
|  |  | ||||||
|             //为玩家打开GUI列表 |             //为玩家打开GUI列表 | ||||||
|             DisassembleManager.getInstance().open(player); |         DisassembleManager.getInstance().open(player); | ||||||
|  |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -50,19 +50,21 @@ public class ConfigManager { | |||||||
|         List<String> disProductConfigStringList = disProductConfig.getStringList("SrDisassemble"); |         List<String> disProductConfigStringList = disProductConfig.getStringList("SrDisassemble"); | ||||||
|         for (String disProductConfigString : disProductConfigStringList) { |         for (String disProductConfigString : disProductConfigStringList) { | ||||||
|             HashMap<String,DisProduct> disProductHashMap = new HashMap<>(); |             HashMap<String,DisProduct> disProductHashMap = new HashMap<>(); | ||||||
|  |             int countWeight = 0; | ||||||
|             //循环读取每个需要分解的产物 |             //循环读取每个需要分解的产物 | ||||||
|             int anInt = disToItemProduct.getInt("SrDisassemble." + disProductConfigString + ".disTime"); |             int anInt = disToItemProduct.getInt("SrDisassemble." + disProductConfigString + ".disTime"); | ||||||
|             String tagetIndex = disToItemProduct.getString("SrDisassemble." + disProductConfigString + ".index"); |             String tagetIndex = disToItemProduct.getString("SrDisassemble." + disProductConfigString + ".index"); | ||||||
|             CanDisItem canDisItem = new CanDisItem(disProductConfigString, anInt,disProductConfigString,tagetIndex); |             CanDisItem canDisItem = new CanDisItem(disProductConfigString, anInt,disProductConfigString,tagetIndex); | ||||||
|             List<String> stringList = disToItemProduct.getStringList("SrDisassemble." + disProductConfigString +".disProduct"); |             List<String> stringList = disToItemProduct.getStringList("SrDisassemble." + disProductConfigString +".disProduct"); | ||||||
|             for (String product : stringList) { |             for (String product : stringList) { | ||||||
|                 Double proMax = itemDetailProduct.getDouble("SrDisassemble."+disProductConfigString+"."+product+".probabilityMax"); |                 int proMax = itemDetailProduct.getInt("SrDisassemble."+disProductConfigString+"."+product+".weight"); | ||||||
|                 Double proMin = itemDetailProduct.getDouble("SrDisassemble."+disProductConfigString+"."+product+".probabilityMin"); |  | ||||||
|                 String index = itemDetailProduct.getString("SrDisassemble."+disProductConfigString+"."+product+".index"); |                 String index = itemDetailProduct.getString("SrDisassemble."+disProductConfigString+"."+product+".index"); | ||||||
|                 DisProduct disPojo = new DisProduct(product, index, proMax, proMin); |                 DisProduct disPojo = new DisProduct(product, index, proMax); | ||||||
|  |                 countWeight+= proMax; | ||||||
|                 logger.info(ChatColor.GREEN+disPojo.toString()); |                 logger.info(ChatColor.GREEN+disPojo.toString()); | ||||||
|                 disProductHashMap.put(product,disPojo); |                 disProductHashMap.put(product,disPojo); | ||||||
|             } |             } | ||||||
|  |             canDisItem.setCoutWeight(countWeight); | ||||||
|             canDisItem.setDisProductHashMap(disProductHashMap); |             canDisItem.setDisProductHashMap(disProductHashMap); | ||||||
|  |  | ||||||
|             this.disProductHashMap.put(disProductConfigString,canDisItem); |             this.disProductHashMap.put(disProductConfigString,canDisItem); | ||||||
| @@ -119,15 +121,17 @@ public class ConfigManager { | |||||||
|             int anInt = disToItemProduct.getInt("SrDisassemble." + disProductConfigString + ".disTime"); |             int anInt = disToItemProduct.getInt("SrDisassemble." + disProductConfigString + ".disTime"); | ||||||
|             String tagetIndex = disToItemProduct.getString("SrDisassemble." + disProductConfigString + ".index"); |             String tagetIndex = disToItemProduct.getString("SrDisassemble." + disProductConfigString + ".index"); | ||||||
|             CanDisItem canDisItem = new CanDisItem(disProductConfigString, anInt,disProductConfigString,tagetIndex); |             CanDisItem canDisItem = new CanDisItem(disProductConfigString, anInt,disProductConfigString,tagetIndex); | ||||||
|  |             int  countWeight = 0; | ||||||
|             List<String> stringList = disToItemProduct.getStringList("SrDisassemble." + disProductConfigString +".disProduct"); |             List<String> stringList = disToItemProduct.getStringList("SrDisassemble." + disProductConfigString +".disProduct"); | ||||||
|             for (String product : stringList) { |             for (String product : stringList) { | ||||||
|                 Double proMax = itemDetailProduct.getDouble("SrDisassemble."+disProductConfigString+"."+product+".probabilityMax"); |                 int proMax = itemDetailProduct.getInt("SrDisassemble."+disProductConfigString+"."+product+".weight"); | ||||||
|                 Double proMin = itemDetailProduct.getDouble("SrDisassemble."+disProductConfigString+"."+product+".probabilityMin"); |  | ||||||
|                 String index = itemDetailProduct.getString("SrDisassemble."+disProductConfigString+"."+product+".index"); |                 String index = itemDetailProduct.getString("SrDisassemble."+disProductConfigString+"."+product+".index"); | ||||||
|                 DisProduct disPojo = new DisProduct(product, index, proMax, proMin); |                 DisProduct disPojo = new DisProduct(product, index, proMax); | ||||||
|  |                 countWeight+= proMax; | ||||||
|                 logger.info(ChatColor.GREEN+disPojo.toString()); |                 logger.info(ChatColor.GREEN+disPojo.toString()); | ||||||
|                 disProductHashMap.put(product,disPojo); |                 disProductHashMap.put(product,disPojo); | ||||||
|             } |             } | ||||||
|  |             canDisItem.setCoutWeight(countWeight); | ||||||
|             canDisItem.setDisProductHashMap(disProductHashMap); |             canDisItem.setDisProductHashMap(disProductHashMap); | ||||||
|  |  | ||||||
|             this.disProductHashMap.put(disProductConfigString,canDisItem); |             this.disProductHashMap.put(disProductConfigString,canDisItem); | ||||||
|   | |||||||
| @@ -21,6 +21,7 @@ public class JdbcSqlClass { | |||||||
|     private static String user; |     private static String user; | ||||||
|     private static String password; |     private static String password; | ||||||
|     private static Connection con; |     private static Connection con; | ||||||
|  |     private static boolean bool = false; | ||||||
|  |  | ||||||
|  |  | ||||||
|     public static void openConnection() { |     public static void openConnection() { | ||||||
| @@ -240,19 +241,21 @@ public class JdbcSqlClass { | |||||||
|     /** |     /** | ||||||
|      * 清空数据 |      * 清空数据 | ||||||
|      */ |      */ | ||||||
|     public static void clearPauseBoxTable(){ |     public static void clearPauseBoxTable(String guiname){ | ||||||
|  |  | ||||||
|  |  | ||||||
|         try { |         try { | ||||||
|  |  | ||||||
|             Statement statement = getConnection(); |             Statement statement = getConnection(); | ||||||
|             String sql = "delete from pausebox"; |             String sql = "delete from pausebox where guiname = '"+guiname+"'"; | ||||||
|  |  | ||||||
|             statement.executeUpdate(sql); |             statement.executeUpdate(sql); | ||||||
|         } catch (SQLException e) { |         } catch (SQLException e) { | ||||||
|             throw new RuntimeException(e); |             throw new RuntimeException(e); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         bool = true; | ||||||
|  |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static int addColumnPauseBox(String columns){ |     public static int addColumnPauseBox(String columns){ | ||||||
| @@ -446,12 +449,12 @@ public class JdbcSqlClass { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static List<String> getPlayerList(){ |     public static List<String> getPlayerList(String guiname){ | ||||||
|  |  | ||||||
|         List<String> userList = new ArrayList<>(); |         List<String> userList = new ArrayList<>(); | ||||||
|  |  | ||||||
|         Statement statement = getConnection(); |         Statement statement = getConnection(); | ||||||
|         String sql = "select username from pausebox"; |         String sql = "select username from pausebox where guiname = '"+guiname+"'"; | ||||||
|         try { |         try { | ||||||
|             ResultSet resultSet = statement.executeQuery(sql); |             ResultSet resultSet = statement.executeQuery(sql); | ||||||
|             while (resultSet.next()){ |             while (resultSet.next()){ | ||||||
| @@ -503,11 +506,11 @@ public class JdbcSqlClass { | |||||||
|      * @param player |      * @param player | ||||||
|      * @return |      * @return | ||||||
|      */ |      */ | ||||||
|     public static List<PauseBox> getPauseBoxData(String player) { |     public static List<PauseBox> getPauseBoxData(String player,String guiname) { | ||||||
|  |  | ||||||
|         List<PauseBox> pauseBoxList = new ArrayList<>(); |         List<PauseBox> pauseBoxList = new ArrayList<>(); | ||||||
|         Statement statement = getConnection(); |         Statement statement = getConnection(); | ||||||
|         String sql = "select * from pausebox where username = '"+player+"' and guiname = 'TemporarilyBox'"; |         String sql = "select * from pausebox where username = '"+player+"' and guiname = '"+guiname+"'"; | ||||||
|         try { |         try { | ||||||
|             ResultSet resultSet = statement.executeQuery(sql); |             ResultSet resultSet = statement.executeQuery(sql); | ||||||
|             while (resultSet.next()){ |             while (resultSet.next()){ | ||||||
|   | |||||||
| @@ -50,7 +50,7 @@ public class DisassembleManager { | |||||||
|  |  | ||||||
|  |  | ||||||
|     public static ConfigurationSection getTemporarilyBox(){ |     public static ConfigurationSection getTemporarilyBox(){ | ||||||
|         return DisassembleManager.getGermGui( "disassemble","TemporarilyBox"); |         return DisassembleManager.getGermGui( "disassemble","TemporarilyBox-disassemble"); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     //用于打开gui |     //用于打开gui | ||||||
| @@ -65,8 +65,6 @@ public class DisassembleManager { | |||||||
|                 return; |                 return; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |  | ||||||
|         //分解gui |         //分解gui | ||||||
|             SassembleGuiService sassembleGuiService = new SassembleGuiService(getDisassembleGui(), "disassemble", player); |             SassembleGuiService sassembleGuiService = new SassembleGuiService(getDisassembleGui(), "disassemble", player); | ||||||
|  |  | ||||||
| @@ -75,20 +73,4 @@ public class DisassembleManager { | |||||||
|         sassembleGuiService.openGui(player); |         sassembleGuiService.openGui(player); | ||||||
|         packscreen.openChildGui(player); |         packscreen.openChildGui(player); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * 用于打开回炉gui |  | ||||||
|      * @param player |  | ||||||
|      */ |  | ||||||
|     public void openMeltAgain(Player player) { |  | ||||||
|  |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * 用于打开维修gui |  | ||||||
|      * @param player |  | ||||||
|      */ |  | ||||||
|     public void openRepair(Player player) { |  | ||||||
|  |  | ||||||
|     } |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -11,6 +11,7 @@ import com.yuyu.srdisassemble.pojo.CanDisItem; | |||||||
| import com.yuyu.srdisassemble.pojo.DisProduct; | import com.yuyu.srdisassemble.pojo.DisProduct; | ||||||
| import com.yuyu.srdisassemble.pojo.DisassembleData; | import com.yuyu.srdisassemble.pojo.DisassembleData; | ||||||
| import com.yuyu.srdisassemble.utils.MinUtil; | import com.yuyu.srdisassemble.utils.MinUtil; | ||||||
|  | import org.bukkit.Bukkit; | ||||||
| import org.bukkit.ChatColor; | import org.bukkit.ChatColor; | ||||||
| import org.bukkit.Color; | import org.bukkit.Color; | ||||||
| import org.bukkit.Material; | import org.bukkit.Material; | ||||||
| @@ -53,6 +54,10 @@ public class SassembleGuiService extends GermGuiScreen { | |||||||
|         this.savePauseSlots(); |         this.savePauseSlots(); | ||||||
|         this.boolGui(); |         this.boolGui(); | ||||||
|         this.openPauseBox(); |         this.openPauseBox(); | ||||||
|  | //        this.setOpenedHandler((((player, germGuiScreen) -> { | ||||||
|  | //            this.getTemporarilyBox(); | ||||||
|  | //            this.openPauseBox(); | ||||||
|  | //        }))); | ||||||
|         this.setClosedHandler(((player, germGuiScreen) -> { |         this.setClosedHandler(((player, germGuiScreen) -> { | ||||||
|             //窗口关闭事件 |             //窗口关闭事件 | ||||||
|             this.returnItemStacks(player); |             this.returnItemStacks(player); | ||||||
| @@ -75,17 +80,14 @@ public class SassembleGuiService extends GermGuiScreen { | |||||||
|      * 获取暂存箱对象 |      * 获取暂存箱对象 | ||||||
|      */ |      */ | ||||||
|     public void getTemporarilyBox(){ |     public void getTemporarilyBox(){ | ||||||
|         this.temporarilyBoxScreen = TemporarilyBox.getGermGuiScreen(playerHost.getName(), "TemporarilyBox"); |         this.temporarilyBoxScreen = TemporarilyBox.getGermGuiScreen(playerHost.getName(), "TemporarilyBox-disassemble"); | ||||||
|         if (temporarilyBoxScreen == null) { |         if (temporarilyBoxScreen == null) { | ||||||
|             temporarilyBoxScreen = GermGuiScreen.getGermGuiScreen("TemporarilyBox", DisassembleManager.getTemporarilyBox()); |             temporarilyBoxScreen = GermGuiScreen.getGermGuiScreen("TemporarilyBox-disassemble", DisassembleManager.getTemporarilyBox()); | ||||||
|             TemporarilyBox.addGuiScreen(playerHost.getName(),"TemporarilyBox",temporarilyBoxScreen); |             TemporarilyBox.addGuiScreen(playerHost.getName(),"TemporarilyBox-disassemble",temporarilyBoxScreen); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     synchronized public void setItemToPauseBox(ItemStack item){ |     synchronized public void setItemToPauseBox(ItemStack item){ | ||||||
| //        if (!this.disassembleFlag){ |  | ||||||
| //            return; |  | ||||||
| //        } |  | ||||||
|         for (int i = 0; i <= 15 ; i++){ |         for (int i = 0; i <= 15 ; i++){ | ||||||
|             GermGuiSlot germGuiSlot = guiSlots.get(i); |             GermGuiSlot germGuiSlot = guiSlots.get(i); | ||||||
|             if (germGuiSlot.getItemStack().getType() == Material.AIR){ |             if (germGuiSlot.getItemStack().getType() == Material.AIR){ | ||||||
| @@ -106,7 +108,7 @@ public class SassembleGuiService extends GermGuiScreen { | |||||||
|      * gui关闭时保存暂存箱 |      * gui关闭时保存暂存箱 | ||||||
|      */ |      */ | ||||||
|     public void saveTemporarilyBox(){ |     public void saveTemporarilyBox(){ | ||||||
|         TemporarilyBox.addGuiScreen(playerHost.getName(), "TemporarilyBox",this.temporarilyBoxScreen); |         TemporarilyBox.addGuiScreen(playerHost.getName(), "TemporarilyBox-disassemble",this.temporarilyBoxScreen); | ||||||
|         TemporarilyBox.addGuiScreen(playerHost.getName(),"disassemble",this); |         TemporarilyBox.addGuiScreen(playerHost.getName(),"disassemble",this); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -128,7 +130,7 @@ public class SassembleGuiService extends GermGuiScreen { | |||||||
|             men1.setEnable(false); |             men1.setEnable(false); | ||||||
|             fire.setEnable(true); |             fire.setEnable(true); | ||||||
|             doorPause.setEnable(true); |             doorPause.setEnable(true); | ||||||
|             int calculateMinutesDifference = MinUtil.calculateMinutesDifference(data.getDisassembleTime()); |             int calculateMinutesDifference = MinUtil.calculateMinutesDifference(data.getDisassembleTime()) + 1; | ||||||
|             if (calculateMinutesDifference <= 0) { |             if (calculateMinutesDifference <= 0) { | ||||||
|                 //执行语句说明分解完成 |                 //执行语句说明分解完成 | ||||||
|                 this.disassembleComplete(); |                 this.disassembleComplete(); | ||||||
| @@ -152,7 +154,7 @@ public class SassembleGuiService extends GermGuiScreen { | |||||||
|                 label.setTexts(texts); |                 label.setTexts(texts); | ||||||
|                 label.setEnable(true); |                 label.setEnable(true); | ||||||
|                 executor.scheduleWithFixedDelay(() -> { |                 executor.scheduleWithFixedDelay(() -> { | ||||||
|                     int nums = MinUtil.calculateMinutesDifference(data.getDisassembleTime()); |                     int nums = MinUtil.calculateMinutesDifference(data.getDisassembleTime()) + 1; | ||||||
|  |  | ||||||
|                     String text = "##ACDA70D6还有"+nums+"分钟"; |                     String text = "##ACDA70D6还有"+nums+"分钟"; | ||||||
|                     texts.remove(1); |                     texts.remove(1); | ||||||
| @@ -184,7 +186,7 @@ public class SassembleGuiService extends GermGuiScreen { | |||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|  |  | ||||||
|                 },1, 1, TimeUnit.MINUTES); |                 },60,10 , TimeUnit.SECONDS); | ||||||
|                 //1分钟延迟,minTime分钟后执行 |                 //1分钟延迟,minTime分钟后执行 | ||||||
|             } |             } | ||||||
|  |  | ||||||
| @@ -233,8 +235,8 @@ public class SassembleGuiService extends GermGuiScreen { | |||||||
|         GermGuiSlot disassembleSlot = (GermGuiSlot) bgCanvas.getGuiPart("disassembleSlot"); |         GermGuiSlot disassembleSlot = (GermGuiSlot) bgCanvas.getGuiPart("disassembleSlot"); | ||||||
|  |  | ||||||
|         confirmButton.registerCallbackHandler((player, btn) -> { |         confirmButton.registerCallbackHandler((player, btn) -> { | ||||||
|                 this.disassemble(player); |  | ||||||
|                 cCanvas.setEnable(false); |                 cCanvas.setEnable(false); | ||||||
|  |                 this.disassemble(player); | ||||||
|         },GermGuiButton.EventType.LEFT_CLICK); |         },GermGuiButton.EventType.LEFT_CLICK); | ||||||
|  |  | ||||||
|         //取消事件 |         //取消事件 | ||||||
| @@ -246,7 +248,20 @@ public class SassembleGuiService extends GermGuiScreen { | |||||||
|         //油壶按钮绑定的事件触发画布显示 |         //油壶按钮绑定的事件触发画布显示 | ||||||
|         germGuiButton.registerCallbackHandler((player, btn) -> { |         germGuiButton.registerCallbackHandler((player, btn) -> { | ||||||
|             if ((boolean)disassembleSlot.getInteract()) { |             if ((boolean)disassembleSlot.getInteract()) { | ||||||
|                 cCanvas.setEnable(true); |                 GermGuiLabel label = cCanvas.getGuiPart("label", GermGuiLabel.class); | ||||||
|  |                 List<String> texts = label.getTexts(); | ||||||
|  |                 if (disassembleSlot.getItemStack().getType() == Material.AIR){ | ||||||
|  |                     texts.clear(); | ||||||
|  |                     texts.add("请放入分解物品!"); | ||||||
|  |                     label.setTexts(texts); | ||||||
|  |                     cCanvas.setEnable(true); | ||||||
|  |                 }else { | ||||||
|  |                     texts.clear(); | ||||||
|  |                     texts.add("点击确定分解"); | ||||||
|  |                     texts.add("#ACDA70D6" + disassembleSlot.getItemStack().getItemMeta().getDisplayName()); | ||||||
|  |                     label.setTexts(texts); | ||||||
|  |                     cCanvas.setEnable(true); | ||||||
|  |                 } | ||||||
|             } |             } | ||||||
|         },GermGuiButton.EventType.LEFT_CLICK); |         },GermGuiButton.EventType.LEFT_CLICK); | ||||||
|     } |     } | ||||||
| @@ -315,7 +330,7 @@ public class SassembleGuiService extends GermGuiScreen { | |||||||
|         GermGuiLabel label = (GermGuiLabel) bgCanvas.getGuiPart("label"); |         GermGuiLabel label = (GermGuiLabel) bgCanvas.getGuiPart("label"); | ||||||
|         List<String> texts = new ArrayList<>(); |         List<String> texts = new ArrayList<>(); | ||||||
|         texts.add("#C80800FF距离分解完成"); |         texts.add("#C80800FF距离分解完成"); | ||||||
|         int minTime = MinUtil.calculateMinutesDifference(data.getDisassembleTime()); |         int minTime = MinUtil.calculateMinutesDifference(data.getDisassembleTime()) + 1; | ||||||
|         texts.add("#ACDA70D6还有"+minTime+"分钟"); |         texts.add("#ACDA70D6还有"+minTime+"分钟"); | ||||||
|         label.setTexts(texts); |         label.setTexts(texts); | ||||||
|         label.setEnable(true); |         label.setEnable(true); | ||||||
| @@ -331,7 +346,7 @@ public class SassembleGuiService extends GermGuiScreen { | |||||||
|         },2,TimeUnit.SECONDS); |         },2,TimeUnit.SECONDS); | ||||||
|  |  | ||||||
|         executor.scheduleWithFixedDelay(() -> { |         executor.scheduleWithFixedDelay(() -> { | ||||||
|             int calculateMinutesDifference = MinUtil.calculateMinutesDifference(data.getDisassembleTime()); |             int calculateMinutesDifference = MinUtil.calculateMinutesDifference(data.getDisassembleTime()) + 1; | ||||||
|             String text = "#ACDA70D6还有"+calculateMinutesDifference+"分钟"; |             String text = "#ACDA70D6还有"+calculateMinutesDifference+"分钟"; | ||||||
|             texts.remove(1); |             texts.remove(1); | ||||||
|             texts.add(text); |             texts.add(text); | ||||||
| @@ -352,12 +367,13 @@ public class SassembleGuiService extends GermGuiScreen { | |||||||
|                     fire.setEnable(false); |                     fire.setEnable(false); | ||||||
|                     door.setEnable(false); |                     door.setEnable(false); | ||||||
|                     men1.setEnable(true); |                     men1.setEnable(true); | ||||||
|  |                     doorPause.setEnable(false); | ||||||
|                     this.temporarilyBoxScreen.openChildGui(this.playerHost); |                     this.temporarilyBoxScreen.openChildGui(this.playerHost); | ||||||
|                     executor.shutdown(); |                     executor.shutdown(); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|  |  | ||||||
|         },1, 1, TimeUnit.MINUTES); |         },60,10 , TimeUnit.SECONDS); | ||||||
|             //1分钟延迟,minTime分钟后执行 |             //1分钟延迟,minTime分钟后执行 | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -383,12 +399,21 @@ public class SassembleGuiService extends GermGuiScreen { | |||||||
|         HashMap<String, DisProduct> disProducts = canDisItem.getDisProductHashMap(); |         HashMap<String, DisProduct> disProducts = canDisItem.getDisProductHashMap(); | ||||||
|         float v = random.nextFloat(); |         float v = random.nextFloat(); | ||||||
|         ItemStack product = null; |         ItemStack product = null; | ||||||
|         for (DisProduct disProduct : disProducts.values()) { | //        for (DisProduct disProduct : disProducts.values()) { | ||||||
|             if (disProduct.getProMax() > v && disProduct.getProMin() <= v){ | //            if (disProduct.getProMax() > v && disProduct.getProMin() <= v){ | ||||||
|                 product = SrItemAPI.getItem(disProduct.getIndexName(),new HashMap<>(),null,true,true); | //                product = SrItemAPI.getItem(disProduct.getIndexName(),new HashMap<>(),null,true,true); | ||||||
|                 break; | //                break; | ||||||
|             } | //            } | ||||||
|  | //        } | ||||||
|  |         String index = getIndex(canDisItem.getCoutWeight(),canDisItem.getDisProductHashMap()); | ||||||
|  |  | ||||||
|  |         if (index != null) { | ||||||
|  |             product = SrItemAPI.getItem(index,new HashMap<>(),null,true,true); | ||||||
|  |         }else { | ||||||
|  |             Bukkit.getPluginManager().getPlugin("SrDisassemble").getLogger().info(ChatColor.RED+itemName+"分解出错"); | ||||||
|  |             return; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         disassembleSlot.setInteract(true); |         disassembleSlot.setInteract(true); | ||||||
|         //赋予产物 |         //赋予产物 | ||||||
| //        disassembleSlot.setItemStack(product); | //        disassembleSlot.setItemStack(product); | ||||||
| @@ -437,4 +462,24 @@ public class SassembleGuiService extends GermGuiScreen { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     public String getIndex(int coutWeight,HashMap<String,DisProduct> disProductHashMap){ | ||||||
|  |         if (coutWeight == 0 || disProductHashMap.size() == 0){ | ||||||
|  |             return null; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         int ranNum = random.nextInt(coutWeight) + 1; | ||||||
|  |         int start = 0;//起始为0 | ||||||
|  |  | ||||||
|  |         for (DisProduct disProduct : disProductHashMap.values()){ | ||||||
|  |             //确定权重位置 | ||||||
|  |             if (ranNum >= start && ranNum <= start + disProduct.getWeight() ){ | ||||||
|  |                 //符合表示确定 | ||||||
|  |                 return disProduct.getIndexName(); | ||||||
|  |             } | ||||||
|  |             start+=disProduct.getWeight(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         return null; | ||||||
|  |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -12,6 +12,9 @@ import com.yuyu.srdisassemble.data.JdbcSqlClass; | |||||||
| import com.yuyu.srdisassemble.pojo.PauseBox; | import com.yuyu.srdisassemble.pojo.PauseBox; | ||||||
| import org.bukkit.Bukkit; | import org.bukkit.Bukkit; | ||||||
| import org.bukkit.Material; | import org.bukkit.Material; | ||||||
|  | import org.bukkit.event.EventHandler; | ||||||
|  | import org.bukkit.event.Listener; | ||||||
|  | import org.bukkit.event.player.PlayerQuitEvent; | ||||||
| import org.bukkit.inventory.ItemStack; | import org.bukkit.inventory.ItemStack; | ||||||
| import org.bukkit.inventory.meta.ItemMeta; | import org.bukkit.inventory.meta.ItemMeta; | ||||||
|  |  | ||||||
| @@ -25,7 +28,7 @@ import java.util.List; | |||||||
|  * @date 2024/6/21 18:50:18 |  * @date 2024/6/21 18:50:18 | ||||||
|  * @description 用于存放暂存箱 |  * @description 用于存放暂存箱 | ||||||
|  */ |  */ | ||||||
| public class TemporarilyBox { | public class TemporarilyBox implements Listener { | ||||||
|     public static HashMap<String, HashMap<String,GermGuiScreen>> temporarilyBoxHashMap = new HashMap<>(); |     public static HashMap<String, HashMap<String,GermGuiScreen>> temporarilyBoxHashMap = new HashMap<>(); | ||||||
|  |  | ||||||
|     public static GermGuiScreen getGermGuiScreen(String playname,String guiName) { |     public static GermGuiScreen getGermGuiScreen(String playname,String guiName) { | ||||||
| @@ -41,6 +44,26 @@ public class TemporarilyBox { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * 清空缓存gui | ||||||
|  |      */ | ||||||
|  |     public void clearPauseGui(){ | ||||||
|  |         JdbcSqlClass.clearPauseBoxTable("TemporarilyBox-disassemble"); | ||||||
|  |         // Plugin shutdown logic | ||||||
|  |         TemporarilyBox.savePauseBoxData(); | ||||||
|  |         temporarilyBoxHashMap.clear(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @EventHandler | ||||||
|  |     public void clearDisassembleGui(PlayerQuitEvent event){ | ||||||
|  |         String name = event.getPlayer().getName(); | ||||||
|  |         if(isHasGui(name,"disassemble")) { | ||||||
|  |             deleteGuiScreen(name,"disassemble"); | ||||||
|  |         }else { | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|     public static void deleteGuiScreen(String playname,String guiName) { |     public static void deleteGuiScreen(String playname,String guiName) { | ||||||
|         if(temporarilyBoxHashMap.containsKey(playname)) { |         if(temporarilyBoxHashMap.containsKey(playname)) { | ||||||
|             temporarilyBoxHashMap.get(playname).remove(guiName); |             temporarilyBoxHashMap.get(playname).remove(guiName); | ||||||
| @@ -74,13 +97,16 @@ public class TemporarilyBox { | |||||||
|      * 用于插件启动时,读取玩家的数据库存储 |      * 用于插件启动时,读取玩家的数据库存储 | ||||||
|      */ |      */ | ||||||
|     public static void getPauseBoxData(){ |     public static void getPauseBoxData(){ | ||||||
|         List<String> playerList = JdbcSqlClass.getPlayerList(); |         List<String> playerList = JdbcSqlClass.getPlayerList("TemporarilyBox-disassemble"); | ||||||
|  |  | ||||||
|         for (String player : playerList){ |         for (String player : playerList){ | ||||||
|             List<PauseBox> pauseBoxData = JdbcSqlClass.getPauseBoxData(player); |             if (isHasGui(player,"TemporarilyBox-disassemble")) { | ||||||
|  |                 continue; | ||||||
|  |             } | ||||||
|  |             List<PauseBox> pauseBoxData = JdbcSqlClass.getPauseBoxData(player,"TemporarilyBox-disassemble"); | ||||||
|  |  | ||||||
|             //暂存箱gui |             //暂存箱gui | ||||||
|             GermGuiScreen pauseBox = GermGuiScreen.getGermGuiScreen("TemporarilyBox", DisassembleManager.getTemporarilyBox()); |             GermGuiScreen pauseBox = GermGuiScreen.getGermGuiScreen("TemporarilyBox-disassemble", DisassembleManager.getTemporarilyBox()); | ||||||
|             GermGuiCanvas canvas = (GermGuiCanvas) pauseBox.getGuiPart("canvas"); |             GermGuiCanvas canvas = (GermGuiCanvas) pauseBox.getGuiPart("canvas"); | ||||||
|             GermGuiScroll scroll = (GermGuiScroll) canvas.getGuiPart("scroll"); |             GermGuiScroll scroll = (GermGuiScroll) canvas.getGuiPart("scroll"); | ||||||
|  |  | ||||||
| @@ -107,7 +133,7 @@ public class TemporarilyBox { | |||||||
|             } |             } | ||||||
|  |  | ||||||
|             //循环完毕之后封存 |             //循环完毕之后封存 | ||||||
|             TemporarilyBox.addGuiScreen(player,"TemporarilyBox",pauseBox); |             TemporarilyBox.addGuiScreen(player,"TemporarilyBox-disassemble",pauseBox); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -116,7 +142,7 @@ public class TemporarilyBox { | |||||||
|      */ |      */ | ||||||
|     public static void savePauseBoxData(){ |     public static void savePauseBoxData(){ | ||||||
|         for (String username : temporarilyBoxHashMap.keySet()){ |         for (String username : temporarilyBoxHashMap.keySet()){ | ||||||
|             GermGuiScreen temporarilyBox = temporarilyBoxHashMap.get(username).get("TemporarilyBox"); |             GermGuiScreen temporarilyBox = temporarilyBoxHashMap.get(username).get("TemporarilyBox-disassemble"); | ||||||
|             GermGuiCanvas canvas = (GermGuiCanvas) temporarilyBox.getGuiPart("canvas"); |             GermGuiCanvas canvas = (GermGuiCanvas) temporarilyBox.getGuiPart("canvas"); | ||||||
|             GermGuiScroll scroll = (GermGuiScroll) canvas.getGuiPart("scroll"); |             GermGuiScroll scroll = (GermGuiScroll) canvas.getGuiPart("scroll"); | ||||||
|             for (int i = 1 ; i <= 16 ; i++){ |             for (int i = 1 ; i <= 16 ; i++){ | ||||||
| @@ -132,7 +158,7 @@ public class TemporarilyBox { | |||||||
|                     for (String s : lore){ |                     for (String s : lore){ | ||||||
|                         lores = lores+s+"|"; |                         lores = lores+s+"|"; | ||||||
|                     } |                     } | ||||||
|                     JdbcSqlClass.insertPauseBoxData(username,i,itemStack.getAmount(),index,"TemporarilyBox",lores); |                     JdbcSqlClass.insertPauseBoxData(username,i,itemStack.getAmount(),index,"TemporarilyBox-disassemble",lores); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -16,6 +16,7 @@ public class CanDisItem { | |||||||
|     private String target; |     private String target; | ||||||
|     private String targetIndex; |     private String targetIndex; | ||||||
|     private  HashMap<String,DisProduct> disProductHashMap; |     private  HashMap<String,DisProduct> disProductHashMap; | ||||||
|  |     private int coutWeight; | ||||||
|  |  | ||||||
|     public void setTarget(String target) { |     public void setTarget(String target) { | ||||||
|         this.target = target; |         this.target = target; | ||||||
| @@ -64,9 +65,18 @@ public class CanDisItem { | |||||||
|         this.targetIndex = targetIndex; |         this.targetIndex = targetIndex; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public CanDisItem(String itemName, int disTime, HashMap<String, DisProduct> disProductHashMap) { |     public CanDisItem(String itemName, int disTime, HashMap<String, DisProduct> disProductHashMap,int coutWeight) { | ||||||
|         this.itemName = itemName; |         this.itemName = itemName; | ||||||
|         this.disTime = disTime; |         this.disTime = disTime; | ||||||
|         this.disProductHashMap = disProductHashMap; |         this.disProductHashMap = disProductHashMap; | ||||||
|  |         this.coutWeight = coutWeight; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public int getCoutWeight() { | ||||||
|  |         return coutWeight; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public void setCoutWeight(int coutWeight) { | ||||||
|  |         this.coutWeight = coutWeight; | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -19,10 +19,7 @@ public class DisProduct { | |||||||
|     private final String ItemName; |     private final String ItemName; | ||||||
|     //物品的索引 |     //物品的索引 | ||||||
|     private final String indexName; |     private final String indexName; | ||||||
|     //最大的概率 |     private int weight; | ||||||
|     private final double ProMax; |  | ||||||
|     //最小的概率 |  | ||||||
|     private final double ProMin; |  | ||||||
|     //获取ItemStack |     //获取ItemStack | ||||||
|     private final ItemStack itemStack; |     private final ItemStack itemStack; | ||||||
|  |  | ||||||
| @@ -34,22 +31,22 @@ public class DisProduct { | |||||||
|         return indexName; |         return indexName; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public double getProMax() { |  | ||||||
|         return ProMax; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public double getProMin() { |     public DisProduct(String itemName, String indexName,int weight) { | ||||||
|         return ProMin; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public DisProduct(String itemName, String indexName, double proMax, double proMin) { |  | ||||||
|         ItemName = itemName; |         ItemName = itemName; | ||||||
|         this.indexName = indexName; |         this.indexName = indexName; | ||||||
|         ProMax = proMax; |         this.weight = weight; | ||||||
|         ProMin = proMin; |  | ||||||
|         this.itemStack = SrItemAPI.getItem(indexName,new HashMap<>(),null,true,true); |         this.itemStack = SrItemAPI.getItem(indexName,new HashMap<>(),null,true,true); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     public int getWeight() { | ||||||
|  |         return weight; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public void setWeight(int weight) { | ||||||
|  |         this.weight = weight; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     public ItemStack getItemStack() { |     public ItemStack getItemStack() { | ||||||
|         return itemStack; |         return itemStack; | ||||||
|     } |     } | ||||||
| @@ -59,8 +56,6 @@ public class DisProduct { | |||||||
|         return "DisProduct{" + |         return "DisProduct{" + | ||||||
|                 "ItemName='" + ItemName + '\'' + |                 "ItemName='" + ItemName + '\'' + | ||||||
|                 ", indexName='" + indexName + '\'' + |                 ", indexName='" + indexName + '\'' + | ||||||
|                 ", ProMax=" + ProMax + |  | ||||||
|                 ", ProMin=" + ProMin + |  | ||||||
|                 ", itemStack=" + itemStack + |                 ", itemStack=" + itemStack + | ||||||
|                 '}'; |                 '}'; | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -1,51 +0,0 @@ | |||||||
| package com.yuyu.srdisassemble.utils; |  | ||||||
|  |  | ||||||
| import org.apache.ibatis.io.Resources; |  | ||||||
| import org.apache.ibatis.session.SqlSession; |  | ||||||
| import org.apache.ibatis.session.SqlSessionFactory; |  | ||||||
| import org.apache.ibatis.session.SqlSessionFactoryBuilder; |  | ||||||
|  |  | ||||||
| import java.io.IOException; |  | ||||||
| import java.io.InputStream; |  | ||||||
|  |  | ||||||
| public class MybatisUtil { |  | ||||||
|     private static final SqlSessionFactory factory; |  | ||||||
|  |  | ||||||
|     static { |  | ||||||
|  |  | ||||||
|  |  | ||||||
|         InputStream inputStream = null; |  | ||||||
|         try { |  | ||||||
|             inputStream = Resources.getResourceAsStream("mybatis-config.xml"); |  | ||||||
|             factory = new SqlSessionFactoryBuilder().build(inputStream); |  | ||||||
|         } catch (IOException e) { |  | ||||||
|             throw new RuntimeException("Failed to initialize MyBatis SqlSessionFactory", e); |  | ||||||
|         } finally { |  | ||||||
|             if (inputStream != null) { |  | ||||||
|                 try { |  | ||||||
|                     inputStream.close(); |  | ||||||
|                 } catch (IOException e) { |  | ||||||
|                     e.printStackTrace(); |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public MybatisUtil( ) { |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public static SqlSession getSqlSession() { |  | ||||||
|         return factory.openSession(); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public static void close(SqlSession sqlSession) { |  | ||||||
|         if (sqlSession != null) { |  | ||||||
|             sqlSession.close(); |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|  |  | ||||||
| } |  | ||||||
| @@ -8,13 +8,6 @@ depend: | |||||||
| commands: | commands: | ||||||
|   srdisassemble: |   srdisassemble: | ||||||
|     description: srdisassemble command |     description: srdisassemble command | ||||||
|     aliases: [ srd ] |     aliases: [ srdm ] | ||||||
|     permission: srdisassemble.command |     permission: srdisassemble.command | ||||||
|   srmeltagain: |  | ||||||
|     description: srmeltagain command |  | ||||||
|     aliases: [ srm ] |  | ||||||
|     permission: srmeltagain.command |  | ||||||
|   srrepair: |  | ||||||
|     description: srrepair command |  | ||||||
|     aliases: [ srr ] |  | ||||||
|     permission: srrepair.command |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user