Merge branch 'modular' of https://github.com/MylesIsCool/ViaVersion into modular

This commit is contained in:
Matsv 2016-09-26 13:25:47 +02:00
commit 8396c5a3e3
No known key found for this signature in database
GPG Key ID: 97CEC2A2EA31350F
4 changed files with 30 additions and 6 deletions

View File

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

View File

@ -1,2 +1,7 @@
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
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() {

View File

@ -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;
}
}