public int getBalance() throws LogonException {
    if (!session.alreadyLoggedOn())
      throw new LogonException("Not Logged On; Session does not exist");

    GetBalanceRequest getBalanceRequest = new GetBalanceRequest();
    getBalanceRequest.setSessionId(session.getSessionId());

    return ((GetBalanceResponse) wsTemplate.marshalSendAndReceive(getBalanceRequest)).getBalance();
  }
  public void submitQuest(int questID) throws LogonException {
    if (!session.alreadyLoggedOn())
      throw new LogonException("Not Logged On; Session does not exist");

    SubmitQuestRequest submitQuestRequest = new SubmitQuestRequest();
    submitQuestRequest.setSessionId(session.getSessionId());
    submitQuestRequest.setQuestID(questID);

    wsTemplate.marshalSendAndReceive(submitQuestRequest);
  }
  public List<BuildingInfo> getBuildings() throws LogonException {
    if (!session.alreadyLoggedOn())
      throw new LogonException("Not Logged On; Session does not exist");

    GetBuildingsRequest getBuildingsRequest = new GetBuildingsRequest();
    getBuildingsRequest.setSessionId(session.getSessionId());

    return ((GetBuildingsResponse) wsTemplate.marshalSendAndReceive(getBuildingsRequest))
        .getPayload()
        .getGetBuildingsResponseMessage()
        .getBuildings();
  }
  public List<QuestNPCInfo> getQuests(int npcID) throws LogonException {
    if (!session.alreadyLoggedOn())
      throw new LogonException("Not Logged On; Session does not exist");

    GetQuestsNPCRequest questsNPCRequest = new GetQuestsNPCRequest();
    questsNPCRequest.setSessionId(session.getSessionId());
    questsNPCRequest.setNPCID(npcID);

    GetQuestsNPCResponse getQuestsNPCResponse =
        (GetQuestsNPCResponse) wsTemplate.marshalSendAndReceive(questsNPCRequest);

    return getQuestsNPCResponse.getPayload().getQuestsNPCResponseMessage().getQuests();
  }
  public String respawn() throws LogonException {

    // Make sure user is already logged on before letting them logout
    if (!session.alreadyLoggedOn())
      throw new LogonException("Not Logged On; Session does not exist");

    RespawnRequest respawnRequest = new RespawnRequest();
    respawnRequest.setSessionId(session.getSessionId());

    RespawnResponse logoutResponse =
        (RespawnResponse) wsTemplate.marshalSendAndReceive(respawnRequest);

    return logoutResponse.getStatus();
  }
  public void logout() throws LogonException {

    // Make sure user is already logged on before letting them logout
    if (!session.alreadyLoggedOn())
      throw new LogonException("You must first be logged on before calling Logout");

    LogoutRequest logoutRequest = new LogoutRequest();
    logoutRequest.setSessionId(session.getSessionId());

    LogoutResponse logoutResponse =
        (LogoutResponse) wsTemplate.marshalSendAndReceive(logoutRequest);
    System.out.println("logout response = " + logoutResponse.getStatus());
    session.wipe();
  }
  public String runAdminCommand(String adminCommand) throws LogonException {

    // Make sure user is  already logged on
    if (!session.alreadyLoggedOn())
      throw new LogonException("Not Logged On; Session does not exist");

    AdminCommandRequest adminCommandRequest = new AdminCommandRequest();
    adminCommandRequest.setSessionId(session.getSessionId());
    adminCommandRequest.setCommand(adminCommand);

    AdminCommandResponse adminCommandResponse =
        (AdminCommandResponse) wsTemplate.marshalSendAndReceive(adminCommandRequest);

    return adminCommandResponse.getStatus();
  }
  public List<String> playerAttack() throws LogonException {
    if (!session.alreadyLoggedOn())
      throw new LogonException("Not Logged On; Session does not exist");

    AttackEntityRequest attackEntityRequest = new AttackEntityRequest();
    attackEntityRequest.setSessionId(session.getSessionId());

    AttackEntityResponse attackEntityResponse =
        (AttackEntityResponse) wsTemplate.marshalSendAndReceive(attackEntityRequest);

    try {
      return attackEntityResponse.getPayload().getEntity();
    } catch (Exception e) {
      return null;
    }
  }
  public void login() throws LogonException {

    // Make sure user is not already logged on
    if (session.alreadyLoggedOn()) throw new LogonException("Already Logged On; Session Exists");

    LoginRequest loginRequest = new LoginRequest();
    loginRequest.setUserName(session.getUserName());

    LoginResponse loginResponse = (LoginResponse) wsTemplate.marshalSendAndReceive(loginRequest);
    System.out.println("login response = " + loginResponse.getSessionId());

    // See if the server returned an error.  If so, throw it to caller as an exception
    if (loginResponse.getSessionId().equalsIgnoreCase("Already Logged On"))
      throw new LogonException(loginResponse.getSessionId());

    session.setSessionId(loginResponse.getSessionId());
  }
  public double[] updateLocation(double x, double y) throws LogonException {

    // Make sure user is  already logged on
    if (!session.alreadyLoggedOn())
      throw new LogonException("Not Logged On; Session does not exist");

    SetMyLocationRequest setMyLocationRequest = new SetMyLocationRequest();
    setMyLocationRequest.setSessionId(session.getSessionId());
    setMyLocationRequest.setXCooridinate(x);
    setMyLocationRequest.setYCooridinate(y);

    SetMyLocationResponse setMyLocationResponse =
        (SetMyLocationResponse) wsTemplate.marshalSendAndReceive(setMyLocationRequest);

    return new double[] {
      setMyLocationResponse.getModifiedLocationX(), setMyLocationResponse.getModifiedLocationY()
    };
  }
  public List<NPCInfo> getNPCInfo() throws LogonException {

    // Make sure user is  already logged on
    if (!session.alreadyLoggedOn())
      throw new LogonException("Not Logged On; Session does not exist");

    // Finally try to get a list of user locations
    GetNPCInfoRequest getNPCInfoRequest = new GetNPCInfoRequest();
    getNPCInfoRequest.setSessionId(session.getSessionId());

    GetNPCInfoResponse getNPCInfoResponse =
        (GetNPCInfoResponse) wsTemplate.marshalSendAndReceive(getNPCInfoRequest);
    List<NPCInfo> npcList;

    try {
      npcList = getNPCInfoResponse.getPayload().getNPCInfoResponseMessage().getNPCs();
    } catch (NullPointerException e) {
      npcList = null;
    }

    return npcList;
  }