Ejemplo n.º 1
0
  private void handleToggleItemShareCategory(Party party, ItemShareType type, boolean toggle) {
    party.setSharingDrops(type, toggle);

    String toggleMessage =
        LocaleLoader.getString(
            "Commands.Party.ToggleShareCategory",
            StringUtils.getCapitalized(type.toString()),
            toggle ? "enabled" : "disabled");

    for (Player member : party.getOnlineMembers()) {
      member.sendMessage(toggleMessage);
    }
  }
Ejemplo n.º 2
0
  @Override
  public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    Party party = UserManager.getPlayer((Player) sender).getParty();

    if (party.getLevel()
        < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.ITEM_SHARE)) {
      sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.4"));
      return true;
    }

    switch (args.length) {
      case 2:
        ShareMode mode = ShareMode.getShareMode(args[1].toUpperCase());

        if (mode == null) {
          sender.sendMessage(
              LocaleLoader.getString(
                  "Commands.Usage.2", "party", "itemshare", "<NONE | EQUAL | RANDOM>"));
          return true;
        }

        handleChangingShareMode(party, mode);
        return true;

      case 3:
        boolean toggle;

        if (CommandUtils.shouldEnableToggle(args[2])) {
          toggle = true;
        } else if (CommandUtils.shouldDisableToggle(args[2])) {
          toggle = false;
        } else {
          sender.sendMessage(
              LocaleLoader.getString(
                  "Commands.Usage.2",
                  "party",
                  "itemshare",
                  "<loot | mining | herbalism | woodcutting | misc> <true | false>"));
          return true;
        }

        try {
          handleToggleItemShareCategory(
              party, ItemShareType.valueOf(args[1].toUpperCase()), toggle);
        } catch (IllegalArgumentException ex) {
          sender.sendMessage(
              LocaleLoader.getString(
                  "Commands.Usage.2",
                  "party",
                  "itemshare",
                  "<loot | mining | herbalism | woodcutting | misc> <true | false>"));
        }

        return true;

      default:
        sender.sendMessage(
            LocaleLoader.getString(
                "Commands.Usage.2", "party", "itemshare", "<NONE | EQUAL | RANDOM>"));
        sender.sendMessage(
            LocaleLoader.getString(
                "Commands.Usage.2",
                "party",
                "itemshare",
                "<loot | mining | herbalism | woodcutting | misc> <true | false>"));
        return true;
    }
  }