Skip to content

Commit

Permalink
fix(expansion): only register when papi is present
Browse files Browse the repository at this point in the history
  • Loading branch information
BrycensRanch committed Mar 18, 2023
1 parent d92a1a0 commit 74d5e69
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/main/java/me/romvnly/TownyPlus/TownyPlusMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ public void onEnable() {
saveDefaultConfig();
Config.reload();
Lang.reload();
if (pluginManager.getPlugin("PlaceholderAPI") != null && pluginManager.isPluginEnabled("PlaceholderAPI")) {

expansion = new TownyPlusExpansion();
Boolean didRegisterSuccessfully = expansion.register();
if (didRegisterSuccessfully) {
Expand All @@ -153,6 +155,7 @@ public void onEnable() {
else {
logger.warn("Failed to register with PlaceholderAPI!");
}
}
if (Config.DEBUG_MODE) {
logger.info("Debug mode is enabled. This will cause a lot of spam in the console.");
}
Expand Down Expand Up @@ -209,10 +212,21 @@ public void onEnable() {
metrics.addCustomChart(new SimplePie("internal_web_server", () ->
BooleanUtils.toStringTrueFalse(Config.HTTPD_ENABLED)
));
metrics.addCustomChart(new DrilldownPie("plugin_version", () -> {
String[] version = getDescription().getVersion().split("-");
return Map.of(version[0], Map.of(version[1], 1));
}));
metrics.addCustomChart(new SimplePie("branch", () ->
GitProperties.getGitProperty("git.branch")
));
metrics.addCustomChart(new SimplePie("database_type", () ->
Config.DB_TYPE
));
metrics.addCustomChart(new SimplePie("checking_for_updates", () ->
BooleanUtils.toStringTrueFalse(Config.CHECK_FOR_UPDATES)
));
metrics.addCustomChart(new SimplePie("auto_updating", () ->
BooleanUtils.toStringTrueFalse(Config.AUTO_UPDATE_PLUGIN)
));
metrics.addCustomChart(new SimplePie("discordsrv_integration", () ->
BooleanUtils.toStringTrueFalse(Config.DISCORDSRV_ENABLED)
));
}
if (Config.CHECK_FOR_UPDATES) {
this.updateChecker = new UpdateChecker(this, UpdateCheckSource.GITHUB_RELEASE_TAG, githubRepo)
Expand Down Expand Up @@ -314,6 +328,7 @@ public void onDisable() {
}
logger.info("Plugin has been disabled.");
if (this.database != null) this.database.close();
if (expansion != null)
expansion.unregister();
if (this.isEnabled()) Bukkit.getServer().getPluginManager().disablePlugin(this);
Bukkit.getScheduler().cancelTasks(this);
Expand Down

0 comments on commit 74d5e69

Please sign in to comment.