diff --git a/api/pom.xml b/api/pom.xml index bcad7b4f..dce9e57c 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-parent - 1.0-SNAPSHOT + 1.4.7-SNAPSHOT ../pom.xml net.md-5 bungeecord-api - 1.0-SNAPSHOT + 1.4.7-SNAPSHOT jar BungeeCord-API 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 new file mode 100644 index 00000000..7ba6288a --- /dev/null +++ b/api/src/main/java/net/md_5/bungee/api/CommandSender.java @@ -0,0 +1,21 @@ +package net.md_5.bungee.api; + +import java.util.Collection; + +public interface CommandSender +{ + + public String getName(); + + public void sendMessage(String message); + + public Collection getGroups(); + + public void addGroups(String... groups); + + public void removeGroups(String... groups); + + public boolean hasPermission(String permission); + + public boolean setPermission(String permission, boolean value); +} diff --git a/api/src/main/java/net/md_5/bungee/api/ConnectedPlayer.java b/api/src/main/java/net/md_5/bungee/api/ConnectedPlayer.java new file mode 100644 index 00000000..6c82fa08 --- /dev/null +++ b/api/src/main/java/net/md_5/bungee/api/ConnectedPlayer.java @@ -0,0 +1,8 @@ +package net.md_5.bungee.api; + +/** + * Represents a player physically connected to the world hosted on this server. + */ +public interface ConnectedPlayer extends ProxiedPlayer +{ +} diff --git a/api/src/main/java/net/md_5/bungee/api/ProxyConnection.java b/api/src/main/java/net/md_5/bungee/api/Connection.java similarity index 81% rename from api/src/main/java/net/md_5/bungee/api/ProxyConnection.java rename to api/src/main/java/net/md_5/bungee/api/Connection.java index 7ec64427..bd1cbfec 100644 --- a/api/src/main/java/net/md_5/bungee/api/ProxyConnection.java +++ b/api/src/main/java/net/md_5/bungee/api/Connection.java @@ -7,7 +7,7 @@ import java.net.InetSocketAddress; * It should expose information about the remote peer, however not be specific * to a type of connection, whether server or player. */ -public abstract class ProxyConnection +public interface Connection { /** @@ -15,5 +15,5 @@ public abstract class ProxyConnection * * @return the remote address */ - public abstract InetSocketAddress getAddress(); + public InetSocketAddress getAddress(); } diff --git a/api/src/main/java/net/md_5/bungee/api/ProxiedPlayer.java b/api/src/main/java/net/md_5/bungee/api/ProxiedPlayer.java new file mode 100644 index 00000000..c858cb49 --- /dev/null +++ b/api/src/main/java/net/md_5/bungee/api/ProxiedPlayer.java @@ -0,0 +1,9 @@ +package net.md_5.bungee.api; + +/** + * 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 +{ +} 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 f5a71978..a3ddf173 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 @@ -5,21 +5,12 @@ import com.google.common.base.Preconditions; import java.util.Collection; import java.util.logging.Logger; import lombok.Getter; -import org.yaml.snakeyaml.Yaml; public abstract class ProxyServer { @Getter private static ProxyServer instance; - private ThreadLocal yaml = new ThreadLocal() - { - @Override - protected Yaml initialValue() - { - return new Yaml(); - } - }; /** * Sets the proxy instance. This method may only be called once per an @@ -34,16 +25,6 @@ public abstract class ProxyServer ProxyServer.instance = instance; } - /** - * Gets a reusable, thread safe {@link Yaml} instance. - * - * @return an {@link Yaml} instance - */ - public Yaml getYaml() - { - return yaml.get(); - } - /** * Gets the name of the currently running proxy software. * @@ -71,7 +52,7 @@ public abstract class ProxyServer * * @return all networked users */ - public abstract Collection getConnections(); + public abstract Collection getConnections(); /** * Get the {@link PluginManager} associated with loading plugins and diff --git a/api/src/main/java/net/md_5/bungee/api/RemoteServer.java b/api/src/main/java/net/md_5/bungee/api/Server.java similarity index 93% rename from api/src/main/java/net/md_5/bungee/api/RemoteServer.java rename to api/src/main/java/net/md_5/bungee/api/Server.java index fe38d003..83f2fee2 100644 --- a/api/src/main/java/net/md_5/bungee/api/RemoteServer.java +++ b/api/src/main/java/net/md_5/bungee/api/Server.java @@ -7,7 +7,7 @@ import lombok.RequiredArgsConstructor; * Represents a destination which this proxy might connect to. */ @RequiredArgsConstructor -public abstract class RemoteServer extends ProxyConnection +public abstract class Server implements Connection { @Getter diff --git a/api/src/main/java/net/md_5/bungee/api/event/ChatEvent.java b/api/src/main/java/net/md_5/bungee/api/event/ChatEvent.java new file mode 100644 index 00000000..022e9c49 --- /dev/null +++ b/api/src/main/java/net/md_5/bungee/api/event/ChatEvent.java @@ -0,0 +1,28 @@ +package net.md_5.bungee.api.event; + +import lombok.Data; +import net.md_5.bungee.api.Connection; +import net.md_5.bungee.api.ProxiedPlayer; +import net.md_5.bungee.api.plugin.Cancellable; + +@Data +public class ChatEvent implements Cancellable +{ + + /** + * Cancelled state. + */ + private boolean cancelled; + /** + * Where this message is being sent to. + */ + private final Connection destination; + /** + * User involved with sending or receiving this message. + */ + private final ProxiedPlayer player; + /** + * Text contained in this chat. + */ + private String message; +} diff --git a/api/src/main/java/net/md_5/bungee/api/event/LoginEvent.java b/api/src/main/java/net/md_5/bungee/api/event/LoginEvent.java new file mode 100644 index 00000000..473518ff --- /dev/null +++ b/api/src/main/java/net/md_5/bungee/api/event/LoginEvent.java @@ -0,0 +1,34 @@ +package net.md_5.bungee.api.event; + +import java.net.InetAddress; +import lombok.Data; +import net.md_5.bungee.api.plugin.Cancellable; + +/** + * Event called to represent a player logging in. + */ +@Data +public class LoginEvent implements Cancellable +{ + + /** + * Cancelled state. + */ + private boolean cancelled; + /** + * Message to use when kicking if this event is canceled. + */ + private String cancelReason; + /** + * Username which the player wishes to use. + */ + private final String username; + /** + * IP address of the remote connection. + */ + private final InetAddress address; + /** + * Hostname which the user tried to connect to. + */ + private final String hostname; +} diff --git a/api/src/main/java/net/md_5/bungee/api/event/PluginMessageEvent.java b/api/src/main/java/net/md_5/bungee/api/event/PluginMessageEvent.java new file mode 100644 index 00000000..27fa0744 --- /dev/null +++ b/api/src/main/java/net/md_5/bungee/api/event/PluginMessageEvent.java @@ -0,0 +1,35 @@ +package net.md_5.bungee.api.event; + +import lombok.Data; +import net.md_5.bungee.api.Connection; +import net.md_5.bungee.api.ProxiedPlayer; +import net.md_5.bungee.api.plugin.Cancellable; + +/** + * Event called when a plugin message is sent to the client or server. + */ +@Data +public class PluginMessageEvent implements Cancellable +{ + + /** + * Cancelled state. + */ + private boolean cancelled; + /** + * Dispatcher of this message. + */ + private final Connection sender; + /** + * Player involved with sending or receiving this message. + */ + private final ProxiedPlayer player; + /** + * Tag specified for this plugin message. + */ + private String tag; + /** + * Data contained in this plugin message. + */ + private byte[] data; +} 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 72f58ff3..8974c0a2 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 @@ -14,6 +14,7 @@ import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.logging.Level; import net.md_5.bungee.api.ProxyServer; +import org.yaml.snakeyaml.Yaml; /** * Class to manage bridging between plugin duties and implementation duties, for @@ -22,6 +23,7 @@ import net.md_5.bungee.api.ProxyServer; public class PluginManager { + private final Yaml yaml = new Yaml(); private final EventBus eventBus = new EventBus(); private final Map plugins = new HashMap<>(); @@ -63,7 +65,7 @@ public class PluginManager JarEntry pdf = jar.getJarEntry("plugin.yml"); try (InputStream in = jar.getInputStream(pdf)) { - PluginDescription desc = ProxyServer.getInstance().getYaml().loadAs(in, PluginDescription.class); + PluginDescription desc = yaml.loadAs(in, PluginDescription.class); URLClassLoader loader = new URLClassLoader(new URL[] { file.toURI().toURL() diff --git a/pom.xml b/pom.xml index 194e9cba..360d920c 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ net.md-5 bungeecord-parent - 1.0-SNAPSHOT + 1.4.7-SNAPSHOT pom BungeeCord diff --git a/proxy/pom.xml b/proxy/pom.xml index 02a137ce..3a3d0f5a 100644 --- a/proxy/pom.xml +++ b/proxy/pom.xml @@ -6,24 +6,19 @@ net.md-5 bungeecord-parent - 1.0-SNAPSHOT + 1.4.7-SNAPSHOT ../pom.xml net.md-5 bungeecord-proxy - 1.0-SNAPSHOT + 1.4.7-SNAPSHOT jar BungeeCord-Proxy Proxy component of the Elastic Portal Suite - - com.google.code.findbugs - jsr305 - 2.0.1 - net.md-5 mendax @@ -36,7 +31,7 @@ org.bouncycastle - bcprov-ext-jdk15on + bcprov-jdk15on 1.47 @@ -81,41 +76,9 @@ + true - - com.github.wvengen - proguard-maven-plugin - 2.0.6 - - - package - - proguard - - - - - true - false - - ${java.home}/lib/rt.jar - ${java.home}/lib/jce.jar - - false - - - - - - - - net.sf.proguard - proguard-base - 4.8 - - -