mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-25 11:35:18 +01:00
Sponge: Fix dump, add load message, move loading, handle reload
And fix travis
This commit is contained in:
parent
9a8a6e5b16
commit
90dabce0d2
@ -1,7 +1,7 @@
|
||||
sudo: false
|
||||
|
||||
language: java
|
||||
jdk: oraclejdk7
|
||||
jdk: oraclejdk8
|
||||
|
||||
cache:
|
||||
directories:
|
||||
|
5
TODOLIST
5
TODOLIST
@ -1,2 +1,7 @@
|
||||
PORT STUFF TO GUAVA :D (so we dont need to include commons)
|
||||
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
|
@ -57,7 +57,6 @@ public class ViaManager {
|
||||
// Mark as injected
|
||||
System.setProperty("ViaVersion", getPlatform().getPluginVersion());
|
||||
// If successful
|
||||
// TODO: This method might run in onLoad, ensure sync tasks can still run if plugin not enabled.
|
||||
platform.runSync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -1,10 +1,12 @@
|
||||
package us.myles.ViaVersion;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.inject.Inject;
|
||||
import org.spongepowered.api.Game;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
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.plugin.Plugin;
|
||||
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.configuration.ConfigurationProvider;
|
||||
import us.myles.ViaVersion.api.platform.ViaPlatform;
|
||||
import us.myles.ViaVersion.dump.PluginInfo;
|
||||
import us.myles.ViaVersion.sponge.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Logger;
|
||||
@ -42,7 +47,7 @@ public class SpongePlugin implements ViaPlatform {
|
||||
private Logger logger;
|
||||
|
||||
@Listener
|
||||
public void onServerStart(GameStartedServerEvent event) {
|
||||
public void onServerStart(GameAboutToStartServerEvent event) {
|
||||
// Setup Logger
|
||||
logger = new LoggerWrapper(container.getLogger());
|
||||
// Setup Plugin
|
||||
@ -50,6 +55,7 @@ public class SpongePlugin implements ViaPlatform {
|
||||
asyncExecutor = game.getScheduler().createAsyncExecutor(this);
|
||||
SpongeCommandHandler commandHandler = new SpongeCommandHandler();
|
||||
game.getCommandManager().register(this, commandHandler, Arrays.asList("viaversion", "viaver"));
|
||||
getLogger().info("ViaVersion " + getPluginVersion() + " is now loaded, injecting!");
|
||||
// Init platform
|
||||
Via.init(ViaManager.builder()
|
||||
.platform(this)
|
||||
@ -153,11 +159,25 @@ public class SpongePlugin implements ViaPlatform {
|
||||
|
||||
@Override
|
||||
public void onReload() {
|
||||
// TODO: Warning?
|
||||
getLogger().severe("ViaVersion is already loaded, this should work fine. If you get any console errors, try rebooting.");
|
||||
}
|
||||
|
||||
@Override
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user