当前位置: 首页>>代码示例>>Java>>正文


Java Protocol类代码示例

本文整理汇总了Java中pro.beam.interactive.net.packet.Protocol的典型用法代码示例。如果您正苦于以下问题:Java Protocol类的具体用法?Java Protocol怎么用?Java Protocol使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Protocol类属于pro.beam.interactive.net.packet包,在下文中一共展示了Protocol类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleInput

import pro.beam.interactive.net.packet.Protocol; //导入依赖的package包/类
public boolean handleInput(Protocol.Report.TactileInfo tInfo, Protocol.Report.Users users) {
    boolean pressed = false;
    if (handlers.containsKey(tInfo.getId())) {
        KeyHandler kHandler = handlers.get(tInfo.getId());
        pressed = kHandler.handleKey(tInfo, users);

        Protocol.ProgressUpdate.TactileUpdate.Builder tacBuilder = Protocol.ProgressUpdate.TactileUpdate.newBuilder();
        tacBuilder
            .setId(tInfo.getId())
            .setFired(pressed)
            .setProgress(kHandler.getProgress());

        if (pressed) tacBuilder.setCooldown(kHandler.getCooldown());

        builder.addTactile(tacBuilder);
    }

    return pressed;
}
 
开发者ID:mixer,项目名称:surgeon-sim,代码行数:20,代码来源:KeyMap.java

示例2: login

import pro.beam.interactive.net.packet.Protocol; //导入依赖的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

示例3: take

import pro.beam.interactive.net.packet.Protocol; //导入依赖的package包/类
@Override
public void take(Protocol.Report report) {

    if (getPlayer() == null) {
        return;
    }

    Location l = getPlayer().getLocation().clone().add(getDelta());
    l.setY(l.getY() - 3);

    fill(l, 0, 3, Material.DIRT);
    fill(l, 3, 4, Material.GRASS);

    Location chestLocation = l.clone().add(2, 4, 2);
    spawnChest(chestLocation);


    StringBuffer buffer = new StringBuffer();
    buffer.append(ChatColor.GRAY);
    buffer.append(ChatColor.ITALIC);
    buffer.append("Spawning Bonus Island!");

    getPlayer().sendMessage(buffer.toString());
    InteractivePlugin.INSTANCE.addIsland(l.getBlockX(), l.getBlockZ());
}
 
开发者ID:mixer,项目名称:skyblock-interactive-minecraft,代码行数:26,代码来源:CreateBonusIslandAction.java

示例4: take

import pro.beam.interactive.net.packet.Protocol; //导入依赖的package包/类
@Override
public void take(Protocol.Report report) {
    final Player p = getPlayer();

    if (p != null) {

        String faction = isHostile() ? "A Very Mean" : "A Really Nice";

        StringBuffer buffer = new StringBuffer();
        buffer.append(ChatColor.GRAY);
        buffer.append(ChatColor.ITALIC);
        buffer.append("S" +
                "pawning " + faction + " Mob!");

        p.sendMessage(buffer.toString());

        if (InteractivePlugin.INSTANCE != null) {
            Bukkit.getScheduler().runTaskLater(InteractivePlugin.INSTANCE, new Runnable() {
                @Override
                public void run() {
                    p.getWorld().spawnEntity(SpawnMobAction.this.getLocationWithin(p, 5), SpawnMobAction.this.getRandomEntity());
                }
            }, 1);
        }
    }
}
 
开发者ID:mixer,项目名称:skyblock-interactive-minecraft,代码行数:27,代码来源:SpawnMobAction.java

示例5: take

import pro.beam.interactive.net.packet.Protocol; //导入依赖的package包/类
@Override
public void take(Protocol.Report report) {
    Player p = getPlayer();

    if (p == null) {
        return;
    }

    World w = p.getWorld();

    w.setTime(w.getTime() + 12000);

    StringBuffer buffer = new StringBuffer();
    buffer.append(ChatColor.GRAY);
    buffer.append(ChatColor.ITALIC);
    buffer.append("Changing Time Of Day!");

    getPlayer().sendMessage(buffer.toString());

}
 
开发者ID:mixer,项目名称:skyblock-interactive-minecraft,代码行数:21,代码来源:ChangeTimeAction.java

示例6: KeyMap

