mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-27 19:47:49 +01:00
Sorted out bStats shenanigans
- Added bStats support for Velocity - Fixed Sponge bStats issues - Added bStats link for Velocity to html
This commit is contained in:
parent
94c9dd3f95
commit
3ee0d2e455
@ -90,7 +90,7 @@ subprojects {
|
|||||||
ext.geoIpVersion = "2.15.0"
|
ext.geoIpVersion = "2.15.0"
|
||||||
ext.gsonVersion = "2.8.6"
|
ext.gsonVersion = "2.8.6"
|
||||||
ext.guavaVersion = "28.0-jre"
|
ext.guavaVersion = "28.0-jre"
|
||||||
ext.bstatsVersion = "2.1.0"
|
ext.bstatsVersion = "2.2.1"
|
||||||
ext.placeholderapiVersion = "2.10.9"
|
ext.placeholderapiVersion = "2.10.9"
|
||||||
ext.nkPlaceholderapiVersion = "1.3-SNAPSHOT"
|
ext.nkPlaceholderapiVersion = "1.3-SNAPSHOT"
|
||||||
|
|
||||||
|
@ -202,6 +202,9 @@
|
|||||||
BungeeCord</a>
|
BungeeCord</a>
|
||||||
<a class="btn col-plan" href="https://bstats.org/plugin/sponge/plan" rel="noopener noreferrer"
|
<a class="btn col-plan" href="https://bstats.org/plugin/sponge/plan" rel="noopener noreferrer"
|
||||||
target="_blank"><i class="fa fa-fw fa-chart-area"></i> Sponge</a>
|
target="_blank"><i class="fa fa-fw fa-chart-area"></i> Sponge</a>
|
||||||
|
<a class="btn col-plan" href="https://bstats.org/plugin/velocity/Plan/10326"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
target="_blank"><i class="fa fa-fw fa-chart-area"></i> Velocity</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button class="btn bg-plan" data-dismiss="modal" type="button">OK</button>
|
<button class="btn bg-plan" data-dismiss="modal" type="button">OK</button>
|
||||||
|
@ -793,6 +793,9 @@
|
|||||||
rel="noopener noreferrer" target="_blank"><i class="fa fa-fw fa-chart-area"></i> BungeeCord</a>
|
rel="noopener noreferrer" target="_blank"><i class="fa fa-fw fa-chart-area"></i> BungeeCord</a>
|
||||||
<a class="btn col-plan" href="https://bstats.org/plugin/sponge/plan" rel="noopener noreferrer"
|
<a class="btn col-plan" href="https://bstats.org/plugin/sponge/plan" rel="noopener noreferrer"
|
||||||
target="_blank"><i class="fa fa-fw fa-chart-area"></i> Sponge</a>
|
target="_blank"><i class="fa fa-fw fa-chart-area"></i> Sponge</a>
|
||||||
|
<a class="btn col-plan" href="https://bstats.org/plugin/velocity/Plan/10326"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
target="_blank"><i class="fa fa-fw fa-chart-area"></i> Velocity</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button class="btn bg-plan" data-dismiss="modal" type="button">OK</button>
|
<button class="btn bg-plan" data-dismiss="modal" type="button">OK</button>
|
||||||
|
@ -662,6 +662,9 @@
|
|||||||
BungeeCord</a>
|
BungeeCord</a>
|
||||||
<a class="btn col-plan" href="https://bstats.org/plugin/sponge/plan" rel="noopener noreferrer"
|
<a class="btn col-plan" href="https://bstats.org/plugin/sponge/plan" rel="noopener noreferrer"
|
||||||
target="_blank"><i class="fa fa-fw fa-chart-area"></i> Sponge</a>
|
target="_blank"><i class="fa fa-fw fa-chart-area"></i> Sponge</a>
|
||||||
|
<a class="btn col-plan" href="https://bstats.org/plugin/velocity/Plan/10326"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
target="_blank"><i class="fa fa-fw fa-chart-area"></i> Velocity</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button class="btn bg-plan" data-dismiss="modal" type="button">OK</button>
|
<button class="btn bg-plan" data-dismiss="modal" type="button">OK</button>
|
||||||
|
@ -232,6 +232,9 @@
|
|||||||
BungeeCord</a>
|
BungeeCord</a>
|
||||||
<a class="btn col-plan" href="https://bstats.org/plugin/sponge/plan" rel="noopener noreferrer"
|
<a class="btn col-plan" href="https://bstats.org/plugin/sponge/plan" rel="noopener noreferrer"
|
||||||
target="_blank"><i class="fa fa-fw fa-chart-area"></i> Sponge</a>
|
target="_blank"><i class="fa fa-fw fa-chart-area"></i> Sponge</a>
|
||||||
|
<a class="btn col-plan" href="https://bstats.org/plugin/velocity/Plan/10326"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
target="_blank"><i class="fa fa-fw fa-chart-area"></i> Velocity</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button class="btn bg-plan" data-dismiss="modal" type="button">OK</button>
|
<button class="btn bg-plan" data-dismiss="modal" type="button">OK</button>
|
||||||
|
@ -284,6 +284,8 @@
|
|||||||
BungeeCord</a>
|
BungeeCord</a>
|
||||||
<a class="btn col-plan" href="https://bstats.org/plugin/sponge/plan" rel="noopener noreferrer"
|
<a class="btn col-plan" href="https://bstats.org/plugin/sponge/plan" rel="noopener noreferrer"
|
||||||
target="_blank"><i class="fa fa-fw fa-chart-area"></i> Sponge</a>
|
target="_blank"><i class="fa fa-fw fa-chart-area"></i> Sponge</a>
|
||||||
|
<a class="btn col-plan" href="https://bstats.org/plugin/velocity/Plan/10326" rel="noopener noreferrer"
|
||||||
|
target="_blank"><i class="fa fa-fw fa-chart-area"></i> Velocity</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button class="btn bg-plan" data-dismiss="modal" type="button">OK</button>
|
<button class="btn bg-plan" data-dismiss="modal" type="button">OK</button>
|
||||||
|
@ -1283,6 +1283,9 @@
|
|||||||
BungeeCord</a>
|
BungeeCord</a>
|
||||||
<a class="btn col-plan" href="https://bstats.org/plugin/sponge/plan" rel="noopener noreferrer"
|
<a class="btn col-plan" href="https://bstats.org/plugin/sponge/plan" rel="noopener noreferrer"
|
||||||
target="_blank"><i class="fa fa-fw fa-chart-area"></i> Sponge</a>
|
target="_blank"><i class="fa fa-fw fa-chart-area"></i> Sponge</a>
|
||||||
|
<a class="btn col-plan" href="https://bstats.org/plugin/velocity/Plan/10326"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
target="_blank"><i class="fa fa-fw fa-chart-area"></i> Velocity</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button class="btn bg-plan" data-dismiss="modal" type="button">OK</button>
|
<button class="btn bg-plan" data-dismiss="modal" type="button">OK</button>
|
||||||
|
@ -17,12 +17,13 @@
|
|||||||
package com.djrapitops.plan;
|
package com.djrapitops.plan;
|
||||||
|
|
||||||
import com.djrapitops.plan.storage.database.Database;
|
import com.djrapitops.plan.storage.database.Database;
|
||||||
|
import com.djrapitops.plugin.task.AbsRunnable;
|
||||||
import org.bstats.charts.SimplePie;
|
import org.bstats.charts.SimplePie;
|
||||||
import org.bstats.sponge.Metrics;
|
import org.bstats.sponge.Metrics;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
public class BStatsSponge {
|
public class BStatsSponge extends AbsRunnable {
|
||||||
|
|
||||||
private final Metrics metrics;
|
private final Metrics metrics;
|
||||||
private final Database database;
|
private final Database database;
|
||||||
@ -32,6 +33,11 @@ public class BStatsSponge {
|
|||||||
this.database = database;
|
this.database = database;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
registerMetrics();
|
||||||
|
}
|
||||||
|
|
||||||
public void registerMetrics() {
|
public void registerMetrics() {
|
||||||
if (metrics != null) {
|
if (metrics != null) {
|
||||||
registerConfigSettingGraphs();
|
registerConfigSettingGraphs();
|
||||||
|
@ -62,19 +62,27 @@ import java.util.Optional;
|
|||||||
)
|
)
|
||||||
public class PlanSponge extends SpongePlugin implements PlanPlugin {
|
public class PlanSponge extends SpongePlugin implements PlanPlugin {
|
||||||
|
|
||||||
@com.google.inject.Inject
|
private final Metrics metrics;
|
||||||
private Metrics.Factory metrics;
|
private final Logger slf4jLogger;
|
||||||
|
private final File dataFolder;
|
||||||
|
|
||||||
@com.google.inject.Inject
|
|
||||||
private Logger slf4jLogger;
|
|
||||||
|
|
||||||
@com.google.inject.Inject
|
|
||||||
@ConfigDir(sharedRoot = false)
|
|
||||||
private File dataFolder;
|
|
||||||
private PlanSystem system;
|
private PlanSystem system;
|
||||||
private Locale locale;
|
private Locale locale;
|
||||||
private ServerShutdownSave serverShutdownSave;
|
private ServerShutdownSave serverShutdownSave;
|
||||||
|
|
||||||
|
@com.google.inject.Inject
|
||||||
|
public PlanSponge(
|
||||||
|
Logger slf4jLogger,
|
||||||
|
@ConfigDir(sharedRoot = false) File dataFolder,
|
||||||
|
Metrics.Factory metrics
|
||||||
|
) {
|
||||||
|
this.slf4jLogger = slf4jLogger;
|
||||||
|
this.dataFolder = dataFolder;
|
||||||
|
|
||||||
|
int pluginId = 3086;
|
||||||
|
this.metrics = metrics.make(pluginId);
|
||||||
|
}
|
||||||
|
|
||||||
private final Map<String, CommandMapping> commands = new HashMap<>();
|
private final Map<String, CommandMapping> commands = new HashMap<>();
|
||||||
|
|
||||||
@Listener
|
@Listener
|
||||||
@ -96,10 +104,8 @@ public class PlanSponge extends SpongePlugin implements PlanPlugin {
|
|||||||
locale = system.getLocaleSystem().getLocale();
|
locale = system.getLocaleSystem().getLocale();
|
||||||
system.enable();
|
system.enable();
|
||||||
|
|
||||||
int pluginId = 3086;
|
|
||||||
new BStatsSponge(
|
new BStatsSponge(
|
||||||
metrics.make(pluginId),
|
metrics, system.getDatabaseSystem().getDatabase()
|
||||||
system.getDatabaseSystem().getDatabase()
|
|
||||||
).registerMetrics();
|
).registerMetrics();
|
||||||
|
|
||||||
logger.info(locale.getString(PluginLang.ENABLED));
|
logger.info(locale.getString(PluginLang.ENABLED));
|
||||||
|
@ -13,6 +13,7 @@ dependencies {
|
|||||||
compileOnly project(":api")
|
compileOnly project(":api")
|
||||||
|
|
||||||
compile "com.djrapitops:AbstractPluginFramework-velocity:$abstractPluginFrameworkVersion"
|
compile "com.djrapitops:AbstractPluginFramework-velocity:$abstractPluginFrameworkVersion"
|
||||||
|
compile "org.bstats:bstats-velocity:$bstatsVersion"
|
||||||
|
|
||||||
compileOnly "com.velocitypowered:velocity-api:$velocityVersion"
|
compileOnly "com.velocitypowered:velocity-api:$velocityVersion"
|
||||||
testCompile "com.velocitypowered:velocity-api:$velocityVersion"
|
testCompile "com.velocitypowered:velocity-api:$velocityVersion"
|
||||||
@ -24,6 +25,7 @@ dependencies {
|
|||||||
|
|
||||||
shadowJar {
|
shadowJar {
|
||||||
dependsOn blossomSourceReplacementJava
|
dependsOn blossomSourceReplacementJava
|
||||||
|
relocate 'org.bstats', 'com.djrapitops.plan.utilities.metrics'
|
||||||
|
|
||||||
configurations = [project.configurations.compile]
|
configurations = [project.configurations.compile]
|
||||||
}
|
}
|
@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* 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.storage.database.Database;
|
||||||
|
import com.djrapitops.plan.storage.database.queries.objects.ServerQueries;
|
||||||
|
import org.bstats.charts.SimplePie;
|
||||||
|
import org.bstats.velocity.Metrics;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
public class BStatsVelocity {
|
||||||
|
|
||||||
|
private final PlanVelocity plugin;
|
||||||
|
private final Database database;
|
||||||
|
|
||||||
|
private final Metrics metrics;
|
||||||
|
|
||||||
|
public BStatsVelocity(PlanVelocity plugin, Database database, Metrics metrics) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.database = database;
|
||||||
|
this.metrics = metrics;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerMetrics() {
|
||||||
|
registerConfigSettingGraphs();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerConfigSettingGraphs() {
|
||||||
|
addStringSettingPie("database_type", () -> database.getType().getName());
|
||||||
|
addStringSettingPie("network_servers", () -> String.valueOf(database.query(ServerQueries.fetchPlanServerInformationCollection()).size()));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addStringSettingPie(String id, Supplier<String> setting) {
|
||||||
|
metrics.addCustomChart(new SimplePie(id, setting::get));
|
||||||
|
}
|
||||||
|
}
|
@ -31,6 +31,7 @@ import com.velocitypowered.api.event.proxy.ProxyShutdownEvent;
|
|||||||
import com.velocitypowered.api.plugin.Plugin;
|
import com.velocitypowered.api.plugin.Plugin;
|
||||||
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
||||||
import com.velocitypowered.api.proxy.ProxyServer;
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
|
import org.bstats.velocity.Metrics;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@ -52,12 +53,19 @@ import java.nio.file.Path;
|
|||||||
)
|
)
|
||||||
public class PlanVelocity extends VelocityPlugin implements PlanPlugin {
|
public class PlanVelocity extends VelocityPlugin implements PlanPlugin {
|
||||||
|
|
||||||
|
private final Metrics.Factory metricsFactory;
|
||||||
private PlanSystem system;
|
private PlanSystem system;
|
||||||
private Locale locale;
|
private Locale locale;
|
||||||
|
|
||||||
@com.google.inject.Inject
|
@com.google.inject.Inject
|
||||||
public PlanVelocity(ProxyServer proxy, Logger slf4jLogger, @DataDirectory Path dataFolderPath) {
|
public PlanVelocity(
|
||||||
|
ProxyServer proxy,
|
||||||
|
Logger slf4jLogger,
|
||||||
|
@DataDirectory Path dataFolderPath,
|
||||||
|
Metrics.Factory metricsFactory
|
||||||
|
) {
|
||||||
super(proxy, slf4jLogger, dataFolderPath);
|
super(proxy, slf4jLogger, dataFolderPath);
|
||||||
|
this.metricsFactory = metricsFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@ -78,6 +86,13 @@ public class PlanVelocity extends VelocityPlugin implements PlanPlugin {
|
|||||||
locale = system.getLocaleSystem().getLocale();
|
locale = system.getLocaleSystem().getLocale();
|
||||||
system.enable();
|
system.enable();
|
||||||
|
|
||||||
|
int pluginId = 10326;
|
||||||
|
new BStatsVelocity(
|
||||||
|
this,
|
||||||
|
system.getDatabaseSystem().getDatabase(),
|
||||||
|
metricsFactory.make(this, pluginId)
|
||||||
|
).registerMetrics();
|
||||||
|
|
||||||
logger.info(locale.getString(PluginLang.ENABLED));
|
logger.info(locale.getString(PluginLang.ENABLED));
|
||||||
} catch (AbstractMethodError e) {
|
} catch (AbstractMethodError e) {
|
||||||
logger.error("Plugin ran into AbstractMethodError - Server restart is required. Likely cause is updating the jar without a restart.");
|
logger.error("Plugin ran into AbstractMethodError - Server restart is required. Likely cause is updating the jar without a restart.");
|
||||||
|
Loading…
Reference in New Issue
Block a user