diff --git a/bukkit/src/main/java/us/myles/ViaVersion/ViaVersionPlugin.java b/bukkit/src/main/java/us/myles/ViaVersion/ViaVersionPlugin.java
index eaf67ba9f..844905033 100644
--- a/bukkit/src/main/java/us/myles/ViaVersion/ViaVersionPlugin.java
+++ b/bukkit/src/main/java/us/myles/ViaVersion/ViaVersionPlugin.java
@@ -13,7 +13,6 @@ import us.myles.ViaVersion.api.ViaAPI;
import us.myles.ViaVersion.api.ViaVersion;
import us.myles.ViaVersion.api.command.ViaCommandSender;
import us.myles.ViaVersion.api.configuration.ConfigurationProvider;
-import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.platform.ViaPlatform;
import us.myles.ViaVersion.bukkit.*;
import us.myles.ViaVersion.classgenerator.ClassGenerator;
diff --git a/bukkit/src/main/java/us/myles/ViaVersion/handlers/ViaDecodeHandler.java b/bukkit/src/main/java/us/myles/ViaVersion/handlers/ViaDecodeHandler.java
index e021349a7..1d376c58d 100644
--- a/bukkit/src/main/java/us/myles/ViaVersion/handlers/ViaDecodeHandler.java
+++ b/bukkit/src/main/java/us/myles/ViaVersion/handlers/ViaDecodeHandler.java
@@ -3,10 +3,7 @@ package us.myles.ViaVersion.handlers;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
-import us.myles.ViaVersion.ViaVersionPlugin;
import us.myles.ViaVersion.api.PacketWrapper;
-import us.myles.ViaVersion.api.Via;
-import us.myles.ViaVersion.api.ViaVersion;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.exception.CancelException;
diff --git a/bukkit/src/main/java/us/myles/ViaVersion/handlers/ViaEncodeHandler.java b/bukkit/src/main/java/us/myles/ViaVersion/handlers/ViaEncodeHandler.java
index 9ef555c9e..67cac1581 100644
--- a/bukkit/src/main/java/us/myles/ViaVersion/handlers/ViaEncodeHandler.java
+++ b/bukkit/src/main/java/us/myles/ViaVersion/handlers/ViaEncodeHandler.java
@@ -6,7 +6,6 @@ import io.netty.handler.codec.MessageToByteEncoder;
import us.myles.ViaVersion.ViaVersionPlugin;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.Via;
-import us.myles.ViaVersion.api.ViaVersion;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.exception.CancelException;
diff --git a/bungee/pom.xml b/bungee/pom.xml
index bfad5ebd0..0a8ee274f 100644
--- a/bungee/pom.xml
+++ b/bungee/pom.xml
@@ -24,13 +24,31 @@
+
+
+
+ bungeecord-repo
+ https://oss.sonatype.org/content/repositories/snapshots
+
+
+
net.md-5
bungeecord-api
- 1.9-SNAPSHOT
+ 1.10-SNAPSHOT
provided
+
+ us.myles
+ viaversion-common
+ 1.0.0-ALPHA-modules
+
+
+ us.myles
+ viaversion-common
+ 1.0.0-ALPHA-modules
+
\ No newline at end of file
diff --git a/bungee/src/main/java/us/myles/ViaVersion/Bungee.java b/bungee/src/main/java/us/myles/ViaVersion/Bungee.java
index e5f3f4758..2e3284c29 100644
--- a/bungee/src/main/java/us/myles/ViaVersion/Bungee.java
+++ b/bungee/src/main/java/us/myles/ViaVersion/Bungee.java
@@ -1,18 +1,126 @@
package us.myles.ViaVersion;
+import com.google.gson.JsonObject;
+import net.md_5.bungee.api.chat.TextComponent;
+import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Plugin;
+import us.myles.ViaVersion.api.Via;
+import us.myles.ViaVersion.api.ViaAPI;
+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.bungee.BungeeViaAPI;
+import us.myles.ViaVersion.bungee.BungeeViaInjector;
+import us.myles.ViaVersion.bungee.BungeeViaLoader;
+import us.myles.ViaVersion.bungee.command.BungeeCommandSender;
+import us.myles.ViaVersion.bungee.config.BungeeConfigProvider;
-import static net.md_5.bungee.api.ChatColor.RED;
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
-public class Bungee extends Plugin {
+public class Bungee extends Plugin implements ViaPlatform {
+
+ private BungeeViaAPI api;
+ private BungeeConfigProvider config;
+
+ @Override
+ public void onLoad() {
+ api = new BungeeViaAPI();
+ config = new BungeeConfigProvider();
+ }
@Override
public void onEnable() {
- getLogger().severe(RED + "===============================================");
- getLogger().severe(RED + "ViaVersion is NOT a Bungeecord plugin.");
- getLogger().severe(RED + "Install this plugin on all your spigot/bukkit");
- getLogger().severe(RED + "servers and use the latest Bungeecord version");
- getLogger().severe(RED + "to make ViaVersion work with BungeeCord.");
- getLogger().severe(RED + "===============================================");
+ Via.init(ViaManager.builder()
+ .platform(this)
+ .injector(new BungeeViaInjector())
+ .loader(new BungeeViaLoader())
+ .build());
}
+
+ @Override
+ public String getPlatformName() {
+ return "BungeeCord";
+ }
+
+ @Override
+ public String getPluginVersion() {
+ return getDescription().getVersion();
+ }
+
+ @Override
+ public int runAsync(Runnable runnable) {
+ return getProxy().getScheduler().runAsync(this, runnable).getId();
+ }
+
+ @Override
+ public int runSync(Runnable runnable) {
+ return getProxy().getScheduler().runAsync(this, runnable).getId(); // TODO don't run sync @ Bungee?
+ }
+
+ @Override
+ public int runRepeatingSync(Runnable runnable, Long ticks) {
+ return getProxy().getScheduler().schedule(this, runnable, 0, ticks * 50, TimeUnit.MILLISECONDS).getId();
+ }
+
+ @Override
+ public void cancelTask(int taskId) {
+ getProxy().getScheduler().cancel(taskId);
+ }
+
+ @Override
+ public ViaCommandSender[] getOnlinePlayers() {
+ ViaCommandSender[] array = new ViaCommandSender[getProxy().getPlayers().size()];
+ int i = 0;
+ for (ProxiedPlayer player : getProxy().getPlayers()) {
+ array[i++] = new BungeeCommandSender(player);
+ }
+ return array;
+ }
+
+ @Override
+ public void sendMessage(UUID uuid, String message) {
+ getProxy().getPlayer(uuid).sendMessage(new TextComponent(message));
+ }
+
+ @Override
+ public boolean kickPlayer(UUID uuid, String message) {
+ if (getProxy().getPlayer(uuid) != null) {
+ getProxy().getPlayer(uuid).disconnect(new TextComponent(message));
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean isPluginEnabled() {
+ return true;
+ }
+
+ @Override
+ public ViaAPI getApi() {
+ return api;
+ }
+
+ @Override
+ public ViaVersionConfig getConf() {
+ return config;
+ }
+
+ @Override
+ public ConfigurationProvider getConfigurationProvider() {
+ return config;
+ }
+
+ @Override
+ public void onReload() {
+ // TODO handle
+ }
+
+ @Override
+ public JsonObject getDump() {
+ return null;
+ }
+
}
diff --git a/bungee/src/main/java/us/myles/ViaVersion/bungee/BungeeBossBar.java b/bungee/src/main/java/us/myles/ViaVersion/bungee/BungeeBossBar.java
new file mode 100644
index 000000000..e377921c5
--- /dev/null
+++ b/bungee/src/main/java/us/myles/ViaVersion/bungee/BungeeBossBar.java
@@ -0,0 +1,34 @@
+package us.myles.ViaVersion.bungee;
+
+import net.md_5.bungee.api.connection.ProxiedPlayer;
+import us.myles.ViaVersion.api.boss.BossBar;
+import us.myles.ViaVersion.api.boss.BossColor;
+import us.myles.ViaVersion.api.boss.BossStyle;
+import us.myles.ViaVersion.boss.CommonBoss;
+
+public class BungeeBossBar extends CommonBoss {
+
+ public BungeeBossBar(String title, float health, BossColor color, BossStyle style) {
+ super(title, health, color, style);
+ }
+
+
+ @Override
+ public BossBar addPlayer(ProxiedPlayer player) {
+ addPlayer(player.getUniqueId());
+ return this;
+ }
+
+ @Override
+ public BossBar addPlayers(ProxiedPlayer... players) {
+ for (ProxiedPlayer p : players)
+ addPlayer(p);
+ return this;
+ }
+
+ @Override
+ public BossBar removePlayer(ProxiedPlayer player) {
+ removePlayer(player.getUniqueId());
+ return this;
+ }
+}
diff --git a/bungee/src/main/java/us/myles/ViaVersion/bungee/BungeeViaAPI.java b/bungee/src/main/java/us/myles/ViaVersion/bungee/BungeeViaAPI.java
new file mode 100644
index 000000000..ce33fed0b
--- /dev/null
+++ b/bungee/src/main/java/us/myles/ViaVersion/bungee/BungeeViaAPI.java
@@ -0,0 +1,78 @@
+package us.myles.ViaVersion.bungee;
+
+import io.netty.buffer.ByteBuf;
+import lombok.NonNull;
+import net.md_5.bungee.api.connection.ProxiedPlayer;
+import us.myles.ViaVersion.api.Via;
+import us.myles.ViaVersion.api.ViaAPI;
+import us.myles.ViaVersion.api.boss.BossBar;
+import us.myles.ViaVersion.api.boss.BossColor;
+import us.myles.ViaVersion.api.boss.BossStyle;
+import us.myles.ViaVersion.api.data.UserConnection;
+import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
+import us.myles.ViaVersion.protocols.base.ProtocolInfo;
+
+import java.util.Map;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import java.util.UUID;
+
+public class BungeeViaAPI implements ViaAPI {
+ @Override
+ public int getPlayerVersion(@NonNull ProxiedPlayer player) {
+ if (!isPorted(player.getUniqueId()))
+ return ProtocolRegistry.SERVER_PROTOCOL;
+ return getPortedPlayers().get(player.getUniqueId()).get(ProtocolInfo.class).getProtocolVersion();
+ }
+
+ @Override
+ public int getPlayerVersion(@NonNull UUID uuid) {
+ if (!isPorted(uuid))
+ return ProtocolRegistry.SERVER_PROTOCOL;
+ return getPortedPlayers().get(uuid).get(ProtocolInfo.class).getProtocolVersion();
+ }
+
+ @Override
+ public boolean isPorted(UUID playerUUID) {
+ return getPortedPlayers().containsKey(playerUUID);
+ }
+
+ @Override
+ public String getVersion() {
+ return Via.getPlatform().getPluginVersion();
+ }
+
+ @Override
+ public void sendRawPacket(UUID uuid, ByteBuf packet) throws IllegalArgumentException {
+ if (!isPorted(uuid)) throw new IllegalArgumentException("This player is not controlled by ViaVersion!");
+ UserConnection ci = getPortedPlayers().get(uuid);
+ ci.sendRawPacket(packet);
+ }
+
+ @Override
+ public void sendRawPacket(ProxiedPlayer player, ByteBuf packet) throws IllegalArgumentException {
+ sendRawPacket(player.getUniqueId(), packet);
+ }
+
+ @Override
+ public BossBar createBossBar(String title, BossColor color, BossStyle style) {
+ return new BungeeBossBar(title, 1F, color, style);
+ }
+
+ @Override
+ public BossBar createBossBar(String title, float health, BossColor color, BossStyle style) {
+ return new BungeeBossBar(title, health, color, style);
+ }
+
+ @Override
+ public SortedSet getSupportedVersions() {
+ SortedSet outputSet = new TreeSet<>(ProtocolRegistry.getSupportedVersions());
+ outputSet.removeAll(Via.getPlatform().getConf().getBlockedProtocols());
+
+ return outputSet;
+ }
+
+ public Map getPortedPlayers() {
+ return Via.getManager().getPortedPlayers();
+ }
+}
diff --git a/bungee/src/main/java/us/myles/ViaVersion/bungee/BungeeViaInjector.java b/bungee/src/main/java/us/myles/ViaVersion/bungee/BungeeViaInjector.java
new file mode 100644
index 000000000..17214b49f
--- /dev/null
+++ b/bungee/src/main/java/us/myles/ViaVersion/bungee/BungeeViaInjector.java
@@ -0,0 +1,20 @@
+package us.myles.ViaVersion.bungee;
+
+import us.myles.ViaVersion.api.platform.ViaInjector;
+
+public class BungeeViaInjector implements ViaInjector {
+ @Override
+ public void inject() throws Exception {
+
+ }
+
+ @Override
+ public void uninject() throws Exception {
+
+ }
+
+ @Override
+ public int getServerProtocolVersion() throws Exception {
+ return 47;
+ }
+}
diff --git a/bungee/src/main/java/us/myles/ViaVersion/bungee/BungeeViaLoader.java b/bungee/src/main/java/us/myles/ViaVersion/bungee/BungeeViaLoader.java
new file mode 100644
index 000000000..fd179b048
--- /dev/null
+++ b/bungee/src/main/java/us/myles/ViaVersion/bungee/BungeeViaLoader.java
@@ -0,0 +1,10 @@
+package us.myles.ViaVersion.bungee;
+
+import us.myles.ViaVersion.api.platform.ViaPlatformLoader;
+
+public class BungeeViaLoader implements ViaPlatformLoader {
+ @Override
+ public void load() {
+
+ }
+}
diff --git a/bungee/src/main/java/us/myles/ViaVersion/bungee/command/BungeeCommandSender.java b/bungee/src/main/java/us/myles/ViaVersion/bungee/command/BungeeCommandSender.java
new file mode 100644
index 000000000..e5f21482c
--- /dev/null
+++ b/bungee/src/main/java/us/myles/ViaVersion/bungee/command/BungeeCommandSender.java
@@ -0,0 +1,38 @@
+package us.myles.ViaVersion.bungee.command;
+
+import lombok.AllArgsConstructor;
+import net.md_5.bungee.api.CommandSender;
+import net.md_5.bungee.api.chat.TextComponent;
+import net.md_5.bungee.api.connection.ProxiedPlayer;
+import us.myles.ViaVersion.api.command.ViaCommandSender;
+
+import java.util.UUID;
+
+@AllArgsConstructor
+public class BungeeCommandSender implements ViaCommandSender {
+ private CommandSender sender;
+
+ @Override
+ public boolean hasPermission(String permission) {
+ return sender.hasPermission(permission);
+ }
+
+ @Override
+ public void sendMessage(String msg) {
+ sender.sendMessage(new TextComponent(msg));
+ }
+
+ @Override
+ public UUID getUUID() {
+ if (sender instanceof ProxiedPlayer) {
+ return ((ProxiedPlayer) sender).getUniqueId();
+ } else {
+ return UUID.fromString(getName());
+ }
+ }
+
+ @Override
+ public String getName() {
+ return sender.getName();
+ }
+}
diff --git a/bungee/src/main/java/us/myles/ViaVersion/bungee/config/BungeeConfigProvider.java b/bungee/src/main/java/us/myles/ViaVersion/bungee/config/BungeeConfigProvider.java
new file mode 100644
index 000000000..d2eb518f2
--- /dev/null
+++ b/bungee/src/main/java/us/myles/ViaVersion/bungee/config/BungeeConfigProvider.java
@@ -0,0 +1,175 @@
+package us.myles.ViaVersion.bungee.config;
+
+import us.myles.ViaVersion.api.ViaVersionConfig;
+import us.myles.ViaVersion.api.configuration.ConfigurationProvider;
+
+import java.util.List;
+import java.util.Map;
+
+// TODO implement
+public class BungeeConfigProvider implements ViaVersionConfig, ConfigurationProvider {
+ @Override
+ public boolean isCheckForUpdates() {
+ return false;
+ }
+
+ @Override
+ public boolean isPreventCollision() {
+ return false;
+ }
+
+ @Override
+ public boolean isNewEffectIndicator() {
+ return false;
+ }
+
+ @Override
+ public boolean isShowNewDeathMessages() {
+ return false;
+ }
+
+ @Override
+ public boolean isSuppressMetadataErrors() {
+ return false;
+ }
+
+ @Override
+ public boolean isShieldBlocking() {
+ return false;
+ }
+
+ @Override
+ public boolean isHologramPatch() {
+ return false;
+ }
+
+ @Override
+ public boolean isBossbarPatch() {
+ return false;
+ }
+
+ @Override
+ public boolean isBossbarAntiflicker() {
+ return false;
+ }
+
+ @Override
+ public boolean isUnknownEntitiesSuppressed() {
+ return false;
+ }
+
+ @Override
+ public double getHologramYOffset() {
+ return 0;
+ }
+
+ @Override
+ public boolean isAutoTeam() {
+ return false;
+ }
+
+ @Override
+ public boolean isBlockBreakPatch() {
+ return false;
+ }
+
+ @Override
+ public int getMaxPPS() {
+ return 0;
+ }
+
+ @Override
+ public String getMaxPPSKickMessage() {
+ return null;
+ }
+
+ @Override
+ public int getTrackingPeriod() {
+ return 0;
+ }
+
+ @Override
+ public int getWarningPPS() {
+ return 0;
+ }
+
+ @Override
+ public int getMaxWarnings() {
+ return 0;
+ }
+
+ @Override
+ public String getMaxWarningsKickMessage() {
+ return null;
+ }
+
+ @Override
+ public boolean isAntiXRay() {
+ return false;
+ }
+
+ @Override
+ public boolean isSendSupportedVersions() {
+ return false;
+ }
+
+ @Override
+ public boolean isStimulatePlayerTick() {
+ return false;
+ }
+
+ @Override
+ public boolean isItemCache() {
+ return false;
+ }
+
+ @Override
+ public boolean isNMSPlayerTicking() {
+ return false;
+ }
+
+ @Override
+ public boolean isReplacePistons() {
+ return false;
+ }
+
+ @Override
+ public int getPistonReplacementId() {
+ return 0;
+ }
+
+ @Override
+ public boolean isForceJsonTransform() {
+ return false;
+ }
+
+ @Override
+ public List getBlockedProtocols() {
+ return null;
+ }
+
+ @Override
+ public String getBlockedDisconnectMsg() {
+ return null;
+ }
+
+ @Override
+ public String getReloadDisconnectMsg() {
+ return null;
+ }
+
+ @Override
+ public void set(String path, Object value) {
+
+ }
+
+ @Override
+ public void saveConfig() {
+
+ }
+
+ @Override
+ public Map getValues() {
+ return null;
+ }
+}
diff --git a/pom.xml b/pom.xml
index 3cd69f629..5c778885a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -48,12 +48,6 @@
spacehq-repo
https://repo.spacehq.org/content/repositories/releases/
-
-
-
- bungeecord-repo
- https://oss.sonatype.org/content/repositories/snapshots
-