Save the IP checked against for bisect hosting

This commit is contained in:
libraryaddict 2020-03-19 16:05:47 +13:00
parent 0319f72633
commit 45ecc68a2a
No known key found for this signature in database
GPG Key ID: 052E4FBCD257AEA4

View File

@ -15,14 +15,16 @@ public class BisectHosting {
public boolean isBisectHosted(String pluginName) {
File configFile = new File("plugins/" + pluginName + "/internal.yml");
boolean claimedHosted = false;
String serverIp = Bukkit.getIp().replaceAll("[^:0-9.]", "");
if (configFile.exists()) {
YamlConfiguration configuration = YamlConfiguration.loadConfiguration(configFile);
if (configuration.contains("Bisect-Hosted")) {
if (configuration.contains("Bisect-Hosted") && configuration.contains("Server-IP")) {
claimedHosted = configuration.getBoolean("Bisect-Hosted");
// If not hosted by bisect
if (!claimedHosted) {
if (!claimedHosted && configuration.getString("Server-IP").equals(serverIp)) {
return false;
}
}
@ -45,7 +47,6 @@ public class BisectHosting {
// If config doesn't exist, or it's not a bisect server
if (!configFile.exists()) {
if (!configFile.getParentFile().exists()) {
configFile.getParentFile().mkdirs();
}
@ -59,6 +60,7 @@ public class BisectHosting {
"\n# Coupon 'libraryaddict' for 25% off your first invoice on any of their gaming servers");
writer.write("\n# Be sure to visit through this link! https://bisecthosting.com/libraryaddict");
writer.write("\nBisect-Hosted: " + hostedBy);
writer.write("\nServer-IP: " + serverIp);
}
catch (FileNotFoundException | UnsupportedEncodingException e) {
e.printStackTrace();