Add bStats support, seeing as mcstats has been down for ages

This commit is contained in:
sauilitired 2018-12-21 21:10:37 +01:00
parent 3c48488c61
commit 23b9eca4ab
3 changed files with 238 additions and 233 deletions

View File

@ -2,6 +2,7 @@ repositories {
maven { url "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" } maven { url "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" }
maven { url = "https://oss.sonatype.org/content/repositories/snapshots/" } maven { url = "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "http://nexus.hc.to/content/repositories/pub_releases" } maven { url "http://nexus.hc.to/content/repositories/pub_releases" }
maven { url = "https://repo.codemc.org/repository/maven-public" }
mavenLocal() mavenLocal()
} }
@ -10,6 +11,7 @@ dependencies {
testCompile project(':Core') testCompile project(':Core')
compile 'org.spigotmc:spigot-api:1.13.2-R0.1-SNAPSHOT' compile 'org.spigotmc:spigot-api:1.13.2-R0.1-SNAPSHOT'
compile(group: 'com.sk89q.worldedit', name: 'worldedit-bukkit', version: '7.0.0-SNAPSHOT') compile(group: 'com.sk89q.worldedit', name: 'worldedit-bukkit', version: '7.0.0-SNAPSHOT')
compile(group: 'org.bstats', name: 'bstats-bukkit', version: '1.4')
compile("net.milkbowl.vault:VaultAPI:1.7") { compile("net.milkbowl.vault:VaultAPI:1.7") {
exclude module: 'bukkit' exclude module: 'bukkit'
} }
@ -34,8 +36,9 @@ jar.enabled = false
shadowJar { shadowJar {
dependencies { dependencies {
include(dependency(':Core')) include(dependency(':Core'))
include(dependency('org.bstats:bstats-bukkit:1.4'))
} }
relocate('org.mcstats', 'com.plotsquared.stats') // relocate('org.mcstats', 'com.plotsquared.stats')
archiveName = "${parent.name}-${project.name}-${parent.version}.jar" archiveName = "${parent.name}-${project.name}-${parent.version}.jar"
destinationDir = file '../target' destinationDir = file '../target'
} }

View File

@ -113,6 +113,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
@Getter private SingleWorldListener singleWorldListener; @Getter private SingleWorldListener singleWorldListener;
private Method methodUnloadChunk0; private Method methodUnloadChunk0;
private boolean methodUnloadSetup = false; private boolean methodUnloadSetup = false;
private boolean metricsStarted;
@Override public int[] getServerVersion() { @Override public int[] getServerVersion() {
if (this.version == null) { if (this.version == null) {
@ -146,17 +147,14 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
new PlotSquared(this, "Bukkit"); new PlotSquared(this, "Bukkit");
if (Settings.Enabled_Components.METRICS) { if (Settings.Enabled_Components.METRICS) {
new Metrics(this).start(); // new Metrics(this).start();
PlotSquared.log(C.PREFIX + "&6Metrics enabled."); // PlotSquared.log(C.PREFIX + "&6Metrics enabled.");
this.startMetrics();
} else { } else {
PlotSquared.log(C.CONSOLE_PLEASE_ENABLE_METRICS.f(getPluginName())); PlotSquared.log(C.CONSOLE_PLEASE_ENABLE_METRICS.f(getPluginName()));
} }
if (Settings.Enabled_Components.WORLDS) { if (Settings.Enabled_Components.WORLDS) {
TaskManager.IMP.taskRepeat(new Runnable() { TaskManager.IMP.taskRepeat(this::unload, 20);
@Override public void run() {
unload();
}
}, 20);
try { try {
singleWorldListener = new SingleWorldListener(this); singleWorldListener = new SingleWorldListener(this);
} catch (Exception e) { } catch (Exception e) {
@ -165,7 +163,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
} }
} }
public void unload() { private void unload() {
if (!this.methodUnloadSetup) { if (!this.methodUnloadSetup) {
this.methodUnloadSetup = true; this.methodUnloadSetup = true;
try { try {
@ -298,9 +296,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
@Override @SuppressWarnings("deprecation") public void runEntityTask() { @Override @SuppressWarnings("deprecation") public void runEntityTask() {
PlotSquared.log(C.PREFIX + "KillAllEntities started."); PlotSquared.log(C.PREFIX + "KillAllEntities started.");
TaskManager.runTaskRepeat(new Runnable() { TaskManager.runTaskRepeat(() -> PlotSquared.get().foreachPlotArea(new RunnableVal<PlotArea>() {
@Override public void run() {
PlotSquared.get().foreachPlotArea(new RunnableVal<PlotArea>() {
@Override public void run(PlotArea plotArea) { @Override public void run(PlotArea plotArea) {
final World world = Bukkit.getWorld(plotArea.worldname); final World world = Bukkit.getWorld(plotArea.worldname);
try { try {
@ -543,9 +539,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
e.printStackTrace(); e.printStackTrace();
} }
} }
}); }), 20);
}
}, 20);
} }
@Override @Nullable @Override @Nullable
@ -740,8 +734,13 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
} }
@Override public void startMetrics() { @Override public void startMetrics() {
new Metrics(this).start(); if (this.metricsStarted) {
return;
}
// new Metrics(this).start(); mcstats
new org.bstats.bukkit.Metrics(this); // bstats
PlotSquared.log(C.PREFIX + "&6Metrics enabled."); PlotSquared.log(C.PREFIX + "&6Metrics enabled.");
this.metricsStarted = true;
} }
@Override public void setGenerator(@NonNull final String worldName) { @Override public void setGenerator(@NonNull final String worldName) {
@ -765,8 +764,8 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
if (!PlotSquared.get().hasPlotArea(worldName)) { if (!PlotSquared.get().hasPlotArea(worldName)) {
SetGenCB.setGenerator(BukkitUtil.getWorld(worldName)); SetGenCB.setGenerator(BukkitUtil.getWorld(worldName));
} }
} catch (Exception ignored) { } catch (Exception e) {
PlotSquared.log("Failed to reload world: " + world + " | " + ignored.getMessage()); PlotSquared.log("Failed to reload world: " + world + " | " + e.getMessage());
Bukkit.getServer().unloadWorld(world, false); Bukkit.getServer().unloadWorld(world, false);
return; return;
} }

View File

@ -31,7 +31,7 @@ import java.util.stream.Collectors;
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
public class BukkitLegacyMappings extends LegacyMappings { public final class BukkitLegacyMappings extends LegacyMappings {
private static final LegacyBlock[] BLOCKS = private static final LegacyBlock[] BLOCKS =
new LegacyBlock[] {new LegacyBlock(0, "air"), new LegacyBlock(1, "stone"), new LegacyBlock[] {new LegacyBlock(0, "air"), new LegacyBlock(1, "stone"),
@ -731,6 +731,9 @@ public class BukkitLegacyMappings extends LegacyMappings {
* @return LegacyBlock if found, else null * @return LegacyBlock if found, else null
*/ */
public PlotBlock fromAny(@NonNull final String string) { public PlotBlock fromAny(@NonNull final String string) {
if (string.isEmpty()) {
return StringPlotBlock.EVERYTHING;
}
String workingString = string; String workingString = string;
String[] parts = null; String[] parts = null;
if (string.contains(":")) { if (string.contains(":")) {