Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.myiume.dota2interactive.api;
- import java.net.URI;
- import com.google.common.util.concurrent.CheckedFuture;
- import com.google.common.util.concurrent.ListenableFuture;
- import me.myiume.dota2interactive.Dota2Interactive;
- import pro.beam.api.BeamAPI;
- import pro.beam.api.exceptions.BeamException;
- import pro.beam.api.resource.BeamUser;
- import pro.beam.api.services.impl.UsersService;
- import pro.beam.interactive.robot.Robot;
- import pro.beam.interactive.robot.RobotBuilder;
- public class TetrisConnector {
- public BeamAPI getBeam() {
- URI uri = URI.create(Dota2Interactive.getURL());
- String username = Dota2Interactive.getUsername();
- String password = Dota2Interactive.getPassword();
- if (username == null && password == null) {
- return new BeamAPI();
- } else {
- return new BeamAPI(uri, username, password);
- }
- }
- public BeamUser getUser(BeamAPI beam) throws BeamException {
- String username = Dota2Interactive.getUsername();
- String password = Dota2Interactive.getPassword();
- CheckedFuture<BeamUser, BeamException> task;
- task = beam.use(UsersService.class).login(username, password);
- return task.checkedGet();
- }
- public ListenableFuture<Robot> getRobot() {
- return this.getRobot(getBeam());
- }
- public ListenableFuture<Robot> getRobot(BeamAPI beam) {
- RobotBuilder builder = new RobotBuilder();
- builder.username(Dota2Interactive.getUsername());
- builder.password(Dota2Interactive.getPassword());
- builder.channel(Dota2Interactive.getChannel());
- return builder.build(beam);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement