mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-26 10:01:23 +01:00
Added 'extensions' module:
- Module is in charge of registering built in DataExtensions - This is done via ExtensionRegister
This commit is contained in:
parent
5061f6d9ec
commit
e8da008538
@ -1,9 +1,39 @@
|
||||
plugins {
|
||||
id "com.jfrog.bintray" version "1.8.1"
|
||||
}
|
||||
|
||||
ext.apiVersion = '0.0.1'
|
||||
|
||||
bintray {
|
||||
user = System.getenv('BINTRAY_USER')
|
||||
key = System.getenv('BINTRAY_KEY')
|
||||
pkg {
|
||||
repo = 'Plan-repository'
|
||||
name = 'Plan-API'
|
||||
licenses = ['LGPL-v3.0']
|
||||
vcsUrl = 'https://github.com/plan-player-analytics/Plan'
|
||||
issueTrackerUrl = 'https://github.com/plan-player-analytics/Plan/issues'
|
||||
version {
|
||||
name = "$apiVersion"
|
||||
desc = 'Plan APIv5 version 0.0.1'
|
||||
}
|
||||
publications = ['BintrayPublication']
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
BintrayPublication(MavenPublication) {
|
||||
groupId = 'com.djrapitops'
|
||||
artifactId = 'Plan-api'
|
||||
version = "$apiVersion"
|
||||
|
||||
artifact jar
|
||||
}
|
||||
mavenJava(MavenPublication) {
|
||||
groupId = 'com.djrapitops'
|
||||
artifactId = 'Plan-api'
|
||||
version = project.version
|
||||
version = "$apiVersion"
|
||||
|
||||
artifact jar
|
||||
}
|
||||
|
@ -4,13 +4,13 @@ dependencies {
|
||||
compile "com.djrapitops:AbstractPluginFramework-bukkit:$abstractPluginFrameworkVersion"
|
||||
compile "org.bstats:bstats-bukkit:$bstatsVersion"
|
||||
|
||||
compileOnly "com.destroystokyo.paper:paper-api:$paperVersion"
|
||||
compileOnly "org.spigotmc:spigot-api:$spigotVersion"
|
||||
compileOnly "org.bukkit:bukkit:$bukkitVersion"
|
||||
// compileOnly "org.spigotmc:spigot-api:$spigotVersion"
|
||||
// compileOnly "org.bukkit:bukkit:$bukkitVersion"
|
||||
compileOnly "com.destroystokyo.paper:paper-api:$paperVersion"
|
||||
|
||||
testCompile "com.destroystokyo.paper:paper-api:$paperVersion"
|
||||
testCompile "org.spigotmc:spigot-api:$spigotVersion"
|
||||
testCompile "org.bukkit:bukkit:$bukkitVersion"
|
||||
// testCompile "org.spigotmc:spigot-api:$spigotVersion"
|
||||
// testCompile "org.bukkit:bukkit:$bukkitVersion"
|
||||
testCompile "com.destroystokyo.paper:paper-api:$paperVersion"
|
||||
|
||||
testCompile project(path: ":common", configuration: 'testArtifacts')
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ public class CommandListener implements Listener {
|
||||
try {
|
||||
command = plugin.getServer().getCommandMap().getCommand(commandName);
|
||||
} catch (NoSuchMethodError ignored) {
|
||||
/* Ignored, Bukkit 1.8 has no such method */
|
||||
/* Ignored, Bukkit 1.8 has no such method. This method is from Paper */
|
||||
}
|
||||
}
|
||||
return command;
|
||||
|
@ -46,6 +46,7 @@ public class PaperTPSCountTimer extends BukkitTPSCountTimer {
|
||||
try {
|
||||
tps = plugin.getServer().getTPS()[0];
|
||||
} catch (NoSuchMethodError e) {
|
||||
// This method is from Paper
|
||||
return super.getTPS(diff, now, cpuUsage, usedMemory, entityCount, chunksLoaded, playersOnline, freeDiskSpace);
|
||||
}
|
||||
|
||||
|
@ -175,6 +175,7 @@ public class PingCountTimerBukkit extends AbsRunnable implements Listener {
|
||||
|
||||
private int getPing(Player player) {
|
||||
if (PING_METHOD_AVAILABLE) {
|
||||
// This method is from Paper
|
||||
return player.spigot().getPing();
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
dependencies {
|
||||
compile "com.djrapitops:AbstractPluginFramework-api:$abstractPluginFrameworkVersion"
|
||||
compile project(path: ":api", configuration: 'shadow')
|
||||
compile project(path: ":api")
|
||||
compile project(path: ":extensions", configuration: 'shadow')
|
||||
compile "com.djrapitops:PlanPluginBridge:$planPluginBridgeVersion"
|
||||
compile "org.apache.httpcomponents:httpclient:$httpClientVersion"
|
||||
compile "org.apache.commons:commons-text:$commonsTextVersion"
|
||||
|
@ -17,6 +17,7 @@
|
||||
package com.djrapitops.plan.extension;
|
||||
|
||||
import com.djrapitops.plan.extension.implementation.DataProviderExtractor;
|
||||
import com.djrapitops.plan.extension.implementation.ExtensionRegister;
|
||||
import com.djrapitops.plan.extension.implementation.providers.gathering.ProviderValueGatherer;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
@ -40,6 +41,7 @@ public class ExtensionServiceImplementation implements ExtensionService {
|
||||
|
||||
private final DBSystem dbSystem;
|
||||
private final ServerInfo serverInfo;
|
||||
private final ExtensionRegister extensionRegister;
|
||||
private final PluginLogger logger;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
@ -49,11 +51,13 @@ public class ExtensionServiceImplementation implements ExtensionService {
|
||||
public ExtensionServiceImplementation(
|
||||
DBSystem dbSystem,
|
||||
ServerInfo serverInfo,
|
||||
ExtensionRegister extensionRegister,
|
||||
PluginLogger logger,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
this.dbSystem = dbSystem;
|
||||
this.serverInfo = serverInfo;
|
||||
this.extensionRegister = extensionRegister;
|
||||
this.logger = logger;
|
||||
this.errorHandler = errorHandler;
|
||||
|
||||
@ -62,6 +66,10 @@ public class ExtensionServiceImplementation implements ExtensionService {
|
||||
ExtensionService.ExtensionServiceHolder.set(this);
|
||||
}
|
||||
|
||||
public void enable() {
|
||||
extensionRegister.registerBuiltInExtensions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(DataExtension extension) {
|
||||
DataProviderExtractor extractor = new DataProviderExtractor(extension);
|
||||
|
@ -19,6 +19,7 @@ package com.djrapitops.plan.system;
|
||||
import com.djrapitops.plan.api.PlanAPI;
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.data.plugin.HookHandler;
|
||||
import com.djrapitops.plan.extension.ExtensionServiceImplementation;
|
||||
import com.djrapitops.plan.system.cache.CacheSystem;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.export.ExportSystem;
|
||||
@ -69,6 +70,7 @@ public class PlanSystem implements SubSystem {
|
||||
private final ExportSystem exportSystem;
|
||||
private final HtmlUtilities htmlUtilities;
|
||||
private final HookHandler hookHandler;
|
||||
private final ExtensionServiceImplementation extensionService;
|
||||
private final PlanAPI planAPI;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
@ -90,6 +92,7 @@ public class PlanSystem implements SubSystem {
|
||||
ExportSystem exportSystem,
|
||||
HtmlUtilities htmlUtilities,
|
||||
HookHandler hookHandler,
|
||||
ExtensionServiceImplementation extensionService,
|
||||
PlanAPI planAPI,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
@ -109,6 +112,7 @@ public class PlanSystem implements SubSystem {
|
||||
this.exportSystem = exportSystem;
|
||||
this.htmlUtilities = htmlUtilities;
|
||||
this.hookHandler = hookHandler;
|
||||
this.extensionService = extensionService;
|
||||
this.planAPI = planAPI;
|
||||
this.errorHandler = errorHandler;
|
||||
}
|
||||
@ -132,6 +136,7 @@ public class PlanSystem implements SubSystem {
|
||||
taskSystem,
|
||||
hookHandler
|
||||
);
|
||||
extensionService.enable();
|
||||
enabled = true;
|
||||
}
|
||||
|
||||
|
12
Plan/extensions/build.gradle
Normal file
12
Plan/extensions/build.gradle
Normal file
@ -0,0 +1,12 @@
|
||||
dependencies {
|
||||
compile project(path: ":api")
|
||||
compile "com.djrapitops:Extension-AdvancedAchievements:1.1-R0.1"
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
configurations = [project.configurations.compile]
|
||||
|
||||
dependencies {
|
||||
exclude(project(':api'))
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.djrapitops.plan.extension.implementation;
|
||||
|
||||
import com.djrapitops.extension.AdvancedAchievementsExtensionFactory;
|
||||
import com.djrapitops.plan.extension.ExtensionService;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
/**
|
||||
* In charge of registering built in {@link com.djrapitops.plan.extension.DataExtension} implementations.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@Singleton
|
||||
public class ExtensionRegister {
|
||||
|
||||
@Inject
|
||||
public ExtensionRegister() {
|
||||
/* Required for dagger injection */
|
||||
}
|
||||
|
||||
public void registerBuiltInExtensions() {
|
||||
// No need to catch exceptions here,
|
||||
// this method will not be called unless Plan has enabled properly
|
||||
ExtensionService extensionService = ExtensionService.getInstance();
|
||||
|
||||
new AdvancedAchievementsExtensionFactory().createExtension().ifPresent(extensionService::register);
|
||||
}
|
||||
|
||||
}
|
@ -6,4 +6,5 @@ include 'bukkit'
|
||||
include 'sponge'
|
||||
include 'bungeecord'
|
||||
include 'velocity'
|
||||
include 'plugin'
|
||||
include 'plugin'
|
||||
include 'extensions'
|
Loading…
Reference in New Issue
Block a user