import pro.beam.interactive.net.packet.Protocol; //导入依赖的package包/类
public KeyMap() {
    handlers = new HashMap<Integer, KeyHandler>();
    handlers.put(0, new KeyHandler(65, KeyType.PRESS, 0.5));
    handlers.put(1, new KeyHandler(83, KeyType.PRESS, 0.5));
    handlers.put(2, new KeyHandler(68, KeyType.PRESS, 0.5));
    handlers.put(3, new KeyHandler(70, KeyType.PRESS, 0.5));
    handlers.put(4, new KeyHandler(32, KeyType.PRESS, 0.5));

    handlers.put(5, new KeyHandler(-1, KeyType.SHAKE, 10.0));

    allowed.addAll(Arrays.asList(65, 83, 68, 70, 32));

    builder = Protocol.ProgressUpdate.newBuilder();
}
 
开发者ID:mixer,项目名称:surgeon-sim,代码行数:15,代码来源:KeyMap.java

示例7: handleKey

import pro.beam.interactive.net.packet.Protocol; //导入依赖的package包/类
public boolean handleKey(Protocol.Report.TactileInfo tInfo, Protocol.Report.Users users) {
    if (type == KeyType.PRESS) {
        if (users.getQuorum() == 0.0) return pressKey(0.0);
        return pressKey(tInfo.getHolding() / (double) users.getQuorum());
    }
    //noinspection SimplifiableIfStatement
    if (type == KeyType.SHAKE) {
        return shakeScreen(tInfo.getPressFrequency());
    }

    return false;
}
 
开发者ID:mixer,项目名称:surgeon-sim,代码行数:13,代码来源:KeyHandler.java

示例8: handle

