[FEATURE] UploadAssetMixProvider

This commit is contained in:
Gravita 2023-09-26 14:08:44 +07:00
parent 183cfe949f
commit 1f3b7e0552
4 changed files with 42 additions and 6 deletions

View file

@ -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);
}
}

View file

@ -13,6 +13,7 @@ public abstract class MixProvider implements AutoCloseable{
public static void registerProviders() {
if (!registredProviders) {
providers.register("uploadAsset", UploadAssetMixProvider.class);
registredProviders = true;
}
}

View file

@ -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() {
}
}

View file

@ -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;
}