mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 09:01:08 +03:00
[FEATURE][EXPERIMENTAL] New API: TextureUploadExtension
This commit is contained in:
parent
f6b3a62497
commit
3afe77bf34
7 changed files with 77 additions and 2 deletions
|
@ -15,6 +15,7 @@
|
|||
import java.net.InetSocketAddress;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public final class ClientProfile implements Comparable<ClientProfile>, ProfileFeatureAPI.ClientProfile {
|
||||
private static final FileNameMatcher ASSET_MATCHER = new FileNameMatcher(
|
||||
|
@ -287,10 +288,25 @@ public String toString() {
|
|||
return String.format("%s (%s)", title, uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public UUID getUUID() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProfileFeatureAPI.OptionalMod> getOptionalMods() {
|
||||
return updateOptional.stream().collect(Collectors.toUnmodifiableList());
|
||||
}
|
||||
|
||||
public boolean hasFlag(CompatibilityFlags flag) {
|
||||
return flags.contains(flag);
|
||||
}
|
||||
|
|
|
@ -2,11 +2,12 @@
|
|||
|
||||
import pro.gravit.launcher.core.LauncherNetworkAPI;
|
||||
import pro.gravit.launcher.base.profiles.optional.actions.OptionalAction;
|
||||
import pro.gravit.launcher.core.api.features.ProfileFeatureAPI;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class OptionalFile {
|
||||
public class OptionalFile implements ProfileFeatureAPI.OptionalMod {
|
||||
@LauncherNetworkAPI
|
||||
public List<OptionalAction> actions;
|
||||
@LauncherNetworkAPI
|
||||
|
@ -57,6 +58,16 @@ public String getName() {
|
|||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return visible;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
import pro.gravit.launcher.core.hasher.HashedDir;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
|
@ -15,12 +16,16 @@ interface UpdateInfo {}
|
|||
interface ClientProfile {
|
||||
String getName();
|
||||
UUID getUUID();
|
||||
String getDescription();
|
||||
List<OptionalMod> getOptionalMods();
|
||||
String getProperty(String name);
|
||||
Map<String, String> getProperties();
|
||||
}
|
||||
|
||||
interface OptionalMod {
|
||||
String getName();
|
||||
String getDescription();
|
||||
String getCategory();
|
||||
boolean isVisible();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package pro.gravit.launcher.core.api.features;
|
||||
|
||||
import pro.gravit.launcher.core.api.model.Texture;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public interface TextureUploadFeatureAPI {
|
||||
CompletableFuture<TextureUploadInfo> fetchInfo();
|
||||
CompletableFuture<Texture> upload(String name, byte[] bytes, UploadSettings settings);
|
||||
|
||||
interface TextureUploadInfo {
|
||||
Set<String> getAvailable();
|
||||
boolean isRequireManualSlimSkinSelect();
|
||||
}
|
||||
|
||||
record UploadSettings(boolean slim) {
|
||||
|
||||
}
|
||||
}
|
|
@ -1,10 +1,12 @@
|
|||
package pro.gravit.launcher.core;
|
||||
package pro.gravit.launcher.core.backend;
|
||||
|
||||
import pro.gravit.launcher.core.api.features.ProfileFeatureAPI;
|
||||
import pro.gravit.launcher.core.api.method.AuthMethod;
|
||||
import pro.gravit.launcher.core.api.method.AuthMethodPassword;
|
||||
import pro.gravit.launcher.core.api.model.SelfUser;
|
||||
import pro.gravit.launcher.core.api.model.Texture;
|
||||
import pro.gravit.launcher.core.api.model.UserPermissions;
|
||||
import pro.gravit.launcher.core.backend.extensions.Extension;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
@ -20,6 +22,12 @@ public interface LauncherBackendAPI {
|
|||
CompletableFuture<ReadyProfile> downloadProfile(ProfileFeatureAPI.ClientProfile profile, ClientProfileSettings settings, DownloadCallback callback);
|
||||
// Tools
|
||||
CompletableFuture<byte[]> fetchTexture(Texture texture);
|
||||
// Status
|
||||
UserPermissions getPermissions();
|
||||
boolean hasPermission(String permission);
|
||||
String getUsername();
|
||||
// Extensions
|
||||
<T extends Extension> T getExtension(Class<T> clazz);
|
||||
|
||||
record LauncherInitData(List<AuthMethod> methods) {}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
package pro.gravit.launcher.core.backend.extensions;
|
||||
|
||||
public interface Extension {
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package pro.gravit.launcher.core.backend.extensions;
|
||||
|
||||
import pro.gravit.launcher.core.api.features.TextureUploadFeatureAPI;
|
||||
import pro.gravit.launcher.core.api.model.Texture;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public interface TextureUploadExtension extends Extension {
|
||||
CompletableFuture<TextureUploadFeatureAPI.TextureUploadInfo> fetchTextureUploadInfo();
|
||||
CompletableFuture<Texture> uploadTexture(String name, byte[] bytes, TextureUploadFeatureAPI.UploadSettings settings);
|
||||
}
|
Loading…
Reference in a new issue