lilypad.client.connect.api.request.RequestException Java Examples

The following examples show how to use lilypad.client.connect.api.request.RequestException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HelperLilyPad.java    From helper with MIT License 6 votes vote down vote up
@Override
public void run() {
    this.attempts++;
    try {
        this.connect.request(new MessageRequest(Collections.emptyList(), this.channel, this.message));
    } catch (RequestException e) {
        if (e.getMessage().equals("Not open") || e.getMessage().equals("Not connected")) {
            // attempt to resend later - try 3 times.
            if (this.attempts < 3) {
                Schedulers.async().runLater(this, 2, TimeUnit.SECONDS);
            }
        } else {
            e.printStackTrace();
        }
    }
}
 
Example #2
Source File: HelperLilyPad.java    From helper with MIT License 5 votes vote down vote up
@Override
public void redirectPlayer(@Nonnull String serverId, @Nonnull String playerUsername) {
    try {
        this.connect.request(new RedirectRequest(serverId, playerUsername));
    } catch (RequestException e) {
        e.printStackTrace();
    }
}
 
Example #3
Source File: LilyPadMessenger.java    From LuckPerms with MIT License 5 votes vote down vote up
@Override
public void sendOutgoingMessage(@NonNull OutgoingMessage outgoingMessage) {
    MessageRequest request = new MessageRequest(Collections.emptyList(), CHANNEL, outgoingMessage.asEncodedString().getBytes(StandardCharsets.UTF_8));
    try {
        this.connect.request(request);
    } catch (RequestException e) {
        e.printStackTrace();
    }
}
 
Example #4
Source File: ConnectPlayerCallback.java    From JLilyPad with GNU General Public License v3.0 5 votes vote down vote up
public void resendLocalPlayers() throws RequestException {		
	this.localPlayersLock.lock();
	try {
		for(String player : this.localPlayers) {
			this.connect.request(new NotifyPlayerRequest(true, player));
		}
	} finally {
		this.localPlayersLock.unlock();
	}
}
 
Example #5
Source File: ConnectPlayerCallback.java    From JLilyPad with GNU General Public License v3.0 5 votes vote down vote up
public void notifyPlayerLeave(String player) {
	this.localPlayersLock.lock();
	try {
		this.localPlayers.remove(player);
	} finally {
		this.localPlayersLock.unlock();
	}
	try {
		this.connect.request(new NotifyPlayerRequest(false, player));
	} catch(RequestException exception) {
		// ignore
	}
}
 
Example #6
Source File: ConnectPlayerCallback.java    From JLilyPad with GNU General Public License v3.0 5 votes vote down vote up
public boolean queryPlayers() throws RequestException, InterruptedException {
	GetPlayersResult result = this.connect.request(new GetPlayersRequest(false)).await(10000L);
	if(result == null) {
		return false;
	}
	this.playerCount = result.getCurrentPlayers();
	this.playerMaximum = result.getMaximumPlayers();
	return true;
}