后端和gui修复
This commit is contained in:
		
							
								
								
									
										10
									
								
								.idea/libraries/lib__5_.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								.idea/libraries/lib__5_.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | |||||||
|  | <component name="libraryTable"> | ||||||
|  |   <library name="lib (5)"> | ||||||
|  |     <CLASSES> | ||||||
|  |       <root url="file://$PROJECT_DIR$/lib" /> | ||||||
|  |     </CLASSES> | ||||||
|  |     <JAVADOC /> | ||||||
|  |     <SOURCES /> | ||||||
|  |     <jarDirectory url="file://$PROJECT_DIR$/lib" recursive="false" /> | ||||||
|  |   </library> | ||||||
|  | </component> | ||||||
| @@ -1,17 +1,17 @@ | |||||||
| package com.yuyu.srdisassemble; | package com.yuyu.srdisassemble; | ||||||
|  |  | ||||||
| import com.sakurarealm.sritem.bukkit.command.CommandBase; | import com.sakurarealm.sritem.bukkit.command.CommandBase; | ||||||
| import com.sakurarealm.sritem.bukkit.command.OpenCommand; |  | ||||||
| import com.yuyu.srdisassemble.command.DisCommand; | import com.yuyu.srdisassemble.command.DisCommand; | ||||||
| import com.yuyu.srdisassemble.config.ConfigManager; | import com.yuyu.srdisassemble.config.ConfigManager; | ||||||
|  | import com.yuyu.srdisassemble.data.JdbcSqlClass; | ||||||
|  | import com.yuyu.srdisassemble.disassemeble.TemporarilyBox; | ||||||
| import lombok.Getter; | import lombok.Getter; | ||||||
| import org.bukkit.ChatColor; | import org.bukkit.ChatColor; | ||||||
| import org.bukkit.plugin.java.JavaPlugin; | import org.bukkit.plugin.java.JavaPlugin; | ||||||
|  |  | ||||||
| public final class SrDisassemble extends JavaPlugin { | public final class SrDisassemble extends JavaPlugin { | ||||||
|  |  | ||||||
|     @Getter |  | ||||||
|     private static SrDisassemble instance;//用于获取实例 |  | ||||||
|     @Getter |     @Getter | ||||||
|     private static ConfigManager configManager;//用于鉴定 |     private static ConfigManager configManager;//用于鉴定 | ||||||
|  |  | ||||||
| @@ -28,11 +28,18 @@ 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()); | ||||||
|  |  | ||||||
|  |         //读取暂存箱 | ||||||
|  |         JdbcSqlClass.createPauseBoxTable(); | ||||||
|  | //        JdbcSqlClass.setPauseBox2UTF(); | ||||||
|  |         TemporarilyBox.getPauseBoxData(); | ||||||
|  |  | ||||||
|  |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void onDisable() { |     public void onDisable() { | ||||||
|  |         JdbcSqlClass.clearPauseBoxTable(); | ||||||
|         // Plugin shutdown logic |         // Plugin shutdown logic | ||||||
|  |         TemporarilyBox.savePauseBoxData(); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,42 +0,0 @@ | |||||||
| package com.yuyu.srdisassemble.data; |  | ||||||
|  |  | ||||||
| import com.yuyu.srdisassemble.SrDisassemble; |  | ||||||
| import org.apache.ibatis.datasource.DataSourceFactory; |  | ||||||
| import org.apache.ibatis.datasource.unpooled.UnpooledDataSourceFactory; |  | ||||||
|  |  | ||||||
| import java.util.Properties; |  | ||||||
|  |  | ||||||
| public class DataSource implements DataSourceFactory { |  | ||||||
|     private static UnpooledDataSourceFactory unpooledDataSourceFactory = new UnpooledDataSourceFactory(); |  | ||||||
|  |  | ||||||
|  |  | ||||||
|     public DataSource(){ |  | ||||||
|  |  | ||||||
|  |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public void setProperties(Properties props) { |  | ||||||
|         props.setProperty("driver", SrDisassemble.getConfigManager().getDriver()); |  | ||||||
|     props.setProperty("url", SrDisassemble.getConfigManager().getUrl()); |  | ||||||
|  |  | ||||||
|  |  | ||||||
|         props.setProperty("username", SrDisassemble.getConfigManager().getUsername()); |  | ||||||
|         props.setProperty("password", SrDisassemble.getConfigManager().getPassword()); |  | ||||||
|  |  | ||||||
|  |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public javax.sql.DataSource getDataSource() { |  | ||||||
|         Properties props = new Properties(); |  | ||||||
|         props.setProperty("driver", SrDisassemble.getConfigManager().getDriver()); |  | ||||||
|         props.setProperty("url", SrDisassemble.getConfigManager().getUrl()); |  | ||||||
|         props.setProperty("username", SrDisassemble.getConfigManager().getUsername()); |  | ||||||
|         props.setProperty("password", SrDisassemble.getConfigManager().getPassword()); |  | ||||||
|  |  | ||||||
|         unpooledDataSourceFactory.setProperties(props); |  | ||||||
|         return unpooledDataSourceFactory.getDataSource(); |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @@ -1,7 +1,9 @@ | |||||||
| package com.yuyu.srdisassemble.data; | package com.yuyu.srdisassemble.data; | ||||||
|  |  | ||||||
|  | import com.google.common.annotations.VisibleForTesting; | ||||||
| import com.yuyu.srdisassemble.SrDisassemble; | import com.yuyu.srdisassemble.SrDisassemble; | ||||||
| import com.yuyu.srdisassemble.pojo.DisassembleData; | import com.yuyu.srdisassemble.pojo.DisassembleData; | ||||||
|  | import com.yuyu.srdisassemble.pojo.PauseBox; | ||||||
| import org.bukkit.ChatColor; | import org.bukkit.ChatColor; | ||||||
|  |  | ||||||
| import java.sql.*; | import java.sql.*; | ||||||
| @@ -77,9 +79,7 @@ public class JdbcSqlClass { | |||||||
|  |  | ||||||
|             boolean rs = connection.execute(createTable); |             boolean rs = connection.execute(createTable); | ||||||
|  |  | ||||||
|             if (rs) { |  | ||||||
|                 SrDisassemble.getInstance().getLogger().info(ChatColor.GREEN + "initTable执行完毕"); |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -129,6 +129,164 @@ public class JdbcSqlClass { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |     public static void setPauseBox2UTF(){ | ||||||
|  |         try { | ||||||
|  |             Statement connection = getConnection(); | ||||||
|  |  | ||||||
|  |             //执行Sql语句 | ||||||
|  |  | ||||||
|  |             String sql = "ALTER TABLE pausebox CONVERT TO CHARACTER SET utf8mb4;"; | ||||||
|  |             boolean rs = connection.execute(sql); | ||||||
|  |  | ||||||
|  |             connection.close(); | ||||||
|  |         } catch (Exception e) { | ||||||
|  |             throw new RuntimeException(e); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public static void createPauseBoxTable(){ | ||||||
|  |         try { | ||||||
|  |             //此处获取连接并保存 | ||||||
|  |             con = DriverManager.getConnection(JdbcSqlClass.url, JdbcSqlClass.user, JdbcSqlClass.password); | ||||||
|  |  | ||||||
|  |             Statement connection = getConnection(); | ||||||
|  |  | ||||||
|  |             //执行Sql语句 | ||||||
|  |             String createTable = "create table if not exists pausebox(\n" + | ||||||
|  |                     "    username varchar(255) null comment '玩家名称',\n" + | ||||||
|  |                     "    slotnumber int null comment '槽位',\n" + | ||||||
|  |                     "    nums int null comment '数量',\n" + | ||||||
|  |                     "    productindex varchar(255) null comment '原胚索引',\n" + | ||||||
|  |                     "    guiname varchar(255) null comment 'gui的姓名'\n" + | ||||||
|  |                     ") CHARACTER SET utf8mb4 COLLATE utf8mb4_bin"; | ||||||
|  |  | ||||||
|  |             boolean rs = connection.execute(createTable); | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |             String sql = "select column_name\n" + | ||||||
|  |                     "from INFORMATION_SCHEMA.COLUMNS\n" + | ||||||
|  |                     "where TABLE_NAME = 'pausebox'"; | ||||||
|  |  | ||||||
|  |             //手动注入所有列 | ||||||
|  |             List<String> columns = new ArrayList<>(); | ||||||
|  |             columns.add("username"); | ||||||
|  |             columns.add("slotnumber"); | ||||||
|  |             columns.add("nums"); | ||||||
|  |             columns.add("productindex"); | ||||||
|  |             columns.add("guiname"); | ||||||
|  |  | ||||||
|  |             try { | ||||||
|  |                 ResultSet resultSet = connection.executeQuery(sql); | ||||||
|  |                 List<String> lists = new ArrayList<>(); | ||||||
|  |                 int index = 0; | ||||||
|  |                 while (resultSet.next()) { | ||||||
|  |                     String columnName = resultSet.getString("column_name"); | ||||||
|  |                     lists.add(columnName); | ||||||
|  |                     index++; | ||||||
|  |                 } | ||||||
|  |                 List<String> missColumn = new ArrayList<>(); | ||||||
|  |                 for (String columnName : columns) { | ||||||
|  |                     if (!lists.contains(columnName)) { | ||||||
|  |                         missColumn.add(columnName); | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |                 //新增列 | ||||||
|  |                 for (String columnName : missColumn) { | ||||||
|  |                     addColumnPauseBox(columnName); | ||||||
|  |                 } | ||||||
|  |  | ||||||
|  |             } catch (SQLException e) { | ||||||
|  |                 throw new RuntimeException(e); | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |             connection.close(); | ||||||
|  |         } catch (Exception e) { | ||||||
|  |             throw new RuntimeException(e); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * 插入数据 | ||||||
|  |      * @param username | ||||||
|  |      * @param slotNumber | ||||||
|  |      * @param nums | ||||||
|  |      * @param productindex | ||||||
|  |      * @param guiname | ||||||
|  |      */ | ||||||
|  |     public static void insertPauseBoxData(String username,int slotNumber,int nums,String productindex,String guiname){ | ||||||
|  |  | ||||||
|  |         try { | ||||||
|  |             String sql = "insert into pausebox(username, slotnumber, nums, productindex, guiname)" + | ||||||
|  |                     " VALUES ('"+username+"',"+slotNumber+","+nums+",'"+productindex+"','"+guiname+"')"; | ||||||
|  |  | ||||||
|  |             Statement statement = getConnection(); | ||||||
|  |  | ||||||
|  |             int i = statement.executeUpdate(sql); | ||||||
|  |  | ||||||
|  |             if (i > 0) { | ||||||
|  |                 return; | ||||||
|  |             }else { | ||||||
|  |                 System.out.println(username+"\t"+slotNumber+"\t"+nums+"\t"+productindex+"\t"+guiname+"插入失败"); | ||||||
|  |             } | ||||||
|  |         } catch (SQLException e) { | ||||||
|  |             throw new RuntimeException(e); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * 清空数据 | ||||||
|  |      */ | ||||||
|  |     public static void clearPauseBoxTable(){ | ||||||
|  |  | ||||||
|  |  | ||||||
|  |         try { | ||||||
|  |  | ||||||
|  |             Statement statement = getConnection(); | ||||||
|  |             String sql = "delete from pausebox"; | ||||||
|  |  | ||||||
|  |             statement.executeUpdate(sql); | ||||||
|  |         } catch (SQLException e) { | ||||||
|  |             throw new RuntimeException(e); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public static int addColumnPauseBox(String columns){ | ||||||
|  |         String sql = null; | ||||||
|  |         if (columns.equals("username")) { | ||||||
|  |             sql = "ALTER TABLE pausebox\n" + | ||||||
|  |                     "ADD username varchar(255) null comment '玩家名称'"; | ||||||
|  |         } else if (columns.equals("slotnumber")) { | ||||||
|  |             sql = "ALTER TABLE pausebox\n" + | ||||||
|  |                     "ADD slotnumber int null comment '槽位'"; | ||||||
|  |         } else if (columns.equals("nums")) { | ||||||
|  |             sql = "ALTER TABLE pausebox\n" + | ||||||
|  |                     "ADD nums int null comment '数量'"; | ||||||
|  |         } else if (columns.equals("productindex")) { | ||||||
|  |             sql = "ALTER TABLE pausebox\n" + | ||||||
|  |                     "ADD productindex varchar(255) null comment '原胚索引'"; | ||||||
|  |         } else if (columns.equals("guiname")) { | ||||||
|  |             sql = "ALTER TABLE pausebox\n" + | ||||||
|  |                     "ADD guiname varchar(255) null comment 'gui的姓名'"; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         if (sql != null) { | ||||||
|  |             Statement stmt = getConnection(); | ||||||
|  |             try { | ||||||
|  |                 int i = stmt.executeUpdate(sql); | ||||||
|  |                 stmt.close(); | ||||||
|  |                 return i; | ||||||
|  |             } catch (SQLException e) { | ||||||
|  |                 throw new RuntimeException(e); | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |         } | ||||||
|  |         return 0; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * 用于新增列 |      * 用于新增列 | ||||||
|      * |      * | ||||||
| @@ -137,10 +295,10 @@ public class JdbcSqlClass { | |||||||
|     public static int addColumn(String columns) { |     public static int addColumn(String columns) { | ||||||
|         String sql = null; |         String sql = null; | ||||||
|         if (columns.equals("id")) { |         if (columns.equals("id")) { | ||||||
|             sql = "ALTER TABLE srdisassemble\n" + |             sql = "ALTER TABLE pausebox\n" + | ||||||
|                     "ADD id BIGINT auto_increment not null PRIMARY KEY  comment 'ID'"; |                     "ADD id BIGINT auto_increment not null PRIMARY KEY  comment 'ID'"; | ||||||
|         } else if (columns.equals("playername")) { |         } else if (columns.equals("playername")) { | ||||||
|             sql = "ALTER TABLE srdisassemble\n" + |             sql = "ALTER TABLE pausebox\n" + | ||||||
|                     "ADD playername      varchar(255) null comment '玩家姓名'"; |                     "ADD playername      varchar(255) null comment '玩家姓名'"; | ||||||
|         } else if (columns.equals("disassembleTime")) { |         } else if (columns.equals("disassembleTime")) { | ||||||
|             sql = "ALTER TABLE srdisassemble\n" + |             sql = "ALTER TABLE srdisassemble\n" + | ||||||
| @@ -182,10 +340,6 @@ public class JdbcSqlClass { | |||||||
|             String sql = "ALTER TABLE srdisassemble CONVERT TO CHARACTER SET utf8mb4;"; |             String sql = "ALTER TABLE srdisassemble CONVERT TO CHARACTER SET utf8mb4;"; | ||||||
|             boolean rs = connection.execute(sql); |             boolean rs = connection.execute(sql); | ||||||
|  |  | ||||||
|             if (rs) { |  | ||||||
|                 SrDisassemble.getInstance().getLogger().info(ChatColor.GREEN + "修改字符集成功"); |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             connection.close(); |             connection.close(); | ||||||
|         } catch (Exception e) { |         } catch (Exception e) { | ||||||
|             throw new RuntimeException(e); |             throw new RuntimeException(e); | ||||||
| @@ -288,6 +442,26 @@ public class JdbcSqlClass { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     public static List<String> getPlayerList(){ | ||||||
|  |  | ||||||
|  |         List<String> userList = new ArrayList<>(); | ||||||
|  |  | ||||||
|  |         Statement statement = getConnection(); | ||||||
|  |         String sql = "select username from pausebox"; | ||||||
|  |         try { | ||||||
|  |             ResultSet resultSet = statement.executeQuery(sql); | ||||||
|  |             while (resultSet.next()){ | ||||||
|  |                 userList.add(resultSet.getString("username")); | ||||||
|  |             } | ||||||
|  |             resultSet.close(); | ||||||
|  |             statement.close(); | ||||||
|  |  | ||||||
|  |         } catch (SQLException e) { | ||||||
|  |             throw new RuntimeException(e); | ||||||
|  |         } | ||||||
|  |         return userList; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     public static String getDriver() { |     public static String getDriver() { | ||||||
|         return driver; |         return driver; | ||||||
|     } |     } | ||||||
| @@ -319,4 +493,34 @@ public class JdbcSqlClass { | |||||||
|     public static void setPassword(String password) { |     public static void setPassword(String password) { | ||||||
|         JdbcSqlClass.password = password; |         JdbcSqlClass.password = password; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * 用于获取PauseBox gui的数据 | ||||||
|  |      * @param player | ||||||
|  |      * @return | ||||||
|  |      */ | ||||||
|  |     public static List<PauseBox> getPauseBoxData(String player) { | ||||||
|  |  | ||||||
|  |         List<PauseBox> pauseBoxList = new ArrayList<>(); | ||||||
|  |         Statement statement = getConnection(); | ||||||
|  |         String sql = "select * from pausebox where username = '"+player+"' and guiname = 'TemporarilyBox'"; | ||||||
|  |         try { | ||||||
|  |             ResultSet resultSet = statement.executeQuery(sql); | ||||||
|  |             while (resultSet.next()){ | ||||||
|  |                 PauseBox pauseBox = new PauseBox(resultSet.getString("username"), | ||||||
|  |                         resultSet.getInt("slotnumber"), | ||||||
|  |                         resultSet.getInt("nums"), | ||||||
|  |                         resultSet.getString("productindex"), | ||||||
|  |                         resultSet.getString("guiname")); | ||||||
|  |                 pauseBoxList.add(pauseBox); | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             resultSet.close(); | ||||||
|  |             statement.close(); | ||||||
|  |         } catch (SQLException e) { | ||||||
|  |             throw new RuntimeException(e); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         return pauseBoxList; | ||||||
|  |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,63 +0,0 @@ | |||||||
| package com.yuyu.srdisassemble.data; |  | ||||||
|  |  | ||||||
| import com.yuyu.srdisassemble.data.mapper.SqlDataMapper; |  | ||||||
| import com.yuyu.srdisassemble.pojo.DisassembleData; |  | ||||||
| import com.yuyu.srdisassemble.utils.MybatisUtil; |  | ||||||
| import org.apache.ibatis.session.SqlSession; |  | ||||||
|  |  | ||||||
| import java.util.List; |  | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * @author 峰。 |  | ||||||
|  * @version 1.0 |  | ||||||
|  * @project SrDisassemble |  | ||||||
|  * @date 2024/6/17 16:57:26 |  | ||||||
|  * @description |  | ||||||
|  */ |  | ||||||
| public class SqlData { |  | ||||||
|     /** |  | ||||||
|      * 插件启动时加载表 |  | ||||||
|      */ |  | ||||||
|     public static void initTable(){ |  | ||||||
|         SqlSession sqlSession = MybatisUtil.getSqlSession(); |  | ||||||
| //        sqlSession.getConfiguration().addMapper(SqlDataMapper.class); |  | ||||||
|         SqlDataMapper mapper = sqlSession.getMapper(SqlDataMapper.class); |  | ||||||
|  |  | ||||||
|         mapper.createTable(); |  | ||||||
|         mapper.setChartseUtf8(); |  | ||||||
|  |  | ||||||
|         sqlSession.commit(); |  | ||||||
|         sqlSession.close(); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * 新增数据 |  | ||||||
|      * @param data |  | ||||||
|      */ |  | ||||||
|     public static void addDisassemble(DisassembleData data){ |  | ||||||
|         try (SqlSession sqlSession = MybatisUtil.getSqlSession()){ |  | ||||||
|             SqlDataMapper mapper = sqlSession.getMapper(SqlDataMapper.class); |  | ||||||
|             mapper.addDisassembleEvent(data); |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public static List<DisassembleData> getDisassembleData(String playerName){ |  | ||||||
|         try (SqlSession sqlSession = MybatisUtil.getSqlSession()){ |  | ||||||
|             SqlDataMapper mapper = sqlSession.getMapper(SqlDataMapper.class); |  | ||||||
|             List<DisassembleData> disassembleData = mapper.selectDisassembleEvent(playerName); |  | ||||||
|             return disassembleData; |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public static List<DisassembleData> getDisassembleData(String playerName, String target){ |  | ||||||
|         try (SqlSession sqlSession = MybatisUtil.getSqlSession()){ |  | ||||||
|             SqlDataMapper mapper = sqlSession.getMapper(SqlDataMapper.class); |  | ||||||
|             List<DisassembleData> disassembleData = mapper.selectDisassembleEventAndTarget(playerName,target); |  | ||||||
|             return disassembleData; |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public static void deleteDisassemble(String playerName){ |  | ||||||
|  |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @@ -1,18 +0,0 @@ | |||||||
| package com.yuyu.srdisassemble.data.mapper; |  | ||||||
|  |  | ||||||
| import com.yuyu.srdisassemble.pojo.DisassembleData; |  | ||||||
| import org.apache.ibatis.annotations.Param; |  | ||||||
|  |  | ||||||
| import java.util.Date; |  | ||||||
| import java.util.List; |  | ||||||
|  |  | ||||||
| public interface SqlDataMapper { |  | ||||||
|  |  | ||||||
|  |  | ||||||
|     void createTable(); |  | ||||||
|     void setChartseUtf8(); |  | ||||||
|     void addDisassembleEvent(@Param("data") DisassembleData data); |  | ||||||
|     List<DisassembleData> selectDisassembleEvent(@Param("playername") String playername); |  | ||||||
|     List<DisassembleData> selectDisassembleEventAndTarget(@Param("playername")String playername, @Param("target") String target); |  | ||||||
|     void deleteDisassemble(@Param("playername") String playername, @Param("target") String target,@Param("disassembleTime") Date disassembleTime); |  | ||||||
| } |  | ||||||
| @@ -1,12 +1,12 @@ | |||||||
| package com.yuyu.srdisassemble.disassemeble; | package com.yuyu.srdisassemble.disassemeble; | ||||||
|  |  | ||||||
|  | import com.germ.germplugin.GermPlugin; | ||||||
| import com.germ.germplugin.api.dynamic.gui.*; | import com.germ.germplugin.api.dynamic.gui.*; | ||||||
| import com.sakurarealm.sritem.api.ItemStackHelper; | import com.sakurarealm.sritem.api.ItemStackHelper; | ||||||
| import com.sakurarealm.sritem.api.SrItemAPI; | import com.sakurarealm.sritem.api.SrItemAPI; | ||||||
| import com.sakurarealm.sritem.api.builder.SrItemHandler; | import com.sakurarealm.sritem.api.builder.SrItemHandler; | ||||||
| import com.yuyu.srdisassemble.SrDisassemble; | import com.yuyu.srdisassemble.SrDisassemble; | ||||||
| import com.yuyu.srdisassemble.data.JdbcSqlClass; | import com.yuyu.srdisassemble.data.JdbcSqlClass; | ||||||
| import com.yuyu.srdisassemble.data.SqlData; |  | ||||||
| import com.yuyu.srdisassemble.pojo.CanDisItem; | 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; | ||||||
| @@ -37,7 +37,7 @@ public class SassembleGuiService extends GermGuiScreen { | |||||||
|     private DisassembleData data; |     private DisassembleData data; | ||||||
|     private String name; |     private String name; | ||||||
|     private Random random ; |     private Random random ; | ||||||
|     private boolean disassemble = true; |     private boolean disassembleFlag = true; | ||||||
|     private Player playerHost; |     private Player playerHost; | ||||||
|     private GermGuiScreen temporarilyBoxScreen; |     private GermGuiScreen temporarilyBoxScreen; | ||||||
|     private List<GermGuiSlot> guiSlots = new ArrayList<>(); |     private List<GermGuiSlot> guiSlots = new ArrayList<>(); | ||||||
| @@ -50,8 +50,8 @@ public class SassembleGuiService extends GermGuiScreen { | |||||||
|         this.random = new Random(); |         this.random = new Random(); | ||||||
|         this.name = playerHost.getName(); |         this.name = playerHost.getName(); | ||||||
|         this.getTemporarilyBox(); |         this.getTemporarilyBox(); | ||||||
|         this.boolGui(); |  | ||||||
|         this.savePauseSlots(); |         this.savePauseSlots(); | ||||||
|  |         this.boolGui(); | ||||||
|         this.openPauseBox(); |         this.openPauseBox(); | ||||||
|         this.setClosedHandler(((player, germGuiScreen) -> { |         this.setClosedHandler(((player, germGuiScreen) -> { | ||||||
|             //窗口关闭事件 |             //窗口关闭事件 | ||||||
| @@ -83,6 +83,9 @@ public class SassembleGuiService extends GermGuiScreen { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     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){ | ||||||
| @@ -116,19 +119,42 @@ public class SassembleGuiService extends GermGuiScreen { | |||||||
|                     new HashMap<>(),null,true,true)); |                     new HashMap<>(),null,true,true)); | ||||||
|  |  | ||||||
|             GermGuiGif fire = (GermGuiGif) bgCanvas.getGuiPart("fire"); |             GermGuiGif fire = (GermGuiGif) bgCanvas.getGuiPart("fire"); | ||||||
|             GermGuiTexture men1 = (GermGuiTexture) bgCanvas.getGuiPart("men1"); |             GermGuiButton men1 = (GermGuiButton) bgCanvas.getGuiPart("men1"); | ||||||
|             GermGuiTexture doorPause = (GermGuiTexture) bgCanvas.getGuiPart("doorPause"); |             GermGuiTexture doorPause = (GermGuiTexture) bgCanvas.getGuiPart("doorPause"); | ||||||
|             GermGuiGif door = (GermGuiGif) bgCanvas.getGuiPart("door"); |             GermGuiGif door = (GermGuiGif) bgCanvas.getGuiPart("door"); | ||||||
|  |  | ||||||
|             men1.setEnable(false); |             men1.setEnable(false); | ||||||
|             fire.setEnable(true); |             fire.setEnable(true); | ||||||
|             doorPause.setEnable(true); |             doorPause.setEnable(true); | ||||||
|  |  | ||||||
|             ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); |  | ||||||
|  |  | ||||||
|             executor.scheduleAtFixedRate(() -> { |  | ||||||
|             int calculateMinutesDifference = MinUtil.calculateMinutesDifference(data.getDisassembleTime()); |             int calculateMinutesDifference = MinUtil.calculateMinutesDifference(data.getDisassembleTime()); | ||||||
|             if (calculateMinutesDifference <= 0) { |             if (calculateMinutesDifference <= 0) { | ||||||
|  |                 //执行语句说明分解完成 | ||||||
|  |                 this.disassembleComplete(); | ||||||
|  |                 if ((boolean)disassembleSlot.getInteract()){ | ||||||
|  |  | ||||||
|  |                     JdbcSqlClass.deleteData(data.getId()); | ||||||
|  |                     //赋予产物后把火关掉,门打开 | ||||||
|  |                     //TODO(此处后面可以让美术大佬做一个开炉门的gif | ||||||
|  |                     fire.setEnable(false); | ||||||
|  |                     door.setEnable(false); | ||||||
|  |                     men1.setEnable(true); | ||||||
|  |                     doorPause.setEnable(false); | ||||||
|  |                     this.temporarilyBoxScreen.openChildGui(this.playerHost); | ||||||
|  |                 } | ||||||
|  |  | ||||||
|  |             }else { | ||||||
|  |                 ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); | ||||||
|  |  | ||||||
|  |  | ||||||
|  |                 executor.scheduleWithFixedDelay(() -> { | ||||||
|  |                     int nums = MinUtil.calculateMinutesDifference(data.getDisassembleTime()); | ||||||
|  |                     if (nums <= 0) { | ||||||
|  |  | ||||||
|  |                         if(!this.disassembleFlag){ | ||||||
|  |                             executor.shutdown(); | ||||||
|  |                             return; | ||||||
|  |                         } | ||||||
|  |  | ||||||
|                         //执行语句说明分解完成 |                         //执行语句说明分解完成 | ||||||
|                         this.disassembleComplete(); |                         this.disassembleComplete(); | ||||||
|                         if ((boolean)disassembleSlot.getInteract()){ |                         if ((boolean)disassembleSlot.getInteract()){ | ||||||
| @@ -141,18 +167,20 @@ public class SassembleGuiService extends GermGuiScreen { | |||||||
|                             door.setEnable(false); |                             door.setEnable(false); | ||||||
|                             men1.setEnable(true); |                             men1.setEnable(true); | ||||||
|                             doorPause.setEnable(false); |                             doorPause.setEnable(false); | ||||||
|                         this.openTemporarilyBox(); |                             this.temporarilyBoxScreen.openChildGui(this.playerHost); | ||||||
|                         executor.shutdownNow(); |                             executor.shutdown(); | ||||||
|  |                         } | ||||||
|                     } |                     } | ||||||
|  |  | ||||||
|  |                 },1, 1, TimeUnit.MINUTES); | ||||||
|  |                 //1分钟延迟,minTime分钟后执行 | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             },0, 1 , TimeUnit.MINUTES); |  | ||||||
|             //0延迟,minTime分钟后执行 |             //0延迟,minTime分钟后执行 | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|         } |         } | ||||||
| //        else { |  | ||||||
| //            this.openTemporarilyBox(); |  | ||||||
| //        } |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -189,7 +217,7 @@ public class SassembleGuiService extends GermGuiScreen { | |||||||
|         //通过画布获取按键 |         //通过画布获取按键 | ||||||
|         GermGuiButton confirmButton = (GermGuiButton) cCanvas.getGuiPart("confirmButton"); |         GermGuiButton confirmButton = (GermGuiButton) cCanvas.getGuiPart("confirmButton"); | ||||||
|         GermGuiButton cancleButton = (GermGuiButton) cCanvas.getGuiPart("cancleButton"); |         GermGuiButton cancleButton = (GermGuiButton) cCanvas.getGuiPart("cancleButton"); | ||||||
|         GermGuiButton germGuiButton =(GermGuiButton) bgCanvas.getGuiPart("youhu"); |         GermGuiButton germGuiButton =(GermGuiButton) bgCanvas.getGuiPart("men1"); | ||||||
|         GermGuiSlot disassembleSlot = (GermGuiSlot) bgCanvas.getGuiPart("disassembleSlot"); |         GermGuiSlot disassembleSlot = (GermGuiSlot) bgCanvas.getGuiPart("disassembleSlot"); | ||||||
|  |  | ||||||
|         confirmButton.registerCallbackHandler((player, btn) -> { |         confirmButton.registerCallbackHandler((player, btn) -> { | ||||||
| @@ -221,7 +249,7 @@ public class SassembleGuiService extends GermGuiScreen { | |||||||
|         ItemStack itemStack = disassembleSlot.getItemStack(); |         ItemStack itemStack = disassembleSlot.getItemStack(); | ||||||
|  |  | ||||||
|         if (itemStack.getType() == Material.AIR || itemStack == null) { |         if (itemStack.getType() == Material.AIR || itemStack == null) { | ||||||
|             player.sendMessage(Color.RED+"在熔炉物品框中放上可分解的物品!"); |             player.sendMessage(ChatColor.RED+"在熔炉物品框中放上可分解的物品!"); | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|         SrItemHandler srItemHandler = ItemStackHelper.getSrItemHandler(itemStack); |         SrItemHandler srItemHandler = ItemStackHelper.getSrItemHandler(itemStack); | ||||||
| @@ -231,7 +259,7 @@ public class SassembleGuiService extends GermGuiScreen { | |||||||
|         HashMap<String, CanDisItem> disProductHashMap = SrDisassemble.getConfigManager().getDisProductHashMap(); |         HashMap<String, CanDisItem> disProductHashMap = SrDisassemble.getConfigManager().getDisProductHashMap(); | ||||||
|         CanDisItem canDisItem = disProductHashMap.get(itemName); |         CanDisItem canDisItem = disProductHashMap.get(itemName); | ||||||
|         if (!disProductHashMap.containsKey(itemName)){ |         if (!disProductHashMap.containsKey(itemName)){ | ||||||
|             player.sendMessage(Color.RED+"放入的物品不可分解!"); |             player.sendMessage(ChatColor.RED+"放入的物品不可分解!"); | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|         disassembleSlot.setInteract(false);//关闭交互 |         disassembleSlot.setInteract(false);//关闭交互 | ||||||
| @@ -255,7 +283,7 @@ public class SassembleGuiService extends GermGuiScreen { | |||||||
|         if ((boolean)door.getEnable() == true){ |         if ((boolean)door.getEnable() == true){ | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|         GermGuiTexture men1 = (GermGuiTexture) bgCanvas.getGuiPart("men1"); |         GermGuiButton men1 = (GermGuiButton) bgCanvas.getGuiPart("men1"); | ||||||
|         men1.setEnable(false); |         men1.setEnable(false); | ||||||
|         GermGuiGif fire = (GermGuiGif) bgCanvas.getGuiPart("fire"); |         GermGuiGif fire = (GermGuiGif) bgCanvas.getGuiPart("fire"); | ||||||
|         fire.setEnable(true); |         fire.setEnable(true); | ||||||
| @@ -276,10 +304,17 @@ public class SassembleGuiService extends GermGuiScreen { | |||||||
|         ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); |         ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); | ||||||
|  |  | ||||||
|  |  | ||||||
|         executor.scheduleAtFixedRate(() -> { |         executor.scheduleWithFixedDelay(() -> { | ||||||
|             int calculateMinutesDifference = MinUtil.calculateMinutesDifference(data.getDisassembleTime()); |             int calculateMinutesDifference = MinUtil.calculateMinutesDifference(data.getDisassembleTime()); | ||||||
|             if (calculateMinutesDifference <= 0) { |             if (calculateMinutesDifference <= 0) { | ||||||
|                 //执行语句说明分解完成 |                 //执行语句说明分解完成 | ||||||
|  |  | ||||||
|  |                 if (!this.disassembleFlag){ | ||||||
|  |                     //disassembleFlag == false 说明gui已经关闭,即已经放弃了,下次打开时会打开新的gui | ||||||
|  |                     executor.shutdown(); | ||||||
|  |                     return; | ||||||
|  |                 } | ||||||
|  |  | ||||||
|                 this.disassembleComplete(); |                 this.disassembleComplete(); | ||||||
|                 if ((boolean)disassembleSlot.getInteract()){ |                 if ((boolean)disassembleSlot.getInteract()){ | ||||||
|  |  | ||||||
| @@ -290,8 +325,8 @@ public class SassembleGuiService extends GermGuiScreen { | |||||||
|                     fire.setEnable(false); |                     fire.setEnable(false); | ||||||
|                     door.setEnable(false); |                     door.setEnable(false); | ||||||
|                     men1.setEnable(true); |                     men1.setEnable(true); | ||||||
|                     this.openTemporarilyBox(); |                     this.temporarilyBoxScreen.openChildGui(this.playerHost); | ||||||
|                     executor.shutdownNow(); |                     executor.shutdown(); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|  |  | ||||||
| @@ -339,7 +374,7 @@ public class SassembleGuiService extends GermGuiScreen { | |||||||
|  |  | ||||||
|     //遍历gui的所有物品槽,并且返回到玩家背包中 |     //遍历gui的所有物品槽,并且返回到玩家背包中 | ||||||
|     synchronized private void returnItemStacks(Player player) { |     synchronized private void returnItemStacks(Player player) { | ||||||
|         this.disassemble = false; |         this.disassembleFlag = false; | ||||||
|         this.temporarilyBoxScreen.close(); |         this.temporarilyBoxScreen.close(); | ||||||
|         List<GermGuiSlot> allGuiParts = this.getAllGuiParts(GermGuiSlot.class); |         List<GermGuiSlot> allGuiParts = this.getAllGuiParts(GermGuiSlot.class); | ||||||
|         for (GermGuiSlot guiPart : allGuiParts) { |         for (GermGuiSlot guiPart : allGuiParts) { | ||||||
| @@ -347,6 +382,20 @@ public class SassembleGuiService extends GermGuiScreen { | |||||||
|                 player.getInventory().addItem(guiPart.getItemStack()); |                 player.getInventory().addItem(guiPart.getItemStack()); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         for (GermGuiSlot guiPart : guiSlots) { | ||||||
|  |             if (guiPart.getItemStack().getType() != Material.AIR) { | ||||||
|  |                 ItemStack itemStack = guiPart.getItemStack(); | ||||||
|  |                 SrItemHandler srItemHandler = ItemStackHelper.getSrItemHandler(itemStack); | ||||||
|  |  | ||||||
|  |                 if (!srItemHandler.isSrItem()){ | ||||||
|  |                     player.sendMessage(ChatColor.GREEN+"暂存箱只能存放RPG物品!"); | ||||||
|  |                     player.getInventory().addItem(itemStack); | ||||||
|  |                     guiPart.setItemStack(null); | ||||||
|  |                 } | ||||||
|  |  | ||||||
|  |             } | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,8 +1,20 @@ | |||||||
| package com.yuyu.srdisassemble.disassemeble; | package com.yuyu.srdisassemble.disassemeble; | ||||||
|  |  | ||||||
|  | import com.germ.germplugin.api.dynamic.gui.GermGuiCanvas; | ||||||
| import com.germ.germplugin.api.dynamic.gui.GermGuiScreen; | import com.germ.germplugin.api.dynamic.gui.GermGuiScreen; | ||||||
|  | import com.germ.germplugin.api.dynamic.gui.GermGuiScroll; | ||||||
|  | import com.germ.germplugin.api.dynamic.gui.GermGuiSlot; | ||||||
|  | import com.sakurarealm.sritem.api.ItemStackHelper; | ||||||
|  | import com.sakurarealm.sritem.api.SrItemAPI; | ||||||
|  | import com.sakurarealm.sritem.api.builder.SrItemHandler; | ||||||
|  | import com.yuyu.srdisassemble.data.JdbcSqlClass; | ||||||
|  | import com.yuyu.srdisassemble.pojo.PauseBox; | ||||||
|  | import org.bukkit.Bukkit; | ||||||
|  | import org.bukkit.Material; | ||||||
|  | import org.bukkit.inventory.ItemStack; | ||||||
|  |  | ||||||
| import java.util.HashMap; | import java.util.HashMap; | ||||||
|  | import java.util.List; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * @author 峰。 |  * @author 峰。 | ||||||
| @@ -42,4 +54,64 @@ public class TemporarilyBox { | |||||||
|             temporarilyBoxHashMap.put(playname, stringGermGuiScreenHashMap); |             temporarilyBoxHashMap.put(playname, stringGermGuiScreenHashMap); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * 用于插件启动时,读取玩家的数据库存储 | ||||||
|  |      */ | ||||||
|  |     public static void getPauseBoxData(){ | ||||||
|  |         List<String> playerList = JdbcSqlClass.getPlayerList(); | ||||||
|  |  | ||||||
|  |         for (String player : playerList){ | ||||||
|  |             List<PauseBox> pauseBoxData = JdbcSqlClass.getPauseBoxData(player); | ||||||
|  |  | ||||||
|  |             //暂存箱gui | ||||||
|  |             GermGuiScreen pauseBox = GermGuiScreen.getGermGuiScreen("TemporarilyBox", DisassembleManager.getTemporarilyBox()); | ||||||
|  |             GermGuiCanvas canvas = (GermGuiCanvas) pauseBox.getGuiPart("canvas"); | ||||||
|  |             GermGuiScroll scroll = (GermGuiScroll) canvas.getGuiPart("scroll"); | ||||||
|  |  | ||||||
|  |             for (PauseBox p : pauseBoxData){ | ||||||
|  |                 String username = p.getUsername(); | ||||||
|  |                 int slotNum = p.getSlotnumber(); | ||||||
|  |                 int nums = p.getNums(); | ||||||
|  |                 String index = p.getProductindex(); | ||||||
|  |                 String guiname = p.getGuiname(); | ||||||
|  |  | ||||||
|  |                 String slot = "slot_"+slotNum; | ||||||
|  |                 GermGuiSlot germGuiSlot = (GermGuiSlot) scroll.getGuiPart(slot); | ||||||
|  |                 ItemStack item = SrItemAPI.getItem(index, new HashMap<>(), null, true, true); | ||||||
|  |  | ||||||
|  |                 if (item == null){ | ||||||
|  |                     continue; | ||||||
|  |                 } | ||||||
|  |                 item.setAmount(nums); | ||||||
|  |                 germGuiSlot.setItemStack(item); | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             //循环完毕之后封存 | ||||||
|  |             TemporarilyBox.addGuiScreen(player,"TemporarilyBox",pauseBox); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * 此方法仅仅用于保存暂存箱的数据 | ||||||
|  |      */ | ||||||
|  |     public static void savePauseBoxData(){ | ||||||
|  |         for (String username : temporarilyBoxHashMap.keySet()){ | ||||||
|  |             GermGuiScreen temporarilyBox = temporarilyBoxHashMap.get(username).get("TemporarilyBox"); | ||||||
|  |             GermGuiCanvas canvas = (GermGuiCanvas) temporarilyBox.getGuiPart("canvas"); | ||||||
|  |             GermGuiScroll scroll = (GermGuiScroll) canvas.getGuiPart("scroll"); | ||||||
|  |             for (int i = 1 ; i <= 16 ; i++){ | ||||||
|  |                 String slot = "slot_"+i; | ||||||
|  |                 GermGuiSlot germGuiSlot = (GermGuiSlot) scroll.getGuiPart(slot); | ||||||
|  |                 ItemStack itemStack = germGuiSlot.getItemStack(); | ||||||
|  |                 if (itemStack.getType() != Material.AIR) { | ||||||
|  |                     SrItemHandler srItemHandler = ItemStackHelper.getSrItemHandler(itemStack); | ||||||
|  |                     String index = srItemHandler.getLore().get(0); | ||||||
|  |                     index = index.substring(1); | ||||||
|  |                     JdbcSqlClass.insertPauseBoxData(username,i,itemStack.getAmount(),index,"TemporarilyBox"); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,64 +0,0 @@ | |||||||
| <?xml version="1.0" encoding="UTF-8" ?> |  | ||||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |  | ||||||
| <mapper namespace="com.yuyu.srdisassemble.data.mapper.SqlDataMapper"> |  | ||||||
|  |  | ||||||
|  |  | ||||||
|     <update id="creatTable"> |  | ||||||
|         create table if not exists srdisassemble |  | ||||||
|         ( |  | ||||||
|             id BIGINT auto_increment comment 'ID', |  | ||||||
|             playername      varchar(255) null comment '玩家姓名', |  | ||||||
|             disassembleTime datetime     null comment '分解的时间', |  | ||||||
|             target          varchar(255) null comment '分解的目标', |  | ||||||
|             targetIndex     varchar(255) null comment '分解目标的索引' |  | ||||||
|             guiname         varchar(255) null comment '打开gui的名称' |  | ||||||
|             ); |  | ||||||
|     </update> |  | ||||||
|  |  | ||||||
|     <update id="setChartseUtf8"> |  | ||||||
|         ALTER TABLE srdisassemble CONVERT TO CHARACTER SET utf8mb4; |  | ||||||
|     </update> |  | ||||||
|  |  | ||||||
|     <insert id="addDisassembleEvent" parameterType="com.yuyu.srdisassemble.pojo.DisassembleData"> |  | ||||||
|         insert into srdisassemble(playername,disassembleTime,target,targetIndex) |  | ||||||
|         values( |  | ||||||
|                #{data.playername}, |  | ||||||
|                #{data.disassembleTime}, |  | ||||||
|                #{data.target}, |  | ||||||
|                #{data.targetIndex} |  | ||||||
|               ) |  | ||||||
|     </insert> |  | ||||||
|  |  | ||||||
|     <select id="selectDisassembleEvent" resultMap="dataMap"> |  | ||||||
|         select * from srdisassemble |  | ||||||
|         where playername = #{playername}; |  | ||||||
|     </select> |  | ||||||
|  |  | ||||||
|     <select id="selectDisassembleEventAndTarget" resultType="com.yuyu.srdisassemble.pojo.DisassembleData"> |  | ||||||
|         select * from srdisassemble |  | ||||||
|         where playername = #{playername} |  | ||||||
|         and target = #{target}; |  | ||||||
|     </select> |  | ||||||
|  |  | ||||||
|     <delete id="deleteDisassemble"> |  | ||||||
|         delete from srdisassemble where |  | ||||||
|                     id = #{id} |  | ||||||
|     </delete> |  | ||||||
|  |  | ||||||
|     <resultMap id="dataMap" type="com.yuyu.srdisassemble.pojo.DisassembleData"> |  | ||||||
|         <result property="playername" javaType="java.lang.String" column="playername"></result> |  | ||||||
|         <result property="disassembleTime" javaType="java.util.Date" column="disassembleTime"></result> |  | ||||||
|         <result property="target" javaType="java.lang.String" column="target"></result> |  | ||||||
|         <result property="targetIndex" javaType="java.lang.String" column="targetIndex"></result> |  | ||||||
|     </resultMap> |  | ||||||
|  |  | ||||||
|  |  | ||||||
| </mapper> |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -1,43 +0,0 @@ | |||||||
| <?xml version="1.0" encoding="UTF-8" ?> |  | ||||||
| <!DOCTYPE configuration |  | ||||||
|         PUBLIC "-//mybatis.org//DTD Config 3.0//EN" |  | ||||||
|         "http://mybatis.org/dtd/mybatis-3-config.dtd"> |  | ||||||
| <configuration> |  | ||||||
|  |  | ||||||
|     <!-- |  | ||||||
|         这些属性可以在外部进行配置,并可以进行动态替换。 |  | ||||||
|         你既可以在典型的 Java 属性文件中配置这些属性,也可以在 properties 元素的子元素中设置 |  | ||||||
|     --> |  | ||||||
|  |  | ||||||
| <!--        <settings>--> |  | ||||||
| <!--            <setting name="logImpl" value="STDOUT_LOGGING"/>--> |  | ||||||
| <!--        </settings>--> |  | ||||||
|  |  | ||||||
|  |  | ||||||
|     <environments default="development"> |  | ||||||
|         <!--每个 environment 元素定义的环境 ID(比如:id="development")。--> |  | ||||||
|         <environment id="development"> |  | ||||||
|             <!--事务管理器的配置(比如:type="JDBC")。--> |  | ||||||
|             <!-- |  | ||||||
|                 事务管理器(transactionManager) |  | ||||||
|                 在 MyBatis 中有两种类型的事务管理器(也就是 type="[JDBC|MANAGED]"): |  | ||||||
|                 JDBC – 这个配置直接使用了 JDBC 的提交和回滚设施,它依赖从数据源获得的连接来管理事务作用域。 |  | ||||||
|                 MANAGED – 这个配置几乎没做什么。它从不提交或回滚一个连接,而是让容器来管理事务的整个生命周期(比如 JEE 应用服务器的上下文)。 |  | ||||||
|                 默认情况下它会关闭连接。然而一些容器并不希望连接被关闭,因此需要将 closeConnection 属性设置为 false 来阻止默认的关闭行为。 |  | ||||||
|                 如果你正在使用 Spring + MyBatis,则没有必要配置事务管理器,因为 Spring 模块会使用自带的管理器来覆盖前面的配置。 |  | ||||||
|                 这两种事务管理器类型都不需要设置任何属性。它们其实是类型别名,换句话说,你可以用 TransactionFactory 接口实现类的全限定名或类型别名代替它们。 |  | ||||||
|             --> |  | ||||||
|             <transactionManager type="JDBC"/> |  | ||||||
|             <!--数据源的配置(比如:type="POOLED")--> |  | ||||||
|             <dataSource type="com.yuyu.srdisassemble.data.DataSource"> |  | ||||||
|             </dataSource> |  | ||||||
|         </environment> |  | ||||||
|     </environments> |  | ||||||
|  |  | ||||||
|     <mappers> |  | ||||||
|  |  | ||||||
|         <mapper resource="SqlDataMapper.xml" class="com.yuyu.srdisassemble.data.mapper.SqlDataMapper"/> |  | ||||||
|     </mappers> |  | ||||||
|  |  | ||||||
| </configuration> |  | ||||||
|  |  | ||||||
| @@ -4,6 +4,7 @@ main: com.yuyu.srdisassemble.SrDisassemble | |||||||
|  |  | ||||||
| depend: | depend: | ||||||
|   - SrItem |   - SrItem | ||||||
|  |   - GermPlugin | ||||||
| commands: | commands: | ||||||
|   srdisassemble: |   srdisassemble: | ||||||
|     description: srdisassemble command |     description: srdisassemble command | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user