import pro.beam.interactive.net.packet.Protocol; //导入依赖的package包/类
@Override
public void handle(Protocol.Report report) {
    try {
        this.actions.dispatch(report);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:mixer,项目名称:skyblock-interactive-minecraft,代码行数:9,代码来源:ActionDispatchEventListener.java

示例9: isMet

import pro.beam.interactive.net.packet.Protocol; //导入依赖的package包/类
@Override
public boolean isMet(Protocol.Report report) {
    for (Protocol.Report.TactileInfo info : report.getTactileList()) {
        if ((info.getId() == this.code) && (info.getPressFrequency() > 0)) {
            return true;
        }
    }

    return false;
}
 
开发者ID:mixer,项目名称:skyblock-interactive-minecraft,代码行数:11,代码来源:TactileInput.java

示例10: dispatch

import pro.beam.interactive.net.packet.Protocol; //导入依赖的package包/类
public void dispatch(Protocol.Report report) throws IOException {
    ProgressUpdate.Builder progress = ProgressUpdate.newBuilder();

    for (Map.Entry<TactileInput, Action> e : this.actions.entrySet()) {
        if (!e.getKey().isMet(report)) {
            if (pressedTactiles.contains(e.getKey().code)) {
                pressedTactiles.remove(e.getKey().code);
                progress.addTactile(ProgressUpdate.TactileUpdate.newBuilder()
                    .setId(e.getKey().code)
                    .setProgress(0)
                    .setFired(false)
                    .build()
                );               
            }
            continue;
        }

        e.getValue().take(report);

        pressedTactiles.add(e.getKey().code);

        progress.addTactile(ProgressUpdate.TactileUpdate.newBuilder()
                .setId(e.getKey().code)
                .setProgress(1)
                .setFired(true)
                .build()
        );
    }

    if (progress.getTactileCount() + progress.getJoystickCount() > 0) {
        this.plugin.robot.write(progress.build());
    }
}
 
开发者ID:mixer,项目名称:skyblock-interactive-minecraft,代码行数:34,代码来源:ActionManager.java

示例11: take

import pro.beam.interactive.net.packet.Protocol; //导入依赖的package包/类
@Override
public void take(Protocol.Report report) {
    final Player p = getPlayer();

    if (p != null) {
        if (InteractivePlugin.INSTANCE != null) {
            Bukkit.getScheduler().runTaskLater(InteractivePlugin.INSTANCE, new Runnable() {
                @Override
                public void run() {
                    Location position = PositionUtil.getSafeLocationWithin(p, 2, 5);
                    if (position == null) {
                        position = PositionUtil.getLocationWithin(p, 4, 6);
                    }
                    Block block = p.getWorld().getBlockAt(position);
                    if ((block.getType() != Material.DIRT) || (block.getType() != Material.GRASS)) {
                        block.setType(Material.DIRT);
                        position.add(0, 1, 0);
                    }

                    p.getWorld().generateTree(position, TreeType.TREE);

                    StringBuffer buffer = new StringBuffer();
                    buffer.append(ChatColor.GRAY);
                    buffer.append(ChatColor.ITALIC);
                    buffer.append("A Wild Tree Appears!");

                    getPlayer().sendMessage(buffer.toString());
                }
            }, 1);
        }
    }
}
 
开发者ID:mixer,项目名称:skyblock-interactive-minecraft,代码行数:33,代码来源:SpawnTreeAction.java

示例12: take

import pro.beam.interactive.net.packet.Protocol; //导入依赖的package包/类
@Override
public void take(Protocol.Report report) {
    final Player p = getPlayer();

    if (p != null) {



        if (InteractivePlugin.INSTANCE != null) {
            Bukkit.getScheduler().runTaskLater(InteractivePlugin.INSTANCE, new Runnable() {
                @Override
                public void run() {
                    int potionId = RandomPotionAction.GetRandomInRange(0, RandomPotionAction.PotionList.size() - 1);
                    p.addPotionEffect(new PotionEffect(RandomPotionAction.PotionList.get(potionId), RandomPotionAction.GetRandomInRange(20, 2400),
                            RandomPotionAction.GetRandomInRange(0, 2)));

                    StringBuffer buffer = new StringBuffer();
                    buffer.append(ChatColor.GRAY);
                    buffer.append(ChatColor.ITALIC);
                    buffer.append("Potion Attack!");

                    getPlayer().sendMessage(buffer.toString());
                }
            }, 1);
        }
    }
}
 
开发者ID:mixer,项目名称:skyblock-interactive-minecraft,代码行数:28,代码来源:RandomPotionAction.java

示例13: take

import pro.beam.interactive.net.packet.Protocol; //导入依赖的package包/类
@Override
public void take(Protocol.Report report) {
    final Player player = getPlayer();

    if ((player == null) || this.active) {
        return;
    }

    this.active = true;
    this.countDown = 3;

    if (InteractivePlugin.INSTANCE != null) {
        this.taskId = Bukkit.getScheduler().scheduleSyncRepeatingTask(InteractivePlugin.INSTANCE, new Runnable() {
            @Override
            public void run() {

                if (ReplaceCurrentItemAction.this.countDown <= 0) {
                    Bukkit.getScheduler().cancelTask(ReplaceCurrentItemAction.this.taskId);
                    swapItem(player);
                    ReplaceCurrentItemAction.this.active = false;
                } else {
                    StringBuffer buffer = new StringBuffer();
                    buffer.append(ChatColor.GRAY);
                    buffer.append(ChatColor.ITALIC);
                    buffer.append("Changing Item in ");
                    buffer.append(ReplaceCurrentItemAction.this.countDown);

                    player.sendMessage(buffer.toString());

                    ReplaceCurrentItemAction.this.countDown--;
                }
            }
        }, 20, 20);
    }

}
 
开发者ID:mixer,项目名称:skyblock-interactive-minecraft,代码行数:37,代码来源:ReplaceCurrentItemAction.java

示例14: take

import pro.beam.interactive.net.packet.Protocol; //导入依赖的package包/类
@Override
public void take(Protocol.Report report) {
    final Player p = getPlayer();

    if (p != null) {
        if (InteractivePlugin.INSTANCE != null) {
            Bukkit.getScheduler().runTaskLater(InteractivePlugin.INSTANCE, new Runnable() {
                @Override
                public void run() {
                    p.getWorld().strikeLightning(p.getLocation());
                }
            }, 1);
        }
    }
}
 
开发者ID:mixer,项目名称:skyblock-interactive-minecraft,代码行数:16,代码来源:StrikeLightningAction.java

示例15: handle

import pro.beam.interactive.net.packet.Protocol; //导入依赖的package包/类
@Override public void handle(Protocol.Report report) {
    // Grab the joystick for each both axes
    Protocol.Report.JoystickInfo joystick = report.getJoystick(0);

    // Move the mouse to the calculated mean of each of the individual axis respectively.
    mouse.mouseMove(
            (int) Math.round(joystick.getCoordMean().getX()),
            (int) Math.round(joystick.getCoordMean().getY())
    );
}
 
开发者ID:mixer,项目名称:beam-interactive-java,代码行数:11,代码来源:MouseMoveListener.java


注:本文中的pro.beam.interactive.net.packet.Protocol类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。