mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-18 14:11:32 +01:00
Implement Abstraction layer (except runnable factory)
This commit is contained in:
parent
a5f49fb237
commit
25be0efbd8
@ -4,7 +4,13 @@ import net.playeranalytics.plugin.scheduling.RunnableFactory;
|
||||
import net.playeranalytics.plugin.server.JavaUtilPluginLogger;
|
||||
import net.playeranalytics.plugin.server.Listeners;
|
||||
import net.playeranalytics.plugin.server.PluginLogger;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class StandalonePlatformAbstractionLayer implements PlatformAbstractionLayer {
|
||||
@ -42,6 +48,31 @@ public class StandalonePlatformAbstractionLayer implements PlatformAbstractionLa
|
||||
|
||||
@Override
|
||||
public PluginInformation getPluginInformation() {
|
||||
return null;
|
||||
return new PluginInformation() {
|
||||
@Override
|
||||
public InputStream getResourceFromJar(String s) {
|
||||
return getClass().getResourceAsStream(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getDataFolder() {
|
||||
return new File("Plan");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
try {
|
||||
return readVersionFromPluginYml();
|
||||
} catch (IOException | URISyntaxException e) {
|
||||
return e.toString();
|
||||
}
|
||||
}
|
||||
|
||||
private String readVersionFromPluginYml() throws IOException, URISyntaxException {
|
||||
String pluginYmlContents = new String(Files.readAllBytes(new File(getClass().getResource("plugin.yml").toURI()).toPath()));
|
||||
String versionHalf = StringUtils.split(pluginYmlContents, "version:")[1];
|
||||
return StringUtils.split(versionHalf, "\n")[0];
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user