2016-12-20 00:31:01 +01:00
|
|
|
package net.ME1312.SubServers.Client.Bukkit.Graphic;
|
2018-08-12 23:23:21 +02:00
|
|
|
|
2020-11-14 08:07:25 +01:00
|
|
|
import net.ME1312.Galaxi.Library.Container.ContainedPair;
|
2020-06-12 07:45:49 +02:00
|
|
|
import net.ME1312.Galaxi.Library.Container.Container;
|
2019-04-18 16:02:09 +02:00
|
|
|
import net.ME1312.Galaxi.Library.Util;
|
|
|
|
import net.ME1312.Galaxi.Library.Version.Version;
|
2020-11-16 21:34:59 +01:00
|
|
|
import net.ME1312.SubServers.Client.Bukkit.SubPlugin;
|
2020-11-14 06:29:29 +01:00
|
|
|
import net.ME1312.SubServers.Client.Common.Network.API.Host;
|
|
|
|
import net.ME1312.SubServers.Client.Common.Network.API.SubServer;
|
2020-11-16 21:34:59 +01:00
|
|
|
|
2016-12-20 00:31:01 +01:00
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.ChatColor;
|
2017-12-07 18:22:36 +01:00
|
|
|
import org.bukkit.Material;
|
2020-06-26 01:47:30 +02:00
|
|
|
import org.bukkit.entity.Player;
|
2017-12-07 18:22:36 +01:00
|
|
|
import org.bukkit.inventory.ItemStack;
|
2016-12-20 00:31:01 +01:00
|
|
|
|
|
|
|
import java.util.*;
|
2017-12-07 18:22:36 +01:00
|
|
|
import java.util.regex.Matcher;
|
|
|
|
import java.util.regex.Pattern;
|
2016-12-20 00:31:01 +01:00
|
|
|
|
2017-01-21 17:49:37 +01:00
|
|
|
/**
|
|
|
|
* GUI Renderer Layout Class
|
|
|
|
*/
|
|
|
|
public abstract class UIRenderer {
|
2021-06-07 09:22:57 +02:00
|
|
|
private final boolean USE_TITLES;
|
|
|
|
private final boolean TAPI_1_11;
|
|
|
|
private final boolean TAPI_PLUGIN;
|
|
|
|
|
2020-06-12 07:45:49 +02:00
|
|
|
static HashMap<String, PluginRenderer<Host>> hostPlugins = new HashMap<String, PluginRenderer<Host>>();
|
|
|
|
static HashMap<String, PluginRenderer<SubServer>> subserverPlugins = new HashMap<String, PluginRenderer<SubServer>>();
|
2021-06-07 09:22:57 +02:00
|
|
|
private ContainedPair<String, Integer> tdownload = null;
|
2017-12-07 18:22:36 +01:00
|
|
|
private int download = -1;
|
2017-01-21 17:49:37 +01:00
|
|
|
private final UUID player;
|
2016-12-20 00:31:01 +01:00
|
|
|
private SubPlugin plugin;
|
2017-01-08 20:42:40 +01:00
|
|
|
|
|
|
|
/**
|
2017-01-21 17:49:37 +01:00
|
|
|
* Creates a new UIRenderer
|
|
|
|
*
|
|
|
|
* @param plugin SubPlugin
|
|
|
|
* @param player Player
|
2017-01-08 20:42:40 +01:00
|
|
|
*/
|
2017-01-21 17:49:37 +01:00
|
|
|
public UIRenderer(SubPlugin plugin, UUID player) {
|
2017-01-30 21:22:36 +01:00
|
|
|
if (Util.isNull(plugin, player)) throw new NullPointerException();
|
2016-12-20 00:31:01 +01:00
|
|
|
this.plugin = plugin;
|
|
|
|
this.player = player;
|
2021-06-07 09:22:57 +02:00
|
|
|
|
|
|
|
// Detect Title API
|
|
|
|
if (USE_TITLES = plugin.config.get().getMap("Settings").getBoolean("Use-Title-Messages", true)) {
|
|
|
|
if (TAPI_1_11 = plugin.api.getGameVersion().compareTo(new Version("1.11")) >= 0) {
|
|
|
|
TAPI_PLUGIN = false;
|
|
|
|
} else {
|
|
|
|
TAPI_PLUGIN = Bukkit.getPluginManager().getPlugin("TitleAPI") != null;
|
|
|
|
}
|
|
|
|
} else{
|
|
|
|
TAPI_1_11 = TAPI_PLUGIN = false;
|
|
|
|
}
|
2016-12-20 00:31:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Opens a new window
|
|
|
|
*/
|
2017-01-21 17:49:37 +01:00
|
|
|
public abstract void newUI();
|
2016-12-20 00:31:01 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Clears the Window History
|
|
|
|
*/
|
2017-01-21 17:49:37 +01:00
|
|
|
public abstract void clearHistory();
|
2016-12-20 00:31:01 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If there is any Window History
|
|
|
|
*
|
|
|
|
* @return Window History Status
|
|
|
|
*/
|
2017-01-21 17:49:37 +01:00
|
|
|
public abstract boolean hasHistory();
|
2016-12-20 00:31:01 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Reopens the current window
|
|
|
|
*/
|
2017-01-21 17:49:37 +01:00
|
|
|
public abstract void reopen();
|
2016-12-20 00:31:01 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Reopens the previous window
|
|
|
|
*/
|
2017-01-21 17:49:37 +01:00
|
|
|
public abstract void back();
|
2016-12-20 00:31:01 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Attempt to send a Title Message
|
|
|
|
*
|
|
|
|
* @param str Message
|
|
|
|
* @return Success Status
|
|
|
|
*/
|
|
|
|
public boolean sendTitle(String str) {
|
|
|
|
return sendTitle(str, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Attempt to send a Title Message
|
|
|
|
*
|
|
|
|
* @param str Message
|
|
|
|
* @param stay How long the message should stay
|
|
|
|
* @return Success Status
|
|
|
|
*/
|
|
|
|
public boolean sendTitle(String str, int stay) {
|
|
|
|
return sendTitle(str, -1, stay, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Attempt to send a Title Message
|
|
|
|
*
|
|
|
|
* @param str Message
|
2017-12-07 18:22:36 +01:00
|
|
|
* @param fadein FadeIn Transition length (in ticks)
|
|
|
|
* @param stay How long the message should stay (in ticks)
|
|
|
|
* @param fadeout FadeOut Transition length (in ticks)
|
2016-12-20 00:31:01 +01:00
|
|
|
* @return Success Status
|
|
|
|
*/
|
|
|
|
public boolean sendTitle(String str, int fadein, int stay, int fadeout) {
|
2021-06-07 09:22:57 +02:00
|
|
|
if (USE_TITLES) {
|
2016-12-20 00:31:01 +01:00
|
|
|
String line1, line2;
|
2021-06-07 09:22:57 +02:00
|
|
|
if (str == null) {
|
|
|
|
line1 = line2 = null;
|
2016-12-20 00:31:01 +01:00
|
|
|
} else {
|
2021-06-07 09:22:57 +02:00
|
|
|
if (!str.contains("\n")) {
|
|
|
|
line1 = str;
|
|
|
|
line2 = ChatColor.RESET.toString();
|
|
|
|
} else if (str.startsWith("\n")) {
|
|
|
|
line1 = str.replace("\n", "");
|
|
|
|
line2 = ChatColor.RESET.toString();
|
|
|
|
} else {
|
|
|
|
String[] arr = str.split("\\n", 2);
|
|
|
|
line1 = arr[0];
|
|
|
|
line2 = arr[1];
|
|
|
|
}
|
2016-12-20 00:31:01 +01:00
|
|
|
}
|
|
|
|
try {
|
2020-06-26 01:47:30 +02:00
|
|
|
Player player = Bukkit.getPlayer(this.player);
|
2021-06-07 09:22:57 +02:00
|
|
|
if (player != null) {
|
|
|
|
if (TAPI_1_11) {
|
|
|
|
if (str == null) {
|
|
|
|
player.resetTitle();
|
|
|
|
} else {
|
|
|
|
player.sendTitle(line1, line2, (fadein >= 0)?fadein:10, (stay >= 0)?stay:70, (fadeout >= 0)?fadeout:20);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
} else if (TAPI_PLUGIN) {
|
|
|
|
if (str == null) {
|
|
|
|
com.connorlinfoot.titleapi.TitleAPI.clearTitle(player);
|
|
|
|
} else {
|
|
|
|
com.connorlinfoot.titleapi.TitleAPI.sendTitle(player, (fadein >= 0)?fadein:10, (stay >= 0)?stay:70, (fadeout >= 0)?fadeout:20, line1, line2);
|
|
|
|
}
|
|
|
|
return true;
|
2020-06-26 01:47:30 +02:00
|
|
|
}
|
2021-06-07 09:22:57 +02:00
|
|
|
}
|
2016-12-20 00:31:01 +01:00
|
|
|
} catch (Throwable e) {
|
|
|
|
return false;
|
|
|
|
}
|
2021-06-07 09:22:57 +02:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* See if Title Messages are available for use
|
|
|
|
*
|
|
|
|
* @return Title Message Availability
|
|
|
|
*/
|
|
|
|
public boolean canSendTitle() {
|
|
|
|
return USE_TITLES && (TAPI_1_11 || TAPI_PLUGIN);
|
2016-12-20 00:31:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows/Hides the Downloading Title Message
|
|
|
|
*
|
|
|
|
* @param subtitle Subtitle to display (or null to hide)
|
|
|
|
*/
|
|
|
|
public void setDownloading(String subtitle) {
|
2021-06-07 09:22:57 +02:00
|
|
|
if (subtitle != null && !canSendTitle()) {
|
2017-12-07 18:22:36 +01:00
|
|
|
if (download != -1) Bukkit.getScheduler().cancelTask(download);
|
|
|
|
download = Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> {
|
2018-01-02 23:29:25 +01:00
|
|
|
if (tdownload != null) Bukkit.getPlayer(player).sendMessage(plugin.api.getLang("SubServers", "Interface.Generic.Downloading").replace("$str$", subtitle));
|
2017-12-07 18:22:36 +01:00
|
|
|
download = -1;
|
2017-10-07 18:49:36 +02:00
|
|
|
}, 50L);
|
2017-04-03 19:08:00 +02:00
|
|
|
} if (subtitle != null && tdownload == null) {
|
2020-11-14 08:07:25 +01:00
|
|
|
tdownload = new ContainedPair<String, Integer>(subtitle, 0);
|
2021-06-07 09:22:57 +02:00
|
|
|
final Container<Integer> delay = new Container<Integer>(0);
|
|
|
|
|
|
|
|
String word = ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.Generic.Downloading.Title"));
|
|
|
|
String a = plugin.api.getLang("SubServers", "Interface.Generic.Downloading.Title-Color-Alt");
|
|
|
|
String b = plugin.api.getLang("SubServers", "Interface.Generic.Downloading.Title-Color");
|
2016-12-20 00:31:01 +01:00
|
|
|
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
2017-04-03 19:08:00 +02:00
|
|
|
if (tdownload != null) {
|
2016-12-20 00:31:01 +01:00
|
|
|
int i = 0;
|
2021-06-07 09:22:57 +02:00
|
|
|
int start = Math.max(tdownload.value - 3, 0);
|
|
|
|
int end = Math.min(tdownload.value, word.length());
|
|
|
|
StringBuilder s = new StringBuilder((delay.value > 7 && start == 0)?a:b);
|
|
|
|
++delay.value;
|
|
|
|
if (delay.value > 7) ++tdownload.value;
|
|
|
|
if (tdownload.value >= word.length() + 3) {
|
|
|
|
tdownload.value = 0;
|
|
|
|
delay.value = 0;
|
2016-12-20 00:31:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
for (char c : word.toCharArray()) {
|
2021-06-07 09:22:57 +02:00
|
|
|
++i;
|
|
|
|
if (i == start) s.append(a);
|
|
|
|
s.append(c);
|
|
|
|
if (i == end) s.append(b);
|
2016-12-20 00:31:01 +01:00
|
|
|
}
|
|
|
|
|
2021-06-07 09:22:57 +02:00
|
|
|
s.append('\n');
|
|
|
|
s.append(a);
|
|
|
|
s.append(tdownload.key);
|
|
|
|
if (sendTitle(s.toString(), 0, 10, 5)) {
|
|
|
|
Bukkit.getScheduler().runTaskLater(plugin, this, 1);
|
|
|
|
}
|
2016-12-20 00:31:01 +01:00
|
|
|
} else {
|
2021-06-07 09:22:57 +02:00
|
|
|
sendTitle(null);
|
2016-12-20 00:31:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else if (subtitle != null) {
|
2021-06-07 09:22:57 +02:00
|
|
|
tdownload.key = subtitle;
|
2017-04-24 19:16:57 +02:00
|
|
|
} else {
|
|
|
|
if (tdownload != null) {
|
|
|
|
tdownload = null;
|
|
|
|
}
|
2017-12-07 18:22:36 +01:00
|
|
|
if (download != -1) {
|
|
|
|
Bukkit.getScheduler().cancelTask(download);
|
|
|
|
download = -1;
|
2017-04-24 19:16:57 +02:00
|
|
|
}
|
2016-12-20 00:31:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-07 18:22:36 +01:00
|
|
|
/**
|
|
|
|
* Parse an ItemStack from a String
|
|
|
|
*
|
|
|
|
* @param str String to parse
|
|
|
|
* @return ItemStack
|
|
|
|
*/
|
|
|
|
public ItemStack parseItem(String str) {
|
|
|
|
return parseItem(str, new ItemStack(Material.AIR));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Parse an ItemStack from a String
|
|
|
|
*
|
|
|
|
* @param str String to parse
|
|
|
|
* @param def Default to return if unable to parse
|
|
|
|
* @return ItemStack
|
|
|
|
*/
|
2021-03-08 18:02:28 +01:00
|
|
|
@SuppressWarnings({"deprecation", "JavaReflectionMemberAccess"})
|
2017-12-07 18:22:36 +01:00
|
|
|
public ItemStack parseItem(String str, ItemStack def) {
|
2021-06-07 09:22:57 +02:00
|
|
|
final Container<String> item = new Container<String>(str);
|
2017-12-07 18:22:36 +01:00
|
|
|
if (plugin.api.getGameVersion().compareTo(new Version("1.13")) < 0) {
|
|
|
|
try {
|
|
|
|
// int
|
2021-06-07 09:22:57 +02:00
|
|
|
Matcher matcher = Pattern.compile("(?i)^(\\d+)$").matcher(item.value);
|
2017-12-07 18:22:36 +01:00
|
|
|
if (matcher.find()) {
|
2021-03-08 18:02:28 +01:00
|
|
|
return new ItemStack(Integer.parseInt(matcher.group(1)), 1);
|
2017-12-07 18:22:36 +01:00
|
|
|
}
|
|
|
|
// int:int
|
|
|
|
matcher.reset();
|
2021-06-07 09:22:57 +02:00
|
|
|
matcher = Pattern.compile("(?i)^(\\d+):(\\d+)$").matcher(item.value);
|
2017-12-07 18:22:36 +01:00
|
|
|
if (matcher.find()) {
|
2021-03-08 18:02:28 +01:00
|
|
|
return new ItemStack(Integer.parseInt(matcher.group(1)), 1, Short.parseShort(matcher.group(2)));
|
2017-12-07 18:22:36 +01:00
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
}
|
2021-03-08 18:02:28 +01:00
|
|
|
|
2021-06-07 09:22:57 +02:00
|
|
|
if (item.value.toLowerCase().startsWith("minecraft:")) {
|
|
|
|
item.value(item.value.substring(10));
|
|
|
|
} else if (item.value.toLowerCase().startsWith("bukkit:")) {
|
|
|
|
item.value(item.value.substring(7));
|
2018-07-15 20:07:22 +02:00
|
|
|
|
2021-03-08 18:02:28 +01:00
|
|
|
// Legacy Material Name
|
2021-06-07 09:22:57 +02:00
|
|
|
Matcher matcher = Pattern.compile("(?i)\\W(\\d+)$").matcher(item.value);
|
2021-03-08 18:02:28 +01:00
|
|
|
try {
|
|
|
|
if (matcher.find()) {
|
2021-06-07 09:22:57 +02:00
|
|
|
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)));
|
2021-03-08 18:02:28 +01:00
|
|
|
} else {
|
2021-06-07 09:22:57 +02:00
|
|
|
return new ItemStack(Material.valueOf(item.value.toUpperCase()), 1);
|
2021-03-08 18:02:28 +01:00
|
|
|
}
|
|
|
|
} catch (IllegalArgumentException e) {}
|
2017-12-07 18:22:36 +01:00
|
|
|
}
|
2018-07-15 20:07:22 +02:00
|
|
|
|
2021-03-08 18:02:28 +01:00
|
|
|
// Material Name
|
2018-07-15 20:07:22 +02:00
|
|
|
if (plugin.api.getGameVersion().compareTo(new Version("1.13")) < 0) {
|
2021-03-08 18:02:28 +01:00
|
|
|
try {
|
2021-06-07 09:22:57 +02:00
|
|
|
return new ItemStack(Material.valueOf(item.value.toUpperCase()), 1);
|
2021-03-08 18:02:28 +01:00
|
|
|
} catch (IllegalArgumentException e) {}
|
2018-07-15 20:07:22 +02:00
|
|
|
} else try {
|
2021-06-07 09:22:57 +02:00
|
|
|
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);
|
2018-07-15 20:07:22 +02:00
|
|
|
}
|
|
|
|
} catch (Exception e) {}
|
|
|
|
|
2017-12-07 18:22:36 +01:00
|
|
|
return def;
|
|
|
|
}
|
|
|
|
|
2016-12-27 17:03:19 +01:00
|
|
|
/**
|
|
|
|
* Add Host Plugin
|
|
|
|
*
|
|
|
|
* @param handle Handle to bind
|
|
|
|
* @param renderer Renderer
|
|
|
|
*/
|
2018-08-12 23:23:21 +02:00
|
|
|
public static void addHostPlugin(String handle, PluginRenderer<Host> renderer) {
|
2017-01-30 21:22:36 +01:00
|
|
|
if (Util.isNull(handle, renderer)) throw new NullPointerException();
|
2016-12-27 17:03:19 +01:00
|
|
|
hostPlugins.put(handle, renderer);
|
|
|
|
}
|
|
|
|
|
2017-01-21 17:49:37 +01:00
|
|
|
/**
|
|
|
|
* Get Host Plugins
|
|
|
|
*
|
|
|
|
* @return Host Plugins
|
|
|
|
*/
|
2018-08-12 23:23:21 +02:00
|
|
|
public static Map<String, PluginRenderer> getHostPlugins() {
|
|
|
|
return new HashMap<String, PluginRenderer>(hostPlugins);
|
2017-01-21 17:49:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove Host Plugin
|
|
|
|
*
|
|
|
|
* @param handle Handle
|
|
|
|
*/
|
|
|
|
public static void removeHostPlugin(String handle) {
|
2017-01-30 21:22:36 +01:00
|
|
|
if (Util.isNull(handle)) throw new NullPointerException();
|
2017-01-21 17:49:37 +01:00
|
|
|
hostPlugins.remove(handle);
|
|
|
|
}
|
|
|
|
|
2016-12-27 17:03:19 +01:00
|
|
|
/**
|
|
|
|
* Add SubServer Plugin
|
|
|
|
*
|
|
|
|
* @param handle Handle to bind
|
|
|
|
* @param renderer Renderer
|
|
|
|
*/
|
2018-08-12 23:23:21 +02:00
|
|
|
public static void addSubServerPlugin(String handle, PluginRenderer<SubServer> renderer) {
|
2017-01-30 21:22:36 +01:00
|
|
|
if (Util.isNull(handle, renderer)) throw new NullPointerException();
|
2016-12-27 17:03:19 +01:00
|
|
|
subserverPlugins.put(handle, renderer);
|
|
|
|
}
|
|
|
|
|
2016-12-20 00:31:01 +01:00
|
|
|
/**
|
2017-01-21 17:49:37 +01:00
|
|
|
* Get SubServer Plugins
|
2016-12-20 00:31:01 +01:00
|
|
|
*
|
2017-01-21 17:49:37 +01:00
|
|
|
* @return SubServer Plugins
|
2016-12-20 00:31:01 +01:00
|
|
|
*/
|
2018-08-12 23:23:21 +02:00
|
|
|
public static Map<String, PluginRenderer> getSubServerPlugins() {
|
|
|
|
return new HashMap<String, PluginRenderer>(subserverPlugins);
|
2017-01-21 17:49:37 +01:00
|
|
|
}
|
2016-12-20 00:31:01 +01:00
|
|
|
|
2017-01-21 17:49:37 +01:00
|
|
|
/**
|
|
|
|
* Remove SubServer Plugin
|
|
|
|
*
|
|
|
|
* @param handle Handle
|
|
|
|
*/
|
|
|
|
public static void removeSubServerPlugin(String handle) {
|
2017-01-30 21:22:36 +01:00
|
|
|
if (Util.isNull(handle)) throw new NullPointerException();
|
2017-01-21 17:49:37 +01:00
|
|
|
subserverPlugins.remove(handle);
|
2016-12-20 00:31:01 +01:00
|
|
|
}
|
|
|
|
|
2017-01-21 17:49:37 +01:00
|
|
|
/**
|
|
|
|
* Opens the Host Menu
|
|
|
|
*
|
|
|
|
* @param page Page Number (starting from page 1)
|
|
|
|
*/
|
|
|
|
public abstract void hostMenu(int page);
|
|
|
|
|
2016-12-20 00:31:01 +01:00
|
|
|
/**
|
2016-12-24 05:55:17 +01:00
|
|
|
* Opens Host/<name>
|
2016-12-20 00:31:01 +01:00
|
|
|
*
|
|
|
|
* @param host Host Name
|
|
|
|
*/
|
2017-01-21 17:49:37 +01:00
|
|
|
public abstract void hostAdmin(String host);
|
2016-12-20 00:31:01 +01:00
|
|
|
|
|
|
|
/**
|
2016-12-24 05:55:17 +01:00
|
|
|
* Opens Host/<name>/Create
|
2016-12-20 00:31:01 +01:00
|
|
|
*
|
|
|
|
* @param options Creator Options
|
|
|
|
*/
|
2017-01-21 17:49:37 +01:00
|
|
|
public abstract void hostCreator(CreatorOptions options);
|
2016-12-20 00:31:01 +01:00
|
|
|
|
2017-01-21 17:49:37 +01:00
|
|
|
/**
|
|
|
|
* Opens Host/<name>/Plugins
|
|
|
|
*
|
|
|
|
* @param host Host Name
|
|
|
|
*/
|
|
|
|
public abstract void hostPlugin(int page, String host);
|
2016-12-20 00:31:01 +01:00
|
|
|
|
2017-08-26 07:19:59 +02:00
|
|
|
/**
|
|
|
|
* Opens the Group Menu
|
|
|
|
*
|
|
|
|
* @param page Page Number (starting from page 1)
|
|
|
|
*/
|
|
|
|
public abstract void groupMenu(int page);
|
|
|
|
|
2017-01-21 17:49:37 +01:00
|
|
|
/**
|
|
|
|
* Opens the SubServer Menu
|
|
|
|
*
|
|
|
|
* @param page Page Number (starting from page 1)
|
|
|
|
* @param host Host Name (or null to scan all hosts)
|
|
|
|
*/
|
2017-08-26 07:19:59 +02:00
|
|
|
public abstract void serverMenu(int page, String host, String group);
|
2016-12-20 00:31:01 +01:00
|
|
|
|
2017-01-21 17:49:37 +01:00
|
|
|
/**
|
|
|
|
* Opens SubServer/<name>
|
|
|
|
*
|
|
|
|
* @param server SubServer Name
|
|
|
|
*/
|
|
|
|
public abstract void subserverAdmin(String server);
|
2016-12-20 00:31:01 +01:00
|
|
|
|
2017-01-21 17:49:37 +01:00
|
|
|
/**
|
|
|
|
* Opens SubServer/<name>/Plugins
|
|
|
|
*
|
|
|
|
* @param server SubServer Name
|
|
|
|
*/
|
|
|
|
public abstract void subserverPlugin(int page, String server);
|
2016-12-20 00:31:01 +01:00
|
|
|
|
2017-01-21 17:49:37 +01:00
|
|
|
/**
|
|
|
|
* Options Layout Class
|
|
|
|
*/
|
|
|
|
public abstract static class Options {
|
|
|
|
List<Runnable> history = new LinkedList<Runnable>();
|
|
|
|
private boolean init = false;
|
2016-12-20 00:31:01 +01:00
|
|
|
|
2017-01-21 17:49:37 +01:00
|
|
|
public boolean init() {
|
|
|
|
if (!init) {
|
|
|
|
init = true;
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2016-12-20 00:31:01 +01:00
|
|
|
|
2017-01-21 17:49:37 +01:00
|
|
|
/**
|
|
|
|
* If there is any undo history
|
|
|
|
*
|
|
|
|
* @return Undo History Status
|
|
|
|
*/
|
|
|
|
public boolean hasHistory() {
|
|
|
|
return !history.isEmpty();
|
|
|
|
}
|
2016-12-20 00:31:01 +01:00
|
|
|
|
2017-01-21 17:49:37 +01:00
|
|
|
/**
|
|
|
|
* Reverts the last change
|
|
|
|
*/
|
|
|
|
public void undo() {
|
|
|
|
Runnable lastWindow = history.get(history.size() - 1);
|
|
|
|
history.remove(history.size() - 1);
|
|
|
|
lastWindow.run();
|
|
|
|
}
|
2016-12-20 00:31:01 +01:00
|
|
|
}
|
2017-01-08 20:42:40 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* SubCreator Options Class
|
|
|
|
*/
|
2016-12-20 00:31:01 +01:00
|
|
|
public static class CreatorOptions extends Options {
|
|
|
|
private String host;
|
|
|
|
private String name = null;
|
2017-05-29 07:00:02 +02:00
|
|
|
private String template = null;
|
2016-12-20 00:31:01 +01:00
|
|
|
private Version version = null;
|
2018-10-08 23:07:44 +02:00
|
|
|
private Integer port = null;
|
2016-12-20 00:31:01 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Grabs a raw CreatorOptions instance
|
|
|
|
*
|
|
|
|
* @param host Host Name
|
|
|
|
*/
|
|
|
|
public CreatorOptions(String host) {
|
|
|
|
this.host = host;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the Host Name
|
|
|
|
*
|
|
|
|
* @return Host Name
|
|
|
|
*/
|
|
|
|
public String getHost() {
|
|
|
|
return this.host;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the Server Name
|
|
|
|
*
|
|
|
|
* @return Server Name
|
|
|
|
*/
|
|
|
|
public String getName() {
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the Server Name
|
|
|
|
*
|
|
|
|
* @param value Value
|
|
|
|
*/
|
|
|
|
public void setName(String value) {
|
2017-01-30 21:22:36 +01:00
|
|
|
if (Util.isNull(value)) throw new NullPointerException();
|
2016-12-20 00:31:01 +01:00
|
|
|
final String name = this.name;
|
|
|
|
history.add(() -> this.name = name);
|
|
|
|
this.name = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-05-29 07:00:02 +02:00
|
|
|
* Gets the Template
|
2016-12-20 00:31:01 +01:00
|
|
|
*
|
2017-05-29 07:00:02 +02:00
|
|
|
* @return Template
|
2016-12-20 00:31:01 +01:00
|
|
|
*/
|
2017-05-29 07:00:02 +02:00
|
|
|
public String getTemplate() {
|
|
|
|
return template;
|
2016-12-20 00:31:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-05-29 07:00:02 +02:00
|
|
|
* Sets the Template
|
2016-12-20 00:31:01 +01:00
|
|
|
*
|
|
|
|
* @param value Value
|
|
|
|
*/
|
2017-05-29 07:00:02 +02:00
|
|
|
public void setTemplate(String value) {
|
2017-01-30 21:22:36 +01:00
|
|
|
if (Util.isNull(value)) throw new NullPointerException();
|
2017-05-29 07:00:02 +02:00
|
|
|
final String template = this.template;
|
|
|
|
history.add(() -> this.template = template);
|
|
|
|
this.template = value;
|
2016-12-20 00:31:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the Server Version
|
|
|
|
*
|
|
|
|
* @return Server Version
|
|
|
|
*/
|
|
|
|
public Version getVersion() {
|
|
|
|
return version;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the Server Version
|
|
|
|
*
|
|
|
|
* @param value Value
|
|
|
|
*/
|
|
|
|
public void setVersion(Version value) {
|
|
|
|
final Version version = this.version;
|
|
|
|
history.add(() -> this.version = version);
|
|
|
|
this.version = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the Port Number for the Server
|
|
|
|
*
|
2018-10-08 23:07:44 +02:00
|
|
|
* @return Server Port Number (null for auto-select)
|
2016-12-20 00:31:01 +01:00
|
|
|
*/
|
2018-10-08 23:07:44 +02:00
|
|
|
public Integer getPort() {
|
2016-12-20 00:31:01 +01:00
|
|
|
return port;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the Port Number for the Server
|
|
|
|
*
|
2018-10-08 23:07:44 +02:00
|
|
|
* @param value Value (null for auto-select)
|
2016-12-20 00:31:01 +01:00
|
|
|
*/
|
2018-10-08 23:07:44 +02:00
|
|
|
public void setPort(Integer value) {
|
2019-05-09 22:17:15 +02:00
|
|
|
final Integer port = this.port;
|
2016-12-20 00:31:01 +01:00
|
|
|
history.add(() -> this.port = port);
|
|
|
|
this.port = value;
|
|
|
|
}
|
|
|
|
}
|
2017-01-21 17:49:37 +01:00
|
|
|
}
|