Esempio n. 1
0
 @Command(
     identifier = "heal",
     permissions = {Perms.COMMAND_HEAL})
 public void onHealCommand(Player player, @Arg(name = "target", def = "?sender") Player target) {
   Players.heal(target);
   Chat.message(target, Messages.PLAYER_HEALED);
   // If the player using the command healed themself.
   if (!target.getUniqueId().equals(player.getUniqueId())) {
     if (!player.hasPermission(Perms.COMMAND_HEAL_OTHER)) {
       Chat.message(player, Messages.permissionRequired(Perms.COMMAND_HEAL_OTHER));
       return;
     }
     Chat.message(player, Messages.playerHealed(target.getName()));
   }
 }
  @Override
  public void run() {
    if (messageIndex >= finalIndex) {
      Commons.getInstance().getThreadManager().cancelTask(taskId);
      return;
    }

    Player player = Players.getPlayer(playerId);
    if (messageCooldown.isOnCooldown(player)) {
      return;
    }
    try {
      String message = messages[messageIndex];
      Chat.message(player, message);
      Sounds.playSound(player, sound);
      messageCooldown.setOnCooldown(player);
      messageIndex++;
    } catch (IndexOutOfBoundsException e) {
      Commons.getInstance()
          .debug(
              "Uh oh! Message index["
                  + messageIndex
                  + "] doesn't exist!\n"
                  + StringUtil.joinString(messages, "\n"));
    }
  }
  public static void loadItem(File file) {
    String itemName = FilenameUtils.removeExtension(file.getName());

    XmlItemStack item = null;
    try {
      item = serializer.read(XmlItemStack.class, file);
    } catch (Exception e) {
      e.printStackTrace();
    }

    if (item == null) {
      return;
    }

    items.put(itemName, item.getItemStack());
    Chat.debug(
        String.format(
            "Loaded item %s",
            StringUtil.joinString(Messages.itemInfo(item.getItemStack()), "\n", 0)));
  }