@Override
 public void run(final String cmd, String parameters) {
   parameters = parameters.trim();
   if (!parameters.equals("clear")) {
     SpecialOutfit.createExplicitCheckpoint();
     KoLmafia.updateDisplay("Internal checkpoint created.");
     return;
   } else if (parameters.equals("clear")) {
     SpecialOutfit.forgetCheckpoints();
     KoLmafia.updateDisplay("Checkpoints cleared.");
   }
 }
 @Override
 public void run(String command, final String parameters) {
   if (command.equals("overdrink")) {
     DrinkItemRequest.permitOverdrink();
     command = "drink";
   } else if (command.equals("eatsilent")) {
     EatItemRequest.ignoreMilkPrompt();
     command = "eat";
   }
   SpecialOutfit.createImplicitCheckpoint();
   UseItemCommand.use(command, parameters);
   SpecialOutfit.restoreImplicitCheckpoint();
 }
    private void buff(boolean maxBuff) {
      UseSkillRequest request = (UseSkillRequest) SkillBuffFrame.this.skillSelect.getSelectedItem();
      if (request == null) {
        return;
      }

      String buffName = request.getSkillName();
      if (buffName == null) {
        return;
      }

      String[] targets =
          StaticEntity.getClient()
              .extractTargets((String) SkillBuffFrame.this.targetSelect.getSelectedItem());

      int buffCount =
          !maxBuff
              ? InputFieldUtilities.getValue(SkillBuffFrame.this.amountField, 1)
              : Integer.MAX_VALUE;
      if (buffCount == 0) {
        return;
      }

      SpecialOutfit.createImplicitCheckpoint();

      if (targets.length == 0) {
        RequestThread.postRequest(
            UseSkillRequest.getInstance(buffName, KoLCharacter.getUserName(), buffCount));
      } else {
        for (int i = 0; i < targets.length && KoLmafia.permitsContinue(); ++i) {
          if (targets[i] != null) {
            RequestThread.postRequest(UseSkillRequest.getInstance(buffName, targets[i], buffCount));
          }
        }
      }

      SpecialOutfit.restoreImplicitCheckpoint();
    }
Esempio n. 4
0
  /**
   * Initializes the <code>KoLmafia</code> session. Called after the login has been confirmed to
   * notify that the login was successful, the user-specific settings should be loaded, and the user
   * can begin adventuring.
   */
  public static void initialize(final String username) {
    // Load the JSON string first, so we can use it, if necessary.
    ActionBarManager.loadJSONString();

    // Initialize the variables to their initial states to avoid
    // null pointers getting thrown all over the place

    // Do this first to reset per-player item aliases
    ItemDatabase.reset();

    KoLCharacter.reset(username);

    // Get rid of cached password hashes in KoLAdventures
    AdventureDatabase.refreshAdventureList();

    // Reset all per-player information

    ChatManager.reset();
    MailManager.clearMailboxes();
    StoreManager.clearCache();
    DisplayCaseManager.clearCache();
    ClanManager.clearCache();

    CampgroundRequest.reset();
    MushroomManager.reset();
    HermitRequest.initialize();
    SpecialOutfit.forgetCheckpoints();

    KoLmafia.updateDisplay("Initializing session for " + username + "...");
    Preferences.setString("lastUsername", username);

    // Perform requests to read current character's data

    StaticEntity.getClient().refreshSession();

    // Reset the session tally and encounter list

    StaticEntity.getClient().resetSession();

    // Open the session log and indicate that we've logged in.

    RequestLogger.openSessionLog();

    if (Preferences.getBoolean("logStatusOnLogin")) {
      KoLmafiaCLI.DEFAULT_SHELL.executeCommand("log", "snapshot");
    }

    // If the password hash is non-null, then that means you
    // might be mid-transition.

    if (GenericRequest.passwordHash.equals("")) {
      PasswordHashRequest request = new PasswordHashRequest("lchat.php");
      RequestThread.postRequest(request);
    }

    ContactManager.registerPlayerId(username, String.valueOf(KoLCharacter.getUserId()));

    if (Preferences.getString("spadingData").length() > 10) {
      KoLmafia.updateDisplay(
          "Some data has been collected that may be of interest "
              + "to others.  Please type `spade' to examine and submit or delete this data.");
    }

    // Rebuild Scripts menu if needed
    GenericFrame.compileScripts();

    if (StaticEntity.getClient() instanceof KoLmafiaGUI) {
      KoLmafiaGUI.intializeMainInterfaces();
    } else if (Preferences.getString("initialFrames").indexOf("LocalRelayServer") != -1) {
      KoLmafiaGUI.constructFrame("LocalRelayServer");
    }

    String updateText;

    String holiday = HolidayDatabase.getHoliday(true);
    String moonEffect = HolidayDatabase.getMoonEffect();

    if (holiday.equals("")) {
      updateText = moonEffect;
    } else {
      updateText = holiday + ", " + moonEffect;
    }

    KoLmafia.updateDisplay(updateText);

    if (MailManager.hasNewMessages()) {
      KoLmafia.updateDisplay("You have new mail.");
    }
  }