當前位置: 首頁>>代碼示例>>Java>>正文


Java Robot類代碼示例

本文整理匯總了Java中pro.beam.interactive.robot.Robot的典型用法代碼示例。如果您正苦於以下問題:Java Robot類的具體用法?Java Robot怎麽用?Java Robot使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Robot類屬於pro.beam.interactive.robot包,在下文中一共展示了Robot類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: login

import pro.beam.interactive.robot.Robot; //導入依賴的package包/類
public static void login(String username, String oauthToken) throws ExecutionException, InterruptedException {
    beam = new BeamAPI(oauthToken);
    BeamUser user = beam.use(UsersService.class).getCurrent().get();
    final Robot robot = new RobotBuilder().channel(user.channel).build(beam, false).get();

    //Listen for report events on the robot.
    robot.on(Protocol.Report.class, report -> {
        for (Protocol.Report.TactileInfo tInfo : report.getTactileList()) {
            KeyMap.getInstance().handleInput(tInfo, report.getUsers());
        }

        Protocol.ProgressUpdate pu = KeyMap.getInstance().getProgressUpdate();

        try {
            robot.write(pu);
        } catch (IOException ex) {
            System.err.println("Failed to send packet.");
            ex.printStackTrace();
        }
    });

    init();
}
 
開發者ID:mixer,項目名稱:surgeon-sim,代碼行數:24,代碼來源:BPSurgeonSim.java

示例2: getRobot

import pro.beam.interactive.robot.Robot; //導入依賴的package包/類
public ListenableFuture<Robot> getRobot(BeamAPI beam) {
    RobotBuilder builder = new RobotBuilder();

    builder.username(this.config.getString("beam.auth.username"));
    builder.password(this.config.getString("beam.auth.password"));
    builder.channel(this.config.getInt("beam.auth.channel"));
    if (this.config.isSet("beam.auth.twoFactor")) {
        builder.twoFactor(this.config.getString("beam.auth.twoFactor"));
    }

    return builder.build(beam);
}
 
開發者ID:mixer,項目名稱:skyblock-interactive-minecraft,代碼行數:13,代碼來源:TetrisBukkitConnector.java

示例3: main

import pro.beam.interactive.robot.Robot; //導入依賴的package包/類
public static void main(String[] args) {
    // Construct an instance of the BeamAPI that will be used for communication with Tetris.
    BeamAPI beam = new BeamAPI();

    // This future will return a Robot that is connected. See usage below for how to add a callback to
    // a ListenableFuture.
    //
    // A RobotBuilder is the entry-point to creating a Robot that you can do things with. It follows
    // the typical builder-pattern as expressed in Java, and an example usage may be found below:
    ListenableFuture<Robot> future = new RobotBuilder().username("<username>")
                                                       .password("<password>")
                                                       .channel(127)
                                                       .build(beam);

    // This is a rudimentary example of how to listen for a callback on a ListenableFuture.
    Futures.addCallback(future, new FutureCallback<Robot>() {
        @Override public void onSuccess(Robot robot) {
            // The robot is connected and ready to be used.

            // Set up an event handler to listen to the Report message, and delegate
            // into the given instance of a listener.
            robot.on(Protocol.Report.class, new MouseMoveListener());
            robot.on(Protocol.Report.class, new KeyPressListener());
        }

        @Override public void onFailure(Throwable throwable) {
            // There was an error connecting to the socket.

            System.err.println("Error experienced in connecting to Beam.");
            throwable.printStackTrace();
        }
    });
}
 
開發者ID:mixer,項目名稱:beam-interactive-java,代碼行數:34,代碼來源:TetrisExample.java


注:本文中的pro.beam.interactive.robot.Robot類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。