Class Client

java.lang.Object
io.github.archipelagomw.Client

public abstract class Client extends Object
  • Field Details

  • Constructor Details

    • Client

      public Client()
  • Method Details

    • setGame

      public void setGame(String game)
      Sets the name of the game to send to Archipelago's servers
      Parameters:
      game - the name of your game.
    • setTags

      public APResult<Void> setTags(Set<String> tags)
      overwrite, and set all tags sent to the Archipelago server. this will overwrite any previous tags that have been set.
      Parameters:
      tags - a Set of tags to send.
      Returns:
      Whether the send was successful or not
    • addTag

      public APResult<Void> addTag(String tag)
      add a tag to your list, keeping all previous tags intact.
      Parameters:
      tag - String tag to be added.
      Returns:
      Whether the send was successful or not
    • removeTag

      public APResult<Void> removeTag(String tag)
      removes supplied tag, if it exists.
      Parameters:
      tag - String tag to be removed.
      Returns:
      Whether the send was successful or not
    • getUUID

      public static String getUUID()
      Gets the UUID of clients on this machine
      Returns:
      UUID of the client, this should theoretically never change.
    • loadDataPackage

      protected void loadDataPackage()
    • saveDataPackage

      public void saveDataPackage()
    • isConnected

      public boolean isConnected()
      Returns true only if connected to an Archipelago server.
      Returns:
      true if connected, otherwise false
    • close

      public void close()
      closes a connection to the Archipelago server if connected.
    • setPassword

      public void setPassword(String password)
      sets a password to authenticate with to join a password protected room.
      Parameters:
      password - room password
    • setName

      public void setName(String name)
      sets the slot name to connect to an Archcipelago server with.
      Parameters:
      name -
    • getTeam

      public int getTeam()
      Returns:
      team ID
    • getSlot

      public int getSlot()
      Returns:
      Slot ID
    • getRoomInfo

      public RoomInfoPacket getRoomInfo()
      fetches the
      Returns:
      Room info.
    • getSlotInfo

      public Map<Integer,NetworkSlot> getSlotInfo()
    • connect

      public void connect(String address) throws URISyntaxException
      Works exactly like connect(URI, boolean) with allowDowngrade set to true;
      Parameters:
      address -
      Throws:
      URISyntaxException - on malformed address
    • connect

      public void connect(URI address)
      Works exactly like connect(URI, boolean) but allowDowngrade is False
      Parameters:
      address - Address to connect to
    • connect

      public void connect(URI address, boolean allowDowngrade)
      Equivalent to connect(URI, boolean, SocketFactory) socketFactory being null.
    • connect

      public void connect(URI address, boolean allowDowngrade, SocketFactory socketFactory)
      Connects to an Archipelago server with previously provided info.
      supply the following info before calling this method
      game: setGame(String)
      slot name: setName(String)

      if no protocol wss:// or ws:// is given will attempt a ssl connection to the supplied address, if that fails it will then try a non-ssl connection, unless allowDowngrade is false.

      Do not prefix address with wss:// or ws://. let the user enter a protocol to use. by default ssl will be tried first, if that fails then non-ssl will be used. unless allowDowngrade is set to false.
      Parameters:
      address - address of the archipelago server.
      allowDowngrade - if set to false will prevent auto downgrade of ssl connection.
    • sendChat

      public APResult<Void> sendChat(String message)
      Sends a Chat message to all other connected Clients.
      Parameters:
      message - Message to send.
      Returns:
      Whether the send was successful or not
    • checkLocation

      public APResult<Void> checkLocation(long locationID)
      inform the Archipelago server that a location ID has been checked.
      Parameters:
      locationID - id of a location.
      Returns:
      Whether send was successful or not
    • checkLocations

      public APResult<Void> checkLocations(Collection<Long> locationIDs)
      inform the Archipelago server that a collection of location ID has been checked.
      Parameters:
      locationIDs - a collection of a locations.
      Returns:
      Whether send was successful or not
    • scoutLocations

      public APResult<Void> scoutLocations(ArrayList<Long> locationIDs)
      Ask the server for information about what is in locations. you will get a response in the LocationInfoEvent event.
      Parameters:
      locationIDs - List of location ID's to request info on.
      Returns:
      Whether the send was successful or not
    • scoutLocations

      public APResult<Void> scoutLocations(ArrayList<Long> locationIDs, CreateAsHint createAsHint)
      Ask the server for information about what is in locations. you will get a response in the LocationInfoEvent event.
      Parameters:
      locationIDs - List of location ID's to request info on.
      createAsHint - Whether to create hints for the provided locations
      Returns:
      Whether the send was successful or not
    • onError

      public abstract void onError(Exception ex)
    • onClose

      public abstract void onClose(String Reason, int attemptingReconnect)
    • getDataPackage

      public DataPackage getDataPackage()
    • getMyName

      public String getMyName()
    • getPassword

      public String getPassword()
    • getHintPoints

      public int getHintPoints()
    • getGame

      public String getGame()
    • getConnectedAddress

      public String getConnectedAddress()
    • reconnect

      public void reconnect()
      this should not need to be called externally but is left public just in case.
    • getAlias

      public String getAlias()
      gets the alias of this slot.
      Returns:
      Alias of the slot connected to.
    • getLocationManager

      public LocationManager getLocationManager()
    • getItemManager

      public ItemManager getItemManager()
    • ensureConnectedAndAuth

      protected <T> APResult<T> ensureConnectedAndAuth()
    • setGameState

      public APResult<Void> setGameState(ClientStatus status)
      Update the current game status.
      Parameters:
      status - a ClientStatus to send to the server.
      Returns:
      Whether the send was successful or not
      See Also:
    • sync

      public APResult<Void> sync()
      manually trigger a resync to the Archipelago server. this should be done automatically if the library detects a desync.
      Returns:
      Whether the send was successful or not
    • sendBounce

      public APResult<Void> sendBounce(BouncePacket bouncePacket)
      sends a bouncepacket to the server, such as for deathlink
      Parameters:
      bouncePacket - The packet to send
      Returns:
      Whether the send was successful or not
    • disconnect

      public void disconnect()
      disconnects from a connected Archipelago server.
    • getTags

      public Set<String> getTags()
      Returns:
      set of tags currently in use.
    • getItemsHandlingFlags

      public int getItemsHandlingFlags()
      fetch the itemflags that have been set, bitwise Or against ItemsHandling to read.
      Returns:
      items handling int.
    • setItemsHandlingFlags

      public void setItemsHandlingFlags(int itemsHandlingFlags)
      fetch the itemflags that have been set, bitwise Or against ItemsHandling to read.
    • getEventManager

      public EventManager getEventManager()
      Returns:
      the event manager.
    • getBouncedManager

      public BouncedManager getBouncedManager()
      Returns:
      the bounced packet handler
    • dataStorageSet

      public APResult<Integer> dataStorageSet(SetPacket setPacket)
      Uses DataStorage to save a value on the AP server.
      Returns:
      Whether the send was successful or not, and the requestId
    • dataStorageSetNotify

      public APResult<Void> dataStorageSetNotify(Collection<String> keys)
      Registers to receive updates of when a key in the Datastorage has been changed on the server.
      Parameters:
      keys - List of Keys to be notified of.
      Returns:
      Whether the send was successful or not
    • dataStorageGet

      public APResult<Integer> dataStorageGet(Collection<String> keys)
      Uses DataStorage to reterieve a value from the server will get value back though a RetrievedEvent.
      see following table for list of reserved keys.
      Name Type Notes
      hints_{team}_{slot} list[Hint] All Hints belonging to the requested Player.
      slot_data_{slot} dict[str, any] slot_data belonging to the requested slot.
      item_name_groups_{game_name} dict[str, list[str]] item_name_groups belonging to the requested game.
      location_name_groups_{game_name} dict[str, list[str]] location_name_groups belonging to the requested game.
      client_status_{team}_{slot} ClientStatus The current game status of the requested player.
      race_mode int 0 if race mode is disabled, and 1 if it's enabled.
      Parameters:
      keys - a list of keys to retrieve values for
      Returns:
      Whether the send was successful or not, and the requestId
    • sendDeathlink

      public APResult<Void> sendDeathlink(String source, String cause)
      Helper for sending a death link bounce packet. You can send these without enabling death link first, but it is frowned upon.
      Parameters:
      source - A String that is the name of the player sending the death link (does not have to be slot name)
      cause - A String that is the cause of this death. may be empty.
      Returns:
      Whether the send was successful or not
    • setDeathLinkEnabled

      public APResult<Void> setDeathLinkEnabled(boolean enabled)
      Enable or disable receiving death links.
      Parameters:
      enabled - set to TRUE to enable death links, FALSE to disable.
      Returns:
      Whether the send was successful or not
    • sendPackets

      public APResult<Void> sendPackets(List<APPacket> packets)
      Enables sending multiple packets at once.
      Parameters:
      packets - The packets to send
      Returns:
      Whether the send was successful
    • createHints

      public APResult<Void> createHints(List<Long> locations, int player, HintStatus status)
      Creates hints for the provided locations
      Parameters:
      locations - The locations to hint for.
      player - The id of the player whose locations are being hinted for
      status - Sets the status of the hint to this status; server rejects HINT_FOUND
      Returns:
      Whether the send was successful
    • createHints

      public APResult<Void> createHints(List<Long> locations, int player)
      Creates hints for the provided locations
      Parameters:
      locations - The locations to hint for.
      player - The id of the player whose locations are being hinted for
      Returns:
      Whether the send was successful
    • createHints

      public APResult<Void> createHints(List<Long> locations)
      Creates hints for the provided locations with this client's slot
      Parameters:
      locations - The locations to hint for.
      Returns:
      Whether the send was successful