diff --git a/api/pom.xml b/api/pom.xml index 9ba5570e39..308654558d 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -18,6 +18,11 @@ API implemented by the Elastic Portal Suite + + tc.oc + minecraft-api + 1.8-SNAPSHOT + tc.oc bungeecord-chat diff --git a/api/src/main/java/net/md_5/bungee/api/CommandSender.java b/api/src/main/java/net/md_5/bungee/api/CommandSender.java index a35b3fd0c9..798ca60dda 100644 --- a/api/src/main/java/net/md_5/bungee/api/CommandSender.java +++ b/api/src/main/java/net/md_5/bungee/api/CommandSender.java @@ -1,27 +1,10 @@ package net.md_5.bungee.api; -import net.md_5.bungee.api.chat.BaseComponent; - import java.util.Collection; -public interface CommandSender +public interface CommandSender extends tc.oc.minecraft.api.command.CommandSender { - /** - * Get the unique name of this command sender. - * - * @return the senders username - */ - public String getName(); - - /** - * Send a message to this sender. - * - * @param message the message to send - */ - @Deprecated - public void sendMessage(String message); - /** * Send several messages to this sender. Each message will be sent * separately. @@ -31,20 +14,6 @@ public interface CommandSender @Deprecated public void sendMessages(String... messages); - /** - * Send a message to this sender. - * - * @param message the message to send - */ - public void sendMessage(BaseComponent... message); - - /** - * Send a message to this sender. - * - * @param message the message to send - */ - public void sendMessage(BaseComponent message); - /** * Get all groups this user is part of. This returns an unmodifiable * collection. @@ -67,14 +36,6 @@ public interface CommandSender */ public void removeGroups(String... groups); - /** - * Checks if this user has the specified permission node. - * - * @param permission the node to check - * @return whether they have this node - */ - public boolean hasPermission(String permission); - /** * Set a permission node for this user. * diff --git a/api/src/main/java/net/md_5/bungee/api/ProxyServer.java b/api/src/main/java/net/md_5/bungee/api/ProxyServer.java index 33ebc5c192..0142c538ba 100644 --- a/api/src/main/java/net/md_5/bungee/api/ProxyServer.java +++ b/api/src/main/java/net/md_5/bungee/api/ProxyServer.java @@ -16,7 +16,7 @@ import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.api.scheduler.TaskScheduler; -public abstract class ProxyServer +public abstract class ProxyServer implements tc.oc.minecraft.api.server.LocalServer { @Getter @@ -87,6 +87,18 @@ public static void setInstance(ProxyServer instance) */ public abstract ProxiedPlayer getPlayer(UUID uuid); + @Override + public ProxiedPlayer getPlayerExact(String name) + { + return getPlayer( name ); + } + + @Override + public Collection getOnlinePlayers() + { + return getPlayers(); + } + /** * Return all servers registered to this proxy, keyed by name. Unlike the * methods in {@link ConfigurationAdapter#getServers()}, this will not diff --git a/api/src/main/java/net/md_5/bungee/api/config/ServerInfo.java b/api/src/main/java/net/md_5/bungee/api/config/ServerInfo.java index e9f1ff6696..74b2791d78 100644 --- a/api/src/main/java/net/md_5/bungee/api/config/ServerInfo.java +++ b/api/src/main/java/net/md_5/bungee/api/config/ServerInfo.java @@ -10,7 +10,7 @@ /** * Class used to represent a server to connect to. */ -public interface ServerInfo +public interface ServerInfo extends tc.oc.minecraft.api.server.Server { /** diff --git a/api/src/main/java/net/md_5/bungee/api/connection/ProxiedPlayer.java b/api/src/main/java/net/md_5/bungee/api/connection/ProxiedPlayer.java index 375815c446..204d452b30 100644 --- a/api/src/main/java/net/md_5/bungee/api/connection/ProxiedPlayer.java +++ b/api/src/main/java/net/md_5/bungee/api/connection/ProxiedPlayer.java @@ -2,7 +2,7 @@ import java.util.Locale; import java.util.Map; -import java.util.UUID; + import net.md_5.bungee.api.Callback; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.CommandSender; @@ -14,24 +14,9 @@ * Represents a player who's connection is being connected to somewhere else, * whether it be a remote or embedded server. */ -public interface ProxiedPlayer extends Connection, CommandSender +public interface ProxiedPlayer extends Connection, CommandSender, tc.oc.minecraft.api.entity.Player { - /** - * Gets this player's display name. - * - * @return the players current display name - */ - String getDisplayName(); - - /** - * Sets this players display name to be used as their nametag and tab list - * name. - * - * @param name the name to set - */ - void setDisplayName(String name); - /** * Send a message to the specified screen position of this player. * @@ -128,13 +113,6 @@ public interface ProxiedPlayer extends Connection, CommandSender @Deprecated String getUUID(); - /** - * Get this connection's UUID, if set. - * - * @return the UUID - */ - UUID getUniqueId(); - /** * Gets this player's locale. * diff --git a/api/src/main/java/net/md_5/bungee/api/plugin/Listener.java b/api/src/main/java/net/md_5/bungee/api/plugin/Listener.java index 31ed4eea7f..a4797ad72f 100644 --- a/api/src/main/java/net/md_5/bungee/api/plugin/Listener.java +++ b/api/src/main/java/net/md_5/bungee/api/plugin/Listener.java @@ -3,6 +3,6 @@ /** * Dummy interface which all event subscribers and listeners must implement. */ -public interface Listener +public interface Listener extends tc.oc.minecraft.api.event.Listener { } diff --git a/api/src/main/java/net/md_5/bungee/api/plugin/Plugin.java b/api/src/main/java/net/md_5/bungee/api/plugin/Plugin.java index 834d9a6455..cb741da001 100644 --- a/api/src/main/java/net/md_5/bungee/api/plugin/Plugin.java +++ b/api/src/main/java/net/md_5/bungee/api/plugin/Plugin.java @@ -15,7 +15,7 @@ * Represents any Plugin that may be loaded at runtime to enhance existing * functionality. */ -public class Plugin +public class Plugin implements tc.oc.minecraft.api.plugin.Plugin { @Getter @@ -50,6 +50,12 @@ public void onDisable() { } + @Override + public ProxyServer getServer() + { + return getProxy(); + } + /** * Gets the data folder where this plugin may store arbitrary data. It will * be a child of {@link ProxyServer#getPluginsFolder()}. @@ -61,6 +67,12 @@ public final File getDataFolder() return new File( getProxy().getPluginsFolder(), getDescription().getName() ); } + @Override + public InputStream getResource(String name) + { + return getResourceAsStream( name ); + } + /** * Get a resource from within this plugins jar or container. Care must be * taken to close the returned stream. diff --git a/api/src/main/java/net/md_5/bungee/api/plugin/PluginDescription.java b/api/src/main/java/net/md_5/bungee/api/plugin/PluginDescription.java index ef12ae9037..2568203b4e 100644 --- a/api/src/main/java/net/md_5/bungee/api/plugin/PluginDescription.java +++ b/api/src/main/java/net/md_5/bungee/api/plugin/PluginDescription.java @@ -1,8 +1,12 @@ package net.md_5.bungee.api.plugin; import java.io.File; +import java.util.Collections; import java.util.HashSet; +import java.util.List; import java.util.Set; + +import com.google.common.collect.ImmutableList; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -13,7 +17,7 @@ @Data @NoArgsConstructor @AllArgsConstructor -public class PluginDescription +public class PluginDescription implements tc.oc.minecraft.api.plugin.PluginDescription { /** @@ -48,4 +52,22 @@ public class PluginDescription * Optional description. */ private String description = null; + + @Override + public List getAuthors() + { + return Collections.singletonList( author ); + } + + @Override + public List getDepend() + { + return ImmutableList.copyOf( getDepends() ); + } + + @Override + public List getSoftDepend() + { + return ImmutableList.copyOf( getSoftDepends() ); + } } diff --git a/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java b/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java index 6e8d4ab244..83d3ca4672 100644 --- a/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java +++ b/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java @@ -37,7 +37,7 @@ * example event handling and plugin management. */ @RequiredArgsConstructor -public class PluginManager +public class PluginManager implements tc.oc.minecraft.api.plugin.PluginManager { private static final Pattern argsSplit = Pattern.compile( " " ); @@ -185,6 +185,12 @@ public Collection getPlugins() return plugins.values(); } + @Override + public Collection getAllPlugins() + { + return getPlugins(); + } + /** * Returns a loaded plugin identified by the specified name. * @@ -378,6 +384,24 @@ public T callEvent(T event) return event; } + @Override + public void registerListener(tc.oc.minecraft.api.plugin.Plugin plugin, tc.oc.minecraft.api.event.Listener listener) + { + registerListener( (Plugin) plugin, (Listener) listener ); + } + + @Override + public void unregisterListener(tc.oc.minecraft.api.event.Listener listener) + { + unregisterListener( (Listener) listener ); + } + + @Override + public void unregisterListeners(tc.oc.minecraft.api.plugin.Plugin plugin) + { + unregisterListeners( (Plugin) plugin ); + } + /** * Register a {@link Listener} for receiving called events. Methods in this * Object which wish to receive events must be annotated with the diff --git a/config/pom.xml b/config/pom.xml index 99baac2dcb..cad0a76bfe 100644 --- a/config/pom.xml +++ b/config/pom.xml @@ -18,6 +18,12 @@ Generic java configuration API intended for use with BungeeCord + + tc.oc + minecraft-api + 1.8-SNAPSHOT + compile + org.yaml snakeyaml diff --git a/config/src/main/java/net/md_5/bungee/config/Configuration.java b/config/src/main/java/net/md_5/bungee/config/Configuration.java index d333c8144a..58347d4795 100644 --- a/config/src/main/java/net/md_5/bungee/config/Configuration.java +++ b/config/src/main/java/net/md_5/bungee/config/Configuration.java @@ -8,14 +8,16 @@ import java.util.List; import java.util.Map; import lombok.AccessLevel; +import lombok.Getter; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor(access = AccessLevel.PACKAGE) -public final class Configuration +public final class Configuration implements tc.oc.minecraft.api.configuration.Configuration { private static final char SEPARATOR = '.'; final Map self; + @Getter private final Configuration defaults; public Configuration() diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java index 1fd69b6df7..3bc19ddb34 100644 --- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java +++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java @@ -10,6 +10,7 @@ import net.md_5.bungee.api.Favicon; import net.md_5.bungee.api.ServerPing; import net.md_5.bungee.api.Title; +import net.md_5.bungee.command.ConsoleCommandSender; import net.md_5.bungee.module.ModuleManager; import com.google.common.io.ByteStreams; import net.md_5.bungee.api.chat.BaseComponent; @@ -81,6 +82,7 @@ import net.md_5.bungee.query.RemoteQuery; import net.md_5.bungee.util.CaseInsensitiveMap; import org.fusesource.jansi.AnsiConsole; +import tc.oc.minecraft.api.command.*; /** * Main BungeeCord proxy class. @@ -595,6 +597,12 @@ public ServerInfo constructServerInfo(String name, InetSocketAddress address, St return new BungeeServerInfo( name, address, motd, restricted ); } + @Override + public tc.oc.minecraft.api.command.ConsoleCommandSender getConsoleSender() + { + return ConsoleCommandSender.getInstance(); + } + @Override public CommandSender getConsole() { diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeServerInfo.java b/proxy/src/main/java/net/md_5/bungee/BungeeServerInfo.java index 1dd0aeba8a..f8699d26ad 100644 --- a/proxy/src/main/java/net/md_5/bungee/BungeeServerInfo.java +++ b/proxy/src/main/java/net/md_5/bungee/BungeeServerInfo.java @@ -13,6 +13,8 @@ import java.util.HashSet; import java.util.LinkedList; import java.util.Queue; +import java.util.UUID; + import lombok.Getter; import lombok.RequiredArgsConstructor; import lombok.Synchronized; @@ -69,6 +71,32 @@ public Collection getPlayers() return Collections.unmodifiableCollection( new HashSet( players ) ); } + @Override + public Collection getOnlinePlayers() + { + return getPlayers(); + } + + @Override + public ProxiedPlayer getPlayerExact(String name) + { + for(ProxiedPlayer player : getPlayers()) + { + if(name.equalsIgnoreCase(player.getName())) return player; + } + return null; + } + + @Override + public ProxiedPlayer getPlayer(UUID id) + { + for(ProxiedPlayer player : getPlayers()) + { + if(id.equals(player.getUniqueId())) return player; + } + return null; + } + @Override public boolean canAccess(CommandSender player) { diff --git a/proxy/src/main/java/net/md_5/bungee/UserConnection.java b/proxy/src/main/java/net/md_5/bungee/UserConnection.java index 5f0484c4d0..01a54572b7 100644 --- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java +++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java @@ -520,6 +520,12 @@ public Locale getLocale() return ( locale == null && settings != null ) ? locale = Locale.forLanguageTag( settings.getLocale().replaceAll( "_", "-" ) ) : locale; } + @Override + public Locale getCurrentLocale() + { + return getLocale(); + } + @Override public boolean isForgeUser() { diff --git a/proxy/src/main/java/net/md_5/bungee/command/ConsoleCommandSender.java b/proxy/src/main/java/net/md_5/bungee/command/ConsoleCommandSender.java index 49dde16ffe..326e89abf9 100644 --- a/proxy/src/main/java/net/md_5/bungee/command/ConsoleCommandSender.java +++ b/proxy/src/main/java/net/md_5/bungee/command/ConsoleCommandSender.java @@ -10,7 +10,7 @@ /** * Command sender representing the proxy console. */ -public class ConsoleCommandSender implements CommandSender +public class ConsoleCommandSender implements CommandSender, tc.oc.minecraft.api.command.ConsoleCommandSender { @Getter