mirror of
https://github.com/ME1312/SubServers-2.git
synced 2024-11-22 10:15:52 +01:00
Corrections to legacy formatting
This commit is contained in:
parent
1c010ea9b2
commit
620db38e9b
@ -1,56 +0,0 @@
|
||||
package net.ME1312.SubServers.Bungee.Library.Compatibility;
|
||||
|
||||
import net.ME1312.Galaxi.Library.Container.Pair;
|
||||
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
import net.md_5.bungee.api.plugin.TabExecutor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Command Layout Class that implements all possible features (Base Version)
|
||||
*/
|
||||
public abstract class CommandX extends Command implements TabExecutor {
|
||||
|
||||
/**
|
||||
* Create a Command
|
||||
*
|
||||
* @param name Command Name
|
||||
*/
|
||||
public CommandX(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Command
|
||||
*
|
||||
* @param name Command Name
|
||||
* @param permission Command Permission
|
||||
* @param aliases Command Aliases
|
||||
*/
|
||||
public CommandX(String name, String permission, String... aliases) {
|
||||
super(name, permission, aliases);
|
||||
}
|
||||
|
||||
/**
|
||||
* Suggest Arguments
|
||||
*
|
||||
* @param sender Sender
|
||||
* @param args Arguments (including the final unfinished one)
|
||||
* @return An Error Message (if there was one, otherwise null) and a List of Suggestions
|
||||
*/
|
||||
public abstract Pair<String, List<String>> suggestArguments(CommandSender sender, String[] args);
|
||||
|
||||
/**
|
||||
* Override the BungeeCord Method of {@link #suggestArguments(CommandSender, String[])}
|
||||
*
|
||||
* @param sender Sender
|
||||
* @param args Arguments (including the final unfinished one)
|
||||
* @return A Collection of Suggestions
|
||||
*/
|
||||
@Override
|
||||
public Iterable<String> onTabComplete(CommandSender sender, String[] args) {
|
||||
return suggestArguments(sender, args).value();
|
||||
}
|
||||
}
|
@ -1,76 +0,0 @@
|
||||
package net.ME1312.SubServers.Bungee.Library.Compatibility.mc1_13;
|
||||
|
||||
import net.ME1312.Galaxi.Library.Container.ContainedPair;
|
||||
import net.ME1312.Galaxi.Library.Container.Pair;
|
||||
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Command Layout Class that implements all possible features (1.13 Version)
|
||||
*/
|
||||
public class CommandX extends net.ME1312.SubServers.Bungee.Library.Compatibility.CommandX/* implements TabValidator */ {
|
||||
public final net.ME1312.SubServers.Bungee.Library.Compatibility.CommandX command;
|
||||
|
||||
/**
|
||||
* Create a Command
|
||||
*
|
||||
* @param other CommandX from previous version
|
||||
*/
|
||||
public CommandX(net.ME1312.SubServers.Bungee.Library.Compatibility.CommandX other) {
|
||||
super(other.getName());
|
||||
command = other;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override BungeeCord Method for the previously used one
|
||||
*
|
||||
* @param sender Sender
|
||||
* @param args Arguments
|
||||
*/
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
command.execute(sender, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<String, List<String>> suggestArguments(CommandSender sender, String[] args) {
|
||||
return command.suggestArguments(sender, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate a Command (Override for custom)
|
||||
*
|
||||
* @param sender Sender
|
||||
* @param command Command to validate
|
||||
* @return Pair with a String error message and a Integer that represents where the command was deemed invalid
|
||||
*/
|
||||
public Pair<String, Integer> validateCommand(CommandSender sender, String command) {
|
||||
List<Pair<String, Integer>> split = new LinkedList<Pair<String, Integer>>();
|
||||
String cmd = command;
|
||||
int i;
|
||||
while ((i = cmd.indexOf((int) ' ')) < 0) {
|
||||
i++;
|
||||
String arg = cmd.substring(i);
|
||||
split.add(new ContainedPair<>(arg.contains(" ")?arg.substring(0, arg.indexOf((int) ' ')):arg, i));
|
||||
cmd = arg;
|
||||
}
|
||||
|
||||
List<String> args = new LinkedList<String>();
|
||||
Pair<String, Integer> response = null;
|
||||
i = 0;
|
||||
for (Pair<String, Integer> arg : split) {
|
||||
if (i > 0) {
|
||||
args.add(arg.key());
|
||||
Pair<String, List<String>> suggestions = suggestArguments(sender, args.toArray(new String[args.size() - 1]));
|
||||
if (suggestions.key() != null) response = new ContainedPair<>(suggestions.key(), arg.value());
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
// TODO Override the original validator method
|
||||
}
|
@ -11,7 +11,6 @@ import net.ME1312.Galaxi.Library.Version.Version;
|
||||
import net.ME1312.SubData.Server.ClientHandler;
|
||||
import net.ME1312.SubData.Server.SubDataClient;
|
||||
import net.ME1312.SubServers.Bungee.Host.*;
|
||||
import net.ME1312.SubServers.Bungee.Library.Compatibility.CommandX;
|
||||
import net.ME1312.SubServers.Bungee.Library.Compatibility.Galaxi.GalaxiInfo;
|
||||
import net.ME1312.SubServers.Bungee.Library.Compatibility.Logger;
|
||||
import net.ME1312.SubServers.Bungee.Network.Packet.PacketCheckPermission;
|
||||
@ -26,6 +25,7 @@ import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
import net.md_5.bungee.api.plugin.TabExecutor;
|
||||
import net.md_5.bungee.command.ConsoleCommandSender;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
@ -43,23 +43,13 @@ import static net.ME1312.SubServers.Bungee.Library.Compatibility.Galaxi.GalaxiCo
|
||||
* Plugin Command Class
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public final class SubCommand extends CommandX {
|
||||
public final class SubCommand extends Command implements TabExecutor {
|
||||
static HashMap<UUID, HashMap<ServerInfo, Pair<Long, Boolean>>> players = new HashMap<UUID, HashMap<ServerInfo, Pair<Long, Boolean>>>();
|
||||
private static Thread reload;
|
||||
private SubProxy plugin;
|
||||
private String label;
|
||||
|
||||
static Pair<SubCommand, CommandX> newInstance(SubProxy plugin, String command) {
|
||||
Pair<SubCommand, CommandX> cmd = new ContainedPair<>(new SubCommand(plugin, command), null);
|
||||
CommandX now = cmd.key();
|
||||
//if (plugin.api.getGameVersion()[plugin.api.getGameVersion().length - 1].compareTo(new Version("1.13")) >= 0) { // TODO Future Command Validator API?
|
||||
// now = new net.ME1312.SubServers.Bungee.Library.Compatibility.mc1_13.CommandX(cmd.name());
|
||||
//}
|
||||
cmd.value(now);
|
||||
return cmd;
|
||||
}
|
||||
|
||||
private SubCommand(SubProxy plugin, String command) {
|
||||
SubCommand(SubProxy plugin, String command) {
|
||||
super(command);
|
||||
this.plugin = plugin;
|
||||
this.label = '/' + command;
|
||||
@ -869,7 +859,7 @@ public final class SubCommand extends CommandX {
|
||||
* @return The validator's response and list of possible arguments
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Pair<String, List<String>> suggestArguments(CommandSender sender, String[] args) {
|
||||
public List<String> onTabComplete(CommandSender sender, String[] args) {
|
||||
String Last = (args.length > 0)?args[args.length - 1]:"";
|
||||
String last = Last.toLowerCase();
|
||||
|
||||
@ -893,7 +883,7 @@ public final class SubCommand extends CommandX {
|
||||
}));
|
||||
}
|
||||
}
|
||||
return new ContainedPair<>(null, Collections.emptyList());
|
||||
return Collections.emptyList();
|
||||
} else if (args.length <= 1) {
|
||||
List<String> cmds = new ArrayList<>();
|
||||
cmds.addAll(Arrays.asList("help", "list", "info", "status", "version", "start", "restart", "stop", "kill", "terminate", "cmd", "command", "create", "update", "upgrade"));
|
||||
@ -902,7 +892,7 @@ public final class SubCommand extends CommandX {
|
||||
for (String cmd : cmds) {
|
||||
if (cmd.startsWith(last)) list.add(Last + cmd.substring(last.length()));
|
||||
}
|
||||
return new ContainedPair<>((list.size() <= 0)?plugin.api.getLang("SubServers", "Command.Generic.Invalid-Subcommand").replace("$str$", args[0]):null, list);
|
||||
return list;
|
||||
} else {
|
||||
if (args[0].equals("info") || args[0].equals("status")) {
|
||||
ReturnRunnable<Collection<String>> getPlayers = () -> {
|
||||
@ -949,7 +939,7 @@ public final class SubCommand extends CommandX {
|
||||
if (!list.contains(player) && player.toLowerCase().startsWith(last))
|
||||
list.add(Last + player.substring(last.length()));
|
||||
}
|
||||
return new ContainedPair<>((list.size() <= 0)?plugin.api.getLang("SubServers", "Command.Info.Unknown").replace("$str$", args[0]):null, list);
|
||||
return list;
|
||||
} else if (args.length == 3) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
|
||||
@ -993,9 +983,9 @@ public final class SubCommand extends CommandX {
|
||||
}
|
||||
break;
|
||||
}
|
||||
return new ContainedPair<>((list.size() <= 0)?plugin.api.getLang("SubServers", "Command.Info.Unknown").replace("$str$", args[0]):null, list);
|
||||
return list;
|
||||
} else {
|
||||
return new ContainedPair<>(null, Collections.emptyList());
|
||||
return Collections.emptyList();
|
||||
}
|
||||
} else if (!(sender instanceof ProxiedPlayer) && (args[0].equals("reload") || args[0].equals("restore"))) {
|
||||
if (args[0].equals("reload")) {
|
||||
@ -1005,15 +995,15 @@ public final class SubCommand extends CommandX {
|
||||
for (String complete : completes) {
|
||||
if (complete.toLowerCase().startsWith(last)) list.add(Last + complete.substring(last.length()));
|
||||
}
|
||||
return new ContainedPair<>(null, list);
|
||||
return list;
|
||||
} else {
|
||||
return new ContainedPair<>(null, Collections.emptyList());
|
||||
return Collections.emptyList();
|
||||
}
|
||||
} else /* if (args[0].equals("restore")) */ {
|
||||
if (args.length == 2) {
|
||||
return new ContainedPair<>(null, Collections.singletonList("<Subserver>"));
|
||||
return Collections.singletonList("<Subserver>");
|
||||
} else {
|
||||
return new ContainedPair<>(null, Collections.emptyList());
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
} else if (args[0].equals("start") ||
|
||||
@ -1039,7 +1029,7 @@ public final class SubCommand extends CommandX {
|
||||
if (Arrays.binarySearch(select.selection, name.toLowerCase()) < 0 && name.toLowerCase().startsWith(last)) list.add(Last + name.substring(last.length()));
|
||||
}
|
||||
}
|
||||
return new ContainedPair<>((list.size() <= 0)?plugin.api.getLang("SubServers", "Command.Generic.Unknown-Host").replace("$str$", select.last):null, list);
|
||||
return list;
|
||||
} else if (last.startsWith(":")) {
|
||||
Map<String, List<Server>> groups = plugin.api.getGroups();
|
||||
if (groups.size() > 0) {
|
||||
@ -1050,7 +1040,7 @@ public final class SubCommand extends CommandX {
|
||||
if (Arrays.binarySearch(select.selection, group.toLowerCase()) < 0 && group.toLowerCase().startsWith(last)) list.add(Last + group.substring(last.length()));
|
||||
}
|
||||
}
|
||||
return new ContainedPair<>((list.size() <= 0)?plugin.api.getLang("SubServers", "Command.Generic.Unknown-Group").replace("$str$", select.last):null, list);
|
||||
return list;
|
||||
} else {
|
||||
Map<String, SubServer> subservers = plugin.api.getSubServers();
|
||||
if (subservers.size() > 0) {
|
||||
@ -1060,31 +1050,31 @@ public final class SubCommand extends CommandX {
|
||||
if (Arrays.binarySearch(select.selection, server.getName().toLowerCase()) < 0 && server.getName().toLowerCase().startsWith(last)) list.add(Last + server.getName().substring(last.length()));
|
||||
}
|
||||
}
|
||||
return new ContainedPair<>((list.size() <= 0)?plugin.api.getLang("SubServers", "Command.Generic.Unknown-SubServer").replace("$str$", select.last):null, list);
|
||||
return list;
|
||||
}
|
||||
} else if (args[0].equals("cmd") || args[0].equals("command")) {
|
||||
if (select.args.length == 3) {
|
||||
return new ContainedPair<>(null, Collections.singletonList("<Command>"));
|
||||
return Collections.singletonList("<Command>");
|
||||
} else {
|
||||
return new ContainedPair<>(null, Collections.singletonList("[Args...]"));
|
||||
return Collections.singletonList("[Args...]");
|
||||
}
|
||||
} else if (args[0].equals("update") || args[0].equals("upgrade")) {
|
||||
if (select.args.length == 3) {
|
||||
return new ContainedPair<>(null, Arrays.asList("[Template]", "[Version]"));
|
||||
return Arrays.asList("[Template]", "[Version]");
|
||||
} else if (select.args.length == 4) {
|
||||
return new ContainedPair<>(null, Collections.singletonList("<Version>"));
|
||||
return Collections.singletonList("<Version>");
|
||||
}
|
||||
}
|
||||
return new ContainedPair<>(null, Collections.emptyList());
|
||||
return Collections.emptyList();
|
||||
} else if (args[0].equals("create")) {
|
||||
if (args.length == 2) {
|
||||
return new ContainedPair<>(null, Collections.singletonList("<Name>"));
|
||||
return Collections.singletonList("<Name>");
|
||||
} else if (args.length == 3) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
for (Host host : plugin.api.getHosts().values()) {
|
||||
if (host.getName().toLowerCase().startsWith(last)) list.add(Last + host.getName().substring(last.length()));
|
||||
}
|
||||
return new ContainedPair<>((list.size() <= 0)?plugin.api.getLang("SubServers", "Command.Generic.Unknown-Host").replace("$str$", args[0]):null, list);
|
||||
return list;
|
||||
} else if (args.length == 4) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
Map<String, Host> hosts = plugin.api.getHosts();
|
||||
@ -1095,18 +1085,18 @@ public final class SubCommand extends CommandX {
|
||||
if (template.getName().toLowerCase().startsWith(last)) list.add(Last + template.getName().substring(last.length()));
|
||||
}
|
||||
}
|
||||
return new ContainedPair<>((list.size() <= 0)?plugin.api.getLang("SubServers", "Command.Creator.Invalid-Template").replace("$str$", args[0]):null, list);
|
||||
return list;
|
||||
} else if (args.length == 5) {
|
||||
return new ContainedPair<>(null, Collections.singletonList("[Version]"));
|
||||
return Collections.singletonList("[Version]");
|
||||
} else if (args.length == 6) {
|
||||
if (last.length() > 0) {
|
||||
if (Util.isException(() -> Integer.parseInt(last)) || Integer.parseInt(last) <= 0 || Integer.parseInt(last) > 65535) {
|
||||
return new ContainedPair<>(plugin.api.getLang("SubServers", "Command.Creator.Invalid-Port"), Collections.emptyList());
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
return new ContainedPair<>(null, Collections.singletonList("[Port]"));
|
||||
return Collections.singletonList("[Port]");
|
||||
} else {
|
||||
return new ContainedPair<>(null, Collections.emptyList());
|
||||
return Collections.emptyList();
|
||||
}
|
||||
} else if (sender instanceof ProxiedPlayer && (args[0].equals("tp") || args[0].equals("teleport"))) {
|
||||
if (args.length == 2 || args.length == 3) {
|
||||
@ -1135,12 +1125,12 @@ public final class SubCommand extends CommandX {
|
||||
for (Server server : plugin.api.getServers().values()) {
|
||||
if (server.getName().toLowerCase().startsWith(last)) list.add(Last + server.getName().substring(last.length()));
|
||||
}
|
||||
return new ContainedPair<>((list.size() <= 0)?plugin.api.getLang("SubServers", "Command.Generic.Unknown-Server").replace("$str$", args[0]):null, list);
|
||||
return list;
|
||||
} else {
|
||||
return new ContainedPair<>(null, Collections.emptyList());
|
||||
return Collections.emptyList();
|
||||
}
|
||||
} else {
|
||||
return new ContainedPair<>(plugin.api.getLang("SubServers", "Command.Generic.Invalid-Subcommand").replace("$str$", args[0]), Collections.emptyList());
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1148,9 +1138,9 @@ public final class SubCommand extends CommandX {
|
||||
/**
|
||||
* BungeeCord /server
|
||||
*/
|
||||
public static final class BungeeServer extends CommandX {
|
||||
public static final class BungeeServer extends Command implements TabExecutor {
|
||||
private SubProxy plugin;
|
||||
private BungeeServer(SubProxy plugin, String command) {
|
||||
BungeeServer(SubProxy plugin, String command) {
|
||||
super(command, "bungeecord.command.server");
|
||||
this.plugin = plugin;
|
||||
|
||||
@ -1165,16 +1155,6 @@ public final class SubCommand extends CommandX {
|
||||
);
|
||||
}
|
||||
|
||||
static Pair<BungeeServer, CommandX> newInstance(SubProxy plugin, String command) {
|
||||
Pair<BungeeServer, CommandX> cmd = new ContainedPair<>(new BungeeServer(plugin, command), null);
|
||||
CommandX now = cmd.key();
|
||||
//if (plugin.api.getGameVersion()[plugin.api.getGameVersion().length - 1].compareTo(new Version("1.13")) >= 0) { // TODO Future Command Validator API?
|
||||
// now = new net.ME1312.SubServers.Bungee.Library.Compatibility.mc1_13.CommandX(cmd.name());
|
||||
//}
|
||||
cmd.value(now);
|
||||
return cmd;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override /server
|
||||
*
|
||||
@ -1227,16 +1207,16 @@ public final class SubCommand extends CommandX {
|
||||
* @param args Arguments
|
||||
* @return The validator's response and list of possible arguments
|
||||
*/
|
||||
public Pair<String, List<String>> suggestArguments(CommandSender sender, String[] args) {
|
||||
public List<String> onTabComplete(CommandSender sender, String[] args) {
|
||||
if (args.length <= 1) {
|
||||
String last = (args.length > 0)?args[args.length - 1].toLowerCase():"";
|
||||
List<String> list = new ArrayList<String>();
|
||||
for (Server server : plugin.api.getServers().values()) {
|
||||
if (server.getName().toLowerCase().startsWith(last) && !server.isHidden()) list.add(server.getName());
|
||||
}
|
||||
return new ContainedPair<>((list.size() <= 0)?plugin.api.getLang("SubServers", "Bungee.Server.Invalid").replace("$str$", args[0]):null, list);
|
||||
return list;
|
||||
} else {
|
||||
return new ContainedPair<>(null, Collections.emptyList());
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -695,13 +695,13 @@ public final class SubProxy extends BungeeCommon implements Listener {
|
||||
|
||||
private void post() {
|
||||
if (!config.get().getMap("Settings").getRawStringList("Disabled-Overrides", Collections.emptyList()).contains("/server"))
|
||||
getPluginManager().registerCommand(plugin, SubCommand.BungeeServer.newInstance(this, "server").value());
|
||||
getPluginManager().registerCommand(plugin, new SubCommand.BungeeServer(this, "server"));
|
||||
if (!config.get().getMap("Settings").getRawStringList("Disabled-Overrides", Collections.emptyList()).contains("/glist"))
|
||||
getPluginManager().registerCommand(plugin, new SubCommand.BungeeList(this, "glist"));
|
||||
|
||||
getPluginManager().registerCommand(plugin, SubCommand.newInstance(this, "subservers").value());
|
||||
getPluginManager().registerCommand(plugin, SubCommand.newInstance(this, "subserver").value());
|
||||
getPluginManager().registerCommand(plugin, SubCommand.newInstance(this, "sub").value());
|
||||
getPluginManager().registerCommand(plugin, new SubCommand(this, "subservers"));
|
||||
getPluginManager().registerCommand(plugin, new SubCommand(this, "subserver"));
|
||||
getPluginManager().registerCommand(plugin, new SubCommand(this, "sub"));
|
||||
GalaxiCommand.group(SubCommand.class);
|
||||
|
||||
if (getReconnectHandler() != null && getReconnectHandler().getClass().equals(SmartFallback.class))
|
||||
|
@ -1,8 +1,6 @@
|
||||
package net.ME1312.SubServers.Client.Bukkit.Graphic;
|
||||
|
||||
import net.ME1312.Galaxi.Library.Container.ContainedPair;
|
||||
import net.ME1312.Galaxi.Library.Container.Container;
|
||||
import net.ME1312.Galaxi.Library.Container.Pair;
|
||||
import net.ME1312.Galaxi.Library.Container.Value;
|
||||
import net.ME1312.Galaxi.Library.Version.Version;
|
||||
import net.ME1312.SubServers.Client.Bukkit.SubPlugin;
|
||||
@ -70,14 +68,32 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
windowHistory.remove(windowHistory.size() - 1);
|
||||
reopen();
|
||||
}
|
||||
|
||||
ItemStack createItem(String material, String name, short damage) {
|
||||
/*
|
||||
private static final String[] STAINED_GLASS_INDEX = new String[] {
|
||||
"WHITE_STAINED_GLASS_PANE",
|
||||
"ORANGE_STAINED_GLASS_PANE",
|
||||
"MAGENTA_STAINED_GLASS_PANE",
|
||||
"LIGHT_BLUE_STAINED_GLASS_PANE",
|
||||
"YELLOW_STAINED_GLASS_PANE",
|
||||
"LIME_STAINED_GLASS_PANE",
|
||||
"PINK_STAINED_GLASS_PANE",
|
||||
"GRAY_STAINED_GLASS_PANE",
|
||||
"LIGHT_GRAY_STAINED_GLASS_PANE",
|
||||
"CYAN_STAINED_GLASS_PANE",
|
||||
"PURPLE_STAINED_GLASS_PANE",
|
||||
"BLUE_STAINED_GLASS_PANE",
|
||||
"BROWN_STAINED_GLASS_PANE",
|
||||
"GREEN_STAINED_GLASS_PANE",
|
||||
"RED_STAINED_GLASS_PANE",
|
||||
"BLACK_STAINED_GLASS_PANE"
|
||||
}; */
|
||||
private ItemStack color(int color) {
|
||||
try {
|
||||
if (plugin.api.getGameVersion().compareTo(new Version("1.13")) < 0) {
|
||||
return ItemStack.class.getConstructor(Material.class, int.class, short.class).newInstance(Material.valueOf(material), 1, damage);
|
||||
} else {
|
||||
return new ItemStack((Material) Material.class.getMethod("getMaterial", String.class, boolean.class).invoke(null, name, false), 1);
|
||||
}
|
||||
// if (plugin.api.getGameVersion().compareTo(new Version("1.13")) < 0) {
|
||||
return new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) color);
|
||||
// } else {
|
||||
// return new ItemStack((Material) Material.class.getMethod("getMaterial", String.class, boolean.class).invoke(null, STAINED_GLASS_INDEX[color], false), 1);
|
||||
// }
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
@ -97,7 +113,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
|
||||
ItemStack block;
|
||||
ItemMeta blockMeta;
|
||||
ItemStack div = createItem("STAINED_GLASS_PANE", "BLACK_STAINED_GLASS_PANE", (short) 15);
|
||||
ItemStack div = color(15);
|
||||
ItemMeta divMeta = div.getItemMeta();
|
||||
divMeta.setDisplayName(ChatColor.RESET.toString());
|
||||
div.setItemMeta(divMeta);
|
||||
@ -109,7 +125,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
int area = (count % 9 == 0) ? count : ((count / 9) + 1) * 9;
|
||||
|
||||
Inventory inv = Bukkit.createInventory(null, 18 + area, plugin.api.getLang("SubServers", "Interface.Host-Menu.Title"));
|
||||
block = createItem("STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE", (short) 7);
|
||||
block = color(7);
|
||||
block.setItemMeta(divMeta);
|
||||
while (i < area) {
|
||||
inv.setItem(i, block);
|
||||
@ -119,16 +135,16 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
i = ((count < 9) ? ((9 - count) / 2) : 0);
|
||||
|
||||
boolean even = (count & 1) == 0 && count < 9;
|
||||
Pair<String, Short> enabled, disabled;
|
||||
int enabled, disabled;
|
||||
|
||||
for (Host host : index) {
|
||||
if (index.indexOf(host) >= min && index.indexOf(host) <= max) {
|
||||
if (even && (i == 4 || i == 13 || i == 22 || i == 31)) inv.setItem(i++, adiv);
|
||||
enabled = (((i & 1) == 0) ? new ContainedPair<>("BLUE_STAINED_GLASS_PANE", (short) 3) : new ContainedPair<>("LIGHT_BLUE_STAINED_GLASS_PANE", (short) 11));
|
||||
disabled = (((i & 1) == 0) ? new ContainedPair<>("MAGENTA_STAINED_GLASS_PANE", (short) 2) : new ContainedPair<>("RED_STAINED_GLASS_PANE", (short) 14));
|
||||
enabled = (((i & 1) == 0)? 3 : 11);
|
||||
disabled = (((i & 1) == 0)? 2 : 14);
|
||||
|
||||
if (host.isAvailable() && host.isEnabled()) {
|
||||
block = createItem("STAINED_GLASS_PANE", enabled.key(), enabled.value());
|
||||
block = color(enabled);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(ChatColor.AQUA + host.getDisplayName());
|
||||
LinkedList<String> lore = new LinkedList<String>();
|
||||
@ -138,7 +154,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
if (plugin.config.get().getMap("Settings").getBoolean("Show-Addresses", false)) lore.add(ChatColor.WHITE + host.getAddress().getHostAddress());
|
||||
blockMeta.setLore(lore);
|
||||
} else {
|
||||
block = createItem("STAINED_GLASS_PANE", disabled.key(), disabled.value());
|
||||
block = color(disabled);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(ChatColor.RED + host.getDisplayName());
|
||||
LinkedList<String> lore = new LinkedList<String>();
|
||||
@ -163,7 +179,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
}
|
||||
|
||||
if (index.size() == 0) {
|
||||
block = createItem("STAINED_GLASS_PANE", "RED_STAINED_GLASS_PANE", (short) 14);
|
||||
block = color(14);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.Host-Menu.No-Hosts"));
|
||||
block.setItemMeta(blockMeta);
|
||||
@ -180,7 +196,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
i = inv.getSize() - 9;
|
||||
|
||||
if (min != 0) {
|
||||
block = createItem("STAINED_GLASS_PANE", "YELLOW_STAINED_GLASS_PANE", (short) 4);
|
||||
block = color(4);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.Generic.Back-Arrow"));
|
||||
block.setItemMeta(blockMeta);
|
||||
@ -189,11 +205,11 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
} else i += 2;
|
||||
i++;
|
||||
if (groups.keySet().size() <= 0) {
|
||||
block = createItem("STAINED_GLASS_PANE", "LIME_STAINED_GLASS_PANE", (short) 5);
|
||||
block = color(5);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.Host-Menu.Server-Menu"));
|
||||
} else {
|
||||
block = createItem("STAINED_GLASS_PANE", "ORANGE_STAINED_GLASS_PANE", (short) 1);
|
||||
block = color(1);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.Host-Menu.Group-Menu"));
|
||||
}
|
||||
@ -203,7 +219,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
inv.setItem(i++, block);
|
||||
i++;
|
||||
if (index.size() - 1 > max) {
|
||||
block = createItem("STAINED_GLASS_PANE", "YELLOW_STAINED_GLASS_PANE", (short) 4);
|
||||
block = color(4);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.Generic.Next-Arrow"));
|
||||
block.setItemMeta(blockMeta);
|
||||
@ -228,7 +244,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
|
||||
ItemStack block;
|
||||
ItemMeta blockMeta;
|
||||
ItemStack div = createItem("STAINED_GLASS_PANE", "BLACK_STAINED_GLASS_PANE", (short) 15);
|
||||
ItemStack div = color(15);
|
||||
ItemMeta divMeta = div.getItemMeta();
|
||||
divMeta.setDisplayName(ChatColor.RESET.toString());
|
||||
div.setItemMeta(divMeta);
|
||||
@ -243,16 +259,16 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
|
||||
Player player = Bukkit.getPlayer(this.player);
|
||||
if (!(player.hasPermission("subservers.host.*.*") || player.hasPermission("subservers.host.*.create") || player.hasPermission("subservers.host." + name.toLowerCase() + ".*") || player.hasPermission("subservers.host." + name.toLowerCase() + ".create"))) {
|
||||
block = createItem("STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE", (short) 7);
|
||||
block = color(7);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.Host-Admin.Creator")));
|
||||
blockMeta.setLore(Arrays.asList(plugin.api.getLang("SubServers", "Interface.Generic.Invalid-Permission").replace("$str$", "subservers.host.create." + name.toLowerCase())));
|
||||
} else if (!host.isAvailable() || !host.isEnabled()) {
|
||||
block = createItem("STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE", (short) 7);
|
||||
block = color(7);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.Host-Admin.Creator")));
|
||||
} else {
|
||||
block = createItem("STAINED_GLASS_PANE", "YELLOW_STAINED_GLASS_PANE", (short) 4);
|
||||
block = color(4);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.Host-Admin.Creator"));
|
||||
}
|
||||
@ -264,7 +280,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
inv.setItem(11, block);
|
||||
inv.setItem(12, block);
|
||||
|
||||
block = createItem("STAINED_GLASS_PANE", "BLUE_STAINED_GLASS_PANE", (short) 3);
|
||||
block = color(3);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.Host-Admin.SubServers"));
|
||||
block.setItemMeta(blockMeta);
|
||||
@ -278,7 +294,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
if (!host.isAvailable() || !host.isEnabled() || hostPlugins.size() <= 0) {
|
||||
block = div;
|
||||
} else {
|
||||
block = createItem("STAINED_GLASS_PANE", "BLUE_STAINED_GLASS_PANE", (short) 11);
|
||||
block = color(11);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.Host-Admin.Plugins"));
|
||||
block.setItemMeta(blockMeta);
|
||||
@ -287,7 +303,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
inv.setItem(28, block);
|
||||
|
||||
if (host.isAvailable() && host.isEnabled()) {
|
||||
block = createItem("STAINED_GLASS_PANE", "BLUE_STAINED_GLASS_PANE", (short) 11);
|
||||
block = color(11);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(ChatColor.AQUA + host.getDisplayName());
|
||||
LinkedList<String> lore = new LinkedList<String>();
|
||||
@ -297,7 +313,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
if (plugin.config.get().getMap("Settings").getBoolean("Show-Addresses", false)) lore.add(ChatColor.WHITE + host.getAddress().getHostAddress());
|
||||
blockMeta.setLore(lore);
|
||||
} else {
|
||||
block = createItem("STAINED_GLASS_PANE", "RED_STAINED_GLASS_PANE", (short) 14);
|
||||
block = color(14);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(ChatColor.RED + host.getDisplayName());
|
||||
LinkedList<String> lore = new LinkedList<String>();
|
||||
@ -315,7 +331,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
|
||||
|
||||
if (hasHistory()) {
|
||||
block = createItem("STAINED_GLASS_PANE", "RED_STAINED_GLASS_PANE", (short) 14);
|
||||
block = color(14);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.Generic.Back"));
|
||||
block.setItemMeta(blockMeta);
|
||||
@ -342,7 +358,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
setDownloading(null);
|
||||
ItemStack block;
|
||||
ItemMeta blockMeta;
|
||||
ItemStack div = createItem("STAINED_GLASS_PANE", "BLACK_STAINED_GLASS_PANE", (short) 15);
|
||||
ItemStack div = color(15);
|
||||
ItemMeta divMeta = div.getItemMeta();
|
||||
divMeta.setDisplayName(ChatColor.RESET.toString());
|
||||
div.setItemMeta(divMeta);
|
||||
@ -356,11 +372,11 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
}
|
||||
|
||||
if (options.getName() == null) {
|
||||
block = createItem("STAINED_GLASS_PANE", "RED_STAINED_GLASS_PANE", (short) 14);
|
||||
block = color(14);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(ChatColor.RED + plugin.api.getLang("SubServers", "Interface.Host-Creator.Edit-Name"));
|
||||
} else {
|
||||
block = createItem("STAINED_GLASS_PANE", "LIME_STAINED_GLASS_PANE", (short) 5);
|
||||
block = color(5);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(ChatColor.GREEN + plugin.api.getLang("SubServers", "Interface.Host-Creator.Edit-Name"));
|
||||
blockMeta.setLore(Arrays.asList(ChatColor.GRAY + options.getName()));
|
||||
@ -370,7 +386,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
inv.setItem(11, block);
|
||||
inv.setItem(12, block);
|
||||
|
||||
block = createItem("STAINED_GLASS_PANE", "LIME_STAINED_GLASS_PANE", (short) 5);
|
||||
block = color(5);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(ChatColor.GREEN + plugin.api.getLang("SubServers", "Interface.Host-Creator.Edit-Port"));
|
||||
blockMeta.setLore(Arrays.asList(ChatColor.GRAY.toString() + ((options.getPort() == null)?"Auto Select":options.getPort())));
|
||||
@ -380,11 +396,11 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
inv.setItem(16, block);
|
||||
|
||||
if (options.getTemplate() == null) {
|
||||
block = createItem("STAINED_GLASS_PANE", "RED_STAINED_GLASS_PANE", (short) 14);
|
||||
block = color(14);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(ChatColor.RED + plugin.api.getLang("SubServers", "Interface.Host-Creator.Edit-Template"));
|
||||
} else {
|
||||
block = createItem("STAINED_GLASS_PANE", "LIME_STAINED_GLASS_PANE", (short) 5);
|
||||
block = color(5);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(ChatColor.GREEN + plugin.api.getLang("SubServers", "Interface.Host-Creator.Edit-Template"));
|
||||
blockMeta.setLore(Arrays.asList(ChatColor.GRAY + options.getTemplate()));
|
||||
@ -395,11 +411,11 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
inv.setItem(30, block);
|
||||
|
||||
if (options.getVersion() == null && (options.getTemplate() == null || host.getCreator().getTemplate(options.getTemplate()).requiresVersion())) {
|
||||
block = createItem("STAINED_GLASS_PANE", "RED_STAINED_GLASS_PANE", (short) 14);
|
||||
block = color(14);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(ChatColor.RED + plugin.api.getLang("SubServers", "Interface.Host-Creator.Edit-Version"));
|
||||
} else {
|
||||
block = createItem("STAINED_GLASS_PANE", "LIME_STAINED_GLASS_PANE", (short) 5);
|
||||
block = color(5);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(ChatColor.GREEN + plugin.api.getLang("SubServers", "Interface.Host-Creator.Edit-Version"));
|
||||
blockMeta.setLore(Arrays.asList(ChatColor.GRAY + ((options.getVersion() == null)?"Unspecified":"Minecraft "+options.getVersion().toString())));
|
||||
@ -410,12 +426,12 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
inv.setItem(34, block);
|
||||
|
||||
if (!options.hasHistory()) {
|
||||
block = createItem("STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE", (short) 7);
|
||||
block = color(7);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(ChatColor.GRAY + ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.Generic.Undo")));
|
||||
block.setItemMeta(blockMeta);
|
||||
} else {
|
||||
block = createItem("STAINED_GLASS_PANE", "ORANGE_STAINED_GLASS_PANE", (short) 1);
|
||||
block = color(1);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.Generic.Undo"));
|
||||
block.setItemMeta(blockMeta);
|
||||
@ -425,13 +441,13 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
inv.setItem(46, block);
|
||||
|
||||
if (options.getName() == null || options.getTemplate() == null || (options.getVersion() == null && host.getCreator().getTemplate(options.getTemplate()).requiresVersion())) {
|
||||
block = createItem("STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE", (short) 7);
|
||||
block = color(7);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(ChatColor.GRAY + ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.Host-Creator.Submit")));
|
||||
blockMeta.setLore(Arrays.asList(plugin.api.getLang("SubServers", "Interface.Host-Creator.Form-Incomplete")));
|
||||
block.setItemMeta(blockMeta);
|
||||
} else {
|
||||
block = createItem("STAINED_GLASS_PANE", "YELLOW_STAINED_GLASS_PANE", (short) 4);
|
||||
block = color(4);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.Host-Creator.Submit"));
|
||||
block.setItemMeta(blockMeta);
|
||||
@ -442,7 +458,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
inv.setItem(50, block);
|
||||
|
||||
if (hasHistory()) {
|
||||
block = createItem("STAINED_GLASS_PANE", "RED_STAINED_GLASS_PANE", (short) 14);
|
||||
block = color(14);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.Generic.Back"));
|
||||
block.setItemMeta(blockMeta);
|
||||
@ -474,7 +490,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
|
||||
ItemStack block;
|
||||
ItemMeta blockMeta;
|
||||
ItemStack div = createItem("STAINED_GLASS_PANE", "BLACK_STAINED_GLASS_PANE", (short) 15);
|
||||
ItemStack div = color(15);
|
||||
ItemMeta divMeta = div.getItemMeta();
|
||||
divMeta.setDisplayName(ChatColor.RESET.toString());
|
||||
div.setItemMeta(divMeta);
|
||||
@ -486,7 +502,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
int area = (count % 9 == 0)?count: ((count / 9) + 1) * 9;
|
||||
|
||||
Inventory inv = Bukkit.createInventory(null, 18 + area, plugin.api.getLang("SubServers", "Interface.Host-Creator.Edit-Template.Title").replace("$str$", host.getDisplayName()));
|
||||
block = createItem("STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE", (short) 7);
|
||||
block = color(7);
|
||||
block.setItemMeta(divMeta);
|
||||
while (i < area) {
|
||||
inv.setItem(i, block);
|
||||
@ -521,7 +537,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
}
|
||||
|
||||
if (index.size() == 0) {
|
||||
block = createItem("STAINED_GLASS_PANE", "RED_STAINED_GLASS_PANE", (short) 14);
|
||||
block = color(14);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.Host-Creator.Edit-Template.No-Templates"));
|
||||
block.setItemMeta(blockMeta);
|
||||
@ -538,7 +554,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
i = inv.getSize() - 9;
|
||||
|
||||
if (min != 0) {
|
||||
block = createItem("STAINED_GLASS_PANE", "YELLOW_STAINED_GLASS_PANE", (short) 4);
|
||||
block = color(4);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.Generic.Back-Arrow"));
|
||||
block.setItemMeta(blockMeta);
|
||||
@ -546,7 +562,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
inv.setItem(i++, block);
|
||||
} else i += 2;
|
||||
i++;
|
||||
block = createItem("STAINED_GLASS_PANE", "RED_STAINED_GLASS_PANE", (short) 14);
|
||||
block = color(14);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.Generic.Back"));
|
||||
block.setItemMeta(blockMeta);
|
||||
@ -555,7 +571,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
inv.setItem(i++, block);
|
||||
i++;
|
||||
if (index.size() - 1 > max) {
|
||||
block = createItem("STAINED_GLASS_PANE", "YELLOW_STAINED_GLASS_PANE", (short) 4);
|
||||
block = color(4);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.Generic.Next-Arrow"));
|
||||
block.setItemMeta(blockMeta);
|
||||
@ -587,7 +603,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
|
||||
ItemStack block;
|
||||
ItemMeta blockMeta;
|
||||
ItemStack div = createItem("STAINED_GLASS_PANE", "BLACK_STAINED_GLASS_PANE", (short) 15);
|
||||
ItemStack div = color(15);
|
||||
ItemMeta divMeta = div.getItemMeta();
|
||||
divMeta.setDisplayName(ChatColor.RESET.toString());
|
||||
div.setItemMeta(divMeta);
|
||||
@ -599,7 +615,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
int area = (count % 9 == 0) ? count : ((count / 9) + 1) * 9;
|
||||
|
||||
Inventory inv = Bukkit.createInventory(null, 18 + area, plugin.api.getLang("SubServers", "Interface.Host-Plugin.Title").replace("$str$", host.getDisplayName()));
|
||||
block = createItem("STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE", (short) 7);
|
||||
block = color(7);
|
||||
block.setItemMeta(divMeta);
|
||||
while (i < area) {
|
||||
inv.setItem(i, block);
|
||||
@ -627,7 +643,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
}
|
||||
|
||||
if (renderers.size() == 0) {
|
||||
block = createItem("STAINED_GLASS_PANE", "RED_STAINED_GLASS_PANE", (short) 14);
|
||||
block = color(14);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.Host-Plugin.No-Plugins"));
|
||||
block.setItemMeta(blockMeta);
|
||||
@ -644,7 +660,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
i = inv.getSize() - 9;
|
||||
|
||||
if (min != 0) {
|
||||
block = createItem("STAINED_GLASS_PANE", "YELLOW_STAINED_GLASS_PANE", (short) 4);
|
||||
block = color(4);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.Generic.Back-Arrow"));
|
||||
block.setItemMeta(blockMeta);
|
||||
@ -653,7 +669,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
} else i += 2;
|
||||
i++;
|
||||
if (hasHistory()) {
|
||||
block = createItem("STAINED_GLASS_PANE", "RED_STAINED_GLASS_PANE", (short) 14);
|
||||
block = color(14);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.Generic.Back"));
|
||||
block.setItemMeta(blockMeta);
|
||||
@ -663,7 +679,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
i++;
|
||||
}
|
||||
if (renderers.size() - 1 > max) {
|
||||
block = createItem("STAINED_GLASS_PANE", "YELLOW_STAINED_GLASS_PANE", (short) 4);
|
||||
block = color(4);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.Generic.Next-Arrow"));
|
||||
block.setItemMeta(blockMeta);
|
||||
@ -690,7 +706,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
|
||||
ItemStack block;
|
||||
ItemMeta blockMeta;
|
||||
ItemStack div = createItem("STAINED_GLASS_PANE", "BLACK_STAINED_GLASS_PANE", (short) 15);
|
||||
ItemStack div = color(15);
|
||||
ItemMeta divMeta = div.getItemMeta();
|
||||
divMeta.setDisplayName(ChatColor.RESET.toString());
|
||||
div.setItemMeta(divMeta);
|
||||
@ -702,7 +718,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
int area = (count % 9 == 0) ? count : ((count / 9) + 1) * 9;
|
||||
|
||||
Inventory inv = Bukkit.createInventory(null, 18 + area, plugin.api.getLang("SubServers", "Interface.Group-Menu.Title"));
|
||||
block = createItem("STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE", (short) 7);
|
||||
block = color(7);
|
||||
block.setItemMeta(divMeta);
|
||||
while (i < area) {
|
||||
inv.setItem(i, block);
|
||||
@ -712,14 +728,14 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
i = ((count < 9) ? ((9 - count) / 2) : 0);
|
||||
|
||||
boolean even = (count & 1) == 0 && count < 9;
|
||||
Pair<String, Short> color;
|
||||
int color;
|
||||
|
||||
for (String group : index) {
|
||||
if (index.indexOf(group) >= min && index.indexOf(group) <= max) {
|
||||
if (even && (i == 4 || i == 13 || i == 22 || i == 31)) inv.setItem(i++, adiv);
|
||||
color = (((i & 1) == 0) ? new ContainedPair<>("ORANGE_STAINED_GLASS_PANE", (short) 1) : new ContainedPair<>("YELLOW_STAINED_GLASS_PANE", (short) 4));
|
||||
color = (((i & 1) == 0)? 1 : 4);
|
||||
|
||||
block = createItem("STAINED_GLASS_PANE", color.key(), color.value());
|
||||
block = color(color);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(ChatColor.GOLD + group);
|
||||
LinkedList<String> lore = new LinkedList<String>();
|
||||
@ -739,7 +755,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
}
|
||||
|
||||
if (index.size() == 0) {
|
||||
block = createItem("STAINED_GLASS_PANE", "RED_STAINED_GLASS_PANE", (short) 14);
|
||||
block = color(14);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.Group-Menu.No-Groups"));
|
||||
block.setItemMeta(blockMeta);
|
||||
@ -756,7 +772,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
i = inv.getSize() - 9;
|
||||
|
||||
if (min != 0) {
|
||||
block = createItem("STAINED_GLASS_PANE", "YELLOW_STAINED_GLASS_PANE", (short) 4);
|
||||
block = color(4);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.Generic.Back-Arrow"));
|
||||
block.setItemMeta(blockMeta);
|
||||
@ -764,7 +780,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
inv.setItem(i++, block);
|
||||
} else i += 2;
|
||||
i++;
|
||||
block = createItem("STAINED_GLASS_PANE", "LIME_STAINED_GLASS_PANE", (short) 5);
|
||||
block = color(5);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.Group-Menu.Server-Menu"));
|
||||
block.setItemMeta(blockMeta);
|
||||
@ -773,7 +789,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
inv.setItem(i++, block);
|
||||
i++;
|
||||
if (index.size() - 1 > max) {
|
||||
block = createItem("STAINED_GLASS_PANE", "YELLOW_STAINED_GLASS_PANE", (short) 4);
|
||||
block = color(4);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.Generic.Next-Arrow"));
|
||||
block.setItemMeta(blockMeta);
|
||||
@ -801,7 +817,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
|
||||
ItemStack block;
|
||||
ItemMeta blockMeta;
|
||||
ItemStack div = createItem("STAINED_GLASS_PANE", "BLACK_STAINED_GLASS_PANE", (short) 15);
|
||||
ItemStack div = color(15);
|
||||
ItemMeta divMeta = div.getItemMeta();
|
||||
divMeta.setDisplayName(ChatColor.RESET.toString());
|
||||
div.setItemMeta(divMeta);
|
||||
@ -813,7 +829,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
int area = (count % 9 == 0) ? count : ((count / 9) + 1) * 9;
|
||||
|
||||
Inventory inv = Bukkit.createInventory(null, 18 + area, (host == null)?((group == null)?plugin.api.getLang("SubServers", "Interface.Server-Menu.Title"):plugin.api.getLang("SubServers", "Interface.Group-SubServer.Title").replace("$str$", group)):plugin.api.getLang("SubServers", "Interface.Host-SubServer.Title").replace("$str$", hostname.value()));
|
||||
block = createItem("STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE", (short) 7);
|
||||
block = color(7);
|
||||
block.setItemMeta(divMeta);
|
||||
while (i < area) {
|
||||
inv.setItem(i, block);
|
||||
@ -823,19 +839,19 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
i = ((count < 9) ? ((9 - count) / 2) : 0);
|
||||
|
||||
boolean even = (count & 1) == 0 && count < 9;
|
||||
Pair<String, Short> external, online, temp, offline, disabled;
|
||||
int external, online, temp, offline, disabled;
|
||||
|
||||
for (Server server : servers) {
|
||||
if (servers.indexOf(server) >= min && servers.indexOf(server) <= max) {
|
||||
if (even && (i == 4 || i == 13 || i == 22 || i == 31)) inv.setItem(i++, adiv);
|
||||
external = (((i & 1) == 0) ? new ContainedPair<>("WHITE_STAINED_GLASS_PANE", (short) 0) : new ContainedPair<>("LIGHT_GRAY_STAINED_GLASS_PANE", (short) 8));
|
||||
online = (((i & 1) == 0) ? new ContainedPair<>("LIME_STAINED_GLASS_PANE", (short) 5) : new ContainedPair<>("GREEN_STAINED_GLASS_PANE", (short) 13));
|
||||
temp = (((i & 1) == 0) ? new ContainedPair<>("LIGHT_BLUE_STAINED_GLASS_PANE", (short) 3) : new ContainedPair<>("BLUE_STAINED_GLASS_PANE", (short) 11));
|
||||
offline = (((i & 1) == 0) ? new ContainedPair<>("YELLOW_STAINED_GLASS_PANE", (short) 4) : new ContainedPair<>("ORANGE_STAINED_GLASS_PANE", (short) 1));
|
||||
disabled = (((i & 1) == 0) ? new ContainedPair<>("MAGENTA_STAINED_GLASS_PANE", (short) 2) : new ContainedPair<>("RED_STAINED_GLASS_PANE", (short) 14));
|
||||
external = (((i & 1) == 0)? 0 : 8);
|
||||
online = (((i & 1) == 0)? 5 : 13);
|
||||
temp = (((i & 1) == 0)? 3 : 11);
|
||||
offline = (((i & 1) == 0)? 4 : 1);
|
||||
disabled = (((i & 1) == 0)? 2 : 14);
|
||||
|
||||
if (!(server instanceof SubServer)) {
|
||||
block = createItem("STAINED_GLASS_PANE", external.key(), external.value());
|
||||
block = color(external);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(ChatColor.WHITE + server.getDisplayName());
|
||||
LinkedList<String> lore = new LinkedList<String>();
|
||||
@ -847,8 +863,8 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
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()) {
|
||||
Pair<String, Short> blockinfo = (((SubServer) server).getStopAction() == SubServer.StopAction.REMOVE_SERVER || ((SubServer) server).getStopAction() == SubServer.StopAction.RECYCLE_SERVER || ((SubServer) server).getStopAction() == SubServer.StopAction.DELETE_SERVER)?temp:online;
|
||||
block = createItem("STAINED_GLASS_PANE", blockinfo.key(), blockinfo.value());
|
||||
int blocktype = (((SubServer) server).getStopAction() == SubServer.StopAction.REMOVE_SERVER || ((SubServer) server).getStopAction() == SubServer.StopAction.RECYCLE_SERVER || ((SubServer) server).getStopAction() == SubServer.StopAction.DELETE_SERVER)?temp:online;
|
||||
block = color(blocktype);
|
||||
blockMeta = block.getItemMeta();
|
||||
LinkedList<String> lore = new LinkedList<String>();
|
||||
if (!server.getName().equals(server.getDisplayName()))
|
||||
@ -861,7 +877,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
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).isAvailable() && ((SubServer) server).isEnabled() && ((SubServer) server).getCurrentIncompatibilities().size() == 0) {
|
||||
block = createItem("STAINED_GLASS_PANE", offline.key(), offline.value());
|
||||
block = color(offline);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(ChatColor.YELLOW + server.getDisplayName());
|
||||
LinkedList<String> lore = new LinkedList<String>();
|
||||
@ -871,7 +887,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
lore.add(ChatColor.WHITE + ((plugin.config.get().getMap("Settings").getBoolean("Show-Addresses", false))?server.getAddress().getAddress().getHostAddress()+':':"") + server.getAddress().getPort());
|
||||
blockMeta.setLore(lore);
|
||||
} else {
|
||||
block = createItem("STAINED_GLASS_PANE", disabled.key(), disabled.value());
|
||||
block = color(disabled);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(ChatColor.RED + server.getDisplayName());
|
||||
LinkedList<String> lore = new LinkedList<String>();
|
||||
@ -903,7 +919,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
}
|
||||
|
||||
if (servers.size() == 0) {
|
||||
block = createItem("STAINED_GLASS_PANE", "RED_STAINED_GLASS_PANE", (short) 14);
|
||||
block = color(14);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.Server-Menu.No-Servers"));
|
||||
block.setItemMeta(blockMeta);
|
||||
@ -920,7 +936,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
i = inv.getSize() - 9;
|
||||
|
||||
if (min != 0) {
|
||||
block = createItem("STAINED_GLASS_PANE", "YELLOW_STAINED_GLASS_PANE", (short) 4);
|
||||
block = color(4);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.Generic.Back-Arrow"));
|
||||
block.setItemMeta(blockMeta);
|
||||
@ -929,7 +945,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
} else i += 2;
|
||||
i++;
|
||||
if (host == null || group == null || hasHistory()) {
|
||||
block = createItem("STAINED_GLASS_PANE", ((host == null && group == null)?"BLUE_STAINED_GLASS_PANE":"RED_STAINED_GLASS_PANE"), (short) ((host == null && group == null)?11:14));
|
||||
block = color(((host == null && group == null)? 11 : 14));
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName((host == null && group == null)?plugin.api.getLang("SubServers", "Interface.Server-Menu.Host-Menu"):plugin.api.getLang("SubServers", "Interface.Generic.Back"));
|
||||
block.setItemMeta(blockMeta);
|
||||
@ -939,7 +955,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
i++;
|
||||
}
|
||||
if (servers.size() - 1 > max) {
|
||||
block = createItem("STAINED_GLASS_PANE", "YELLOW_STAINED_GLASS_PANE", (short) 4);
|
||||
block = color(4);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.Generic.Next-Arrow"));
|
||||
block.setItemMeta(blockMeta);
|
||||
@ -992,7 +1008,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
lastVisitedObjects[0] = subserver;
|
||||
ItemStack block;
|
||||
ItemMeta blockMeta;
|
||||
ItemStack div = createItem("STAINED_GLASS_PANE", "BLACK_STAINED_GLASS_PANE", (short) 15);
|
||||
ItemStack div = color(15);
|
||||
ItemMeta divMeta = div.getItemMeta();
|
||||
divMeta.setDisplayName(ChatColor.RESET.toString());
|
||||
div.setItemMeta(divMeta);
|
||||
@ -1009,12 +1025,12 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
Player player = Bukkit.getPlayer(this.player);
|
||||
if (subserver.isRunning()) {
|
||||
if (!permits(subserver, player, "subservers.subserver.%.*", "subservers.subserver.%.terminate")) {
|
||||
block = createItem("STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE", (short) 7);
|
||||
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 = createItem("STAINED_GLASS_PANE", "RED_STAINED_GLASS_PANE", (short) 14);
|
||||
block = color(14);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Terminate"));
|
||||
}
|
||||
@ -1024,12 +1040,12 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
inv.setItem(10, block);
|
||||
|
||||
if (!permits(subserver, player, "subservers.subserver.%.*", "subservers.subserver.%.stop")) {
|
||||
block = createItem("STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE", (short) 7);
|
||||
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 = createItem("STAINED_GLASS_PANE", "MAGENTA_STAINED_GLASS_PANE", (short) 2);
|
||||
block = color(2);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Stop"));
|
||||
}
|
||||
@ -1040,12 +1056,12 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
inv.setItem(12, block);
|
||||
|
||||
if (!permits(subserver, player, "subservers.subserver.%.*", "subservers.subserver.%.command")) {
|
||||
block = createItem("STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE", (short) 7);
|
||||
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 = createItem("STAINED_GLASS_PANE", "BLUE_STAINED_GLASS_PANE", (short) 3);
|
||||
block = color(3);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Command"));
|
||||
}
|
||||
@ -1058,16 +1074,16 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
inv.setItem(16, block);
|
||||
} else {
|
||||
if (!permits(subserver, player, "subservers.subserver.%.*", "subservers.subserver.%.start")) {
|
||||
block = createItem("STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE", (short) 7);
|
||||
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 = createItem("STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE", (short) 7);
|
||||
block = color(7);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Start")));
|
||||
} else {
|
||||
block = createItem("STAINED_GLASS_PANE", "LIME_STAINED_GLASS_PANE", (short) 5);
|
||||
block = color(5);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Start"));
|
||||
}
|
||||
@ -1089,16 +1105,16 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
inv.setItem(12, block);
|
||||
|
||||
if (!permits(subserver, player, "subservers.subserver.%.*", "subservers.subserver.%.update")) {
|
||||
block = createItem("STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE", (short) 7);
|
||||
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 = createItem("STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE", (short) 7);
|
||||
block = color(7);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Update")));
|
||||
} else {
|
||||
block = createItem("STAINED_GLASS_PANE", "YELLOW_STAINED_GLASS_PANE", (short) 4);
|
||||
block = color(4);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Update"));
|
||||
}
|
||||
@ -1115,7 +1131,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
if (!host.isAvailable() || !host.isEnabled() || !subserver.isAvailable() || !subserver.isEnabled() || subserverPlugins.size() <= 0) {
|
||||
block = div;
|
||||
} else {
|
||||
block = createItem("STAINED_GLASS_PANE", "BLUE_STAINED_GLASS_PANE", (short) 11);
|
||||
block = color(11);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Plugins"));
|
||||
block.setItemMeta(blockMeta);
|
||||
@ -1124,7 +1140,8 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
inv.setItem(28, block);
|
||||
|
||||
if (subserver.isRunning()) {
|
||||
block = (subserver.getStopAction() == SubServer.StopAction.REMOVE_SERVER || subserver.getStopAction() == SubServer.StopAction.RECYCLE_SERVER || subserver.getStopAction() == SubServer.StopAction.DELETE_SERVER)?createItem("STAINED_GLASS_PANE", "BLUE_STAINED_GLASS_PANE", (short) 11):createItem("STAINED_GLASS_PANE", "LIME_STAINED_GLASS_PANE", (short) 5);
|
||||
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()))
|
||||
@ -1137,7 +1154,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
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 = createItem("STAINED_GLASS_PANE", "YELLOW_STAINED_GLASS_PANE", (short) 4);
|
||||
block = color(4);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(ChatColor.YELLOW + subserver.getDisplayName());
|
||||
LinkedList<String> lore = new LinkedList<String>();
|
||||
@ -1147,7 +1164,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
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 = createItem("STAINED_GLASS_PANE", "RED_STAINED_GLASS_PANE", (short) 14);
|
||||
block = color(14);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(ChatColor.RED + subserver.getDisplayName());
|
||||
LinkedList<String> lore = new LinkedList<String>();
|
||||
@ -1171,7 +1188,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
inv.setItem(32, block);
|
||||
|
||||
if (hasHistory()) {
|
||||
block = createItem("STAINED_GLASS_PANE", "RED_STAINED_GLASS_PANE", (short) 14);
|
||||
block = color(14);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.Generic.Back"));
|
||||
block.setItemMeta(blockMeta);
|
||||
@ -1205,7 +1222,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
|
||||
ItemStack block;
|
||||
ItemMeta blockMeta;
|
||||
ItemStack div = createItem("STAINED_GLASS_PANE", "BLACK_STAINED_GLASS_PANE", (short) 15);
|
||||
ItemStack div = color(15);
|
||||
ItemMeta divMeta = div.getItemMeta();
|
||||
divMeta.setDisplayName(ChatColor.RESET.toString());
|
||||
div.setItemMeta(divMeta);
|
||||
@ -1217,7 +1234,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
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()));
|
||||
block = createItem("STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE", (short) 7);
|
||||
block = color(7);
|
||||
block.setItemMeta(divMeta);
|
||||
while (i < area) {
|
||||
inv.setItem(i, block);
|
||||
@ -1245,7 +1262,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
}
|
||||
|
||||
if (renderers.size() == 0) {
|
||||
block = createItem("STAINED_GLASS_PANE", "RED_STAINED_GLASS_PANE", (short) 14);
|
||||
block = color(14);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.SubServer-Plugin.No-Plugins"));
|
||||
block.setItemMeta(blockMeta);
|
||||
@ -1262,7 +1279,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
i = inv.getSize() - 9;
|
||||
|
||||
if (min != 0) {
|
||||
block = createItem("STAINED_GLASS_PANE", "YELLOW_STAINED_GLASS_PANE", (short) 4);
|
||||
block = color(4);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.Generic.Back-Arrow"));
|
||||
block.setItemMeta(blockMeta);
|
||||
@ -1271,7 +1288,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
} else i += 2;
|
||||
i++;
|
||||
if (hasHistory()) {
|
||||
block = createItem("STAINED_GLASS_PANE", "RED_STAINED_GLASS_PANE", (short) 14);
|
||||
block = color(14);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.Generic.Back"));
|
||||
block.setItemMeta(blockMeta);
|
||||
@ -1281,7 +1298,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
i++;
|
||||
}
|
||||
if (renderers.size() - 1 > max) {
|
||||
block = createItem("STAINED_GLASS_PANE", "YELLOW_STAINED_GLASS_PANE", (short) 4);
|
||||
block = color(4);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.Generic.Next-Arrow"));
|
||||
block.setItemMeta(blockMeta);
|
||||
|
@ -215,6 +215,7 @@ public abstract class UIRenderer {
|
||||
* @param def Default to return if unable to parse
|
||||
* @return ItemStack
|
||||
*/
|
||||
@SuppressWarnings({"deprecation", "JavaReflectionMemberAccess"})
|
||||
public ItemStack parseItem(String str, ItemStack def) {
|
||||
final Value<String> item = new Container<String>(str);
|
||||
if (plugin.api.getGameVersion().compareTo(new Version("1.13")) < 0) {
|
||||
@ -222,37 +223,41 @@ public abstract class UIRenderer {
|
||||
// int
|
||||
Matcher matcher = Pattern.compile("(?i)^(\\d+)$").matcher(item.value());
|
||||
if (matcher.find()) {
|
||||
return ItemStack.class.getConstructor(int.class, int.class).newInstance(Integer.parseInt(matcher.group(1)), 1);
|
||||
return new ItemStack(Integer.parseInt(matcher.group(1)), 1);
|
||||
}
|
||||
// int:int
|
||||
matcher.reset();
|
||||
matcher = Pattern.compile("(?i)^(\\d+):(\\d+)$").matcher(item.value());
|
||||
if (matcher.find()) {
|
||||
return ItemStack.class.getConstructor(int.class, int.class, short.class).newInstance(Integer.parseInt(matcher.group(1)), 1, Short.parseShort(matcher.group(2)));
|
||||
return new ItemStack(Integer.parseInt(matcher.group(1)), 1, Short.parseShort(matcher.group(2)));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
// minecraft:name
|
||||
|
||||
if (item.value().toLowerCase().startsWith("minecraft:")) {
|
||||
item.value(item.value().substring(10));
|
||||
} else
|
||||
|
||||
// bukkit:name
|
||||
if (item.value().toLowerCase().startsWith("bukkit:")) {
|
||||
} else if (item.value().toLowerCase().startsWith("bukkit:")) {
|
||||
item.value(item.value().substring(7));
|
||||
|
||||
if (!Util.isException(() -> Material.valueOf(item.value().toUpperCase()))) {
|
||||
return new ItemStack(Material.valueOf(item.value().toUpperCase()), 1);
|
||||
}
|
||||
// Legacy Material Name
|
||||
Matcher matcher = Pattern.compile("(?i)\\W(\\d+)$").matcher(item.value());
|
||||
try {
|
||||
if (matcher.find()) {
|
||||
item.value(item.value().substring(0, item.value().length() - matcher.group().length()));
|
||||
return new ItemStack(Material.valueOf(item.value().toUpperCase()), 1, Short.parseShort(matcher.group(1)));
|
||||
} else {
|
||||
return new ItemStack(Material.valueOf(item.value().toUpperCase()), 1);
|
||||
}
|
||||
} catch (IllegalArgumentException e) {}
|
||||
}
|
||||
|
||||
// material name
|
||||
// Material Name
|
||||
if (plugin.api.getGameVersion().compareTo(new Version("1.13")) < 0) {
|
||||
if (!Util.isException(() -> Material.valueOf(item.value().toUpperCase()))) {
|
||||
try {
|
||||
return new ItemStack(Material.valueOf(item.value().toUpperCase()), 1);
|
||||
}
|
||||
} catch (IllegalArgumentException e) {}
|
||||
} else try {
|
||||
if (Material.class.getMethod("getMaterial", String.class, boolean.class).invoke(null, item.value().toUpperCase(), false) != null) {
|
||||
return new ItemStack((Material) Material.class.getMethod("getMaterial", String.class, boolean.class).invoke(null, item.value().toUpperCase(), false), 1);
|
||||
|
@ -250,13 +250,13 @@ public final class ExProxy extends BungeeCommon implements Listener {
|
||||
|
||||
private void post() {
|
||||
if (!config.get().getMap("Settings").getRawStringList("Disabled-Overrides", Collections.emptyList()).contains("/server"))
|
||||
getPluginManager().registerCommand(plugin, SubCommand.BungeeServer.newInstance(this, "server").value());
|
||||
getPluginManager().registerCommand(plugin, new SubCommand.BungeeServer(this, "server"));
|
||||
if (!config.get().getMap("Settings").getRawStringList("Disabled-Overrides", Collections.emptyList()).contains("/glist"))
|
||||
getPluginManager().registerCommand(plugin, new SubCommand.BungeeList(this, "glist"));
|
||||
|
||||
getPluginManager().registerCommand(plugin, SubCommand.newInstance(this, "subservers").value());
|
||||
getPluginManager().registerCommand(plugin, SubCommand.newInstance(this, "subserver").value());
|
||||
getPluginManager().registerCommand(plugin, SubCommand.newInstance(this, "sub").value());
|
||||
getPluginManager().registerCommand(plugin, new SubCommand(this, "subservers"));
|
||||
getPluginManager().registerCommand(plugin, new SubCommand(this, "subserver"));
|
||||
getPluginManager().registerCommand(plugin, new SubCommand(this, "sub"));
|
||||
GalaxiCommand.group(SubCommand.class);
|
||||
|
||||
if (getReconnectHandler() != null && getReconnectHandler().getClass().equals(SmartFallback.class))
|
||||
|
@ -13,7 +13,6 @@ import net.ME1312.Galaxi.Library.Util;
|
||||
import net.ME1312.Galaxi.Library.Version.Version;
|
||||
import net.ME1312.SubData.Client.SubDataClient;
|
||||
import net.ME1312.SubData.Client.SubDataSender;
|
||||
import net.ME1312.SubServers.Bungee.Library.Compatibility.CommandX;
|
||||
import net.ME1312.SubServers.Bungee.Library.Compatibility.Galaxi.GalaxiInfo;
|
||||
import net.ME1312.SubServers.Client.Common.Network.API.*;
|
||||
import net.ME1312.SubServers.Client.Common.Network.Packet.PacketCreateServer;
|
||||
@ -34,6 +33,7 @@ import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
import net.md_5.bungee.api.plugin.TabExecutor;
|
||||
import net.md_5.bungee.command.ConsoleCommandSender;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
@ -48,7 +48,7 @@ import static net.ME1312.SubServers.Bungee.Library.Compatibility.Galaxi.GalaxiCo
|
||||
import static net.ME1312.SubServers.Bungee.Library.Compatibility.Galaxi.GalaxiCommand.help;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public final class SubCommand extends CommandX {
|
||||
public final class SubCommand extends Command implements TabExecutor {
|
||||
static HashMap<UUID, HashMap<ServerInfo, Pair<Long, Boolean>>> permitted = new HashMap<UUID, HashMap<ServerInfo, Pair<Long, Boolean>>>();
|
||||
private TreeMap<String, Proxy> proxyCache = new TreeMap<String, Proxy>();
|
||||
private TreeMap<String, Host> hostCache = new TreeMap<String, Host>();
|
||||
@ -58,17 +58,7 @@ public final class SubCommand extends CommandX {
|
||||
private ExProxy plugin;
|
||||
private String label;
|
||||
|
||||
static Pair<SubCommand, CommandX> newInstance(ExProxy plugin, String command) {
|
||||
Pair<SubCommand, CommandX> cmd = new ContainedPair<>(new SubCommand(plugin, command), null);
|
||||
CommandX now = cmd.key();
|
||||
//if (plugin.api.getGameVersion()[plugin.api.getGameVersion().length - 1].compareTo(new Version("1.13")) >= 0) { // TODO Future Command Validator API?
|
||||
// now = new net.ME1312.SubServers.Sync.Library.Compatibility.mc1_13.CommandX(cmd.name());
|
||||
//}
|
||||
cmd.value(now);
|
||||
return cmd;
|
||||
}
|
||||
|
||||
private SubCommand(ExProxy plugin, String command) {
|
||||
SubCommand(ExProxy plugin, String command) {
|
||||
super(command);
|
||||
this.plugin = plugin;
|
||||
this.label = '/' + command;
|
||||
@ -967,14 +957,14 @@ public final class SubCommand extends CommandX {
|
||||
* @return The validator's response and list of possible arguments
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Pair<String, List<String>> suggestArguments(CommandSender sender, String[] args) {
|
||||
public List<String> onTabComplete(CommandSender sender, String[] args) {
|
||||
String Last = (args.length > 0)?args[args.length - 1]:"";
|
||||
String last = Last.toLowerCase();
|
||||
|
||||
if (plugin.api.getSubDataNetwork()[0] == null) {
|
||||
if (sender instanceof ConsoleCommandSender)
|
||||
new IllegalStateException("SubData is not connected").printStackTrace();
|
||||
return new ContainedPair<>(null, Collections.emptyList());
|
||||
return Collections.emptyList();
|
||||
} else if (sender instanceof ProxiedPlayer && (!permitted.keySet().contains(((ProxiedPlayer) sender).getUniqueId()) || !permitted.get(((ProxiedPlayer) sender).getUniqueId()).keySet().contains(((ProxiedPlayer) sender).getServer().getInfo())
|
||||
|| !permitted.get(((ProxiedPlayer) sender).getUniqueId()).get(((ProxiedPlayer) sender).getServer().getInfo()).value())) {
|
||||
if (permitted.keySet().contains(((ProxiedPlayer) sender).getUniqueId()) && permitted.get(((ProxiedPlayer) sender).getUniqueId()).keySet().contains(((ProxiedPlayer) sender).getServer().getInfo())
|
||||
@ -995,7 +985,7 @@ public final class SubCommand extends CommandX {
|
||||
}));
|
||||
}
|
||||
}
|
||||
return new ContainedPair<>(null, Collections.emptyList());
|
||||
return Collections.emptyList();
|
||||
} else if (args.length <= 1) {
|
||||
List<String> cmds = new ArrayList<>();
|
||||
cmds.addAll(Arrays.asList("help", "list", "info", "status", "version", "start", "restart", "stop", "kill", "terminate", "cmd", "command", "create", "update", "upgrade"));
|
||||
@ -1007,7 +997,7 @@ public final class SubCommand extends CommandX {
|
||||
for (String cmd : cmds) {
|
||||
if (cmd.startsWith(last)) list.add(Last + cmd.substring(last.length()));
|
||||
}
|
||||
return new ContainedPair<>((list.size() <= 0)?plugin.api.getLang("SubServers", "Command.Generic.Invalid-Subcommand").replace("$str$", args[0]):null, list);
|
||||
return list;
|
||||
} else {
|
||||
if (args[0].equals("info") || args[0].equals("status")) {
|
||||
ReturnRunnable<Collection<String>> getPlayers = () -> {
|
||||
@ -1056,7 +1046,7 @@ public final class SubCommand extends CommandX {
|
||||
if (!list.contains(player) && player.toLowerCase().startsWith(last))
|
||||
list.add(Last + player.substring(last.length()));
|
||||
}
|
||||
return new ContainedPair<>((list.size() <= 0)?plugin.api.getLang("SubServers", "Command.Info.Unknown").replace("$str$", args[0]):null, list);
|
||||
return list;
|
||||
} else if (args.length == 3) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
|
||||
@ -1100,16 +1090,16 @@ public final class SubCommand extends CommandX {
|
||||
}
|
||||
break;
|
||||
}
|
||||
return new ContainedPair<>((list.size() <= 0)?plugin.api.getLang("SubServers", "Command.Info.Unknown").replace("$str$", args[0]):null, list);
|
||||
return list;
|
||||
} else {
|
||||
return new ContainedPair<>(null, Collections.emptyList());
|
||||
return Collections.emptyList();
|
||||
}
|
||||
} else if (!(sender instanceof ProxiedPlayer) && (args[0].equals("restore"))) {
|
||||
/* if (args[0].equals("restore")) */ {
|
||||
if (args.length == 2) {
|
||||
return new ContainedPair<>(null, Collections.singletonList("<Subserver>"));
|
||||
return Collections.singletonList("<Subserver>");
|
||||
} else {
|
||||
return new ContainedPair<>(null, Collections.emptyList());
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
} else if (args[0].equals("start") ||
|
||||
@ -1135,7 +1125,7 @@ public final class SubCommand extends CommandX {
|
||||
if (Arrays.binarySearch(select.selection, name.toLowerCase()) < 0 && name.toLowerCase().startsWith(last)) list.add(Last + name.substring(last.length()));
|
||||
}
|
||||
}
|
||||
return new ContainedPair<>((list.size() <= 0)?plugin.api.getLang("SubServers", "Command.Generic.Unknown-Host").replace("$str$", select.last):null, list);
|
||||
return list;
|
||||
} else if (last.startsWith(":")) {
|
||||
Map<String, List<Server>> groups = groupCache;
|
||||
if (groups.size() > 0) {
|
||||
@ -1146,7 +1136,7 @@ public final class SubCommand extends CommandX {
|
||||
if (Arrays.binarySearch(select.selection, group.toLowerCase()) < 0 && group.toLowerCase().startsWith(last)) list.add(Last + group.substring(last.length()));
|
||||
}
|
||||
}
|
||||
return new ContainedPair<>((list.size() <= 0)?plugin.api.getLang("SubServers", "Command.Generic.Unknown-Group").replace("$str$", select.last):null, list);
|
||||
return list;
|
||||
} else {
|
||||
Map<String, ServerImpl> subservers = plugin.servers;
|
||||
if (subservers.size() > 0) {
|
||||
@ -1156,32 +1146,32 @@ public final class SubCommand extends CommandX {
|
||||
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()));
|
||||
}
|
||||
}
|
||||
return new ContainedPair<>((list.size() <= 0)?plugin.api.getLang("SubServers", "Command.Generic.Unknown-SubServer").replace("$str$", select.last):null, list);
|
||||
return list;
|
||||
}
|
||||
} else if (args[0].equals("cmd") || args[0].equals("command")) {
|
||||
if (select.args.length == 3) {
|
||||
return new ContainedPair<>(null, Collections.singletonList("<Command>"));
|
||||
return Collections.singletonList("<Command>");
|
||||
} else {
|
||||
return new ContainedPair<>(null, Collections.singletonList("[Args...]"));
|
||||
return Collections.singletonList("[Args...]");
|
||||
}
|
||||
} else if (args[0].equals("update") || args[0].equals("upgrade")) {
|
||||
if (select.args.length == 3) {
|
||||
return new ContainedPair<>(null, Arrays.asList("[Template]", "[Version]"));
|
||||
return Arrays.asList("[Template]", "[Version]");
|
||||
} else if (select.args.length == 4) {
|
||||
return new ContainedPair<>(null, Collections.singletonList("<Version>"));
|
||||
return Collections.singletonList("<Version>");
|
||||
}
|
||||
}
|
||||
return new ContainedPair<>(null, Collections.emptyList());
|
||||
return Collections.emptyList();
|
||||
} else if (args[0].equals("create")) {
|
||||
updateCache();
|
||||
if (args.length == 2) {
|
||||
return new ContainedPair<>(null, Collections.singletonList("<Name>"));
|
||||
return Collections.singletonList("<Name>");
|
||||
} else if (args.length == 3) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
for (Host host : hostCache.values()) {
|
||||
if (host.getName().toLowerCase().startsWith(last)) list.add(Last + host.getName().substring(last.length()));
|
||||
}
|
||||
return new ContainedPair<>((list.size() <= 0)?plugin.api.getLang("SubServers", "Command.Generic.Unknown-Host").replace("$str$", args[0]):null, list);
|
||||
return list;
|
||||
} else if (args.length == 4) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
Map<String, Host> hosts = hostCache;
|
||||
@ -1192,18 +1182,18 @@ public final class SubCommand extends CommandX {
|
||||
if (template.getName().toLowerCase().startsWith(last)) list.add(Last + template.getName().substring(last.length()));
|
||||
}
|
||||
}
|
||||
return new ContainedPair<>((list.size() <= 0)?plugin.api.getLang("SubServers", "Command.Creator.Invalid-Template").replace("$str$", args[0]):null, list);
|
||||
return list;
|
||||
} else if (args.length == 5) {
|
||||
return new ContainedPair<>(null, Collections.singletonList("[Version]"));
|
||||
return Collections.singletonList("[Version]");
|
||||
} else if (args.length == 6) {
|
||||
if (last.length() > 0) {
|
||||
if (Util.isException(() -> Integer.parseInt(last)) || Integer.parseInt(last) <= 0 || Integer.parseInt(last) > 65535) {
|
||||
return new ContainedPair<>(plugin.api.getLang("SubServers", "Command.Creator.Invalid-Port"), Collections.emptyList());
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
return new ContainedPair<>(null, Collections.singletonList("[Port]"));
|
||||
return Collections.singletonList("[Port]");
|
||||
} else {
|
||||
return new ContainedPair<>(null, Collections.emptyList());
|
||||
return Collections.emptyList();
|
||||
}
|
||||
} else if (sender instanceof ProxiedPlayer && (args[0].equals("tp") || args[0].equals("teleport"))) {
|
||||
if (args.length == 2 || args.length == 3) {
|
||||
@ -1232,12 +1222,12 @@ public final class SubCommand extends CommandX {
|
||||
for (ServerImpl server : plugin.servers.values()) {
|
||||
if (server.getName().toLowerCase().startsWith(last)) list.add(Last + server.getName().substring(last.length()));
|
||||
}
|
||||
return new ContainedPair<>((list.size() <= 0)?plugin.api.getLang("SubServers", "Command.Generic.Unknown-Server").replace("$str$", args[0]):null, list);
|
||||
return list;
|
||||
} else {
|
||||
return new ContainedPair<>(null, Collections.emptyList());
|
||||
return Collections.emptyList();
|
||||
}
|
||||
} else {
|
||||
return new ContainedPair<>(plugin.api.getLang("SubServers", "Command.Generic.Invalid-Subcommand").replace("$str$", args[0]), Collections.emptyList());
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1427,9 +1417,9 @@ public final class SubCommand extends CommandX {
|
||||
* BungeeCord /server
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static final class BungeeServer extends CommandX {
|
||||
public static final class BungeeServer extends Command implements TabExecutor {
|
||||
private ExProxy plugin;
|
||||
private BungeeServer(ExProxy plugin, String command) {
|
||||
BungeeServer(ExProxy plugin, String command) {
|
||||
super(command, "bungeecord.command.server");
|
||||
this.plugin = plugin;
|
||||
|
||||
@ -1444,16 +1434,6 @@ public final class SubCommand extends CommandX {
|
||||
);
|
||||
}
|
||||
|
||||
static Pair<BungeeServer, CommandX> newInstance(ExProxy plugin, String command) {
|
||||
Pair<BungeeServer, CommandX> cmd = new ContainedPair<>(new BungeeServer(plugin, command), null);
|
||||
CommandX now = cmd.key();
|
||||
//if (plugin.api.getGameVersion()[plugin.api.getGameVersion().length - 1].compareTo(new Version("1.13")) >= 0) { // TODO Future Command Validator API?
|
||||
// now = new net.ME1312.SubServers.Sync.Library.Compatibility.mc1_13.CommandX(cmd.name());
|
||||
//}
|
||||
cmd.value(now);
|
||||
return cmd;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override /server
|
||||
*
|
||||
@ -1510,7 +1490,7 @@ public final class SubCommand extends CommandX {
|
||||
* @param args Arguments
|
||||
* @return The validator's response and list of possible arguments
|
||||
*/
|
||||
public Pair<String, List<String>> suggestArguments(CommandSender sender, String[] args) {
|
||||
public List<String> onTabComplete(CommandSender sender, String[] args) {
|
||||
if (plugin.lang != null && args.length <= 1) {
|
||||
String last = (args.length > 0)?args[args.length - 1].toLowerCase():"";
|
||||
List<String> list = new ArrayList<String>();
|
||||
@ -1518,15 +1498,15 @@ public final class SubCommand extends CommandX {
|
||||
for (ServerImpl server : plugin.servers.values()) {
|
||||
if (!server.isHidden()) list.add(server.getName());
|
||||
}
|
||||
return new ContainedPair<>(null, new LinkedList<>(list));
|
||||
return list;
|
||||
} else {
|
||||
for (ServerImpl server : plugin.servers.values()) {
|
||||
if (server.getName().toLowerCase().startsWith(last) && !server.isHidden()) list.add(server.getName());
|
||||
}
|
||||
return new ContainedPair<>((list.size() <= 0)?plugin.api.getLang("SubServers", "Bungee.Server.Invalid").replace("$str$", args[0]):null, list);
|
||||
return list;
|
||||
}
|
||||
} else {
|
||||
return new ContainedPair<>(null, Collections.emptyList());
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1534,7 +1514,6 @@ public final class SubCommand extends CommandX {
|
||||
/**
|
||||
* BungeeCord /glist
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static final class BungeeList extends Command {
|
||||
private ExProxy plugin;
|
||||
BungeeList(ExProxy plugin, String command) {
|
||||
|
Loading…
Reference in New Issue
Block a user