mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-30 16:19:56 +08:00
parent
42ecfa7298
commit
bfcb7eea85
@ -66,7 +66,7 @@ subprojects {
|
||||
ext.daggerVersion = "2.33"
|
||||
ext.daggerCompilerVersion = "2.33"
|
||||
|
||||
ext.palVersion = "4.0.5"
|
||||
ext.palVersion = "4.0.9"
|
||||
|
||||
ext.bukkitVersion = "1.13.2-R0.1-SNAPSHOT"
|
||||
ext.spigotVersion = "1.13.2-R0.1-SNAPSHOT"
|
||||
|
@ -34,13 +34,13 @@ import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Main class for Bukkit that manages the plugin.
|
||||
@ -55,12 +55,23 @@ public class Plan extends JavaPlugin implements PlanPlugin {
|
||||
|
||||
private PluginLogger logger;
|
||||
private RunnableFactory runnableFactory;
|
||||
private PlatformAbstractionLayer abstractionLayer;
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
abstractionLayer = new BukkitPlatformLayer(this);
|
||||
logger = abstractionLayer.getPluginLogger();
|
||||
runnableFactory = abstractionLayer.getRunnableFactory();
|
||||
|
||||
try {
|
||||
new DependencyStartup(logger, abstractionLayer.getDependencyLoader()).loadDependencies();
|
||||
} catch (IOException e) {
|
||||
getLogger().log(Level.SEVERE, e, () -> this.getClass().getSimpleName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
PlatformAbstractionLayer abstractionLayer = new BukkitPlatformLayer(this);
|
||||
logger = abstractionLayer.getPluginLogger();
|
||||
runnableFactory = abstractionLayer.getRunnableFactory();
|
||||
PlanBukkitComponent component = DaggerPlanBukkitComponent.builder()
|
||||
.plan(this)
|
||||
.abstractionLayer(abstractionLayer)
|
||||
@ -86,7 +97,7 @@ public class Plan extends JavaPlugin implements PlanPlugin {
|
||||
onDisable();
|
||||
} catch (Exception e) {
|
||||
String version = abstractionLayer.getPluginInformation().getVersion();
|
||||
Logger.getGlobal().log(Level.SEVERE, e, () -> this.getClass().getSimpleName() + "-v" + version);
|
||||
getLogger().log(Level.SEVERE, e, () -> this.getClass().getSimpleName() + "-v" + version);
|
||||
logger.error("Plugin Failed to Initialize Correctly. If this issue is caused by config settings you can use /plan reload");
|
||||
logger.error("This error should be reported at https://github.com/plan-player-analytics/Plan/issues");
|
||||
onDisable();
|
||||
|
@ -29,6 +29,7 @@ import net.playeranalytics.plugin.PlatformAbstractionLayer;
|
||||
import net.playeranalytics.plugin.scheduling.RunnableFactory;
|
||||
import net.playeranalytics.plugin.server.PluginLogger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@ -45,12 +46,23 @@ public class PlanBungee extends Plugin implements PlanPlugin {
|
||||
|
||||
private PluginLogger logger;
|
||||
private RunnableFactory runnableFactory;
|
||||
private PlatformAbstractionLayer abstractionLayer;
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
abstractionLayer = new BungeePlatformLayer(this);
|
||||
logger = abstractionLayer.getPluginLogger();
|
||||
runnableFactory = abstractionLayer.getRunnableFactory();
|
||||
|
||||
try {
|
||||
new DependencyStartup(logger, abstractionLayer.getDependencyLoader()).loadDependencies();
|
||||
} catch (IOException e) {
|
||||
getLogger().log(Level.SEVERE, e, () -> this.getClass().getSimpleName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
PlatformAbstractionLayer abstractionLayer = new BungeePlatformLayer(this);
|
||||
logger = abstractionLayer.getPluginLogger();
|
||||
runnableFactory = abstractionLayer.getRunnableFactory();
|
||||
PlanBungeeComponent component = DaggerPlanBungeeComponent.builder()
|
||||
.plan(this)
|
||||
.abstractionLayer(abstractionLayer)
|
||||
|
@ -6,9 +6,9 @@ dependencies {
|
||||
compile "org.apache.commons:commons-text:$commonsTextVersion"
|
||||
compile "org.apache.commons:commons-compress:$commonsCompressVersion"
|
||||
compile "com.github.ben-manes.caffeine:caffeine:$caffeineVersion"
|
||||
compile "com.h2database:h2:$h2Version"
|
||||
compile "mysql:mysql-connector-java:$mysqlVersion"
|
||||
compile "org.xerial:sqlite-jdbc:$sqliteVersion"
|
||||
implementation "com.h2database:h2:$h2Version"
|
||||
implementation "mysql:mysql-connector-java:$mysqlVersion"
|
||||
implementation "org.xerial:sqlite-jdbc:$sqliteVersion"
|
||||
compile "com.zaxxer:HikariCP:$hikariVersion"
|
||||
compile "org.slf4j:slf4j-nop:$slf4jVersion"
|
||||
compile "org.slf4j:slf4j-api:$slf4jVersion"
|
||||
@ -50,7 +50,6 @@ shadowJar {
|
||||
relocate 'com.maxmind', 'plan.com.maxmind'
|
||||
relocate 'com.fasterxml', 'plan.com.fasterxml'
|
||||
relocate 'com.zaxxer', 'plan.com.zaxxer'
|
||||
relocate 'com.googlecode.htmlcompressor', 'plan.com.google.htmlcompressor'
|
||||
relocate 'com.google.protobuf', 'plan.com.google.protobuf'
|
||||
relocate 'com.google.gson', 'plan.com.google.gson'
|
||||
relocate 'com.google.errorprone', 'plan.com.google.errorprone'
|
||||
|
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan;
|
||||
|
||||
import com.djrapitops.plan.utilities.java.Lists;
|
||||
import net.playeranalytics.plugin.dependencies.DependencyLoader;
|
||||
import net.playeranalytics.plugin.me.lucko.jarrelocator.Relocation;
|
||||
import net.playeranalytics.plugin.server.PluginLogger;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class DependencyStartup {
|
||||
|
||||
private static final String REPOSITORY_MAVEN_CENTRAL = "https://repo1.maven.org/maven2/";
|
||||
private final PluginLogger logger;
|
||||
private final DependencyLoader dependencyLoader;
|
||||
|
||||
public DependencyStartup(PluginLogger logger, DependencyLoader dependencyLoader) {
|
||||
this.logger = logger;
|
||||
this.dependencyLoader = dependencyLoader;
|
||||
}
|
||||
|
||||
public void loadDependencies() throws IOException {
|
||||
logger.info("Resolving runtime dependencies..");
|
||||
dependencyLoader.addDependency(REPOSITORY_MAVEN_CENTRAL,
|
||||
"com.h2database", "h2", "1.4.199",
|
||||
Lists.builder(Relocation.class)
|
||||
.add(new Relocation(
|
||||
new String(new char[]{'o', 'r', 'g', '.', 'h', '2'}),
|
||||
"plan.org.h2"
|
||||
)).build()
|
||||
);
|
||||
dependencyLoader.addDependency(REPOSITORY_MAVEN_CENTRAL,
|
||||
"mysql", "mysql-connector-java", "8.0.23",
|
||||
Lists.builder(Relocation.class)
|
||||
.add(new Relocation(
|
||||
new String(new char[]{'c', 'o', 'm', '.', 'm', 'y', 's', 'q', 'l'}),
|
||||
"plan.com.mysql"
|
||||
)).build()
|
||||
);
|
||||
dependencyLoader.addDependency(REPOSITORY_MAVEN_CENTRAL,
|
||||
"org.xerial", "sqlite-jdbc", "3.34.0",
|
||||
Lists.builder(Relocation.class)
|
||||
.add(new Relocation(
|
||||
new String(new char[]{'o', 'r', 'g', '.', 's', 'q', 'l', 'i', 't', 'e'}),
|
||||
"plan.org.sqlite"
|
||||
)).build()
|
||||
);
|
||||
logger.info("Loading runtime dependencies..");
|
||||
dependencyLoader.load();
|
||||
|
||||
try {
|
||||
Class.forName("org.sqlite.JDBC");
|
||||
} catch (ClassNotFoundException e) {
|
||||
logger.error("Could not load SQLite driver");
|
||||
}
|
||||
try {
|
||||
Class.forName("com.mysql.cj.jdbc.Driver");
|
||||
} catch (ClassNotFoundException e) {
|
||||
logger.error("Could not load MySQL driver");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -34,6 +34,7 @@ import net.playeranalytics.plugin.PlatformAbstractionLayer;
|
||||
import net.playeranalytics.plugin.scheduling.RunnableFactory;
|
||||
import net.playeranalytics.plugin.server.PluginLogger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -59,12 +60,23 @@ public class PlanNukkit extends PluginBase implements PlanPlugin {
|
||||
private final Map<String, Subcommand> commands = new HashMap<>();
|
||||
private PluginLogger logger;
|
||||
private RunnableFactory runnableFactory;
|
||||
private PlatformAbstractionLayer abstractionLayer;
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
abstractionLayer = new NukkitPlatformLayer(this);
|
||||
logger = abstractionLayer.getPluginLogger();
|
||||
runnableFactory = abstractionLayer.getRunnableFactory();
|
||||
|
||||
try {
|
||||
new DependencyStartup(logger, abstractionLayer.getDependencyLoader()).loadDependencies();
|
||||
} catch (IOException e) {
|
||||
Logger.getGlobal().log(Level.SEVERE, e, () -> this.getClass().getSimpleName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
PlatformAbstractionLayer abstractionLayer = new NukkitPlatformLayer(this);
|
||||
logger = abstractionLayer.getPluginLogger();
|
||||
runnableFactory = abstractionLayer.getRunnableFactory();
|
||||
PlanNukkitComponent component = DaggerPlanNukkitComponent.builder()
|
||||
.plan(this)
|
||||
.abstractionLayer(abstractionLayer)
|
||||
|
@ -20,9 +20,9 @@ shadowJar {
|
||||
exclude 'org/apache/logging/**'
|
||||
}
|
||||
relocate 'dagger', 'plan.dagger'
|
||||
relocate 'com.mysql.jdbc', 'plan.com.mysql.jdbc'
|
||||
relocate 'com.mysql', 'plan.com.mysql'
|
||||
relocate 'com.mysql', 'plan.com.mysql'
|
||||
relocate 'org.sqlite', 'plan.org.sqlite'
|
||||
relocate 'com.mysql.cj', 'plan.com.mysql.cj'
|
||||
relocate 'javax.inject', 'plan.javax.inject'
|
||||
relocate 'com.github.benmanes', 'plan.com.github.benmanes'
|
||||
|
||||
|
@ -36,6 +36,7 @@ import org.spongepowered.api.command.CommandManager;
|
||||
import org.spongepowered.api.command.CommandMapping;
|
||||
import org.spongepowered.api.config.ConfigDir;
|
||||
import org.spongepowered.api.event.Listener;
|
||||
import org.spongepowered.api.event.game.state.GamePreInitializationEvent;
|
||||
import org.spongepowered.api.event.game.state.GameStartedServerEvent;
|
||||
import org.spongepowered.api.event.game.state.GameStoppingServerEvent;
|
||||
import org.spongepowered.api.plugin.Dependency;
|
||||
@ -43,6 +44,7 @@ import org.spongepowered.api.plugin.Plugin;
|
||||
import org.spongepowered.api.scheduler.Task;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -78,6 +80,7 @@ public class PlanSponge implements PlanPlugin {
|
||||
private ServerShutdownSave serverShutdownSave;
|
||||
private PluginLogger logger;
|
||||
private RunnableFactory runnableFactory;
|
||||
private PlatformAbstractionLayer abstractionLayer;
|
||||
|
||||
@com.google.inject.Inject
|
||||
public PlanSponge(
|
||||
@ -94,6 +97,11 @@ public class PlanSponge implements PlanPlugin {
|
||||
|
||||
private final Map<String, CommandMapping> commands = new HashMap<>();
|
||||
|
||||
@Listener
|
||||
public void onServerLoad(GamePreInitializationEvent event) {
|
||||
onLoad();
|
||||
}
|
||||
|
||||
@Listener
|
||||
public void onServerStart(GameStartedServerEvent event) {
|
||||
onEnable();
|
||||
@ -104,10 +112,18 @@ public class PlanSponge implements PlanPlugin {
|
||||
onDisable();
|
||||
}
|
||||
|
||||
public void onEnable() {
|
||||
PlatformAbstractionLayer abstractionLayer = new SpongePlatformLayer(this, dataFolder, slf4jLogger);
|
||||
private void onLoad() {
|
||||
abstractionLayer = new SpongePlatformLayer(this, dataFolder, slf4jLogger);
|
||||
logger = abstractionLayer.getPluginLogger();
|
||||
runnableFactory = abstractionLayer.getRunnableFactory();
|
||||
try {
|
||||
new DependencyStartup(logger, abstractionLayer.getDependencyLoader()).loadDependencies();
|
||||
} catch (IOException e) {
|
||||
java.util.logging.Logger.getGlobal().log(Level.SEVERE, e, () -> this.getClass().getSimpleName());
|
||||
}
|
||||
}
|
||||
|
||||
public void onEnable() {
|
||||
PlanSpongeComponent component = DaggerPlanSpongeComponent.builder()
|
||||
.plan(this)
|
||||
.abstractionLayer(abstractionLayer)
|
||||
|
@ -37,6 +37,7 @@ import org.bstats.velocity.Metrics;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Path;
|
||||
import java.util.logging.Level;
|
||||
@ -93,7 +94,17 @@ public class PlanVelocity implements PlanPlugin {
|
||||
PlatformAbstractionLayer abstractionLayer = new VelocityPlatformLayer(this, proxy, slf4jLogger, dataFolderPath);
|
||||
logger = abstractionLayer.getPluginLogger();
|
||||
runnableFactory = abstractionLayer.getRunnableFactory();
|
||||
PlanVelocityComponent component = DaggerPlanVelocityComponent.builder().plan(this).build();
|
||||
|
||||
try {
|
||||
new DependencyStartup(logger, abstractionLayer.getDependencyLoader()).loadDependencies();
|
||||
} catch (IOException e) {
|
||||
java.util.logging.Logger.getGlobal().log(Level.SEVERE, e, () -> this.getClass().getSimpleName());
|
||||
}
|
||||
|
||||
PlanVelocityComponent component = DaggerPlanVelocityComponent.builder()
|
||||
.plan(this)
|
||||
.abstractionLayer(abstractionLayer)
|
||||
.build();
|
||||
try {
|
||||
system = component.system();
|
||||
locale = system.getLocaleSystem().getLocale();
|
||||
|
Loading…
Reference in New Issue
Block a user