diff --git a/Auto-Tune/dependency-reduced-pom.xml b/Auto-Tune/dependency-reduced-pom.xml
index f94f277..c2f670b 100644
--- a/Auto-Tune/dependency-reduced-pom.xml
+++ b/Auto-Tune/dependency-reduced-pom.xml
@@ -4,7 +4,7 @@
unprotesting.com.github
Auto-Tune
Auto-Tune
- 0.8.4
+ 0.8.5
The automatic pricing plugin for minecraft
https://github.com/Unprotesting/Auto-Tune
@@ -46,7 +46,7 @@
maven-shade-plugin
- 2.3
+ 3.2.4
package
@@ -96,42 +96,17 @@
spigot-api
1.16.2-R0.1-SNAPSHOT
provided
-
-
- commons-lang
- commons-lang
-
-
- gson
- com.google.code.gson
-
-
- bungeecord-chat
- net.md-5
-
-
- snakeyaml
- org.yaml
-
-
com.github.MilkBowl
VaultAPI
1.7
provided
-
-
- bukkit
- org.bukkit
-
-
+ 1.8
${project.groupId}.${project.artifactId}
UTF-8
- 1.8
-
diff --git a/Auto-Tune/pom.xml b/Auto-Tune/pom.xml
index c1f5b2b..2050d32 100644
--- a/Auto-Tune/pom.xml
+++ b/Auto-Tune/pom.xml
@@ -8,7 +8,7 @@
unprotesting.com.github
Auto-Tune
- 0.8.4
+ 0.8.5
jar
Auto-Tune
@@ -125,7 +125,7 @@
org.apache.maven.plugins
maven-shade-plugin
- 2.3
+ 3.2.4
diff --git a/Auto-Tune/src/unprotesting/com/github/Main.java b/Auto-Tune/src/unprotesting/com/github/Main.java
index f214d65..7ffb97c 100644
--- a/Auto-Tune/src/unprotesting/com/github/Main.java
+++ b/Auto-Tune/src/unprotesting/com/github/Main.java
@@ -107,6 +107,8 @@ public final class Main extends JavaPlugin implements Listener {
public static String basicVolatilityAlgorithim;
public static String priceModel;
+ public Boolean vaildAPIKey = false;
+
@Getter
@Setter
public static Gui gui;
@@ -174,6 +176,16 @@ public void onEnable() {
loadShopsFile();
loadShopData();
materialListSize = memMap.size();
+ vaildAPIKey = HttpPostRequestor.checkAPIKey();
+ if (!vaildAPIKey){
+ log.severe(String.format("Disabled due to invalid API key", getDescription().getName()));
+ debugLog("Please check API key is vaild in config.yml");
+ getServer().getPluginManager().disablePlugin(this);
+ return;
+ }
+ if (vaildAPIKey) {
+ log("API-Key found in database. Continuing to load Auto-Tune..");
+ }
this.getCommand("at").setExecutor(new AutoTuneCommand());
this.getCommand("shop").setExecutor(new AutoTuneGUIShopUserCommand());
this.getCommand("sell").setExecutor(new AutoTuneSellCommand());
diff --git a/Auto-Tune/src/unprotesting/com/github/util/HttpPostRequestor.java b/Auto-Tune/src/unprotesting/com/github/util/HttpPostRequestor.java
index 70d238f..fdebd69 100644
--- a/Auto-Tune/src/unprotesting/com/github/util/HttpPostRequestor.java
+++ b/Auto-Tune/src/unprotesting/com/github/util/HttpPostRequestor.java
@@ -42,12 +42,10 @@ public static Double sendPostRequestUsingHttpClient(String model, String algorit
if (statusCode == 200) {
client.close();
}
- ;
if (statusCode != 200) {
client.close();
Main.log("Error on status code");
}
- ;
Main.debugLog(response.getStatusLine().getReasonPhrase());
HttpEntity entityResponse = response.getEntity();
if (entityResponse != null) {
@@ -81,6 +79,59 @@ public static Double sendRequestForPrice(String model, String algorithm, String
}
return newPrice;
}
-
+
+
+ public static boolean ghostCheckAPIKey() throws ClientProtocolException, IOException {
+ if (Config.getApiKey() == "xyz"){
+ Main.log("Please change your API key in the config.yml file");
+ return false;
+ }
+ if (Config.getEmail() == "xyz@gmail.com"){
+ Main.log("Please change your Email in the config.yml file");
+ return false;
+ }
+ else{
+ Main.debugLog("Api-Key has been changed in config");
+ CloseableHttpClient client = HttpClients.createDefault();
+ HttpPost httpPost = new HttpPost("https://safe-refuge-09383.herokuapp.com");
+ httpPost.setHeader("content-type", "application/json");
+ httpPost.setHeader("apikey", Config.getApiKey());
+ httpPost.setHeader("email", Config.getEmail());
+ JSONObject json = new JSONObject();
+ json.put("apikey", Config.getApiKey());
+ StringEntity entity = new StringEntity(json.toJSONString());
+ httpPost.setEntity(entity);
+ CloseableHttpResponse response = client.execute(httpPost);
+ int statusCode = response.getStatusLine().getStatusCode();
+ if (statusCode == 200) {
+ client.close();
+ return true;
+ }
+ else if (statusCode != 200) {
+ client.close();
+ Main.log("Error on status code");
+ return false;
+ }
+ }
+ return false;
+
+ }
+
+ public static boolean checkAPIKey(){
+ try {
+ boolean vaildKey = ghostCheckAPIKey();
+ if (vaildKey == true){
+ return true;
+ }
+ else if (vaildKey != true){
+ return false;
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ return false;
+ }
+ return false;
+ }
+
}
\ No newline at end of file
diff --git a/Auto-Tune/src/unprotesting/com/github/util/JSONManager.java b/Auto-Tune/src/unprotesting/com/github/util/JSONManager.java
index 975ab1d..0041a31 100644
--- a/Auto-Tune/src/unprotesting/com/github/util/JSONManager.java
+++ b/Auto-Tune/src/unprotesting/com/github/util/JSONManager.java
@@ -15,4 +15,5 @@ public static JSONObject returnJSONFromParams(String model, String algorithm, Do
obj.put("minVolatility", minVolatility);
return obj;
}
+
}
\ No newline at end of file