[Fix] Velocity enable sequence

- Annotation processor
- Fixed APF parts and added listeners that allow enable and disable.
This commit is contained in:
Rsl1122 2018-10-27 15:17:45 +03:00
parent 23613d7a63
commit 8aa7fd12e0
3 changed files with 65 additions and 42 deletions

View File

@ -36,7 +36,17 @@
<path>
<groupId>com.google.dagger</groupId>
<artifactId>dagger-compiler</artifactId>
<version>2.16</version>
<version>2.17</version>
</path>
<path>
<groupId>com.velocitypowered</groupId>
<artifactId>velocity-api</artifactId>
<version>1.0-SNAPSHOT</version>
</path>
<path>
<groupId>org.spongepowered</groupId>
<artifactId>spongeapi</artifactId>
<version>7.1.0</version>
</path>
</annotationProcessorPaths>
</configuration>
@ -66,6 +76,7 @@
<exclude>org.mockito:*</exclude>
<exclude>org.easymock:*</exclude>
<exclude>junit:*</exclude>
<exclued>org.slf4j:*</exclued>
</excludes>
</artifactSet>
<relocations>
@ -88,10 +99,6 @@
<pattern>com.zaxxer</pattern>
<shadedPattern>plan.com.zaxxer</shadedPattern>
</relocation>
<relocation>
<pattern>org.slf4j</pattern>
<shadedPattern>plan.org.slf4j</shadedPattern>
</relocation>
<relocation>
<pattern>org.bstats</pattern>
<shadedPattern>com.djrapitops.plan.utilities.metrics</shadedPattern>
@ -339,7 +346,7 @@
<dependency>
<groupId>org.spongepowered</groupId>
<artifactId>spongeapi</artifactId>
<version>7.0.0</version>
<version>7.1.0</version>
<scope>provided</scope>
<exclusions>
<exclusion>
@ -356,15 +363,15 @@
</exclusion>
<exclusion>
<artifactId>configurate-hocon</artifactId>
<groupId>ninja.leaping.configurate</groupId>
<groupId>org.spongepowered</groupId>
</exclusion>
<exclusion>
<artifactId>configurate-gson</artifactId>
<groupId>ninja.leaping.configurate</groupId>
<groupId>org.spongepowered</groupId>
</exclusion>
<exclusion>
<artifactId>configurate-yaml</artifactId>
<groupId>ninja.leaping.configurate</groupId>
<groupId>org.spongepowered</groupId>
</exclusion>
<exclusion>
<artifactId>flow-math</artifactId>
@ -402,6 +409,12 @@
<version>0.3.8-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>1.7.25</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>

View File

@ -95,7 +95,7 @@
<dependency>
<groupId>org.spongepowered</groupId>
<artifactId>spongeapi</artifactId>
<version>7.0.0</version>
<version>7.1.0</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
@ -202,7 +202,7 @@
<dependency>
<groupId>com.google.dagger</groupId>
<artifactId>dagger</artifactId>
<version>2.16</version>
<version>2.17</version>
</dependency>
</dependencies>
@ -238,7 +238,17 @@
<path>
<groupId>com.google.dagger</groupId>
<artifactId>dagger-compiler</artifactId>
<version>2.16</version>
<version>2.17</version>
</path>
<path>
<groupId>com.velocitypowered</groupId>
<artifactId>velocity-api</artifactId>
<version>1.0-SNAPSHOT</version>
</path>
<path>
<groupId>org.spongepowered</groupId>
<artifactId>spongeapi</artifactId>
<version>7.1.0</version>
</path>
</annotationProcessorPaths>
</configuration>
@ -269,7 +279,7 @@
<exclude>org.mockito:*</exclude>
<exclude>org.easymock:*</exclude>
<exclude>junit:*</exclude>
<!--<exclued>org.slf4j:*</exclued>-->
<exclued>org.slf4j:*</exclued>
</excludes>
</artifactSet>
<relocations>
@ -292,10 +302,10 @@
<pattern>com.zaxxer</pattern>
<shadedPattern>plan.com.zaxxer</shadedPattern>
</relocation>
<relocation>
<pattern>org.slf4j</pattern>
<shadedPattern>plan.org.slf4j</shadedPattern>
</relocation>
<!--<relocation>-->
<!--<pattern>org.slf4j</pattern>-->
<!--<shadedPattern>plan.org.slf4j</shadedPattern>-->
<!--</relocation>-->
<relocation>
<pattern>org.bstats</pattern>
<shadedPattern>com.djrapitops.plan.utilities.metrics</shadedPattern>

