diff --git a/build.bat b/build.bat index a241bb4e..53b640f0 100644 --- a/build.bat +++ b/build.bat @@ -4,7 +4,7 @@ CALL mvn clean package if not exist out mkdir out del BitHeroes.jar >nul 2>&1 -echo F|xcopy target\ReRun-*-jar-with-dependencies.jar BitHeroes.jar /Y +echo F|xcopy target\BitHeroes-*-jar-with-dependencies.jar BitHeroes.jar /Y if not exist user-config.properties echo. 2>user-config.properties rem Generating mini client diff --git a/client.bat b/client.bat index af85afea..0dd18f42 100644 --- a/client.bat +++ b/client.bat @@ -1 +1,2 @@ +del mini-game-on-chrome.bat >nul 2>&1 java -jar BitHeroes.jar client diff --git a/pom.xml b/pom.xml index 46bd16e6..51b7a2aa 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ 4.0.0 bh.bot BitHeroes - 1.0.1 + 1.0.2 diff --git a/release.sh b/release.sh index 8d56072a..a05cc956 100755 --- a/release.sh +++ b/release.sh @@ -47,6 +47,9 @@ telegram.channel-id= # Tolerant tolerant.position=50 tolerant.color=0 + +# Google Chrome path, for Windows only +external.application.chrome.path=C:\\\\Program Files (x86)\\\\Google\\\\Chrome\\\\Application\\\\chrome.exe EOF # Copy files for mini client diff --git a/src/main/java/bh/bot/app/GenMiniClient.java b/src/main/java/bh/bot/app/GenMiniClient.java index ed7df1e3..662adb73 100644 --- a/src/main/java/bh/bot/app/GenMiniClient.java +++ b/src/main/java/bh/bot/app/GenMiniClient.java @@ -11,6 +11,7 @@ import static bh.bot.common.Log.err; import static bh.bot.common.Log.info; +import static bh.bot.common.utils.StringUtil.isBlank; public class GenMiniClient extends AbstractApplication { private static final File chromeUserDir = new File("chrome-user-dir"); @@ -23,8 +24,8 @@ protected void internalRun(String[] args) { String scriptFileName = String.format("mini-game-on-chrome.%s", Configuration.OS.isWin ? "bat" : "sh"); if (errMsg != null) { - err("Unable to generate %s with error:", scriptFileName); - err(" %s", errMsg); + err("ERROR: Unable to generate mini-client!!!"); + err("Error message: %s", errMsg); info("To be able to use mini game client (using Google Chrome), the following conditions must be met:"); info(" 1. Google Chrome must be installed"); info(" 2. You can play Bit Heroes game at https://www.kongregate.com/games/Juppiomenz/bit-heroes"); @@ -69,7 +70,38 @@ protected void internalRun(String[] args) { chromeArgs.add("--window-position=0,0"); chromeArgs.add(String.format("\"--app=file://%s\"", pathIndex.toAbsolutePath().toString())); } else if (Configuration.OS.isWin) { - app = "\"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe\""; + final String keyChromePath = "external.application.chrome.path"; + final String defaultChromePath = "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"; + String chromePath = Configuration.read(keyChromePath); + if (isBlank(chromePath)) { + info("Missing configuration of Google Chrome path (key %s), going to set to use default path: %s", keyChromePath, defaultChromePath); + chromePath = defaultChromePath; + } + + if (!(new File(chromePath)).exists()) { + err("ERROR: Chrome not found"); + info("Can not find Google Chrome at provided path %s", chromePath); + info("Please provide a correct path to chrome.exe into key '%s' on user-config.properties file", keyChromePath); + info("To get it, you can do this:"); + info("1. Right click on Google Chrome shortcut"); + info("2. Select Properties"); + info("3. Copy value of Target line"); + info("4. Transfrom the value to a correct format. For example:"); + info(" - Input value is:"); + info(" \"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe\""); + info(" (with the double quotes)"); + info(" - Should be translated into:"); + info(" C:\\\\Program Files (x86)\\\\Google\\\\Chrome\\\\Application\\\\chrome.exe"); + info(" (remove the double quotes and double the back slashes)"); + info("5. Fill the translated path into key '%s' of the user-config.properties file", keyChromePath); + info(" Example:"); + info("%s=C:\\\\Program Files (x86)\\\\Google\\\\Chrome\\\\Application\\\\chrome.exe", keyChromePath); + info("6. Save the file user-config.properties after modified"); + info("7. Run script '.\\client.bat' to generate mini-client"); + System.exit(1); + } + + app = String.format("\"%s\"", chromePath); chromeArgs.add(String.format("\"--user-data-dir=%s\"", chromeUserDir.getAbsolutePath())); chromeArgs.add("--window-size=820,565"); chromeArgs.add("--window-position=0,0"); diff --git a/src/main/resources/config.properties b/src/main/resources/config.properties index b268c1c4..39be7cd5 100644 --- a/src/main/resources/config.properties +++ b/src/main/resources/config.properties @@ -37,4 +37,8 @@ offset.fishing.buttons.cast-sp.x=368 offset.fishing.buttons.cast-sp.y=462 # Fishing#Catch offset.fishing.buttons.catch-sp.x=360 -offset.fishing.buttons.catch-sp.y=462 \ No newline at end of file +offset.fishing.buttons.catch-sp.y=462 + +# External +# Google Chrome path, for Windows only +external.application.chrome.path=C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe