Merge remote-tracking branch 'runelite/master'

This commit is contained in:
Owain van Brakel
2020-04-18 23:38:58 +02:00
32 changed files with 812 additions and 280 deletions

View File

@@ -29,6 +29,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import net.runelite.http.api.RuneLiteAPI;
import okhttp3.Call;
import okhttp3.Callback;
@@ -77,8 +78,10 @@ public class ConfigClient
}
}
public void set(String key, String value)
public CompletableFuture<Void> set(String key, String value)
{
CompletableFuture<Void> future = new CompletableFuture<>();
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
.addPathSegment("config")
.addPathSegment(key)
@@ -98,6 +101,7 @@ public class ConfigClient
public void onFailure(Call call, IOException e)
{
logger.warn("Unable to synchronize configuration item", e);
future.completeExceptionally(e);
}
@Override
@@ -105,12 +109,17 @@ public class ConfigClient
{
response.close();
logger.debug("Synchronized configuration value '{}' to '{}'", key, value);
future.complete(null);
}
});
return future;
}
public void unset(String key)
public CompletableFuture<Void> unset(String key)
{
CompletableFuture<Void> future = new CompletableFuture<>();
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
.addPathSegment("config")
.addPathSegment(key)
@@ -130,6 +139,7 @@ public class ConfigClient
public void onFailure(Call call, IOException e)
{
logger.warn("Unable to unset configuration item", e);
future.completeExceptionally(e);
}
@Override
@@ -137,7 +147,10 @@ public class ConfigClient
{
response.close();
logger.debug("Unset configuration value '{}'", key);
future.complete(null);
}
});
return future;
}
}

View File

@@ -33,6 +33,7 @@ import java.io.InputStreamReader;
import java.util.Collection;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.runelite.http.api.RuneLiteAPI;
@@ -52,8 +53,10 @@ public class LootTrackerClient
private final UUID uuid;
public void submit(Collection<LootRecord> lootRecords)
public CompletableFuture<Void> submit(Collection<LootRecord> lootRecords)
{
CompletableFuture<Void> future = new CompletableFuture<>();
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
.addPathSegment("loottracker")
.build();
@@ -71,6 +74,7 @@ public class LootTrackerClient
public void onFailure(Call call, IOException e)
{
log.warn("unable to submit loot", e);
future.completeExceptionally(e);
}
@Override
@@ -78,8 +82,11 @@ public class LootTrackerClient
{
log.debug("Submitted loot");
response.close();
future.complete(null);
}
});
return future;
}
public Collection<LootRecord> get() throws IOException