コード例 #1
0
 @Override
 public void onPluginMessageReceived(String channel, Player player, byte[] message) {
   LocalSession session = plugin.getSession(player);
   String text = new String(message, UTF_8_CHARSET);
   session.handleCUIInitializationMessage(text);
   session.describeCUI(plugin.wrapPlayer(player));
 }
コード例 #2
0
 @EventHandler(priority = EventPriority.LOWEST, event = PlayerJoinEvent.class)
 public void onPlayerJoin(PlayerJoinEvent event) {
   plugin.wrapPlayer(event.getPlayer()).dispatchCUIHandshake();
 }
コード例 #3
0
 /**
  * Called when a player leaves a server
  *
  * @param event Relevant event details
  */
 @EventHandler(event = PlayerQuitEvent.class)
 public void onPlayerQuit(PlayerQuitEvent event) {
   plugin.getWorldEdit().markExpire(plugin.wrapPlayer(event.getPlayer()));
 }
コード例 #4
0
  /**
   * Called when a player interacts
   *
   * @param event Relevant event details
   */
  @EventHandler(event = PlayerInteractEvent.class)
  public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.useItemInHand() == Result.DENY) {
      return;
    }

    final LocalPlayer player = plugin.wrapPlayer(event.getPlayer());
    final LocalWorld world = player.getWorld();
    final WorldEdit we = plugin.getWorldEdit();

    Action action = event.getAction();
    if (action == Action.LEFT_CLICK_BLOCK) {
      final Block clickedBlock = event.getClickedBlock();
      final WorldVector pos =
          new WorldVector(world, clickedBlock.getX(), clickedBlock.getY(), clickedBlock.getZ());

      if (we.handleBlockLeftClick(player, pos)) {
        event.setCancelled(true);
      }

      if (we.handleArmSwing(player)) {
        event.setCancelled(true);
      }

      if (!ignoreLeftClickAir) {
        final int taskId =
            Bukkit.getScheduler()
                .scheduleSyncDelayedTask(
                    plugin,
                    new Runnable() {
                      public void run() {
                        ignoreLeftClickAir = false;
                      }
                    },
                    2);

        if (taskId != -1) {
          ignoreLeftClickAir = true;
        }
      }
    } else if (action == Action.LEFT_CLICK_AIR) {
      if (ignoreLeftClickAir) {
        return;
      }

      if (we.handleArmSwing(player)) {
        event.setCancelled(true);
      }

    } else if (action == Action.RIGHT_CLICK_BLOCK) {
      final Block clickedBlock = event.getClickedBlock();
      final WorldVector pos =
          new WorldVector(world, clickedBlock.getX(), clickedBlock.getY(), clickedBlock.getZ());

      if (we.handleBlockRightClick(player, pos)) {
        event.setCancelled(true);
      }

      if (we.handleRightClick(player)) {
        event.setCancelled(true);
      }
    } else if (action == Action.RIGHT_CLICK_AIR) {
      if (we.handleRightClick(player)) {
        event.setCancelled(true);
      }
    }
  }