mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
[FEATURE] UploadAssetMixProvider
This commit is contained in:
parent
183cfe949f
commit
1f3b7e0552
4 changed files with 42 additions and 6 deletions
|
@ -6,6 +6,8 @@
|
|||
import pro.gravit.launchserver.auth.Feature;
|
||||
import pro.gravit.launchserver.auth.core.User;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@Feature(GetAssetUploadUrlRequestEvent.FEATURE_NAME)
|
||||
public interface AuthSupportAssetUpload {
|
||||
String getAssetUploadUrl(String name, User user);
|
||||
|
@ -15,6 +17,6 @@ default AuthRequestEvent.OAuthRequestEvent getAssetUploadToken(String name, User
|
|||
}
|
||||
|
||||
default AssetUploadInfoRequestEvent getAssetUploadInfo(User user) {
|
||||
return new AssetUploadInfoRequestEvent(true, true, AssetUploadInfoRequestEvent.SlimSupportConf.USER);
|
||||
return new AssetUploadInfoRequestEvent(Set.of("SKIN", "CAPE"), AssetUploadInfoRequestEvent.SlimSupportConf.USER);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ public abstract class MixProvider implements AutoCloseable{
|
|||
|
||||
public static void registerProviders() {
|
||||
if (!registredProviders) {
|
||||
providers.register("uploadAsset", UploadAssetMixProvider.class);
|
||||
registredProviders = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package pro.gravit.launchserver.auth.mix;
|
||||
|
||||
import pro.gravit.launcher.events.request.AssetUploadInfoRequestEvent;
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.auth.core.AuthCoreProvider;
|
||||
import pro.gravit.launchserver.auth.core.User;
|
||||
import pro.gravit.launchserver.auth.core.interfaces.provider.AuthSupportAssetUpload;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class UploadAssetMixProvider extends MixProvider implements AuthSupportAssetUpload {
|
||||
public Map<String, String> urls;
|
||||
public AssetUploadInfoRequestEvent.SlimSupportConf slimSupportConf;
|
||||
|
||||
@Override
|
||||
public String getAssetUploadUrl(String name, User user) {
|
||||
return urls.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AssetUploadInfoRequestEvent getAssetUploadInfo(User user) {
|
||||
return new AssetUploadInfoRequestEvent(urls.keySet(), slimSupportConf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(LaunchServer server, AuthCoreProvider core) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
|
||||
}
|
||||
}
|
|
@ -2,14 +2,13 @@
|
|||
|
||||
import pro.gravit.launcher.events.RequestEvent;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class AssetUploadInfoRequestEvent extends RequestEvent {
|
||||
public boolean uploadSkin;
|
||||
public boolean uploadCape;
|
||||
public Set<String> available;
|
||||
public SlimSupportConf slimSupportConf;
|
||||
|
||||
public AssetUploadInfoRequestEvent(boolean uploadSkin, boolean uploadCape, SlimSupportConf slimSupportConf) {
|
||||
this.uploadSkin = uploadSkin;
|
||||
this.uploadCape = uploadCape;
|
||||
public AssetUploadInfoRequestEvent(Set<String> available, SlimSupportConf slimSupportConf) {
|
||||
this.slimSupportConf = slimSupportConf;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue