Skip to content

Commit

Permalink
Change doc url
Browse files Browse the repository at this point in the history
Added URLGit for handling Github URLs which will now use the version of the API running to avoid inconsistencies.
  • Loading branch information
Fernthedev committed Jan 28, 2020
1 parent 9fae7ef commit c58277b
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
Expand Up @@ -2,6 +2,7 @@

import com.github.fernthedev.fernapi.universal.api.ILocale;
import com.github.fernthedev.fernapi.universal.api.Locale;
import com.github.fernthedev.fernapi.universal.api.URLGit;
import com.github.fernthedev.fernapi.universal.data.network.IPMessageHandler;
import com.github.fernthedev.fernapi.universal.exceptions.FernRuntimeException;
import com.github.fernthedev.fernapi.universal.exceptions.setup.IncorrectSetupException;
Expand All @@ -11,7 +12,9 @@
import lombok.NonNull;
import lombok.Setter;


/**
* Holds most of the core api
*/
public class Universal {

private Universal() {}
Expand Down Expand Up @@ -64,7 +67,7 @@ public void setup(@NonNull MethodInterface<?> methodInterface, FernAPIPlugin apl
protected static void checkNull() {
if(mi == null || !setup) {
try {
throw new IncorrectSetupException("You have not setup the API correctly. Check this for more info: https://github.com/Fernthedev/FernAPI/blob/master/error/incorrectsetup.md",new NullPointerException());
throw new IncorrectSetupException("You have not setup the API correctly. Check this for more info: " + URLGit.INCORRECT_SETUP, new NullPointerException());
} catch (IncorrectSetupException e) {
e.printStackTrace();
}
Expand Down
@@ -0,0 +1,35 @@
package com.github.fernthedev.fernapi.universal.api;

import lombok.Getter;

/**
* Holds URLs for github files that may change in the future.
*/
@Getter
public class URLGit {

private static final String tag;

static {
Package pack = URLGit.class.getPackage();
String checkTag = pack.getSpecificationVersion();

if (checkTag == null) checkTag = pack.getImplementationVersion();
if (checkTag == null) throw new NullPointerException("Version is somehow null. Checked specification and implementation");

tag = checkTag;
}

public static String formatString(String string) {
return string
.replaceAll("%tag%", tag);
}

public static final String MAIN_PATH = "https://github.com/Fernthedev/FernAPI/";
public static final String FILE_PATH = MAIN_PATH + "blob/%tag%/";
public static final String DOCS = FILE_PATH + "docs/";

public static final String INCORRECT_SETUP = formatString(DOCS + "error/incorrectsetup.md");


}

0 comments on commit c58277b

Please sign in to comment.