Clean-up for Travis.
This commit is contained in:
committed by
Ian W. ONeill
parent
3c0e1bef47
commit
608471f30d
@@ -15,7 +15,10 @@ public interface ChatTranslationConfig extends Config
|
|||||||
position = 0,
|
position = 0,
|
||||||
group = "Public Chat Translation"
|
group = "Public Chat Translation"
|
||||||
)
|
)
|
||||||
default boolean publicChat() { return false; }
|
default boolean publicChat()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
keyName = "publicTargetLanguage",
|
keyName = "publicTargetLanguage",
|
||||||
@@ -38,7 +41,10 @@ public interface ChatTranslationConfig extends Config
|
|||||||
position = 2,
|
position = 2,
|
||||||
group = "Player Message Translation"
|
group = "Player Message Translation"
|
||||||
)
|
)
|
||||||
default boolean playerChat() { return false; }
|
default boolean playerChat()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
keyName = "playerTargetLanguage",
|
keyName = "playerTargetLanguage",
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import net.runelite.client.plugins.PluginDescriptor;
|
|||||||
import net.runelite.client.plugins.PluginType;
|
import net.runelite.client.plugins.PluginType;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Provider;
|
import javax.inject.Provider;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
@@ -32,7 +31,8 @@ import java.awt.event.KeyEvent;
|
|||||||
tags = {"translate", "language", "english", "spanish", "dutch", "french"},
|
tags = {"translate", "language", "english", "spanish", "dutch", "french"},
|
||||||
type = PluginType.UTILITY
|
type = PluginType.UTILITY
|
||||||
)
|
)
|
||||||
public class ChatTranslationPlugin extends Plugin implements KeyListener {
|
public class ChatTranslationPlugin extends Plugin implements KeyListener
|
||||||
|
{
|
||||||
|
|
||||||
public static final String TRANSLATE = "Translate";
|
public static final String TRANSLATE = "Translate";
|
||||||
private static final ImmutableList<String> AFTER_OPTIONS = ImmutableList.of("Message", "Add ignore", "Remove friend", "Kick");
|
private static final ImmutableList<String> AFTER_OPTIONS = ImmutableList.of("Message", "Add ignore", "Remove friend", "Kick");
|
||||||
@@ -144,7 +144,8 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener {
|
|||||||
|
|
||||||
Translator translator = new Translator();
|
Translator translator = new Translator();
|
||||||
|
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
//Automatically check language of message and translate to selected language.
|
//Automatically check language of message and translate to selected language.
|
||||||
String translation = translator.translate("auto", config.publicTargetLanguage().toString(), message);
|
String translation = translator.translate("auto", config.publicTargetLanguage().toString(), message);
|
||||||
if (translation != null)
|
if (translation != null)
|
||||||
@@ -153,7 +154,9 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener {
|
|||||||
messageNode.setRuneLiteFormatMessage(translation);
|
messageNode.setRuneLiteFormatMessage(translation);
|
||||||
chatMessageManager.update(messageNode);
|
chatMessageManager.update(messageNode);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,8 +164,10 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void keyPressed(KeyEvent event) {
|
public void keyPressed(KeyEvent event)
|
||||||
if (client.getGameState() != GameState.LOADING && client.getGameState() != GameState.LOGGED_IN) {
|
{
|
||||||
|
if (client.getGameState() != GameState.LOADING && client.getGameState() != GameState.LOGGED_IN)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,7 +188,8 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener {
|
|||||||
|
|
||||||
String message = client.getVar(VarClientStr.CHATBOX_TYPED_TEXT);
|
String message = client.getVar(VarClientStr.CHATBOX_TYPED_TEXT);
|
||||||
|
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
//Automatically check language of message and translate to selected language.
|
//Automatically check language of message and translate to selected language.
|
||||||
String translation = translator.translate("auto", config.playerTargetLanguage().toString(), message);
|
String translation = translator.translate("auto", config.playerTargetLanguage().toString(), message);
|
||||||
|
|
||||||
@@ -191,18 +197,24 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener {
|
|||||||
{
|
{
|
||||||
client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, translation);
|
client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, translation);
|
||||||
|
|
||||||
clientThread.invoke(() -> {
|
clientThread.invoke(() ->
|
||||||
|
{
|
||||||
client.runScript(96, 0, translation);
|
client.runScript(96, 0, translation);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, "");
|
client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, "");
|
||||||
} catch (Exception e) {
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package net.runelite.client.plugins.chattranslation;
|
package net.runelite.client.plugins.chattranslation;
|
||||||
|
|
||||||
public enum Languages {
|
public enum Languages
|
||||||
|
{
|
||||||
|
|
||||||
ENGLISH("en"),
|
ENGLISH("en"),
|
||||||
DUTCH("nl"),
|
DUTCH("nl"),
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ import java.net.HttpURLConnection;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
|
|
||||||
public class Translator {
|
public class Translator
|
||||||
|
{
|
||||||
|
|
||||||
public String translate(String source, String target, String message) throws Exception
|
public String translate(String source, String target, String message) throws Exception
|
||||||
{
|
{
|
||||||
@@ -23,7 +24,8 @@ public class Translator {
|
|||||||
String inputLine;
|
String inputLine;
|
||||||
StringBuffer response = new StringBuffer();
|
StringBuffer response = new StringBuffer();
|
||||||
|
|
||||||
while ((inputLine = in.readLine()) != null) {
|
while ((inputLine = in.readLine()) != null)
|
||||||
|
{
|
||||||
response.append(inputLine);
|
response.append(inputLine);
|
||||||
}
|
}
|
||||||
in.close();
|
in.close();
|
||||||
|
|||||||
Reference in New Issue
Block a user