2727import net .minecraft .util .Session ;
2828import org .apache .logging .log4j .LogManager ;
2929import org .apache .logging .log4j .Logger ;
30+ import uk .co .hexeption .darkforge .MC ;
3031
3132import java .lang .reflect .Field ;
3233import java .net .Proxy ;
3334
34- public class LoginUtils {
35+ public class LoginUtils implements MC {
3536
3637 private static final Logger logger = LogManager .getLogger ();
3738
38- public static void setSession (Session s ) throws IllegalAccessException {
39-
40- Class <? extends Minecraft > mc = Minecraft .getMinecraft ().getClass ();
41- try {
42- Field session = null ;
43-
44- for (Field f : mc .getDeclaredFields ()) {
45- if (f .getType ().isInstance (s )) {
46- session = f ;
47- }
48- }
49-
50- if (session == null ) {
51- throw new IllegalStateException ("no field of type " + Session .class .getCanonicalName () + " declared." );
52- }
53-
54- session .setAccessible (true );
55- session .set (Minecraft .getMinecraft (), s );
56- session .setAccessible (false );
57-
58- } catch (Exception e ) {
59- e .printStackTrace ();
60- throw e ;
61- }
62- }
63-
6439 public static String loginAlt (String email , String password ) {
6540
6641 YggdrasilAuthenticationService authenticationService = new YggdrasilAuthenticationService (Proxy .NO_PROXY , "" );
@@ -71,7 +46,7 @@ public static String loginAlt(String email, String password) {
7146
7247 try {
7348 authentication .logIn ();
74- setSession (new Session (authentication .getSelectedProfile ().getName (), authentication .getSelectedProfile ().getId ().toString (), authentication .getAuthenticatedToken (), "mojang" ));
49+ mixMC . setSession (new Session (authentication .getSelectedProfile ().getName (), authentication .getSelectedProfile ().getId ().toString (), authentication .getAuthenticatedToken (), "mojang" ));
7550 displayText = "" ;
7651 } catch (AuthenticationUnavailableException e ) {
7752 displayText = "§4§lCannot contact authentication server!" ;
@@ -86,8 +61,6 @@ public static String loginAlt(String email, String password) {
8661 logger .error (e .getMessage ());
8762 } catch (NullPointerException e ) {
8863 displayText = "§4§lWrong password!" ;
89- } catch (IllegalAccessException e ) {
90- e .printStackTrace ();
9164 }
9265
9366 return displayText ;
@@ -110,11 +83,7 @@ public static String getName(String email, String password) {
11083
11184 public static void changeCrackedName (String name ) {
11285
113- try {
114- setSession (new Session (name , "" , "" , "mojang" ));
115- } catch (IllegalAccessException e ) {
116- e .printStackTrace ();
117- }
86+ mixMC .setSession (new Session (name , "" , "" , "mojang" ));
11887 }
11988
12089
0 commit comments