-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update mps, fix ssl problems and use v3.mps.dynamx.fr for mps backend
- Loading branch information
1 parent
d251e09
commit f920648
Showing
6 changed files
with
48 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,45 @@ | ||
package fr.dynamx.utils; | ||
|
||
import fr.aym.acslib.api.services.mps.ModProtectionConfig; | ||
import fr.aym.acslib.api.services.mps.ModProtectionContainer; | ||
import fr.aym.mps.core.BasicMpsConfig; | ||
import fr.aym.mps.utils.ProtectionException; | ||
import fr.aym.mps.utils.MpsUrlFactory; | ||
|
||
import javax.annotation.Nullable; | ||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
|
||
import static fr.dynamx.utils.DynamXConstants.*; | ||
|
||
public class DynamXMpsConfig extends BasicMpsConfig { | ||
public DynamXMpsConfig() { | ||
super(VERSION, MPS_KEY, null, MPS_URL, new String[]{MPS_AUX_URL}, new String[0], MPS_STARTER); | ||
super(VERSION, MPS_KEY, null, new DynamXMpsUrlFactory(MPS_URL, new String[]{MPS_AUX_URL}), new String[0], MPS_STARTER); | ||
} | ||
|
||
public static class DynamXMpsUrlFactory extends MpsUrlFactory.DefaultUrlFactory { | ||
public DynamXMpsUrlFactory(String mainUrl, String[] auxUrls) { | ||
super(mainUrl, auxUrls); | ||
} | ||
|
||
public String getPatchedMainUrl() { | ||
return MPS_URL_PATCHER.apply(this.getMainUrl()); | ||
} | ||
|
||
@Override | ||
public URL getHomeUrl(ModProtectionConfig config, int attempt) throws MalformedURLException { | ||
String mpsURL = attempt > -1 ? getAuxUrls()[attempt] : getPatchedMainUrl(); | ||
return new URL(mpsURL + config.getMpsVersion() + "/home.php?access_key=" + config.getMpsAccessKey()); | ||
} | ||
|
||
@Override | ||
public URL getResourceUrl(ModProtectionConfig config, int attempt, String encodedModVersion, String resource, @Nullable ModProtectionContainer.CustomRepoParams params) throws MalformedURLException { | ||
if (params != null) { | ||
if (attempt == -1) | ||
return new URL(MPS_URL_PATCHER.apply(params.getDomain()) + resource); | ||
return new URL(params.getDomain().replace(getMainUrl(), getAuxUrls()[attempt]) + resource); //apply aux url | ||
} | ||
String mpsURL = (attempt > -1 ? getAuxUrls()[attempt] : getPatchedMainUrl()); | ||
return new URL(mpsURL + config.getMpsVersion() + "/router.php?mod_version=" + encodedModVersion + "&target=" + resource); | ||
} | ||
} | ||
} |