mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-11-24 03:05:49 +01:00
More changes. API is going well, but struggling to break it up into sensible classes whilst allowing for the fact that in the future we will have:
- Player to Proxy - Proxy to Proxy - Player to Internal Server Connections.
This commit is contained in:
parent
5402bd2cb1
commit
434b950a92
@ -6,13 +6,13 @@
|
||||
<parent>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-parent</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<version>1.4.7-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-api</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<version>1.4.7-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>BungeeCord-API</name>
|
||||
|
21
api/src/main/java/net/md_5/bungee/api/CommandSender.java
Normal file
21
api/src/main/java/net/md_5/bungee/api/CommandSender.java
Normal file
@ -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<String> getGroups();
|
||||
|
||||
public void addGroups(String... groups);
|
||||
|
||||
public void removeGroups(String... groups);
|
||||
|
||||
public boolean hasPermission(String permission);
|
||||
|
||||
public boolean setPermission(String permission, boolean value);
|
||||
}
|
@ -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
|
||||
{
|
||||
}
|
@ -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();
|
||||
}
|
9
api/src/main/java/net/md_5/bungee/api/ProxiedPlayer.java
Normal file
9
api/src/main/java/net/md_5/bungee/api/ProxiedPlayer.java
Normal file
@ -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
|
||||
{
|
||||
}
|
@ -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> yaml = new ThreadLocal<Yaml>()
|
||||
{
|
||||
@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<ProxyConnection> getConnections();
|
||||
public abstract Collection<Connection> getConnections();
|
||||
|
||||
/**
|
||||
* Get the {@link PluginManager} associated with loading plugins and
|
||||
|
@ -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
|
28
api/src/main/java/net/md_5/bungee/api/event/ChatEvent.java
Normal file
28
api/src/main/java/net/md_5/bungee/api/event/ChatEvent.java
Normal file
@ -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;
|
||||
}
|
34
api/src/main/java/net/md_5/bungee/api/event/LoginEvent.java
Normal file
34
api/src/main/java/net/md_5/bungee/api/event/LoginEvent.java
Normal file
@ -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;
|
||||
}
|
@ -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;
|
||||
}
|
@ -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<String, Plugin> 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()
|
||||
|
2
pom.xml
2
pom.xml
@ -10,7 +10,7 @@
|
||||
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-parent</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<version>1.4.7-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>BungeeCord</name>
|
||||
|
@ -6,24 +6,19 @@
|
||||
<parent>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-parent</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<version>1.4.7-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-proxy</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<version>1.4.7-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>BungeeCord-Proxy</name>
|
||||
<description>Proxy component of the Elastic Portal Suite</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
<artifactId>jsr305</artifactId>
|
||||
<version>2.0.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>mendax</artifactId>
|
||||
@ -36,7 +31,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-ext-jdk15on</artifactId>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
<version>1.47</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
@ -81,41 +76,9 @@
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.github.wvengen</groupId>
|
||||
<artifactId>proguard-maven-plugin</artifactId>
|
||||
<version>2.0.6</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>proguard</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<addMavenDescriptor>true</addMavenDescriptor>
|
||||
<includeDependency>false</includeDependency>
|
||||
<libs>
|
||||
<lib>${java.home}/lib/rt.jar</lib>
|
||||
<lib>${java.home}/lib/jce.jar</lib>
|
||||
</libs>
|
||||
<obfuscate>false</obfuscate>
|
||||
<options>
|
||||
<option>-dontoptimize</option>
|
||||
<option>-keep class net.md_5.bungee.** { *; }</option>
|
||||
</options>
|
||||
</configuration>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>net.sf.proguard</groupId>
|
||||
<artifactId>proguard-base</artifactId>
|
||||
<version>4.8</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
Loading…
Reference in New Issue
Block a user