Exemple #1
0
  /** Starts action after cheat was entered. */
  private void startCheat(final String cheat) {
    if (!editEnabled) {
      addCommand(cheat);
    }
    if (!editEnabled && GOD_ON.equals(cheat)) {
      editEnabled = true;
      Tools.getGUIData().godModeChanged(editEnabled);
    } else if (editEnabled && GOD_OFF.equals(cheat)) {
      editEnabled = false;
      Tools.getGUIData().godModeChanged(editEnabled);
    } else if (CHEAT_LIST.equals(cheat)) {
      final StringBuilder list = new StringBuilder();
      for (final String ch : CHEATS_MAP.keySet()) {
        list.append(ch);
        list.append('\n');
      }
      addCommandOutput(list.toString());
    } else if (RUN_GC.equals(cheat)) {
      System.gc();
      Tools.info("run gc");
    } else if (ALLOCATE_10.equals(cheat)) {
      final Thread t =
          new Thread(
              new Runnable() {
                @Override
                public void run() {
                  Tools.info("allocate mem");
                  Byte[] b = new Byte[1024000];
                  Tools.info("allocate mem done.");

                  System.gc();
                  Tools.info("run gc");
                  Tools.sleep(60000);
                  Tools.info("free mem.");
                }
              });
      t.start();
    } else if (CLICKTEST_SHORT.equals(cheat)) {
      RoboTest.startClicker(1, false);
    } else if (CLICKTEST_LONG.equals(cheat)) {
      RoboTest.startClicker(8 * 60, false);
    } else if (CLICKTEST_LAZY_SHORT.equals(cheat)) {
      RoboTest.startClicker(1, true);
    } else if (CLICKTEST_LAZY_LONG.equals(cheat)) {
      RoboTest.startClicker(8 * 60, true); /* 8 hours */
    } else if (RIGHT_CLICKTEST_SHORT.equals(cheat)) {
      RoboTest.startRightClicker(1, false);
    } else if (RIGHT_CLICKTEST_LONG.equals(cheat)) {
      RoboTest.startRightClicker(8 * 60, false);
    } else if (RIGHT_CLICKTEST_LAZY_SHORT.equals(cheat)) {
      RoboTest.startRightClicker(1, true);
    } else if (RIGHT_CLICKTEST_LAZY_LONG.equals(cheat)) {
      RoboTest.startRightClicker(8 * 60, true); /* 8 hours */
    } else if (MOVETEST_SHORT.equals(cheat)) {
      RoboTest.startMover(1, false);
    } else if (MOVETEST_LONG.equals(cheat)) {
      RoboTest.startMover(8 * 60, false);
    } else if (MOVETEST_LAZY_SHORT.equals(cheat)) {
      RoboTest.startMover(1, true);
    } else if (MOVETEST_LAZY_LONG.equals(cheat)) {
      RoboTest.startMover(8 * 60, true);
    } else if (DEBUG_INC.equals(cheat)) {
      Tools.incrementDebugLevel();
    } else if (DEBUG_DEC.equals(cheat)) {
      Tools.decrementDebugLevel();
    } else if (TESTS.containsKey(cheat)) {
      RoboTest.startTest(TESTS.get(cheat), host.getCluster());
    } else if (REGISTER_MOVEMENT.equals(cheat)) {
      RoboTest.registerMovement();
    }
    nextCommand();
  }