mirror of
https://github.com/ME1312/SubServers-2.git
synced 2025-02-04 05:41:31 +01:00
Add subservers:input
for 1.19+
This is a simple plugin message channel that simulates chat spoofing.
This commit is contained in:
parent
307ac43df0
commit
41dd2d69d0
@ -30,6 +30,7 @@ import java.io.IOException;
|
|||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
@ -671,9 +672,12 @@ public final class SubCommand extends Command implements TabExecutor {
|
|||||||
sender.sendMessages(printHelp());
|
sender.sendMessages(printHelp());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String str = label;
|
ProxiedPlayer player = (ProxiedPlayer) sender;
|
||||||
for (String arg : args) str += ' ' + arg;
|
if (player.getPendingConnection().getVersion() < 759) { // player < 1.19
|
||||||
((ProxiedPlayer) sender).chat(str);
|
player.chat((args.length == 0)? label : label + ' ' + String.join(" ", args));
|
||||||
|
} else {
|
||||||
|
player.getServer().sendData("subservers:input", ((args.length == 0)? label : label + ' ' + String.join(" ", args)).getBytes(StandardCharsets.UTF_8));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ public final class SubProxy extends BungeeCommon implements Listener {
|
|||||||
public SubProtocol subprotocol;
|
public SubProtocol subprotocol;
|
||||||
public SubDataServer subdata = null;
|
public SubDataServer subdata = null;
|
||||||
public SubServer sudo = null;
|
public SubServer sudo = null;
|
||||||
public static final Version version = Version.fromString("2.18.2a");
|
public static final Version version = Version.fromString("2.19a");
|
||||||
|
|
||||||
public final Proxy mProxy;
|
public final Proxy mProxy;
|
||||||
public boolean canSudo = false;
|
public boolean canSudo = false;
|
||||||
@ -724,6 +724,7 @@ public final class SubProxy extends BungeeCommon implements Listener {
|
|||||||
if (!config.get().getMap("Settings").getStringList("Disabled-Overrides", Collections.emptyList()).contains("/glist"))
|
if (!config.get().getMap("Settings").getStringList("Disabled-Overrides", Collections.emptyList()).contains("/glist"))
|
||||||
getPluginManager().registerCommand(plugin, new SubCommand.BungeeList(this, "glist"));
|
getPluginManager().registerCommand(plugin, new SubCommand.BungeeList(this, "glist"));
|
||||||
|
|
||||||
|
registerChannel("subservers:input");
|
||||||
getPluginManager().registerCommand(plugin, new SubCommand(this, "subservers"));
|
getPluginManager().registerCommand(plugin, new SubCommand(this, "subservers"));
|
||||||
getPluginManager().registerCommand(plugin, new SubCommand(this, "subserver"));
|
getPluginManager().registerCommand(plugin, new SubCommand(this, "subserver"));
|
||||||
getPluginManager().registerCommand(plugin, new SubCommand(this, "sub"));
|
getPluginManager().registerCommand(plugin, new SubCommand(this, "sub"));
|
||||||
|
@ -26,6 +26,7 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.command.CommandMap;
|
import org.bukkit.command.CommandMap;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.bukkit.plugin.messaging.Messenger;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.lang.invoke.MethodHandle;
|
import java.lang.invoke.MethodHandle;
|
||||||
@ -33,6 +34,7 @@ import java.lang.reflect.InvocationTargetException;
|
|||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.StandardCopyOption;
|
import java.nio.file.StandardCopyOption;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -96,7 +98,9 @@ public final class SubPlugin extends JavaPlugin {
|
|||||||
Files.move(new File(new File(System.getProperty("user.dir")), "subdata.rsa.key").toPath(), new File(dir, "subdata.rsa.key").toPath());
|
Files.move(new File(new File(System.getProperty("user.dir")), "subdata.rsa.key").toPath(), new File(dir, "subdata.rsa.key").toPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
Messenger pmc = getServer().getMessenger();
|
||||||
|
pmc.registerOutgoingPluginChannel(this, "BungeeCord");
|
||||||
|
pmc.registerIncomingPluginChannel(this, "subservers:input", (channel, player, bytes) -> player.chat(new String(bytes, StandardCharsets.UTF_8)));
|
||||||
reload(false);
|
reload(false);
|
||||||
|
|
||||||
subprotocol = SubProtocol.get();
|
subprotocol = SubProtocol.get();
|
||||||
@ -232,6 +236,10 @@ public final class SubPlugin extends JavaPlugin {
|
|||||||
subdata.clear();
|
subdata.clear();
|
||||||
subdata.put(0, null);
|
subdata.put(0, null);
|
||||||
if (signs != null) signs.save();
|
if (signs != null) signs.save();
|
||||||
|
|
||||||
|
Messenger pmc = getServer().getMessenger();
|
||||||
|
pmc.unregisterOutgoingPluginChannel(this);
|
||||||
|
pmc.unregisterIncomingPluginChannel(this);
|
||||||
} catch (IOException | InterruptedException e) {
|
} catch (IOException | InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
name: SubServers-Client-Bukkit
|
name: SubServers-Client-Bukkit
|
||||||
main: net.ME1312.SubServers.Client.Bukkit.SubPlugin
|
main: net.ME1312.SubServers.Client.Bukkit.SubPlugin
|
||||||
version: "2.18.2a"
|
version: "2.19a"
|
||||||
authors: ["ME1312"]
|
authors: ["ME1312"]
|
||||||
softdepend: [TitleAPI, PlaceholderAPI]
|
softdepend: [TitleAPI, PlaceholderAPI]
|
||||||
website: "https://github.com/ME1312/SubServers-2"
|
website: "https://github.com/ME1312/SubServers-2"
|
||||||
|
@ -27,6 +27,7 @@ import org.spongepowered.api.entity.living.player.Player;
|
|||||||
import org.spongepowered.api.event.Listener;
|
import org.spongepowered.api.event.Listener;
|
||||||
import org.spongepowered.api.event.game.state.GameInitializationEvent;
|
import org.spongepowered.api.event.game.state.GameInitializationEvent;
|
||||||
import org.spongepowered.api.event.game.state.GamePreInitializationEvent;
|
import org.spongepowered.api.event.game.state.GamePreInitializationEvent;
|
||||||
|
import org.spongepowered.api.event.game.state.GameStartedServerEvent;
|
||||||
import org.spongepowered.api.event.game.state.GameStoppingEvent;
|
import org.spongepowered.api.event.game.state.GameStoppingEvent;
|
||||||
import org.spongepowered.api.network.ChannelBinding;
|
import org.spongepowered.api.network.ChannelBinding;
|
||||||
import org.spongepowered.api.plugin.Plugin;
|
import org.spongepowered.api.plugin.Plugin;
|
||||||
@ -47,7 +48,7 @@ import static net.ME1312.SubServers.Client.Sponge.Library.AccessMode.NO_COMMANDS
|
|||||||
/**
|
/**
|
||||||
* SubServers Client Plugin Class
|
* SubServers Client Plugin Class
|
||||||
*/
|
*/
|
||||||
@Plugin(id = "subservers-client-sponge", name = "SubServers-Client-Sponge", authors = "ME1312", version = "2.18.2a", 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.19a", url = "https://github.com/ME1312/SubServers-2", description = "Take control of the server manager — from your servers")
|
||||||
public final class SubPlugin {
|
public final class SubPlugin {
|
||||||
HashMap<Integer, SubDataClient> subdata = new HashMap<Integer, SubDataClient>();
|
HashMap<Integer, SubDataClient> subdata = new HashMap<Integer, SubDataClient>();
|
||||||
Pair<Long, Map<String, Map<String, String>>> lang = null;
|
Pair<Long, Map<String, Map<String, String>>> lang = null;
|
||||||
@ -66,14 +67,15 @@ public final class SubPlugin {
|
|||||||
@Inject public Game game;
|
@Inject public Game game;
|
||||||
|
|
||||||
boolean running = false;
|
boolean running = false;
|
||||||
|
private boolean posted = false;
|
||||||
private long resetDate = 0;
|
private long resetDate = 0;
|
||||||
private boolean reconnect = false;
|
private boolean reconnect = false;
|
||||||
|
|
||||||
@Listener
|
@Listener
|
||||||
public void setup(GamePreInitializationEvent event) {
|
public void enable(GamePreInitializationEvent event) {
|
||||||
if (plugin.getVersion().isPresent()) {
|
if (plugin.getVersion().isPresent()) {
|
||||||
version = Version.fromString(plugin.getVersion().get());
|
version = Version.fromString(plugin.getVersion().get());
|
||||||
} else version = new Version("Custom");
|
} else version = new Version("?");
|
||||||
subdata.put(0, null);
|
subdata.put(0, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,12 +138,23 @@ public final class SubPlugin {
|
|||||||
reconnect = true;
|
reconnect = true;
|
||||||
log.info(" ");
|
log.info(" ");
|
||||||
log.info("Connecting to /" + config.get().getMap("Settings").getMap("SubData").getString("Address", "127.0.0.1:4391"));
|
log.info("Connecting to /" + config.get().getMap("Settings").getMap("SubData").getString("Address", "127.0.0.1:4391"));
|
||||||
connect(null);
|
if (posted) connect(null);
|
||||||
|
|
||||||
//gui = new InternalUIHandler(this);
|
//gui = new InternalUIHandler(this);
|
||||||
if (api.access.value > NO_COMMANDS.value && !config.get().getMap("Settings").getBoolean("API-Only-Mode", false)) {
|
if (api.access.value > NO_COMMANDS.value && !config.get().getMap("Settings").getBoolean("API-Only-Mode", false)) {
|
||||||
Sponge.getCommandManager().register(plugin, new SubCommand(this).spec(), "sub", "subserver", "subservers");
|
Sponge.getCommandManager().register(plugin, new SubCommand(this).spec(), "sub", "subserver", "subservers");
|
||||||
}
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Listener
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public void enable(GameStartedServerEvent event) {
|
||||||
|
if (!posted) try {
|
||||||
|
posted = true;
|
||||||
|
connect(null);
|
||||||
|
|
||||||
new Metrics(this);
|
new Metrics(this);
|
||||||
game.getScheduler().createTaskBuilder().async().execute(() -> {
|
game.getScheduler().createTaskBuilder().async().execute(() -> {
|
||||||
@ -167,8 +180,6 @@ public final class SubPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void reload(boolean notifyPlugins) throws IOException {
|
public void reload(boolean notifyPlugins) throws IOException {
|
||||||
resetDate = Calendar.getInstance().getTime().getTime();
|
resetDate = Calendar.getInstance().getTime().getTime();
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ import java.util.jar.Manifest;
|
|||||||
/**
|
/**
|
||||||
* SubServers.Host Main Class
|
* SubServers.Host Main Class
|
||||||
*/
|
*/
|
||||||
@App(name = "SubServers.Host", version = "2.18.2a", authors = "ME1312", website = "https://github.com/ME1312/SubServers-2", description = "Host subservers on separate machines")
|
@App(name = "SubServers.Host", version = "2.19a", authors = "ME1312", website = "https://github.com/ME1312/SubServers-2", description = "Host subservers on separate machines")
|
||||||
public final class ExHost {
|
public final class ExHost {
|
||||||
HashMap<Integer, SubDataClient> subdata = new HashMap<Integer, SubDataClient>();
|
HashMap<Integer, SubDataClient> subdata = new HashMap<Integer, SubDataClient>();
|
||||||
Pair<Long, Map<String, Map<String, String>>> lang = null;
|
Pair<Long, Map<String, Map<String, String>>> lang = null;
|
||||||
|
@ -74,7 +74,7 @@ public final class ExProxy extends BungeeCommon implements Listener {
|
|||||||
public final Plugin plugin;
|
public final Plugin plugin;
|
||||||
public final SubAPI api = new SubAPI(this);
|
public final SubAPI api = new SubAPI(this);
|
||||||
public SubProtocol subprotocol;
|
public SubProtocol subprotocol;
|
||||||
public static final Version version = Version.fromString("2.18.2a");
|
public static final Version version = Version.fromString("2.19a");
|
||||||
|
|
||||||
public final boolean isPatched;
|
public final boolean isPatched;
|
||||||
public long lastReload = -1;
|
public long lastReload = -1;
|
||||||
@ -260,6 +260,7 @@ public final class ExProxy extends BungeeCommon implements Listener {
|
|||||||
if (!config.get().getMap("Settings").getStringList("Disabled-Overrides", Collections.emptyList()).contains("/glist"))
|
if (!config.get().getMap("Settings").getStringList("Disabled-Overrides", Collections.emptyList()).contains("/glist"))
|
||||||
getPluginManager().registerCommand(plugin, new SubCommand.BungeeList(this, "glist"));
|
getPluginManager().registerCommand(plugin, new SubCommand.BungeeList(this, "glist"));
|
||||||
|
|
||||||
|
registerChannel("subservers:input");
|
||||||
getPluginManager().registerCommand(plugin, new SubCommand(this, "subservers"));
|
getPluginManager().registerCommand(plugin, new SubCommand(this, "subservers"));
|
||||||
getPluginManager().registerCommand(plugin, new SubCommand(this, "subserver"));
|
getPluginManager().registerCommand(plugin, new SubCommand(this, "subserver"));
|
||||||
getPluginManager().registerCommand(plugin, new SubCommand(this, "sub"));
|
getPluginManager().registerCommand(plugin, new SubCommand(this, "sub"));
|
||||||
|
@ -38,6 +38,7 @@ import java.io.InputStreamReader;
|
|||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
@ -731,9 +732,12 @@ public final class SubCommand extends Command implements TabExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String str = label;
|
ProxiedPlayer player = (ProxiedPlayer) sender;
|
||||||
for (String arg : args) str += ' ' + arg;
|
if (player.getPendingConnection().getVersion() < 759) { // player < 1.19
|
||||||
((ProxiedPlayer) sender).chat(str);
|
player.chat((args.length == 0)? label : label + ' ' + String.join(" ", args));
|
||||||
|
} else {
|
||||||
|
player.getServer().sendData("subservers:input", ((args.length == 0)? label : label + ' ' + String.join(" ", args)).getBytes(StandardCharsets.UTF_8));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.velocitypowered</groupId>
|
<groupId>com.velocitypowered</groupId>
|
||||||
<artifactId>velocity-api</artifactId>
|
<artifactId>velocity-api</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>3.1.0-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -64,7 +64,7 @@ import java.nio.charset.Charset;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@Plugin(id = "subservers-sync", name = "SubServers-Sync", authors = "ME1312", version = "2.18.2a", url = "https://github.com/ME1312/SubServers-2", description = "Dynamically sync player and server connection info over multiple proxy instances")
|
@Plugin(id = "subservers-sync", name = "SubServers-Sync", authors = "ME1312", version = "2.19a", url = "https://github.com/ME1312/SubServers-2", description = "Dynamically sync player and server connection info over multiple proxy instances")
|
||||||
public class ExProxy {
|
public class ExProxy {
|
||||||
|
|
||||||
HashMap<Integer, SubDataClient> subdata = new HashMap<Integer, SubDataClient>();
|
HashMap<Integer, SubDataClient> subdata = new HashMap<Integer, SubDataClient>();
|
||||||
@ -225,6 +225,7 @@ public class ExProxy {
|
|||||||
if (!config.get().getMap("Settings").getStringList("Disabled-Overrides", Collections.emptyList()).contains("/glist"))
|
if (!config.get().getMap("Settings").getStringList("Disabled-Overrides", Collections.emptyList()).contains("/glist"))
|
||||||
proxy.getCommandManager().register("glist", new SubCommand.BungeeList(this));
|
proxy.getCommandManager().register("glist", new SubCommand.BungeeList(this));
|
||||||
|
|
||||||
|
proxy.getChannelRegistrar().register(SubCommand.pmc);
|
||||||
proxy.getCommandManager().register("subservers", new SubCommand(this), "subserver", "sub");
|
proxy.getCommandManager().register("subservers", new SubCommand(this), "subserver", "sub");
|
||||||
|
|
||||||
if (config.get().getMap("Settings").getMap("Smart-Fallback", new ObjectMap<>()).getBoolean("Enabled", true))
|
if (config.get().getMap("Settings").getMap("Smart-Fallback", new ObjectMap<>()).getBoolean("Enabled", true))
|
||||||
|
@ -29,6 +29,7 @@ import com.velocitypowered.api.command.SimpleCommand;
|
|||||||
import com.velocitypowered.api.proxy.ConsoleCommandSource;
|
import com.velocitypowered.api.proxy.ConsoleCommandSource;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import com.velocitypowered.api.proxy.ServerConnection;
|
import com.velocitypowered.api.proxy.ServerConnection;
|
||||||
|
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
||||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||||
import com.velocitypowered.api.proxy.server.ServerInfo;
|
import com.velocitypowered.api.proxy.server.ServerInfo;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
@ -42,6 +43,7 @@ import java.io.InputStreamReader;
|
|||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
@ -49,6 +51,7 @@ import java.util.function.Supplier;
|
|||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public final class SubCommand implements SimpleCommand {
|
public final class SubCommand implements SimpleCommand {
|
||||||
|
static final MinecraftChannelIdentifier pmc = MinecraftChannelIdentifier.create("subservers", "input");
|
||||||
static HashMap<UUID, HashMap<ServerInfo, Pair<Long, Boolean>>> permitted = new HashMap<UUID, HashMap<ServerInfo, Pair<Long, Boolean>>>();
|
static HashMap<UUID, HashMap<ServerInfo, Pair<Long, Boolean>>> permitted = new HashMap<UUID, HashMap<ServerInfo, Pair<Long, Boolean>>>();
|
||||||
private Map<String, Proxy> proxyCache = Collections.emptyMap();
|
private Map<String, Proxy> proxyCache = Collections.emptyMap();
|
||||||
private Map<String, Host> hostCache = Collections.emptyMap();
|
private Map<String, Host> hostCache = Collections.emptyMap();
|
||||||
@ -736,9 +739,12 @@ public final class SubCommand implements SimpleCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String str = label;
|
Player player = (Player) sender;
|
||||||
for (String arg : args) str += ' ' + arg;
|
if (player.getProtocolVersion().getProtocol() < 759) { // player < 1.19
|
||||||
((Player) sender).spoofChatInput(str);
|
player.spoofChatInput((args.length == 0)? label : label + ' ' + String.join(" ", args));
|
||||||
|
} else {
|
||||||
|
player.getCurrentServer().ifPresent(server -> server.sendPluginMessage(pmc, ((args.length == 0)? label : label + ' ' + String.join(" ", args)).getBytes(StandardCharsets.UTF_8)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user