Added metrics & made UpdateChecker optional

This commit is contained in:
stijnb1234 2020-02-21 10:18:59 +01:00
parent 383b99114a
commit a881adb64a
3 changed files with 39 additions and 11 deletions

21
pom.xml
View file

@ -52,9 +52,16 @@
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<relocations>
<relocation>
<pattern>org.bstats</pattern>
<shadedPattern>nl.SBDeveloper.V10Lift.Metrics</shadedPattern>
</relocation>
</relocations>
</configuration>
<executions>
<execution>
<id>shade</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
@ -135,6 +142,10 @@
<id>iobyte-repo</id>
<url>https://nexus.iobyte.nl/repository/maven-public/</url>
</repository>
<repository>
<id>CodeMC</id>
<url>https://repo.codemc.org/repository/maven-public</url>
</repository>
</repositories>
<dependencies>
@ -173,6 +184,14 @@
<artifactId>jackson-module-parameter-names</artifactId>
<version>2.10.2</version>
</dependency>
<!-- BStats, used for metrics -->
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>1.7</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View file

@ -8,9 +8,11 @@ import nl.SBDeveloper.V10Lift.Listeners.EntityDamageListener;
import nl.SBDeveloper.V10Lift.Listeners.PlayerInteractListener;
import nl.SBDeveloper.V10Lift.Listeners.SignChangeListener;
import nl.SBDeveloper.V10Lift.Managers.DBManager;
import nl.SBDeveloper.V10Lift.Managers.DataManager;
import nl.SBDevelopment.SBUtilities.Data.YamlFile;
import nl.SBDevelopment.SBUtilities.PrivateManagers.UpdateManager;
import nl.SBDevelopment.SBUtilities.SBUtilities;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
@ -55,16 +57,22 @@ public class V10LiftPlugin extends JavaPlugin {
Bukkit.getPluginManager().registerEvents(new SignChangeListener(), this);
Bukkit.getPluginManager().registerEvents(new EntityDamageListener(), this);
//Load metrics
Metrics metrics = new Metrics(this, 6564);
metrics.addCustomChart(new Metrics.SingleLineChart("lifts", () -> DataManager.getLifts().size()));
//Load the update checker
new UpdateManager(this, 72317, UpdateManager.CheckType.SPIGOT).handleResponse((versionResponse, version) -> {
if (versionResponse == UpdateManager.VersionResponse.FOUND_NEW) {
Bukkit.getLogger().warning("[V10Lift] There is a new version available! Current: " + this.getDescription().getVersion() + " New: " + version);
} else if (versionResponse == UpdateManager.VersionResponse.LATEST) {
Bukkit.getLogger().info("[V10Lift] You are running the latest version [" + this.getDescription().getVersion() + "]!");
} else if (versionResponse == UpdateManager.VersionResponse.UNAVAILABLE) {
Bukkit.getLogger().severe("[V10Lift] Unable to perform an update check.");
}
}).check();
if (getSConfig().getFile().getBoolean("CheckUpdates")) {
new UpdateManager(this, 72317, UpdateManager.CheckType.SPIGOT).handleResponse((versionResponse, version) -> {
if (versionResponse == UpdateManager.VersionResponse.FOUND_NEW) {
Bukkit.getLogger().warning("[V10Lift] There is a new version available! Current: " + this.getDescription().getVersion() + " New: " + version);
} else if (versionResponse == UpdateManager.VersionResponse.LATEST) {
Bukkit.getLogger().info("[V10Lift] You are running the latest version [" + this.getDescription().getVersion() + "]!");
} else if (versionResponse == UpdateManager.VersionResponse.UNAVAILABLE) {
Bukkit.getLogger().severe("[V10Lift] Unable to perform an update check.");
}
}).check();
}
Bukkit.getLogger().info("[V10Lift] Plugin loaded successfully!");
}

View file

@ -10,3 +10,4 @@ MasterRepairAmount: 10
DefaultSpeed: 16
DefaultRealistic: true
DoorCloseTime: 100
CheckUpdates: true