11package today .netshield .bungee ;
22
3- import com .google .gson .Gson ;
4- import com .google .gson .JsonObject ;
53import lombok .Getter ;
64import net .md_5 .bungee .api .plugin .Plugin ;
75import net .md_5 .bungee .config .Configuration ;
86import net .md_5 .bungee .config .ConfigurationProvider ;
97import net .md_5 .bungee .config .YamlConfiguration ;
10- import okhttp3 .*;
118import today .netshield .bungee .listeners .PlayerListener ;
12- import today .netshield .bungee .utils .CC ;
139import today .netshield .bungee .utils .ConfigFiles ;
1410
1511import 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