private void usePowertools(final PlayerAnimationEvent event) {
    if (event.getAnimationType() != PlayerAnimationType.ARM_SWING) {
      return;
    }
    final User user = ess.getUser(event.getPlayer());
    final ItemStack is = user.getItemInHand();
    if (is == null || is.getType() == Material.AIR || !user.arePowerToolsEnabled()) {
      return;
    }
    final List<String> commandList = user.getPowertool(is);
    if (commandList == null || commandList.isEmpty()) {
      return;
    }

    // We need to loop through each command and execute
    for (String command : commandList) {
      if (command.matches(".*\\{player\\}.*")) {
        // user.sendMessage("Click a player to use this command");
        continue;
      } else if (command.startsWith("c:")) {
        for (Player p : server.getOnlinePlayers()) {
          p.sendMessage(user.getDisplayName() + ":" + command.substring(2));
        }
      } else {
        user.getServer().dispatchCommand(event.getPlayer(), command);
      }
    }
  }
 @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
 public void onPlayerMovesArm(PlayerAnimationEvent event) {
   if (event.getAnimationType() == PlayerAnimationType.ARM_SWING) {
     plugin
         .getServer()
         .getScheduler()
         .runTask(plugin, new ResetIgnoreSleepTask(plugin, event.getPlayer().getName()));
   }
 }
Beispiel #3
0
  @EventHandler(priority = EventPriority.NORMAL)
  public void onPlayerAnimation(PlayerAnimationEvent event) {
    VPlayer vplayer = VPlayers.i.get(event.getPlayer());
    if (!vplayer.isVampire()) return;

    if (event.getAnimationType() == PlayerAnimationType.ARM_SWING
        && Conf.jumpMaterials.contains(event.getPlayer().getItemInHand().getType())) {
      vplayer.jump(Conf.jumpDeltaSpeed, true);
    }
  }