cmdList = cmd.getCmdMap();
+ cmdList.forEach((cmdStr) -> {
+ try {
+ String[] split = cmdStr.split("&");
+ System.out.println("下一个命令是" + split[0]);
+ if (FIGHT.equals(split[0])){
+ fight();
+ }else {
+ sendNewRequest(split[0], FindType.valueOf(split[1]));
+ }
+ } catch (InterruptedException e) {
+ System.err.println("错误了!!!");
+ e.printStackTrace();
+ }
+ });
+ }
+
+ private void sendNewRequest(String cmdStr, FindType type) throws InterruptedException {
+ Thread.sleep(800);
+ String next = "";
+ if (type == FindType.ALL){
+ next = target.get(cmdStr);
+ }else {
+ for (String temp : target.keySet()){
+ if (temp.contains(cmdStr)){
+ next = target.get(temp);
+ }
+ }
+ }
+ if(next == null || "".equals(next)){
+ next = "00";
+ }
+ System.out.println(cmdStr + "Next CMD ID ===" + next);
+ if (next != null) {
+ currentUrl = SEND_URL + next + APPEND_SID + SID;
+ }
+ String result = HttpUtils.doGet(currentUrl);
+ if (result != null && !"".equals(result)){
+ String substring = result.substring(result.indexOf("")+3, result.indexOf("
").matcher(result);
+ while (matcher.find()){
+ String group = matcher.group(0);
+ int cmdEnd = group.indexOf("&");
+ int first = group.indexOf(">");
+ int last = group.indexOf("<");
+ String key = group.substring(first+1, last);
+ String cmd = group.substring(4, cmdEnd);
+ target.put(key,cmd);
+ }
+ }
+
+ private void fight() throws InterruptedException {
+ if (!target.containsKey("雁翎刀法")){
+ return;
+ }
+ while (!"战斗已经结束!".equals(currentMsg)){
+ if (currentMsg.contains("成功闯过")){
+ break;
+ }
+ if (target.containsKey("雁翎刀法")){
+ String next = target.get("雁翎刀法");
+ if (next != null) {
+ sendNewRequest("雁翎刀法",FindType.ALL);
+ }
+ }
+ }
+ List list = new ArrayList<>();
+ for (String t : needThings){
+ target.forEach((x,y) -> {
+ if (x.contains(t)){
+ list.add(t);
+ }
+ });
+ }
+ for (String str : list){
+ sendNewRequest(str,FindType.CONT);
+ }
+ sendNewRequest("返回游戏",FindType.ALL);
+ }
+
+ String [] needThings = new String[]{
+ "山谷灵芝","毒蛇胆","食人怪鱼鱼鳞","食人谷","魄力丹","蛇筋","马","训练书","必杀技","冰珠","冰魄珠","太尉秘图","龙鳞","大白菜",
+ "牛皮"
+ };
+
+}
diff --git a/common/src/main/java/com/qn/dwonline/DwOnline.java b/common/src/main/java/com/qn/dwonline/DwOnline.java
new file mode 100644
index 0000000..1a4ad8d
--- /dev/null
+++ b/common/src/main/java/com/qn/dwonline/DwOnline.java
@@ -0,0 +1,22 @@
+package com.qn.dwonline;
+
+public class DwOnline{
+
+
+ private static String SEND_URL = "http://111.230.193.166:1880/gCmd.do?cmd=";
+ private static String APPEND = "&sid=";
+ private static String CURRENT_SID = "pvfw1h50ybuljdeopt6rn";
+
+
+ public static void main(String[] args) throws InterruptedException {
+ String url = SEND_URL + "00" + APPEND + CURRENT_SID;
+ // 循环(死循环)
+ while (true){
+// url = sendNewRequest(url,"升级",FindType.ALL);
+// url = sendNewRequest(url,"确定升级",FindType.ALL);
+// url = sendNewRequest(url,"加速",FindType.ALL);
+// url = sendNewRequest(url,"加速全部",FindType.CONT);
+ }
+ }
+
+}
diff --git a/common/src/main/java/com/qn/dwonline/common/CmdList.java b/common/src/main/java/com/qn/dwonline/common/CmdList.java
new file mode 100644
index 0000000..7853b0a
--- /dev/null
+++ b/common/src/main/java/com/qn/dwonline/common/CmdList.java
@@ -0,0 +1,12 @@
+package com.qn.dwonline.common;
+
+import java.util.ArrayList;
+
+public class CmdList extends ArrayList {
+
+ public void put(String cmd,FindType findType){
+ String type = cmd + "&" + findType;
+ this.add((E) type);
+ }
+
+}
diff --git a/common/src/main/java/com/qn/dwonline/common/FindType.java b/common/src/main/java/com/qn/dwonline/common/FindType.java
new file mode 100644
index 0000000..91e8aa6
--- /dev/null
+++ b/common/src/main/java/com/qn/dwonline/common/FindType.java
@@ -0,0 +1,7 @@
+package com.qn.dwonline.common;
+
+public enum FindType {
+ ALL,
+ CONT,
+ IF_EXIST_LOOP
+}
diff --git a/common/src/main/java/com/qn/dwonline/commond/BaseCMD.java b/common/src/main/java/com/qn/dwonline/commond/BaseCMD.java
new file mode 100644
index 0000000..d3a77c0
--- /dev/null
+++ b/common/src/main/java/com/qn/dwonline/commond/BaseCMD.java
@@ -0,0 +1,46 @@
+package com.qn.dwonline.commond;
+
+import com.qn.dwonline.common.CmdList;
+import com.qn.dwonline.common.FindType;
+
+public abstract class BaseCMD {
+
+ protected CmdList cmd = new CmdList();
+
+ protected final String FIGHT = "Fight";
+
+ public int times;
+
+ public CmdList getCmdMap(){
+ cmd.put("INIT SEND REQUEST",FindType.ALL);
+ preCmd();
+ return cmd;
+ }
+
+ protected abstract void preCmd();
+
+ protected void fight(String fightWith){
+ cmd.put(fightWith,FindType.ALL);
+ cmd.put("攻击" + fightWith,FindType.ALL);
+ cmd.put(FIGHT,FindType.ALL);
+ }
+
+ protected void fight(String fightWith,String match){
+ cmd.put(fightWith,FindType.CONT);
+ cmd.put("攻击" + fightWith,FindType.CONT);
+ cmd.put(FIGHT,FindType.ALL);
+ }
+
+ protected void clickFight(String fightWith){
+ cmd.put(fightWith,FindType.CONT);
+ cmd.put(FIGHT,FindType.CONT);
+ }
+
+ public int getTimes() {
+ return times;
+ }
+
+ public void setTimes(int times) {
+ this.times = times;
+ }
+}
diff --git a/common/src/main/java/com/qn/dwonline/commond/BlackWind.java b/common/src/main/java/com/qn/dwonline/commond/BlackWind.java
new file mode 100644
index 0000000..a04e432
--- /dev/null
+++ b/common/src/main/java/com/qn/dwonline/commond/BlackWind.java
@@ -0,0 +1,42 @@
+package com.qn.dwonline.commond;
+
+import com.qn.dwonline.common.FindType;
+
+public class BlackWind extends BaseCMD{
+
+ @Override
+ public void preCmd() {
+ this.times = 3;
+ cmd.put("黑风岭砍柴老者",FindType.ALL);
+ cmd.put("进入黑风岭副本",FindType.ALL);
+ cmd.put("继续",FindType.ALL);
+ cmd.put("右:黑松林→",FindType.ALL);
+ cmd.put("右:黑松林→",FindType.ALL);
+ cmd.put("右:黑松林→",FindType.ALL);
+ cmd.put("右:乱石河边→",FindType.ALL);
+ cmd.put("进入乱石河",FindType.ALL);
+ fight("巨型鲤鱼");
+ cmd.put("进入猛虎坡",FindType.ALL);
+ fight("病大虫");
+ cmd.put("进入猛虎洞",FindType.ALL);
+ fight("黑风虎");
+ cmd.put("进入洞穴",FindType.ALL);
+ fight("黑风雌虎");
+ fight("黑风雌虎");
+// cmd.put("右:干草洞穴→",FindType.ALL);
+// fight("幼虎");
+// fight("幼虎");
+// cmd.put("左:洞穴←",FindType.ALL);
+ cmd.put("进入窄路",FindType.ALL);
+ fight("黑风雄虎");
+ cmd.put("右:大洞穴→",FindType.ALL);
+ fight("狮虎兽");
+ cmd.put("左:窄路←",FindType.ALL);
+ cmd.put("进入潮湿小路",FindType.ALL);
+ cmd.put("左:内洞←",FindType.ALL);
+ fight("巨型猛虎");
+ cmd.put("右:潮湿小路→",FindType.ALL);
+ cmd.put("进入巨型洞穴",FindType.ALL);
+ fight("虎王");
+ }
+}
diff --git a/common/src/main/java/com/qn/dwonline/commond/DangKou.java b/common/src/main/java/com/qn/dwonline/commond/DangKou.java
new file mode 100644
index 0000000..a887858
--- /dev/null
+++ b/common/src/main/java/com/qn/dwonline/commond/DangKou.java
@@ -0,0 +1,49 @@
+package com.qn.dwonline.commond;
+
+import com.qn.dwonline.common.FindType;
+
+public class DangKou extends BaseCMD{
+
+ @Override
+ public void preCmd() {
+ cmd.put("下:草原↓", FindType.ALL);
+ cmd.put("下:草原↓", FindType.ALL);
+ cmd.put("右:草原→", FindType.ALL);
+ cmd.put("下:绿洲↓", FindType.ALL);
+ cmd.put("下:绿洲↓", FindType.ALL);
+ cmd.put("右:红帐篷→", FindType.ALL);
+ fight("波斯人入侵者");
+ cmd.put("左:绿洲←",FindType.ALL);
+ cmd.put("左:绿洲←",FindType.ALL);
+ cmd.put("下:黑帐篷↓",FindType.ALL);
+ fight("叛乱喇嘛");
+ fight("叛乱喇嘛");
+ cmd.put("进入密道",FindType.ALL);
+ cmd.put("确定进入",FindType.ALL);
+ cmd.put(FIGHT,FindType.ALL);
+ cmd.put("右:密道→",FindType.ALL);
+ cmd.put(FIGHT,FindType.ALL);
+ cmd.put("右:密道→",FindType.ALL);
+ cmd.put(FIGHT,FindType.ALL);
+ cmd.put("右:密道→",FindType.ALL);
+ cmd.put(FIGHT,FindType.ALL);
+ cmd.put("下:密道↓",FindType.ALL);
+ cmd.put(FIGHT,FindType.ALL);
+ cmd.put("右:密道→",FindType.ALL);
+ cmd.put(FIGHT,FindType.ALL);
+ cmd.put("下:密道↓",FindType.ALL);
+ cmd.put(FIGHT,FindType.ALL);
+ cmd.put("下:密道↓",FindType.ALL);
+ cmd.put(FIGHT,FindType.ALL);
+ cmd.put("下:毒虫殿↓",FindType.ALL);
+ fight("恶毒蝎子王");
+ fight("巨型青蛙王");
+ fight("奇异毒蛇王");
+ fight("吸血蝙蝠王");
+ cmd.put("进入巫婆殿",FindType.ALL);
+ fight("叶比亚","");
+
+
+
+ }
+}
diff --git a/common/src/main/java/com/qn/dwonline/commond/EatPeople.java b/common/src/main/java/com/qn/dwonline/commond/EatPeople.java
new file mode 100644
index 0000000..e0e8738
--- /dev/null
+++ b/common/src/main/java/com/qn/dwonline/commond/EatPeople.java
@@ -0,0 +1,47 @@
+package com.qn.dwonline.commond;
+
+import com.qn.dwonline.common.FindType;
+
+public class EatPeople extends BaseCMD{
+
+ @Override
+ public void preCmd() {
+ cmd.put("进入食人谷副本",FindType.ALL);
+ fight("守谷小喽罗");
+ cmd.put("进入悬崖大树",FindType.ALL);
+ fight("大吼猴");
+ cmd.put("下:食人谷口↓",FindType.ALL);
+ cmd.put("进入一线天",FindType.ALL);
+ fight("剧毒奇寒蛇");
+ cmd.put("进入狭小石门",FindType.ALL);
+ fight("食人谷守卫");
+ fight("食人谷守卫");
+ cmd.put("进入小河边",FindType.ALL);
+ fight("食人谷力士");
+ cmd.put("进入河底",FindType.ALL);
+ fight("食人怪鱼");
+ cmd.put("左:小河边←",FindType.ALL);
+ cmd.put("上:小路↑",FindType.ALL);
+ cmd.put("右:巨型峡谷→",FindType.ALL);
+ fight("食人谷护法");
+ cmd.put("上:奇异果园↑",FindType.ALL);
+ cmd.put("食人谷果农",FindType.ALL);
+ cmd.put("配置狂暴一",FindType.ALL);
+ cmd.put("返回食人谷果农",FindType.ALL);
+ cmd.put("返回游戏",FindType.ALL);
+ cmd.put("下:巨型峡谷↓",FindType.ALL);
+ cmd.put("进入谷内小屋",FindType.ALL);
+ cmd.put("继续",FindType.ALL);
+ fight("食人谷五当家");
+ cmd.put("右:大堂→",FindType.ALL);
+ fight("食人谷四当家");
+ cmd.put("上:北偏厅↑",FindType.ALL);
+ fight("食人谷三当家");
+ cmd.put("下:大堂↓",FindType.ALL);
+ cmd.put("下:南偏厅↓",FindType.ALL);
+ fight("食人谷二当家");
+ cmd.put("上:大堂↑",FindType.ALL);
+ cmd.put("进入暗室",FindType.ALL);
+ fight("食人谷大当家");
+ }
+}
diff --git a/common/src/main/java/com/qn/dwonline/commond/GaoTreasury.java b/common/src/main/java/com/qn/dwonline/commond/GaoTreasury.java
new file mode 100644
index 0000000..d4b9ed4
--- /dev/null
+++ b/common/src/main/java/com/qn/dwonline/commond/GaoTreasury.java
@@ -0,0 +1,59 @@
+package com.qn.dwonline.commond;
+
+import com.qn.dwonline.common.FindType;
+
+public class GaoTreasury extends BaseCMD{
+
+ @Override
+ public void preCmd() {
+ this.times = 2;
+ cmd.put("进入太尉宝库副本",FindType.ALL);
+ fight("宝库铁甲兵");
+ cmd.put("进入下.一石阶",FindType.ALL);
+ cmd.put("返回游戏",FindType.ALL);
+ fight("宝库精甲兵");
+ cmd.put("上:石室↑",FindType.ALL);
+ fight("宝库铁甲守将");
+ cmd.put("下:石阶↓",FindType.ALL);
+ cmd.put("下:石室↓",FindType.ALL);
+ fight("宝库精甲守将");
+ cmd.put("上:石阶↑",FindType.ALL);
+ cmd.put("进入过道",FindType.ALL);
+ fight("宝库钢甲兵");
+ cmd.put("进入下.一过道",FindType.ALL);
+ cmd.put("返回游戏",FindType.ALL);
+ fight("宝库银甲兵");
+ cmd.put("上:铁屋↑",FindType.ALL);
+ fight("黄将军","true");
+ cmd.put("右:铁屋→",FindType.ALL);
+ fight("李将军","true");
+ cmd.put("左:铁屋←",FindType.ALL);
+ cmd.put("下:过道↓",FindType.ALL);
+ cmd.put("下:铁屋↓",FindType.ALL);
+ fight("史将军","true");
+ cmd.put("右:铁屋→",FindType.ALL);
+ fight("封将军","true");
+ cmd.put("左:铁屋←",FindType.ALL);
+ cmd.put("上:过道↑",FindType.ALL);
+ cmd.put("进入秘道",FindType.ALL);
+ fight("宝库白银守将");
+ cmd.put("进入下.一秘道",FindType.ALL);
+ fight("宝库黄金守将");
+ cmd.put("进入下.一秘道",FindType.ALL);
+ cmd.put("下:秘道↓",FindType.ALL);
+ cmd.put("左:秘道←",FindType.ALL);
+ cmd.put("左:秘道←",FindType.ALL);
+ cmd.put("下:秘道↓",FindType.ALL);
+ cmd.put("下:秘道↓",FindType.ALL);
+ cmd.put("右:秘道→",FindType.ALL);
+ cmd.put("下:秘道↓",FindType.ALL);
+ cmd.put("右:秘道→",FindType.ALL);
+ cmd.put("右:藏宝库巨门→",FindType.ALL);
+ fight("高不低","true");
+ cmd.put("进入太尉宝库",FindType.ALL);
+ fight("高破风","true");
+ }
+
+
+
+}
diff --git a/common/src/main/java/com/qn/dwonline/commond/IceStone.java b/common/src/main/java/com/qn/dwonline/commond/IceStone.java
new file mode 100644
index 0000000..addad43
--- /dev/null
+++ b/common/src/main/java/com/qn/dwonline/commond/IceStone.java
@@ -0,0 +1,115 @@
+package com.qn.dwonline.commond;
+
+import com.qn.dwonline.common.FindType;
+
+public class IceStone extends BaseCMD{
+
+ @Override
+ public void preCmd() {
+ setTimes(2);
+ cmd.put("冰封老人",FindType.ALL);
+ cmd.put("进入冰魄洞副本",FindType.ALL);
+ cmd.put("传送进冰魄洞",FindType.ALL);
+ cmd.put("返回游戏",FindType.ALL);
+ cmd.put("返回游戏",FindType.ALL);
+
+ fight("水洞守卫");
+ cmd.put("上:水洞↑",FindType.ALL);
+ fight("水洞守卫");
+ cmd.put("右:水洞→",FindType.ALL);
+ fight("水洞守卫");
+ cmd.put("下:水洞↓",FindType.ALL);
+ fight("水洞守卫");
+ cmd.put("下:水洞↓",FindType.ALL);
+ fight("水洞守卫");
+ cmd.put("左:水洞←",FindType.ALL);
+ fight("水洞守卫");
+ cmd.put("上:水洞↑",FindType.ALL);
+ cmd.put("右:水洞→",FindType.ALL);
+ cmd.put("右:水洞→",FindType.ALL);
+ fight("水洞守卫");
+ fight("水灵怪兽");
+
+ // 木洞
+ cmd.put("进入木洞",FindType.ALL);
+ cmd.put("返回游戏",FindType.ALL);
+ fight("木洞守卫");
+ cmd.put("上:木洞↑",FindType.ALL);
+ fight("木洞守卫");
+ cmd.put("上:木洞↑",FindType.ALL);
+ fight("木洞守卫");
+ cmd.put("右:木洞→",FindType.ALL);
+ fight("木洞守卫");
+ cmd.put("下:木洞↓",FindType.ALL);
+ fight("木洞守卫");
+ cmd.put("下:木洞↓",FindType.ALL);
+ fight("木洞守卫");
+ cmd.put("下:木洞↓",FindType.ALL);
+ fight("木洞守卫");
+ cmd.put("下:木洞↓",FindType.ALL);
+ fight("木洞守卫");
+ cmd.put("左:木洞←",FindType.ALL);
+ fight("木洞守卫");
+ cmd.put("上:木洞↑",FindType.ALL);
+ fight("木洞守卫");
+ cmd.put("上:木洞↑",FindType.ALL);
+ cmd.put("右:木洞→",FindType.ALL);
+ cmd.put("右:木洞→",FindType.ALL);
+ fight("木洞守卫");
+ fight("木灵怪兽");
+
+ // 冰洞
+ cmd.put("进入冰洞",FindType.ALL);
+ cmd.put("返回游戏",FindType.ALL);
+ fight("冰洞守卫");
+ cmd.put("上:冰洞↑",FindType.ALL);
+ fight("冰洞守卫");
+ cmd.put("上:冰洞↑",FindType.ALL);
+ fight("冰洞守卫");
+ cmd.put("右:冰洞→",FindType.ALL);
+ fight("冰洞守卫");
+ cmd.put("右:冰洞→",FindType.ALL);
+ fight("冰洞守卫");
+ cmd.put("下:冰洞↓",FindType.ALL);
+ fight("冰洞守卫");
+ cmd.put("左:冰洞←",FindType.ALL);
+ fight("冰洞守卫");
+ cmd.put("下:冰洞↓",FindType.ALL);
+ fight("冰洞守卫");
+ cmd.put("下:冰洞↓",FindType.ALL);
+ fight("冰洞守卫");
+ cmd.put("左:冰洞←",FindType.ALL);
+ fight("冰洞守卫");
+ cmd.put("下:冰洞↓",FindType.ALL);
+ fight("冰洞守卫");
+ cmd.put("右:冰洞→",FindType.ALL);
+ fight("冰洞守卫");
+ cmd.put("右:冰洞→",FindType.ALL);
+ fight("冰洞守卫");
+ cmd.put("上:冰洞↑",FindType.ALL);
+ fight("冰洞守卫");
+ cmd.put("上:冰洞↑",FindType.ALL);
+ fight("冰洞守卫");
+ cmd.put("右:冰洞→",FindType.ALL);
+ fight("冰洞守卫");
+ fight("冰灵怪兽");
+
+ //收尾了
+ cmd.put("进入黑金桥",FindType.ALL);
+ fight("黑金使者");
+ cmd.put("进入紫土桥",FindType.ALL);
+ fight("紫土使者");
+ cmd.put("进入铁木桥",FindType.ALL);
+ fight("铁木使者");
+ cmd.put("进入寒水桥",FindType.ALL);
+ fight("寒水使者");
+ cmd.put("进入烈焰桥",FindType.ALL);
+ fight("烈焰使者");
+ cmd.put("进入冰魄洞",FindType.ALL);
+ fight("天怒神兽");
+ fight("冰魄异兽");
+ }
+
+
+
+}
diff --git a/common/src/main/java/com/qn/dwonline/commond/JiangduWangfu.java b/common/src/main/java/com/qn/dwonline/commond/JiangduWangfu.java
new file mode 100644
index 0000000..7704339
--- /dev/null
+++ b/common/src/main/java/com/qn/dwonline/commond/JiangduWangfu.java
@@ -0,0 +1,47 @@
+package com.qn.dwonline.commond;
+
+import com.qn.dwonline.common.FindType;
+
+public class JiangduWangfu extends BaseCMD{
+ @Override
+ public void preCmd() {
+ cmd.put("王生妻子.佩蓉", FindType.ALL);
+ cmd.put("传送到九霄洞副本", FindType.ALL);
+ cmd.put("我愿意", FindType.ALL);
+ cmd.put("下:沙漠↓", FindType.ALL);
+ fight("沙漠蜥蜴");
+ cmd.put("下:沙漠↓", FindType.ALL);
+ fight("沙漠蜥蜴");
+ cmd.put("下:沙漠↓", FindType.ALL);
+ fight("沙漠蜥蜴");
+ cmd.put("下:沙漠↓", FindType.ALL);
+ fight("沙漠蜥蜴");
+ cmd.put("下:沙漠↓", FindType.ALL);
+ fight("沙漠蜥蜴");
+ cmd.put("右:沙漠→", FindType.ALL);
+ fight("沙漠蜥蜴");
+ cmd.put("上:沙漠↑", FindType.ALL);
+ fight("沙漠蜥蜴");
+ cmd.put("上:沙漠↑", FindType.ALL);
+ fight("沙漠蜥蜴");
+ cmd.put("上:沙漠↑", FindType.ALL);
+ fight("沙漠蜥蜴");
+ cmd.put("上:沙漠↑", FindType.ALL);
+ fight("沙漠蜥蜴");
+ cmd.put("右:沙漠→", FindType.ALL);
+ fight("沙漠蜥蜴");
+ cmd.put("下:沙漠↓", FindType.ALL);
+ fight("沙漠蜥蜴");
+ cmd.put("下:沙漠↓", FindType.ALL);
+ fight("沙漠蜥蜴");
+ cmd.put("下:沙漠↓", FindType.ALL);
+ fight("沙漠蜥蜴");
+ cmd.put("下:沙漠↓", FindType.ALL);
+ fight("沙漠蜥蜴");
+ cmd.put("进入峭壁",FindType.ALL);
+ fight("小易","");
+ cmd.put("进入九霄洞",FindType.ALL);
+// fight("小唯","");
+
+ }
+}
diff --git a/common/src/main/java/com/qn/dwonline/commond/ShaoHuaShan.java b/common/src/main/java/com/qn/dwonline/commond/ShaoHuaShan.java
new file mode 100644
index 0000000..cdbbcdc
--- /dev/null
+++ b/common/src/main/java/com/qn/dwonline/commond/ShaoHuaShan.java
@@ -0,0 +1,53 @@
+package com.qn.dwonline.commond;
+
+import com.qn.dwonline.common.FindType;
+
+public class ShaoHuaShan extends BaseCMD{
+
+
+ @Override
+ public void preCmd() {
+ cmd.put("少华山石匠", FindType.ALL);
+ cmd.put("传送至落雪山副本", FindType.ALL);
+ fight("落雪山草寇");
+ cmd.put("进入雪地", FindType.ALL);
+ cmd.put("左:雪地←",FindType.ALL);
+ cmd.put("左:雪地←",FindType.ALL);
+ cmd.put("下:冰窟↓",FindType.ALL);
+ fight("冰原毒蛇");
+ cmd.put("上:雪地↑",FindType.ALL);
+ cmd.put("右:雪地→",FindType.ALL);
+ cmd.put("右:雪地→",FindType.ALL);
+ cmd.put("右:雪地→",FindType.ALL);
+ cmd.put("右:雪地→",FindType.ALL);
+ cmd.put("上:雪地↑",FindType.ALL);
+ cmd.put("右:冰河→",FindType.ALL);
+ fight("冰河巨鱼");
+ cmd.put("左:雪地←",FindType.ALL);
+ cmd.put("下:雪地↓",FindType.ALL);
+ cmd.put("下:雪地↓",FindType.ALL);
+ cmd.put("右:雪地机关一→",FindType.ALL);
+ cmd.put("打开机关",FindType.ALL);
+ cmd.put("返回游戏",FindType.ALL);
+ cmd.put("左:雪地←",FindType.ALL);
+ cmd.put("左:雪地←",FindType.ALL);
+ cmd.put("上:雪地↑",FindType.ALL);
+ cmd.put("上:白雪地↑",FindType.ALL);
+ cmd.put("上:冰原↑",FindType.ALL);
+ fight("落雪山小首领");
+ cmd.put("进入雪原",FindType.ALL);
+ fight("落雪山首领");
+ cmd.put("进入白雪河",FindType.ALL);
+ fight("落雪山七当家");
+ cmd.put("进入寒冰路",FindType.ALL);
+ fight("落雪山六当家");
+ cmd.put("进入寒冰坡",FindType.ALL);
+ fight("落雪山五当家");
+ cmd.put("进入白雪路",FindType.ALL);
+ fight("落雪山四当家");
+ cmd.put("进入落雪山顶",FindType.ALL);
+ fight("落雪山三当家");
+ cmd.put("右:落雪洞一→",FindType.ALL);
+ fight("落雪山二当家");
+ }
+}
diff --git a/common/src/main/java/com/qn/dwonline/commond/ShiJiaZhuang.java b/common/src/main/java/com/qn/dwonline/commond/ShiJiaZhuang.java
new file mode 100644
index 0000000..3737833
--- /dev/null
+++ b/common/src/main/java/com/qn/dwonline/commond/ShiJiaZhuang.java
@@ -0,0 +1,69 @@
+package com.qn.dwonline.commond;
+
+import com.qn.dwonline.common.FindType;
+
+public class ShiJiaZhuang extends BaseCMD{
+
+
+ @Override
+ public void preCmd() {
+ cmd.put("史家庄童仆", FindType.ALL);
+ cmd.put("传送至云树山副本", FindType.ALL);
+ fight("云树林守卫");
+ cmd.put("进入云树林", FindType.ALL);
+ fight("小红虫");
+ fight("小红虫");
+ fight("大红虫");
+ cmd.put("左:云树林←",FindType.ALL);
+ fight("小红虫");
+ fight("小红虫");
+ fight("大红虫");
+ cmd.put("上:云树林↑",FindType.ALL);
+ fight("小红虫");
+ fight("小红虫");
+ fight("大红虫");
+ cmd.put("下:云树林↓",FindType.ALL);
+ cmd.put("右:云树林→",FindType.ALL);
+ cmd.put("右:云树林→",FindType.ALL);
+ fight("小红虫");
+ fight("小红虫");
+ fight("大红虫");
+ cmd.put("右:云树林→",FindType.ALL);
+ fight("小红虫");
+ fight("小红虫");
+ fight("大红虫");
+ cmd.put("右:云树林→",FindType.ALL);
+ fight("小红虫");
+ fight("小红虫");
+ fight("大红虫");
+ cmd.put("左:云树林←",FindType.ALL);
+ cmd.put("下:云树林↓",FindType.ALL);
+ fight("小红虫");
+ fight("小红虫");
+ fight("大红虫");
+ cmd.put("上:云树林↑",FindType.ALL);
+ cmd.put("左:云树林←",FindType.ALL);
+ cmd.put("上:云树林↑",FindType.ALL);
+ fight("小红虫");
+ fight("小红虫");
+ fight("大红虫");
+ cmd.put("下:云树林↓",FindType.ALL);
+ cmd.put("左:云树林←",FindType.ALL);
+ cmd.put("进入小河",FindType.ALL);
+ fight("大河鱼");
+ cmd.put("进入小路",FindType.ALL);
+ cmd.put("上:土路↑",FindType.ALL);
+ fight("大土狗");
+ cmd.put("进入石子路",FindType.ALL);
+ fight("大土狼");
+ cmd.put("进入云树山脚",FindType.ALL);
+ fight("云树山守卫");
+ cmd.put("进入山坡",FindType.ALL);
+ fight("云树山守将");
+ cmd.put("进入云树山顶",FindType.ALL);
+ fight("云树山二当家");
+ cmd.put("进入小草屋",FindType.ALL);
+ fight("云树山大当家");
+
+ }
+}
diff --git a/common/src/main/java/com/qn/dwonline/commond/Test.java b/common/src/main/java/com/qn/dwonline/commond/Test.java
new file mode 100644
index 0000000..1e7d845
--- /dev/null
+++ b/common/src/main/java/com/qn/dwonline/commond/Test.java
@@ -0,0 +1,15 @@
+package com.qn.dwonline.commond;
+
+public class Test extends BaseCMD{
+
+ private String fightFor;
+
+ public Test(String fightFor) {
+ this.fightFor = fightFor;
+ }
+
+ @Override
+ public void preCmd() {
+ fight(fightFor);
+ }
+}
diff --git a/common/src/main/java/com/qn/dwonline/commond/pick/DaBaiCai.java b/common/src/main/java/com/qn/dwonline/commond/pick/DaBaiCai.java
new file mode 100644
index 0000000..1dcdc50
--- /dev/null
+++ b/common/src/main/java/com/qn/dwonline/commond/pick/DaBaiCai.java
@@ -0,0 +1,31 @@
+package com.qn.dwonline.commond.pick;
+
+import com.qn.dwonline.common.FindType;
+import com.qn.dwonline.commond.BaseCMD;
+
+public class DaBaiCai extends BaseCMD {
+ @Override
+ protected void preCmd() {
+ clickFight("偷菜盗贼");
+ cmd.put("左:菜畦←", FindType.ALL);
+ clickFight("偷菜盗贼");
+ cmd.put("上:菜畦↑", FindType.ALL);
+ clickFight("偷菜盗贼");
+ cmd.put("左:菜畦←", FindType.ALL);
+ clickFight("偷菜盗贼");
+ cmd.put("左:菜畦←", FindType.ALL);
+ clickFight("偷菜盗贼");
+ cmd.put("下:菜畦↓", FindType.ALL);
+ clickFight("偷菜盗贼");
+ cmd.put("右:菜畦→", FindType.ALL);
+ clickFight("偷菜盗贼");
+ cmd.put("下:菜畦↓", FindType.ALL);
+ clickFight("偷菜盗贼");
+ cmd.put("右:菜畦→", FindType.ALL);
+ clickFight("偷菜盗贼");
+ cmd.put("上:菜畦↑", FindType.ALL);
+ clickFight("偷菜盗贼");
+ cmd.put("右:菜畦→", FindType.ALL);
+ clickFight("偷菜盗贼");
+ }
+}
diff --git a/common/src/main/java/com/qn/dwonline/dojbo/FuBenAction.java b/common/src/main/java/com/qn/dwonline/dojbo/FuBenAction.java
new file mode 100644
index 0000000..f5091be
--- /dev/null
+++ b/common/src/main/java/com/qn/dwonline/dojbo/FuBenAction.java
@@ -0,0 +1,39 @@
+package com.qn.dwonline.dojbo;
+
+import com.qn.dwonline.BaseAction;
+import com.qn.dwonline.commond.*;
+
+public class FuBenAction {
+
+ public static void main(String[] args) {
+ BaseCMD baseCMD = doWhichOne(3);
+ int times = baseCMD.getTimes();
+ BaseAction baseAction = new BaseAction("i5gnhu51jtbicraw5t8pl");
+// for (int i = 0; i < times; i++){
+ baseAction.doJob(baseCMD);
+// }
+ }
+
+ static BaseCMD doWhichOne(int i){
+ switch (i){
+ case 1:
+ return new ShiJiaZhuang();
+ case 2:
+ return new ShaoHuaShan();
+ case 3:
+ return new EatPeople();
+ case 4:
+ return new GaoTreasury();
+ case 5:
+ return new IceStone();
+ case 6:
+ return new JiangduWangfu();
+ case 7:
+ return new DangKou();
+ default:
+ return new BlackWind();
+ }
+ }
+
+
+}
diff --git a/common/src/main/java/com/qn/dwonline/dojbo/PickAction.java b/common/src/main/java/com/qn/dwonline/dojbo/PickAction.java
new file mode 100644
index 0000000..08bfdc7
--- /dev/null
+++ b/common/src/main/java/com/qn/dwonline/dojbo/PickAction.java
@@ -0,0 +1,19 @@
+package com.qn.dwonline.dojbo;
+
+import com.qn.dwonline.BaseAction;
+import com.qn.dwonline.commond.*;
+import com.qn.dwonline.commond.pick.DaBaiCai;
+
+public class PickAction {
+
+ public static void main(String[] args) {
+ BaseCMD baseCMD = new DaBaiCai();
+ BaseAction baseAction = new BaseAction("xq31ce51i2vqwn8t8qglo");
+ int i=0;
+ while (true){
+ System.out.println("第"+(++i)+"次循环");
+ baseAction.doJob(baseCMD);
+ }
+ }
+
+}
diff --git a/common/src/main/java/com/qn/dwonline/dojbo/TestAction.java b/common/src/main/java/com/qn/dwonline/dojbo/TestAction.java
new file mode 100644
index 0000000..29a8464
--- /dev/null
+++ b/common/src/main/java/com/qn/dwonline/dojbo/TestAction.java
@@ -0,0 +1,14 @@
+package com.qn.dwonline.dojbo;
+
+import com.qn.dwonline.BaseAction;
+import com.qn.dwonline.commond.*;
+
+public class TestAction {
+ public static void main(String[] args) {
+ BaseCMD baseCMD = new Test("老黄牛");
+ BaseAction baseAction = new BaseAction("dzh5xd51kaeiq0b2b0zqn");
+ while (true){
+ baseAction.doJob(baseCMD);
+ }
+ }
+}
diff --git a/common/src/main/java/model/wx/TextMessage.java b/common/src/main/java/com/qn/model/wx/TextMessage.java
similarity index 97%
rename from common/src/main/java/model/wx/TextMessage.java
rename to common/src/main/java/com/qn/model/wx/TextMessage.java
index 96f298b..8781ae0 100644
--- a/common/src/main/java/model/wx/TextMessage.java
+++ b/common/src/main/java/com/qn/model/wx/TextMessage.java
@@ -1,4 +1,4 @@
-package model.wx;
+package com.qn.model.wx;
import java.io.Serializable;
diff --git a/common/src/main/java/com/qn/test/event/EventSourceObject.java b/common/src/main/java/com/qn/test/event/EventSourceObject.java
new file mode 100644
index 0000000..b148efa
--- /dev/null
+++ b/common/src/main/java/com/qn/test/event/EventSourceObject.java
@@ -0,0 +1,37 @@
+package com.qn.test.event;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+public class EventSourceObject {
+ private String name;
+ private Set listener;
+
+ public EventSourceObject() {
+ this.name = "zhangsan";
+ this.listener = new HashSet();
+ }
+
+ public void addMyListener(MyEventListener l){
+ listener.add(l);
+ }
+
+ protected void notifies(){
+ System.out.println("事件源发生了,需要进行事件回调");
+ Iterator iterator = listener.iterator();
+ while (iterator.hasNext()){
+ MyEventListener next = (MyEventListener) iterator.next();
+ next.fire(new MyEvent(this));
+ }
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ notifies();
+ }
+}
diff --git a/common/src/main/java/com/qn/test/event/MainEventTest.java b/common/src/main/java/com/qn/test/event/MainEventTest.java
new file mode 100644
index 0000000..c606ed6
--- /dev/null
+++ b/common/src/main/java/com/qn/test/event/MainEventTest.java
@@ -0,0 +1,21 @@
+package com.qn.test.event;
+
+import java.util.Timer;
+import java.util.TimerTask;
+
+public class MainEventTest {
+ public static void main(String[] args) {
+ // 事件源
+ EventSourceObject eventSourceObject = new EventSourceObject();
+ eventSourceObject.addMyListener(new MyEventListener());
+ eventSourceObject.setName("lisi");
+
+ Timer timer = new Timer();
+ timer.schedule(new TimerTask() {
+ @Override
+ public void run() {
+
+ }
+ },1000);
+ }
+}
diff --git a/common/src/main/java/com/qn/test/event/MyEvent.java b/common/src/main/java/com/qn/test/event/MyEvent.java
new file mode 100644
index 0000000..53ae98e
--- /dev/null
+++ b/common/src/main/java/com/qn/test/event/MyEvent.java
@@ -0,0 +1,15 @@
+package com.qn.test.event;
+
+import java.util.EventObject;
+
+public class MyEvent extends EventObject {
+ /**
+ * Constructs a prototypical Event.
+ *
+ * @param source The object on which the Event initially occurred.
+ * @throws IllegalArgumentException if source is null.
+ */
+ public MyEvent(Object source) {
+ super(source);
+ }
+}
diff --git a/common/src/main/java/com/qn/test/event/MyEventListener.java b/common/src/main/java/com/qn/test/event/MyEventListener.java
new file mode 100644
index 0000000..1f444ff
--- /dev/null
+++ b/common/src/main/java/com/qn/test/event/MyEventListener.java
@@ -0,0 +1,12 @@
+package com.qn.test.event;
+
+import java.util.EventListener;
+
+public class MyEventListener implements EventListener {
+
+ public void fire(MyEvent e){
+ EventSourceObject source = (EventSourceObject) e.getSource();
+ System.out.println("事件发生后" + source.getName());
+ }
+
+}
diff --git a/common/src/main/java/com/qn/test/sort/SortDemo.java b/common/src/main/java/com/qn/test/sort/SortDemo.java
new file mode 100644
index 0000000..7c9ca5e
--- /dev/null
+++ b/common/src/main/java/com/qn/test/sort/SortDemo.java
@@ -0,0 +1,43 @@
+package com.qn.test.sort;
+
+public class SortDemo {
+
+ static int [] arr = {20,1,46,15,7,5,76,13,30,6,9,71,63,74,654,16,7894,1321,156,78,61,754,90,60,30,40,90,406};
+
+ //插入排序
+ public static void sortTest1(){
+ int length = arr.length;
+ for(int i = 1;i < length; i++){
+ int temp = arr[i];
+ int j;
+ for (j = i ; j > 0 && arr[j-1] > temp ; j-- ){
+ arr[j] = arr[j-1];
+ }
+ arr[j] = temp;
+ }
+ for(int o : arr){
+ System.out.print(o + ",");
+ }
+ }
+
+ //插入排序
+ public static void sortTest2(){
+ int length = arr.length;
+ for(int i = length/2 ;i > 0; i /= 2){
+ int temp = arr[i];
+ int j;
+ for (j = i ; j > 0 && arr[j-1] > temp ; j-- ){
+ arr[j] = arr[j-1];
+ }
+ arr[j] = temp;
+ }
+ for(int o : arr){
+ System.out.print(o + ",");
+ }
+ }
+
+ public static void main(String[] args) {
+ sortTest1();
+ }
+
+}
diff --git a/common/src/main/java/com/qn/utils/AesUtil.java b/common/src/main/java/com/qn/utils/AesUtil.java
new file mode 100644
index 0000000..70e968c
--- /dev/null
+++ b/common/src/main/java/com/qn/utils/AesUtil.java
@@ -0,0 +1,60 @@
+package com.qn.utils;
+import javax.crypto.Cipher;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+
+/**
+ * @author: wuyou
+ * @create: 2019-05-09 14:18
+ **/
+public class AesUtil {
+ public static final String SECRET_KEY = "a69i3z8b516gd370";
+
+ /**
+ * Encrypt string.
+ *
+ * @param sSrc the s src
+ * @return the string
+ */
+ public static String encrypt(String sSrc) {
+ try {
+ if (sSrc == null){
+ return null;
+ }
+ byte[] raw = SECRET_KEY.getBytes();
+ SecretKeySpec sKeySpec = new SecretKeySpec(raw, "AES");
+ // "算法/模式/补码方式"
+ Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
+ // 使用CBC模式,需要一个向量iv,可增加加密算法的强度
+ IvParameterSpec iv = new IvParameterSpec("0102030405060708".getBytes());
+ cipher.init(Cipher.ENCRYPT_MODE, sKeySpec, iv);
+ byte[] encrypted = cipher.doFinal(sSrc.getBytes());
+ // 此处使用BASE64做转码功能,同时能起到2次加密的作用。
+ return Base64.encodeS(encrypted);
+ } catch (Throwable e) {
+ return null;
+ }
+ }
+
+ /**
+ * Decrypt string.
+ *
+ * @param sSrc the s src
+ * @return the string
+ */
+ public static String decrypt(String sSrc) {
+ try {
+ byte[] raw = SECRET_KEY.getBytes("ASCII");
+ SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
+ Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
+ IvParameterSpec iv = new IvParameterSpec("0102030405060708".getBytes());
+ cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv);
+ // 先用base64解密
+ byte[] encrypted1 = Base64.decode(sSrc);
+ byte[] original = cipher.doFinal(encrypted1);
+ return new String(original);
+ } catch (Throwable th) {
+ return null;
+ }
+ }
+}
diff --git a/common/src/main/java/com/qn/utils/Base64.java b/common/src/main/java/com/qn/utils/Base64.java
new file mode 100644
index 0000000..7791b7d
--- /dev/null
+++ b/common/src/main/java/com/qn/utils/Base64.java
@@ -0,0 +1,285 @@
+package com.qn.utils;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.zip.Deflater;
+import java.util.zip.Inflater;
+
+/**
+ * @author: wuyou
+ * @create: 2019-05-09 14:19
+ **/
+public class Base64 {
+
+ private static final byte[] ENCODING_TABLE = {(byte) 'A', (byte) 'B',
+ (byte) 'C', (byte) 'D', (byte) 'E', (byte) 'F', (byte) 'G',
+ (byte) 'H', (byte) 'I', (byte) 'J', (byte) 'K', (byte) 'L',
+ (byte) 'M', (byte) 'N', (byte) 'O', (byte) 'P', (byte) 'Q',
+ (byte) 'R', (byte) 'S', (byte) 'T', (byte) 'U', (byte) 'V',
+ (byte) 'W', (byte) 'X', (byte) 'Y', (byte) 'Z', (byte) 'a',
+ (byte) 'b', (byte) 'c', (byte) 'd', (byte) 'e', (byte) 'f',
+ (byte) 'g', (byte) 'h', (byte) 'i', (byte) 'j', (byte) 'k',
+ (byte) 'l', (byte) 'm', (byte) 'n', (byte) 'o', (byte) 'p',
+ (byte) 'q', (byte) 'r', (byte) 's', (byte) 't', (byte) 'u',
+ (byte) 'v', (byte) 'w', (byte) 'x', (byte) 'y', (byte) 'z',
+ (byte) '0', (byte) '1', (byte) '2', (byte) '3', (byte) '4',
+ (byte) '5', (byte) '6', (byte) '7', (byte) '8', (byte) '9',
+ (byte) '+', (byte) '/'};
+ private static final byte[] DECODING_TABLE;
+
+ static {
+ DECODING_TABLE = new byte[128];
+ for (int i = 0; i < 128; i++) {
+ DECODING_TABLE[i] = (byte) -1;
+ }
+ for (int i = 'A'; i <= 'Z'; i++) {
+ DECODING_TABLE[i] = (byte) (i - 'A');
+ }
+ for (int i = 'a'; i <= 'z'; i++) {
+ DECODING_TABLE[i] = (byte) (i - 'a' + 26);
+ }
+ for (int i = '0'; i <= '9'; i++) {
+ DECODING_TABLE[i] = (byte) (i - '0' + 52);
+ }
+ DECODING_TABLE['+'] = 62;
+ DECODING_TABLE['/'] = 63;
+ }
+
+ public static String encodeS(byte[] data) {
+ return new String(encode(data));
+ }
+
+ public static byte[] encode(byte[] data) {
+ byte[] bytes;
+ int modulus = data.length % 3;
+ if (modulus == 0) {
+ bytes = new byte[(4 * data.length) / 3];
+ } else {
+ bytes = new byte[4 * ((data.length / 3) + 1)];
+ }
+ int dataLength = (data.length - modulus);
+ int a1;
+ int a2;
+ int a3;
+ for (int i = 0, j = 0; i < dataLength; i += 3, j += 4) {
+ a1 = data[i] & 0xff;
+ a2 = data[i + 1] & 0xff;
+ a3 = data[i + 2] & 0xff;
+ bytes[j] = ENCODING_TABLE[(a1 >>> 2) & 0x3f];
+ bytes[j + 1] = ENCODING_TABLE[((a1 << 4) | (a2 >>> 4)) & 0x3f];
+ bytes[j + 2] = ENCODING_TABLE[((a2 << 2) | (a3 >>> 6)) & 0x3f];
+ bytes[j + 3] = ENCODING_TABLE[a3 & 0x3f];
+ }
+ int b1;
+ int b2;
+ int b3;
+ int d1;
+ int d2;
+ switch (modulus) {
+ //nothing left to do
+ case 0:
+ break;
+ case 1:
+ d1 = data[data.length - 1] & 0xff;
+ b1 = (d1 >>> 2) & 0x3f;
+ b2 = (d1 << 4) & 0x3f;
+ bytes[bytes.length - 4] = ENCODING_TABLE[b1];
+ bytes[bytes.length - 3] = ENCODING_TABLE[b2];
+ bytes[bytes.length - 2] = (byte) '=';
+ bytes[bytes.length - 1] = (byte) '=';
+ break;
+ case 2:
+ d1 = data[data.length - 2] & 0xff;
+ d2 = data[data.length - 1] & 0xff;
+ b1 = (d1 >>> 2) & 0x3f;
+ b2 = ((d1 << 4) | (d2 >>> 4)) & 0x3f;
+ b3 = (d2 << 2) & 0x3f;
+ bytes[bytes.length - 4] = ENCODING_TABLE[b1];
+ bytes[bytes.length - 3] = ENCODING_TABLE[b2];
+ bytes[bytes.length - 2] = ENCODING_TABLE[b3];
+ bytes[bytes.length - 1] = (byte) '=';
+ break;
+ default:
+ break;
+ }
+ return bytes;
+ }
+
+ public static byte[] decode(byte[] data) {
+ byte[] bytes;
+ byte b1;
+ byte b2;
+ byte b3;
+ byte b4;
+ data = discardNonBase64Bytes(data);
+ if (data[data.length - 2] == '=') {
+ bytes = new byte[(((data.length / 4) - 1) * 3) + 1];
+ } else if (data[data.length - 1] == '=') {
+ bytes = new byte[(((data.length / 4) - 1) * 3) + 2];
+ } else {
+ bytes = new byte[((data.length / 4) * 3)];
+ }
+ for (int i = 0, j = 0; i < (data.length - 4); i += 4, j += 3) {
+ b1 = DECODING_TABLE[data[i]];
+ b2 = DECODING_TABLE[data[i + 1]];
+ b3 = DECODING_TABLE[data[i + 2]];
+ b4 = DECODING_TABLE[data[i + 3]];
+ bytes[j] = (byte) ((b1 << 2) | (b2 >> 4));
+ bytes[j + 1] = (byte) ((b2 << 4) | (b3 >> 2));
+ bytes[j + 2] = (byte) ((b3 << 6) | b4);
+ }
+ if (data[data.length - 2] == '=') {
+ b1 = DECODING_TABLE[data[data.length - 4]];
+ b2 = DECODING_TABLE[data[data.length - 3]];
+ bytes[bytes.length - 1] = (byte) ((b1 << 2) | (b2 >> 4));
+ } else if (data[data.length - 1] == '=') {
+ b1 = DECODING_TABLE[data[data.length - 4]];
+ b2 = DECODING_TABLE[data[data.length - 3]];
+ b3 = DECODING_TABLE[data[data.length - 2]];
+ bytes[bytes.length - 2] = (byte) ((b1 << 2) | (b2 >> 4));
+ bytes[bytes.length - 1] = (byte) ((b2 << 4) | (b3 >> 2));
+ } else {
+ b1 = DECODING_TABLE[data[data.length - 4]];
+ b2 = DECODING_TABLE[data[data.length - 3]];
+ b3 = DECODING_TABLE[data[data.length - 2]];
+ b4 = DECODING_TABLE[data[data.length - 1]];
+ bytes[bytes.length - 3] = (byte) ((b1 << 2) | (b2 >> 4));
+ bytes[bytes.length - 2] = (byte) ((b2 << 4) | (b3 >> 2));
+ bytes[bytes.length - 1] = (byte) ((b3 << 6) | b4);
+ }
+ return bytes;
+ }
+
+ public static byte[] decode(String data) {
+ byte[] bytes;
+ byte b1;
+ byte b2;
+ byte b3;
+ byte b4;
+ data = discardNonBase64Chars(data);
+ if (data.charAt(data.length() - 2) == '=') {
+ bytes = new byte[(((data.length() / 4) - 1) * 3) + 1];
+ } else if (data.charAt(data.length() - 1) == '=') {
+ bytes = new byte[(((data.length() / 4) - 1) * 3) + 2];
+ } else {
+ bytes = new byte[((data.length() / 4) * 3)];
+ }
+ for (int i = 0, j = 0; i < (data.length() - 4); i += 4, j += 3) {
+ b1 = DECODING_TABLE[data.charAt(i)];
+ b2 = DECODING_TABLE[data.charAt(i + 1)];
+ b3 = DECODING_TABLE[data.charAt(i + 2)];
+ b4 = DECODING_TABLE[data.charAt(i + 3)];
+ bytes[j] = (byte) ((b1 << 2) | (b2 >> 4));
+ bytes[j + 1] = (byte) ((b2 << 4) | (b3 >> 2));
+ bytes[j + 2] = (byte) ((b3 << 6) | b4);
+ }
+ if (data.charAt(data.length() - 2) == '=') {
+ b1 = DECODING_TABLE[data.charAt(data.length() - 4)];
+ b2 = DECODING_TABLE[data.charAt(data.length() - 3)];
+ bytes[bytes.length - 1] = (byte) ((b1 << 2) | (b2 >> 4));
+ } else if (data.charAt(data.length() - 1) == '=') {
+ b1 = DECODING_TABLE[data.charAt(data.length() - 4)];
+ b2 = DECODING_TABLE[data.charAt(data.length() - 3)];
+ b3 = DECODING_TABLE[data.charAt(data.length() - 2)];
+ bytes[bytes.length - 2] = (byte) ((b1 << 2) | (b2 >> 4));
+ bytes[bytes.length - 1] = (byte) ((b2 << 4) | (b3 >> 2));
+ } else {
+ b1 = DECODING_TABLE[data.charAt(data.length() - 4)];
+ b2 = DECODING_TABLE[data.charAt(data.length() - 3)];
+ b3 = DECODING_TABLE[data.charAt(data.length() - 2)];
+ b4 = DECODING_TABLE[data.charAt(data.length() - 1)];
+ bytes[bytes.length - 3] = (byte) ((b1 << 2) | (b2 >> 4));
+ bytes[bytes.length - 2] = (byte) ((b2 << 4) | (b3 >> 2));
+ bytes[bytes.length - 1] = (byte) ((b3 << 6) | b4);
+ }
+ return bytes;
+ }
+
+ private static byte[] discardNonBase64Bytes(byte[] data) {
+ byte[] temp = new byte[data.length];
+ int bytesCopied = 0;
+ for (int i = 0; i < data.length; i++) {
+ if (isValidBase64Byte(data[i])) {
+ temp[bytesCopied++] = data[i];
+ }
+ }
+ byte[] newData = new byte[bytesCopied];
+ System.arraycopy(temp, 0, newData, 0, bytesCopied);
+ return newData;
+ }
+
+ private static String discardNonBase64Chars(String data) {
+ StringBuffer sb = new StringBuffer();
+ int length = data.length();
+ for (int i = 0; i < length; i++) {
+ if (isValidBase64Byte((byte) (data.charAt(i)))) {
+ sb.append(data.charAt(i));
+ }
+ }
+ return sb.toString();
+ }
+
+ private static boolean isValidBase64Byte(byte b) {
+ if (b == '=') {
+ return true;
+ } else if ((b < 0) || (b >= 128)) {
+ return false;
+ } else if (DECODING_TABLE[b] == -1) {
+ return false;
+ }
+ return true;
+ }
+
+ public static byte[] compressBytes(byte input[]) {
+ int cachesize = 1024;
+
+ Deflater compresser = new Deflater();
+
+ compresser.reset();
+ compresser.setInput(input);
+ compresser.finish();
+ byte output[] = new byte[0];
+ ByteArrayOutputStream o = new ByteArrayOutputStream(input.length);
+ try {
+ byte[] buf = new byte[cachesize];
+ int got;
+ while (!compresser.finished()) {
+ got = compresser.deflate(buf);
+ o.write(buf, 0, got);
+ }
+ output = o.toByteArray();
+ } finally {
+ try {
+ o.close();
+ } catch (IOException e) {
+ }
+ }
+ return output;
+ }
+
+ public static byte[] decompressBytes(byte input[]) {
+ int cachesize = 1024;
+ Inflater decompresser = new Inflater();
+
+ byte output[] = new byte[0];
+ decompresser.reset();
+ decompresser.setInput(input);
+ ByteArrayOutputStream o = new ByteArrayOutputStream(input.length);
+ try {
+ byte[] buf = new byte[cachesize];
+ int got;
+ while (!decompresser.finished()) {
+ got = decompresser.inflate(buf);
+ o.write(buf, 0, got);
+ }
+ output = o.toByteArray();
+ } catch (Exception e) {
+ } finally {
+ try {
+ o.close();
+ } catch (IOException e) {
+ }
+ }
+ return output;
+ }
+}
diff --git a/common/src/main/java/com/qn/utils/BeanUtil.java b/common/src/main/java/com/qn/utils/BeanUtil.java
new file mode 100644
index 0000000..98e808b
--- /dev/null
+++ b/common/src/main/java/com/qn/utils/BeanUtil.java
@@ -0,0 +1,423 @@
+package com.qn.utils;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.*;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
+
+public class BeanUtil {
+
+ private static WriteLock lock = new ReentrantReadWriteLock().writeLock();
+
+ private static final Map, Map> METADATA = new HashMap<>();
+
+ /**
+ * 对象转换
+ *
+ * @param source
+ * 源对象
+ * @param targetClass
+ * 目标类
+ * @return 返回一个新的目标类对象, 该目标类对象的属性值从源对象中拷贝而来
+ */
+ public static T convert(Object source, Class targetClass) {
+ T target = newInstance(targetClass);
+ copyProperties(source, target);
+ return target;
+ }
+
+ /**
+ * 对象列表转换
+ *
+ * @param sources
+ * 源对象列表
+ * @param targetClass
+ * 目标类
+ * @return 返回一个新的目标对象列表, 每个目标类对象的属性值从源对象中拷贝而来
+ */
+ public static List convert(Collection> sources, Class targetClass) {
+ List targets = new ArrayList();
+ if (sources != null && sources.size() > 0) {
+ for (Object source : sources) {
+ targets.add(convert(source, targetClass));
+ }
+ }
+ return targets;
+ }
+
+ /**
+ * 属性拷贝, 当且仅当两个对象的非静态属性名称相同且对应的属性类型也相同时才进行属性值拷贝
+ *
+ * @param source
+ * 源对象
+ * @param target
+ * 目标对象
+ */
+ public static void copyProperties(Object source, Object target) {
+ copyProperties(source, target, true);
+ }
+
+ /**
+ * 属性拷贝, 当且仅当两个对象的非静态属性名称相同且对应的属性类型也相同时才进行属性值拷贝
+ *
+ * @param source
+ * 源对象
+ * @param target
+ * 目标对象
+ * @param copyNullProperty
+ * 是否拷贝null属性值
+ */
+ public static void copyProperties(Object source, Object target, boolean copyNullProperty) {
+ if (source == null) {
+ return ;
+ }
+ Class> sourceClass = source.getClass();
+ Class> targetClass = target.getClass();
+ Map targetFields = getFieldsMap(targetClass, FieldType.NOT_STATIC);
+ Map sourceFields = getFieldsMap(sourceClass, FieldType.NOT_STATIC);
+ for (String name : targetFields.keySet()) {
+ if (sourceFields.containsKey(name)) {
+ Field sourceField = sourceFields.get(name);
+ Field targetField = targetFields.get(name);
+ if (targetField.getType() == sourceField.getType()) {
+ Object value = getPropertyValue(source, sourceField);
+ if (value == null && !copyNullProperty) {
+ continue ;
+ }
+ setPropertyValue(target, targetField, value);
+ }
+ }
+ }
+ }
+
+ /**
+ * 创建类的一个实例
+ *
+ * @param beanClass
+ * 类
+ */
+ public static T newInstance(Class beanClass) {
+ try {
+ return beanClass.newInstance();
+ } catch (Throwable e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * 设置对象属性的值
+ *
+ * @param bean
+ * 目标对象
+ * @param field
+ * 属性名称
+ * @param propertyValue
+ * 属性的值
+ */
+ public static void setPropertyValue(Object bean, Field field, Object propertyValue) {
+ try {
+ field.set(bean, propertyValue);
+ } catch (Throwable e) {
+ throw new RuntimeException(bean.getClass().getName() + " " + field.getName() + " " + propertyValue, e);
+ }
+ }
+
+ /**
+ * 获取目标属性的值
+ *
+ * @param bean
+ * 目标对象
+ * @param field
+ * 属性名称
+ * @return
+ */
+ @SuppressWarnings("unchecked")
+ public static T getPropertyValue(Object bean, Field field) {
+ try {
+ return (T) field.get(bean);
+ } catch (Throwable e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * 设置属性的值
+ *
+ * @param bean
+ * 对象或类
+ * @param property
+ * 类属性或对象属性名称
+ * @param propertyValue
+ * 属性的值
+ */
+ public static void setPropertyValue(Object bean, String property, Object propertyValue) {
+ if (bean != null) {
+ Class> beanClass = null;
+ if (bean instanceof Class) {
+ beanClass = (Class>) bean;
+ } else {
+ beanClass = bean.getClass();
+ }
+ Field field = getFieldsMap(beanClass, FieldType.ALL).get(property);
+ if (field != null) {
+ setPropertyValue(bean, field, propertyValue);
+ }
+ }
+ }
+
+ /**
+ * 获取属性的值
+ *
+ * @param bean
+ * 对象或类
+ * @param property
+ * 类属性名称或对象属性名称
+ * @return
+ */
+ public static T getPropertyValue(Object bean, String property) {
+ if (bean != null) {
+ Class> beanClass = null;
+ if (bean instanceof Class) {
+ beanClass = (Class>) bean;
+ } else {
+ beanClass = bean.getClass();
+ }
+ Field field = getFieldsMap(beanClass, FieldType.ALL).get(property);
+ if (field != null) {
+ return getPropertyValue(bean, field);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * 获取属性的类型
+ *
+ * @param bean
+ * 对象或类
+ * @param property
+ * 类属性名称或对象属性名称
+ * @return
+ */
+ public static Class> getPropertyType(Object bean, String property) {
+ if (bean != null) {
+ Class> beanClass = null;
+ if (bean instanceof Class) {
+ beanClass = (Class>) bean;
+ } else {
+ beanClass = bean.getClass();
+ }
+ Field field = getFieldsMap(beanClass, FieldType.ALL).get(property);
+ if (field != null) {
+ return field.getType();
+ }
+ }
+ return null;
+ }
+
+ /**
+ * 将对象转换为散列表
+ *
+ * @param source
+ * 源对象
+ * @return
+ */
+ public static Map convertMap(Object source) {
+ return convertMap(source, true);
+ }
+
+ /**
+ * 将对象转换为散列表
+ *
+ * @param source
+ * 源对象
+ * @param convertNullProperty
+ * 空属性是否转换
+ * @return
+ */
+ public static Map convertMap(Object source, boolean convertNullProperty) {
+ Map map = new HashMap();
+ if (source != null) {
+ Map sourceFields = getFieldsMap(source.getClass(), FieldType.NOT_STATIC);
+ for (String name : sourceFields.keySet()) {
+ Object value = getPropertyValue(source, sourceFields.get(name));
+ if (value == null && !convertNullProperty) {
+ continue ;
+ } else {
+ map.put(name, value);
+ }
+ }
+ }
+ return map;
+ }
+
+ /**
+ * 将list