diff --git a/app-core/pom.xml b/app-core/pom.xml
index 5badaeee..3f0837c1 100644
--- a/app-core/pom.xml
+++ b/app-core/pom.xml
@@ -17,12 +17,12 @@
com.home.mercury
app-shared
- 1.0.0
-
-
- lc.kra.system
- system-hook
+ 1.0.0.1
+
+
+
+
com.sun.jna
jna
diff --git a/app-core/src/main/java/com/mercury/platform/core/ChatHelper.java b/app-core/src/main/java/com/mercury/platform/core/ChatHelper.java
index 095287be..a38c95ee 100644
--- a/app-core/src/main/java/com/mercury/platform/core/ChatHelper.java
+++ b/app-core/src/main/java/com/mercury/platform/core/ChatHelper.java
@@ -1,8 +1,10 @@
package com.mercury.platform.core;
+import com.mercury.platform.shared.ConfigManager;
import com.mercury.platform.shared.HasEventHandlers;
import com.mercury.platform.shared.events.EventRouter;
import com.mercury.platform.shared.events.custom.ChatCommandEvent;
+import com.mercury.platform.shared.events.custom.DndModeEvent;
import com.mercury.platform.shared.events.custom.OpenChatEvent;
import com.sun.jna.Native;
import org.apache.logging.log4j.LogManager;
@@ -30,65 +32,61 @@ public ChatHelper() {
}
private void executeMessage(String message) {
- new Thread(() -> {
- StringSelection selection = new StringSelection(message);
- Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
- clipboard.setContents(selection, null);
-
- gameToFront();
-
- robot.keyPress(KeyEvent.VK_ENTER);
- robot.keyRelease(KeyEvent.VK_ENTER);
-
- robot.keyPress(KeyEvent.VK_CONTROL);
- robot.keyPress(KeyEvent.VK_A);
- robot.keyRelease(KeyEvent.VK_CONTROL);
- robot.keyRelease(KeyEvent.VK_A);
-
- robot.keyPress(KeyEvent.VK_BACK_SPACE);
- robot.keyRelease(KeyEvent.VK_BACK_SPACE);
-
- robot.keyPress(KeyEvent.VK_CONTROL);
- robot.keyPress(KeyEvent.VK_V);
- robot.keyRelease(KeyEvent.VK_V);
- robot.keyRelease(KeyEvent.VK_CONTROL);
- robot.keyPress(KeyEvent.VK_ENTER);
- robot.keyRelease(KeyEvent.VK_ENTER);
- }).start();
+ StringSelection selection = new StringSelection(message);
+ Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
+ clipboard.setContents(selection, null);
+
+ gameToFront();
+
+ robot.keyPress(KeyEvent.VK_ENTER);
+ robot.keyRelease(KeyEvent.VK_ENTER);
+
+ robot.keyPress(KeyEvent.VK_CONTROL);
+ robot.keyPress(KeyEvent.VK_A);
+ robot.keyRelease(KeyEvent.VK_CONTROL);
+ robot.keyRelease(KeyEvent.VK_A);
+
+ robot.keyPress(KeyEvent.VK_BACK_SPACE);
+ robot.keyRelease(KeyEvent.VK_BACK_SPACE);
+
+ robot.keyPress(KeyEvent.VK_CONTROL);
+ robot.keyPress(KeyEvent.VK_V);
+ robot.keyRelease(KeyEvent.VK_V);
+ robot.keyRelease(KeyEvent.VK_CONTROL);
+ robot.keyPress(KeyEvent.VK_ENTER);
+ robot.keyRelease(KeyEvent.VK_ENTER);
}
- private void openChat(String whisper){
- new Thread(() -> {
- gameToFront();
-
- StringSelection selection = new StringSelection("@" + whisper);
- Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
- clipboard.setContents(selection, selection);
-
- robot.keyPress(KeyEvent.VK_ENTER);
- robot.keyRelease(KeyEvent.VK_ENTER);
-
- robot.keyPress(KeyEvent.VK_CONTROL);
- robot.keyPress(KeyEvent.VK_A);
- robot.keyRelease(KeyEvent.VK_CONTROL);
- robot.keyRelease(KeyEvent.VK_A);
-
- robot.keyPress(KeyEvent.VK_BACK_SPACE);
- robot.keyRelease(KeyEvent.VK_BACK_SPACE);
-
- robot.keyPress(KeyEvent.VK_CONTROL);
- robot.keyPress(KeyEvent.VK_V);
- robot.keyRelease(KeyEvent.VK_V);
- robot.keyRelease(KeyEvent.VK_CONTROL);
- robot.keyPress(KeyEvent.VK_SPACE);
- robot.keyRelease(KeyEvent.VK_SPACE);
- }).start();
+ private void openChat(String whisper) {
+ gameToFront();
+
+ StringSelection selection = new StringSelection("@" + whisper);
+ Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
+ clipboard.setContents(selection, selection);
+
+ robot.keyPress(KeyEvent.VK_ENTER);
+ robot.keyRelease(KeyEvent.VK_ENTER);
+
+ robot.keyPress(KeyEvent.VK_CONTROL);
+ robot.keyPress(KeyEvent.VK_A);
+ robot.keyRelease(KeyEvent.VK_CONTROL);
+ robot.keyRelease(KeyEvent.VK_A);
+
+ robot.keyPress(KeyEvent.VK_BACK_SPACE);
+ robot.keyRelease(KeyEvent.VK_BACK_SPACE);
+
+ robot.keyPress(KeyEvent.VK_CONTROL);
+ robot.keyPress(KeyEvent.VK_V);
+ robot.keyRelease(KeyEvent.VK_V);
+ robot.keyRelease(KeyEvent.VK_CONTROL);
+ robot.keyPress(KeyEvent.VK_SPACE);
+ robot.keyRelease(KeyEvent.VK_SPACE);
}
-
+ /**
+ * NEED REFACTORING
+ */
private void gameToFront(){
List titles = new ArrayList<>();
titles.add("Path of Exile");
- titles.add("PathOfExile");
- titles.add("PathOfExile_64");
user32.EnumWindows((hWnd, arg1) -> {
byte[] windowText = new byte[512];
user32.GetWindowTextA(hWnd, windowText, 512);
@@ -113,5 +111,15 @@ public void initHandlers() {
EventRouter.INSTANCE.registerHandler(OpenChatEvent.class, event -> {
openChat(((OpenChatEvent) event).getWhisper());
});
+ EventRouter.INSTANCE.registerHandler(DndModeEvent.class, event -> {
+ boolean dnd = ((DndModeEvent) event).isDnd();
+ if(ConfigManager.INSTANCE.isInGameDnd()){
+ if(dnd) {
+ executeMessage("/dnd " + ConfigManager.INSTANCE.getDndResponseText());
+ }else {
+ executeMessage("/dnd");
+ }
+ }
+ });
}
}
diff --git a/app-core/src/main/java/com/mercury/platform/core/MercuryConstants.java b/app-core/src/main/java/com/mercury/platform/core/MercuryConstants.java
index dc06d865..6723205b 100644
--- a/app-core/src/main/java/com/mercury/platform/core/MercuryConstants.java
+++ b/app-core/src/main/java/com/mercury/platform/core/MercuryConstants.java
@@ -4,7 +4,7 @@
* Created by Константин on 29.01.2017.
*/
public class MercuryConstants {
- public static final String APP_VERSION = "1.0.0.3";
+ public static final String APP_VERSION = "1.0.0.4";
public static final String SERVER_HOST = "exslims.ddns.net";
public static final int PORT = 5555;
}
diff --git a/app-core/src/main/java/com/mercury/platform/shared/ConfigManager.java b/app-core/src/main/java/com/mercury/platform/shared/ConfigManager.java
index 51df97ca..7ebc1ed5 100644
--- a/app-core/src/main/java/com/mercury/platform/shared/ConfigManager.java
+++ b/app-core/src/main/java/com/mercury/platform/shared/ConfigManager.java
@@ -52,6 +52,8 @@ private static class ConfigManagerHolder {
private boolean itemsGridEnable = true;
private boolean checkUpdateOnStartUp = true;
private boolean dismissAfterKick = false;
+ private boolean inGameDnd = false;
+ private String dndResponseText = "Response text";
public ConfigManager() {
minimumFrameSize = new HashMap<>();
@@ -59,7 +61,7 @@ public ConfigManager() {
minimumFrameSize.put("IncMessageFrame",new Dimension(315,10));
minimumFrameSize.put("OutMessageFrame",new Dimension(280,115));
minimumFrameSize.put("TestCasesFrame",new Dimension(400,100));
- minimumFrameSize.put("SettingsFrame",new Dimension(540,100));
+ minimumFrameSize.put("SettingsFrame",new Dimension(540,400));
minimumFrameSize.put("HistoryFrame",new Dimension(280,400));
minimumFrameSize.put("TimerFrame",new Dimension(240,102));
minimumFrameSize.put("ChatScannerFrame",new Dimension(200,100));
@@ -85,6 +87,8 @@ public ConfigManager() {
defaultAppSettings.put("itemsGridEnable",true);
defaultAppSettings.put("checkUpdateOnStartUp",true);
defaultAppSettings.put("dismissAfterKick",false);
+ defaultAppSettings.put("inGameDnd",false);
+ defaultAppSettings.put("dndResponseText","Response text");
}
@@ -126,6 +130,8 @@ public void load() {
saveProperty("itemsGridEnable", String.valueOf(defaultAppSettings.get("itemsGridEnable")));
saveProperty("checkUpdateOnStartUp", String.valueOf(defaultAppSettings.get("checkUpdateOnStartUp")));
saveProperty("dismissAfterKick", String.valueOf(defaultAppSettings.get("dismissAfterKick")));
+ saveProperty("inGameDnd", String.valueOf(defaultAppSettings.get("inGameDnd")));
+ saveProperty("dndResponseText", defaultAppSettings.get("dndResponseText"));
} catch (Exception e) {
logger.error(e);
@@ -181,6 +187,8 @@ private void loadConfigFile(){
itemsGridEnable = Boolean.valueOf(loadProperty("itemsGridEnable"));
checkUpdateOnStartUp = Boolean.valueOf(loadProperty("checkUpdateOnStartUp"));
dismissAfterKick = Boolean.valueOf(loadProperty("dismissAfterKick"));
+ inGameDnd = Boolean.valueOf(loadProperty("inGameDnd"));
+ dndResponseText = loadProperty("dndResponseText");
} catch (Exception e) {
logger.error("Error in loadConfigFile: ",e);
}
@@ -390,6 +398,25 @@ public void setItemsGridEnable(boolean itemsGridEnable) {
this.itemsGridEnable = itemsGridEnable;
saveProperty("itemsGridEnable",String.valueOf(this.itemsGridEnable));
}
+
+ public boolean isInGameDnd() {
+ return inGameDnd;
+ }
+
+ public void setInGameDnd(boolean inGameDnd) {
+ this.inGameDnd = inGameDnd;
+ saveProperty("inGameDnd",String.valueOf(this.inGameDnd));
+ }
+
+ public String getDndResponseText() {
+ return dndResponseText;
+ }
+
+ public void setDndResponseText(String dndResponseText) {
+ this.dndResponseText = dndResponseText;
+ saveProperty("dndResponseText",dndResponseText);
+ }
+
private List getDefaultButtons(){
List defaultButtons = new ArrayList<>();
defaultButtons.add(new ResponseButton(0,"1m","one minute",false,false));
@@ -404,7 +431,7 @@ public Map getDefaultFramesSettings(){
defaultFramesSettings.put("IncMessageFrame",new FrameSettings(new Point(700, 600),new Dimension(315,0)));
defaultFramesSettings.put("OutMessageFrame",new FrameSettings(new Point(200, 500),new Dimension(280,115)));
defaultFramesSettings.put("TestCasesFrame",new FrameSettings(new Point(1400, 500),new Dimension(400,100)));
- defaultFramesSettings.put("SettingsFrame",new FrameSettings(new Point(600, 600),new Dimension(540,100)));
+ defaultFramesSettings.put("SettingsFrame",new FrameSettings(new Point(600, 600),new Dimension(540,500)));
defaultFramesSettings.put("HistoryFrame",new FrameSettings(new Point(600, 500),new Dimension(280,400)));
defaultFramesSettings.put("TimerFrame",new FrameSettings(new Point(400, 600),new Dimension(240,102)));
defaultFramesSettings.put("ChatScannerFrame",new FrameSettings(new Point(400, 600),new Dimension(500,250)));
diff --git a/app-shared/pom.xml b/app-shared/pom.xml
index 92405666..82d407e4 100644
--- a/app-shared/pom.xml
+++ b/app-shared/pom.xml
@@ -4,13 +4,9 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
-
- com.home.mercury
- MercuryTrade
- ${project.version}
-
-
+ com.home.mercury
app-shared
+ 1.0.0.4
jar
diff --git a/app-socket-server/pom.xml b/app-socket-server/pom.xml
deleted file mode 100644
index 6f2121b2..00000000
--- a/app-socket-server/pom.xml
+++ /dev/null
@@ -1,113 +0,0 @@
-
-
- 4.0.0
-
-
-
- maven-assembly-plugin
-
-
-
- com.mercury.platform.server.main.ServerMain
-
-
-
- jar-with-dependencies
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
-
-
- 1.8
-
-
-
-
-
-
- com.home.mercury
- MercuryTrade
- ${project.version}
-
-
- jar
- app-socket-server
-
-
- 2.5
- 2.7
- 3.0
- 4.12
- 1.9.5
- 4.1.3.Final
- 3.2.0
- 21.0
-
-
-
-
- com.home.mercury
- app-shared
- 1.0.0
-
-
- commons-io
- commons-io
- ${commons-io.version}
-
-
-
- io.netty
- netty-all
- ${netty.version}
-
-
-
- com.lmax
- disruptor
- ${disruptor.version}
-
-
-
- com.google.guava
- guava
- ${guava.version}
-
-
-
- org.apache.commons
- commons-lang3
- ${commons-lang3.version}
-
-
-
- org.apache.logging.log4j
- log4j-api
- ${log4j.version}
-
-
-
- org.apache.logging.log4j
- log4j-core
- ${log4j.version}
-
-
-
- junit
- junit
- test
- ${junit.version}
-
-
-
- org.mockito
- mockito-all
- ${mockito.version}
-
-
-
\ No newline at end of file
diff --git a/app-socket-server/src/main/java/com/mercury/platform/client/ClientMain.java b/app-socket-server/src/main/java/com/mercury/platform/client/ClientMain.java
deleted file mode 100644
index b553933d..00000000
--- a/app-socket-server/src/main/java/com/mercury/platform/client/ClientMain.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package com.mercury.platform.client;
-
-import com.mercury.platform.client.bus.event.UpdateReceivedEvent;
-import com.mercury.platform.client.bus.handlers.UpdateEventHandler;
-import com.mercury.platform.client.core.UpdaterClient;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.nio.file.StandardOpenOption;
-
-/**
- * Created by Frost on 14.01.2017.
- */
-public class ClientMain {
- private static final Logger LOGGER = LogManager.getLogger(ClientMain.class);
-
- public static void main(String[] args) throws Exception {
- String host = "localhost";
- String mercuryVersion = "1.0";
- int port = 10000;
- UpdaterClient updaterClient = new UpdaterClient(host, mercuryVersion, port);
- updaterClient.registerListener(handler -> LOGGER.info("update received, size = {} bytes" , handler.getBytes().length));
- updaterClient.registerListener(new UpdateEventHandler() {
- @Override
- public void onUpdateReceived(UpdateReceivedEvent handler) throws IOException {
-
- Files.write(Paths.get("test-mercury.jar") , handler.getBytes() , StandardOpenOption.CREATE);
- }
- });
- updaterClient.start();
- }
-}
diff --git a/app-socket-server/src/main/java/com/mercury/platform/client/bus/UpdaterClientEventBus.java b/app-socket-server/src/main/java/com/mercury/platform/client/bus/UpdaterClientEventBus.java
deleted file mode 100644
index c1955eb8..00000000
--- a/app-socket-server/src/main/java/com/mercury/platform/client/bus/UpdaterClientEventBus.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.mercury.platform.client.bus;
-
-import com.google.common.eventbus.EventBus;
-
-/**
- * Created by Frost on 25.01.2017.
- */
-public class UpdaterClientEventBus extends EventBus{
-
- private static final UpdaterClientEventBus instance = new UpdaterClientEventBus();
-
- public static UpdaterClientEventBus getInstance() {
- return instance;
- }
-
- private EventBus eventBus;
-
- private UpdaterClientEventBus() {
- this.eventBus = new EventBus();
- }
-
- @Override
- public void register(Object object) {
- eventBus.register(object);
- }
-
- @Override
- public void unregister(Object object) {
- eventBus.unregister(object);
- }
-
- @Override
- public void post(Object event) {
- eventBus.post(event);
- }
-
-}
diff --git a/app-socket-server/src/main/java/com/mercury/platform/client/bus/event/UpdateReceivedEvent.java b/app-socket-server/src/main/java/com/mercury/platform/client/bus/event/UpdateReceivedEvent.java
deleted file mode 100644
index 83b62c76..00000000
--- a/app-socket-server/src/main/java/com/mercury/platform/client/bus/event/UpdateReceivedEvent.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.mercury.platform.client.bus.event;
-
-/**
- * Created by Frost on 25.01.2017.
- */
-public class UpdateReceivedEvent {
-
- private byte[] bytes;
-
-
- public UpdateReceivedEvent(byte [] bytes) {
- this.bytes = bytes;
- }
-
- public byte[] getBytes() {
- return bytes;
- }
-}
diff --git a/app-socket-server/src/main/java/com/mercury/platform/client/bus/handlers/UpdateEventHandler.java b/app-socket-server/src/main/java/com/mercury/platform/client/bus/handlers/UpdateEventHandler.java
deleted file mode 100644
index f3b381df..00000000
--- a/app-socket-server/src/main/java/com/mercury/platform/client/bus/handlers/UpdateEventHandler.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.mercury.platform.client.bus.handlers;
-
-import com.google.common.eventbus.Subscribe;
-import com.mercury.platform.client.bus.event.UpdateReceivedEvent;
-
-import java.io.IOException;
-
-/**
- * Created by Frost on 25.01.2017.
- */
-public interface UpdateEventHandler {
- @Subscribe void onUpdateReceived(UpdateReceivedEvent jarFile) throws IOException;
-}
diff --git a/app-socket-server/src/main/java/com/mercury/platform/client/converter/JarFactory.java b/app-socket-server/src/main/java/com/mercury/platform/client/converter/JarFactory.java
deleted file mode 100644
index cd89e827..00000000
--- a/app-socket-server/src/main/java/com/mercury/platform/client/converter/JarFactory.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package com.mercury.platform.client.converter;
-
-/**
- * Created by Frost on 25.01.2017.
- */
-public class JarFactory {
-
-}
diff --git a/app-socket-server/src/main/java/com/mercury/platform/client/core/UpdaterClient.java b/app-socket-server/src/main/java/com/mercury/platform/client/core/UpdaterClient.java
deleted file mode 100644
index 9dacfc4f..00000000
--- a/app-socket-server/src/main/java/com/mercury/platform/client/core/UpdaterClient.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package com.mercury.platform.client.core;
-
-import com.mercury.platform.client.bus.UpdaterClientEventBus;
-import com.mercury.platform.client.bus.handlers.UpdateEventHandler;
-import com.mercury.platform.client.holder.VersionHolder;
-import com.mercury.platform.client.init.ClientChannelInitializer;
-import io.netty.bootstrap.Bootstrap;
-import io.netty.channel.ChannelFuture;
-import io.netty.channel.EventLoopGroup;
-import io.netty.channel.nio.NioEventLoopGroup;
-import io.netty.channel.socket.nio.NioSocketChannel;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
-import java.net.InetSocketAddress;
-
-/**
- * Created by Frost on 14.01.2017.
- */
-public class UpdaterClient {
-
- private static final Logger LOGGER = LogManager.getLogger(UpdaterClient.class);
-
- private final String host;
- private final int port;
- private volatile boolean stopped;
-
- public UpdaterClient(String host, String mercuryVersion, int port) {
- this.host = host;
- this.port = port;
- String version = mercuryVersion.replace(".", "0");
- VersionHolder.getInstance().setVersion(Integer.valueOf(version));
- }
-
- public void start() throws InterruptedException {
- this.stopped = false;
- while (!stopped) {
- EventLoopGroup group = null;
- try {
- group = new NioEventLoopGroup();
- LOGGER.info("Starting updater client");
- Bootstrap bootstrap = new Bootstrap();
- bootstrap.group(group).channel(NioSocketChannel.class)
- .remoteAddress(new InetSocketAddress(host, port))
- .handler(new ClientChannelInitializer());
- LOGGER.info("Updater client was started");
- ChannelFuture channelFuture = bootstrap.connect().sync();
- channelFuture.channel().closeFuture().sync();
- } catch (Exception e) {
- LOGGER.error(e.getMessage());
- } finally {
- if (group != null)
- group.shutdownGracefully().sync();
- }
- Thread.sleep(5000); //TIMEOUT 5 sec
- }
- }
- public void shutdown() {
- this.stopped = true;
- }
- public int getMercuryVersion() {
- return VersionHolder.getInstance().getVersion();
- }
-
- public void registerListener(UpdateEventHandler handler) {
- UpdaterClientEventBus.getInstance().register(handler);
- }
-
- public void removeListener(UpdateEventHandler handler) {
- UpdaterClientEventBus.getInstance().unregister(handler);
- }
-}
diff --git a/app-socket-server/src/main/java/com/mercury/platform/client/handlers/ClientHandler.java b/app-socket-server/src/main/java/com/mercury/platform/client/handlers/ClientHandler.java
deleted file mode 100644
index 0aba036b..00000000
--- a/app-socket-server/src/main/java/com/mercury/platform/client/handlers/ClientHandler.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package com.mercury.platform.client.handlers;
-
-import com.google.common.primitives.Bytes;
-import com.mercury.platform.client.bus.UpdaterClientEventBus;
-import com.mercury.platform.client.bus.event.UpdateReceivedEvent;
-import com.mercury.platform.client.holder.VersionHolder;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.SimpleChannelInboundHandler;
-import org.apache.commons.lang3.ArrayUtils;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Created by Frost on 14.01.2017.
- */
-public class ClientHandler extends SimpleChannelInboundHandler