View File

@ -13,12 +13,14 @@ import com.djrapitops.plan.system.settings.theme.PlanColorScheme;
import com.djrapitops.plugin.VelocityPlugin;
import com.djrapitops.plugin.command.ColorScheme;
import com.djrapitops.plugin.logging.L;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
import com.velocitypowered.api.event.proxy.ProxyShutdownEvent;
import com.velocitypowered.api.plugin.Plugin;
import com.velocitypowered.api.plugin.annotation.DataDirectory;
import com.velocitypowered.api.proxy.ProxyServer;
import org.slf4j.Logger;
import java.io.File;
import java.io.InputStream;
import java.nio.file.Path;
@ -29,23 +31,31 @@ import java.nio.file.Path;
*
* @author MicleBrick
*/
@Plugin(id = "plan", name = "Plan", version = "4.4.6", description = "Player Analytics Plugin by Rsl1122", authors = {"Rsl1122"})
@Plugin(
id = "plan",
name = "Plan",
version = "4.4.6",
description = "Player Analytics Plugin by Rsl1122",
authors = {"Rsl1122"}
)
public class PlanVelocity extends VelocityPlugin implements PlanPlugin {
private PlanSystem system;
private Locale locale;
@com.google.inject.Inject
@DataDirectory
private Path dataFolderPath;
@com.google.inject.Inject
private ProxyServer proxy;
@com.google.inject.Inject
private Logger slf4jLogger;
public PlanVelocity(ProxyServer proxy, Logger slf4jLogger, @DataDirectory Path dataFolderPath) {
super(proxy, slf4jLogger, dataFolderPath);
}
@Override
public File getDataFolder() {
return dataFolderPath.toFile();
@Subscribe
public void onProxyStart(ProxyInitializeEvent event) {
onEnable();
}
@Subscribe
public void onProxyShutdown(ProxyShutdownEvent event) {
onDisable();
}
@Override
@ -63,11 +73,11 @@ public class PlanVelocity extends VelocityPlugin implements PlanPlugin {
logger.error("----------------------------------------");
logger.error("Error: " + e.getMessage());
logger.error("----------------------------------------");
logger.error("Plugin Failed to Initialize Correctly. If this issue is caused by config settings you can use /planbungee reload");
logger.error("Plugin Failed to Initialize Correctly. If this issue is caused by config settings you can use /planvelocity reload");
onDisable();
} catch (Exception e) {
errorHandler.log(L.CRITICAL, this.getClass(), e);
logger.error("Plugin Failed to Initialize Correctly. If this issue is caused by config settings you can use /planbungee reload");
logger.error("Plugin Failed to Initialize Correctly. If this issue is caused by config settings you can use /planvelocity reload");
logger.error("This error should be reported at https://github.com/Rsl1122/Plan-PlayerAnalytics/issues");
onDisable();
}
@ -80,7 +90,7 @@ public class PlanVelocity extends VelocityPlugin implements PlanPlugin {
public void onDisable() {
system.disable();
slf4jLogger.info(locale.getString(PluginLang.DISABLED));
logger.info(locale.getString(PluginLang.DISABLED));
}
@Override
@ -90,7 +100,7 @@ public class PlanVelocity extends VelocityPlugin implements PlanPlugin {
@Override
public InputStream getResource(String resource) {
return getClass().getResourceAsStream(resource);
return getClass().getResourceAsStream("/" + resource);
}
@Override
@ -107,14 +117,4 @@ public class PlanVelocity extends VelocityPlugin implements PlanPlugin {
public boolean isReloading() {
return reloading;
}
@Override
public ProxyServer getProxy() {
return proxy;
}
@Override
protected Logger getLogger() {
return slf4jLogger;
}
}