Sponge: Fix dump, add load message, move loading, handle reload

And fix travis
This commit is contained in:
Myles 2016-09-26 11:48:06 +01:00
parent 9a8a6e5b16
commit 90dabce0d2
4 changed files with 30 additions and 6 deletions

View File

@ -1,7 +1,7 @@
sudo: false sudo: false
language: java language: java
jdk: oraclejdk7 jdk: oraclejdk8
cache: cache:
directories: directories:

View File

@ -1,2 +1,7 @@
PORT STUFF TO GUAVA :D (so we dont need to include commons) PORT STUFF TO GUAVA :D (so we dont need to include commons)
Test on SpongeForge, only tested SpongeVanilla Test on SpongeForge, only tested SpongeVanilla
Stop using new Gson() everywhere
Java docs (for platforms etc)
Config implementation for sponge
Port bukkit listeners to sponge maybe
Fix task ids, methods for sponge

View File

@ -57,7 +57,6 @@ public class ViaManager {
// Mark as injected // Mark as injected
System.setProperty("ViaVersion", getPlatform().getPluginVersion()); System.setProperty("ViaVersion", getPlatform().getPluginVersion());
// If successful // If successful
// TODO: This method might run in onLoad, ensure sync tasks can still run if plugin not enabled.
platform.runSync(new Runnable() { platform.runSync(new Runnable() {
@Override @Override
public void run() { public void run() {

View File

@ -1,10 +1,12 @@
package us.myles.ViaVersion; package us.myles.ViaVersion;
import com.google.gson.Gson;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.inject.Inject; import com.google.inject.Inject;
import org.spongepowered.api.Game; import org.spongepowered.api.Game;
import org.spongepowered.api.entity.living.player.Player; import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.event.Listener; import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.game.state.GameAboutToStartServerEvent;
import org.spongepowered.api.event.game.state.GameStartedServerEvent; import org.spongepowered.api.event.game.state.GameStartedServerEvent;
import org.spongepowered.api.plugin.Plugin; import org.spongepowered.api.plugin.Plugin;
import org.spongepowered.api.plugin.PluginContainer; import org.spongepowered.api.plugin.PluginContainer;
@ -16,9 +18,12 @@ import us.myles.ViaVersion.api.ViaVersionConfig;
import us.myles.ViaVersion.api.command.ViaCommandSender; import us.myles.ViaVersion.api.command.ViaCommandSender;
import us.myles.ViaVersion.api.configuration.ConfigurationProvider; import us.myles.ViaVersion.api.configuration.ConfigurationProvider;
import us.myles.ViaVersion.api.platform.ViaPlatform; import us.myles.ViaVersion.api.platform.ViaPlatform;
import us.myles.ViaVersion.dump.PluginInfo;
import us.myles.ViaVersion.sponge.*; import us.myles.ViaVersion.sponge.*;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -42,7 +47,7 @@ public class SpongePlugin implements ViaPlatform {
private Logger logger; private Logger logger;
@Listener @Listener
public void onServerStart(GameStartedServerEvent event) { public void onServerStart(GameAboutToStartServerEvent event) {
// Setup Logger // Setup Logger
logger = new LoggerWrapper(container.getLogger()); logger = new LoggerWrapper(container.getLogger());
// Setup Plugin // Setup Plugin
@ -50,6 +55,7 @@ public class SpongePlugin implements ViaPlatform {
asyncExecutor = game.getScheduler().createAsyncExecutor(this); asyncExecutor = game.getScheduler().createAsyncExecutor(this);
SpongeCommandHandler commandHandler = new SpongeCommandHandler(); SpongeCommandHandler commandHandler = new SpongeCommandHandler();
game.getCommandManager().register(this, commandHandler, Arrays.asList("viaversion", "viaver")); game.getCommandManager().register(this, commandHandler, Arrays.asList("viaversion", "viaver"));
getLogger().info("ViaVersion " + getPluginVersion() + " is now loaded, injecting!");
// Init platform // Init platform
Via.init(ViaManager.builder() Via.init(ViaManager.builder()
.platform(this) .platform(this)
@ -153,11 +159,25 @@ public class SpongePlugin implements ViaPlatform {
@Override @Override
public void onReload() { public void onReload() {
// TODO: Warning? getLogger().severe("ViaVersion is already loaded, this should work fine. If you get any console errors, try rebooting.");
} }
@Override @Override
public JsonObject getDump() { public JsonObject getDump() {
return new JsonObject(); JsonObject platformSpecific = new JsonObject();
List<PluginInfo> plugins = new ArrayList<>();
for (PluginContainer p : game.getPluginManager().getPlugins()) {
plugins.add(new PluginInfo(
true,
p.getName(),
p.getVersion().orElse("Unknown Version"),
p.getInstance().isPresent() ? p.getInstance().get().getClass().getCanonicalName() : "Unknown",
p.getAuthors()
));
}
platformSpecific.add("plugins", new Gson().toJsonTree(plugins));
return platformSpecific;
} }
} }