Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
56 lines (45 sloc) 1.69 KB

TrixAuth

public Demo() {
		TrixAuth auth = new TrixAuth("ServerName", "WebsiteURL", "UserName", "UserPassword");

		auth.setNeededConfirmed(false); // <---- User confirmation required : true = needed, false = no need
		auth.setRejectedBanned(true); // <--- Eject the user if he is banned : true = yes, false = no

		try {
			auth.connect();
		} catch (ServerNotFoundException e) {
			System.err.println(e.getMessage()); // <---- URL == null
		} catch (UserEmptyException e) {
			System.err.println(e.getMessage()); // <---- user name || password == null
		} catch (UserNotConfirmedException e) {
			System.err.println(e.getMessage()); // <---- Email address of the user is not confirmed
		} catch (UserBannedException e) {
			System.err.println(e.getMessage()); // <---- User is banned
		} catch (UserWrongException e) {
			System.err.println(e.getMessage()); // <--- Invalid user name or password
		} catch (TimeOutException e) {
			System.err.println(e.getMessage()); // <--- Site timed out
		}

		switch (auth.getAuthStatus()) {
		case CONNECTED:
			// Connected

			// Example //

			TrixProfile profile = auth.getProfile();

			System.out.println("Profile:");
			System.out.println("• Username: " + profile.getUserName());
			System.out.println("• Mail: " + profile.getUserMail());
			System.out.println("• Money: " + profile.getMoney());
			System.out.println("• Rank: " + profile.getUserRank());
			System.out.println("• Banned: " + profile.isAccountBanned());
			System.out.println("• Confirmed: " + profile.isAccountConfirmed());

			break;
		case CONNECTION:
			// Connection in progress
			break;
		case DISCONNECTED:
			// Not connected
			break;
		}

		// Log out //

		auth.disconnect();
	}
You can’t perform that action at this time.