Fix some issues with the sponge api version and loading the plugin

This commit is contained in:
Blue (Lukas Rieger) 2019-11-15 19:39:21 +01:00
parent 82ab8c2c7c
commit 705f97dabf
3 changed files with 16 additions and 11 deletions

View File

@ -1,5 +1,5 @@
dependencies {
shadow "org.spongepowered:spongeapi:7.2.0-SNAPSHOT"
shadow "org.spongepowered:spongeapi:7.1.0-SNAPSHOT"
compile group: 'org.bstats', name: 'bstats-sponge-lite', version: '1.5'
compile project(':BlueMapCore')
}

View File

@ -83,6 +83,14 @@ public class Commands {
.build();
}
public CommandSpec createStandaloneReloadCommand() {
return CommandSpec.builder()
.description(Text.of("BlueMaps root command"))
.childArgumentParseExceptionFallback(false)
.child(createReloadCommand(), "reload")
.build();
}
public CommandSpec createReloadCommand() {
return CommandSpec.builder()
.description(Text.of("Reloads all resources and configuration-files"))

View File

@ -34,7 +34,6 @@ import java.nio.file.Path;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.zip.GZIPInputStream;
@ -50,9 +49,7 @@ import org.spongepowered.api.event.game.GameReloadEvent;
import org.spongepowered.api.event.game.state.GameStartingServerEvent;
import org.spongepowered.api.event.game.state.GameStoppingEvent;
import org.spongepowered.api.plugin.Plugin;
import org.spongepowered.api.plugin.PluginContainer;
import org.spongepowered.api.scheduler.SpongeExecutorService;
import org.spongepowered.api.util.Tristate;
import com.flowpowered.math.vector.Vector2i;
import com.google.common.collect.Lists;
@ -140,6 +137,11 @@ public class SpongePlugin {
if (!defaultResourceFile.exists()) {
handleMissingResources(defaultResourceFile, configFile);
unload();
//only register reload command
Sponge.getCommandManager().register(this, new Commands(this).createStandaloneReloadCommand(), "bluemap");
return;
}
@ -246,15 +248,10 @@ public class SpongePlugin {
//metrics
Sponge.getScheduler().createTaskBuilder()
.async()
.delay(0, TimeUnit.MINUTES)
.delay(1, TimeUnit.MINUTES)
.interval(30, TimeUnit.MINUTES)
.execute(() -> {
Optional<PluginContainer> plugin = Sponge.getPluginManager().fromInstance(this);
if (!plugin.isPresent()) return;
Tristate metricsEnabled = Sponge.getMetricsConfigManager().getCollectionState(plugin.get());
if (metricsEnabled == Tristate.UNDEFINED) metricsEnabled = Sponge.getMetricsConfigManager().getGlobalCollectionState();
if (metricsEnabled == Tristate.TRUE) Metrics.sendReport("Sponge");
if (Sponge.getMetricsConfigManager().areMetricsEnabled(this)) Metrics.sendReport("Sponge");
})
.submit(this);