Skip to content

Commit d3ea875

Browse files
committed
Se ha sacado el sistema de licencias.
Se ha eliminado el sistema de licencias en el start-up ya que el plugin es open source y necesariamente necesitas tener una key para poder utilizarlo correctamente.
1 parent cbd33eb commit d3ea875

File tree

2 files changed

+2
-103
lines changed

2 files changed

+2
-103
lines changed

bukkit/src/main/java/today/netshield/bukkit/NetShield.java

Lines changed: 1 addition & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
11
package today.netshield.bukkit;
22

3-
import com.google.gson.Gson;
4-
import com.google.gson.JsonObject;
53
import lombok.Getter;
6-
import okhttp3.*;
7-
import org.apache.commons.lang.StringUtils;
84
import org.bukkit.plugin.java.JavaPlugin;
95
import today.netshield.bukkit.listener.PlayerListener;
10-
import today.netshield.bukkit.utils.CC;
11-
12-
import java.io.IOException;
136

147
public final class NetShield extends JavaPlugin {
158
@Getter
@@ -20,51 +13,7 @@ public void onEnable() {
2013
saveDefaultConfig();
2114
instance = this;
2215

23-
CC.log("&7&m" + StringUtils.repeat("-", 24));
24-
CC.log("&b&lNet&9&lShield");
25-
CC.log("&f");
26-
CC.log("&9Version: "+ getDescription().getVersion());
27-
CC.log("&7&oChecking key...");
28-
29-
OkHttpClient client = new OkHttpClient();
30-
31-
Gson gson = new Gson();
32-
JsonObject jsonObject = new JsonObject();
33-
jsonObject.addProperty("key", getConfig().getString("KEY"));
34-
String jsonString = gson.toJson(jsonObject);
35-
36-
RequestBody requestBody = RequestBody.create(jsonString, MediaType.parse("application/json"));
37-
38-
Request request = new Request.Builder()
39-
.url("https://netshield.bombardeen.me/api/checkkey")
40-
.post(requestBody)
41-
.addHeader("Content-Type", "application/json")
42-
.build();
43-
44-
try (Response response = client.newCall(request).execute()) {
45-
if (response.isSuccessful()) {
46-
String jsonResponse = response.body().string();
47-
JsonObject responseObject = gson.fromJson(jsonResponse, JsonObject.class);
48-
String status = responseObject.has("status") ? responseObject.get("status").getAsString() : null;
49-
50-
if (!status.equals("VALID_KEY")) {
51-
CC.log("&9Status: &c" + status);
52-
CC.log("&c&oShutting down the plugin...");
53-
getPluginLoader().disablePlugin(this);
54-
} else {
55-
CC.log("&9Status: &a" + status);
56-
CC.log("&eThanks for using &lNetShield&e!");
57-
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
58-
}
59-
} else {
60-
CC.log("Error: " + response.code() + " - " + response.message());
61-
getPluginLoader().disablePlugin(this);
62-
}
63-
} catch (IOException e) {
64-
throw new RuntimeException(e);
65-
}
66-
67-
CC.log("&7&m" + StringUtils.repeat("-", 24));
16+
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
6817
}
6918

7019
@Override
Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
package today.netshield.bungee;
22

3-
import com.google.gson.Gson;
4-
import com.google.gson.JsonObject;
53
import lombok.Getter;
64
import net.md_5.bungee.api.plugin.Plugin;
75
import net.md_5.bungee.config.Configuration;
86
import net.md_5.bungee.config.ConfigurationProvider;
97
import net.md_5.bungee.config.YamlConfiguration;
10-
import okhttp3.*;
118
import today.netshield.bungee.listeners.PlayerListener;
12-
import today.netshield.bungee.utils.CC;
139
import today.netshield.bungee.utils.ConfigFiles;
1410

1511
import java.io.File;
@@ -37,52 +33,6 @@ public void onEnable() {
3733
throw new RuntimeException(e);
3834
}
3935

40-
CC.log("&7&m------------------------");
41-
CC.log("&b&lNet&9&lShield");
42-
CC.log("&f");
43-
CC.log("&9Version: "+ getDescription().getVersion());
44-
CC.log("&7&oChecking key...");
45-
46-
OkHttpClient client = new OkHttpClient();
47-
48-
Gson gson = new Gson();
49-
JsonObject jsonObject = new JsonObject();
50-
jsonObject.addProperty("key", getConfig().getString("KEY"));
51-
String jsonString = gson.toJson(jsonObject);
52-
53-
RequestBody requestBody = RequestBody.create(jsonString, MediaType.parse("application/json"));
54-
55-
Request request = new Request.Builder()
56-
.url("https://netshield.bombardeen.me/api/checkkey")
57-
.post(requestBody)
58-
.addHeader("Content-Type", "application/json")
59-
.build();
60-
61-
try (Response response = client.newCall(request).execute()) {
62-
if (response.isSuccessful()) {
63-
String jsonResponse = response.body().string();
64-
JsonObject responseObject = gson.fromJson(jsonResponse, JsonObject.class);
65-
String status = responseObject.has("status") ? responseObject.get("status").getAsString() : null;
66-
67-
if (!status.equals("VALID_KEY")) {
68-
CC.log("&9Status: &c" + status);
69-
CC.log("&c&oShutting down the plugin...");
70-
getProxy().getPluginManager().unregisterCommands(this);
71-
getProxy().getPluginManager().unregisterListeners(this);
72-
} else {
73-
CC.log("&9Status: &a" + status);
74-
CC.log("&eThanks for using &lNetShield&e!");
75-
getProxy().getPluginManager().registerListener(this, new PlayerListener());
76-
}
77-
} else {
78-
CC.log("Error: " + response.code() + " - " + response.message());
79-
getProxy().getPluginManager().unregisterCommands(this);
80-
getProxy().getPluginManager().unregisterListeners(this);
81-
}
82-
} catch (IOException e) {
83-
throw new RuntimeException(e);
84-
}
85-
86-
CC.log("&7&m------------------------");
36+
getProxy().getPluginManager().registerListener(this, new PlayerListener());
8737
}
8838
}

0 commit comments

Comments
 (0)