Skip to content
This repository has been archived by the owner on Jun 22, 2021. It is now read-only.

Commit

Permalink
Merge pull request #16 from Team-Creative-Name/dev-branch
Browse files Browse the repository at this point in the history
Dev branch
  • Loading branch information
collectioncard authored Jun 26, 2020
2 parents 43928d3 + 3e593f3 commit fc4a40a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

group 'com.github.tcn.plexi'
version 'v1.0-beta.5.1'
version 'v1.0-beta.5.2'

sourceCompatibility = 1.8

Expand Down
31 changes: 17 additions & 14 deletions src/main/java/com/github/tcn/plexi/settingsManager/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class Settings {
//reference to this object - the only one
private static Settings SETTINGS_INSTANCE = null;
//the version number
private final String VERSION_NUMBER = "v1.0-beta.5.1";
private final String VERSION_NUMBER = "v1.0-beta.5.2";
//stuff loaded from the config file
private String TOKEN = null;
private String PREFIX = null;
Expand Down Expand Up @@ -154,28 +154,31 @@ private boolean validateGlobals() {

//ping the ombi API to see if we have valid settings
//if this throws an exception, we have invalid values

if (!checkObiConnectivity()) {
isValid = false;
//inform the user that we cannot connect to ombi
JOptionPane.showMessageDialog(null, "Unable to connect to Ombi - Please check your settings", "Plexi - Connectivity Issue", JOptionPane.INFORMATION_MESSAGE);
//NOTE: There is no reason to check this if isValid is false
if (isValid) {
if (!checkOmbiConnectivity()) {
isValid = false;
//inform the user that we cannot connect to ombi
JOptionPane.showMessageDialog(null, "Unable to connect to Ombi - Please check your settings", "Plexi - Connectivity Issue", JOptionPane.INFORMATION_MESSAGE);
}
}


return isValid;
}


//returns true if we are able to connect to the Ombi API
private boolean checkObiConnectivity() {
OkHttpClient client = new OkHttpClient();
private boolean checkOmbiConnectivity() {
try {
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
.url(OMBI_URL + "/api/v1/Status")
.addHeader("Accept", "application/json")
.addHeader("ApiKey", OMBI_KEY)
.build();
Request request = new Request.Builder()
.url(OMBI_URL + "/api/v1/Status")
.addHeader("Accept", "application/json")
.addHeader("ApiKey", OMBI_KEY)
.build();

try {
client.newCall(request).execute();
//if that call didnt fail, we were able to connect
return true;
Expand Down

0 comments on commit fc4a40a

Please sign in to comment.