mirror of
https://github.com/ME1312/SubServers-2.git
synced 2025-01-10 09:57:45 +01:00
Add action methods to RemotePlayer
This commit is contained in:
parent
910b504af8
commit
2a9c74f601
@ -29,7 +29,7 @@
|
||||
<groupId>net.ME1312.Galaxi</groupId>
|
||||
<artifactId>GalaxiUtil</artifactId>
|
||||
<version>21w24a</version>
|
||||
<scope>provided</scope>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@ -54,6 +54,59 @@
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>process-resources</phase>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<tasks>
|
||||
<mkdir dir="${project.build.directory}" />
|
||||
<copy file="${basedir}/../../LICENSE" todir="${project.build.directory}/classes" />
|
||||
</tasks>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<configuration>
|
||||
<finalName>SubServers.Bungee.Common</finalName>
|
||||
<outputDirectory>../../Artifacts/Maven</outputDirectory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>javadoc</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<windowtitle>SubServers.Bungee.Common Javadoc</windowtitle>
|
||||
<doctitle>SubServers.Bungee.Common ${project.version}</doctitle>
|
||||
<show>protected</show>
|
||||
<destDir>./</destDir>
|
||||
<outputDirectory>${basedir}/../../Javadoc/SubServers.Bungee.Common</outputDirectory>
|
||||
<reportOutputDirectory>${basedir}/../../Javadoc/SubServers.Bungee.Common</reportOutputDirectory>
|
||||
<additionalOptions>-Xdoclint:none</additionalOptions>
|
||||
<links>
|
||||
<link>https://dev.me1312.net/jenkins/job/GalaxiEngine/javadoc/GalaxiUtil/</link>
|
||||
<link>https://ci.md-5.net/job/BungeeCord/ws/api/target/apidocs/</link>
|
||||
</links>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -1,8 +1,15 @@
|
||||
package net.ME1312.SubServers.Bungee.Library.Compatibility;
|
||||
|
||||
import net.ME1312.Galaxi.Library.Callback.Callback;
|
||||
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
@ -10,6 +17,13 @@ import java.util.UUID;
|
||||
*/
|
||||
public interface RemotePlayer {
|
||||
|
||||
/**
|
||||
* Get Local Player
|
||||
*
|
||||
* @return Local Player (or null when not local)
|
||||
*/
|
||||
ProxiedPlayer get();
|
||||
|
||||
/**
|
||||
* Get the UUID of this player.
|
||||
*
|
||||
@ -51,4 +65,105 @@ public interface RemotePlayer {
|
||||
* @return the server this player is connected to
|
||||
*/
|
||||
ServerInfo getServer();
|
||||
|
||||
/**
|
||||
* Sends messages to this player
|
||||
*
|
||||
* @param messages Messages to send
|
||||
*/
|
||||
default void sendMessage(String... messages) {
|
||||
sendMessage(messages, i -> {});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends messages to this player
|
||||
*
|
||||
* @param messages Messages to send
|
||||
* @param response Success Status
|
||||
*/
|
||||
void sendMessage(String[] messages, Callback<Integer> response);
|
||||
|
||||
/**
|
||||
* Sends messages to this player
|
||||
*
|
||||
* @param messages Messages to send
|
||||
*/
|
||||
default void sendMessage(BaseComponent... messages) {
|
||||
sendMessage(messages, i -> {});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends messages to this player
|
||||
*
|
||||
* @param messages Messages to send
|
||||
* @param response Success Status
|
||||
*/
|
||||
void sendMessage(BaseComponent[] messages, Callback<Integer> response);
|
||||
|
||||
/**
|
||||
* Transfers this player to another server
|
||||
*
|
||||
* @param server Target server
|
||||
*/
|
||||
default void transfer(String server) {
|
||||
transfer(server, i -> {});
|
||||
}
|
||||
|
||||
/**
|
||||
* Transfers this player to another server
|
||||
*
|
||||
* @param server Target server
|
||||
* @param response Success status
|
||||
*/
|
||||
void transfer(String server, Callback<Integer> response);
|
||||
|
||||
/**
|
||||
* Transfers this player to another server
|
||||
*
|
||||
* @param server Target server
|
||||
*/
|
||||
default void transfer(ServerInfo server) {
|
||||
transfer(server, i -> {});
|
||||
}
|
||||
|
||||
/**
|
||||
* Transfers this player to another server
|
||||
*
|
||||
* @param server Target server
|
||||
* @param response Success status
|
||||
*/
|
||||
void transfer(ServerInfo server, Callback<Integer> response);
|
||||
|
||||
/**
|
||||
* Disconnects this player from the network
|
||||
*/
|
||||
default void disconnect() {
|
||||
disconnect(i -> {});
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnects this player from the network
|
||||
*
|
||||
* @param response Success status
|
||||
*/
|
||||
default void disconnect(Callback<Integer> response) {
|
||||
disconnect(null, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnects this player from the network
|
||||
*
|
||||
* @param message Disconnect Message
|
||||
*/
|
||||
default void disconnect(String message) {
|
||||
disconnect(message, i -> {});
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnects this player from the network
|
||||
*
|
||||
* @param message Disconnect Message
|
||||
* @param response Success status
|
||||
*/
|
||||
void disconnect(String message, Callback<Integer> response);
|
||||
}
|
||||
|
@ -25,33 +25,23 @@
|
||||
<version>1.15-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ME1312.Galaxi</groupId>
|
||||
<artifactId>GalaxiUtil</artifactId>
|
||||
<version>21w24a</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ME1312.SubServers</groupId>
|
||||
<artifactId>SubServers.Bungee.Common</artifactId>
|
||||
<version>-PLACEHOLDER</version>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ME1312.SubData</groupId>
|
||||
<artifactId>Server</artifactId>
|
||||
<version>21w08a</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.dosse.upnp</groupId>
|
||||
<artifactId>WaifUPnP</artifactId>
|
||||
<version>1.1</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@ -117,6 +107,15 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<configuration>
|
||||
<finalName>SubServers.Bungee</finalName>
|
||||
<outputDirectory>../Artifacts/Maven</outputDirectory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
@ -154,7 +153,7 @@
|
||||
</goals>
|
||||
<configuration>
|
||||
<windowtitle>SubServers.Bungee Javadoc</windowtitle>
|
||||
<doctitle>SubServers.Bungee Javadoc</doctitle>
|
||||
<doctitle>SubServers.Bungee ${project.version}</doctitle>
|
||||
<show>protected</show>
|
||||
<destDir>./</destDir>
|
||||
<outputDirectory>${basedir}/../Javadoc/SubServers.Bungee</outputDirectory>
|
||||
|
@ -1,12 +1,21 @@
|
||||
package net.ME1312.SubServers.Bungee.Host;
|
||||
|
||||
import net.ME1312.Galaxi.Library.Callback.Callback;
|
||||
import net.ME1312.Galaxi.Library.Map.ObjectMap;
|
||||
import net.ME1312.Galaxi.Library.Util;
|
||||
import net.ME1312.SubData.Server.SubDataClient;
|
||||
import net.ME1312.SubData.Server.SubDataSerializable;
|
||||
import net.ME1312.SubServers.Bungee.Network.Packet.PacketExDisconnectPlayer;
|
||||
import net.ME1312.SubServers.Bungee.Network.Packet.PacketExMessagePlayer;
|
||||
import net.ME1312.SubServers.Bungee.Network.Packet.PacketExTransferPlayer;
|
||||
import net.ME1312.SubServers.Bungee.SubAPI;
|
||||
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.chat.ComponentSerializer;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -27,9 +36,21 @@ public class RemotePlayer implements net.ME1312.SubServers.Bungee.Library.Compat
|
||||
* @param player Local Player
|
||||
*/
|
||||
public RemotePlayer(ProxiedPlayer player) {
|
||||
this(player, player.getServer().getInfo());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Translate a Local Player to a Remote Player
|
||||
*
|
||||
* @param player Local Player
|
||||
* @param server Server the player is on
|
||||
*/
|
||||
public RemotePlayer(ProxiedPlayer player, ServerInfo server) {
|
||||
if (Util.isNull(player)) throw new NullPointerException();
|
||||
this.local = player;
|
||||
this.id = player.getUniqueId();
|
||||
this.server = (server instanceof Server)? (Server) server : null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -41,20 +62,16 @@ public class RemotePlayer implements net.ME1312.SubServers.Bungee.Library.Compat
|
||||
* @param server Server the player is on
|
||||
* @param ip Player IP Address
|
||||
*/
|
||||
public RemotePlayer(String name, UUID id, Proxy proxy, Server server, InetSocketAddress ip) {
|
||||
public RemotePlayer(String name, UUID id, Proxy proxy, ServerInfo server, InetSocketAddress ip) {
|
||||
if (Util.isNull(name, id, proxy, ip)) throw new NullPointerException();
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.ip = ip;
|
||||
this.proxy = proxy;
|
||||
this.server = server;
|
||||
this.server = (server instanceof Server)? (Server) server : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Local Player
|
||||
*
|
||||
* @return Local Player (or null when not local)
|
||||
*/
|
||||
@Override
|
||||
public ProxiedPlayer get() {
|
||||
return local;
|
||||
}
|
||||
@ -98,11 +115,14 @@ public class RemotePlayer implements net.ME1312.SubServers.Bungee.Library.Compat
|
||||
return (proxy == null)? null : proxy.getName();
|
||||
}
|
||||
|
||||
private SubDataClient getProxyConnection() {
|
||||
Proxy proxy = getProxy();
|
||||
return (proxy == null)? null : (SubDataClient) proxy.getSubData()[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Server getServer() {
|
||||
if (local != null) {
|
||||
return (Server) local.getServer().getInfo();
|
||||
} else return server;
|
||||
return server;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -111,6 +131,121 @@ public class RemotePlayer implements net.ME1312.SubServers.Bungee.Library.Compat
|
||||
return (server == null)? null : server.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String[] messages, Callback<Integer> response) {
|
||||
if (local != null) {
|
||||
local.sendMessages(messages);
|
||||
response.run(0);
|
||||
} else {
|
||||
SubDataClient client = getProxyConnection();
|
||||
if (client != null) {
|
||||
StackTraceElement[] origin = new Exception().getStackTrace();
|
||||
client.sendPacket(new PacketExMessagePlayer(getUniqueId(), messages, null, data -> {
|
||||
try {
|
||||
response.run(data.getInt(0x0001));
|
||||
} catch (Throwable e) {
|
||||
Throwable ew = new InvocationTargetException(e);
|
||||
ew.setStackTrace(origin);
|
||||
ew.printStackTrace();
|
||||
}
|
||||
}));
|
||||
} else response.run(4);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(BaseComponent[] messages, Callback<Integer> response) {
|
||||
if (local != null) {
|
||||
local.sendMessage(messages);
|
||||
response.run(0);
|
||||
} else {
|
||||
SubDataClient client = getProxyConnection();
|
||||
if (client != null) {
|
||||
StackTraceElement[] origin = new Exception().getStackTrace();
|
||||
client.sendPacket(new PacketExMessagePlayer(getUniqueId(), null, new String[]{ ComponentSerializer.toString(messages) }, data -> {
|
||||
try {
|
||||
response.run(data.getInt(0x0001));
|
||||
} catch (Throwable e) {
|
||||
Throwable ew = new InvocationTargetException(e);
|
||||
ew.setStackTrace(origin);
|
||||
ew.printStackTrace();
|
||||
}
|
||||
}));
|
||||
} else response.run(4);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transfer(String server, Callback<Integer> response) {
|
||||
if (local != null) {
|
||||
Server info = SubAPI.getInstance().getServer(server);
|
||||
if (info != null) {
|
||||
local.connect(info);
|
||||
response.run(0);
|
||||
} else response.run(1);
|
||||
} else {
|
||||
SubDataClient client = getProxyConnection();
|
||||
if (client != null) {
|
||||
StackTraceElement[] origin = new Exception().getStackTrace();
|
||||
client.sendPacket(new PacketExTransferPlayer(getUniqueId(), server, data -> {
|
||||
try {
|
||||
response.run(data.getInt(0x0001));
|
||||
} catch (Throwable e) {
|
||||
Throwable ew = new InvocationTargetException(e);
|
||||
ew.setStackTrace(origin);
|
||||
ew.printStackTrace();
|
||||
}
|
||||
}));
|
||||
} else response.run(4);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transfer(ServerInfo server, Callback<Integer> response) {
|
||||
if (local != null) {
|
||||
local.connect(server);
|
||||
response.run(0);
|
||||
} else {
|
||||
SubDataClient client = getProxyConnection();
|
||||
if (client != null) {
|
||||
StackTraceElement[] origin = new Exception().getStackTrace();
|
||||
client.sendPacket(new PacketExTransferPlayer(getUniqueId(), server.getName(), data -> {
|
||||
try {
|
||||
response.run(data.getInt(0x0001));
|
||||
} catch (Throwable e) {
|
||||
Throwable ew = new InvocationTargetException(e);
|
||||
ew.setStackTrace(origin);
|
||||
ew.printStackTrace();
|
||||
}
|
||||
}));
|
||||
} else response.run(4);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect(String message, Callback<Integer> response) {
|
||||
if (local != null) {
|
||||
if (message != null) {
|
||||
local.disconnect(message);
|
||||
} else local.disconnect();
|
||||
response.run(0);
|
||||
} else {
|
||||
SubDataClient client = getProxyConnection();
|
||||
if (client != null) {
|
||||
StackTraceElement[] origin = new Exception().getStackTrace();
|
||||
client.sendPacket(new PacketExDisconnectPlayer(getUniqueId(), message, data -> {
|
||||
try {
|
||||
response.run(data.getInt(0x0001));
|
||||
} catch (Throwable e) {
|
||||
Throwable ew = new InvocationTargetException(e);
|
||||
ew.setStackTrace(origin);
|
||||
ew.printStackTrace();
|
||||
}
|
||||
}));
|
||||
} else response.run(4);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof RemotePlayer && getUniqueId().equals(((RemotePlayer) obj).getUniqueId());
|
||||
|
@ -0,0 +1,65 @@
|
||||
package net.ME1312.SubServers.Bungee.Network.Packet;
|
||||
|
||||
import net.ME1312.Galaxi.Library.Callback.Callback;
|
||||
import net.ME1312.Galaxi.Library.Map.ObjectMap;
|
||||
import net.ME1312.Galaxi.Library.Util;
|
||||
import net.ME1312.SubData.Server.Protocol.PacketObjectIn;
|
||||
import net.ME1312.SubData.Server.Protocol.PacketObjectOut;
|
||||
import net.ME1312.SubData.Server.SubDataClient;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Message External Player Packet
|
||||
*/
|
||||
public class PacketExMessagePlayer implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
|
||||
private static HashMap<UUID, Callback<ObjectMap<Integer>>[]> callbacks = new HashMap<UUID, Callback<ObjectMap<Integer>>[]>();
|
||||
private UUID player;
|
||||
private String[] legacy, raw;
|
||||
private UUID id;
|
||||
|
||||
/**
|
||||
* New PacketExMessagePlayer (In)
|
||||
*/
|
||||
public PacketExMessagePlayer() {}
|
||||
|
||||
/**
|
||||
* New PacketExMessagePlayer (Out)
|
||||
*
|
||||
* @param player Player
|
||||
* @param legacy Messages (Legacy)
|
||||
* @param raw Messages (JSON)
|
||||
* @param callback Callbacks
|
||||
*/
|
||||
@SafeVarargs
|
||||
public PacketExMessagePlayer(UUID player, String[] legacy, String[] raw, Callback<ObjectMap<Integer>>... callback) {
|
||||
if (Util.isNull(player, callback)) throw new NullPointerException();
|
||||
this.player = player;
|
||||
this.legacy = legacy;
|
||||
this.raw = raw;
|
||||
this.id = Util.getNew(callbacks.keySet(), UUID::randomUUID);
|
||||
callbacks.put(id, callback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectMap<Integer> send(SubDataClient client) {
|
||||
ObjectMap<Integer> data = new ObjectMap<Integer>();
|
||||
data.set(0x0000, id);
|
||||
data.set(0x0001, player);
|
||||
if (legacy != null) data.set(0x0002, legacy);
|
||||
if (raw != null) data.set(0x0003, raw);
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive(SubDataClient client, ObjectMap<Integer> data) {
|
||||
for (Callback<ObjectMap<Integer>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(data);
|
||||
callbacks.remove(data.getUUID(0x0000));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int version() {
|
||||
return 0x0001;
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package net.ME1312.SubServers.Bungee.Network.Packet;
|
||||
|
||||
import net.ME1312.Galaxi.Library.Callback.Callback;
|
||||
import net.ME1312.Galaxi.Library.Map.ObjectMap;
|
||||
import net.ME1312.Galaxi.Library.Util;
|
||||
import net.ME1312.SubData.Server.Protocol.PacketObjectIn;
|
||||
import net.ME1312.SubData.Server.Protocol.PacketObjectOut;
|
||||
import net.ME1312.SubData.Server.SubDataClient;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Transfer External Player Packet
|
||||
*/
|
||||
public class PacketExTransferPlayer implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
|
||||
private static HashMap<UUID, Callback<ObjectMap<Integer>>[]> callbacks = new HashMap<UUID, Callback<ObjectMap<Integer>>[]>();
|
||||
private UUID player;
|
||||
private String server;
|
||||
private UUID id;
|
||||
|
||||
/**
|
||||
* New PacketExTransferPlayer (In)
|
||||
*/
|
||||
public PacketExTransferPlayer() {}
|
||||
|
||||
/**
|
||||
* New PacketExTransferPlayer (Out)
|
||||
*
|
||||
* @param player Player
|
||||
* @param server Server
|
||||
* @param callback Callbacks
|
||||
*/
|
||||
@SafeVarargs
|
||||
public PacketExTransferPlayer(UUID player, String server, Callback<ObjectMap<Integer>>... callback) {
|
||||
if (Util.isNull(player, callback)) throw new NullPointerException();
|
||||
this.player = player;
|
||||
this.server = server;
|
||||
this.id = Util.getNew(callbacks.keySet(), UUID::randomUUID);
|
||||
callbacks.put(id, callback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectMap<Integer> send(SubDataClient client) {
|
||||
ObjectMap<Integer> data = new ObjectMap<Integer>();
|
||||
data.set(0x0000, id);
|
||||
data.set(0x0001, player);
|
||||
if (server != null) data.set(0x0002, server);
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive(SubDataClient client, ObjectMap<Integer> data) {
|
||||
for (Callback<ObjectMap<Integer>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(data);
|
||||
callbacks.remove(data.getUUID(0x0000));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int version() {
|
||||
return 0x0001;
|
||||
}
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
package net.ME1312.SubServers.Bungee.Network.Packet;
|
||||
|
||||
import net.ME1312.Galaxi.Library.Map.ObjectMap;
|
||||
import net.ME1312.Galaxi.Library.Util;
|
||||
import net.ME1312.SubData.Server.Protocol.PacketObjectIn;
|
||||
import net.ME1312.SubData.Server.Protocol.PacketObjectOut;
|
||||
import net.ME1312.SubData.Server.SubDataClient;
|
||||
import net.ME1312.SubServers.Bungee.Host.RemotePlayer;
|
||||
import net.ME1312.SubServers.Bungee.SubProxy;
|
||||
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.chat.ComponentSerializer;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Message Player Packet
|
||||
*/
|
||||
public class PacketMessagePlayer implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
|
||||
private SubProxy plugin;
|
||||
private int response;
|
||||
private UUID tracker;
|
||||
|
||||
/**
|
||||
* New PacketMessagePlayer (In)
|
||||
*
|
||||
* @param plugin SubPlugin
|
||||
*/
|
||||
public PacketMessagePlayer(SubProxy plugin) {
|
||||
if (Util.isNull(plugin)) throw new NullPointerException();
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* New PacketMessagePlayer (Out)
|
||||
*
|
||||
* @param response Response ID
|
||||
* @param tracker Receiver ID
|
||||
*/
|
||||
public PacketMessagePlayer(int response, UUID tracker) {
|
||||
this.response = response;
|
||||
this.tracker = tracker;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectMap<Integer> send(SubDataClient client) {
|
||||
ObjectMap<Integer> json = new ObjectMap<Integer>();
|
||||
if (tracker != null) json.set(0x0000, tracker);
|
||||
json.set(0x0001, response);
|
||||
return json;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void receive(SubDataClient client, ObjectMap<Integer> data) {
|
||||
UUID tracker = (data.contains(0x0000)?data.getUUID(0x0000):null);
|
||||
try {
|
||||
UUID id = data.getUUID(0x0001);
|
||||
|
||||
ProxiedPlayer local;
|
||||
RemotePlayer remote;
|
||||
if ((local = plugin.getPlayer(id)) != null) {
|
||||
if (data.contains(0x0002))
|
||||
local.sendMessages(data.getRawStringList(0x0002).toArray(new String[0]));
|
||||
if (data.contains(0x0003)) {
|
||||
List<String> messages = data.getRawStringList(0x0003);
|
||||
LinkedList<BaseComponent> components = new LinkedList<BaseComponent>();
|
||||
for (String message : messages) components.addAll(Arrays.asList(ComponentSerializer.parse(message)));
|
||||
local.sendMessage(components.toArray(new BaseComponent[0]));
|
||||
}
|
||||
client.sendPacket(new PacketMessagePlayer(0, tracker));
|
||||
} else if ((remote = plugin.api.getRemotePlayer(id)) != null) {
|
||||
if (remote.getProxy().getSubData()[0] != null) {
|
||||
((SubDataClient) remote.getProxy().getSubData()[0]).sendPacket(new PacketExDisconnectPlayer(remote.getUniqueId(), (data.contains(0x0002)?data.getRawString(0x0002):null), r -> {
|
||||
client.sendPacket(new PacketMessagePlayer(r.getInt(0x0001), tracker));
|
||||
}));
|
||||
} else {
|
||||
client.sendPacket(new PacketMessagePlayer(4, tracker));
|
||||
}
|
||||
} else {
|
||||
client.sendPacket(new PacketMessagePlayer(3, tracker));
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
client.sendPacket(new PacketMessagePlayer(2, tracker));
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int version() {
|
||||
return 0x0001;
|
||||
}
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
package net.ME1312.SubServers.Bungee.Network.Packet;
|
||||
|
||||
import net.ME1312.Galaxi.Library.Map.ObjectMap;
|
||||
import net.ME1312.Galaxi.Library.Util;
|
||||
import net.ME1312.SubData.Server.Protocol.PacketObjectIn;
|
||||
import net.ME1312.SubData.Server.Protocol.PacketObjectOut;
|
||||
import net.ME1312.SubData.Server.SubDataClient;
|
||||
import net.ME1312.SubServers.Bungee.Host.RemotePlayer;
|
||||
import net.ME1312.SubServers.Bungee.Host.Server;
|
||||
import net.ME1312.SubServers.Bungee.SubProxy;
|
||||
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Transfer Player Packet
|
||||
*/
|
||||
public class PacketTransferPlayer implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
|
||||
private SubProxy plugin;
|
||||
private int response;
|
||||
private UUID tracker;
|
||||
|
||||
/**
|
||||
* New PacketTransferPlayer (In)
|
||||
*
|
||||
* @param plugin SubPlugin
|
||||
*/
|
||||
public PacketTransferPlayer(SubProxy plugin) {
|
||||
if (Util.isNull(plugin)) throw new NullPointerException();
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* New PacketTransferPlayer (Out)
|
||||
*
|
||||
* @param response Response ID
|
||||
* @param tracker Receiver ID
|
||||
*/
|
||||
public PacketTransferPlayer(int response, UUID tracker) {
|
||||
this.response = response;
|
||||
this.tracker = tracker;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectMap<Integer> send(SubDataClient client) {
|
||||
ObjectMap<Integer> json = new ObjectMap<Integer>();
|
||||
if (tracker != null) json.set(0x0000, tracker);
|
||||
json.set(0x0001, response);
|
||||
return json;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive(SubDataClient client, ObjectMap<Integer> data) {
|
||||
UUID tracker = (data.contains(0x0000)?data.getUUID(0x0000):null);
|
||||
try {
|
||||
UUID id = data.getUUID(0x0001);
|
||||
|
||||
ProxiedPlayer local;
|
||||
RemotePlayer remote;
|
||||
if ((local = plugin.getPlayer(id)) != null) {
|
||||
Server server;
|
||||
if (data.contains(0x0002) && (server = plugin.api.getServer(data.getRawString(0x0002))) != null) {
|
||||
local.connect(server);
|
||||
client.sendPacket(new PacketTransferPlayer(0, tracker));
|
||||
} else {
|
||||
client.sendPacket(new PacketTransferPlayer(1, tracker));
|
||||
}
|
||||
} else if ((remote = plugin.api.getRemotePlayer(id)) != null) {
|
||||
if (remote.getProxy().getSubData()[0] != null) {
|
||||
((SubDataClient) remote.getProxy().getSubData()[0]).sendPacket(new PacketExTransferPlayer(remote.getUniqueId(), (data.contains(0x0002)?data.getRawString(0x0002):null), r -> {
|
||||
client.sendPacket(new PacketTransferPlayer(r.getInt(0x0001), tracker));
|
||||
}));
|
||||
} else {
|
||||
client.sendPacket(new PacketTransferPlayer(4, tracker));
|
||||
}
|
||||
} else {
|
||||
client.sendPacket(new PacketTransferPlayer(3, tracker));
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
client.sendPacket(new PacketTransferPlayer(2, tracker));
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int version() {
|
||||
return 0x0001;
|
||||
}
|
||||
}
|
@ -2,8 +2,6 @@ package net.ME1312.SubServers.Bungee.Network;
|
||||
|
||||
import net.ME1312.Galaxi.Library.Callback.Callback;
|
||||
import net.ME1312.Galaxi.Library.Version.Version;
|
||||
import net.ME1312.SubData.Server.Library.DataSize;
|
||||
import net.ME1312.SubData.Server.SubDataClient;
|
||||
import net.ME1312.SubData.Server.SubDataProtocol;
|
||||
import net.ME1312.SubData.Server.SubDataServer;
|
||||
import net.ME1312.SubServers.Bungee.Event.SubNetworkConnectEvent;
|
||||
@ -76,8 +74,9 @@ public class SubProtocol extends SubDataProtocol {
|
||||
registerPacket(0x0038, PacketRemoveServer.class);
|
||||
registerPacket(0x0039, PacketDeleteServer.class);
|
||||
//registerPacket(0x003A, PacketRestoreServer.class); // TODO
|
||||
//registerPacket(0x003B, PacketTeleportPlayer.class);
|
||||
registerPacket(0x003B, PacketTransferPlayer.class);
|
||||
registerPacket(0x003C, PacketDisconnectPlayer.class);
|
||||
registerPacket(0x003D, PacketMessagePlayer.class);
|
||||
|
||||
registerPacket(0x0030, new PacketCreateServer(plugin));
|
||||
registerPacket(0x0031, new PacketAddServer(plugin));
|
||||
@ -90,8 +89,9 @@ public class SubProtocol extends SubDataProtocol {
|
||||
registerPacket(0x0038, new PacketRemoveServer(plugin));
|
||||
registerPacket(0x0039, new PacketDeleteServer(plugin));
|
||||
//registerPacket(0x003A, new PacketRestoreServer(plugin)); // TODO
|
||||
//registerPacket(0x003B, new PacketTeleportPlayer(plugin));
|
||||
registerPacket(0x003B, new PacketTransferPlayer(plugin));
|
||||
registerPacket(0x003C, new PacketDisconnectPlayer(plugin));
|
||||
registerPacket(0x003D, new PacketMessagePlayer(plugin));
|
||||
|
||||
|
||||
// 50-6F: External Host Packets
|
||||
@ -120,20 +120,24 @@ public class SubProtocol extends SubDataProtocol {
|
||||
//registerPacket(0x005A, new PacketExRestoreServer());
|
||||
|
||||
|
||||
// 70-7F: External Misc Packets
|
||||
// 70-7F: External Sync Packets
|
||||
registerPacket(0x0070, PacketOutExRunEvent.class);
|
||||
registerPacket(0x0071, PacketOutExReset.class);
|
||||
registerPacket(0x0072, PacketOutExReload.class);
|
||||
registerPacket(0x0073, PacketOutExUpdateWhitelist.class);
|
||||
registerPacket(0x0074, PacketExSyncPlayer.class);
|
||||
registerPacket(0x0075, PacketExTransferPlayer.class);
|
||||
registerPacket(0x0076, PacketExDisconnectPlayer.class);
|
||||
registerPacket(0x0077, PacketExMessagePlayer.class);
|
||||
|
||||
//registerPacket(0x0070, new PacketOutRunEvent());
|
||||
//registerPacket(0x0071, new PacketOutReset());
|
||||
//registerPacket(0x0072, new PacketOutReload());
|
||||
//registerPacket(0x0073, new PacketOutExUpdateWhitelist());
|
||||
registerPacket(0x0074, new PacketExSyncPlayer(plugin));
|
||||
registerPacket(0x0075, new PacketExTransferPlayer());
|
||||
registerPacket(0x0076, new PacketExDisconnectPlayer());
|
||||
registerPacket(0x0077, new PacketExMessagePlayer());
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
@ -90,7 +90,7 @@ public final class SubProxy extends BungeeCommon implements Listener {
|
||||
public SubProtocol subprotocol;
|
||||
public SubDataServer subdata = null;
|
||||
public SubServer sudo = null;
|
||||
public static final Version version = Version.fromString("2.17a");
|
||||
public static final Version version = Version.fromString("2.17b/p1");
|
||||
|
||||
public final Proxy mProxy;
|
||||
public boolean canSudo = false;
|
||||
@ -1030,7 +1030,7 @@ public final class SubProxy extends BungeeCommon implements Listener {
|
||||
public void connected(ServerConnectedEvent e) {
|
||||
if (e.getPlayer().isConnected()) {
|
||||
synchronized (rPlayers) {
|
||||
RemotePlayer player = new RemotePlayer(e.getPlayer().getName(), e.getPlayer().getUniqueId(), mProxy, (e.getServer().getInfo() instanceof Server)?(Server) e.getServer().getInfo():null, e.getPlayer().getAddress());
|
||||
RemotePlayer player = new RemotePlayer(e.getPlayer(), e.getServer().getInfo());
|
||||
rPlayerLinkP.put(player.getUniqueId(), player.getProxy());
|
||||
rPlayers.put(player.getUniqueId(), player);
|
||||
if (player.getServer() != null) rPlayerLinkS.put(player.getUniqueId(), player.getServer());
|
||||
|
@ -40,29 +40,14 @@
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-chat</artifactId>
|
||||
<version>1.10-SNAPSHOT</version>
|
||||
<version>1.9-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ME1312.Galaxi</groupId>
|
||||
<artifactId>GalaxiUtil</artifactId>
|
||||
<version>21w24a</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ME1312.SubServers</groupId>
|
||||
<artifactId>SubServers.Client.Common</artifactId>
|
||||
<version>-PLACEHOLDER</version>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ME1312.SubData</groupId>
|
||||
<artifactId>Client</artifactId>
|
||||
<version>21w08a</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.ConnorLinfoot</groupId>
|
||||
@ -117,6 +102,15 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<configuration>
|
||||
<finalName>SubServers.Client.Bukkit</finalName>
|
||||
<outputDirectory>../../Artifacts/Maven</outputDirectory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
@ -154,7 +148,7 @@
|
||||
</goals>
|
||||
<configuration>
|
||||
<windowtitle>SubServers.Client.Bukkit Javadoc</windowtitle>
|
||||
<doctitle>SubServers.Client.Bukkit Javadoc</doctitle>
|
||||
<doctitle>SubServers.Client.Bukkit ${project.version}</doctitle>
|
||||
<show>protected</show>
|
||||
<destDir>./</destDir>
|
||||
<outputDirectory>${basedir}/../../Javadoc/SubServers.Client.Bukkit</outputDirectory>
|
||||
|
@ -5,7 +5,6 @@ import net.ME1312.Galaxi.Library.Container.Pair;
|
||||
import net.ME1312.Galaxi.Library.Map.ObjectMap;
|
||||
import net.ME1312.Galaxi.Library.Util;
|
||||
import net.ME1312.Galaxi.Library.Version.Version;
|
||||
import net.ME1312.SubData.Client.Library.DataSize;
|
||||
import net.ME1312.SubData.Client.SubDataClient;
|
||||
import net.ME1312.SubData.Client.SubDataProtocol;
|
||||
import net.ME1312.SubServers.Client.Bukkit.Event.SubNetworkConnectEvent;
|
||||
@ -76,6 +75,9 @@ public class SubProtocol extends SubDataProtocol {
|
||||
registerPacket(0x0037, PacketStopServer.class);
|
||||
registerPacket(0x0038, PacketRemoveServer.class);
|
||||
registerPacket(0x0039, PacketDeleteServer.class);
|
||||
registerPacket(0x003B, PacketTransferPlayer.class);
|
||||
registerPacket(0x003C, PacketDisconnectPlayer.class);
|
||||
registerPacket(0x003D, PacketMessagePlayer.class);
|
||||
|
||||
registerPacket(0x0030, new PacketCreateServer());
|
||||
registerPacket(0x0031, new PacketAddServer());
|
||||
@ -87,9 +89,12 @@ public class SubProtocol extends SubDataProtocol {
|
||||
registerPacket(0x0037, new PacketStopServer());
|
||||
registerPacket(0x0038, new PacketRemoveServer());
|
||||
registerPacket(0x0039, new PacketDeleteServer());
|
||||
registerPacket(0x003B, new PacketTransferPlayer());
|
||||
registerPacket(0x003C, new PacketDisconnectPlayer());
|
||||
registerPacket(0x003D, new PacketMessagePlayer());
|
||||
|
||||
|
||||
// 70-7F: External Misc Packets
|
||||
// 70-7F: External Sync Packets
|
||||
//registerPacket(0x0070, PacketInExRunEvent.class);
|
||||
//registerPacket(0x0071, PacketInExReset.class);
|
||||
//registerPacket(0x0072, PacketInExReload.class);
|
||||
|
@ -1,6 +1,6 @@
|
||||
name: SubServers-Client-Bukkit
|
||||
main: net.ME1312.SubServers.Client.Bukkit.SubPlugin
|
||||
version: "2.17a"
|
||||
version: "2.17b/p1"
|
||||
authors: ["ME1312"]
|
||||
softdepend: [TitleAPI, PlaceholderAPI]
|
||||
website: "https://github.com/ME1312/SubServers-2"
|
||||
|
@ -19,13 +19,13 @@
|
||||
<groupId>net.ME1312.Galaxi</groupId>
|
||||
<artifactId>GalaxiUtil</artifactId>
|
||||
<version>21w24a</version>
|
||||
<scope>provided</scope>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ME1312.SubData</groupId>
|
||||
<artifactId>Client</artifactId>
|
||||
<version>21w08a</version>
|
||||
<scope>provided</scope>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@ -50,6 +50,33 @@
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>process-resources</phase>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<tasks>
|
||||
<mkdir dir="${project.build.directory}" />
|
||||
<copy file="${basedir}/../../LICENSE" todir="${project.build.directory}/classes" />
|
||||
</tasks>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<configuration>
|
||||
<finalName>SubServers.Client.Common</finalName>
|
||||
<outputDirectory>../../Artifacts/Maven</outputDirectory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
@ -98,6 +125,32 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>javadoc</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<windowtitle>SubServers.Client.Common Javadoc</windowtitle>
|
||||
<doctitle>SubServers.Client.Common ${project.version}</doctitle>
|
||||
<show>protected</show>
|
||||
<destDir>./</destDir>
|
||||
<outputDirectory>${basedir}/../../Javadoc/SubServers.Client.Common</outputDirectory>
|
||||
<reportOutputDirectory>${basedir}/../../Javadoc/SubServers.Client.Common</reportOutputDirectory>
|
||||
<additionalOptions>-Xdoclint:none</additionalOptions>
|
||||
<links>
|
||||
<link>https://dev.me1312.net/jenkins/job/GalaxiEngine/javadoc/GalaxiUtil/</link>
|
||||
<link>https://dev.me1312.net/jenkins/job/SubData/javadoc/Client/</link>
|
||||
</links>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -6,13 +6,11 @@ import net.ME1312.Galaxi.Library.Util;
|
||||
import net.ME1312.SubData.Client.DataClient;
|
||||
import net.ME1312.SubData.Client.SubDataClient;
|
||||
import net.ME1312.SubServers.Client.Common.ClientAPI;
|
||||
import net.ME1312.SubServers.Client.Common.Network.Packet.PacketDownloadPlayerInfo;
|
||||
import net.ME1312.SubServers.Client.Common.Network.Packet.*;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Simplified RemotePlayer Data Class
|
||||
@ -169,6 +167,153 @@ public class RemotePlayer {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends messages to this player
|
||||
*
|
||||
* @param messages Messages to send
|
||||
*/
|
||||
public void sendMessage(String... messages) {
|
||||
sendMessage(messages, i -> {});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends messages to this player
|
||||
*
|
||||
* @param messages Messages to send
|
||||
* @param response Success Status
|
||||
*/
|
||||
public void sendMessage(String[] messages, Callback<Integer> response) {
|
||||
StackTraceElement[] origin = new Exception().getStackTrace();
|
||||
client().sendPacket(new PacketMessagePlayer(getUniqueId(), messages, null, data -> {
|
||||
try {
|
||||
response.run(data.getInt(0x0001));
|
||||
} catch (Throwable e) {
|
||||
Throwable ew = new InvocationTargetException(e);
|
||||
ew.setStackTrace(origin);
|
||||
ew.printStackTrace();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends JSON format messages to this player
|
||||
*
|
||||
* @param messages Messages to send
|
||||
*/
|
||||
public void sendRawMessage(String... messages) {
|
||||
sendRawMessage(messages, i -> {});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends JSON format messages to this player
|
||||
*
|
||||
* @param messages Messages to send
|
||||
* @param response Success Status
|
||||
*/
|
||||
public void sendRawMessage(String[] messages, Callback<Integer> response) {
|
||||
StackTraceElement[] origin = new Exception().getStackTrace();
|
||||
client().sendPacket(new PacketMessagePlayer(getUniqueId(), null, messages, data -> {
|
||||
try {
|
||||
response.run(data.getInt(0x0001));
|
||||
} catch (Throwable e) {
|
||||
Throwable ew = new InvocationTargetException(e);
|
||||
ew.setStackTrace(origin);
|
||||
ew.printStackTrace();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Transfers this player to another server
|
||||
*
|
||||
* @param server Target server
|
||||
*/
|
||||
public void transfer(String server) {
|
||||
transfer(server, i -> {});
|
||||
}
|
||||
|
||||
/**
|
||||
* Transfers this player to another server
|
||||
*
|
||||
* @param server Target server
|
||||
* @param response Success status
|
||||
*/
|
||||
public void transfer(String server, Callback<Integer> response) {
|
||||
StackTraceElement[] origin = new Exception().getStackTrace();
|
||||
client().sendPacket(new PacketTransferPlayer(getUniqueId(), server, data -> {
|
||||
try {
|
||||
response.run(data.getInt(0x0001));
|
||||
} catch (Throwable e) {
|
||||
Throwable ew = new InvocationTargetException(e);
|
||||
ew.setStackTrace(origin);
|
||||
ew.printStackTrace();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Transfers this player to another server
|
||||
*
|
||||
* @param server Target server
|
||||
*/
|
||||
public void transfer(Server server) {
|
||||
transfer(server, i -> {});
|
||||
}
|
||||
|
||||
/**
|
||||
* Transfers this player to another server
|
||||
*
|
||||
* @param server Target server
|
||||
* @param response Success status
|
||||
*/
|
||||
public void transfer(Server server, Callback<Integer> response) {
|
||||
transfer(server.getName(), response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnects this player from the network
|
||||
*/
|
||||
public void disconnect() {
|
||||
disconnect(i -> {});
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnects this player from the network
|
||||
*
|
||||
* @param response Success status
|
||||
*/
|
||||
public void disconnect(Callback<Integer> response) {
|
||||
disconnect(null, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnects this player from the network
|
||||
*
|
||||
* @param message Disconnect Message
|
||||
*/
|
||||
public void disconnect(String message) {
|
||||
disconnect(message, i -> {});
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnects this player from the network
|
||||
*
|
||||
* @param message Disconnect Message
|
||||
* @param response Success status
|
||||
*/
|
||||
public void disconnect(String message, Callback<Integer> response) {
|
||||
StackTraceElement[] origin = new Exception().getStackTrace();
|
||||
client().sendPacket(new PacketDisconnectPlayer(getUniqueId(), message, data -> {
|
||||
try {
|
||||
response.run(data.getInt(0x0001));
|
||||
} catch (Throwable e) {
|
||||
Throwable ew = new InvocationTargetException(e);
|
||||
ew.setStackTrace(origin);
|
||||
ew.printStackTrace();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Timestamp for when the data was last refreshed
|
||||
*
|
||||
|
@ -1,4 +1,4 @@
|
||||
package net.ME1312.SubServers.Sync.Network.Packet;
|
||||
package net.ME1312.SubServers.Client.Common.Network.Packet;
|
||||
|
||||
import net.ME1312.Galaxi.Library.Callback.Callback;
|
||||
import net.ME1312.Galaxi.Library.Map.ObjectMap;
|
@ -0,0 +1,65 @@
|
||||
package net.ME1312.SubServers.Client.Common.Network.Packet;
|
||||
|
||||
import net.ME1312.Galaxi.Library.Callback.Callback;
|
||||
import net.ME1312.Galaxi.Library.Map.ObjectMap;
|
||||
import net.ME1312.Galaxi.Library.Util;
|
||||
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
|
||||
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
|
||||
import net.ME1312.SubData.Client.SubDataSender;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Message Player Packet
|
||||
*/
|
||||
public class PacketMessagePlayer implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
|
||||
private static HashMap<UUID, Callback<ObjectMap<Integer>>[]> callbacks = new HashMap<UUID, Callback<ObjectMap<Integer>>[]>();
|
||||
private UUID player;
|
||||
private String[] legacy, raw;
|
||||
private UUID id;
|
||||
|
||||
/**
|
||||
* New PacketMessagePlayer (In)
|
||||
*/
|
||||
public PacketMessagePlayer() {}
|
||||
|
||||
/**
|
||||
* New PacketMessagePlayer (Out)
|
||||
*
|
||||
* @param player Player
|
||||
* @param legacy Messages (Legacy)
|
||||
* @param raw Messages (JSON)
|
||||
* @param callback Callbacks
|
||||
*/
|
||||
@SafeVarargs
|
||||
public PacketMessagePlayer(UUID player, String[] legacy, String[] raw, Callback<ObjectMap<Integer>>... callback) {
|
||||
if (Util.isNull(player, callback)) throw new NullPointerException();
|
||||
this.player = player;
|
||||
this.legacy = legacy;
|
||||
this.raw = raw;
|
||||
this.id = Util.getNew(callbacks.keySet(), UUID::randomUUID);
|
||||
callbacks.put(id, callback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectMap<Integer> send(SubDataSender client) {
|
||||
ObjectMap<Integer> data = new ObjectMap<Integer>();
|
||||
data.set(0x0000, id);
|
||||
data.set(0x0001, player);
|
||||
if (legacy != null) data.set(0x0002, legacy);
|
||||
if (raw != null) data.set(0x0003, raw);
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive(SubDataSender client, ObjectMap<Integer> data) {
|
||||
for (Callback<ObjectMap<Integer>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(data);
|
||||
callbacks.remove(data.getUUID(0x0000));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int version() {
|
||||
return 0x0001;
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package net.ME1312.SubServers.Client.Common.Network.Packet;
|
||||
|
||||
import net.ME1312.Galaxi.Library.Callback.Callback;
|
||||
import net.ME1312.Galaxi.Library.Map.ObjectMap;
|
||||
import net.ME1312.Galaxi.Library.Util;
|
||||
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
|
||||
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
|
||||
import net.ME1312.SubData.Client.SubDataSender;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Transfer Player Packet
|
||||
*/
|
||||
public class PacketTransferPlayer implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
|
||||
private static HashMap<UUID, Callback<ObjectMap<Integer>>[]> callbacks = new HashMap<UUID, Callback<ObjectMap<Integer>>[]>();
|
||||
private UUID player;
|
||||
private String server;
|
||||
private UUID id;
|
||||
|
||||
/**
|
||||
* New PacketTransferPlayer (In)
|
||||
*/
|
||||
public PacketTransferPlayer() {}
|
||||
|
||||
/**
|
||||
* New PacketTransferPlayer (Out)
|
||||
*
|
||||
* @param player Player
|
||||
* @param server Server
|
||||
* @param callback Callbacks
|
||||
*/
|
||||
@SafeVarargs
|
||||
public PacketTransferPlayer(UUID player, String server, Callback<ObjectMap<Integer>>... callback) {
|
||||
if (Util.isNull(player, callback)) throw new NullPointerException();
|
||||
this.player = player;
|
||||
this.server = server;
|
||||
this.id = Util.getNew(callbacks.keySet(), UUID::randomUUID);
|
||||
callbacks.put(id, callback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectMap<Integer> send(SubDataSender client) {
|
||||
ObjectMap<Integer> data = new ObjectMap<Integer>();
|
||||
data.set(0x0000, id);
|
||||
data.set(0x0001, player);
|
||||
if (server != null) data.set(0x0002, server);
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive(SubDataSender client, ObjectMap<Integer> data) {
|
||||
for (Callback<ObjectMap<Integer>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(data);
|
||||
callbacks.remove(data.getUUID(0x0000));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int version() {
|
||||
return 0x0001;
|
||||
}
|
||||
}
|
@ -25,26 +25,11 @@
|
||||
<version>7.0.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ME1312.Galaxi</groupId>
|
||||
<artifactId>GalaxiUtil</artifactId>
|
||||
<version>21w24a</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ME1312.SubServers</groupId>
|
||||
<artifactId>SubServers.Client.Common</artifactId>
|
||||
<version>-PLACEHOLDER</version>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ME1312.SubData</groupId>
|
||||
<artifactId>Client</artifactId>
|
||||
<version>21w08a</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@ -87,6 +72,15 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<configuration>
|
||||
<finalName>SubServers.Client.Sponge</finalName>
|
||||
<outputDirectory>../../Artifacts/Maven</outputDirectory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
@ -124,7 +118,7 @@
|
||||
</goals>
|
||||
<configuration>
|
||||
<windowtitle>SubServers.Client.Sponge Javadoc</windowtitle>
|
||||
<doctitle>SubServers.Client.Sponge Javadoc</doctitle>
|
||||
<doctitle>SubServers.Client.Sponge ${project.version}</doctitle>
|
||||
<show>protected</show>
|
||||
<destDir>./</destDir>
|
||||
<outputDirectory>${basedir}/../../Javadoc/SubServers.Client.Sponge</outputDirectory>
|
||||
|
@ -79,6 +79,9 @@ public class SubProtocol extends SubDataProtocol {
|
||||
registerPacket(0x0037, PacketStopServer.class);
|
||||
registerPacket(0x0038, PacketRemoveServer.class);
|
||||
registerPacket(0x0039, PacketDeleteServer.class);
|
||||
registerPacket(0x003B, PacketTransferPlayer.class);
|
||||
registerPacket(0x003C, PacketDisconnectPlayer.class);
|
||||
registerPacket(0x003D, PacketMessagePlayer.class);
|
||||
|
||||
registerPacket(0x0030, new PacketCreateServer());
|
||||
registerPacket(0x0031, new PacketAddServer());
|
||||
@ -90,9 +93,12 @@ public class SubProtocol extends SubDataProtocol {
|
||||
registerPacket(0x0037, new PacketStopServer());
|
||||
registerPacket(0x0038, new PacketRemoveServer());
|
||||
registerPacket(0x0039, new PacketDeleteServer());
|
||||
registerPacket(0x003B, new PacketTransferPlayer());
|
||||
registerPacket(0x003C, new PacketDisconnectPlayer());
|
||||
registerPacket(0x003D, new PacketMessagePlayer());
|
||||
|
||||
|
||||
// 70-7F: External Misc Packets
|
||||
// 70-7F: External Sync Packets
|
||||
//registerPacket(0x0070, PacketInExRunEvent.class);
|
||||
//registerPacket(0x0071, PacketInExReset.class);
|
||||
//registerPacket(0x0072, PacketInExReload.class);
|
||||
|
@ -49,7 +49,7 @@ import static net.ME1312.SubServers.Client.Sponge.Library.AccessMode.NO_COMMANDS
|
||||
/**
|
||||
* SubServers Client Plugin Class
|
||||
*/
|
||||
@Plugin(id = "subservers-client-sponge", name = "SubServers-Client-Sponge", authors = "ME1312", version = "2.17a", url = "https://github.com/ME1312/SubServers-2", description = "Take control of the server manager — from your servers")
|
||||
@Plugin(id = "subservers-client-sponge", name = "SubServers-Client-Sponge", authors = "ME1312", version = "2.17b/p1", url = "https://github.com/ME1312/SubServers-2", description = "Take control of the server manager — from your servers")
|
||||
public final class SubPlugin {
|
||||
HashMap<Integer, SubDataClient> subdata = new HashMap<Integer, SubDataClient>();
|
||||
Pair<Long, Map<String, Map<String, String>>> lang = null;
|
||||
|
@ -11,13 +11,13 @@
|
||||
<dependency>
|
||||
<groupId>net.ME1312.SubServers</groupId>
|
||||
<artifactId>SubServers.Client.Bukkit</artifactId>
|
||||
<version>-PLACEHOLDER</version>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ME1312.SubServers</groupId>
|
||||
<artifactId>SubServers.Client.Sponge</artifactId>
|
||||
<version>-PLACEHOLDER</version>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -26,7 +26,6 @@
|
||||
<artifactId>forms_rt</artifactId>
|
||||
<version>7.0.3</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.md_5</groupId>
|
||||
@ -37,7 +36,7 @@
|
||||
<dependency>
|
||||
<groupId>net.ME1312.SubServers</groupId>
|
||||
<artifactId>SubServers.Bungee</artifactId>
|
||||
<version>-PLACEHOLDER</version>
|
||||
<version>${project.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -1,4 +1,4 @@
|
||||
name: SubServers-Console
|
||||
main: net.ME1312.SubServers.Console.ConsolePlugin
|
||||
version: 2.17a
|
||||
version: 2.17b/p1
|
||||
author: ME1312
|
@ -26,42 +26,30 @@
|
||||
<artifactId>jopt-simple</artifactId>
|
||||
<version>5.0.4</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ME1312.Galaxi</groupId>
|
||||
<artifactId>GalaxiEngine</artifactId>
|
||||
<version>21w24a</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ME1312.Galaxi</groupId>
|
||||
<artifactId>GalaxiUI</artifactId>
|
||||
<version>21w24a</version>
|
||||
<scope>runtime</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ME1312.SubServers</groupId>
|
||||
<artifactId>SubServers.Client.Common</artifactId>
|
||||
<version>-PLACEHOLDER</version>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ME1312.SubData</groupId>
|
||||
<artifactId>Client</artifactId>
|
||||
<version>21w08a</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.dosse.upnp</groupId>
|
||||
<artifactId>WaifUPnP</artifactId>
|
||||
<version>1.1</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@ -120,6 +108,15 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<configuration>
|
||||
<finalName>SubServers.Host</finalName>
|
||||
<outputDirectory>../Artifacts/Maven</outputDirectory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
@ -157,7 +154,7 @@
|
||||
</goals>
|
||||
<configuration>
|
||||
<windowtitle>SubServers.Host Javadoc</windowtitle>
|
||||
<doctitle>SubServers.Host Javadoc</doctitle>
|
||||
<doctitle>SubServers.Host ${project.version}</doctitle>
|
||||
<show>protected</show>
|
||||
<destDir>./</destDir>
|
||||
<outputDirectory>${basedir}/../Javadoc/SubServers.Host</outputDirectory>
|
||||
|
@ -43,7 +43,7 @@ import java.util.jar.Manifest;
|
||||
/**
|
||||
* SubServers.Host Main Class
|
||||
*/
|
||||
@App(name = "SubServers.Host", version = "2.17a", authors = "ME1312", website = "https://github.com/ME1312/SubServers-2", description = "Host subservers on separate machines")
|
||||
@App(name = "SubServers.Host", version = "2.17b/p1", authors = "ME1312", website = "https://github.com/ME1312/SubServers-2", description = "Host subservers on separate machines")
|
||||
public final class ExHost {
|
||||
HashMap<Integer, SubDataClient> subdata = new HashMap<Integer, SubDataClient>();
|
||||
Pair<Long, Map<String, Map<String, String>>> lang = null;
|
||||
|
@ -75,6 +75,9 @@ public class SubProtocol extends SubDataProtocol {
|
||||
registerPacket(0x0037, PacketStopServer.class);
|
||||
registerPacket(0x0038, PacketRemoveServer.class);
|
||||
registerPacket(0x0039, PacketDeleteServer.class);
|
||||
registerPacket(0x003B, PacketTransferPlayer.class);
|
||||
registerPacket(0x003C, PacketDisconnectPlayer.class);
|
||||
registerPacket(0x003D, PacketMessagePlayer.class);
|
||||
|
||||
registerPacket(0x0030, new PacketCreateServer());
|
||||
registerPacket(0x0031, new PacketAddServer());
|
||||
@ -86,6 +89,9 @@ public class SubProtocol extends SubDataProtocol {
|
||||
registerPacket(0x0037, new PacketStopServer());
|
||||
registerPacket(0x0038, new PacketRemoveServer());
|
||||
registerPacket(0x0039, new PacketDeleteServer());
|
||||
registerPacket(0x003B, new PacketTransferPlayer());
|
||||
registerPacket(0x003C, new PacketDisconnectPlayer());
|
||||
registerPacket(0x003D, new PacketMessagePlayer());
|
||||
|
||||
|
||||
// 50-6F: External Host Packets
|
||||
@ -112,7 +118,7 @@ public class SubProtocol extends SubDataProtocol {
|
||||
registerPacket(0x0059, new PacketExDeleteServer(host));
|
||||
|
||||
|
||||
// 70-7F: External Misc Packets
|
||||
// 70-7F: External Sync Packets
|
||||
//registerPacket(0x0070, PacketInExRunEvent.class);
|
||||
//registerPacket(0x0071, PacketInExReset.class);
|
||||
//registerPacket(0x0072, PacketInExReload.class);
|
||||
|
@ -25,46 +25,23 @@
|
||||
<version>1.15-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ME1312.Galaxi</groupId>
|
||||
<artifactId>GalaxiUtil</artifactId>
|
||||
<version>21w24a</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ME1312.SubServers</groupId>
|
||||
<artifactId>SubServers.Bungee.Common</artifactId>
|
||||
<version>-PLACEHOLDER</version>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ME1312.SubServers</groupId>
|
||||
<artifactId>SubServers.Client.Common</artifactId>
|
||||
<version>-PLACEHOLDER</version>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ME1312.SubData</groupId>
|
||||
<artifactId>Client</artifactId>
|
||||
<version>21w08a</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.dosse.upnp</groupId>
|
||||
<artifactId>WaifUPnP</artifactId>
|
||||
<version>1.1</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.imaginarycode.minecraft</groupId>
|
||||
<artifactId>RedisBungee</artifactId>
|
||||
<version>0.3.8-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@ -122,6 +99,15 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<configuration>
|
||||
<finalName>SubServers.Sync</finalName>
|
||||
<outputDirectory>../Artifacts/Maven</outputDirectory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
@ -159,7 +145,7 @@
|
||||
</goals>
|
||||
<configuration>
|
||||
<windowtitle>SubServers.Sync Javadoc</windowtitle>
|
||||
<doctitle>SubServers.Sync Javadoc</doctitle>
|
||||
<doctitle>SubServers.Sync ${project.version}</doctitle>
|
||||
<show>protected</show>
|
||||
<destDir>./</destDir>
|
||||
<outputDirectory>${basedir}/../Javadoc/SubServers.Sync</outputDirectory>
|
||||
|
@ -17,10 +17,10 @@ import net.ME1312.SubServers.Bungee.BungeeCommon;
|
||||
import net.ME1312.SubServers.Bungee.Library.Compatibility.Logger;
|
||||
import net.ME1312.SubServers.Bungee.Library.Fallback.FallbackState;
|
||||
import net.ME1312.SubServers.Bungee.Library.Fallback.SmartFallback;
|
||||
import net.ME1312.SubServers.Client.Common.Network.Packet.PacketDisconnectPlayer;
|
||||
import net.ME1312.SubServers.Sync.Event.*;
|
||||
import net.ME1312.SubServers.Sync.Library.ConfigUpdater;
|
||||
import net.ME1312.SubServers.Sync.Library.Metrics;
|
||||
import net.ME1312.SubServers.Sync.Network.Packet.PacketDisconnectPlayer;
|
||||
import net.ME1312.SubServers.Sync.Network.Packet.PacketExSyncPlayer;
|
||||
import net.ME1312.SubServers.Sync.Network.SubProtocol;
|
||||
import net.ME1312.SubServers.Sync.Server.CachedPlayer;
|
||||
@ -72,7 +72,7 @@ public final class ExProxy extends BungeeCommon implements Listener {
|
||||
public final Plugin plugin;
|
||||
public final SubAPI api = new SubAPI(this);
|
||||
public SubProtocol subprotocol;
|
||||
public static final Version version = Version.fromString("2.17a");
|
||||
public static final Version version = Version.fromString("2.17b/p1");
|
||||
|
||||
public final boolean isPatched;
|
||||
public long lastReload = -1;
|
||||
|
@ -0,0 +1,83 @@
|
||||
package net.ME1312.SubServers.Sync.Network.Packet;
|
||||
|
||||
import net.ME1312.Galaxi.Library.Map.ObjectMap;
|
||||
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
|
||||
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
|
||||
import net.ME1312.SubData.Client.SubDataSender;
|
||||
import net.ME1312.SubServers.Sync.ExProxy;
|
||||
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.chat.ComponentSerializer;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Message External Player Packet
|
||||
*/
|
||||
public class PacketExMessagePlayer implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
|
||||
private ExProxy plugin;
|
||||
private int response;
|
||||
private UUID tracker;
|
||||
|
||||
/**
|
||||
* New PacketExMessagePlayer (In)
|
||||
*/
|
||||
public PacketExMessagePlayer(ExProxy plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* New PacketExMessagePlayer (Out)
|
||||
*
|
||||
* @param response Response ID
|
||||
* @param tracker Receiver ID
|
||||
*/
|
||||
public PacketExMessagePlayer(int response, UUID tracker) {
|
||||
this.response = response;
|
||||
this.tracker = tracker;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectMap<Integer> send(SubDataSender client) {
|
||||
ObjectMap<Integer> json = new ObjectMap<Integer>();
|
||||
if (tracker != null) json.set(0x0000, tracker);
|
||||
json.set(0x0001, response);
|
||||
return json;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void receive(SubDataSender client, ObjectMap<Integer> data) {
|
||||
UUID tracker = (data.contains(0x0000)?data.getUUID(0x0000):null);
|
||||
try {
|
||||
UUID id = data.getUUID(0x0001);
|
||||
|
||||
ProxiedPlayer local;
|
||||
if ((local = plugin.getPlayer(id)) != null) {
|
||||
if (data.contains(0x0002))
|
||||
local.sendMessages(data.getRawStringList(0x0002).toArray(new String[0]));
|
||||
if (data.contains(0x0003)) {
|
||||
List<String> messages = data.getRawStringList(0x0003);
|
||||
LinkedList<BaseComponent> components = new LinkedList<BaseComponent>();
|
||||
for (String message : messages) components.addAll(Arrays.asList(ComponentSerializer.parse(message)));
|
||||
local.sendMessage(components.toArray(new BaseComponent[0]));
|
||||
}
|
||||
client.sendPacket(new PacketExMessagePlayer(0, tracker));
|
||||
} else {
|
||||
client.sendPacket(new PacketExMessagePlayer(3, tracker));
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
client.sendPacket(new PacketExMessagePlayer(2, tracker));
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int version() {
|
||||
return 0x0001;
|
||||
}
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
package net.ME1312.SubServers.Sync.Network.Packet;
|
||||
|
||||
import net.ME1312.Galaxi.Library.Map.ObjectMap;
|
||||
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
|
||||
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
|
||||
import net.ME1312.SubData.Client.SubDataSender;
|
||||
import net.ME1312.SubServers.Sync.ExProxy;
|
||||
import net.ME1312.SubServers.Sync.Server.ServerImpl;
|
||||
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.chat.ComponentSerializer;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Transfer External Player Packet
|
||||
*/
|
||||
public class PacketExTransferPlayer implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
|
||||
private ExProxy plugin;
|
||||
private int response;
|
||||
private UUID tracker;
|
||||
|
||||
/**
|
||||
* New PacketExTransferPlayer (In)
|
||||
*/
|
||||
public PacketExTransferPlayer(ExProxy plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* New PacketExTransferPlayer (Out)
|
||||
*
|
||||
* @param response Response ID
|
||||
* @param tracker Receiver ID
|
||||
*/
|
||||
public PacketExTransferPlayer(int response, UUID tracker) {
|
||||
this.response = response;
|
||||
this.tracker = tracker;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectMap<Integer> send(SubDataSender client) {
|
||||
ObjectMap<Integer> json = new ObjectMap<Integer>();
|
||||
if (tracker != null) json.set(0x0000, tracker);
|
||||
json.set(0x0001, response);
|
||||
return json;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void receive(SubDataSender client, ObjectMap<Integer> data) {
|
||||
UUID tracker = (data.contains(0x0000)?data.getUUID(0x0000):null);
|
||||
try {
|
||||
UUID id = data.getUUID(0x0001);
|
||||
|
||||
ProxiedPlayer local;
|
||||
if ((local = plugin.getPlayer(id)) != null) {
|
||||
ServerImpl server;
|
||||
if (data.contains(0x0002) && (server = plugin.servers.get(data.getRawString(0x0002).toLowerCase())) != null) {
|
||||
local.connect(server);
|
||||
client.sendPacket(new PacketExTransferPlayer(0, tracker));
|
||||
} else {
|
||||
client.sendPacket(new PacketExTransferPlayer(1, tracker));
|
||||
}
|
||||
} else {
|
||||
client.sendPacket(new PacketExTransferPlayer(3, tracker));
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
client.sendPacket(new PacketExTransferPlayer(2, tracker));
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int version() {
|
||||
return 0x0001;
|
||||
}
|
||||
}
|
@ -83,7 +83,9 @@ public class SubProtocol extends SubDataProtocol {
|
||||
registerPacket(0x0037, PacketStopServer.class);
|
||||
registerPacket(0x0038, PacketRemoveServer.class);
|
||||
registerPacket(0x0039, PacketDeleteServer.class);
|
||||
registerPacket(0x003B, PacketTransferPlayer.class);
|
||||
registerPacket(0x003C, PacketDisconnectPlayer.class);
|
||||
registerPacket(0x003D, PacketMessagePlayer.class);
|
||||
|
||||
registerPacket(0x0030, new PacketCreateServer());
|
||||
registerPacket(0x0031, new PacketAddServer());
|
||||
@ -95,21 +97,27 @@ public class SubProtocol extends SubDataProtocol {
|
||||
registerPacket(0x0037, new PacketStopServer());
|
||||
registerPacket(0x0038, new PacketRemoveServer());
|
||||
registerPacket(0x0039, new PacketDeleteServer());
|
||||
registerPacket(0x003B, new PacketTransferPlayer());
|
||||
registerPacket(0x003C, new PacketDisconnectPlayer());
|
||||
registerPacket(0x003D, new PacketMessagePlayer());
|
||||
|
||||
|
||||
// 70-7F: External Misc Packets
|
||||
// 70-7F: External Sync Packets
|
||||
//registerPacket(0x0070, PacketInExRunEvent.class);
|
||||
//registerPacket(0x0071, PacketInExReset.class);
|
||||
//registerPacket(0x0073, PacketInExReload.class);
|
||||
registerPacket(0x0074, PacketExSyncPlayer.class);
|
||||
registerPacket(0x0075, PacketExTransferPlayer.class);
|
||||
registerPacket(0x0076, PacketExDisconnectPlayer.class);
|
||||
registerPacket(0x0077, PacketExMessagePlayer.class);
|
||||
|
||||
registerPacket(0x0070, new PacketInExRunEvent(plugin));
|
||||
registerPacket(0x0071, new PacketInExReset());
|
||||
registerPacket(0x0073, new PacketInExUpdateWhitelist(plugin));
|
||||
registerPacket(0x0074, new PacketExSyncPlayer(plugin));
|
||||
registerPacket(0x0075, new PacketExTransferPlayer(plugin));
|
||||
registerPacket(0x0076, new PacketExDisconnectPlayer(plugin));
|
||||
registerPacket(0x0077, new PacketExMessagePlayer(plugin));
|
||||
}
|
||||
|
||||
public static SubProtocol get() {
|
||||
@ -190,7 +198,7 @@ public class SubProtocol extends SubDataProtocol {
|
||||
plugin.api.getRemotePlayers(players -> {
|
||||
for (RemotePlayer player : players.values()) {
|
||||
plugin.rPlayerLinkP.put(player.getUniqueId(), player.getProxyName().toLowerCase());
|
||||
plugin.rPlayers.put(player.getUniqueId(), new CachedPlayer(player));
|
||||
plugin.rPlayers.put(player.getUniqueId(), (CachedPlayer) player);
|
||||
|
||||
ServerInfo server = plugin.getServerInfo(player.getServerName());
|
||||
if (server instanceof ServerImpl)
|
||||
|
@ -1,12 +1,20 @@
|
||||
package net.ME1312.SubServers.Sync.Server;
|
||||
|
||||
import net.ME1312.Galaxi.Library.Callback.Callback;
|
||||
import net.ME1312.Galaxi.Library.Map.ObjectMap;
|
||||
import net.ME1312.SubServers.Client.Common.Network.API.RemotePlayer;
|
||||
import net.ME1312.SubServers.Client.Common.Network.API.Server;
|
||||
import net.ME1312.SubServers.Sync.SubAPI;
|
||||
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.chat.ComponentSerializer;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Cached RemotePlayer Data Class
|
||||
@ -57,9 +65,89 @@ public class CachedPlayer extends RemotePlayer implements net.ME1312.SubServers.
|
||||
super(raw);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProxiedPlayer get() {
|
||||
return ProxyServer.getInstance().getPlayer(getUniqueId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerInfo getServer() {
|
||||
String name = getServerName();
|
||||
return (name == null)? null : ProxyServer.getInstance().getServerInfo(name);
|
||||
}
|
||||
|
||||
// These overrides prevent sending unnecessary packets
|
||||
|
||||
@Override
|
||||
public void sendMessage(String[] messages, Callback<Integer> response) {
|
||||
ProxiedPlayer local = get();
|
||||
if (local != null) {
|
||||
local.sendMessages(messages);
|
||||
response.run(0);
|
||||
} else {
|
||||
super.sendMessage(messages, response);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(BaseComponent[] messages, Callback<Integer> response) {
|
||||
ProxiedPlayer local = get();
|
||||
if (local != null) {
|
||||
local.sendMessage(messages);
|
||||
response.run(0);
|
||||
} else {
|
||||
super.sendRawMessage(new String[]{ComponentSerializer.toString(messages)}, response);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRawMessage(String[] messages, Callback<Integer> response) {
|
||||
ProxiedPlayer local = get();
|
||||
if (local != null) {
|
||||
LinkedList<BaseComponent> components = new LinkedList<BaseComponent>();
|
||||
for (String message : messages) components.addAll(Arrays.asList(ComponentSerializer.parse(message)));
|
||||
local.sendMessage(components.toArray(new BaseComponent[0]));
|
||||
response.run(0);
|
||||
} else {
|
||||
super.sendRawMessage(messages, response);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transfer(String server, Callback<Integer> response) {
|
||||
ProxiedPlayer local = get();
|
||||
if (local != null) {
|
||||
ServerImpl info = SubAPI.getInstance().getInternals().servers.get(server.toLowerCase());
|
||||
if (info != null) {
|
||||
local.connect(info);
|
||||
response.run(0);
|
||||
} else response.run(1);
|
||||
} else {
|
||||
super.transfer(server, response);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transfer(ServerInfo server, Callback<Integer> response) {
|
||||
ProxiedPlayer local = get();
|
||||
if (local != null) {
|
||||
local.connect(server);
|
||||
response.run(0);
|
||||
} else {
|
||||
super.transfer(server.getName(), response);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect(String message, Callback<Integer> response) {
|
||||
ProxiedPlayer local = get();
|
||||
if (local != null) {
|
||||
if (message != null) {
|
||||
local.disconnect(message);
|
||||
} else local.disconnect();
|
||||
response.run(0);
|
||||
} else {
|
||||
super.disconnect(message, response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.ME1312.SubServers.Sync;
|
||||
|
||||
import net.ME1312.Galaxi.Library.Callback.Callback;
|
||||
import net.ME1312.Galaxi.Library.UniversalFile;
|
||||
import net.ME1312.Galaxi.Library.Util;
|
||||
import net.ME1312.Galaxi.Library.Version.Version;
|
||||
@ -8,6 +9,7 @@ import net.ME1312.SubData.Client.DataProtocol;
|
||||
import net.ME1312.SubData.Client.SubDataClient;
|
||||
import net.ME1312.SubServers.Bungee.BungeeAPI;
|
||||
import net.ME1312.SubServers.Client.Common.ClientAPI;
|
||||
import net.ME1312.SubServers.Client.Common.Network.API.RemotePlayer;
|
||||
import net.ME1312.SubServers.Sync.Server.CachedPlayer;
|
||||
import net.ME1312.SubServers.Sync.Server.ServerImpl;
|
||||
|
||||
@ -94,6 +96,14 @@ public final class SubAPI extends ClientAPI implements BungeeAPI {
|
||||
return new HashMap<UUID, CachedPlayer>(plugin.rPlayers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getRemotePlayers(Callback<Map<UUID, RemotePlayer>> callback) {
|
||||
super.getRemotePlayers(map -> {
|
||||
map.replaceAll((k, v) -> new CachedPlayer(v));
|
||||
callback.run(map);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a player on this network by searching across all known proxies (Cached)
|
||||
*
|
||||
@ -108,6 +118,11 @@ public final class SubAPI extends ClientAPI implements BungeeAPI {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getRemotePlayer(String name, Callback<RemotePlayer> callback) {
|
||||
super.getRemotePlayer(name, p -> callback.run(new CachedPlayer(p)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a player on this network by searching across all known proxies (Cached)
|
||||
*
|
||||
@ -119,6 +134,11 @@ public final class SubAPI extends ClientAPI implements BungeeAPI {
|
||||
return getRemotePlayers().getOrDefault(id, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getRemotePlayer(UUID id, Callback<RemotePlayer> callback) {
|
||||
super.getRemotePlayer(id, p -> callback.run(new CachedPlayer(p)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the SubData Network Connections
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user