Skip to content

Commit

Permalink
Release 1.3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Morph21 committed Dec 16, 2024
1 parent 47c968e commit 918ac8f
Show file tree
Hide file tree
Showing 30 changed files with 290 additions and 76 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mercury.platform.core;


import com.mercury.platform.LangTranslator;
import com.mercury.platform.core.misc.SoundNotifier;
import com.mercury.platform.shared.FrameVisibleState;
import com.mercury.platform.shared.HistoryManager;
Expand All @@ -12,15 +13,18 @@
import com.mercury.platform.shared.store.MercuryStoreCore;
import com.mercury.platform.shared.wh.WhisperHelperHandler;

import java.io.IOException;

public class DevStarter {

public static FrameVisibleState APP_STATUS = FrameVisibleState.HIDE;
private volatile int delay = 100;

public void startApplication() {
public void startApplication() throws IOException {
MercuryConfigManager configuration = new MercuryConfigManager(new MercuryConfigurationSource());
configuration.load();
Configuration.set(configuration);
LangTranslator.getInstance().changeLanguage(Configuration.get().applicationConfiguration().get().getLanguages());
new SoundNotifier();
new ChatHelper();
new HotKeysInterceptor();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.mercury.platform.core;

public class MercuryConstants {
public static final String APP_VERSION = "1.3.5";
public static final String APP_VERSION = "1.3.6";
public static final String SERVER_HOST = "exslims.ddns.net";
public static final int PORT = 5555;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mercury.platform.core;

import com.mercury.platform.LangTranslator;
import com.mercury.platform.core.misc.SoundNotifier;
import com.mercury.platform.shared.FrameVisibleState;
import com.mercury.platform.shared.HistoryManager;
Expand All @@ -18,6 +19,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.IOException;
import java.util.Timer;
import java.util.TimerTask;

Expand All @@ -26,10 +28,11 @@ public class ProdStarter {
public static FrameVisibleState APP_STATUS = FrameVisibleState.HIDE;
private volatile int delay = 100;

public void startApplication(boolean alwaysVisible) {
public void startApplication(boolean alwaysVisible) throws IOException {
MercuryConfigManager configuration = new MercuryConfigManager(new MercuryConfigurationSource());
configuration.load();
Configuration.set(configuration);
LangTranslator.getInstance().changeLanguage(Configuration.get().applicationConfiguration().get().getLanguages());
new SoundNotifier();
new ChatHelper();
new HotKeysInterceptor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public TradeIncMessagesInterceptor() {
protected void process(String message) {
if (this.config.get().isIncNotificationEnable()) {
LocalizationMatcher localizationMatcher = this.clients.stream()
.filter(matcher -> matcher.isSuitableFor(message))
.findAny().orElse(null);
.filter(matcher -> matcher.isSuitableFor(message))
.findAny().orElse(null);
if (localizationMatcher != null) {
localizationMatcher.processMessage(message);
}
Expand All @@ -44,21 +44,23 @@ protected void process(String message) {
protected MessageMatcher match() {
return message ->
this.clients.stream()
.filter(matcher -> matcher.isSuitableFor(message))
.findAny().orElse(null) != null;
.filter(matcher -> matcher.isSuitableFor(message))
.findAny().orElse(null) != null;
}

//@神圣怨恨初火: 你好,我想購買 Ghoul Hide, Advanced Marabout Garb 標價 1 exalted 在 Standard (倉庫頁 "4"; 位置: 左 5, 上 10)
private abstract class LocalizationMatcher {
public boolean isSuitableFor(String message) {
return message.contains("Hi, I would like") ||
message.contains("Hi, I'd like") ||
message.contains("I'd like") ||
message.contains("Hi, I'd like") ||
message.contains("I'd like") ||
message.contains("你好,我想購買") ||
message.contains("구매하고 싶습니다" /* "I would like to buy"*/) ||
message.contains("Здравствуйте, хочу купить у вас") /* "Hello, I would like to buy" */ ||
(message.contains("wtb") && message.contains("(stash")) ||
message.contains("안녕하세요, 강탈"); //pathofexile.com/trade/
message.contains("こんにちは") ||
message.contains("구매하고 싶습니다" /* "I would like to buy"*/) ||
message.contains("Здравствуйте, хочу купить у вас") /* "Hello, I would like to buy" */ ||
(message.contains("wtb") && message.contains("(stash")) ||
message.contains("안녕하세요, 강탈") ||
message.contains("안녕하세요"); //pathofexile.com/trade/
}

public abstract String trimString(String src);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mercury.platform.shared.config.descriptor;

import com.mercury.platform.Languages;
import com.mercury.platform.core.misc.WhisperNotifierStatus;
import lombok.Data;

Expand All @@ -18,4 +19,5 @@ public class ApplicationDescriptor implements Serializable {
private boolean checkOutUpdate;
private boolean hideTaskbarUntilHover;
private boolean poe2;
private Languages languages;
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ public MessageParser() {
new PoeTradeItemParser(),
new PoeTradeItemKoreanParser(),
new PoeTradeItemRussianParser(),
new PoeTradeItemParserChina()
new PoeTradeItemParserChina(),
new PoeTradeItemParserJapanese(),
new PoeTradeItemParserKorean2()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ protected NotificationDescriptor parse(Matcher matcher, String whisper) {
tradeNotification.setWhisperNickname(matcher.group(1));
tradeNotification.setSourceString(matcher.group(0));
tradeNotification.setItemName(matcher.group(2));
tradeNotification.setTabName(matcher.group(5));
tradeNotification.setLeft(Integer.parseInt(matcher.group(6)));
tradeNotification.setTop(Integer.parseInt(matcher.group(7)));
if (matcher.group(3) != null) {
String[] split = matcher.group(3).split(" ");
tradeNotification.setCurCount(Double.parseDouble(split[0]));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.mercury.platform.shared.messageparser;

import com.mercury.platform.shared.entity.message.ItemTradeNotificationDescriptor;
import com.mercury.platform.shared.entity.message.NotificationDescriptor;
import com.mercury.platform.shared.entity.message.NotificationType;

import java.util.regex.Matcher;

class PoeTradeItemParserJapanese extends BaseRegexParser {

// Tested for message ナーフ神ジョナサン: こんにちは、Standard リーグで 3 exalted で売っている、あなたの Havoc Band, Emerald Ring を購入したいです (スタッシュタブ "~b/o 3 exalted"; 位置: 左から 6, 上から 7)
// coming from https://www.pathofexile.com/trade2/search/poe2/Standard 12.12.2024
private static final String poeTradePattern = "^(.+): こんにちは、(.+) リーグで (.+) (.+) で売っている、あなたの (.+) を購入したいです \\(スタッシュタブ \"(.+)\"; 位置: 左から (\\d+), 上から (\\d+)\\)$";

public PoeTradeItemParserJapanese() {
super(poeTradePattern);
}

@Override
protected NotificationDescriptor parse(Matcher matcher, String whisper) {
ItemTradeNotificationDescriptor tradeNotification = new ItemTradeNotificationDescriptor();
tradeNotification.setWhisperNickname(matcher.group(1));
tradeNotification.setSourceString(matcher.group(0));
tradeNotification.setItemName(matcher.group(5));
tradeNotification.setLeft(Integer.parseInt(matcher.group(7)));
tradeNotification.setTop(Integer.parseInt(matcher.group(8)));
tradeNotification.setTabName(matcher.group(6));

if (matcher.group(3) != null) {
tradeNotification.setCurCount(Double.parseDouble(matcher.group(3)));
tradeNotification.setCurrency(matcher.group(4));
} else {
tradeNotification.setCurCount(0d);
tradeNotification.setCurrency("???");
}
tradeNotification.setLeague(matcher.group(2));
tradeNotification.setType(NotificationType.INC_ITEM_MESSAGE);
return tradeNotification;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.mercury.platform.shared.messageparser;

import com.mercury.platform.shared.entity.message.ItemTradeNotificationDescriptor;
import com.mercury.platform.shared.entity.message.NotificationDescriptor;
import com.mercury.platform.shared.entity.message.NotificationType;

import java.util.regex.Matcher;

class PoeTradeItemParserKorean2 extends BaseRegexParser {

// Tested for message 술쟁이: 안녕하세요, 5 exalted(으)로 올려놓은 Standard 리그의 Morbid Grasp, Emerald Ring(을)를 구매하고 싶습니다 (보관함 탭 "~price 5 exalted", 위치: 왼쪽 11, 상단 3)
// coming from https://www.pathofexile.com/trade2/search/poe2/Standard 12.12.2024
private static final String poeTradePattern = "^(.+): 안녕하세요, (.+) (.+)\\(으\\)로 올려놓은 (.+) 리그의 (.+)\\(을\\)를 구매하고 싶습니다 \\(보관함 탭 \"(.*)\", 위치: 왼쪽 (\\d+), 상단 (\\d+)\\)$";

public PoeTradeItemParserKorean2() {
super(poeTradePattern);
}

@Override
protected NotificationDescriptor parse(Matcher matcher, String whisper) {
ItemTradeNotificationDescriptor tradeNotification = new ItemTradeNotificationDescriptor();
tradeNotification.setWhisperNickname(matcher.group(1));
tradeNotification.setSourceString(matcher.group(0));
tradeNotification.setItemName(matcher.group(5));
tradeNotification.setLeft(Integer.parseInt(matcher.group(7)));
tradeNotification.setTop(Integer.parseInt(matcher.group(8)));
tradeNotification.setTabName(matcher.group(2));
if (matcher.group(5) != null) {
tradeNotification.setCurCount(Double.parseDouble(matcher.group(2)));
tradeNotification.setCurrency(matcher.group(3));
} else {
tradeNotification.setCurCount(0d);
tradeNotification.setCurrency("???");
}
tradeNotification.setLeague(matcher.group(4));
tradeNotification.setType(NotificationType.INC_ITEM_MESSAGE);
return tradeNotification;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,17 @@ public static LangTranslator getInstance() {
}

private Map<String, String> intializeTranslations(Languages lang) throws IOException {
System.out.println("intializating translation for " + lang.toString());
if (lang == null) {
lang = Languages.en;
}
System.out.println("intializating translation for " + lang.shortName());
Map<String, String> translations = new HashMap<>();
try {
InputStream is = this.getClass().getResourceAsStream("/lang/" + lang.toString() + ".lang");
InputStream is = this.getClass().getResourceAsStream("/lang/" + lang.shortName() + ".lang");

if (is == null) {
System.out.println("first resource not exists");
is = this.getClass().getResourceAsStream("/" + lang.toString() + ".lang");
is = this.getClass().getResourceAsStream("/" + lang.shortName() + ".lang");
if (is == null) {
System.out.println("second resource not exists");
return translations;
Expand Down
26 changes: 17 additions & 9 deletions app-shared/src/main/java/com/mercury/platform/Languages.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
package com.mercury.platform;

public enum Languages {
en("english"),
pl("polish"),
ru("russian"),
en(TranslationKey.english, "en"),
pl(TranslationKey.polish, "pl"),
ru(TranslationKey.russian, "ru"),
;

private String name;
private TranslationKey name;
private String shortName;

Languages(String name) {
Languages(TranslationKey name, String shortName) {
this.name = name;
this.shortName = shortName;
}

public static boolean isCJK() {
return false;
public TranslationKey getName() {
return name;
}

public String getName() {
return name;
public String shortName() {
return shortName;
}


@Override
public String toString() {
return name.value();
}
}
12 changes: 12 additions & 0 deletions app-shared/src/main/java/com/mercury/platform/TranslationKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,18 @@ public enum TranslationKey {
import_to_current_profile("Import to current profile"),
create_new_and_import("Create new and import"),
import_manager("Import manager"),
feedback_suggestions("Feedback & Suggestions"),
not_case_sensitive("not case sensitive"),
vulkan_support("vulkan support"),
restore_default_location("Restore default location"),
align_this_grid("Align this grid"),
paste_here("Paste import string here"),
copy_this("Copy this"),
english("english"),
polish("polish"),
russian("russian"),
choose_language("Choose language"),
language_change_requires_application_restart("Language change requires application restart."),
;

private String defaultValue;
Expand Down
16 changes: 14 additions & 2 deletions app-shared/src/main/resources/lang/en.lang
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,23 @@ previous = Previous
download = Download
welcome = Welcome to MercuryTrade
restart = Restart
new = New
new_btn = New
group = Group
showcase = Showcase
do_you_want_to_delete_this_profile = Do you want to delete this profile?
always_refresh = Always refresh?
import_to_current_profile = Import to current profile
create_new_and_import = Create new and import
import_manager = Import manager
import_manager = Import manager
feedback_suggestions = Feedback & Suggestions
not_case_sensitive = not case sensitive
vulkan_support = Vulkan support
restore_default_location = Restore default location
align_this_grid = Align this grid
paste_here = Paste import string here
copy_this = Copy this
english = english
russian = russian
polish = polish
choose_language = Choose language
language_change_requires_application_restart = Language change requires application restart.
30 changes: 27 additions & 3 deletions app-shared/src/main/resources/lang/pl.lang
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ example_description = Przykład: kliknij przycisk „Szept”, wiadomość zosta
// Close panel on kick button pressed
close_panel_on_kick_button_pressed = Zamknij panel po naciśnięciu przycisku „Wyrzuć”
// Show league
show_league = Pokaż ligę
show_league = Pokaż nazwę ligi
// Response buttons
response_buttons = Przycisk odpowiedzi
// Hotkeys
Expand Down Expand Up @@ -429,7 +429,7 @@ welcome = Witaj w MercuryTrade
// Restart
restart = Zrestartuj
// New
new = Nowy
new_btn = Nowy
// Group
group = Grupa
// Showcase
Expand All @@ -443,4 +443,28 @@ import_to_current_profile = Zaimportuj do aktualnego profilu
// Create new and import
create_new_and_import = Utwórz nowy i zaimportuj
// Import manager
import_manager = Menadżer importu
import_manager = Menadżer importu
// Feedback & Suggestions
feedback_suggestions = Błędy i sugestie
// not case sensitive
not_case_sensitive = wielkość znaków nie ma znaczenia
// vulkan support
vulkan_support = wsparcie dla Vulkan
// Restore default location
restore_default_location = Przywróć domyślne położenie elementów
// Align this grid
align_this_grid = Dopasuj siatkę
// Paste import string here
paste_here = Wklej zaimportowany tekst tutaj
// Copy this
copy_this = Skopiuj ten tekst
// english
english = angielski
// russian
russian = rosyjski
// polish
polish = polski
// Choose language
choose_language = Wybierz język
// Language change requires application restart.
language_change_requires_application_restart = Zmiana języka wymaga restartu aplikacji.
Loading

0 comments on commit 918ac8f

Please sign in to comment.