makes translator work in clan chat as well.
This commit is contained in:
@@ -13,7 +13,7 @@ public interface ChatTranslationConfig extends Config
|
||||
name = "Show 'Translate' menu option",
|
||||
description = "Adds 'Translate' to the right-click menu in the Chatbox.",
|
||||
position = 0,
|
||||
group = "Public Chat Translation"
|
||||
group = "Chat Translation"
|
||||
)
|
||||
default boolean translateOptionVisable()
|
||||
{
|
||||
@@ -23,9 +23,9 @@ public interface ChatTranslationConfig extends Config
|
||||
@ConfigItem(
|
||||
keyName = "publicChat",
|
||||
name = "Translate incoming Messages",
|
||||
description = "Would you like to Translate Public Chat?",
|
||||
description = "Would you like to Translate Chat?",
|
||||
position = 1,
|
||||
group = "Public Chat Translation",
|
||||
group = "Chat Translation",
|
||||
hidden = true,
|
||||
unhide = "translateOptionVisable"
|
||||
)
|
||||
@@ -37,9 +37,9 @@ public interface ChatTranslationConfig extends Config
|
||||
@ConfigItem(
|
||||
keyName = "playerNames",
|
||||
name = "Translated Player list:",
|
||||
description = "Players you add to this list will be Translated in Public chat.",
|
||||
description = "Players you add to this list will be Translated in chat.",
|
||||
position = 2,
|
||||
group = "Public Chat Translation",
|
||||
group = "Chat Translation",
|
||||
hidden = true,
|
||||
unhide = "translateOptionVisable"
|
||||
)
|
||||
@@ -53,7 +53,7 @@ public interface ChatTranslationConfig extends Config
|
||||
name = "Target Language",
|
||||
description = "Language to translate messages too.",
|
||||
position = 2,
|
||||
group = "Public Chat Translation",
|
||||
group = "Chat Translation",
|
||||
hidden = true,
|
||||
unhide = "publicChat"
|
||||
)
|
||||
|
||||
@@ -180,6 +180,7 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener
|
||||
{
|
||||
case PUBLICCHAT:
|
||||
case MODCHAT:
|
||||
case FRIENDSCHAT:
|
||||
if (!config.publicChat())
|
||||
{
|
||||
return;
|
||||
@@ -237,11 +238,24 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener
|
||||
{
|
||||
if (event.getKeyCode() == 0xA)
|
||||
{
|
||||
event.consume();
|
||||
|
||||
Translator translator = new Translator();
|
||||
String message = client.getVar(VarClientStr.CHATBOX_TYPED_TEXT);
|
||||
|
||||
if (message.startsWith("/"))
|
||||
{
|
||||
try
|
||||
{
|
||||
client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, translator.translate("auto", config.playerTargetLanguage().toString(), message));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
event.consume();
|
||||
|
||||
try
|
||||
{
|
||||
//Automatically check language of message and translate to selected language.
|
||||
|
||||
Reference in New Issue
Block a user