daily pastebin goal
29%
SHARE
TWEET

Untitled

a guest Feb 4th, 2016 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package me.myiume.dota2interactive.api;
  2.  
  3. import java.net.URI;
  4.  
  5. import com.google.common.util.concurrent.CheckedFuture;
  6. import com.google.common.util.concurrent.ListenableFuture;
  7.  
  8. import me.myiume.dota2interactive.Dota2Interactive;
  9. import pro.beam.api.BeamAPI;
  10. import pro.beam.api.exceptions.BeamException;
  11. import pro.beam.api.resource.BeamUser;
  12. import pro.beam.api.services.impl.UsersService;
  13. import pro.beam.interactive.robot.Robot;
  14. import pro.beam.interactive.robot.RobotBuilder;
  15.  
  16. public class TetrisConnector {
  17.  
  18.  
  19.     public BeamAPI getBeam() {
  20.         URI uri = URI.create(Dota2Interactive.getURL());
  21.         String username = Dota2Interactive.getUsername();
  22.         String password = Dota2Interactive.getPassword();
  23.  
  24.         if (username == null && password == null) {
  25.             return new BeamAPI();
  26.         } else {
  27.             return new BeamAPI(uri, username, password);
  28.         }
  29.  
  30.     }
  31.  
  32.     public BeamUser getUser(BeamAPI beam) throws BeamException {
  33.         String username = Dota2Interactive.getUsername();
  34.         String password = Dota2Interactive.getPassword();
  35.  
  36.         CheckedFuture<BeamUser, BeamException> task;
  37.             task = beam.use(UsersService.class).login(username, password);
  38.  
  39.  
  40.         return task.checkedGet();
  41.     }
  42.  
  43.     public ListenableFuture<Robot> getRobot() {
  44.         return this.getRobot(getBeam());
  45.     }
  46.  
  47.     public ListenableFuture<Robot> getRobot(BeamAPI beam) {
  48.         RobotBuilder builder = new RobotBuilder();
  49.  
  50.         builder.username(Dota2Interactive.getUsername());
  51.         builder.password(Dota2Interactive.getPassword());
  52.         builder.channel(Dota2Interactive.getChannel());
  53.         return builder.build(beam);
  54.     }
  55. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top