mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-12-28 03:57:39 +01:00
Shaded bStats' Metrics
Also removed custom metrics for the moment. This will later be used to allow addons to register their own metrics :)
This commit is contained in:
parent
d04b286055
commit
4c319dd0e0
35
pom.xml
35
pom.xml
@ -51,15 +51,27 @@
|
|||||||
<id>spigot-repo</id>
|
<id>spigot-repo</id>
|
||||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots</url>
|
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>bstats-repo</id>
|
||||||
|
<url>http://repo.bstats.org/content/repositories/releases/</url>
|
||||||
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<!-- Spigot API -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.13-R0.1-SNAPSHOT</version>
|
<version>1.13-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- Metrics -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.bstats</groupId>
|
||||||
|
<artifactId>bstats-bukkit</artifactId>
|
||||||
|
<version>1.2</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- Mockito (Unit testing) -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mockito</groupId>
|
<groupId>org.mockito</groupId>
|
||||||
<artifactId>mockito-all</artifactId>
|
<artifactId>mockito-all</artifactId>
|
||||||
@ -78,6 +90,7 @@
|
|||||||
<version>${powermock.version}</version>
|
<version>${powermock.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- Database -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mongodb</groupId>
|
<groupId>org.mongodb</groupId>
|
||||||
<artifactId>mongodb-driver</artifactId>
|
<artifactId>mongodb-driver</artifactId>
|
||||||
@ -166,6 +179,27 @@
|
|||||||
<configuration>
|
<configuration>
|
||||||
<minimizeJar>false</minimizeJar>
|
<minimizeJar>false</minimizeJar>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<configuration>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>shade</goal>
|
||||||
|
</goals>
|
||||||
|
<artifactSet>
|
||||||
|
<includes>
|
||||||
|
<include>org.bstats:bstats-bukkit</include>
|
||||||
|
</includes>
|
||||||
|
</artifactSet>
|
||||||
|
<relocations>
|
||||||
|
<relocation>
|
||||||
|
<pattern>org.bstats</pattern>
|
||||||
|
<shadedPattern>world.bentobox.bentobox.util.metrics</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
</relocations>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
@ -213,7 +247,6 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
|
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
|
||||||
<sonar.organization>tastybento-github</sonar.organization>
|
<sonar.organization>tastybento-github</sonar.organization>
|
||||||
<sonar.exclusions>**/Metrics.java</sonar.exclusions>
|
|
||||||
</properties>
|
</properties>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
22
src/main/java/world/bentobox/bentobox/BStats.java
Normal file
22
src/main/java/world/bentobox/bentobox/BStats.java
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package world.bentobox.bentobox;
|
||||||
|
|
||||||
|
import org.bstats.bukkit.Metrics;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Poslovitch
|
||||||
|
*/
|
||||||
|
class BStats {
|
||||||
|
|
||||||
|
private final BentoBox plugin;
|
||||||
|
private Metrics metrics;
|
||||||
|
|
||||||
|
BStats(BentoBox plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
void registerMetrics() {
|
||||||
|
if (metrics == null) {
|
||||||
|
metrics = new Metrics(plugin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package world.bentobox.bentobox;
|
package world.bentobox.bentobox;
|
||||||
|
|
||||||
|
import org.bstats.bukkit.Metrics;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
@ -40,8 +41,8 @@ public class BentoBox extends JavaPlugin {
|
|||||||
private PlayersManager playersManager;
|
private PlayersManager playersManager;
|
||||||
private IslandsManager islandsManager;
|
private IslandsManager islandsManager;
|
||||||
|
|
||||||
// Metrics
|
// bStats
|
||||||
private Metrics metrics;
|
private BStats bStats;
|
||||||
|
|
||||||
// Managers
|
// Managers
|
||||||
private CommandsManager commandsManager;
|
private CommandsManager commandsManager;
|
||||||
@ -73,7 +74,7 @@ public class BentoBox extends JavaPlugin {
|
|||||||
saveDefaultConfig();
|
saveDefaultConfig();
|
||||||
setInstance(this);
|
setInstance(this);
|
||||||
// Load Flags
|
// Load Flags
|
||||||
flagsManager = new FlagsManager(instance);
|
flagsManager = new FlagsManager(this);
|
||||||
|
|
||||||
// Load settings from config.yml. This will check if there are any issues with it too.
|
// Load settings from config.yml. This will check if there are any issues with it too.
|
||||||
settings = new Config<>(this, Settings.class).loadConfigObject("");
|
settings = new Config<>(this, Settings.class).loadConfigObject("");
|
||||||
@ -90,8 +91,7 @@ public class BentoBox extends JavaPlugin {
|
|||||||
headGetter = new HeadGetter(this);
|
headGetter = new HeadGetter(this);
|
||||||
|
|
||||||
// Load metrics
|
// Load metrics
|
||||||
metrics = new Metrics(instance);
|
bStats = new BStats(this);
|
||||||
registerCustomCharts();
|
|
||||||
|
|
||||||
// Load Notifier
|
// Load Notifier
|
||||||
notifier = new Notifier();
|
notifier = new Notifier();
|
||||||
@ -138,6 +138,9 @@ public class BentoBox extends JavaPlugin {
|
|||||||
instance.log("- Tastybento and Poslovitch, 2017-2018");
|
instance.log("- Tastybento and Poslovitch, 2017-2018");
|
||||||
instance.log("#############################################");
|
instance.log("#############################################");
|
||||||
|
|
||||||
|
// Register metrics
|
||||||
|
bStats.registerMetrics();
|
||||||
|
|
||||||
// Fire plugin ready event
|
// Fire plugin ready event
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new BentoBoxReadyEvent());
|
Bukkit.getServer().getPluginManager().callEvent(new BentoBoxReadyEvent());
|
||||||
});
|
});
|
||||||
@ -180,42 +183,6 @@ public class BentoBox extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerCustomCharts(){
|
|
||||||
metrics.addCustomChart(new Metrics.SingleLineChart("islands_count") {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getValue() {
|
|
||||||
return islandsManager.getCount();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
metrics.addCustomChart(new Metrics.SingleLineChart("created_islands") {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getValue() {
|
|
||||||
int created = islandsManager.metricsGetCreatedCount();
|
|
||||||
islandsManager.metricsSetCreatedCount(0);
|
|
||||||
return created;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
metrics.addCustomChart(new Metrics.SimplePie("default_locale") {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getValue() {
|
|
||||||
return getSettings().getDefaultLanguage();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
metrics.addCustomChart(new Metrics.SimplePie("database") {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getValue() {
|
|
||||||
return DatabaseSetup.getDatabase().toString();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the player database
|
* Returns the player database
|
||||||
* @return the player database
|
* @return the player database
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -65,9 +65,6 @@ public class IslandsManager {
|
|||||||
// Async database saving semaphore
|
// Async database saving semaphore
|
||||||
private boolean midSave;
|
private boolean midSave;
|
||||||
|
|
||||||
// Metrics data
|
|
||||||
private int metricsCreatedCount = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Islands Manager
|
* Islands Manager
|
||||||
* @param plugin - plugin
|
* @param plugin - plugin
|
||||||
@ -624,14 +621,6 @@ public class IslandsManager {
|
|||||||
return getIslandAt(loc).filter(i -> i.onIsland(loc)).map(i -> i.getMemberSet().contains(player.getUniqueId())).orElse(false);
|
return getIslandAt(loc).filter(i -> i.onIsland(loc)).map(i -> i.getMemberSet().contains(player.getUniqueId())).orElse(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int metricsGetCreatedCount(){
|
|
||||||
return metricsCreatedCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void metricsSetCreatedCount(int count){
|
|
||||||
metricsCreatedCount = count;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if an online player is in the protected area of their island, a team island or a
|
* Checks if an online player is in the protected area of their island, a team island or a
|
||||||
* coop island in the specific world in the arguments. Note that the user
|
* coop island in the specific world in the arguments. Note that the user
|
||||||
|
Loading…
Reference in New Issue
Block a user