Allow commands to be sent to external servers

This commit is contained in:
ME1312 2021-12-01 04:50:25 -05:00
parent aef7a164e6
commit 7179911d4c
No known key found for this signature in database
GPG Key ID: FEFFE2F698E88FA8
60 changed files with 908 additions and 555 deletions

View File

@ -28,7 +28,7 @@
<dependency>
<groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiUtil</artifactId>
<version>21w47d</version>
<version>21w49a</version>
<scope>compile</scope>
</dependency>
</dependencies>

View File

@ -1,7 +1,7 @@
package net.ME1312.SubServers.Bungee.Event;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubServers.Bungee.Host.SubServer;
import net.ME1312.SubServers.Bungee.Host.Server;
import net.ME1312.SubServers.Bungee.Library.SubEvent;
import net.md_5.bungee.api.plugin.Cancellable;
@ -15,20 +15,24 @@ import java.util.UUID;
public class SubSendCommandEvent extends Event implements SubEvent, Cancellable {
private boolean cancelled = false;
private UUID player;
private SubServer server;
private Server server;
private String command;
private UUID target;
/**
* Server Command Event
*
* @param player Player Commanding Server
* @param server Server being Commanded
* @param player Player Commanding
* @param server Target Server
* @param command Command to Send
* @param target Player that will send
*/
public SubSendCommandEvent(UUID player, SubServer server, String command) {
public SubSendCommandEvent(UUID player, Server server, String command, UUID target) {
Util.nullpo(server, command);
this.player = player;
this.server = server;
this.command = command;
this.target = target;
}
/**
@ -36,7 +40,7 @@ public class SubSendCommandEvent extends Event implements SubEvent, Cancellable
*
* @return The Server Effected
*/
public SubServer getServer() { return server; }
public Server getServer() { return server; }
/**
* Gets the player that triggered the Event
@ -63,6 +67,15 @@ public class SubSendCommandEvent extends Event implements SubEvent, Cancellable
command = value;
}
/**
* Gets the Player that will be forced to send the Command
*
* @return Target Player or null if Console
*/
public UUID getTarget() {
return target;
}
/**
* Gets the Cancelled Status
*

View File

@ -214,7 +214,7 @@ public class ExternalSubServer extends SubServerImpl {
public boolean command(UUID player, String command) {
Util.nullpo(command);
if (running) {
SubSendCommandEvent event = new SubSendCommandEvent(player, this, command);
SubSendCommandEvent event = new SubSendCommandEvent(player, this, command, null);
host.plugin.getPluginManager().callEvent(event);
if (!event.isCancelled() && (player == null || !DISALLOWED_COMMANDS.matcher(command).find())) {
history.add(new LoggedCommand(player, event.getCommand()));

View File

@ -278,7 +278,7 @@ public class InternalSubServer extends SubServerImpl {
public boolean command(UUID player, String command) {
Util.nullpo(command);
if (thread != null && thread.isAlive()) {
SubSendCommandEvent event = new SubSendCommandEvent(player, this, command);
SubSendCommandEvent event = new SubSendCommandEvent(player, this, command, null);
host.plugin.getPluginManager().callEvent(event);
if (!event.isCancelled() && (player == null || !DISALLOWED_COMMANDS.matcher(command).find())) {
try {

View File

@ -58,6 +58,34 @@ public interface Server extends ServerInfo, ClientHandler, ExtraDataHandler<Stri
*/
void removeGroup(String value);
/**
* Commands the Server
*
* @param player Player who's Commanding
* @param target Player who will Send
* @param command Command to Send
*/
boolean command(UUID player, UUID target, String command);
/**
* Commands the Server
*
* @param player Player who's Commanding
* @param command Command to Send
*/
default boolean command(UUID player, String command) {
return command(player, null, command);
}
/**
* Commands the Server
*
* @param command Command to Send
*/
default boolean command(String command) {
return command(null, command);
}
/**
* Get players on this server across all known proxies
*

View File

@ -5,15 +5,20 @@ import net.ME1312.Galaxi.Library.Map.ObjectMapValue;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Server.DataClient;
import net.ME1312.SubData.Server.SubDataClient;
import net.ME1312.SubServers.Bungee.Event.SubSendCommandEvent;
import net.ME1312.SubServers.Bungee.Host.SubServer.LoggedCommand;
import net.ME1312.SubServers.Bungee.Library.Exception.InvalidServerException;
import net.ME1312.SubServers.Bungee.Network.Packet.PacketExControlPlayer;
import net.ME1312.SubServers.Bungee.Network.Packet.PacketOutExEditServer;
import net.ME1312.SubServers.Bungee.Network.Packet.PacketOutExEditServer.Edit;
import net.ME1312.SubServers.Bungee.SubAPI;
import net.md_5.bungee.BungeeServerInfo;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.util.*;
@ -173,6 +178,20 @@ public class ServerImpl extends BungeeServerInfo implements Server {
Collections.sort(groups);
}
@Override
public boolean command(UUID player, UUID target, String command) {
Util.nullpo(command);
SubDataClient channel = (SubDataClient) getSubData()[0];
if (channel != null) {
SubSendCommandEvent event = new SubSendCommandEvent(player, this, command, target);
ProxyServer.getInstance().getPluginManager().callEvent(event);
if (!event.isCancelled() && (player == null || !SubServerImpl.DISALLOWED_COMMANDS.matcher(command).find())) {
channel.sendPacket(new PacketExControlPlayer(target, command));
return true;
} else return false;
} else return false;
}
@Override
public Collection<RemotePlayer> getRemotePlayers() {
return SubAPI.getInstance().getRemotePlayers(this).values();

View File

@ -3,6 +3,7 @@ package net.ME1312.SubServers.Bungee.Host;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import java.io.File;
import java.util.*;
/**
@ -114,7 +115,9 @@ public interface SubServer extends Server {
*
* @return Success Status
*/
boolean start();
default boolean start() {
return start(null);
}
/**
* Stops the Server
@ -129,7 +132,9 @@ public interface SubServer extends Server {
*
* @return Success Status
*/
boolean stop();
default boolean stop() {
return stop(null);
}
/**
* Terminates the Server
@ -144,24 +149,9 @@ public interface SubServer extends Server {
*
* @return Success Status
*/
boolean terminate();
/**
* Commands the Server
*
* @param player Player who Commanded
* @param command Command to Send
* @return Success Status
*/
boolean command(UUID player, String command);
/**
* Commands the Server
*
* @param command Command to Send
* @return Success Status
*/
boolean command(String command);
default boolean terminate() {
return terminate(null);
}
/**
* Edits the Server
@ -325,7 +315,9 @@ public interface SubServer extends Server {
*
* @return Full Server Directory Path
*/
String getFullPath();
default String getFullPath() {
return new File(getHost().getPath(), getPath()).getPath();
}
/**
* Get the Server's Executable String

View File

@ -231,7 +231,7 @@ public abstract class SubServerController {
/**
* Commands the Server
*
* @param player Player who Commanded
* @param player Player who's Commanding
* @param command Command to Send
* @return Success Status
*/

View File

@ -58,26 +58,6 @@ public abstract class SubServerImpl extends ServerImpl implements SubServer {
super(name, new InetSocketAddress(host.getAddress().getHostAddress(), port), motd, hidden, restricted);
}
@Override
public boolean start() {
return start(null);
}
@Override
public boolean stop() {
return stop(null);
}
@Override
public boolean terminate() {
return terminate(null);
}
@Override
public boolean command(String command) {
return command(null, command);
}
public int edit(UUID player, ObjectMap<String> edit) {
return edit(player, edit, false);
}
@ -136,11 +116,6 @@ public abstract class SubServerImpl extends ServerImpl implements SubServer {
}
}
@Override
public String getFullPath() {
return new File(getHost().getPath(), getPath()).getPath();
}
@Override
public void toggleCompatibility(SubServer... server) {
for (SubServer s : server) {

View File

@ -309,7 +309,7 @@ public class ConfigUpdater {
if (was.compareTo(new Version("19w22b")) <= 0) {
if (existing.contains("Lang")) {
updated.getMap("Lang").remove("Interface.Host-Admin.SubServers");
updated.getMap("Lang").remove("Interface.SubServer-Admin.Command");
updated.getMap("Lang").remove("Interface.Server-Admin.Command");
}
existing = updated.clone();
@ -324,7 +324,7 @@ public class ConfigUpdater {
existing = updated.clone();
i++;
} if (was.compareTo(new Version("21w27b")) <= 0) {
} if (was.compareTo(new Version("21w49b")) <= 0) {
//existing = updated.clone();
i++;
@ -430,9 +430,10 @@ public class ConfigUpdater {
def.put("Command.Terminate", "&aSubServers &2&l\\u00BB&a Terminated &2$int$&a subserver(s)");
def.put("Command.Terminate.Disappeared", "&cSubServers &4&l\\u00BB&c Subserver &4$str$&c has disappeared");
def.put("Command.Terminate.Not-Running", "&7SubServers &8&l\\u00BB&7 &f$int$&7 subserver(s) were already offline");
def.put("Command.Command", "&aSubServers &2&l\\u00BB&a Sent command to &2$int$&a subserver(s)");
def.put("Command.Command", "&aSubServers &2&l\\u00BB&a Sent command to &2$int$&a server(s)");
def.put("Command.Command.Disappeared", "&cSubServers &4&l\\u00BB&c Server &4$str$&c has disappeared");
def.put("Command.Command.No-Command", "&cSubServers &4&l\\u00BB&c No command was entered");
def.put("Command.Command.Not-Running", "&7SubServers &8&l\\u00BB&7 &f$int$&7 subserver(s) were offline");
def.put("Command.Command.Not-Running", "&7SubServers &8&l\\u00BB&7 &f$int$&7 server(s) were unavailable");
def.put("Command.Creator", "&aSubServers &2&l\\u00BB&a Creating subserver &2$str$&a");
def.put("Command.Creator.Exists", "&cSubServers &4&l\\u00BB&c There is already a subserver with that name");
def.put("Command.Creator.Unknown-Host", "&cSubServers &4&l\\u00BB&c There is no host with that name");
@ -520,24 +521,23 @@ public class ConfigUpdater {
def.put("Interface.Server-Menu.SubServer-Incompatible", "&4Incompatible with $str$");
def.put("Interface.Server-Menu.SubServer-Unavailable", "&4Unavailable");
def.put("Interface.Server-Menu.SubServer-Disabled", "&4Disabled");
def.put("Interface.Server-Menu.SubServer-Invalid", "&4Cannot be managed by SubServers");
def.put("Interface.Server-Menu.No-Servers", "&c&oThere are No Servers");
def.put("Interface.Server-Menu.Host-Menu", "&b&lView Hosts");
def.put("Interface.SubServer-Admin.Title", "SubServer/$str$");
def.put("Interface.SubServer-Admin.Start", "&aStart SubServer");
def.put("Interface.SubServer-Admin.Start.Title", "&aStarting SubServer");
def.put("Interface.SubServer-Admin.Stop", "&cStop SubServer");
def.put("Interface.SubServer-Admin.Stop.Title", "&cStopping $str$");
def.put("Interface.SubServer-Admin.Terminate", "&4Terminate SubServer");
def.put("Interface.SubServer-Admin.Terminate.Title", "&cTerminating $str$");
def.put("Interface.SubServer-Admin.Command", "&bSend a Command to the SubServer");
def.put("Interface.SubServer-Admin.Command.Title", "&eSubServers\\n&6Enter a Command to send via Chat");
def.put("Interface.SubServer-Admin.Command.Message", "&eSubServers &6&l\\u00BB&e Enter a Command to send via Chat");
def.put("Interface.SubServer-Admin.Update", "&eUpdate SubServer");
def.put("Interface.SubServer-Admin.Update.Title", "&eSubServers\\n&6Enter a Server Version to update to");
def.put("Interface.SubServer-Admin.Update.Message", "&eSubServers &6&l\\u00BB&e Enter a Server Version to update to via Chat");
def.put("Interface.SubServer-Admin.Plugins", "&bPlugins...");
def.put("Interface.SubServer-Plugin.Title", "SubServer/$str$/Plugins");
def.put("Interface.Server-Admin.Title", "Server/$str$");
def.put("Interface.Server-Admin.Start", "&aStart SubServer");
def.put("Interface.Server-Admin.Start.Title", "&aStarting SubServer");
def.put("Interface.Server-Admin.Stop", "&cStop SubServer");
def.put("Interface.Server-Admin.Stop.Title", "&cStopping $str$");
def.put("Interface.Server-Admin.Terminate", "&4Terminate SubServer");
def.put("Interface.Server-Admin.Terminate.Title", "&cTerminating $str$");
def.put("Interface.Server-Admin.Command", "&bSend a Command to the Server");
def.put("Interface.Server-Admin.Command.Title", "&eSubServers\\n&6Enter a Command to send via Chat");
def.put("Interface.Server-Admin.Command.Message", "&eSubServers &6&l\\u00BB&e Enter a Command to send via Chat");
def.put("Interface.Server-Admin.Update", "&eUpdate SubServer");
def.put("Interface.Server-Admin.Update.Title", "&eSubServers\\n&6Enter a Server Version to update to");
def.put("Interface.Server-Admin.Update.Message", "&eSubServers &6&l\\u00BB&e Enter a Server Version to update to via Chat");
def.put("Interface.Server-Admin.Plugins", "&bPlugins...");
def.put("Interface.SubServer-Plugin.Title", "Server/$str$/Plugins");
def.put("Interface.SubServer-Plugin.No-Plugins", "&c&oThere are No Plugins Available");
YAMLSection lang = new YAMLSection();

View File

@ -51,27 +51,28 @@ public class PacketCommandServer implements PacketObjectIn<Integer>, PacketObjec
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
UUID tracker = (data.contains(0x0000)?data.getUUID(0x0000):null);
UUID tracker = (data.contains(0x0000)?data.getUUID(0x0000):null);
try {
String server = data.getString(0x0001);
String command = data.getString(0x0002);
UUID player = (data.contains(0x0003)?data.getUUID(0x0003):null);
UUID player = (data.contains(0x0003)?data.getUUID(0x0003):null);
UUID target = (data.contains(0x0004)?data.getUUID(0x0004):null);
Map<String, Server> servers = plugin.api.getServers();
if (!server.equals("*") && !servers.keySet().contains(server.toLowerCase())) {
client.sendPacket(new PacketCommandServer(3, tracker));
} else if (!server.equals("*") && !(servers.get(server.toLowerCase()) instanceof SubServer)) {
} else if (!server.equals("*") && !(target == null && servers.get(server.toLowerCase()) instanceof SubServer) && servers.get(server.toLowerCase()).getSubData()[0] == null) {
client.sendPacket(new PacketCommandServer(4, tracker));
} else if (!server.equals("*") && !((SubServer) servers.get(server.toLowerCase())).isRunning()) {
} else if (!server.equals("*") && servers.get(server.toLowerCase()) instanceof SubServer && !((SubServer) servers.get(server.toLowerCase())).isRunning()) {
client.sendPacket(new PacketCommandServer(5, tracker));
} else {
if (server.equals("*")) {
boolean sent = false;
for (Server next : servers.values()) {
if (next instanceof SubServer && ((SubServer) next).isRunning()) {
if (((SubServer) next).command(player, command)) {
sent = true;
}
if (target == null) {
sent |= next.command(player, command);
} else {
sent |= next.command(player, target, command);
}
}
if (sent) {
@ -80,10 +81,10 @@ public class PacketCommandServer implements PacketObjectIn<Integer>, PacketObjec
client.sendPacket(new PacketCommandServer(1, tracker));
}
} else {
if (((SubServer) servers.get(server.toLowerCase())).command(player, command)) {
client.sendPacket(new PacketCommandServer(0, tracker));
if (target == null) {
client.sendPacket(new PacketCommandServer((servers.get(server.toLowerCase()).command(player, command))? 0 : 1, tracker));
} else {
client.sendPacket(new PacketCommandServer(1, tracker));
client.sendPacket(new PacketCommandServer((servers.get(server.toLowerCase()).command(player, target, command))? 0 : 1, tracker));
}
}
}

View File

@ -60,7 +60,7 @@ public class PacketExAddServer implements PacketObjectIn<Integer>, PacketObjectO
data.set(0x0005, directory);
data.set(0x0006, executable);
data.set(0x0007, stopcmd);
if (running != null) data.set(0x0008, running.toString());
if (running != null) data.set(0x0008, running);
return data;
}

View File

@ -0,0 +1,62 @@
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 java.util.HashMap;
import java.util.UUID;
import java.util.function.Consumer;
/**
* External Player Control Packet
*/
public class PacketExControlPlayer implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private static HashMap<UUID, Consumer<ObjectMap<Integer>>[]> callbacks = new HashMap<UUID, Consumer<ObjectMap<Integer>>[]>();
private String command;
private UUID target;
private UUID tracker;
/**
* New PacketExControlPlayer (In)
*/
public PacketExControlPlayer() {}
/**
* New PacketExControlPlayer (Out)
*
* @param target Target Player
* @param command Command to send
* @param callback Callbacks
*/
@SafeVarargs
public PacketExControlPlayer(UUID target, String command, Consumer<ObjectMap<Integer>>... callback) {
Util.nullpo(command, callback);
this.target = target;
this.command = command;
this.tracker = Util.getNew(callbacks.keySet(), UUID::randomUUID);
callbacks.put(tracker, callback);
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, tracker);
data.set(0x0001, command);
if (target != null) data.set(0x0002, target);
return data;
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
for (Consumer<ObjectMap<Integer>> callback : callbacks.get(data.getUUID(0x0000))) callback.accept(data);
callbacks.remove(data.getUUID(0x0000));
}
@Override
public int version() {
return 0x0001;
}
}

View File

@ -86,7 +86,7 @@ public class PacketOutExRunEvent implements Listener, PacketObjectOut<Integer> {
public void event(SubAddHostEvent event) {
if (!event.isCancelled()) {
ObjectMap<String> args = new ObjectMap<String>();
if (event.getPlayer() != null) args.set("player", event.getPlayer().toString());
if (event.getPlayer() != null) args.set("player", event.getPlayer());
args.set("host", event.getHost().getName());
broadcast(event.getHost(), new PacketOutExRunEvent(event.getClass(), args));
}
@ -96,7 +96,7 @@ public class PacketOutExRunEvent implements Listener, PacketObjectOut<Integer> {
public void event(SubAddServerEvent event) {
if (!event.isCancelled()) {
ObjectMap<String> args = new ObjectMap<String>();
if (event.getPlayer() != null) args.set("player", event.getPlayer().toString());
if (event.getPlayer() != null) args.set("player", event.getPlayer());
if (event.getHost() != null) args.set("host", event.getHost().getName());
args.set("server", event.getServer().getName());
broadcast(event.getServer(), new PacketOutExRunEvent(event.getClass(), args));
@ -107,7 +107,7 @@ public class PacketOutExRunEvent implements Listener, PacketObjectOut<Integer> {
public void event(SubCreateEvent event) {
if (!event.isCancelled()) {
ObjectMap<String> args = new ObjectMap<String>();
if (event.getPlayer() != null) args.set("player", event.getPlayer().toString());
if (event.getPlayer() != null) args.set("player", event.getPlayer());
args.set("update", event.isUpdate());
args.set("name", event.getName());
args.set("host", event.getHost().getName());
@ -121,7 +121,7 @@ public class PacketOutExRunEvent implements Listener, PacketObjectOut<Integer> {
@EventHandler(priority = Byte.MAX_VALUE)
public void event(SubCreatedEvent event) {
ObjectMap<String> args = new ObjectMap<String>();
if (event.getPlayer() != null) args.set("player", event.getPlayer().toString());
if (event.getPlayer() != null) args.set("player", event.getPlayer());
args.set("success", event.wasSuccessful());
args.set("update", event.wasUpdate());
args.set("name", event.getName());
@ -136,9 +136,10 @@ public class PacketOutExRunEvent implements Listener, PacketObjectOut<Integer> {
public void event(SubSendCommandEvent event) {
if (!event.isCancelled()) {
ObjectMap<String> args = new ObjectMap<String>();
if (event.getPlayer() != null) args.set("player", event.getPlayer().toString());
if (event.getPlayer() != null) args.set("player", event.getPlayer());
args.set("server", event.getServer().getName());
args.set("command", event.getCommand());
if (event.getTarget() != null) args.set("target", event.getTarget());
broadcast(new PacketOutExRunEvent(event.getClass(), args));
}
}
@ -147,7 +148,7 @@ public class PacketOutExRunEvent implements Listener, PacketObjectOut<Integer> {
public void event(SubEditServerEvent event) {
if (!event.isCancelled()) {
ObjectMap<String> args = new ObjectMap<String>();
if (event.getPlayer() != null) args.set("player", event.getPlayer().toString());
if (event.getPlayer() != null) args.set("player", event.getPlayer());
args.set("server", event.getServer().getName());
args.set("edit", event.getEdit().key());
args.set("value", event.getEdit().value().asObject());
@ -159,7 +160,7 @@ public class PacketOutExRunEvent implements Listener, PacketObjectOut<Integer> {
public void event(SubStartEvent event) {
if (!event.isCancelled()) {
ObjectMap<String> args = new ObjectMap<String>();
if (event.getPlayer() != null) args.set("player", event.getPlayer().toString());
if (event.getPlayer() != null) args.set("player", event.getPlayer());
args.set("server", event.getServer().getName());
broadcast(new PacketOutExRunEvent(event.getClass(), args));
}
@ -176,7 +177,7 @@ public class PacketOutExRunEvent implements Listener, PacketObjectOut<Integer> {
public void event(SubStopEvent event) {
if (!event.isCancelled()) {
ObjectMap<String> args = new ObjectMap<String>();
if (event.getPlayer() != null) args.set("player", event.getPlayer().toString());
if (event.getPlayer() != null) args.set("player", event.getPlayer());
args.set("server", event.getServer().getName());
args.set("force", event.isForced());
broadcast(new PacketOutExRunEvent(event.getClass(), args));
@ -195,7 +196,7 @@ public class PacketOutExRunEvent implements Listener, PacketObjectOut<Integer> {
public void event(SubRemoveServerEvent event) {
if (!event.isCancelled()) {
ObjectMap<String> args = new ObjectMap<String>();
if (event.getPlayer() != null) args.set("player", event.getPlayer().toString());
if (event.getPlayer() != null) args.set("player", event.getPlayer());
if (event.getHost() != null) args.set("host", event.getHost().getName());
args.set("server", event.getServer().getName());
broadcast(event.getServer(), new PacketOutExRunEvent(event.getClass(), args));
@ -206,7 +207,7 @@ public class PacketOutExRunEvent implements Listener, PacketObjectOut<Integer> {
public void event(SubRemoveHostEvent event) {
if (!event.isCancelled()) {
ObjectMap<String> args = new ObjectMap<String>();
if (event.getPlayer() != null) args.set("player", event.getPlayer().toString());
if (event.getPlayer() != null) args.set("player", event.getPlayer());
args.set("host", event.getHost().getName());
broadcast(event.getHost(), new PacketOutExRunEvent(event.getClass(), args));
}

View File

@ -68,44 +68,28 @@ public class PacketStopServer implements PacketObjectIn<Integer>, PacketObjectOu
boolean sent = false;
if (force) {
for (Server server : servers.values()) {
if (server instanceof SubServer && ((SubServer) server).isRunning()) {
if (((SubServer) server).terminate(player)) {
sent = true;
}
if (server instanceof SubServer) {
sent |= ((SubServer) server).terminate(player);
}
}
if (sent) {
client.sendPacket(new PacketStopServer(0, tracker));
} else {
client.sendPacket(new PacketStopServer(1, tracker));
}
} else {
for (Server server : servers.values()) {
if (server instanceof SubServer && ((SubServer) server).isRunning()) {
if (((SubServer) server).stop(player)) {
sent = true;
}
if (server instanceof SubServer) {
sent |= ((SubServer) server).stop(player);
}
}
if (sent) {
client.sendPacket(new PacketStopServer(0, tracker));
} else {
client.sendPacket(new PacketStopServer(1, tracker));
}
}
if (sent) {
client.sendPacket(new PacketStopServer(0, tracker));
} else {
client.sendPacket(new PacketStopServer(1, tracker));
}
} else {
if (force) {
if (((SubServer) servers.get(name.toLowerCase())).terminate(player)) {
client.sendPacket(new PacketStopServer(0, tracker));
} else {
client.sendPacket(new PacketStopServer(1, tracker));
}
client.sendPacket(new PacketStopServer((((SubServer) servers.get(name.toLowerCase())).terminate(player))? 0 : 1, tracker));
} else {
if (((SubServer) servers.get(name.toLowerCase())).stop(player)) {
client.sendPacket(new PacketStopServer(0, tracker));
} else {
client.sendPacket(new PacketStopServer(1, tracker));
}
client.sendPacket(new PacketStopServer((((SubServer) servers.get(name.toLowerCase())).stop(player))? 0 : 1, tracker));
}
}
} catch (Throwable e) {

View File

@ -27,7 +27,7 @@ public class SubProtocol extends SubDataProtocol {
SubProxy plugin = SubAPI.getInstance().getInternals();
setName("SubServers 2");
setVersion(new Version("2.16a+"));
setVersion(new Version("2.18a+"));
// 00-0F: Object Link Packets
@ -129,6 +129,7 @@ public class SubProtocol extends SubDataProtocol {
registerPacket(0x0075, PacketExTransferPlayer.class);
registerPacket(0x0076, PacketExDisconnectPlayer.class);
registerPacket(0x0077, PacketExMessagePlayer.class);
registerPacket(0x0078, PacketExControlPlayer.class);
//registerPacket(0x0070, new PacketOutRunEvent());
//registerPacket(0x0071, new PacketOutReset());
@ -138,6 +139,7 @@ public class SubProtocol extends SubDataProtocol {
registerPacket(0x0075, new PacketExTransferPlayer());
registerPacket(0x0076, new PacketExDisconnectPlayer());
registerPacket(0x0077, new PacketExMessagePlayer());
registerPacket(0x0078, new PacketExControlPlayer());
}
@SuppressWarnings("deprecation")

View File

@ -464,8 +464,11 @@ public final class SubAPI implements BungeeAPI {
* @return Success Status
*/
public boolean removeServer(UUID player, String name) {
Util.nullpo(name, getServer(name));
SubRemoveServerEvent event = new SubRemoveServerEvent(player, null, getServer(name));
Util.nullpo(name);
Server server = getServer(name);
if (server == null) return true;
SubRemoveServerEvent event = new SubRemoveServerEvent(player, null, server);
plugin.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
plugin.exServers.remove(name.toLowerCase());
@ -491,8 +494,11 @@ public final class SubAPI implements BungeeAPI {
* @return Success Status
*/
public boolean forceRemoveServer(UUID player, String name) {
Util.nullpo(name, getServer(name));
SubRemoveServerEvent event = new SubRemoveServerEvent(player, null, getServer(name));
Util.nullpo(name);
Server server = getServer(name);
if (server == null) return true;
SubRemoveServerEvent event = new SubRemoveServerEvent(player, null, server);
plugin.getPluginManager().callEvent(event);
plugin.exServers.remove(name.toLowerCase());
return true;

View File

@ -523,8 +523,8 @@ public final class SubCommand extends Command implements TabExecutor {
}
} else if (args[0].equalsIgnoreCase("cmd") || args[0].equalsIgnoreCase("command")) {
if (args.length > 1) {
ServerSelection select = selectServers(sender, args, 1, true);
if (select.subservers.length > 0) {
ServerSelection select = selectServers(sender, args, 1, false);
if (select.servers.length > 0) {
if (select.args.length > 2) {
StringBuilder builder = new StringBuilder(select.args[2]);
for (int i = 3; i < select.args.length; i++) {
@ -534,21 +534,29 @@ public final class SubCommand extends Command implements TabExecutor {
int success = 0, running = 0;
String command = builder.toString();
for (SubServer server : select.subservers) {
if (!server.isRunning()) {
running++;
} else if (server.command(command)) {
success++;
for (Server server : select.servers) {
if (server instanceof SubServer) {
if (!((SubServer) server).isRunning()) {
running++;
} else if (server.command(command)) {
success++;
}
} else {
if (server.getSubData()[0] == null) {
running++;
} else if (server.command(command)) {
success++;
}
}
}
if (running > 0) sender.sendMessage("SubServers > " + running + " subserver"+((running == 1)?" was":"s were") + " offline");
if (success > 0) sender.sendMessage("SubServers > Sent command to " + success + " subserver"+((success == 1)?"":"s"));
if (running > 0) sender.sendMessage("SubServers > " + running + " server"+((running == 1)?" was":"s were") + " unavailable");
if (success > 0) sender.sendMessage("SubServers > Sent command to " + success + " server"+((success == 1)?"":"s"));
} else {
sender.sendMessage("SubServers > No command was entered");
}
}
} else {
sender.sendMessage("SubServers > Usage: " + label + " " + args[0].toLowerCase() + " <Subservers> <Command> [Args...]");
sender.sendMessage("SubServers > Usage: " + label + " " + args[0].toLowerCase() + " <Servers> <Command> [Args...]");
}
} else if (args[0].equalsIgnoreCase("sudo") || args[0].equalsIgnoreCase("screen")) {
if (plugin.canSudo) {
@ -822,7 +830,7 @@ public final class SubCommand extends Command implements TabExecutor {
" Restart Server: /sub restart <Subservers>",
" Stop Server: /sub stop <Subservers>",
" Terminate Server: /sub kill <Subservers>",
" Command Server: /sub cmd <Subservers> <Command> [Args...]",
" Command Server: /sub cmd <Servers> <Command> [Args...]",
" Sudo Server: /sub sudo <Subserver>",
" Create Server: /sub create <Name> <Host> <Template> [Version] [Port]",
" Update Server: /sub update <Subservers> [[Template] <Version>]",
@ -1002,7 +1010,8 @@ public final class SubCommand extends Command implements TabExecutor {
args[0].equals("sudo") || args[0].equals("screen")
))) {
List<String> list = new ArrayList<String>();
ServerSelection select = selectServers(null, args, 1, true);
boolean mode = !args[0].equals("cmd") && !args[0].equals("command");
ServerSelection select = selectServers(null, args, 1, mode);
if (select.last != null) {
if (last.startsWith("::")) {
Map<String, Host> hosts = plugin.api.getHosts();
@ -1027,11 +1036,11 @@ public final class SubCommand extends Command implements TabExecutor {
}
return list;
} else {
Map<String, SubServer> subservers = plugin.api.getSubServers();
if (subservers.size() > 0) {
Map<String, Server> servers = (mode)? (Map<String, Server>) (Map<String, ?>) plugin.api.getSubServers() : plugin.api.getServers();
if (servers.size() > 0) {
if (Arrays.binarySearch(select.selection, "*") < 0 && "*".startsWith(last)) list.add("*");
if (sender instanceof ProxiedPlayer && Arrays.binarySearch(select.selection, ".") < 0 && ".".startsWith(last)) list.add(".");
for (SubServer server : subservers.values()) {
for (Server server : servers.values()) {
if (Arrays.binarySearch(select.selection, server.getName().toLowerCase()) < 0 && server.getName().toLowerCase().startsWith(last)) list.add(Last + server.getName().substring(last.length()));
}
}

View File

@ -155,7 +155,7 @@ public final class SubProxy extends BungeeCommon implements Listener {
Logger.get("SubServers").info("Created ./SubServers/Templates/Sponge");
} else {
long stamp = Math.round(Math.random() * 100000);
Version tv1 = new Version("2.16a+");
Version tv1 = new Version("2.18a+");
Version tv2 = new Version("2.18a+");
if (new File(dir, "Templates/Vanilla/template.yml").exists() && ((new YAMLConfig(new File(dir, "Templates/Vanilla/template.yml"))).get().getVersion("Version", tv2)).compareTo(tv2) != 0) {

View File

@ -15,18 +15,22 @@ public class SubSendCommandEvent extends Event implements SubEvent {
private UUID player;
private String server;
private String command;
private UUID target;
/**
* Server Command Event
*
* @param player Player Commanding Server
* @param server Server being Commanded
* @param player Player Commanding
* @param server Target Server
* @param command Command to Send
* @param target Player that will send
*/
public SubSendCommandEvent(UUID player, String server, String command) {
public SubSendCommandEvent(UUID player, String server, String command, UUID target) {
Util.nullpo(server, command);
this.player = player;
this.server = server;
this.command = command;
this.target = target;
}
/**
@ -52,6 +56,15 @@ public class SubSendCommandEvent extends Event implements SubEvent {
return command;
}
/**
* Gets the Player that will be forced to send the Command
*
* @return Target Player or null if Console
*/
public UUID getTarget() {
return target;
}
@Override
public HandlerList getHandlers() {
return handlers;

View File

@ -11,6 +11,7 @@ import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubServers.Client.Bukkit.Network.Packet.PacketInExRunEvent;
import net.ME1312.SubServers.Client.Bukkit.SubPlugin;
import net.ME1312.SubServers.Client.Common.Network.API.Host;
import net.ME1312.SubServers.Client.Common.Network.API.Server;
import net.ME1312.SubServers.Client.Common.Network.API.SubServer;
import net.ME1312.SubServers.Client.Common.Network.Packet.PacketCreateServer;
import net.ME1312.SubServers.Client.Common.Network.Packet.PacketUpdateServer;
@ -286,15 +287,15 @@ public class DefaultUIHandler implements UIHandler, Listener {
} else if (item.equals(plugin.api.getLang("SubServers", "Interface.Generic.Back"))) {
player.closeInventory();
gui.back();
} else if ((item.length() != 0 && !item.equals(ChatColor.RESET.toString())) && !item.startsWith(ChatColor.WHITE.toString()) && !item.equals(plugin.api.getLang("SubServers", "Interface.Server-Menu.No-Servers"))) {
} else if ((item.length() != 0 && !item.equals(ChatColor.RESET.toString())) && !item.equals(plugin.api.getLang("SubServers", "Interface.Server-Menu.No-Servers"))) {
player.closeInventory();
String obj;
if (event.getCurrentItem().getItemMeta().getLore() != null && event.getCurrentItem().getItemMeta().getLore().size() > 0 && event.getCurrentItem().getItemMeta().getLore().get(0).startsWith(ChatColor.GRAY.toString())) {
if (event.getCurrentItem().getItemMeta().getLore() != null && event.getCurrentItem().getItemMeta().getLore().size() > 0 && event.getCurrentItem().getItemMeta().getLore().get((item.startsWith(ChatColor.WHITE.toString()))? 1 : 0).startsWith(ChatColor.GRAY.toString())) {
obj = ChatColor.stripColor(event.getCurrentItem().getItemMeta().getLore().get(0));
} else {
obj = ChatColor.stripColor(item);
}
gui.subserverAdmin(obj);
gui.serverAdmin(obj);
}
}
} else if (title.startsWith(plugin.api.getLang("SubServers", "Interface.Host-Admin.Title").split("\\$str\\$")[0]) && // Host Admin
@ -319,47 +320,47 @@ public class DefaultUIHandler implements UIHandler, Listener {
gui.hostPlugin(1, ((Host) gui.lastVisitedObjects[0]).getName());
}
}
} else if (title.startsWith(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Title").split("\\$str\\$")[0]) && // SubServer Admin
(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Title").split("\\$str\\$").length == 1 ||
title.endsWith(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Title").split("\\$str\\$")[1]))) {
} else if (title.startsWith(plugin.api.getLang("SubServers", "Interface.Server-Admin.Title").split("\\$str\\$")[0]) && // SubServer Admin
(plugin.api.getLang("SubServers", "Interface.Server-Admin.Title").split("\\$str\\$").length == 1 ||
title.endsWith(plugin.api.getLang("SubServers", "Interface.Server-Admin.Title").split("\\$str\\$")[1]))) {
if (event.getCurrentItem() != null && event.getCurrentItem().getType() != Material.AIR && event.getCurrentItem().hasItemMeta()) {
String item = event.getCurrentItem().getItemMeta().getDisplayName();
if (item.equals(plugin.api.getLang("SubServers", "Interface.Generic.Back"))) {
player.closeInventory();
gui.back();
} else if (item.equals(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Update"))) {
} else if (item.equals(plugin.api.getLang("SubServers", "Interface.Server-Admin.Update"))) {
player.closeInventory();
if (permits((SubServer) gui.lastVisitedObjects[0], player, "subservers.subserver.%.*", "subservers.subserver.%.update")) {
if (!gui.sendTitle(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Update.Title"), 4 * 20))
player.sendMessage(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Update.Message"));
if (permits((Server) gui.lastVisitedObjects[0], player, "subservers.subserver.%.*", "subservers.subserver.%.update")) {
if (!gui.sendTitle(plugin.api.getLang("SubServers", "Interface.Server-Admin.Update.Title"), 4 * 20))
player.sendMessage(plugin.api.getLang("SubServers", "Interface.Server-Admin.Update.Message"));
input.put(player.getUniqueId(), m -> {
gui.setDownloading(plugin.api.getLang("SubServers", "Interface.Generic.Downloading.Response"));
((SubDataClient) plugin.api.getSubDataNetwork()[0]).sendPacket(new PacketUpdateServer(player.getUniqueId(), ((SubServer) gui.lastVisitedObjects[0]).getName(),
((SubDataClient) plugin.api.getSubDataNetwork()[0]).sendPacket(new PacketUpdateServer(player.getUniqueId(), ((Server) gui.lastVisitedObjects[0]).getName(),
null, (m.getString("message").length() == 0 || m.getString("message").equals("/"))?null:new Version((m.getString("message").startsWith("/"))?m.getString("message").substring(1):m.getString("message")), data -> {
gui.reopen();
}));
});
} else gui.reopen();
} else if (item.equals(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Start"))) {
} else if (item.equals(plugin.api.getLang("SubServers", "Interface.Server-Admin.Start"))) {
player.closeInventory();
if (permits((SubServer) gui.lastVisitedObjects[0], player, "subservers.subserver.%.*", "subservers.subserver.%.start")) {
if (permits((Server) gui.lastVisitedObjects[0], player, "subservers.subserver.%.*", "subservers.subserver.%.start")) {
gui.setDownloading(plugin.api.getLang("SubServers", "Interface.Generic.Downloading.Response"));
((SubServer) gui.lastVisitedObjects[0]).start(player.getUniqueId(), response -> {
gui.setDownloading(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Start.Title"));
gui.setDownloading(plugin.api.getLang("SubServers", "Interface.Server-Admin.Start.Title"));
Bukkit.getScheduler().runTaskLater(plugin, gui::reopen, 30);
});
} else gui.reopen();
} else if (item.equals(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Stop"))) {
} else if (item.equals(plugin.api.getLang("SubServers", "Interface.Server-Admin.Stop"))) {
player.closeInventory();
if (permits((SubServer) gui.lastVisitedObjects[0], player, "subservers.subserver.%.*", "subservers.subserver.%.stop")) {
if (permits((Server) gui.lastVisitedObjects[0], player, "subservers.subserver.%.*", "subservers.subserver.%.stop")) {
gui.setDownloading(plugin.api.getLang("SubServers", "Interface.Generic.Downloading.Response"));
final Value<Boolean> listening = new Container<Boolean>(true);
PacketInExRunEvent.callback("SubStoppedEvent", new Consumer<ObjectMap<String>>() {
@Override
public void accept(ObjectMap<String> json) {
try {
if (listening.value()) if (!json.getString("server").equalsIgnoreCase(((SubServer) gui.lastVisitedObjects[0]).getName())) {
if (listening.value()) if (!json.getString("server").equalsIgnoreCase(((Server) gui.lastVisitedObjects[0]).getName())) {
PacketInExRunEvent.callback("SubStoppedEvent", this);
} else {
Bukkit.getScheduler().runTaskLater(plugin, gui::reopen, 5);
@ -371,19 +372,19 @@ public class DefaultUIHandler implements UIHandler, Listener {
if (response != 0) {
gui.reopen();
listening.value(false);
} else gui.setDownloading(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Stop.Title").replace("$str$", ((SubServer) gui.lastVisitedObjects[0]).getName()));
} else gui.setDownloading(plugin.api.getLang("SubServers", "Interface.Server-Admin.Stop.Title").replace("$str$", ((Server) gui.lastVisitedObjects[0]).getName()));
});
} else gui.reopen();
} else if (item.equals(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Terminate"))) {
} else if (item.equals(plugin.api.getLang("SubServers", "Interface.Server-Admin.Terminate"))) {
player.closeInventory();
if (permits((SubServer) gui.lastVisitedObjects[0], player, "subservers.subserver.%.*", "subservers.subserver.%.terminate")) {
if (permits((Server) gui.lastVisitedObjects[0], player, "subservers.subserver.%.*", "subservers.subserver.%.terminate")) {
gui.setDownloading(plugin.api.getLang("SubServers", "Interface.Generic.Downloading.Response"));
final Value<Boolean> listening = new Container<Boolean>(true);
PacketInExRunEvent.callback("SubStoppedEvent", new Consumer<ObjectMap<String>>() {
@Override
public void accept(ObjectMap<String> json) {
try {
if (listening.value()) if (!json.getString("server").equalsIgnoreCase(((SubServer) gui.lastVisitedObjects[0]).getName())) {
if (listening.value()) if (!json.getString("server").equalsIgnoreCase(((Server) gui.lastVisitedObjects[0]).getName())) {
PacketInExRunEvent.callback("SubStoppedEvent", this);
} else {
gui.reopen();
@ -395,24 +396,24 @@ public class DefaultUIHandler implements UIHandler, Listener {
if (response != 0) {
gui.reopen();
listening.value(false);
} else gui.setDownloading(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Terminate.Title").replace("$str$", ((SubServer) gui.lastVisitedObjects[0]).getName()));
} else gui.setDownloading(plugin.api.getLang("SubServers", "Interface.Server-Admin.Terminate.Title").replace("$str$", ((Server) gui.lastVisitedObjects[0]).getName()));
});
} else gui.reopen();
} else if (item.equals(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Command"))) {
} else if (item.equals(plugin.api.getLang("SubServers", "Interface.Server-Admin.Command"))) {
player.closeInventory();
if (permits((SubServer) gui.lastVisitedObjects[0], player, "subservers.subserver.%.*", "subservers.subserver.%.command")) {
if (!gui.sendTitle(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Command.Title"), 4 * 20))
player.sendMessage(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Command.Message"));
if (permits((Server) gui.lastVisitedObjects[0], player, "subservers.subserver.%.*", "subservers.subserver.%.command")) {
if (!gui.sendTitle(plugin.api.getLang("SubServers", "Interface.Server-Admin.Command.Title"), 4 * 20))
player.sendMessage(plugin.api.getLang("SubServers", "Interface.Server-Admin.Command.Message"));
input.put(player.getUniqueId(), m -> {
gui.setDownloading(plugin.api.getLang("SubServers", "Interface.Generic.Downloading.Response"));
((SubServer) gui.lastVisitedObjects[0]).command(player.getUniqueId(), (m.getString("message").startsWith("/"))?m.getString("message").substring(1):m.getString("message"), response -> {
((Server) gui.lastVisitedObjects[0]).command(player.getUniqueId(), (m.getString("message").startsWith("/"))?m.getString("message").substring(1):m.getString("message"), response -> {
gui.reopen();
});
});
} else gui.reopen();
} else if (item.equals(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Plugins"))) {
} else if (item.equals(plugin.api.getLang("SubServers", "Interface.Server-Admin.Plugins"))) {
player.closeInventory();
gui.subserverPlugin(1, ((SubServer) gui.lastVisitedObjects[0]).getName());
gui.serverPlugin(1, ((Server) gui.lastVisitedObjects[0]).getName());
}
}
} else if (title.startsWith(plugin.api.getLang("SubServers", "Interface.SubServer-Plugin.Title").split("\\$str\\$")[0]) && // SubServer Plugin
@ -422,24 +423,24 @@ public class DefaultUIHandler implements UIHandler, Listener {
String item = event.getCurrentItem().getItemMeta().getDisplayName();
if (item.equals(plugin.api.getLang("SubServers", "Interface.Generic.Back-Arrow"))) {
player.closeInventory();
gui.subserverPlugin(gui.lastPage - 1, ((SubServer) gui.lastVisitedObjects[0]).getName());
gui.serverPlugin(gui.lastPage - 1, ((Server) gui.lastVisitedObjects[0]).getName());
} else if (item.equals(plugin.api.getLang("SubServers", "Interface.Generic.Next-Arrow"))) {
player.closeInventory();
gui.subserverPlugin(gui.lastPage + 1, ((SubServer) gui.lastVisitedObjects[0]).getName());
gui.serverPlugin(gui.lastPage + 1, ((Server) gui.lastVisitedObjects[0]).getName());
} else if (item.equals(plugin.api.getLang("SubServers", "Interface.Generic.Back"))) {
player.closeInventory();
gui.back();
} else if ((item.length() != 0 && !item.equals(ChatColor.RESET.toString())) && !item.equals(plugin.api.getLang("SubServers", "Interface.SubServer-Plugin.No-Plugins"))) {
player.closeInventory();
Value<PluginRenderer<SubServer>> plugin = new Container<PluginRenderer<SubServer>>(null);
for (PluginRenderer<SubServer> renderer : DefaultUIRenderer.subserverPlugins.values()) {
Value<PluginRenderer<Server>> plugin = new Container<PluginRenderer<Server>>(null);
for (PluginRenderer<Server> renderer : DefaultUIRenderer.serverPlugins.values()) {
if (item.equals(renderer.getIcon().getItemMeta().getDisplayName())) plugin.value(renderer);
}
if (plugin.value() == null) {
gui.reopen();
} else {
gui.setDownloading(ChatColor.stripColor(this.plugin.api.getLang("SubServers", "Interface.SubServer-Plugin.Title").replace("$str$", ((SubServer) gui.lastVisitedObjects[0]).getName())));
this.plugin.api.getSubServer(((SubServer) gui.lastVisitedObjects[0]).getName(), subserver -> {
gui.setDownloading(ChatColor.stripColor(this.plugin.api.getLang("SubServers", "Interface.SubServer-Plugin.Title").replace("$str$", ((Server) gui.lastVisitedObjects[0]).getName())));
this.plugin.api.getSubServer(((Server) gui.lastVisitedObjects[0]).getName(), subserver -> {
if (subserver != null) {
gui.setDownloading(null);
plugin.value().open(player, subserver);

View File

@ -18,6 +18,7 @@ import org.bukkit.inventory.meta.ItemMeta;
import java.text.DecimalFormat;
import java.util.*;
import java.util.function.BiConsumer;
import static net.ME1312.SubServers.Client.Bukkit.Library.ObjectPermission.permits;
@ -290,7 +291,7 @@ public class DefaultUIRenderer extends UIRenderer {
inv.setItem(15, block);
inv.setItem(16, block);
if (!host.isAvailable() || !host.isEnabled() || hostPlugins.size() <= 0) {
if (hostPlugins.size() <= 0) {
block = div;
} else {
block = color(11);
@ -595,7 +596,7 @@ public class DefaultUIRenderer extends UIRenderer {
lastVisitedObjects[0] = host;
lastPage = page;
List<String> renderers = new LinkedList<String>();
for (String renderer : renderers) {
for (String renderer : hostPlugins.keySet()) {
if (hostPlugins.get(renderer).isEnabled(host)) renderers.add(renderer);
}
Collections.sort(renderers);
@ -881,7 +882,6 @@ public class DefaultUIRenderer extends UIRenderer {
lore.add(ChatColor.GRAY + server.getName());
lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-External"));
lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(server.getRemotePlayers().size())));
lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Invalid"));
lore.add(ChatColor.WHITE + ((plugin.config.get().getMap("Settings").getBoolean("Show-Addresses", false))?server.getAddress().getAddress().getHostAddress()+':':"") + server.getAddress().getPort());
blockMeta.setLore(lore);
} else if (((SubServer) server).isRunning()) {
@ -1016,229 +1016,250 @@ public class DefaultUIRenderer extends UIRenderer {
}
}
public void subserverAdmin(final String name) {
setDownloading(ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Title").replace("$str$", name)));
plugin.api.getSubServer(name, subserver -> {
windowHistory.add(() -> subserverAdmin(name));
if (subserver == null) {
if (hasHistory()) back();
} else subserver.getHost(host -> {
if (host == null) {
if (hasHistory()) back();
public void serverAdmin(final String name) {
setDownloading(ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.Server-Admin.Title").replace("$str$", name)));
BiConsumer<Server, Host> renderer = (server, host) -> {
setDownloading(null);
lastVisitedObjects[0] = server;
ItemStack block;
ItemMeta blockMeta;
ItemStack div = color(15);
ItemMeta divMeta = div.getItemMeta();
divMeta.setDisplayName(ChatColor.RESET.toString());
div.setItemMeta(divMeta);
Inventory inv = Bukkit.createInventory(null, 36, plugin.api.getLang("SubServers", "Interface.Server-Admin.Title").replace("$str$", server.getDisplayName()));
SubServer subserver = (host != null)? (SubServer) server : null;
int i = 0;
while (i < inv.getSize()) {
inv.setItem(i, div);
i++;
}
i = 0;
Player player = Bukkit.getPlayer(this.player);
if (host == null || ((SubServer) server).isRunning()) {
if (host == null || !permits(server, player, "subservers.subserver.%.*", "subservers.subserver.%.terminate")) {
block = color(7);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.Server-Admin.Terminate")));
if (host != null) blockMeta.setLore(Arrays.asList(plugin.api.getLang("SubServers", "Interface.Generic.Invalid-Permission").replace("$str$", "subservers.subserver.terminate." + name.toLowerCase())));
} else {
setDownloading(null);
lastVisitedObjects[0] = subserver;
ItemStack block;
ItemMeta blockMeta;
ItemStack div = color(15);
ItemMeta divMeta = div.getItemMeta();
divMeta.setDisplayName(ChatColor.RESET.toString());
div.setItemMeta(divMeta);
block = color(14);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.Server-Admin.Terminate"));
}
Inventory inv = Bukkit.createInventory(null, 36, plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Title").replace("$str$", subserver.getDisplayName()));
block.setItemMeta(blockMeta);
inv.setItem(1, block);
inv.setItem(10, block);
int i = 0;
while (i < inv.getSize()) {
inv.setItem(i, div);
i++;
}
i = 0;
if (host == null || !permits(server, player, "subservers.subserver.%.*", "subservers.subserver.%.stop")) {
block = color(7);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.Server-Admin.Stop")));
if (host != null) blockMeta.setLore(Arrays.asList(plugin.api.getLang("SubServers", "Interface.Generic.Invalid-Permission").replace("$str$", "subservers.subserver.stop." + name.toLowerCase())));
} else {
block = color(2);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.Server-Admin.Stop"));
}
block.setItemMeta(blockMeta);
inv.setItem(2, block);
inv.setItem(3, block);
inv.setItem(11, block);
inv.setItem(12, block);
Player player = Bukkit.getPlayer(this.player);
if (subserver.isRunning()) {
if (!permits(subserver, player, "subservers.subserver.%.*", "subservers.subserver.%.terminate")) {
block = color(7);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Terminate")));
blockMeta.setLore(Arrays.asList(plugin.api.getLang("SubServers", "Interface.Generic.Invalid-Permission").replace("$str$", "subservers.subserver.terminate." + name.toLowerCase())));
} else {
block = color(14);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Terminate"));
}
if ((host == null && server.getSubData()[0] == null) || !permits(server, player, "subservers.subserver.%.*", "subservers.subserver.%.command")) {
block = color(7);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.Server-Admin.Command")));
if (host != null) blockMeta.setLore(Arrays.asList(plugin.api.getLang("SubServers", "Interface.Generic.Invalid-Permission").replace("$str$", "subservers.subserver.command." + name.toLowerCase())));
} else {
block = color(3);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.Server-Admin.Command"));
}
block.setItemMeta(blockMeta);
inv.setItem(5, block);
inv.setItem(6, block);
inv.setItem(7, block);
inv.setItem(14, block);
inv.setItem(15, block);
inv.setItem(16, block);
} else {
if (!permits(subserver, player, "subservers.subserver.%.*", "subservers.subserver.%.start")) {
block = color(7);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.Server-Admin.Start")));
blockMeta.setLore(Arrays.asList(plugin.api.getLang("SubServers", "Interface.Generic.Invalid-Permission").replace("$str$", "subservers.subserver.start." + name.toLowerCase())));
} else if (!host.isAvailable() || !host.isEnabled() || !subserver.isAvailable() || !subserver.isEnabled() || subserver.getCurrentIncompatibilities().size() != 0) {
block = color(7);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.Server-Admin.Start")));
} else {
block = color(5);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.Server-Admin.Start"));
}
block.setItemMeta(blockMeta);
SubCreator.ServerTemplate template;
if (subserver.getTemplate() == null || !(template = host.getCreator().getTemplate(subserver.getTemplate())).isEnabled() || !template.canUpdate()) {
inv.setItem(3, block);
inv.setItem(4, block);
inv.setItem(5, block);
inv.setItem(12, block);
inv.setItem(13, block);
inv.setItem(14, block);
} else {
inv.setItem(1, block);
inv.setItem(2, block);
inv.setItem(3, block);
inv.setItem(10, block);
inv.setItem(11, block);
inv.setItem(12, block);
block.setItemMeta(blockMeta);
inv.setItem(1, block);
inv.setItem(10, block);
if (!permits(subserver, player, "subservers.subserver.%.*", "subservers.subserver.%.stop")) {
block = color(7);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Stop")));
blockMeta.setLore(Arrays.asList(plugin.api.getLang("SubServers", "Interface.Generic.Invalid-Permission").replace("$str$", "subservers.subserver.stop." + name.toLowerCase())));
} else {
block = color(2);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Stop"));
}
block.setItemMeta(blockMeta);
inv.setItem(2, block);
inv.setItem(3, block);
inv.setItem(11, block);
inv.setItem(12, block);
if (!permits(subserver, player, "subservers.subserver.%.*", "subservers.subserver.%.command")) {
block = color(7);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Command")));
blockMeta.setLore(Arrays.asList(plugin.api.getLang("SubServers", "Interface.Generic.Invalid-Permission").replace("$str$", "subservers.subserver.command." + name.toLowerCase())));
} else {
block = color(3);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Command"));
}
block.setItemMeta(blockMeta);
inv.setItem(5, block);
inv.setItem(6, block);
inv.setItem(7, block);
inv.setItem(14, block);
inv.setItem(15, block);
inv.setItem(16, block);
} else {
if (!permits(subserver, player, "subservers.subserver.%.*", "subservers.subserver.%.start")) {
block = color(7);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Start")));
blockMeta.setLore(Arrays.asList(plugin.api.getLang("SubServers", "Interface.Generic.Invalid-Permission").replace("$str$", "subservers.subserver.start." + name.toLowerCase())));
} else if (!host.isAvailable() || !host.isEnabled() || !subserver.isAvailable() || !subserver.isEnabled() || subserver.getCurrentIncompatibilities().size() != 0) {
block = color(7);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Start")));
} else {
block = color(5);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Start"));
}
block.setItemMeta(blockMeta);
SubCreator.ServerTemplate template;
if (subserver.getTemplate() == null || !(template = host.getCreator().getTemplate(subserver.getTemplate())).isEnabled() || !template.canUpdate()) {
inv.setItem(3, block);
inv.setItem(4, block);
inv.setItem(5, block);
inv.setItem(12, block);
inv.setItem(13, block);
inv.setItem(14, block);
} else {
inv.setItem(1, block);
inv.setItem(2, block);
inv.setItem(3, block);
inv.setItem(10, block);
inv.setItem(11, block);
inv.setItem(12, block);
if (!permits(subserver, player, "subservers.subserver.%.*", "subservers.subserver.%.update")) {
block = color(7);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Update")));
blockMeta.setLore(Arrays.asList(plugin.api.getLang("SubServers", "Interface.Generic.Invalid-Permission").replace("$str$", "subservers.subserver.update." + name.toLowerCase())));
} else if (!host.isAvailable() || !host.isEnabled() || !subserver.isAvailable() || subserver.getCurrentIncompatibilities().size() != 0) {
block = color(7);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Update")));
} else {
block = color(4);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Update"));
}
block.setItemMeta(blockMeta);
inv.setItem(5, block);
inv.setItem(6, block);
inv.setItem(7, block);
inv.setItem(14, block);
inv.setItem(15, block);
inv.setItem(16, block);
}
}
if (!host.isAvailable() || !host.isEnabled() || !subserver.isAvailable() || !subserver.isEnabled() || subserverPlugins.size() <= 0) {
block = div;
} else {
block = color(11);
if (!permits(subserver, player, "subservers.subserver.%.*", "subservers.subserver.%.update")) {
block = color(7);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Plugins"));
block.setItemMeta(blockMeta);
}
inv.setItem(27, block);
inv.setItem(28, block);
if (subserver.isRunning()) {
int blocktype = (subserver.getStopAction() == SubServer.StopAction.REMOVE_SERVER || subserver.getStopAction() == SubServer.StopAction.RECYCLE_SERVER || subserver.getStopAction() == SubServer.StopAction.DELETE_SERVER)? 11 : 5;
block = color(blocktype);
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.Server-Admin.Update")));
blockMeta.setLore(Arrays.asList(plugin.api.getLang("SubServers", "Interface.Generic.Invalid-Permission").replace("$str$", "subservers.subserver.update." + name.toLowerCase())));
} else if (!host.isAvailable() || !host.isEnabled() || !subserver.isAvailable() || subserver.getCurrentIncompatibilities().size() != 0) {
block = color(7);
blockMeta = block.getItemMeta();
LinkedList<String> lore = new LinkedList<String>();
if (!subserver.getName().equals(subserver.getDisplayName()))
lore.add(ChatColor.GRAY + subserver.getName());
if (subserver.getStopAction() != SubServer.StopAction.REMOVE_SERVER || subserver.getStopAction() != SubServer.StopAction.RECYCLE_SERVER || subserver.getStopAction() != SubServer.StopAction.DELETE_SERVER) {
blockMeta.setDisplayName(ChatColor.AQUA + subserver.getDisplayName());
lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Temporary"));
} else blockMeta.setDisplayName(ChatColor.GREEN + subserver.getDisplayName());
lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(subserver.getRemotePlayers().size())));
lore.add(ChatColor.WHITE + ((plugin.config.get().getMap("Settings").getBoolean("Show-Addresses", false))?subserver.getAddress().getAddress().getHostAddress()+':':"") + subserver.getAddress().getPort());
blockMeta.setLore(lore);
} else if (subserver.isAvailable() && subserver.isEnabled() && subserver.getCurrentIncompatibilities().size() == 0) {
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.Server-Admin.Update")));
} else {
block = color(4);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.YELLOW + subserver.getDisplayName());
LinkedList<String> lore = new LinkedList<String>();
if (!subserver.getName().equals(subserver.getDisplayName()))
lore.add(ChatColor.GRAY + subserver.getName());
lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Offline"));
lore.add(ChatColor.WHITE + ((plugin.config.get().getMap("Settings").getBoolean("Show-Addresses", false))?subserver.getAddress().getAddress().getHostAddress()+':':"") + subserver.getAddress().getPort());
blockMeta.setLore(lore);
} else {
block = color(14);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.RED + subserver.getDisplayName());
LinkedList<String> lore = new LinkedList<String>();
if (!subserver.getName().equals(subserver.getDisplayName()))
lore.add(ChatColor.GRAY + subserver.getName());
if (subserver.getCurrentIncompatibilities().size() != 0) {
String list = "";
for (String other : subserver.getCurrentIncompatibilities()) {
if (list.length() != 0) list += ", ";
list += other;
}
lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Incompatible").replace("$str$", list));
}
if (!subserver.isAvailable() || !subserver.isEnabled()) lore.add(plugin.api.getLang("SubServers", (!subserver.isAvailable())?"Interface.Server-Menu.SubServer-Unavailable":"Interface.Server-Menu.SubServer-Disabled"));
lore.add(ChatColor.WHITE + ((plugin.config.get().getMap("Settings").getBoolean("Show-Addresses", false))?subserver.getAddress().getAddress().getHostAddress()+':':"") + subserver.getAddress().getPort());
blockMeta.setLore(lore);
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.Server-Admin.Update"));
}
block.setItemMeta(blockMeta);
inv.setItem(30, block);
inv.setItem(31, block);
inv.setItem(32, block);
if (hasHistory()) {
block = color(14);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.Generic.Back"));
block.setItemMeta(blockMeta);
inv.setItem(34, block);
inv.setItem(35, block);
}
player.openInventory(inv);
open = true;
inv.setItem(5, block);
inv.setItem(6, block);
inv.setItem(7, block);
inv.setItem(14, block);
inv.setItem(15, block);
inv.setItem(16, block);
}
});
});
}
if (serverPlugins.size() > 0) {
block = color(11);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.Server-Admin.Plugins"));
block.setItemMeta(blockMeta);
} else {
block = div;
}
inv.setItem(27, block);
inv.setItem(28, block);
if (host == null) {
block = color(0);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.WHITE + server.getDisplayName());
LinkedList<String> lore = new LinkedList<String>();
if (!server.getName().equals(server.getDisplayName()))
lore.add(ChatColor.GRAY + server.getName());
lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-External"));
lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(server.getRemotePlayers().size())));
lore.add(ChatColor.WHITE + ((plugin.config.get().getMap("Settings").getBoolean("Show-Addresses", false))?server.getAddress().getAddress().getHostAddress()+':':"") + server.getAddress().getPort());
blockMeta.setLore(lore);
} else if (subserver.isRunning()) {
int blocktype = (subserver.getStopAction() == SubServer.StopAction.REMOVE_SERVER || subserver.getStopAction() == SubServer.StopAction.RECYCLE_SERVER || subserver.getStopAction() == SubServer.StopAction.DELETE_SERVER)? 11 : 5;
block = color(blocktype);
blockMeta = block.getItemMeta();
LinkedList<String> lore = new LinkedList<String>();
if (!subserver.getName().equals(subserver.getDisplayName()))
lore.add(ChatColor.GRAY + subserver.getName());
if (subserver.getStopAction() == SubServer.StopAction.REMOVE_SERVER || subserver.getStopAction() == SubServer.StopAction.RECYCLE_SERVER || subserver.getStopAction() == SubServer.StopAction.DELETE_SERVER) {
blockMeta.setDisplayName(ChatColor.AQUA + subserver.getDisplayName());
lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Temporary"));
} else blockMeta.setDisplayName(ChatColor.GREEN + subserver.getDisplayName());
lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(subserver.getRemotePlayers().size())));
lore.add(ChatColor.WHITE + ((plugin.config.get().getMap("Settings").getBoolean("Show-Addresses", false))?subserver.getAddress().getAddress().getHostAddress()+':':"") + subserver.getAddress().getPort());
blockMeta.setLore(lore);
} else if (subserver.isAvailable() && subserver.isEnabled() && subserver.getCurrentIncompatibilities().size() == 0) {
block = color(4);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.YELLOW + subserver.getDisplayName());
LinkedList<String> lore = new LinkedList<String>();
if (!subserver.getName().equals(subserver.getDisplayName()))
lore.add(ChatColor.GRAY + subserver.getName());
lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Offline"));
lore.add(ChatColor.WHITE + ((plugin.config.get().getMap("Settings").getBoolean("Show-Addresses", false))?subserver.getAddress().getAddress().getHostAddress()+':':"") + subserver.getAddress().getPort());
blockMeta.setLore(lore);
} else {
block = color(14);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(ChatColor.RED + subserver.getDisplayName());
LinkedList<String> lore = new LinkedList<String>();
if (!subserver.getName().equals(subserver.getDisplayName()))
lore.add(ChatColor.GRAY + subserver.getName());
if (subserver.getCurrentIncompatibilities().size() != 0) {
String list = "";
for (String other : subserver.getCurrentIncompatibilities()) {
if (list.length() != 0) list += ", ";
list += other;
}
lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Incompatible").replace("$str$", list));
}
if (!subserver.isAvailable() || !subserver.isEnabled()) lore.add(plugin.api.getLang("SubServers", (!subserver.isAvailable())?"Interface.Server-Menu.SubServer-Unavailable":"Interface.Server-Menu.SubServer-Disabled"));
lore.add(ChatColor.WHITE + ((plugin.config.get().getMap("Settings").getBoolean("Show-Addresses", false))?subserver.getAddress().getAddress().getHostAddress()+':':"") + subserver.getAddress().getPort());
blockMeta.setLore(lore);
}
block.setItemMeta(blockMeta);
inv.setItem(30, block);
inv.setItem(31, block);
inv.setItem(32, block);
if (hasHistory()) {
block = color(14);
blockMeta = block.getItemMeta();
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.Generic.Back"));
block.setItemMeta(blockMeta);
inv.setItem(34, block);
inv.setItem(35, block);
}
player.openInventory(inv);
open = true;
};
plugin.api.getServer(name, server -> {
windowHistory.add(() -> serverAdmin(name));
if (server == null) {
if (hasHistory()) back();
} else {
if (server instanceof SubServer) {
((SubServer) server).getHost(host -> {
if (host == null) {
if (hasHistory()) back();
} else {
renderer.accept(server, host);
}
});
} else {
renderer.accept(server, null);
}
}
});
}
public void subserverPlugin(final int page, final String name) {
public void serverPlugin(final int page, final String name) {
setDownloading(ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.SubServer-Plugin.Title").replace("$str$", name)));
plugin.api.getSubServer(name, subserver -> {
windowHistory.add(() -> subserverPlugin(page, name));
if (subserver == null) {
plugin.api.getServer(name, server -> {
windowHistory.add(() -> serverPlugin(page, name));
if (server == null) {
if (hasHistory()) back();
} else {
setDownloading(null);
lastVisitedObjects[0] = subserver;
lastVisitedObjects[0] = server;
lastPage = page;
List<String> renderers = new LinkedList<String>();
for (String renderer : renderers) {
if (subserverPlugins.get(renderer).isEnabled(subserver)) renderers.add(renderer);
for (String renderer : serverPlugins.keySet()) {
if (serverPlugins.get(renderer).isEnabled(server)) renderers.add(renderer);
}
Collections.sort(renderers);
@ -1255,7 +1276,7 @@ public class DefaultUIRenderer extends UIRenderer {
int count = (renderers.size() == 0)?27:((renderers.size() - min >= max)?36:renderers.size() - min);
int area = (count % 9 == 0) ? count : ((count / 9) + 1) * 9;
Inventory inv = Bukkit.createInventory(null, 18 + area, plugin.api.getLang("SubServers", "Interface.SubServer-Plugin.Title").replace("$str$", subserver.getDisplayName()));
Inventory inv = Bukkit.createInventory(null, 18 + area, plugin.api.getLang("SubServers", "Interface.SubServer-Plugin.Title").replace("$str$", server.getDisplayName()));
block = color(7);
block.setItemMeta(divMeta);
while (i < area) {
@ -1271,7 +1292,7 @@ public class DefaultUIRenderer extends UIRenderer {
if (renderers.indexOf(renderer) >= min && renderers.indexOf(renderer) <= max) {
if (even && (i == 4 || i == 13 || i == 22 || i == 31)) inv.setItem(i++, adiv);
inv.setItem(i, subserverPlugins.get(renderer).getIcon());
inv.setItem(i, serverPlugins.get(renderer).getIcon());
count--;
if (count < 9 && (i == 8 || i == 17 || i == 26)) {

View File

@ -6,6 +6,7 @@ import net.ME1312.Galaxi.Library.Util;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubServers.Client.Bukkit.SubPlugin;
import net.ME1312.SubServers.Client.Common.Network.API.Host;
import net.ME1312.SubServers.Client.Common.Network.API.Server;
import net.ME1312.SubServers.Client.Common.Network.API.SubServer;
import org.bukkit.Bukkit;
@ -29,7 +30,7 @@ public abstract class UIRenderer {
private final boolean TAPI_PLUGIN;
static final HashMap<String, PluginRenderer<Host>> hostPlugins = new HashMap<String, PluginRenderer<Host>>();
static final HashMap<String, PluginRenderer<SubServer>> subserverPlugins = new HashMap<String, PluginRenderer<SubServer>>();
static final HashMap<String, PluginRenderer<Server>> serverPlugins = new HashMap<String, PluginRenderer<Server>>();
private ContainedPair<String, Integer> tdownload = null;
private final String[] adownload;
private int download = -1;
@ -360,8 +361,8 @@ public abstract class UIRenderer {
*
* @return Host Plugins
*/
public static Map<String, PluginRenderer> getHostPlugins() {
return new HashMap<String, PluginRenderer>(hostPlugins);
public static Map<String, PluginRenderer<Host>> getHostPlugins() {
return new HashMap<String, PluginRenderer<Host>>(hostPlugins);
}
/**
@ -375,33 +376,33 @@ public abstract class UIRenderer {
}
/**
* Add SubServer Plugin
* Add Server Plugin
*
* @param handle Handle to bind
* @param renderer Renderer
*/
public static void addSubServerPlugin(String handle, PluginRenderer<SubServer> renderer) {
public static void addServerPlugin(String handle, PluginRenderer<Server> renderer) {
Util.nullpo(handle, renderer);
subserverPlugins.put(handle, renderer);
serverPlugins.put(handle, renderer);
}
/**
* Get SubServer Plugins
* Get Server Plugins
*
* @return SubServer Plugins
*/
public static Map<String, PluginRenderer> getSubServerPlugins() {
return new HashMap<String, PluginRenderer>(subserverPlugins);
public static Map<String, PluginRenderer<Server>> getServerPlugins() {
return new HashMap<String, PluginRenderer<Server>>(serverPlugins);
}
/**
* Remove SubServer Plugin
* Remove Server Plugin
*
* @param handle Handle
*/
public static void removeSubServerPlugin(String handle) {
public static void removeServerPlugin(String handle) {
Util.nullpo(handle);
subserverPlugins.remove(handle);
serverPlugins.remove(handle);
}
/**
@ -448,18 +449,18 @@ public abstract class UIRenderer {
public abstract void serverMenu(int page, String host, String group);
/**
* Opens SubServer/&lt;name&gt;
* Opens Server/&lt;name&gt;
*
* @param server SubServer Name
*/
public abstract void subserverAdmin(String server);
public abstract void serverAdmin(String server);
/**
* Opens SubServer/&lt;name&gt;/Plugins
* Opens Server/&lt;name&gt;/Plugins
*
* @param server SubServer Name
*/
public abstract void subserverPlugin(int page, String server);
public abstract void serverPlugin(int page, String server);
/**
* Options Layout Class

View File

@ -107,7 +107,7 @@ public class BungeeChat {
}
hover.setColor(ChatColor.WHITE);
hoverm.add(hover);
message.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, label + " open SubServer/ " + server.getName()));
message.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, label + " open Server/ " + server.getName()));
} else {
message.setColor(ChatColor.WHITE);
hover.setColor(ChatColor.WHITE);
@ -184,7 +184,7 @@ public class BungeeChat {
hoverm = new LinkedList<TextComponent>();
message = new TextComponent(subserver.getDisplayName());
hover = new TextComponent(subserver.getDisplayName() + '\n');
message.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, label + " open SubServer/ " + subserver));
message.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, label + " open Server/ " + subserver));
if (subserver.isRunning()) {
message.setColor(ChatColor.GREEN);
hover.setColor(ChatColor.GREEN);
@ -241,7 +241,7 @@ public class BungeeChat {
}
hover.setColor(ChatColor.WHITE);
hoverm.add(hover);
message.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, label + " open SubServer/ " + subserver.getName()));
message.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, label + " open Server/ " + subserver.getName()));
message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverm.toArray(new TextComponent[hoverm.size()])));
if (i != 0) msg.addExtra(div);
msg.addExtra(message);
@ -278,6 +278,7 @@ public class BungeeChat {
}
hover.setColor(ChatColor.WHITE);
hoverm.add(hover);
message.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, label + " open Server/ " + server.getName()));
message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverm.toArray(new TextComponent[hoverm.size()])));
if (i != 0) msg.addExtra(div);
msg.addExtra(message);

View File

@ -0,0 +1,68 @@
package net.ME1312.SubServers.Client.Bukkit.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 org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import java.util.UUID;
/**
* Player Control Packet
*/
public class PacketExControlPlayer implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private int response;
private UUID tracker;
/**
* New PacketExControlPlayer (In)
*/
public PacketExControlPlayer() {}
/**
* New PacketExControlPlayer (Out)
*
* @param response Response ID
* @param tracker Tracker ID
*/
public PacketExControlPlayer(int response, UUID tracker) {
this.response = response;
this.tracker = tracker;
}
@Override
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
if (tracker != null) data.set(0x0000, tracker);
data.set(0x0001, response);
return data;
}
@Override
public void receive(SubDataSender client, ObjectMap<Integer> data) {
UUID tracker = (data.contains(0x0000)?data.getUUID(0x0000):null);
try {
String command = data.getString(0x0001);
UUID target = (data.contains(0x0002)?data.getUUID(0x0002):null);
CommandSender sender = Bukkit.getConsoleSender();
if (target != null && (sender = Bukkit.getPlayer(target)) == null) {
client.sendPacket(new PacketExControlPlayer(6, tracker));
} else {
Bukkit.getServer().dispatchCommand(sender, command);
client.sendPacket(new PacketExControlPlayer(0, tracker));
}
} catch (Throwable e) {
client.sendPacket(new PacketExControlPlayer(2, tracker));
e.printStackTrace();
}
}
@Override
public int version() {
return 0x0001;
}
}

View File

@ -77,7 +77,7 @@ public class PacketInExRunEvent implements PacketObjectIn<Integer> {
@Override
public void accept(ObjectMap<String> data) {
if (plugin.isEnabled()) {
Bukkit.getPluginManager().callEvent(new SubSendCommandEvent((data.contains("player"))?data.getUUID("player"):null, data.getString("server"), data.getString("command")));
Bukkit.getPluginManager().callEvent(new SubSendCommandEvent((data.contains("player"))?data.getUUID("player"):null, data.getString("server"), data.getString("command"), (data.contains("target"))?data.getUUID("target"):null));
callback("SubSendCommandEvent", this);
}
}

View File

@ -36,7 +36,7 @@ public class SubProtocol extends SubDataProtocol {
SubPlugin plugin = SubAPI.getInstance().getInternals();
setName("SubServers 2");
addVersion(new Version("2.16a+"));
addVersion(new Version("2.18a+"));
// 00-0F: Object Link Packets
@ -100,10 +100,12 @@ public class SubProtocol extends SubDataProtocol {
//registerPacket(0x0070, PacketInExRunEvent.class);
//registerPacket(0x0071, PacketInExReset.class);
//registerPacket(0x0072, PacketInExReload.class);
registerPacket(0x0078, PacketExControlPlayer.class);
registerPacket(0x0070, new PacketInExRunEvent(plugin));
registerPacket(0x0071, new PacketInExReset());
registerPacket(0x0072, new PacketInExReload(plugin));
registerPacket(0x0078, new PacketExControlPlayer());
}
public static SubProtocol get() {

View File

@ -588,8 +588,8 @@ public final class SubCommand extends Command {
}
} else if (args[0].equalsIgnoreCase("cmd") || args[0].equalsIgnoreCase("command")) {
if (args.length > 1) {
selectServers(sender, args, 1, true, new String[]{"subservers.subserver.%.*", "subservers.subserver.%.command"}, select -> {
if (select.subservers.length > 0) {
selectServers(sender, args, 1, false, new String[]{"subservers.subserver.%.*", "subservers.subserver.%.command"}, select -> {
if (select.servers.length > 0) {
if (select.args.length > 2) {
StringBuilder builder = new StringBuilder(select.args[2]);
for (int i = 3; i < select.args.length; i++) {
@ -603,7 +603,7 @@ public final class SubCommand extends Command {
if (running.value > 0) sender.sendMessage(plugin.api.getLang("SubServers", "Command.Command.Not-Running").replace("$int$", running.value.toString()));
if (success.value > 0) sender.sendMessage(plugin.api.getLang("SubServers", "Command.Command").replace("$int$", success.value.toString()));
});
for (SubServer server : select.subservers) {
for (Server server : select.servers) {
merge.reserve();
server.command((sender instanceof Player)?((Player) sender).getUniqueId():null, builder.toString(), response -> {
switch (response) {
@ -627,7 +627,7 @@ public final class SubCommand extends Command {
}
});
} else {
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Generic.Usage").replace("$str$", label.toLowerCase() + " " + args[0].toLowerCase() + " <Subservers> <Command> [Args...]"));
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Generic.Usage").replace("$str$", label.toLowerCase() + " " + args[0].toLowerCase() + " <Servers> <Command> [Args...]"));
}
} else if (args[0].equalsIgnoreCase("create")) {
if (args.length > 3) {
@ -808,12 +808,14 @@ public final class SubCommand extends Command {
else if (args.length > 2) plugin.gui.getRenderer((Player) sender).serverMenu(Integer.parseInt(args[2]), null, null);
else plugin.gui.getRenderer((Player) sender).serverMenu(1, null, null);
break;
case "server/":
case "subserver/":
plugin.gui.getRenderer((Player) sender).subserverAdmin(args[2]);
plugin.gui.getRenderer((Player) sender).serverAdmin(args[2]);
break;
case "server/plugin":
case "subserver/plugin":
if (args.length > 3) plugin.gui.getRenderer((Player) sender).subserverPlugin(Integer.parseInt(args[3]), args[2]);
else plugin.gui.getRenderer((Player) sender).subserverPlugin(1, args[2]);
if (args.length > 3) plugin.gui.getRenderer((Player) sender).serverPlugin(Integer.parseInt(args[3]), args[2]);
else plugin.gui.getRenderer((Player) sender).serverPlugin(1, args[2]);
break;
}
} catch (Throwable e) { /*
@ -1124,7 +1126,7 @@ public final class SubCommand extends Command {
plugin.api.getLang("SubServers", "Command.Help.SubServer.Restart").replace("$str$", label.toLowerCase() + " restart <Subservers>"),
plugin.api.getLang("SubServers", "Command.Help.SubServer.Stop").replace("$str$", label.toLowerCase() + " stop <Subservers>"),
plugin.api.getLang("SubServers", "Command.Help.SubServer.Terminate").replace("$str$", label.toLowerCase() + " kill <Subservers>"),
plugin.api.getLang("SubServers", "Command.Help.SubServer.Command").replace("$str$", label.toLowerCase() + " cmd <Subservers> <Command> [Args...]"),
plugin.api.getLang("SubServers", "Command.Help.SubServer.Command").replace("$str$", label.toLowerCase() + " cmd <Servers> <Command> [Args...]"),
plugin.api.getLang("SubServers", "Command.Help.Host.Create").replace("$str$", label.toLowerCase() + " create <Name> <Host> <Template> [Version] [Port]"),
plugin.api.getLang("SubServers", "Command.Help.SubServer.Update").replace("$str$", label.toLowerCase() + " update <Subservers> [[Template] <Version>]"),
};

View File

@ -18,7 +18,7 @@
<dependency>
<groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiUtil</artifactId>
<version>21w47d</version>
<version>21w49a</version>
<scope>compile</scope>
</dependency>
<dependency>

View File

@ -9,6 +9,7 @@ import net.ME1312.SubData.Client.DataSender;
import net.ME1312.SubData.Client.Library.ForwardedDataSender;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubServers.Client.Common.ClientAPI;
import net.ME1312.SubServers.Client.Common.Network.Packet.PacketCommandServer;
import net.ME1312.SubServers.Client.Common.Network.Packet.PacketDownloadPlayerInfo;
import net.ME1312.SubServers.Client.Common.Network.Packet.PacketDownloadServerInfo;
@ -16,6 +17,7 @@ import java.lang.reflect.InvocationTargetException;
import java.net.InetSocketAddress;
import java.util.*;
import java.util.function.Consumer;
import java.util.function.IntConsumer;
/**
* Simplified Server Data Class
@ -119,6 +121,79 @@ public class Server {
return new LinkedList<String>(raw.getStringList("group"));
}
/**
* Commands the Server
*
* @param player Player who's Commanding
* @param target Player who will Send
* @param command Commmand to Send
* @param response Response Code
*/
public void command(UUID player, UUID target, String command, IntConsumer response) {
Util.nullpo(command, response);
StackTraceElement[] origin = new Exception().getStackTrace();
client().sendPacket(new PacketCommandServer(player, target, getName(), command, data -> {
try {
response.accept(data.getInt(0x0001));
} catch (Throwable e) {
Throwable ew = new InvocationTargetException(e);
ew.setStackTrace(origin);
ew.printStackTrace();
}
}));
}
/**
* Commands the Server
*
* @param player Player who's Commanding
* @param command Commmand to Send
* @param response Response Code
*/
public void command(UUID player, String command, IntConsumer response) {
command(player, null, command, response);
}
/**
* Commands the Server
*
* @param command Commmand to Send
* @param response Response Code
*/
public void command(String command, IntConsumer response) {
command(null, command, response);
}
/**
* Commands the Server
*
* @param player Player who's Commanding
* @param target Player who's Commanding
* @param command Command to Send
*/
public void command(UUID player, UUID target, String command) {
command(player, target, command, i -> {});
}
/**
* Commands the Server
*
* @param player Player who's Commanding
* @param command Command to Send
*/
public void command(UUID player, String command) {
command(player, command, i -> {});
}
/**
* Commands the Server
*
* @param command Command to Send
*/
public void command(String command) {
command(command, i -> {});
}
/**
* Get players on this server across all known proxies
*

View File

@ -218,56 +218,6 @@ public class SubServer extends Server {
terminate(i -> {});
}
/**
* Commands the Server
*
* @param player Player who Commanded
* @param command Commmand to Send
* @param response Response Code
*/
public void command(UUID player, String command, IntConsumer response) {
Util.nullpo(command, response);
StackTraceElement[] origin = new Exception().getStackTrace();
client().sendPacket(new PacketCommandServer(player, getName(), command, data -> {
try {
response.accept(data.getInt(0x0001));
} catch (Throwable e) {
Throwable ew = new InvocationTargetException(e);
ew.setStackTrace(origin);
ew.printStackTrace();
}
}));
}
/**
* Commands the Server
*
* @param command Commmand to Send
* @param response Response Code
*/
public void command(String command, IntConsumer response) {
command(null, command, response);
}
/**
* Commands the Server
*
* @param player Player who Commanded
* @param command Command to Send
*/
public void command(UUID player, String command) {
command(player, command, i -> {});
}
/**
* Commands the Server
*
* @param command Command to Send
*/
public void command(String command) {
command(command, i -> {});
}
/**
* Edits the Server
*

View File

@ -18,6 +18,7 @@ public class PacketCommandServer implements PacketObjectIn<Integer>, PacketObjec
private UUID player;
private String server;
private String command;
private UUID target;
private UUID tracker;
/**
@ -29,14 +30,16 @@ public class PacketCommandServer implements PacketObjectIn<Integer>, PacketObjec
* New PacketCommandServer (Out)
*
* @param player Player Sending
* @param target Target Player
* @param server Server to send to
* @param command Command to send
* @param callback Callbacks
*/
@SafeVarargs
public PacketCommandServer(UUID player, String server, String command, Consumer<ObjectMap<Integer>>... callback) {
public PacketCommandServer(UUID player, UUID target, String server, String command, Consumer<ObjectMap<Integer>>... callback) {
Util.nullpo(server, command, callback);
this.player = player;
this.target = target;
this.server = server;
this.command = command;
this.tracker = Util.getNew(callbacks.keySet(), UUID::randomUUID);
@ -49,7 +52,8 @@ public class PacketCommandServer implements PacketObjectIn<Integer>, PacketObjec
data.set(0x0000, tracker);
data.set(0x0001, server);
data.set(0x0002, command);
if (player != null) data.set(0x0003, player.toString());
if (player != null) data.set(0x0003, player);
if (target != null) data.set(0x0004, target);
return data;
}

View File

@ -51,7 +51,7 @@ public class PacketDeleteServer implements PacketObjectIn<Integer>, PacketObject
data.set(0x0001, server);
data.set(0x0002, recycle);
data.set(0x0003, force);
if (player != null) data.set(0x0004, player.toString());
if (player != null) data.set(0x0004, player);
return data;
}

View File

@ -53,7 +53,7 @@ public class PacketEditServer implements PacketObjectIn<Integer>, PacketObjectOu
data.set(0x0001, server);
data.set(0x0002, edit);
data.set(0x0003, perma);
if (player != null) data.set(0x0004, player.toString());
if (player != null) data.set(0x0004, player);
return data;
}

View File

@ -48,7 +48,7 @@ public class PacketRemoveServer implements PacketObjectIn<Integer>, PacketObject
data.set(0x0000, tracker);
data.set(0x0001, server);
data.set(0x0002, force);
if (player != null) data.set(0x0003, player.toString());
if (player != null) data.set(0x0003, player);
return data;
}

View File

@ -45,7 +45,7 @@ public class PacketRestartServer implements PacketObjectIn<Integer>, PacketObjec
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, tracker);
data.set(0x0001, server);
if (player != null) data.set(0x0002, player.toString());
if (player != null) data.set(0x0002, player);
return data;
}

View File

@ -45,7 +45,7 @@ public class PacketStartServer implements PacketObjectIn<Integer>, PacketObjectO
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, tracker);
data.set(0x0001, server);
if (player != null) data.set(0x0002, player.toString());
if (player != null) data.set(0x0002, player);
return data;
}

View File

@ -49,7 +49,7 @@ public class PacketStopServer implements PacketObjectIn<Integer>, PacketObjectOu
data.set(0x0000, id);
data.set(0x0001, server);
data.set(0x0002, force);
if (player != null) data.set(0x0003, player.toString());
if (player != null) data.set(0x0003, player);
return data;
}

View File

@ -127,7 +127,7 @@
<links>
<link>https://dev.me1312.net/jenkins/job/GalaxiEngine/javadoc/GalaxiUtil/</link>
<link>https://dev.me1312.net/jenkins/job/SubData/javadoc/Client/</link>
<link>https://jd.spongepowered.org/</link>
<link>https://jd.spongepowered.org/spongeapi/7.3.0/</link>
</links>
<includeDependencySources>true</includeDependencySources>
<dependencySourceIncludes>

View File

@ -15,18 +15,22 @@ public class SubSendCommandEvent extends AbstractEvent implements SubEvent {
private UUID player;
private String server;
private String command;
private UUID target;
/**
* Server Command Event
*
* @param player Player Commanding Server
* @param server Server being Commanded
* @param player Player Commanding
* @param server Target Server
* @param command Command to Send
* @param target Player that will send
*/
public SubSendCommandEvent(UUID player, String server, String command) {
public SubSendCommandEvent(UUID player, String server, String command, UUID target) {
Util.nullpo(server, command);
this.player = player;
this.server = server;
this.command = command;
this.target = target;
}
/**
@ -52,6 +56,15 @@ public class SubSendCommandEvent extends AbstractEvent implements SubEvent {
return command;
}
/**
* Gets the Player that will be forced to send the Command
*
* @return Target Player or null if Console
*/
public UUID getTarget() {
return target;
}
/**
* Gets the cause of this Event
*

View File

@ -7,6 +7,7 @@ import net.ME1312.Galaxi.Library.Container.Value;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubServers.Client.Common.Network.API.Host;
import net.ME1312.SubServers.Client.Common.Network.API.Server;
import net.ME1312.SubServers.Client.Common.Network.API.SubServer;
import net.ME1312.SubServers.Client.Sponge.Library.Compatibility.ChatColor;
import net.ME1312.SubServers.Client.Sponge.SubPlugin;
@ -25,7 +26,7 @@ import java.util.concurrent.TimeUnit;
*/
public abstract class UIRenderer {
static HashMap<String, PluginRenderer<Host>> hostPlugins = new HashMap<String, PluginRenderer<Host>>();
static HashMap<String, PluginRenderer<SubServer>> subserverPlugins = new HashMap<String, PluginRenderer<SubServer>>();
static HashMap<String, PluginRenderer<Server>> serverPlugins = new HashMap<String, PluginRenderer<Server>>();
private Pair<String, Integer> tdownload = null;
private UUID download = null;
private final UUID player;
@ -252,33 +253,33 @@ public abstract class UIRenderer {
}
/**
* Add SubServer Plugin
* Add Server Plugin
*
* @param handle Handle to bind
* @param renderer Renderer
*/
public static void addSubServerPlugin(String handle, PluginRenderer<SubServer> renderer) {
public static void addServerPlugin(String handle, PluginRenderer<Server> renderer) {
Util.nullpo(handle, renderer);
subserverPlugins.put(handle, renderer);
serverPlugins.put(handle, renderer);
}
/**
* Get SubServer Plugins
* Get Server Plugins
*
* @return SubServer Plugins
*/
public static Map<String, PluginRenderer<SubServer>> getSubServerPlugins() {
return new HashMap<String, PluginRenderer<SubServer>>(subserverPlugins);
public static Map<String, PluginRenderer<Server>> getServerPlugins() {
return new HashMap<String, PluginRenderer<Server>>(serverPlugins);
}
/**
* Remove SubServer Plugin
* Remove Server Plugin
*
* @param handle Handle
*/
public static void removeSubServerPlugin(String handle) {
public static void removeServerPlugin(String handle) {
Util.nullpo(handle);
subserverPlugins.remove(handle);
serverPlugins.remove(handle);
}
/**
@ -325,18 +326,18 @@ public abstract class UIRenderer {
public abstract void serverMenu(int page, String host, String group);
/**
* Opens SubServer/&lt;name&gt;
* Opens Server/&lt;name&gt;
*
* @param server SubServer Name
*/
public abstract void subserverAdmin(String server);
public abstract void serverAdmin(String server);
/**
* Opens SubServer/&lt;name&gt;/Plugins
* Opens Server/&lt;name&gt;/Plugins
*
* @param server SubServer Name
*/
public abstract void subserverPlugin(int page, String server);
public abstract void serverPlugin(int page, String server);
/**
* Options Layout Class

View File

@ -0,0 +1,69 @@
package net.ME1312.SubServers.Client.Sponge.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 org.spongepowered.api.Sponge;
import org.spongepowered.api.command.CommandSource;
import java.util.UUID;
/**
* Player Control Packet
*/
public class PacketExControlPlayer implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private int response;
private UUID tracker;
/**
* New PacketExControlPlayer (In)
*/
public PacketExControlPlayer() {}
/**
* New PacketExControlPlayer (Out)
*
* @param response Response ID
* @param tracker Tracker ID
*/
public PacketExControlPlayer(int response, UUID tracker) {
this.response = response;
this.tracker = tracker;
}
@Override
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
if (tracker != null) data.set(0x0000, tracker);
data.set(0x0001, response);
return data;
}
@Override
public void receive(SubDataSender client, ObjectMap<Integer> data) {
UUID tracker = (data.contains(0x0000)?data.getUUID(0x0000):null);
try {
String command = data.getString(0x0001);
UUID target = (data.contains(0x0002)?data.getUUID(0x0002):null);
CommandSource sender = Sponge.getServer().getConsole();
if (target != null && (sender = Sponge.getServer().getPlayer(target).orElse(null)) == null) {
client.sendPacket(new PacketExControlPlayer(6, tracker));
} else {
Sponge.getCommandManager().process(sender, command);
client.sendPacket(new PacketExControlPlayer(0, tracker));
}
} catch (Throwable e) {
client.sendPacket(new PacketExControlPlayer(2, tracker));
e.printStackTrace();
}
}
@Override
public int version() {
return 0x0001;
}
}

View File

@ -66,7 +66,7 @@ public class PacketInExRunEvent implements PacketObjectIn<Integer> {
callback("SubSendCommandEvent", new Consumer<ObjectMap<String>>() {
@Override
public void accept(ObjectMap<String> data) {
Sponge.getEventManager().post(new SubSendCommandEvent((data.contains("player"))?data.getUUID("player"):null, data.getString("server"), data.getString("command")));
Sponge.getEventManager().post(new SubSendCommandEvent((data.contains("player"))?data.getUUID("player"):null, data.getString("server"), data.getString("command"), (data.contains("target"))?data.getUUID("target"):null));
callback("SubSendCommandEvent", this);
}
});

View File

@ -39,7 +39,7 @@ public class SubProtocol extends SubDataProtocol {
SubPlugin plugin = SubAPI.getInstance().getInternals();
setName("SubServers 2");
addVersion(new Version("2.16a+"));
addVersion(new Version("2.18a+"));
// 00-0F: Object Link Packets
@ -103,10 +103,12 @@ public class SubProtocol extends SubDataProtocol {
//registerPacket(0x0070, PacketInExRunEvent.class);
//registerPacket(0x0071, PacketInExReset.class);
//registerPacket(0x0072, PacketInExReload.class);
registerPacket(0x0078, PacketExControlPlayer.class);
registerPacket(0x0070, new PacketInExRunEvent(plugin));
registerPacket(0x0071, new PacketInExReset());
registerPacket(0x0072, new PacketInExReload(plugin));
registerPacket(0x0078, new PacketExControlPlayer());
}
public static SubProtocol get() {

View File

@ -255,7 +255,7 @@ public final class SubCommand implements CommandExecutor {
Text.Builder message = Text.builder(server.getDisplayName());
Text.Builder hover = Text.builder(server.getDisplayName() + '\n');
if (server instanceof SubServer) {
message.onClick(TextActions.runCommand("/subservers open SubServer/ " + server.getName()));
message.onClick(TextActions.runCommand("/subservers open Server/ " + server.getName()));
if (((SubServer) server).isRunning()) {
message.color(TextColors.GREEN);
hover.color(TextColors.GREEN);
@ -302,7 +302,7 @@ public final class SubCommand implements CommandExecutor {
} else {
hover.append(Text.builder("\n" + server.getAddress().getPort()).color(TextColors.WHITE).build());
}
message.onClick(TextActions.runCommand("/subservers open SubServer/ " + server.getName()));
message.onClick(TextActions.runCommand("/subservers open Server/ " + server.getName()));
} else {
message.color(TextColors.WHITE);
hover.color(TextColors.WHITE);
@ -404,7 +404,7 @@ public final class SubCommand implements CommandExecutor {
} else {
hover.append(Text.builder("\n" + subserver.getAddress().getPort()).color(TextColors.WHITE).build());
}
message.onClick(TextActions.runCommand("/subservers open SubServer/ " + subserver.getName()));
message.onClick(TextActions.runCommand("/subservers open Server/ " + subserver.getName()));
message.onHover(TextActions.showText(hover.build()));
if (i != 0) msg.append(div);
msg.append(message.build());
@ -434,6 +434,7 @@ public final class SubCommand implements CommandExecutor {
} else {
hover.append(Text.builder("\n" + server.getAddress().getPort()).color(TextColors.WHITE).build());
}
message.onClick(TextActions.runCommand("/subservers open Server/ " + server.getName()));
message.onHover(TextActions.showText(hover.build()));
if (i != 0) msg.append(div);
msg.append(message.build());
@ -955,8 +956,8 @@ public final class SubCommand implements CommandExecutor {
Optional<String[]> s = args.getOne(Text.of("Subservers"));
Optional<String> command = args.getOne(Text.of("Command"));
if (s.isPresent()) {
selectServers(sender, s.get(), true, new String[]{"subservers.subserver.%.*", "subservers.subserver.%.command"}, select -> {
if (select.subservers.length > 0) {
selectServers(sender, s.get(), false, new String[]{"subservers.subserver.%.*", "subservers.subserver.%.command"}, select -> {
if (select.servers.length > 0) {
if (command.isPresent()) {
Container<Integer> success = new Container<Integer>(0);
Container<Integer> running = new Container<Integer>(0);
@ -964,7 +965,7 @@ public final class SubCommand implements CommandExecutor {
if (running.value > 0) sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers", "Command.Command.Not-Running").replace("$int$", running.value.toString())));
if (success.value > 0) sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers", "Command.Command").replace("$int$", success.value.toString())));
});
for (SubServer server : select.subservers) {
for (Server server : select.servers) {
merge.reserve();
server.command((sender instanceof Player)?((Player) sender).getUniqueId():null, command.get(), response -> {
switch (response) {
@ -989,7 +990,7 @@ public final class SubCommand implements CommandExecutor {
});
return CommandResult.builder().successCount(1).build();
} else {
sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers","Command.Generic.Usage").replace("$str$", "/sub command <Subservers> <Command> [Args...]")));
sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers","Command.Generic.Usage").replace("$str$", "/sub command <Servers> <Command> [Args...]")));
return CommandResult.builder().successCount(0).build();
}
} else {
@ -1308,12 +1309,14 @@ public final class SubCommand implements CommandExecutor {
else if (menuopts.length > 0) plugin.gui.getRenderer((Player) sender).serverMenu(Integer.parseInt(menuopts[0]), null, null);
else plugin.gui.getRenderer((Player) sender).serverMenu(1, null, null);
break;
case "server/":
case "subserver/":
plugin.gui.getRenderer((Player) sender).subserverAdmin(menuopts[0]);
plugin.gui.getRenderer((Player) sender).serverAdmin(menuopts[0]);
break;
case "server/plugin":
case "subserver/plugin":
if (menuopts.length > 1) plugin.gui.getRenderer((Player) sender).subserverPlugin(Integer.parseInt(menuopts[1]), menuopts[0]);
else plugin.gui.getRenderer((Player) sender).subserverPlugin(1, menuopts[0]);
if (menuopts.length > 1) plugin.gui.getRenderer((Player) sender).serverPlugin(Integer.parseInt(menuopts[1]), menuopts[0]);
else plugin.gui.getRenderer((Player) sender).serverPlugin(1, menuopts[0]);
break;
}
return CommandResult.builder().successCount(1).build();
@ -1548,7 +1551,7 @@ public final class SubCommand implements CommandExecutor {
ChatColor.convertColor(plugin.api.getLang("SubServers","Command.Help.SubServer.Restart").replace("$str$", "/sub restart <Subservers>")),
ChatColor.convertColor(plugin.api.getLang("SubServers","Command.Help.SubServer.Stop").replace("$str$", "/sub stop <Subservers>")),
ChatColor.convertColor(plugin.api.getLang("SubServers","Command.Help.SubServer.Terminate").replace("$str$", "/sub kill <Subservers>")),
ChatColor.convertColor(plugin.api.getLang("SubServers","Command.Help.SubServer.Command").replace("$str$", "/sub cmd <Subservers> <Command> [Args...]")),
ChatColor.convertColor(plugin.api.getLang("SubServers","Command.Help.SubServer.Command").replace("$str$", "/sub cmd <Servers> <Command> [Args...]")),
ChatColor.convertColor(plugin.api.getLang("SubServers","Command.Help.Host.Create").replace("$str$", "/sub create <Name> <Host> <Template> [Version] [Port]")),
ChatColor.convertColor(plugin.api.getLang("SubServers","Command.Help.SubServer.Update").replace("$str$", "/sub update <Subservers> [[Template] <Version>]")),
};

View File

@ -1,4 +1,4 @@
Version: '2.16a+'
Version: '2.18a+'
Template:
Enabled: true
Icon: 'lava_bucket'

View File

@ -1,4 +1,4 @@
Version: '2.16a+'
Version: '2.18a+'
Template:
Enabled: true
Icon: 'sponge'

View File

@ -30,13 +30,13 @@
<dependency>
<groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiEngine</artifactId>
<version>21w47d</version>
<version>21w49a</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiUI</artifactId>
<version>21w47d</version>
<version>21w49a</version>
<scope>runtime</scope>
</dependency>
<dependency>

View File

@ -12,6 +12,7 @@ public class SubSendCommandEvent extends Event {
private UUID player;
private String server;
private String command;
private UUID target;
/**
* Server Command Event
@ -19,11 +20,12 @@ public class SubSendCommandEvent extends Event {
* @param player Player Commanding Server
* @param server Server being Commanded
*/
public SubSendCommandEvent(UUID player, String server, String command) {
public SubSendCommandEvent(UUID player, String server, String command, UUID target) {
Util.nullpo(server, command);
this.player = player;
this.server = server;
this.command = command;
this.target = target;
}
/**
@ -48,4 +50,13 @@ public class SubSendCommandEvent extends Event {
public String getCommand() {
return command;
}
/**
* Gets the Player that will be forced to send the Command
*
* @return Target Player or null if Console
*/
public UUID getTarget() {
return target;
}
}

View File

@ -63,7 +63,7 @@ public class PacketInExRunEvent implements PacketObjectIn<Integer> {
callback("SubSendCommandEvent", new Consumer<ObjectMap<String>>() {
@Override
public void accept(ObjectMap<String> data) {
GalaxiEngine.getInstance().getPluginManager().executeEvent(new SubSendCommandEvent((data.contains("player"))?data.getUUID("player"):null, data.getString("server"), data.getString("command")));
GalaxiEngine.getInstance().getPluginManager().executeEvent(new SubSendCommandEvent((data.contains("player"))?data.getUUID("player"):null, data.getString("server"), data.getString("command"), (data.contains("target"))?data.getUUID("target"):null));
callback("SubSendCommandEvent", this);
}
});

View File

@ -32,7 +32,7 @@ public class SubProtocol extends SubDataProtocol {
ExHost host = SubAPI.getInstance().getInternals();
setName("SubServers 2");
addVersion(new Version("2.16a+"));
addVersion(new Version("2.18a+"));
// 00-0F: Object Link Packets

View File

@ -701,8 +701,8 @@ public class SubCommand {
public void command(CommandSender sender, String handle, String[] args) {
if (canRun()) {
if (args.length > 0) {
selectServers(sender, args, 0, true, select -> {
if (select.subservers.length > 0) {
selectServers(sender, args, 0, false, select -> {
if (select.servers.length > 0) {
if (select.args.length > 1) {
StringBuilder builder = new StringBuilder(select.args[1]);
for (int i = 2; i < select.args.length; i++) {
@ -713,16 +713,16 @@ public class SubCommand {
Container<Integer> success = new Container<Integer>(0);
Container<Integer> running = new Container<Integer>(0);
AsyncConsolidator merge = new AsyncConsolidator(() -> {
if (running.value > 0) sender.sendMessage(running.value + " subserver"+((running.value == 1)?" was":"s were") + " offline");
if (success.value > 0) sender.sendMessage("Sent command to " + success.value + " subserver"+((success.value == 1)?"":"s"));
if (running.value > 0) sender.sendMessage(running.value + " server"+((running.value == 1)?" was":"s were") + " offline");
if (success.value > 0) sender.sendMessage("Sent command to " + success.value + " server"+((success.value == 1)?"":"s"));
});
for (SubServer server : select.subservers) {
for (Server server : select.servers) {
merge.reserve();
server.command(builder.toString(), response -> {
switch (response) {
case 3:
case 4:
sender.sendMessage("Subserver " + server.getName() + " has disappeared");
sender.sendMessage("Server " + server.getName() + " has disappeared");
break;
case 5:
running.value++;
@ -744,8 +744,8 @@ public class SubCommand {
}
}
}
}.autocomplete(defaultCompletor).usage("<Subservers>", "<Command>", "[Args...]").description("Sends a command to the console of one or more subservers").help(
"Sends a command to the console of one or more subservers on the network.",
}.autocomplete(new ServerCompletion(0, false, ((sender, label, args, select) -> new String[0]))).usage("<Servers>", "<Command>", "[Args...]").description("Sends a command to the console of one or more servers").help(
"Sends a command to the console of one or more servers on the network.",
"",
"Examples:",
" /command Server1 version",

View File

@ -14,6 +14,7 @@ public class SubSendCommandEvent extends Event implements SubEvent {
private UUID player;
private String server;
private String command;
private UUID target;
/**
* Server Command Event
@ -21,11 +22,12 @@ public class SubSendCommandEvent extends Event implements SubEvent {
* @param player Player Commanding Server
* @param server Server being Commanded
*/
public SubSendCommandEvent(UUID player, String server, String command) {
public SubSendCommandEvent(UUID player, String server, String command, UUID target) {
Util.nullpo(server, command);
this.player = player;
this.server = server;
this.command = command;
this.target = target;
}
/**
@ -50,4 +52,13 @@ public class SubSendCommandEvent extends Event implements SubEvent {
public String getCommand() {
return command;
}
/**
* Gets the Player that will be forced to send the Command
*
* @return Target Player or null if Console
*/
public UUID getTarget() {
return target;
}
}

View File

@ -65,7 +65,7 @@ public class PacketInExRunEvent implements PacketObjectIn<Integer> {
callback("SubSendCommandEvent", new Consumer<ObjectMap<String>>() {
@Override
public void accept(ObjectMap<String> data) {
ProxyServer.getInstance().getPluginManager().callEvent(new SubSendCommandEvent((data.contains("player"))?data.getUUID("player"):null, data.getString("server"), data.getString("command")));
ProxyServer.getInstance().getPluginManager().callEvent(new SubSendCommandEvent((data.contains("player"))?data.getUUID("player"):null, data.getString("server"), data.getString("command"), (data.contains("target"))?data.getUUID("target"):null));
callback("SubSendCommandEvent", this);
}
});

View File

@ -44,7 +44,7 @@ public class SubProtocol extends SubDataProtocol {
ExProxy plugin = SubAPI.getInstance().getInternals();
setName("SubServers 2");
addVersion(new Version("2.16a+"));
addVersion(new Version("2.18a+"));
// 00-0F: Object Link Packets

View File

@ -539,8 +539,8 @@ public final class SubCommand extends Command implements TabExecutor {
}
} else if (args[0].equalsIgnoreCase("cmd") || args[0].equalsIgnoreCase("command")) {
if (args.length > 1) {
selectServers(sender, args, 1, true, select -> {
if (select.subservers.length > 0) {
selectServers(sender, args, 1, false, select -> {
if (select.servers.length > 0) {
if (select.args.length > 2) {
StringBuilder builder = new StringBuilder(select.args[2]);
for (int i = 3; i < select.args.length; i++) {
@ -551,16 +551,16 @@ public final class SubCommand extends Command implements TabExecutor {
Container<Integer> success = new Container<Integer>(0);
Container<Integer> running = new Container<Integer>(0);
AsyncConsolidator merge = new AsyncConsolidator(() -> {
if (running.value > 0) sender.sendMessage("SubServers > " + running.value + " subserver"+((running.value == 1)?" was":"s were") + " offline");
if (success.value > 0) sender.sendMessage("SubServers > Sent command to " + success.value + " subserver"+((success.value == 1)?"":"s"));
if (running.value > 0) sender.sendMessage("SubServers > " + running.value + " server"+((running.value == 1)?" was":"s were") + " offline");
if (success.value > 0) sender.sendMessage("SubServers > Sent command to " + success.value + " server"+((success.value == 1)?"":"s"));
});
for (SubServer server : select.subservers) {
for (Server server : select.servers) {
merge.reserve();
server.command(builder.toString(), response -> {
switch (response) {
case 3:
case 4:
sender.sendMessage("SubServers > Subserver " + server.getName() + " has disappeared");
sender.sendMessage("SubServers > Server " + server.getName() + " has disappeared");
break;
case 5:
running.value++;
@ -578,7 +578,7 @@ public final class SubCommand extends Command implements TabExecutor {
}
});
} else {
sender.sendMessage("Usage: " + label + " " + args[0].toLowerCase() + " <Subservers> <Command> [Args...]");
sender.sendMessage("Usage: " + label + " " + args[0].toLowerCase() + " <Servers> <Command> [Args...]");
}
} else if (args[0].equalsIgnoreCase("create")) {
if (args.length > 3) {
@ -919,7 +919,7 @@ public final class SubCommand extends Command implements TabExecutor {
" Restart Server: /sub restart <Subservers>",
" Stop Server: /sub stop <Subservers>",
" Terminate Server: /sub kill <Subservers>",
" Command Server: /sub cmd <Subservers> <Command> [Args...]",
" Command Server: /sub cmd <Servers> <Command> [Args...]",
" Create Server: /sub create <Name> <Host> <Template> [Version] [Port]",
" Update Server: /sub update <Subservers> [[Template] <Version>]",
" Remove Server: /sub delete <Subservers>",
@ -1084,7 +1084,8 @@ public final class SubCommand extends Command implements TabExecutor {
args[0].equals("update") || args[0].equals("upgrade") ||
args[0].equals("remove") || args[0].equals("del") || args[0].equals("delete")) {
List<String> list = new ArrayList<String>();
RawServerSelection select = selectRawServers(null, args, 1, true);
boolean mode = !args[0].equals("cmd") && !args[0].equals("command");
RawServerSelection select = selectRawServers(null, args, 1, mode);
if (select.last != null) {
if (last.startsWith("::")) {
Map<String, Host> hosts = hostCache;
@ -1109,12 +1110,12 @@ public final class SubCommand extends Command implements TabExecutor {
}
return list;
} else {
Map<String, ServerImpl> subservers = plugin.servers;
if (subservers.size() > 0) {
Map<String, ServerImpl> servers = plugin.servers;
if (servers.size() > 0) {
if (Arrays.binarySearch(select.selection, "*") < 0 && "*".startsWith(last)) list.add("*");
if (sender instanceof ProxiedPlayer && Arrays.binarySearch(select.selection, ".") < 0 && ".".startsWith(last)) list.add(".");
for (ServerImpl server : subservers.values()) {
if (server instanceof SubServerImpl && Arrays.binarySearch(select.selection, server.getName().toLowerCase()) < 0 && server.getName().toLowerCase().startsWith(last)) list.add(Last + server.getName().substring(last.length()));
for (ServerImpl server : servers.values()) {
if ((!mode || server instanceof SubServerImpl) && Arrays.binarySearch(select.selection, server.getName().toLowerCase()) < 0 && server.getName().toLowerCase().startsWith(last)) list.add(Last + server.getName().substring(last.length()));
}
}
return list;

View File

@ -12,6 +12,7 @@ public class SubSendCommandEvent implements SubEvent {
private UUID player;
private String server;
private String command;
private UUID target;
/**
* Server Command Event
@ -19,11 +20,12 @@ public class SubSendCommandEvent implements SubEvent {
* @param player Player Commanding Server
* @param server Server being Commanded
*/
public SubSendCommandEvent(UUID player, String server, String command) {
public SubSendCommandEvent(UUID player, String server, String command, UUID target) {
Util.nullpo(server, command);
this.player = player;
this.server = server;
this.command = command;
this.target = target;
}
/**
@ -48,4 +50,13 @@ public class SubSendCommandEvent implements SubEvent {
public String getCommand() {
return command;
}
/**
* Gets the Player that will be forced to send the Command
*
* @return Target Player or null if Console
*/
public UUID getTarget() {
return target;
}
}

View File

@ -63,7 +63,7 @@ public class PacketInExRunEvent implements PacketObjectIn<Integer> {
callback("SubSendCommandEvent", new Consumer<ObjectMap<String>>() {
@Override
public void accept(ObjectMap<String> data) {
ExProxy.getInstance().getEventManager().fire(new SubSendCommandEvent((data.contains("player"))?data.getUUID("player"):null, data.getString("server"), data.getString("command")));
ExProxy.getInstance().getEventManager().fire(new SubSendCommandEvent((data.contains("player"))?data.getUUID("player"):null, data.getString("server"), data.getString("command"), (data.contains("target"))?data.getUUID("target"):null));
callback("SubSendCommandEvent", this);
}
});

View File

@ -41,7 +41,7 @@ public class SubProtocol extends SubDataProtocol {
ExProxy plugin = SubAPI.getInstance().getInternals();
setName("SubServers 2");
addVersion(new Version("2.16a+"));
addVersion(new Version("2.18a+"));
// 00-0F: Object Link Packets

View File

@ -544,8 +544,8 @@ public final class SubCommand implements SimpleCommand {
}
} else if (args[0].equalsIgnoreCase("cmd") || args[0].equalsIgnoreCase("command")) {
if (args.length > 1) {
selectServers(sender, args, 1, true, select -> {
if (select.subservers.length > 0) {
selectServers(sender, args, 1, false, select -> {
if (select.servers.length > 0) {
if (select.args.length > 2) {
StringBuilder builder = new StringBuilder(select.args[2]);
for (int i = 3; i < select.args.length; i++) {
@ -556,16 +556,16 @@ public final class SubCommand implements SimpleCommand {
Container<Integer> success = new Container<Integer>(0);
Container<Integer> running = new Container<Integer>(0);
AsyncConsolidator merge = new AsyncConsolidator(() -> {
if (running.value > 0) sender.sendMessage(Component.text("SubServers > " + running.value + " subserver"+((running.value == 1)?" was":"s were") + " offline"));
if (success.value > 0) sender.sendMessage(Component.text("SubServers > Sent command to " + success.value + " subserver"+((success.value == 1)?"":"s")));
if (running.value > 0) sender.sendMessage(Component.text("SubServers > " + running.value + " server"+((running.value == 1)?" was":"s were") + " offline"));
if (success.value > 0) sender.sendMessage(Component.text("SubServers > Sent command to " + success.value + " server"+((success.value == 1)?"":"s")));
});
for (SubServer server : select.subservers) {
for (Server server : select.servers) {
merge.reserve();
server.command(builder.toString(), response -> {
switch (response) {
case 3:
case 4:
sender.sendMessage(Component.text("SubServers > Subserver " + server.getName() + " has disappeared"));
sender.sendMessage(Component.text("SubServers > Server " + server.getName() + " has disappeared"));
break;
case 5:
running.value++;
@ -583,7 +583,7 @@ public final class SubCommand implements SimpleCommand {
}
});
} else {
sender.sendMessage(Component.text("Usage: " + label + " " + args[0].toLowerCase() + " <Subservers> <Command> [Args...]"));
sender.sendMessage(Component.text("Usage: " + label + " " + args[0].toLowerCase() + " <Servers> <Command> [Args...]"));
}
} else if (args[0].equalsIgnoreCase("create")) {
if (args.length > 3) {
@ -924,7 +924,7 @@ public final class SubCommand implements SimpleCommand {
" Restart Server: /sub restart <Subservers>",
" Stop Server: /sub stop <Subservers>",
" Terminate Server: /sub kill <Subservers>",
" Command Server: /sub cmd <Subservers> <Command> [Args...]",
" Command Server: /sub cmd <Servers> <Command> [Args...]",
" Create Server: /sub create <Name> <Host> <Template> [Version] [Port]",
" Update Server: /sub update <Subservers> [[Template] <Version>]",
" Remove Server: /sub delete <Subservers>",
@ -1093,7 +1093,8 @@ public final class SubCommand implements SimpleCommand {
args[0].equals("update") || args[0].equals("upgrade") ||
args[0].equals("remove") || args[0].equals("del") || args[0].equals("delete")) {
List<String> list = new ArrayList<String>();
RawServerSelection select = selectRawServers(null, args, 1, true);
boolean mode = !args[0].equals("cmd") && !args[0].equals("command");
RawServerSelection select = selectRawServers(null, args, 1, mode);
if (select.last != null) {
if (last.startsWith("::")) {
Map<String, Host> hosts = hostCache;
@ -1123,7 +1124,7 @@ public final class SubCommand implements SimpleCommand {
if (Arrays.binarySearch(select.selection, "*") < 0 && "*".startsWith(last)) list.add("*");
if (sender instanceof Player && Arrays.binarySearch(select.selection, ".") < 0 && ".".startsWith(last)) list.add(".");
for (ServerData server : subservers.values()) {
if (server instanceof SubServerData && Arrays.binarySearch(select.selection, server.getName().toLowerCase()) < 0 && server.getName().toLowerCase().startsWith(last)) list.add(Last + server.getName().substring(last.length()));
if ((!mode || server instanceof SubServerData) && Arrays.binarySearch(select.selection, server.getName().toLowerCase()) < 0 && server.getName().toLowerCase().startsWith(last)) list.add(Last + server.getName().substring(last.length()));
}
}
return list;