A library for interacting with Origins XMPP service, chat with players, send/accept friend requests and more!
- Support for game presences, have custom text as your status!
- Support for chatting with players.
- Support for friends, listen for friend requests, send them, or accept one!
- Basic Lobby support, receive invites, get lobby information.
- Everything else
Nadir
supports.
Origin uses Nadir
made by RobertoGraham, go check it out!
This project is still a work in progress, expect more things to be soon!
You can either intialize an Origin
instance with a username and password, or with an already built instance of Nadir
.
final var origin = Origin.newOrigin(username, password);
origin.connect();
final var origin = Origin.newOrigin(nadir);
origin.connect();
origin.chat().addChatListener(message -> {
System.out.println("Message: " + message.getMessage());
message.reply("abc");
});
origin.chat().addChatListener(new ChatListener() {
@Override
public void onMessageReceived(Message message) {
System.err.println(message.getMessage());
}
@Override
public void onTyping(EntityBareJid from) {
System.err.println("typing");
}
});
try {
origin.getNadir().accounts().findAllBySearchTerms("vrektwastaken")
.flatMap((final var list) -> list.stream()
.findFirst()).ifPresent(account -> origin.friend().sendFriendRequest(account.userId()));
} catch (final IOException exception) {
exception.printStackTrace();
}
origin.friend().acceptFriendRequest(1008999560409L);
origin.friend().addFriendListener(new FriendListener() {
@Override
public void onFriendRequestAccepted(Long userId) {
System.out.println("Accepted!");
}
});
origin.presence().setGameTextPresence(new GameTextPresence("Your text here", "Your text here"));
origin.onConnect(() -> {
// start code
});
origin.onReconnect(() -> {
// stop code temporarily
});
final var lobby = origin.lobby().getLobby(1008999560409L);
origin.lobby().addLobbyListener(new LobbyListener() {
@Override
public void onInvitation(String joinLink, String inviteId, Long userId) {
final var lobby = origin.lobby().getLobby(userId);
}
});